identityinfo.cpp
1 /*
2  * This file is part of signon
3  *
4  * Copyright (C) 2009-2010 Nokia Corporation.
5  *
6  * Contact: Aurel Popirtac <ext-aurel.popirtac@nokia.com>
7  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * version 2.1 as published by the Free Software Foundation.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  */
23 
24 #include <QVariant>
25 
26 #include "libsignoncommon.h"
27 #include "identityinfo.h"
28 #include "identityinfoimpl.h"
29 #include "identity.h"
30 
31 namespace SignOn {
32 
34  impl(new IdentityInfoImpl(this))
35 {
36  qRegisterMetaType<IdentityInfo>("SignOn::IdentityInfo");
37 
38  if (qMetaTypeId<IdentityInfo>() < QMetaType::User)
39  BLAME() << "IdentityInfo::IdentityInfo() - "
40  "IdentityInfo meta type not registered.";
41 
42  impl->m_id = 0;
43  impl->m_storeSecret = false;
44 }
45 
47  impl(new IdentityInfoImpl(this))
48 {
49  impl->copy(*(other.impl));
50 }
51 
53 {
54  impl->copy(*(other.impl));
55  return *this;
56 }
57 
58 IdentityInfo::IdentityInfo(const QString &caption,
59  const QString &userName,
60  const QMap<MethodName, MechanismsList> &methods):
61  impl(new IdentityInfoImpl(this))
62 {
63  impl->m_caption = caption;
64  impl->m_userName = userName;
65  impl->m_isEmpty = false;
66  impl->m_authMethods = methods;
67 }
68 
70 {
71  if (impl) delete impl;
72  impl = 0;
73 }
74 
75 void IdentityInfo::setId(const quint32 id)
76 {
77  impl->m_id = id;
78 }
79 
80 quint32 IdentityInfo::id() const
81 {
82  return impl->m_id;
83 }
84 
85 void IdentityInfo::setUserName(const QString &userName)
86 {
87  impl->m_userName = userName;
88  impl->m_isEmpty = false;
89 }
90 
91 const QString IdentityInfo::userName() const
92 {
93  return impl->m_userName;
94 }
95 
96 void IdentityInfo::setCaption(const QString &caption)
97 {
98  impl->m_caption = caption;
99  impl->m_isEmpty = false;
100 }
101 
102 const QString IdentityInfo::caption() const
103 {
104  return impl->m_caption;
105 }
106 
107 void IdentityInfo::setRealms(const QStringList &realms)
108 {
109  impl->m_realms = realms;
110 }
111 
112 QStringList IdentityInfo::realms() const
113 {
114  return impl->m_realms;
115 }
116 
117 void IdentityInfo::setOwner(const QString &ownerToken)
118 {
119  impl->m_owner = ownerToken;
120 }
121 
122 QString IdentityInfo::owner() const
123 {
124  return impl->m_owner;
125 }
126 
127 void IdentityInfo::setAccessControlList(const QStringList &accessControlList)
128 {
129  impl->m_accessControlList = accessControlList;
130  impl->m_isEmpty = false;
131 }
132 
134 {
135  return impl->m_accessControlList;
136 }
137 
138 QString IdentityInfo::secret() const
139 {
140  return impl->m_secret;
141 }
142 
143 void IdentityInfo::setSecret(const QString &secret, const bool storeSecret)
144 {
145  impl->m_secret = secret;
146  impl->m_storeSecret = storeSecret;
147  impl->m_isEmpty = false;
148 }
149 
151 {
152  return impl->m_storeSecret;
153 }
154 
155 void IdentityInfo::setStoreSecret(const bool storeSecret)
156 {
157  impl->m_storeSecret = storeSecret;
158 }
159 
161  const MechanismsList &mechanismsList)
162 {
163  if (impl->hasMethod(method))
164  impl->updateMethod(method, mechanismsList);
165  else
166  impl->addMethod(method, mechanismsList);
167 }
168 
170 {
171  impl->removeMethod(method);
172 }
173 
175 {
176  impl->setType(type);
177 }
178 
180 {
181  return impl->type();
182 }
183 
184 QList<MethodName> IdentityInfo::methods() const
185 {
186  return impl->m_authMethods.keys();
187 }
188 
190 {
191  return impl->m_authMethods.value(method, QStringList());
192 }
193 
194 void IdentityInfo::setRefCount(qint32 refCount)
195 {
196  impl->setRefCount(refCount);
197 }
198 
200 {
201  return impl->refCount();
202 }
203 
204 } //namespace SignOn