identity.cpp
00001 /*
00002  * This file is part of signon
00003  *
00004  * Copyright (C) 2009-2010 Nokia Corporation.
00005  *
00006  * Contact: Aurel Popirtac <ext-aurel.popirtac@nokia.com>
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 "identityimpl.h"
00025 #include "identity.h"
00026 
00027 namespace SignOn {
00028 
00029 Identity::Identity(const quint32 id, QObject *parent):
00030     QObject(parent)
00031 {
00032     qRegisterMetaType<Error>("SignOn::Error");
00033     qRegisterMetaType<Error>("Error");
00034 
00035     if (qMetaTypeId<Error>() < QMetaType::User)
00036         BLAME() << "Identity::Identity() - "
00037             "SignOn::Error meta type not registered.";
00038 
00039     impl = new IdentityImpl(this, id);
00040 }
00041 
00042 Identity *Identity::newIdentity(const IdentityInfo &info, QObject *parent)
00043 {
00044     Identity *identity = new Identity(SSO_NEW_IDENTITY, parent);
00045     identity->impl->copyInfo(info);
00046     return identity;
00047 }
00048 
00049 Identity *Identity::existingIdentity(const quint32 id, QObject *parent)
00050 {
00051     if (id == 0)
00052         return NULL;
00053     return new Identity(id, parent);
00054 }
00055 
00056 Identity::~Identity()
00057 {
00058 }
00059 
00060 quint32 Identity::id() const
00061 {
00062     return impl->id();
00063 }
00064 
00065 void Identity::queryAvailableMethods()
00066 {
00067     impl->queryAvailableMethods();
00068 }
00069 
00070 AuthSessionP Identity::createSession(const QString &methodName)
00071 {
00072     if (methodName.isEmpty())
00073         return NULL;
00074 
00075     return AuthSessionP(impl->createSession(methodName, this));
00076 }
00077 
00078 void Identity::destroySession(const AuthSessionP &session)
00079 {
00080     if (session.isNull())
00081         return;
00082 
00083     impl->destroySession(session.data());
00084 }
00085 
00086 void Identity::requestCredentialsUpdate(const QString &message)
00087 {
00088     impl->requestCredentialsUpdate(message);
00089 }
00090 
00091 void Identity::storeCredentials(const IdentityInfo &info)
00092 {
00093     impl->storeCredentials(info);
00094 }
00095 
00096 void Identity::remove()
00097 {
00098     impl->remove();
00099 }
00100 
00101 void Identity::addReference(const QString &reference)
00102 {
00103     impl->addReference(reference);
00104 }
00105 
00106 void Identity::removeReference(const QString &reference)
00107 {
00108     impl->removeReference(reference);
00109 }
00110 
00111 void Identity::queryInfo()
00112 {
00113     impl->queryInfo();
00114 }
00115 
00116 void Identity::verifyUser(const QString &message)
00117 {
00118     impl->verifyUser(message);
00119 }
00120 
00121 void Identity::verifyUser(const QVariantMap &params)
00122 {
00123     impl->verifyUser(params);
00124 }
00125 
00126 void Identity::verifySecret(const QString &secret)
00127 {
00128     impl->verifySecret(secret);
00129 }
00130 
00131 void Identity::signOut()
00132 {
00133     impl->signOut();
00134 }
00135 
00136 } //namespace SignOn