signon  8.40
signonidentity.h
Go to the documentation of this file.
00001 /*
00002  * This file is part of signon
00003  *
00004  * Copyright (C) 2009-2010 Nokia Corporation.
00005  * Copyright (C) 2012 Canonical Ltd.
00006  *
00007  * Contact: Aurel Popirtac <ext-aurel.popirtac@nokia.com>
00008  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
00009  *
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public License
00012  * version 2.1 as published by the Free Software Foundation.
00013  *
00014  * This library is distributed in the hope that it will be useful, but
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017  * Lesser General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00022  * 02110-1301 USA
00023  */
00024 
00025 #ifndef SIGNONIDENTITY_H_
00026 #define SIGNONIDENTITY_H_
00027 
00028 #include <QtCore>
00029 #include <QtDBus>
00030 
00031 #include "pluginproxy.h"
00032 
00033 #include "signond-common.h"
00034 #include "signondaemon.h"
00035 #include "signondisposable.h"
00036 #include "signonidentityinfo.h"
00037 #include "credentialsaccessmanager.h"
00038 
00039 #include "signonui_interface.h"
00040 
00041 namespace SignonDaemonNS {
00042 
00048 class SignonIdentity: public SignonDisposable, protected QDBusContext
00049 {
00050     Q_OBJECT
00051 
00052     friend class SignonIdentityAdaptor;
00053 
00054     virtual ~SignonIdentity();
00055 
00056 public:
00057     void destroy();
00058     static SignonIdentity *createIdentity(quint32 id, SignonDaemon *parent);
00059     quint32 id() const { return m_id; }
00060 
00061     SignonIdentityInfo queryInfo(bool &ok, bool queryPassword = true);
00062     quint32 storeCredentials(const SignonIdentityInfo &info, bool storeSecret);
00063 
00064 public Q_SLOTS:
00065     quint32 requestCredentialsUpdate(const QString &message);
00066     QVariantMap getInfo();
00067     bool addReference(const QString &reference);
00068     bool removeReference(const QString &reference);
00069     bool verifyUser(const QVariantMap &params);
00070     bool verifySecret(const QString &secret);
00071     void remove();
00072     bool signOut();
00073     quint32 store(const QVariantMap &info);
00074     void queryUiSlot(QDBusPendingCallWatcher *call);
00075     void verifyUiSlot(QDBusPendingCallWatcher *call);
00076 Q_SIGNALS:
00077     void unregistered();
00078     //TODO - split this into the 3 separate signals(updated, removed, signed out)
00079     void infoUpdated(int);
00080 
00081 private:
00082     SignonIdentity(quint32 id, int timeout, SignonDaemon *parent);
00083     bool init();
00084     bool credentialsStored() const { return m_id > 0 ? true : false; }
00085     void queryUserPassword(const QVariantMap &params);
00086 
00087 private:
00088     quint32 m_id;
00089     SignonUiAdaptor *m_signonui;
00090     SignonIdentityInfo *m_pInfo;
00091     SignonDaemon *m_pSignonDaemon;
00092     bool m_registered;
00093     QDBusMessage m_message;
00094 
00095 }; //class SignonDaemon
00096 
00097 } //namespace SignonDaemonNS
00098 
00099 #endif /* SIGNONIDENTITY_H_ */