X-Git-Url: http://git.maemo.org/git/?p=confmgr;a=blobdiff_plain;f=src%2Fconfig.h;fp=src%2Fconfig.h;h=7b5e2326366a883cf9e720c45b6ada687c106789;hp=0000000000000000000000000000000000000000;hb=6f0e06a23515e795b75e08161487d60c9fc4f933;hpb=8cdf509abbdb8654def1e0df79e1f607e9a41807 diff --git a/src/config.h b/src/config.h new file mode 100644 index 0000000..7b5e232 --- /dev/null +++ b/src/config.h @@ -0,0 +1,71 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#include +#include +#include +#include +#include "profile.h" + +#define APPLICATION_NAME "ConfManager" +//#define CONFIG_DIR "/apps/Maemo/" APPLICATION_NAME "/" + +// For test only! +#define CONFIG_DIR "./" + +#define CONFIG_FILE CONFIG_DIR "cfConfig.xml" +#define BACKUP_CONFIG_FILE CONFIG_DIR "cfConfig.bak" + +#define DEFAULT_XML "\r\n\r\n" + +class Config : public QObject +{ + Q_OBJECT +public: + explicit Config(QObject *parent = 0); + + // Close the config file + ~Config() { closeConfig(); } + + // Return 0 if everything okay else a negative integer + int addProfile(const Profile &p); + int removeProfile(const Profile &p); + + // Write back all the changes to the disk + void flushConfig(); + + // Read all the profiles from config file + bool readAllProfiles(); + // Writes all the profiles from the list to the config file + // Similar to flushConfig(), flushConfig will internally call + // writeAllProfiles() + bool writeAllProfiles(); + // Similar to deletion of config file. Never to be used! + bool removeAllProfiles(); + + // get-set for noOfProfiles + void setNoOfProfiles(const int &no) { noOfProfiles = no; } + int getNoOfProfiles() { return noOfProfiles; } + + QList profileList; + + bool openConfig(); + + // Called by flush and + bool closeConfig(); + +private: + + void updateNoOfProfiles(); + + QFile confFile; + QDomDocument domDoc; + int noOfProfiles; + +signals: + +public slots: + +}; + +#endif // CONFIG_H