root/src/config.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#ifndef CONFIG_H
#define CONFIG_H

#include <QString>
#include <QDir>
#include "nwutils.h"
#include "videoclipcreator.h"
#include "gifcreator.h"

class MplayerConfig {
public:
    void describe(nw::Describer*de);
    QString path;
    QStringList arguments;
private:
    bool needsInit();
    void setDefaultValues();
};

class SnapshotConfig {
public:
    void describe(nw::Describer& de);
    QString snapshotDir;
    QString snapshotFormat;
    QString snapshotName;
    qint8 snapshotQuality;

private:
    bool needsInit();
    void setDefaultValues();
    QString createSaveDir(const QString parentDir, const QString dirname);
};

class RssConfig {
public:
    RssConfig();
    void describe(nw::Describer& de);
    bool autoDownload;
    bool requireFavouriteReleaseGroup;
    bool includeEnglish;
    bool includeRaw;
};

// I am consequently calling it avconv instead of ffmpeg,
// because the debian package maintainers managed to fool me that ffmpeg
// is deprecated and not just forked, now I don't want to change it everywhere.
class AvconvConfig {
public:
    QString command;
    static AvconvConfig detectCommand();
private:
    AvconvConfig(QString command);
};

class BaseConfig
{
public:
    BaseConfig(int argc, char* argv[]);
    BaseConfig(QString initPath);
    void fromArgs(int argc, char* argv[]);

    bool init(QString path = QString());
    bool parse(const QString &jsonData);
    bool createNewConfig(QString filepath);
    void describe(nw::Describer *de);

    QString libraryPath();
    int serverPort() const;

    QDir configPath() const;
    QString malConfigFilePath() const;
    QString anilistConfigFilePath() const;

    QString mplayerLocation();
    QString omxplayerLocation();
    bool omxPlayerIsInstalled();
    bool mplayerIsInstalled();

    std::pair<ShortClipCreator *, ShortClipCreator::Config *> cloneGifShortClipCreator() const;
    std::pair<ShortClipCreator *, ShortClipCreator::Config *> cloneWebmShortClipCreator() const;
    const SnapshotConfig& getSnapshotConfigConstRef() const;
    const MplayerConfig& getMplayerConfigConstRef() const;
    const RssConfig& getRssConfigConstRef() const;
    const AvconvConfig& getAvconvConfigConstRef() const;

    bool getNoGui() const;
    bool getFullScreen() const;
    bool getAutoOpenBrowser() const;

    const VideoClipCreator::Config& getVideoClipCreatorConfig() const;
    const GifCreator::Config& getGifCreatorConfig() const;
private:
    QString mConfigPath;
    QString mLibraryPath;
    QString shortClipCreatorType;

    int mServerPort;
    bool noGui;
    bool fullScreen;
    bool autoOpenBrowser;

    bool initialized;

    SnapshotConfig snapshotConfig;
    MplayerConfig mplayerConfig;
    RssConfig rssConfig;
    AvconvConfig avconvConfig;

    VideoClipCreator::Config videoClipCreatorConfig;
    GifCreator::Config gifCreatorConfig;

    void setDefaults();
};

#endif // CONFIG_H