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 }
100 
101 const QString IdentityInfo::caption() const
102 {
103  return impl->m_caption;
104 }
105 
106 void IdentityInfo::setRealms(const QStringList &realms)
107 {
108  impl->m_realms = realms;
109 }
110 
111 QStringList IdentityInfo::realms() const
112 {
113  return impl->m_realms;
114 }
115 
116 void IdentityInfo::setOwner(const QString &ownerToken)
117 {
118  impl->m_owner = ownerToken;
119 }
120 
121 QString IdentityInfo::owner() const
122 {
123  return impl->m_owner;
124 }
125 
126 void IdentityInfo::setAccessControlList(const QStringList &accessControlList)
127 {
128  impl->m_accessControlList = accessControlList;
129 }
130 
132 {
133  return impl->m_accessControlList;
134 }
135 
136 const QString IdentityInfo::secret() const
137 {
138  return impl->m_secret;
139 }
140 
141 void IdentityInfo::setSecret(const QString &secret, const bool storeSecret)
142 {
143  impl->m_secret = secret;
144  impl->m_storeSecret = storeSecret;
145  impl->m_isEmpty = false;
146 }
147 
149 {
150  return impl->m_storeSecret;
151 }
152 
153 void IdentityInfo::setStoreSecret(const bool storeSecret)
154 {
155  impl->m_storeSecret = storeSecret;
156 }
157 
159  const MechanismsList &mechanismsList)
160 {
161  if (impl->hasMethod(method))
162  impl->updateMethod(method, mechanismsList);
163  else
164  impl->addMethod(method, mechanismsList);
165 }
166 
168 {
169  impl->removeMethod(method);
170 }
171 
173 {
174  impl->setType(type);
175 }
176 
178 {
179  return impl->type();
180 }
181 
182 QList<MethodName> IdentityInfo::methods() const
183 {
184  return impl->m_authMethods.keys();
185 }
186 
188 {
189  return impl->m_authMethods.value(method, QStringList());
190 }
191 
192 void IdentityInfo::setRefCount(qint32 refCount)
193 {
194  impl->setRefCount(refCount);
195 }
196 
198 {
199  return impl->refCount();
200 }
201 
202 } //namespace SignOn