1 #ifndef CONFIGURATION_H_
2 #define CONFIGURATION_H_
10 class ConnectionSettings;
11 class StartupSettings;
12 class DisplaySettings;
15 class DateTimeSettings;
17 //! Domain class. Store application wide configuration values.
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.
23 class Configuration: public QObject {
29 * Constructor to initialize an Configuration instance. The method populates the object by reading
30 * through the application's configuration file.
36 virtual ~Configuration();
38 //! Static. Gets the application wide configuration instance.
40 * Static Gets the static instance of this class. It is used to read the configuration information.
41 * \return Pointer to the Configuration instalce.
43 static Configuration* instance();
44 //! Gets the connection settings.
46 * Gets the connection settings.
47 * \return Pointer to ConnectionSettings instance.
49 //ConnectionSettings* connectionSettings();
51 * Returns the current server URL
55 * Returns the current username
57 QString getUsername();
59 * Returns the current users password
61 QString getPassword();
63 * Returns the refresh interval
65 unsigned int getRefreshinterval();
67 * Sets the current server URL
69 void setServerUrl(QUrl serverUrl);
71 * Sets the current username
73 void setUsername(QString username);
75 * Sets the current users password
77 void setPassword(QString password);
79 * Sets the refresh interval
81 void setRefreshinterval(unsigned int refreshinterval);
82 //! Gets the detault room.
84 * Gets the default meeting room.
85 * \return Pointer to the default room.
88 //! Gets the language code.
90 * Gets the language code.
91 * \return Language code in ISO 3166-1 alpha-2 format.
93 QString languageCode();
94 //! Gets the list of meeting rooms.
96 * Gets the list of meeting rooms.
97 * \return List of rooms.
100 //! Gets startup settings.
102 * Gets the startup settings.
103 * \return Pointer to StartupSettings instance.
105 StartupSettings* startupSettings();
106 //! Gets display settings.
108 * Gets the display settings.
109 * \return Pointer to DisplaySettings instance.
111 DisplaySettings* displaySettings();
112 //! Gets date/time settings.
114 * Gets the date/time settings.
115 * \return Pointer to DateTimeSettings instance.
117 DateTimeSettings* dateTimeSettings();
118 //! Gets the administrator's password.
120 * Gets the administrator's password
121 * \return Administration password.
123 QByteArray adminPassword();
127 * \param aRooms List of rooms
129 void setRooms(const QList<Room*> aRooms);
132 void configurationChanged();
136 //! Saves setting values to file.
138 * Writes setting values to configuration file.
143 //! Static. Reads the configuration instance from XML file.
145 * Static. Reads the configuration information from configuration file.
146 * \param aPath path and name of configuration file
147 * \return Configuration object.
149 void readFromXML(const QString &aPath);
150 //! Static. Reads settings of connection from and XML node.
152 * Static. Reads settings of connection from an XML node.
153 * \param aXml QDomNode containing connection parameters.
154 * \return Pointer to ConnectionSettings object.
156 static ConnectionSettings* readConnectionSettings(const QDomNode &aXML);
157 //! Static. Reads rooms from an XML node.
159 * Static. Reads rooms from an XML node.
160 * \param aXml QDomNode containing meeting room parameters
161 * \return List of meetingrooms.
163 static QList<Room*> readRooms(const QDomNode &aXML);
164 //! Static. Reads language code from an XML node.
166 * Static. Reads rooms from an XML node.
167 * \param aXml QDomNode containing language code
168 * \return Language code.
170 static QString readLanguageCode(const QDomNode &aXML);
171 //! Static. Reads settings of startup from an XML node.
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.
177 static StartupSettings* readStartupSettings(const QDomNode &aXML);
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.
183 static DisplaySettings* readDisplaySettings(const QDomNode &aXML);
184 //! Static. Reads the date/time settings from an XML node.
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.
190 static DateTimeSettings* readDateTimeSettings(const QDomNode &aXML);
192 //! Static. Reads adminstrator's password from an XML node.
194 * Static. Reads adminstrator's password from an XML node.
195 * \param aXml QDomNode containing admin password
196 * \return Admin password.
198 static QByteArray readAdminPassword(const QDomNode &aXML);
200 //! Saves connection data to the document.
202 * Reads data from iConnectionSettings and saves it to the aXML document.
203 * \param aXml QDomNode containing connection parameters.
205 void saveConnectionSettings(const QDomNode &aXML);
206 //! Saves meeting rooms to the document.
208 * Reads data from iRooms list and saves it to the aXML document.
209 * \param aXml QDomNode containing meeting room parameters
211 void saveRooms(const QDomNode &aXML);
212 //! Saves the language code.
214 * Reads data from iLanguageCode and saves it to the aXML document.
215 * \param aXml QDomNode containing language code
217 void saveLanguageCode(const QDomNode &aXML);
218 //! Saves startup setting data to the document.
220 * Reads data from iStartupSettings and saves it to the aXML document.
221 * \param aXml QDomNode containing startup parameters
223 void saveStartupSettings(const QDomNode &aXML);
224 //! Saves display setting data to the document.
226 * Reads data from iDisplaySettings and saves it to the aXML document.
227 * \param aXml QDomNode containing display parameters
229 void saveDisplaySettings(const QDomNode &aXML);
230 //! Saves date/time setting data to the document.
232 * Reads data from iDateTimeSettings and saves it to the aXML document.
233 * \param aXml QDomNode containing the date/time settings
235 void saveDateTimeSettings(const QDomNode &aXML);
237 //! Saves admin password to the document.
239 * Reads data from iAdminPassword and saves it to the aXML document.
240 * \param aXml QDomNode containing admin password
242 void saveAdminPassword(const QDomNode &aXML);
244 //! Hash password with md5 method.
246 * Hash password with md5 method.
247 * \param aPassword password to be encoded
248 * \return Encoded password.
250 QString hashPassword(const QString aPassword);
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.
269 //! Stores administrator password.
270 QByteArray iAdminPassword;
271 //! Stores language code
272 QString iLanguageCode;
276 #endif /*CONFIGURATION_H_*/