Debian Codegraph @

online-accounts/lib/qt/LomiriOnlineAccounts/account.cpp

raw symbols SCIP
1 /*
2 * This file is part of libOnlineAccounts
3 *
4 * Copyright (C) 2015 Canonical Ltd.
5 *
6 * Contact: Alberto Mardegan <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License version 3, as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "account_p.h"
22
23 #include "manager_p.h"
24
25 using namespace OnlineAccounts;
26
27 AccountPrivate::AccountPrivate(Manager *manager, const AccountInfo &info):
28 m_manager(manager),
29 m_info(info),
30 m_isValid(true),
31 q_ptr(0)
32 {
33 }
34
35 AccountPrivate::~AccountPrivate()
36 {
37 }
38
39 void AccountPrivate::setInvalid()
40 {
41 Q_Q(Account);
42 m_isValid = false;
43 Q_EMIT q->disabled();
44 }
45
46 void AccountPrivate::update(const AccountInfo &info)
47 {
48 Q_Q(Account);
49
50 if (info != m_info) {
51 m_info = info;
52 Q_EMIT q->changed();
53 }
54 }
55
56 Service AccountPrivate::service() const
57 {
58 return m_manager->d_ptr->service(m_info.service());
59 }
60
61 Account::Account(AccountPrivate *priv, QObject *parent):
62 QObject(parent),
63 d_ptr(priv)
64 {
65 priv->q_ptr = this;
66 }
67
68 Account::~Account()
69 {
70 delete d_ptr;
71 d_ptr = 0;
72 }
73
74 bool Account::isValid() const
75 {
76 Q_D(const Account);
77 return d->m_isValid;
78 }
79
80 Service Account::service() const
81 {
82 Q_D(const Account);
83 return d->service();
84 }
85
86 AccountId Account::id() const
87 {
88 Q_D(const Account);
89 return d->m_info.id();
90 }
91
92 QString Account::displayName() const
93 {
94 Q_D(const Account);
95 return d->m_info.displayName();
96 }
97
98 QString Account::serviceId() const
99 {
100 Q_D(const Account);
101 return d->m_info.service();
102 }
103
104 AuthenticationMethod Account::authenticationMethod() const
105 {
106 Q_D(const Account);
107 return d->m_info.authenticationMethod();
108 }
109
110 QStringList Account::keys() const
111 {
112 Q_D(const Account);
113 return d->m_info.keys();
114 }
115
116 QVariant Account::setting(const QString &key) const
117 {
118 Q_D(const Account);
119 return d->m_info.setting(key);
120 }
121
122 PendingCall Account::authenticate(const AuthenticationData &authData)
123 {
124 Q_D(Account);
125 ManagerPrivate *mPriv = d->m_manager->d_ptr;
126 return mPriv->authenticate(d->m_info, authData);
127 }