~ubuntu-branches/ubuntu/saucy/quassel/saucy-proposed

« back to all changes in this revision

Viewing changes to src/client/coreaccount.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-02-17 12:49:50 UTC
  • mto: This revision was merged to the branch mainline in revision 59.
  • Revision ID: james.westby@ubuntu.com-20100217124950-v9hajw5d2xa6fszn
Tags: upstream-0.6~beta1
ImportĀ upstreamĀ versionĀ 0.6~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2009 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
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 
19
 ***************************************************************************/
 
20
 
 
21
#include "coreaccount.h"
 
22
 
 
23
CoreAccount::CoreAccount(AccountId accountId) {
 
24
  _accountId = accountId;
 
25
  _internal = false;
 
26
  _port = 4242;
 
27
  _storePassword = false;
 
28
  _useSsl = true;
 
29
  _useProxy = false;
 
30
  _proxyType = QNetworkProxy::Socks5Proxy;
 
31
  _proxyPort = 8080;
 
32
}
 
33
 
 
34
void CoreAccount::setAccountId(AccountId id) {
 
35
  _accountId = id;
 
36
}
 
37
 
 
38
void CoreAccount::setAccountName(const QString &name) {
 
39
  _accountName = name;
 
40
}
 
41
 
 
42
void CoreAccount::setUuid(const QUuid &uuid) {
 
43
  _uuid = uuid;
 
44
}
 
45
 
 
46
void CoreAccount::setInternal(bool internal) {
 
47
  _internal = internal;
 
48
}
 
49
 
 
50
void CoreAccount::setUser(const QString &user) {
 
51
  _user = user;
 
52
}
 
53
 
 
54
void CoreAccount::setPassword(const QString &password) {
 
55
  _password = password;
 
56
}
 
57
 
 
58
void CoreAccount::setStorePassword(bool store) {
 
59
  _storePassword = store;
 
60
}
 
61
 
 
62
void CoreAccount::setHostName(const QString &hostname) {
 
63
  _hostName = hostname;
 
64
}
 
65
 
 
66
void CoreAccount::setPort(uint port) {
 
67
  _port = port;
 
68
}
 
69
 
 
70
void CoreAccount::setUseSsl(bool useSsl) {
 
71
  _useSsl = useSsl;
 
72
}
 
73
 
 
74
void CoreAccount::setUseProxy(bool useProxy) {
 
75
  _useProxy = useProxy;
 
76
}
 
77
 
 
78
void CoreAccount::setProxyType(QNetworkProxy::ProxyType type) {
 
79
  _proxyType = type;
 
80
}
 
81
 
 
82
void CoreAccount::setProxyUser(const QString &proxyUser) {
 
83
  _proxyUser = proxyUser;
 
84
}
 
85
 
 
86
void CoreAccount::setProxyPassword(const QString &proxyPassword) {
 
87
  _proxyPassword = proxyPassword;
 
88
}
 
89
 
 
90
void CoreAccount::setProxyHostName(const QString &proxyHostName) {
 
91
  _proxyHostName = proxyHostName;
 
92
}
 
93
 
 
94
void CoreAccount::setProxyPort(uint proxyPort) {
 
95
  _proxyPort = proxyPort;
 
96
}
 
97
 
 
98
QVariantMap CoreAccount::toVariantMap(bool forcePassword) const {
 
99
  QVariantMap v;
 
100
  v["AccountId"] = accountId().toInt(); // can't use AccountId because then comparison fails
 
101
  v["AccountName"] = accountName();
 
102
  v["Uuid"] = uuid().toString();
 
103
  v["Internal"] = isInternal();
 
104
  v["User"] = user();
 
105
  if(_storePassword || forcePassword)
 
106
    v["Password"] = password();
 
107
  else
 
108
    v["Password"] = QString();
 
109
  v["StorePassword"] = storePassword();
 
110
  v["HostName"] = hostName();
 
111
  v["Port"] = port();
 
112
  v["UseSSL"] = useSsl();
 
113
  v["UseProxy"] = useProxy();
 
114
  v["ProxyType"] = proxyType();
 
115
  v["ProxyUser"] = proxyUser();
 
116
  v["ProxyPassword"] = proxyPassword();
 
117
  v["ProxyHostName"] = proxyHostName();
 
118
  v["ProxyPort"] = proxyPort();
 
119
  return v;
 
120
}
 
121
 
 
122
void CoreAccount::fromVariantMap(const QVariantMap &v) {
 
123
  setAccountId((AccountId)v.value("AccountId").toInt());
 
124
  setAccountName(v.value("AccountName").toString());
 
125
  setUuid(QUuid(v.value("Uuid").toString()));
 
126
  setInternal(v.value("Internal").toBool());
 
127
  setUser(v.value("User").toString());
 
128
  setPassword(v.value("Password").toString());
 
129
  setStorePassword(v.value("StorePassword").toBool());
 
130
  setHostName(v.value("HostName").toString());
 
131
  setPort(v.value("Port").toUInt());
 
132
  setUseSsl(v.value("UseSSL").toBool());
 
133
  setUseProxy(v.value("UseProxy").toBool());
 
134
  setProxyType((QNetworkProxy::ProxyType)v.value("ProxyType").toInt());
 
135
  setProxyUser(v.value("ProxyUser").toString());
 
136
  setProxyPassword(v.value("ProxyPassword").toString());
 
137
  setProxyHostName(v.value("ProxyHostName").toString());
 
138
  setProxyPort(v.value("ProxyPort").toUInt());
 
139
 
 
140
  _storePassword = !password().isEmpty();
 
141
}
 
142
 
 
143
bool CoreAccount::operator==(const CoreAccount &o) const {
 
144
  return toVariantMap(true) == o.toVariantMap(true);
 
145
}