Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
coreaccount.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2015 by the Quassel Project *
3  * devel@quassel-irc.org *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) version 3. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #include "coreaccount.h"
22 
23 CoreAccount::CoreAccount(AccountId accountId)
24 {
26  _internal = false;
27  _port = 4242;
28  _storePassword = false;
29  _useSsl = true;
30  _useProxy = false;
31  _proxyType = QNetworkProxy::Socks5Proxy;
32  _proxyPort = 8080;
33 }
34 
35 
37 {
38  _accountId = id;
39 }
40 
41 
42 void CoreAccount::setAccountName(const QString &name)
43 {
44  _accountName = name;
45 }
46 
47 
48 void CoreAccount::setUuid(const QUuid &uuid)
49 {
50  _uuid = uuid;
51 }
52 
53 
54 void CoreAccount::setInternal(bool internal)
55 {
56  _internal = internal;
57 }
58 
59 
60 void CoreAccount::setUser(const QString &user)
61 {
62  _user = user;
63 }
64 
65 
66 void CoreAccount::setPassword(const QString &password)
67 {
69 }
70 
71 
73 {
74  _storePassword = store;
75 }
76 
77 
78 void CoreAccount::setHostName(const QString &hostname)
79 {
80  _hostName = hostname;
81 }
82 
83 
84 void CoreAccount::setPort(uint port)
85 {
86  _port = port;
87 }
88 
89 
90 void CoreAccount::setUseSsl(bool useSsl)
91 {
92  _useSsl = useSsl;
93 }
94 
95 
96 void CoreAccount::setUseProxy(bool useProxy)
97 {
99 }
100 
101 
102 void CoreAccount::setProxyType(QNetworkProxy::ProxyType type)
103 {
104  _proxyType = type;
105 }
106 
107 
108 void CoreAccount::setProxyUser(const QString &proxyUser)
109 {
111 }
112 
113 
114 void CoreAccount::setProxyPassword(const QString &proxyPassword)
115 {
117 }
118 
119 
120 void CoreAccount::setProxyHostName(const QString &proxyHostName)
121 {
123 }
124 
125 
126 void CoreAccount::setProxyPort(uint proxyPort)
127 {
129 }
130 
131 
132 QVariantMap CoreAccount::toVariantMap(bool forcePassword) const
133 {
134  QVariantMap v;
135  v["AccountId"] = accountId().toInt(); // can't use AccountId because then comparison fails
136  v["AccountName"] = accountName();
137  v["Uuid"] = uuid().toString();
138  v["Internal"] = isInternal();
139  v["User"] = user();
140  if (_storePassword || forcePassword)
141  v["Password"] = password();
142  else
143  v["Password"] = QString();
144  v["StorePassword"] = storePassword();
145  v["HostName"] = hostName();
146  v["Port"] = port();
147  v["UseSSL"] = useSsl();
148  v["UseProxy"] = useProxy();
149  v["ProxyType"] = proxyType();
150  v["ProxyUser"] = proxyUser();
151  v["ProxyPassword"] = proxyPassword();
152  v["ProxyHostName"] = proxyHostName();
153  v["ProxyPort"] = proxyPort();
154  return v;
155 }
156 
157 
158 void CoreAccount::fromVariantMap(const QVariantMap &v)
159 {
160  setAccountId((AccountId)v.value("AccountId").toInt());
161  setAccountName(v.value("AccountName").toString());
162  setUuid(QUuid(v.value("Uuid").toString()));
163  setInternal(v.value("Internal").toBool());
164  setUser(v.value("User").toString());
165  setPassword(v.value("Password").toString());
166  setStorePassword(v.value("StorePassword").toBool());
167  setHostName(v.value("HostName").toString());
168  setPort(v.value("Port").toUInt());
169  setUseSsl(v.value("UseSSL").toBool());
170  setUseProxy(v.value("UseProxy").toBool());
171  setProxyType((QNetworkProxy::ProxyType)v.value("ProxyType").toInt());
172  setProxyUser(v.value("ProxyUser").toString());
173  setProxyPassword(v.value("ProxyPassword").toString());
174  setProxyHostName(v.value("ProxyHostName").toString());
175  setProxyPort(v.value("ProxyPort").toUInt());
176 
177  _storePassword = !password().isEmpty();
178 }
179 
180 
182 {
183  return toVariantMap(true) == o.toVariantMap(true);
184 }