00001 /* 00002 * This file is part of signon 00003 * 00004 * Copyright (C) 2009-2010 Nokia Corporation. 00005 * Copyright (C) 2011-2016 Canonical Ltd. 00006 * 00007 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public License 00011 * version 2.1 as published by the Free Software Foundation. 00012 * 00013 * This library is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00021 * 02110-1301 USA 00022 */ 00023 00024 #include <QVariant> 00025 00026 #include "debug.h" 00027 #include "libsignoncommon.h" 00028 #include "identityinfo.h" 00029 #include "identityinfoimpl.h" 00030 #include "identity.h" 00031 00032 namespace SignOn { 00033 00034 IdentityInfo::IdentityInfo(): 00035 impl(new IdentityInfoImpl) 00036 { 00037 qRegisterMetaType<IdentityInfo>("SignOn::IdentityInfo"); 00038 00039 if (qMetaTypeId<IdentityInfo>() < QMetaType::User) 00040 BLAME() << "IdentityInfo::IdentityInfo() - " 00041 "IdentityInfo meta type not registered."; 00042 } 00043 00044 IdentityInfo::IdentityInfo(const IdentityInfo &other): 00045 impl(new IdentityInfoImpl) 00046 { 00047 *impl = *other.impl; 00048 } 00049 00050 IdentityInfo &IdentityInfo::operator=(const IdentityInfo &other) 00051 { 00052 *impl = *other.impl; 00053 return *this; 00054 } 00055 00056 IdentityInfo::IdentityInfo(const QString &caption, 00057 const QString &userName, 00058 const QMap<MethodName, MechanismsList> &methods): 00059 impl(new IdentityInfoImpl) 00060 { 00061 impl->setCaption(caption); 00062 impl->setUserName(userName); 00063 impl->setMethods(methods); 00064 } 00065 00066 IdentityInfo::~IdentityInfo() 00067 { 00068 if (impl) delete impl; 00069 impl = 0; 00070 } 00071 00072 void IdentityInfo::setId(const quint32 id) 00073 { 00074 impl->setId(id); 00075 } 00076 00077 quint32 IdentityInfo::id() const 00078 { 00079 return impl->id(); 00080 } 00081 00082 void IdentityInfo::setUserName(const QString &userName) 00083 { 00084 impl->setUserName(userName); 00085 } 00086 00087 const QString IdentityInfo::userName() const 00088 { 00089 return impl->userName(); 00090 } 00091 00092 void IdentityInfo::setCaption(const QString &caption) 00093 { 00094 impl->setCaption(caption); 00095 } 00096 00097 const QString IdentityInfo::caption() const 00098 { 00099 return impl->caption(); 00100 } 00101 00102 void IdentityInfo::setRealms(const QStringList &realms) 00103 { 00104 impl->setRealms(realms); 00105 } 00106 00107 QStringList IdentityInfo::realms() const 00108 { 00109 return impl->realms(); 00110 } 00111 00112 void IdentityInfo::setOwner(const QString &ownerToken) 00113 { 00114 impl->setOwners(QStringList() << ownerToken); 00115 } 00116 00117 QString IdentityInfo::owner() const 00118 { 00119 return impl->owners().value(0); 00120 } 00121 00122 void IdentityInfo::setAccessControlList(const QStringList &accessControlList) 00123 { 00124 impl->setAccessControlList(accessControlList); 00125 } 00126 00127 QStringList IdentityInfo::accessControlList() const 00128 { 00129 return impl->accessControlList(); 00130 } 00131 00132 QString IdentityInfo::secret() const 00133 { 00134 return impl->secret(); 00135 } 00136 00137 void IdentityInfo::setSecret(const QString &secret, const bool storeSecret) 00138 { 00139 impl->setSecret(secret); 00140 impl->setStoreSecret(storeSecret); 00141 } 00142 00143 bool IdentityInfo::isStoringSecret() const 00144 { 00145 return impl->storeSecret(); 00146 } 00147 00148 void IdentityInfo::setStoreSecret(const bool storeSecret) 00149 { 00150 impl->setStoreSecret(storeSecret); 00151 } 00152 00153 void IdentityInfo::setMethod(const MethodName &method, 00154 const MechanismsList &mechanismsList) 00155 { 00156 impl->updateMethod(method, mechanismsList); 00157 } 00158 00159 void IdentityInfo::removeMethod(const MethodName &method) 00160 { 00161 impl->removeMethod(method); 00162 } 00163 00164 void IdentityInfo::setType(IdentityInfo::CredentialsType type) 00165 { 00166 impl->setType(type); 00167 } 00168 00169 IdentityInfo::CredentialsType IdentityInfo::type() const 00170 { 00171 return impl->type(); 00172 } 00173 00174 QList<MethodName> IdentityInfo::methods() const 00175 { 00176 return impl->methods().keys(); 00177 } 00178 00179 MechanismsList IdentityInfo::mechanisms(const MethodName &method) const 00180 { 00181 return impl->methods().value(method, QStringList()); 00182 } 00183 00184 void IdentityInfo::setRefCount(qint32 refCount) 00185 { 00186 /* This method is a mistake, let's keep it for binary compatibility as a 00187 * no-op. */ 00188 Q_UNUSED(refCount); 00189 } 00190 00191 qint32 IdentityInfo::refCount() const 00192 { 00193 return impl->refCount(); 00194 } 00195 00196 } //namespace SignOn