Initial Commit. The packaging still does not work properly.
[confmgr] / config.h
diff --git a/config.h b/config.h
new file mode 100644 (file)
index 0000000..7b5e232
--- /dev/null
+++ b/config.h
@@ -0,0 +1,71 @@
+#ifndef CONFIG_H\r
+#define CONFIG_H\r
+\r
+#include <QObject>\r
+#include <QList>\r
+#include <QFile>\r
+#include <QtXml/QDomDocument>\r
+#include "profile.h"\r
+\r
+#define APPLICATION_NAME "ConfManager"\r
+//#define CONFIG_DIR "/apps/Maemo/" APPLICATION_NAME "/"\r
+\r
+// For test only!\r
+#define CONFIG_DIR "./"\r
+\r
+#define CONFIG_FILE CONFIG_DIR "cfConfig.xml"\r
+#define BACKUP_CONFIG_FILE CONFIG_DIR "cfConfig.bak"\r
+\r
+#define DEFAULT_XML "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Profiles NoOfProfiles=\"0\">\r\n</Profiles>"\r
+\r
+class Config : public QObject\r
+{\r
+    Q_OBJECT\r
+public:\r
+    explicit Config(QObject *parent = 0);\r
+\r
+    // Close the config file\r
+    ~Config() { closeConfig(); }\r
+\r
+    // Return 0 if everything okay else a negative integer\r
+    int addProfile(const Profile &p);\r
+    int removeProfile(const Profile &p);\r
+\r
+    // Write back all the changes to the disk\r
+    void flushConfig();\r
+\r
+    // Read all the profiles from config file\r
+    bool readAllProfiles();\r
+    // Writes all the profiles from the list to the config file\r
+    // Similar to flushConfig(), flushConfig will internally call\r
+    // writeAllProfiles()\r
+    bool writeAllProfiles();\r
+    // Similar to deletion of config file. Never to be used!\r
+    bool removeAllProfiles();\r
+\r
+    // get-set for noOfProfiles\r
+    void setNoOfProfiles(const int &no) { noOfProfiles = no; }\r
+    int getNoOfProfiles() { return noOfProfiles; }\r
+\r
+    QList<Profile> profileList;\r
+\r
+    bool openConfig();\r
+\r
+    // Called by flush and\r
+    bool closeConfig();\r
+\r
+private:\r
+\r
+    void updateNoOfProfiles();\r
+\r
+    QFile confFile;\r
+    QDomDocument domDoc;\r
+    int noOfProfiles;\r
+\r
+signals:\r
+\r
+public slots:\r
+\r
+};\r
+\r
+#endif // CONFIG_H\r