User interface update
[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 #include <QUrl>
9
10 class ConnectionSettings;
11 class StartupSettings;
12 class DisplaySettings;
13 class Room;
14 class QDomNode;
15 class DateTimeSettings;
16
17 //! Domain class. Store application wide configuration values.
18 /*!
19  * Domain class. Store application wide configuration values. The values are read from a configuration
20  * file at initialization time. Since there is one appliation per device normally running, therefore
21  * there is only one instance of this class, which is accessible by using a statis getter method.
22  */
23 class Configuration: public QObject {
24 Q_OBJECT
25
26 private:
27         //! Constructor.
28         /*!
29          * Constructor to initialize an Configuration instance. The method populates the object by reading
30          * through the application's configuration file.
31          */
32         Configuration();
33
34 public:
35         //! Destructor
36         virtual ~Configuration();
37
38         //! Static. Gets the application wide configuration instance.
39         /*!
40          * Static Gets the static instance of this class. It is used to read the configuration information.
41          * \return Pointer to the Configuration instalce.
42          */
43         static Configuration* instance();
44         //! Gets the connection settings.
45         /*!
46          * Gets the connection settings.
47          * \return Pointer to ConnectionSettings instance.
48          */
49         //ConnectionSettings* connectionSettings();
50         /**
51          * Returns the current server URL
52          */
53         QUrl getServerUrl();
54         /**
55          * Returns the current username
56          */
57         QString getUsername();
58         /**
59          * Returns the current users password
60          */
61         QString getPassword();
62         /**
63          * Returns the refresh interval
64          */
65         unsigned int getRefreshinterval();
66         /**
67          * Sets the current server URL
68          */
69         void setServerUrl(QUrl serverUrl);
70         /**
71          * Sets the current username
72          */
73         void setUsername(QString username);
74         /**
75          * Sets the current users password
76          */
77         void setPassword(QString password);
78         /**
79          * Sets the refresh interval
80          */
81         void setRefreshinterval(unsigned int refreshinterval);
82         //! Gets the detault room.
83         /*!
84          * Gets the default meeting room.
85          * \return Pointer to the default room.
86          */
87         Room* defaultRoom();
88         //! Gets the language code.
89         /*!
90          * Gets the language code.
91          * \return Language code in ISO 3166-1 alpha-2 format.
92          */
93         QString languageCode();
94         //! Gets the list of meeting rooms.
95         /*!
96          * Gets the list of meeting rooms.
97          * \return List of rooms.
98          */
99         QList<Room*> rooms();
100         //! Gets startup settings.
101         /*!
102          * Gets the startup settings.
103          * \return Pointer to StartupSettings instance.
104          */
105         StartupSettings* startupSettings();
106         //! Gets display settings.
107         /*!
108          * Gets the display settings.
109          * \return Pointer to DisplaySettings instance.
110          */
111         DisplaySettings* displaySettings();
112         //! Gets date/time settings.
113         /*!
114          * Gets the date/time settings.
115          * \return Pointer to DateTimeSettings instance.
116          */
117         DateTimeSettings* dateTimeSettings();
118         //! Gets the administrator's password.
119         /*!
120          * Gets the administrator's password
121          * \return Administration password.
122          */
123         QByteArray adminPassword();
124         //! Sets room list.
125         /*!
126          * Sets  room list.
127          * \param aRooms List of rooms
128          */
129         void setRooms(const QList<Room*> aRooms);
130
131 signals:
132         void configurationChanged();
133
134 public slots:
135
136         //! Saves setting values to file.
137         /*!
138          * Writes setting values to configuration file.
139          */
140         void save();
141
142 private:
143         //! Static. Reads the configuration instance from XML file.
144         /*!
145          * Static. Reads the configuration information from configuration file.
146          * \param aPath path and name of configuration file
147          * \return Configuration object.
148          */
149         void readFromXML(const QString &aPath);
150         //! Static. Reads settings of connection from and XML node.
151         /*!
152          * Static. Reads settings of connection from an XML node.
153          * \param aXml QDomNode containing connection parameters.
154          * \return Pointer to ConnectionSettings object.
155          */
156         static ConnectionSettings* readConnectionSettings(const QDomNode &aXML);
157         //! Static. Reads rooms from an XML node.
158         /*!
159          * Static. Reads rooms from an XML node.
160          * \param aXml QDomNode containing meeting room parameters
161          * \return List of meetingrooms.
162          */
163         static QList<Room*> readRooms(const QDomNode &aXML);
164         //! Static. Reads language code from an XML node.
165         /*!
166          * Static. Reads rooms from an XML node.
167          * \param aXml QDomNode containing language code
168          * \return Language code.
169          */
170         static QString readLanguageCode(const QDomNode &aXML);
171         //! Static. Reads settings of startup from an XML node.
172         /*!
173          * Static. Reads settings of startup from an XML node.
174          * \param aXml QDomNode containing startup parameters
175          * \return Pointer to the read StartupSettings object.
176          */
177         static StartupSettings* readStartupSettings(const QDomNode &aXML);
178         /*!
179          * Static function to load and store display settings from xml node.
180          * \param aXml QDomNode containing display parameters
181          * \return Pointer to the read DisplaySettings object.
182          */
183         static DisplaySettings* readDisplaySettings(const QDomNode &aXML);
184         //! Static. Reads the date/time settings from an XML node.
185         /*!
186          * Static. Reads the date/time settings from an XML node.
187          * \param aXml QDomNode containing the date/time settings
188          * \return The date/time settings.
189          */
190         static DateTimeSettings* readDateTimeSettings(const QDomNode &aXML);
191
192         //! Static. Reads adminstrator's password from an XML node.
193         /*!
194          * Static. Reads adminstrator's password from an XML node.
195          * \param aXml QDomNode containing admin password
196          * \return Admin password.
197          */
198         static QByteArray readAdminPassword(const QDomNode &aXML);
199
200         //! Saves connection data to the document.
201         /*!
202          * Reads data from iConnectionSettings and saves it to the aXML document.
203          * \param aXml QDomNode containing connection parameters.
204          */
205         void saveConnectionSettings(const QDomNode &aXML);
206         //! Saves meeting rooms to the document.
207         /*!
208          * Reads data from iRooms list and saves it to the aXML document.
209          * \param aXml QDomNode containing meeting room parameters
210          */
211         void saveRooms(const QDomNode &aXML);
212         //! Saves the language code.
213         /*!
214          * Reads data from iLanguageCode and saves it to the aXML document.
215          * \param aXml QDomNode containing language code
216          */
217         void saveLanguageCode(const QDomNode &aXML);
218         //! Saves startup setting data to the document.
219         /*!
220          * Reads data from iStartupSettings and saves it to the aXML document.
221          * \param aXml QDomNode containing startup parameters
222          */
223         void saveStartupSettings(const QDomNode &aXML);
224         //! Saves display setting data to the document.
225         /*!
226          * Reads data from iDisplaySettings and saves it to the aXML document.
227          * \param aXml QDomNode containing display parameters
228          */
229         void saveDisplaySettings(const QDomNode &aXML);
230         //! Saves date/time setting data to the document.
231         /*!
232          * Reads data from iDateTimeSettings and saves it to the aXML document.
233          * \param aXml QDomNode containing the date/time settings
234          */
235         void saveDateTimeSettings(const QDomNode &aXML);
236
237         //! Saves admin password to the document.
238         /*!
239          * Reads data from iAdminPassword and saves it to the aXML document.
240          * \param aXml QDomNode containing admin password
241          */
242         void saveAdminPassword(const QDomNode &aXML);
243
244         //! Hash password with md5 method.
245         /*!
246          * Hash password with md5 method.
247          * \param aPassword password to be encoded
248          * \return Encoded password.
249          */
250         QString hashPassword(const QString aPassword);
251
252 private:
253         //! Path and name of configuration file
254         static QString sConfigurationPath;
255         //! The static instance which is in use to read the configuration.
256         static Configuration *sInstance;
257         //! Static constant to store the default interval used for connection refresh.
258         static const unsigned int sDefaultInterval = 60;
259         //! Pointer to the ConnectionSettings object
260         ConnectionSettings *iConnectionSettings;
261         //! Stores startup settings.
262         StartupSettings *iStartupSettings;
263         //! Stores display settings.
264         DisplaySettings *iDisplaySettings;
265         //! Stores date/time settings.
266         DateTimeSettings *iDateTimeSettings;
267         //! List of meeting rooms.
268         QList<Room*> iRooms;
269         //! Stores administrator password.
270         QByteArray iAdminPassword;
271         //! Stores language code
272         QString iLanguageCode;
273
274 };
275
276 #endif /*CONFIGURATION_H_*/