168 lines
3.5 KiB
C++
168 lines
3.5 KiB
C++
#ifndef ALPM_CONFIG_H
|
|
#define ALPM_CONFIG_H
|
|
|
|
#include <c++utilities/application/argumentparser.h>
|
|
|
|
#include <QString>
|
|
#include <QStringList>
|
|
#include <QHostAddress>
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
class QJsonValue;
|
|
QT_END_NAMESPACE
|
|
|
|
namespace PackageManagement {
|
|
|
|
class ConfigArgs
|
|
{
|
|
public:
|
|
ConfigArgs(ApplicationUtilities::ArgumentParser &parser);
|
|
ApplicationUtilities::HelpArgument helpArg;
|
|
ApplicationUtilities::Argument serverArg;
|
|
ApplicationUtilities::Argument repoindexConfArg;
|
|
ApplicationUtilities::Argument rootdirArg;
|
|
ApplicationUtilities::Argument dbpathArg;
|
|
ApplicationUtilities::Argument pacmanConfArg;
|
|
ApplicationUtilities::Argument websocketAddrArg;
|
|
ApplicationUtilities::Argument websocketPortArg;
|
|
ApplicationUtilities::Argument certFileArg;
|
|
ApplicationUtilities::Argument keyFileArg;
|
|
ApplicationUtilities::Argument insecureArg;
|
|
};
|
|
|
|
class Config;
|
|
|
|
class RepoEntry
|
|
{
|
|
friend class Config;
|
|
public:
|
|
const QString &name() const;
|
|
const QString &dbPath() const;
|
|
const QString &srcPath() const;
|
|
const QString &pkgPath() const;
|
|
const QStringList &servers() const;
|
|
void load(const QJsonValue &jsonValue);
|
|
|
|
private:
|
|
QString m_name;
|
|
QString m_dbPath;
|
|
QString m_srcPath;
|
|
QString m_pkgPath;
|
|
QStringList m_servers;
|
|
};
|
|
|
|
inline const QString &RepoEntry::name() const
|
|
{
|
|
return m_name;
|
|
}
|
|
|
|
inline const QString &RepoEntry::dbPath() const
|
|
{
|
|
return m_dbPath;
|
|
}
|
|
|
|
inline const QString &RepoEntry::srcPath() const
|
|
{
|
|
return m_srcPath;
|
|
}
|
|
|
|
inline const QString &RepoEntry::pkgPath() const
|
|
{
|
|
return m_pkgPath;
|
|
}
|
|
|
|
inline const QStringList &RepoEntry::servers() const
|
|
{
|
|
return m_servers;
|
|
}
|
|
|
|
class Config
|
|
{
|
|
public:
|
|
Config();
|
|
|
|
const QString &alpmRootDir() const;
|
|
const QString &alpmDbPath() const;
|
|
const QString &pacmanConfFile() const;
|
|
const QHostAddress &websocketServerListeningAddr() const;
|
|
quint16 websocketServerListeningPort() const;
|
|
const QString &serverCertFile() const;
|
|
const QString &serverKeyFile() const;
|
|
bool serverInsecure() const;
|
|
bool reposFromPacmanConf() const;
|
|
const QList<RepoEntry> &repoEntries() const;
|
|
|
|
void loadFromConfigFile(const QString &args);
|
|
void loadFromConfigFile(const ConfigArgs &args);
|
|
void loadFromArgs(const ConfigArgs &args);
|
|
|
|
private:
|
|
QString m_alpmRootDir;
|
|
QString m_alpmDbPath;
|
|
QString m_pacmanConfFile;
|
|
|
|
QHostAddress m_websocketServerListeningAddr;
|
|
quint16 m_websocketServerListeningPort;
|
|
QString m_serverCertFile;
|
|
QString m_serverKeyFile;
|
|
bool m_serverInsecure;
|
|
|
|
bool m_reposFromPacmanConf;
|
|
QList<RepoEntry> m_repoEntries;
|
|
|
|
};
|
|
|
|
inline const QString &Config::alpmRootDir() const
|
|
{
|
|
return m_alpmRootDir;
|
|
}
|
|
|
|
inline const QString &Config::alpmDbPath() const
|
|
{
|
|
return m_alpmDbPath;
|
|
}
|
|
|
|
inline const QString &Config::pacmanConfFile() const
|
|
{
|
|
return m_pacmanConfFile;
|
|
}
|
|
|
|
inline const QHostAddress &Config::websocketServerListeningAddr() const
|
|
{
|
|
return m_websocketServerListeningAddr;
|
|
}
|
|
|
|
inline quint16 Config::websocketServerListeningPort() const
|
|
{
|
|
return m_websocketServerListeningPort;
|
|
}
|
|
|
|
inline const QString &Config::serverCertFile() const
|
|
{
|
|
return m_serverCertFile;
|
|
}
|
|
|
|
inline const QString &Config::serverKeyFile() const
|
|
{
|
|
return m_serverKeyFile;
|
|
}
|
|
|
|
inline bool Config::serverInsecure() const
|
|
{
|
|
return m_serverInsecure;
|
|
}
|
|
|
|
inline bool Config::reposFromPacmanConf() const
|
|
{
|
|
return m_reposFromPacmanConf;
|
|
}
|
|
|
|
inline const QList<RepoEntry> &Config::repoEntries() const
|
|
{
|
|
return m_repoEntries;
|
|
}
|
|
|
|
} // namespace Alpm
|
|
|
|
#endif // ALPM_CONFIG_H
|