Initial commit
[tietoopcom] / include / tocsettings.h
1 /** \file TocSettings.h\r
2  * \brief Declaration of TocSettings class\r
3  * \r
4  * Tieto Open Communicator - Client for the Telepathy communications framework.\r
5  * Copyright (c) 2010, Tieto Corporation\r
6  *\r
7  * All rights reserved.\r
8  * Redistribution and use in source and binary forms, with or without modification,\r
9  * are permitted provided that the following conditions are met:\r
10  *\r
11  *      Redistributions of source code must retain the above copyright notice,\r
12  *      this list of conditions and the following disclaimer.\r
13  *      Redistributions in binary form must reproduce the above copyright notice,\r
14  *      this list of conditions and the following disclaimer in the documentation\r
15  *      and/or other materials provided with the distribution.\r
16  *      Neither the name of the Tieto Corporation nor the names of its contributors \r
17  *      may be used to endorse or promote products derived from this software without\r
18  *      specific prior written permission.\r
19  *\r
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r
23  * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
27  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
28  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
29  * \r
30  */\r
31 \r
32 #ifndef TOCSETTINGS_H\r
33 #define TOCSETTINGS_H\r
34 \r
35 #include "defs.h"\r
36 \r
37 #include <QMap>\r
38 #include <QStringList>\r
39 \r
40 enum SortOrder {\r
41         Alphabetical,\r
42         ByStatus,\r
43         None\r
44 };\r
45 \r
46 Q_DECLARE_METATYPE(SortOrder);\r
47 \r
48 enum AuthorizationRule {\r
49         Ask,\r
50         AlwaysAccept,\r
51         AlwaysDeny\r
52 };\r
53 \r
54 Q_DECLARE_METATYPE(AuthorizationRule);\r
55 \r
56 class TocSettings {\r
57 \r
58 public:\r
59 \r
60         /** \brief Static public constructor\r
61          * \r
62          * @return Pointer to the static instance\r
63          */\r
64         static TocSettings* getInstance();\r
65 \r
66         /** \brief Public destructor\r
67          * \r
68          */\r
69         ~TocSettings();\r
70 \r
71         /** \brief Getter for current account name\r
72          * \r
73          * @return Account name\r
74          */\r
75         const QString& accountName();\r
76 \r
77         /** \brief Setter for current account name\r
78          * \r
79          * @param accountName New account name\r
80          */\r
81         void setAccountName(const QString& accountName);\r
82 \r
83         /** \brief Getter for current account uid\r
84          * \r
85          * @return Account uid\r
86          */\r
87         const QString& accountUid();\r
88 \r
89         /** \brief Setter for current account uid\r
90          * \r
91          * @param uid New account uid\r
92          */\r
93         void setAccountUid(const QString& uid);\r
94 \r
95         /** \brief Getter for current account password\r
96          * \r
97          * @return Account password\r
98          */\r
99         const QString& accountPasswd();\r
100 \r
101         /** \brief Setter for current account password\r
102          * \r
103          * @param password New account password\r
104          */\r
105         void setAccountPasswd(const QString& password);\r
106 \r
107         /** \brief Getter for current protocol\r
108          * \r
109          * @return Protocol used\r
110          */\r
111         const QString& protocol();\r
112 \r
113         /** \brief Setter for current protocol\r
114          * \r
115          * @param protocol Protocol name\r
116          */\r
117         void setProtocol(const QString& protocol);\r
118 \r
119         /** \brief Getter for protocol common name\r
120          * \r
121          * @return Protocol common used name\r
122          */\r
123         const QString protocolCommonName();\r
124 \r
125         /** \brief Setter for current protocol by service name\r
126          * \r
127          * @param service Service name\r
128          */\r
129         void setProtocolByName(const QString& service);\r
130 \r
131         /** \brief Getter for available protocols\r
132          * \r
133          * @return Available protocols\r
134          */\r
135         const QStringList& protocols();\r
136 \r
137         /** \brief Setter for availabe protocols\r
138          * \r
139          * @param protocols List of protocols names\r
140          */\r
141         void setProtocols(const QStringList& protocols);\r
142 \r
143         /** \brief Getter for current server\r
144          * \r
145          * @return Server name\r
146          */\r
147         const QString& server();\r
148 \r
149         /** \brief Setter for current server\r
150          * \r
151          * @param server Server name\r
152          */\r
153         void setServer(const QString& server);\r
154 \r
155         /** \brief Getter for currently used port\r
156          * \r
157          * @return Port number\r
158          */\r
159         int port();\r
160 \r
161         /** \brief Setter for currently used port\r
162          * \r
163          * @param port Port number\r
164          */\r
165         void setPort(int port);\r
166 \r
167         /** \brief Getter for `old-ssl` connection property\r
168          * \r
169          * @return True if connection needs `old-ssl` enabled\r
170          */\r
171         bool isOldSslEnabled();\r
172 \r
173         /** \brief Setter for `old-ssl` connection property\r
174          * \r
175          * @param bEnabled True if connection needs `old-ssl` enabled \r
176          */\r
177         void setOldSslEnabled(bool bEnabled);\r
178 \r
179         /** \brief Getter for `ignore-ssl-errors` connection property\r
180          * \r
181          * @return True if connection needs `ignore-ssl-errors` enabled\r
182          */\r
183         bool isIgnoreSslErrorsEnabled();\r
184 \r
185         /** \brief Setter for `ignore-ssl-errors` connection property\r
186          * \r
187          * @param bEnabled True if connection needs `ignore-ssl-errors` enabled \r
188          */\r
189         void setIgnoreSslErrorsEnabled(bool bEnabled);\r
190 \r
191         /** \brief Getter for saved contact list\r
192          * \r
193          * @return List of TocContact's\r
194          */\r
195         TocContactList* contactList();\r
196         \r
197         /** \brief Getter for list of contacts to be added to server\r
198          * \r
199          * @return List of Uids to be added\r
200          */\r
201         QStringList* contactsToAdd();\r
202 \r
203         /** \brief Getter for list of contacts to be removed from server\r
204          * \r
205          * @return List of Uids to be removed\r
206          */\r
207         QStringList* contactsToRemove();\r
208 \r
209         /** \brief Getter for sort order policy\r
210          * \r
211          * @return Sorting order policy\r
212          */\r
213         SortOrder sortOrder();\r
214 \r
215         /** \brief Setter for sort order policy\r
216          * \r
217          * @param sortOrder Sorting order policy\r
218          */\r
219         void setSortOrder(SortOrder sortOrder);\r
220 \r
221         /** \brief Getter for authorization rule\r
222          * \r
223          * @return Authorization rule\r
224          */\r
225         AuthorizationRule authorizationRule();\r
226 \r
227         /** \brief Setter for authorization rule\r
228          * \r
229          * @param rule Authorization rule\r
230          */\r
231         void setAuthorizationRule(AuthorizationRule rule);\r
232 \r
233         /** \brief Getter for current ui theme\r
234          * \r
235          * @return File name of the style sheet file\r
236          */\r
237         const QString& currentTheme();\r
238 \r
239         /** \brief Setter for current ui theme\r
240          * \r
241          * @param theme File name of the style sheet file\r
242          */\r
243         void setCurrentTheme(const QString& theme);\r
244 \r
245         /** \brief Returns a server hint for given data\r
246          * \r
247          * @param uid Account login\r
248          * @param serviceName Common name of the service/protocol (eg. Jabber, Google Talk, SIP)\r
249          * @return Default server for the data\r
250          */\r
251         const QString& serverHint( const QString& uid, const QString& serviceName);\r
252 \r
253         /** \brief Returns a port hint for given data\r
254          * \r
255          * @param uid Account login\r
256          * @param serviceName Common name of the service/protocol (eg. Jabber, Google Talk, SIP)\r
257          * @return Default server for the data\r
258          */\r
259         int portHint( const QString& uid, const QString& serviceName);\r
260 \r
261         /** \brief Returns true if such protocol is already supported\r
262          * \r
263          * @param protocol Protocol to check\r
264          * @return True if protocol already exist\r
265          */\r
266         bool isProtocolInstalled(const QString& protocol);\r
267 \r
268         /** \brief Add a new protocol to the list of supported protocols\r
269          * \r
270          * @param commonName    Protocol's common name\r
271          * @param protocol              Protocol's identifier (according to the Telepathy spec)\r
272          */\r
273         void installProtocol(const QString& commonName, const QString& protocol);\r
274 \r
275         /** \brief One shot getter for the `register` parameter of the connection\r
276          * \r
277          * When it returns the "true" value it sets it immediately to "false".\r
278          * \r
279          * @return true if user wants to register an account instead of logging in\r
280          */\r
281         bool isRegister();\r
282 \r
283         /** \brief Setter for the `register` parameter of the connection\r
284          * \r
285          * When it is invoked it sets the `register` parameter to "true"\r
286          *\r
287          */\r
288         void setRegister();\r
289 \r
290 private:\r
291         \r
292         /** \brief Private constructor\r
293          * \r
294          */\r
295         TocSettings();\r
296 \r
297         /** \brief Used to read settings with QSettings\r
298          * \r
299          *  It's meant to be used only in destructor. That's why it's private. \r
300          */\r
301         void read();\r
302         \r
303         \r
304         /** \brief Used to save settings with QSettings\r
305          * \r
306          *  It's meant to be used only when creating an instance. That's why it's private. \r
307          */\r
308         void save();    \r
309         \r
310         static TocSettings*             _pSelf;\r
311 \r
312         QString                                 _accountName;\r
313         QString                                 _accountUid;\r
314         QString                                 _accountPasswd;\r
315         QString                                 _protocol;\r
316         QStringList                             _protocols;\r
317         QString                                 _protocolCommonName;\r
318         QString                                 _server;\r
319         QString                                 _serverHint;\r
320         int                                             _port;\r
321         int                                             _portHint;\r
322         bool                                    _bOldSsl;\r
323         bool                                    _bIgnoreSslErrors;\r
324         QList<TocContact*>*             _pContactList;\r
325         QStringList                             _addedContacts;\r
326         QStringList                             _removedContacts;\r
327         AuthorizationRule               _authorizationRule;\r
328         SortOrder                               _sortOrder;\r
329         QString                                 _currentTheme;\r
330         QMap<QString, QString>* _pProtocolMap;\r
331         bool                                    _register;\r
332 };\r
333 \r
334 #endif  // TOCSETTINGS_H\r