5cd7e6d3e2e94922719a28ea6d184e0eab9e9961
[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 class DateTimeSettings;
15
16 //! Domain class. Store application wide configuration values.
17 /*!
18  * Domain class. Store application wide configuration values. The values are read from a configuration
19  * file at initialization time. Since there is one appliation per device normally running, therefore
20  * there is only one instance of this class, which is accessible by using a statis getter method.
21  */
22 class Configuration : public QObject
23 {
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         //! Gets the detault room.
51         /*!
52          * Gets the default meeting room.
53          * \return Pointer to the default room.
54          */
55         Room* defaultRoom();
56         //! Gets the language code.
57         /*!
58          * Gets the language code.
59          * \return Language code in ISO 3166-1 alpha-2 format.
60          */
61         QString languageCode();
62         //! Gets the list of meeting rooms.
63         /*!
64          * Gets the list of meeting rooms.
65          * \return List of rooms.
66          */
67         QList<Room*> rooms();
68         //! Gets startup settings.
69         /*!
70          * Gets the startup settings.
71          * \return Pointer to StartupSettings instance.
72          */
73         StartupSettings* startupSettings();
74         //! Gets display settings.
75         /*!
76          * Gets the display settings.
77          * \return Pointer to DisplaySettings instance.
78          */
79         DisplaySettings* displaySettings();
80         //! Gets date/time settings.
81         /*!
82          * Gets the date/time settings.
83          * \return Pointer to DateTimeSettings instance.
84          */
85         DateTimeSettings* dateTimeSettings();
86         //! Gets the administrator's password.
87         /*!
88          * Gets the administrator's password
89          * \return Administration password.
90          */
91         QByteArray adminPassword();
92         //! Sets room list.
93         /*!
94          * Sets  room list.
95          * \param aRooms List of rooms
96          */
97         void setRooms(const QList<Room*> aRooms);
98
99 public slots:
100
101         //! Saves setting values to file.
102         /*!
103          * Writes setting values to configuration file.
104          */
105         void save();
106
107 private:
108         //! Static. Reads the configuration instance from XML file.
109         /*!
110          * Static. Reads the configuration information from configuration file.
111          * \param aPath path and name of configuration file
112          * \return Configuration object.
113          */
114         static Configuration* readFromXML(const QString &aPath);
115         //! Static. Reads settings of connection from and XML node.
116         /*!
117          * Static. Reads settings of connection from an XML node.
118          * \param aXml QDomNode containing connection parameters.
119          * \return Pointer to ConnectionSettings object.
120          */
121         static ConnectionSettings* readConnectionSettings(const QDomNode &aXML);
122         //! Static. Reads rooms from an XML node.
123         /*!
124          * Static. Reads rooms from an XML node.
125          * \param aXml QDomNode containing meeting room parameters
126          * \return List of meetingrooms.
127          */
128         static QList<Room*> readRooms(const QDomNode &aXML);
129         //! Static. Reads language code from an XML node.
130         /*!
131          * Static. Reads rooms from an XML node.
132          * \param aXml QDomNode containing language code
133          * \return Language code.
134          */
135         static QString readLanguageCode(const QDomNode &aXML);
136         //! Static. Reads settings of startup from an XML node.
137         /*!
138          * Static. Reads settings of startup from an XML node.
139          * \param aXml QDomNode containing startup parameters
140          * \return Pointer to the read StartupSettings object.
141          */
142         static StartupSettings* readStartupSettings(const QDomNode &aXML);
143         /*!
144          * Static function to load and store display settings from xml node.
145          * \param aXml QDomNode containing display parameters
146          * \return Pointer to the read DisplaySettings object.
147          */
148         static DisplaySettings* readDisplaySettings(const QDomNode &aXML);
149         //! Static. Reads the date/time settings from an XML node.
150         /*!
151          * Static. Reads the date/time settings from an XML node.
152          * \param aXml QDomNode containing the date/time settings
153          * \return The date/time settings.
154          */
155         static DateTimeSettings* readDateTimeSettings(const QDomNode &aXML);
156
157         //! Static. Reads adminstrator's password from an XML node.
158         /*!
159          * Static. Reads adminstrator's password from an XML node.
160          * \param aXml QDomNode containing admin password
161          * \return Admin password.
162          */
163         static QByteArray readAdminPassword(const QDomNode &aXML);
164
165         //! Saves connection data to the document.
166         /*!
167          * Reads data from iConnectionSettings and saves it to the aXML document.
168          * \param aXml QDomNode containing connection parameters.
169          */
170         void saveConnectionSettings(const QDomNode &aXML);
171         //! Saves meeting rooms to the document.
172         /*!
173          * Reads data from iRooms list and saves it to the aXML document.
174          * \param aXml QDomNode containing meeting room parameters
175          */
176         void saveRooms(const QDomNode &aXML);
177         //! Saves the language code.
178         /*!
179          * Reads data from iLanguageCode and saves it to the aXML document.
180          * \param aXml QDomNode containing language code
181          */
182         void saveLanguageCode(const QDomNode &aXML);
183         //! Saves startup setting data to the document.
184         /*!
185          * Reads data from iStartupSettings and saves it to the aXML document.
186          * \param aXml QDomNode containing startup parameters
187          */
188         void saveStartupSettings(const QDomNode &aXML);
189         //! Saves display setting data to the document.
190         /*!
191          * Reads data from iDisplaySettings and saves it to the aXML document.
192          * \param aXml QDomNode containing display parameters
193          */
194         void saveDisplaySettings(const QDomNode &aXML);
195         //! Saves date/time setting data to the document.
196         /*!
197          * Reads data from iDateTimeSettings and saves it to the aXML document.
198          * \param aXml QDomNode containing the date/time settings
199          */
200         void saveDateTimeSettings(const QDomNode &aXML);
201
202         //! Saves admin password to the document.
203         /*!
204          * Reads data from iAdminPassword and saves it to the aXML document.
205          * \param aXml QDomNode containing admin password
206          */
207         void saveAdminPassword(const QDomNode &aXML);
208
209         //! Hash password with md5 method.
210         /*!
211          * Hash password with md5 method.
212          * \param aPassword password to be encoded
213          * \return Encoded password.
214          */
215         QString hashPassword(const QString aPassword);
216
217 private:
218         //! Path and name of configuration file
219         static QString sConfigurationPath;
220         //! The static instance which is in use to read the configuration.
221         static Configuration *sInstance;
222         //! Static constant to store the default interval used for connection refresh.
223         static const unsigned int sDefaultInterval = 60;
224         //! Pointer to the ConnectionSettings object
225         ConnectionSettings *iConnectionSettings;
226         //! Stores startup settings.
227         StartupSettings *iStartupSettings;
228         //! Stores display settings.
229         DisplaySettings *iDisplaySettings;
230         //! Stores date/time settings.
231         DateTimeSettings *iDateTimeSettings;
232         //! List of meeting rooms.
233         QList<Room*> iRooms;
234         //! Stores administrator password.
235         QByteArray iAdminPassword;
236         //! Stores language code
237         QString iLanguageCode;
238
239 };
240
241 #endif /*CONFIGURATION_H_*/