|
signon
8.40
|
00001 /* 00002 * This file is part of signon 00003 * 00004 * Copyright (C) 2009-2010 Nokia Corporation. 00005 * 00006 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public License 00010 * version 2.1 as published by the Free Software Foundation. 00011 * 00012 * This library is distributed in the hope that it will be useful, but 00013 * WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00020 * 02110-1301 USA 00021 */ 00022 00023 #ifndef SIGNONSESSIONCORE_H_ 00024 #define SIGNONSESSIONCORE_H_ 00025 00026 #include <QtCore> 00027 #include <QtDBus> 00028 00029 /* 00030 * TODO: remove invocation of plugin operations into the main signond process 00031 */ 00032 00033 #include "pluginproxy.h" 00034 #include "signondisposable.h" 00035 #include "signonsessioncoretools.h" 00036 00037 using namespace SignOn; 00038 00039 class SignonUiAdaptor; 00040 00041 namespace SignonDaemonNS { 00042 00043 class SignonDaemon; 00044 00050 class SignonSessionCore: public SignonDisposable 00051 { 00052 Q_OBJECT 00053 00054 public: 00055 static SignonSessionCore *sessionCore(const quint32 id, 00056 const QString &method, 00057 SignonDaemon *parent); 00058 virtual ~SignonSessionCore(); 00059 quint32 id() const; 00060 QString method() const; 00061 bool setupPlugin(); 00062 /* 00063 * just for any case 00064 * */ 00065 static void stopAllAuthSessions(); 00066 static QStringList loadedPluginMethods(const QString &method); 00067 00068 void destroy(); 00069 00070 public Q_SLOTS: 00071 QStringList queryAvailableMechanisms(const QStringList &wantedMechanisms); 00072 00073 void process(const QDBusConnection &connection, 00074 const QDBusMessage &message, 00075 const QVariantMap &sessionDataVa, 00076 const QString &mechanism, 00077 const QString &cancelKey); 00078 00079 void cancel(const QString &cancelKey); 00080 void setId(quint32 id); 00081 00082 /* When the credentials system is ready, session processing will begin. 00083 * This mechanism helps avoiding the display of eroneous secure storage 00084 * related messages on query credentials dialogs (e.g. The `No key present` 00085 * scenario - keys might actually be present but the querying of them is 00086 * not complete at the time of the auth. session processing). 00087 */ 00088 void credentialsSystemReady(); 00089 00090 Q_SIGNALS: 00091 void stateChanged(const QString &requestId, 00092 int state, 00093 const QString &message); 00094 00095 private Q_SLOTS: 00096 void startNewRequest(); 00097 00098 void processResultReply(const QString &cancelKey, const QVariantMap &data); 00099 void processStore(const QString &cancelKey, const QVariantMap &data); 00100 void processUiRequest(const QString &cancelKey, const QVariantMap &data); 00101 void processRefreshRequest(const QString &cancelKey, 00102 const QVariantMap &data); 00103 void processError(const QString &cancelKey, int err, const QString &message); 00104 void stateChangedSlot(const QString &cancelKey, 00105 int state, 00106 const QString &message); 00107 00108 void queryUiSlot(QDBusPendingCallWatcher *call); 00109 00110 protected: 00111 SignonSessionCore(quint32 id, 00112 const QString &method, 00113 int timeout, 00114 SignonDaemon *parent); 00115 00116 void childEvent(QChildEvent *ce); 00117 void customEvent(QEvent *event); 00118 00119 private: 00120 void startProcess(); 00121 void replyError(const QDBusConnection &conn, 00122 const QDBusMessage &msg, 00123 int err, 00124 const QString &message); 00125 void processStoreOperation(const StoreOperation &operation); 00126 00127 private: 00128 PluginProxy *m_plugin; 00129 QQueue<RequestData> m_listOfRequests; 00130 SignonUiAdaptor *m_signonui; 00131 00132 QDBusPendingCallWatcher *m_watcher; 00133 00134 QString m_canceled; 00135 00136 uint m_id; 00137 QString m_method; 00138 /* the original request parameters, for the request currently being 00139 * processed */ 00140 QVariantMap m_clientData; 00141 00142 //Queues store operations when the secure storage is unavailable 00143 QQueue<StoreOperation> m_storeQueue; 00144 00145 //Temporary caching 00146 QString m_tmpUsername; 00147 QString m_tmpPassword; 00148 00149 /* Flag used for handling post ui querying results' processing. 00150 * Secure storage not available events won't be posted if the current 00151 * session processing was not preceded by a signon UI query credentials 00152 * interaction, when this flag is set to true. */ 00153 bool m_queryCredsUiDisplayed; 00154 00155 Q_DISABLE_COPY(SignonSessionCore) 00156 }; //class SignonDaemon 00157 00158 } //namespace SignonDaemonNS 00159 00160 #endif //SIGNONSESSIONQUEUE_H_