1/***************************************************************************
2 * Copyright (C) 2005-2014 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#ifndef COREACCOUNT_H_
22#define COREACCOUNT_H_
23
24#include <QCoreApplication>
25#include <QNetworkProxy>
26#include <QUuid>
27#include <QVariantMap>
28
29#include "types.h"
30class CoreAccount
31{
32 Q_DECLARE_TR_FUNCTIONS(CoreAccount)
33
34public:
35 CoreAccount(AccountId accountId = 0);
36 virtual ~CoreAccount() {};
37
38 inline bool isValid() const { return accountId().isValid(); }
39 inline AccountId accountId() const { return _accountId; }
40 inline QString accountName() const { return isInternal() ? tr("Internal Core") : _accountName; }
41 inline QUuid uuid() const { return _uuid; }
42 inline bool isInternal() const { return _internal; }
43
44 inline QString user() const { return _user; }
45 inline bool storePassword() const { return _storePassword; }
46 inline QString hostName() const { return _hostName; }
47 inline uint port() const { return _port; }
48 inline bool useSsl() const { return _useSsl; }
49
50 inline bool useProxy() const { return _useProxy; }
51 inline QNetworkProxy::ProxyType proxyType() const { return _proxyType; }
52 inline QString proxyUser() const { return _proxyUser; }
53 inline QString proxyHostName() const { return _proxyHostName; }
54 inline uint proxyPort() const { return _proxyPort; }
55
56 void setAccountId(AccountId id);
57 void setAccountName(const QString &accountName);
58 void setUuid(const QUuid &uuid);
59 void setInternal(bool);
60
61 void setUser(const QString &user);
62 void setStorePassword(bool);
63 void setHostName(const QString &hostname);
64 void setPort(uint port);
65 void setUseSsl(bool);
66
67 void setUseProxy(bool);
68 void setProxyType(QNetworkProxy::ProxyType);
69 void setProxyUser(const QString &);
70 void setProxyHostName(const QString &);
71 void setProxyPort(uint);
72
73 /* These might be overridden for KWallet/QtKeychain support */
74 virtual inline QString password() const { return _password; }
75 virtual void setPassword(const QString &password);
76 virtual inline QString proxyPassword() const { return _proxyPassword; }
77 virtual void setProxyPassword(const QString &);
78
79 virtual QVariantMap toVariantMap(bool forcePassword = false) const;
80 virtual void fromVariantMap(const QVariantMap &);
81
82 bool operator==(const CoreAccount &other) const;
83
84private:
85 AccountId _accountId;
86 QString _accountName;
87 QUuid _uuid;
88 bool _internal;
89 QString _user, _password, _hostName;
90 uint _port;
91 bool _storePassword, _useSsl, _useProxy;
92 QNetworkProxy::ProxyType _proxyType;
93 QString _proxyUser, _proxyPassword, _proxyHostName;
94 uint _proxyPort;
95};
96
97
98#endif
99