1 /** \file TocSettings.h
\r
2 * \brief Declaration of TocSettings class
\r
4 * Tieto Open Communicator - Client for the Telepathy communications framework.
\r
5 * Copyright (c) 2010, Tieto Corporation
\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
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
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
32 #ifndef TOCSETTINGS_H
\r
33 #define TOCSETTINGS_H
\r
38 #include <QStringList>
\r
46 Q_DECLARE_METATYPE(SortOrder);
\r
48 enum AuthorizationRule {
\r
54 Q_DECLARE_METATYPE(AuthorizationRule);
\r
60 /** \brief Static public constructor
\r
62 * @return Pointer to the static instance
\r
64 static TocSettings* getInstance();
\r
66 /** \brief Public destructor
\r
71 /** \brief Getter for current account name
\r
73 * @return Account name
\r
75 const QString& accountName();
\r
77 /** \brief Setter for current account name
\r
79 * @param accountName New account name
\r
81 void setAccountName(const QString& accountName);
\r
83 /** \brief Getter for current account uid
\r
85 * @return Account uid
\r
87 const QString& accountUid();
\r
89 /** \brief Setter for current account uid
\r
91 * @param uid New account uid
\r
93 void setAccountUid(const QString& uid);
\r
95 /** \brief Getter for current account password
\r
97 * @return Account password
\r
99 const QString& accountPasswd();
\r
101 /** \brief Setter for current account password
\r
103 * @param password New account password
\r
105 void setAccountPasswd(const QString& password);
\r
107 /** \brief Getter for current protocol
\r
109 * @return Protocol used
\r
111 const QString& protocol();
\r
113 /** \brief Setter for current protocol
\r
115 * @param protocol Protocol name
\r
117 void setProtocol(const QString& protocol);
\r
119 /** \brief Getter for protocol common name
\r
121 * @return Protocol common used name
\r
123 const QString protocolCommonName();
\r
125 /** \brief Setter for current protocol by service name
\r
127 * @param service Service name
\r
129 void setProtocolByName(const QString& service);
\r
131 /** \brief Getter for available protocols
\r
133 * @return Available protocols
\r
135 const QStringList& protocols();
\r
137 /** \brief Setter for availabe protocols
\r
139 * @param protocols List of protocols names
\r
141 void setProtocols(const QStringList& protocols);
\r
143 /** \brief Getter for current server
\r
145 * @return Server name
\r
147 const QString& server();
\r
149 /** \brief Setter for current server
\r
151 * @param server Server name
\r
153 void setServer(const QString& server);
\r
155 /** \brief Getter for currently used port
\r
157 * @return Port number
\r
161 /** \brief Setter for currently used port
\r
163 * @param port Port number
\r
165 void setPort(int port);
\r
167 /** \brief Getter for `old-ssl` connection property
\r
169 * @return True if connection needs `old-ssl` enabled
\r
171 bool isOldSslEnabled();
\r
173 /** \brief Setter for `old-ssl` connection property
\r
175 * @param bEnabled True if connection needs `old-ssl` enabled
\r
177 void setOldSslEnabled(bool bEnabled);
\r
179 /** \brief Getter for `ignore-ssl-errors` connection property
\r
181 * @return True if connection needs `ignore-ssl-errors` enabled
\r
183 bool isIgnoreSslErrorsEnabled();
\r
185 /** \brief Setter for `ignore-ssl-errors` connection property
\r
187 * @param bEnabled True if connection needs `ignore-ssl-errors` enabled
\r
189 void setIgnoreSslErrorsEnabled(bool bEnabled);
\r
191 /** \brief Getter for saved contact list
\r
193 * @return List of TocContact's
\r
195 TocContactList* contactList();
\r
197 /** \brief Getter for list of contacts to be added to server
\r
199 * @return List of Uids to be added
\r
201 QStringList* contactsToAdd();
\r
203 /** \brief Getter for list of contacts to be removed from server
\r
205 * @return List of Uids to be removed
\r
207 QStringList* contactsToRemove();
\r
209 /** \brief Getter for sort order policy
\r
211 * @return Sorting order policy
\r
213 SortOrder sortOrder();
\r
215 /** \brief Setter for sort order policy
\r
217 * @param sortOrder Sorting order policy
\r
219 void setSortOrder(SortOrder sortOrder);
\r
221 /** \brief Getter for authorization rule
\r
223 * @return Authorization rule
\r
225 AuthorizationRule authorizationRule();
\r
227 /** \brief Setter for authorization rule
\r
229 * @param rule Authorization rule
\r
231 void setAuthorizationRule(AuthorizationRule rule);
\r
233 /** \brief Getter for current ui theme
\r
235 * @return File name of the style sheet file
\r
237 const QString& currentTheme();
\r
239 /** \brief Setter for current ui theme
\r
241 * @param theme File name of the style sheet file
\r
243 void setCurrentTheme(const QString& theme);
\r
245 /** \brief Returns a server hint for given data
\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
251 const QString& serverHint( const QString& uid, const QString& serviceName);
\r
253 /** \brief Returns a port hint for given data
\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
259 int portHint( const QString& uid, const QString& serviceName);
\r
261 /** \brief Returns true if such protocol is already supported
\r
263 * @param protocol Protocol to check
\r
264 * @return True if protocol already exist
\r
266 bool isProtocolInstalled(const QString& protocol);
\r
268 /** \brief Add a new protocol to the list of supported protocols
\r
270 * @param commonName Protocol's common name
\r
271 * @param protocol Protocol's identifier (according to the Telepathy spec)
\r
273 void installProtocol(const QString& commonName, const QString& protocol);
\r
275 /** \brief One shot getter for the `register` parameter of the connection
\r
277 * When it returns the "true" value it sets it immediately to "false".
\r
279 * @return true if user wants to register an account instead of logging in
\r
283 /** \brief Setter for the `register` parameter of the connection
\r
285 * When it is invoked it sets the `register` parameter to "true"
\r
288 void setRegister();
\r
292 /** \brief Private constructor
\r
297 /** \brief Used to read settings with QSettings
\r
299 * It's meant to be used only in destructor. That's why it's private.
\r
304 /** \brief Used to save settings with QSettings
\r
306 * It's meant to be used only when creating an instance. That's why it's private.
\r
310 static TocSettings* _pSelf;
\r
312 QString _accountName;
\r
313 QString _accountUid;
\r
314 QString _accountPasswd;
\r
316 QStringList _protocols;
\r
317 QString _protocolCommonName;
\r
319 QString _serverHint;
\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
334 #endif // TOCSETTINGS_H
\r