File indexing completed on 2024-11-10 04:40:07

0001 /*
0002  * SPDX-FileCopyrightText: 2008 Igor Trindade Oliveira <igor_trindade@yahoo.com.br>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-or-later
0005  */
0006 
0007 #pragma once
0008 
0009 #include <QHash>
0010 #include <QString>
0011 #include <QStringList>
0012 
0013 class Config
0014 {
0015 public:
0016     Config();
0017     ~Config();
0018     static Config *instance();
0019     static Config *instance(const QString &pathToConfig);
0020     QString xdgDataHome() const;
0021     QString xdgConfigHome() const;
0022     QString basePath() const;
0023     QStringList backends() const;
0024     bool setDbBackend(const QString &backend);
0025     QString dbBackend() const;
0026     QList<QPair<QString, bool>> agents() const;
0027     QHash<QString, QString> envVars() const;
0028 
0029 protected:
0030     void setXdgDataHome(const QString &dataHome);
0031     void setXdgConfigHome(const QString &configHome);
0032     void setBackends(const QStringList &backends);
0033     void insertAgent(const QString &agent, bool sync);
0034 
0035 private:
0036     void readConfiguration(const QString &configFile);
0037 
0038 private:
0039     QString mBasePath;
0040     QString mXdgDataHome;
0041     QString mXdgConfigHome;
0042     QStringList mBackends;
0043     QString mDbBackend;
0044     QList<QPair<QString, bool>> mAgents;
0045     QHash<QString, QString> mEnvVars;
0046 };