qtmeetings sources to Maemo garage
[qtmeetings] / src / Domain / Configuration / Configuration.h
1 #ifndef CONFIGURATION_H_
2 #define CONFIGURATION_H_
3
4 #include <QObject>
5 #include <QString>
6 #include <QList>
7 #include <QTime>
8
9 class ConnectionSettings;
10 class StartupSettings;
11 class DisplaySettings;
12 class Room;
13 class QDomNode;
14
15 //! Domain class. Store application wide configuration values.
16 /*!
17  * Domain class. Store application wide configuration values. The values are read from a configuration
18  * file at initialization time. Since there is one appliation per device normally running, therefore
19  * there is only one instance of this class, which is accessible by using a statis getter method.
20  */
21 class Configuration : public QObject
22 {
23         Q_OBJECT
24
25 private:
26         //! Constructor.
27         /*!
28          * Constructor to initialize an Configuration instance. The method populates the object by reading
29          * through the application's configuration file.
30          */
31         Configuration();
32
33 public:
34         //! Destructor
35         virtual ~Configuration();
36
37         //! Static. Gets the application wide configuration instance.
38         /*!
39          * Static Gets the static instance of this class. It is used to read the configuration information.
40          * \return Pointer to the Configuration instalce.
41          */
42         static Configuration* instance();
43         //! Gets the connection settings.
44         /*!
45          * Gets the connection settings.
46          * \return Pointer to ConnectionSettings instance.
47          */
48         ConnectionSettings* connectionSettings();
49         //! Gets the detault room.
50         /*!
51          * Gets the default meeting room.
52          * \return Pointer to the default room.
53          */
54         Room* defaultRoom();
55         //! Gets the language code.
56         /*!
57          * Gets the language code.
58          * \return Language code in ISO 3166-1 alpha-2 format.
59          */
60         QString languageCode();
61         //! Gets the list of meeting rooms.
62         /*!
63          * Gets the list of meeting rooms.
64          * \return List of rooms.
65          */
66         QList<Room*> rooms();
67         //! Gets startup settings.
68         /*!
69          * Gets the startup settings.
70          * \return Pointer to StartupSettings instance.
71          */
72         StartupSettings* startupSettings();
73         //! Gets display settings.
74         /*!
75          * Gets the display settings.
76          * \return Pointer to DisplaySettings instance.
77          */
78         DisplaySettings* displaySettings();
79         //! Gets the administrator's password.
80         /*!
81          * Gets the administrator's password
82          * \return Administration password.
83          */
84         QByteArray adminPassword();
85         //! Sets room list.
86         /*!
87          * Sets  room list.
88          * \param aRooms List of rooms
89          */
90         void setRooms( const QList<Room*> aRooms );
91         
92 public slots:
93
94         //! Saves setting values to file.
95         /*!
96          * Writes setting values to configuration file.
97          */
98         void save();
99
100 private:
101         //! Static. Reads the configuration instance from XML file.
102         /*!
103          * Static. Reads the configuration information from configuration file.
104          * \param aPath path and name of configuration file
105          * \return Configuration object.
106          */
107         static Configuration* readFromXML( const QString &aPath );
108         //! Static. Reads settings of connection from and XML node.
109         /*!
110          * Static. Reads settings of connection from an XML node.
111          * \param aXml QDomNode containing connection parameters.
112          * \return Pointer to ConnectionSettings object.
113          */
114         static ConnectionSettings* readConnectionSettings( const QDomNode &aXML );
115         //! Static. Reads rooms from an XML node.
116         /*!
117          * Static. Reads rooms from an XML node.
118          * \param aXml QDomNode containing meeting room parameters
119          * \return List of meetingrooms.
120          */
121         static QList<Room*> readRooms( const QDomNode &aXML );
122         //! Static. Reads language code from an XML node.
123         /*!
124          * Static. Reads rooms from an XML node.
125          * \param aXml QDomNode containing language code
126          * \return Language code.
127          */
128         static QString readLanguageCode( const QDomNode &aXML );
129         //! Static. Reads settings of startup from an XML node.
130         /*!
131          * Static. Reads settings of startup from an XML node.
132          * \param aXml QDomNode containing startup parameters
133          * \return Pointer to the read StartupSettings object.
134          */
135         static StartupSettings* readStartupSettings( const QDomNode &aXML );
136         /*!
137          * Static function to load and store display settings from xml node.
138          * \param aXml QDomNode containing display parameters
139          * \return Pointer to the read DisplaySettings object.
140          */
141         static DisplaySettings* readDisplaySettings( const QDomNode &aXML );
142         //! Static. Reads adminstrator's password from an XML node.
143         /*!
144          * Static. Reads adminstrator's password from an XML node.
145          * \param aXml QDomNode containing admin password
146          * \return Admin password.
147          */
148         static QByteArray readAdminPassword( const QDomNode &aXML );
149
150         //! Saves connection data to the document.
151         /*!
152          * Reads data from iConnectionSettings and saves it to the aXML document.
153          * \param aXml QDomNode containing connection parameters.
154          */
155         void saveConnectionSettings( const QDomNode &aXML );
156         //! Saves meeting rooms to the document.
157         /*!
158          * Reads data from iRooms list and saves it to the aXML document.
159          * \param aXml QDomNode containing meeting room parameters
160          */
161         void saveRooms( const QDomNode &aXML );
162         //! Saves the language code.
163         /*!
164          * Reads data from iLanguageCode and saves it to the aXML document.
165          * \param aXml QDomNode containing language code
166          */
167         void saveLanguageCode( const QDomNode &aXML );
168         //! Saves startup setting data to the document.
169         /*!
170          * Reads data from iStartupSettings and saves it to the aXML document.
171          * \param aXml QDomNode containing startup parameters
172          */
173         void saveStartupSettings( const QDomNode &aXML );
174         //! Saves display setting data to the document.
175         /*!
176          * Reads data from iDisplaySettings and saves it to the aXML document.
177          * \param aXml QDomNode containing display parameters
178          */
179         void saveDisplaySettings( const QDomNode &aXML );
180         //! Saves admin password to the document.
181         /*!
182          * Reads data from iAdminPassword and saves it to the aXML document.
183          * \param aXml QDomNode containing admin password
184          */
185         void saveAdminPassword( const QDomNode &aXML );
186
187         //! Hash password with md5 method.
188         /*!
189          * Hash password with md5 method.
190          * \param aPassword password to be encoded
191          * \return Encoded password.
192          */
193         QString hashPassword( const QString aPassword );
194
195 private:
196         //! Path and name of configuration file
197         static QString sConfigurationPath;
198         //! The static instance which is in use to read the configuration.
199         static Configuration *sInstance;
200         //! Static constant to store the default interval used for connection refresh.
201         static const unsigned int sDefaultInterval = 60;
202         //! Pointer to the ConnectionSettings object
203         ConnectionSettings *iConnectionSettings;
204         //! Stores startup settings.
205         StartupSettings *iStartupSettings;
206         //! Stores display settings.
207         DisplaySettings *iDisplaySettings;
208         //! List of meeting rooms.
209         QList<Room*> iRooms;
210         //! Stores administrator password.
211         QByteArray iAdminPassword;
212         //! Stores language code
213         QString iLanguageCode;
214
215 };
216
217 #endif /*CONFIGURATION_H_*/