Added the .desktop file.
[confmgr] / config.h
1 #ifndef CONFIG_H\r
2 #define CONFIG_H\r
3 \r
4 #include <QObject>\r
5 #include <QList>\r
6 #include <QFile>\r
7 #include <QtXml/QDomDocument>\r
8 #include "profile.h"\r
9 \r
10 #define APPLICATION_NAME "ConfManager"\r
11 //#define CONFIG_DIR "/apps/Maemo/" APPLICATION_NAME "/"\r
12 \r
13 // For test only!\r
14 #define CONFIG_DIR "./"\r
15 \r
16 #define CONFIG_FILE CONFIG_DIR "cfConfig.xml"\r
17 #define BACKUP_CONFIG_FILE CONFIG_DIR "cfConfig.bak"\r
18 \r
19 #define DEFAULT_XML "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Profiles NoOfProfiles=\"0\">\r\n</Profiles>"\r
20 \r
21 class Config : public QObject\r
22 {\r
23     Q_OBJECT\r
24 public:\r
25     explicit Config(QObject *parent = 0);\r
26 \r
27     // Close the config file\r
28     ~Config() { closeConfig(); }\r
29 \r
30     // Return 0 if everything okay else a negative integer\r
31     int addProfile(const Profile &p);\r
32     int removeProfile(const Profile &p);\r
33 \r
34     // Write back all the changes to the disk\r
35     void flushConfig();\r
36 \r
37     // Read all the profiles from config file\r
38     bool readAllProfiles();\r
39     // Writes all the profiles from the list to the config file\r
40     // Similar to flushConfig(), flushConfig will internally call\r
41     // writeAllProfiles()\r
42     bool writeAllProfiles();\r
43     // Similar to deletion of config file. Never to be used!\r
44     bool removeAllProfiles();\r
45 \r
46     // get-set for noOfProfiles\r
47     void setNoOfProfiles(const int &no) { noOfProfiles = no; }\r
48     int getNoOfProfiles() { return noOfProfiles; }\r
49 \r
50     QList<Profile> profileList;\r
51 \r
52     bool openConfig();\r
53 \r
54     // Called by flush and\r
55     bool closeConfig();\r
56 \r
57 private:\r
58 \r
59     void updateNoOfProfiles();\r
60 \r
61     QFile confFile;\r
62     QDomDocument domDoc;\r
63     int noOfProfiles;\r
64 \r
65 signals:\r
66 \r
67 public slots:\r
68 \r
69 };\r
70 \r
71 #endif // CONFIG_H\r