signon  8.42
signonsessioncore.h
Go to the documentation of this file.
1 /*
2  * This file is part of signon
3  *
4  * Copyright (C) 2009-2010 Nokia Corporation.
5  *
6  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * version 2.1 as published by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  */
22 
23 #ifndef SIGNONSESSIONCORE_H_
24 #define SIGNONSESSIONCORE_H_
25 
26 #include <QtCore>
27 #include <QtDBus>
28 
29 /*
30  * TODO: remove invocation of plugin operations into the main signond process
31  */
32 
33 #include "pluginproxy.h"
34 #include "signondisposable.h"
35 #include "signonsessioncoretools.h"
36 
37 using namespace SignOn;
38 
39 class SignonUiAdaptor;
40 
41 namespace SignonDaemonNS {
42 
43 class SignonDaemon;
44 
51 {
52  Q_OBJECT
53 
54 public:
55  static SignonSessionCore *sessionCore(const quint32 id,
56  const QString &method,
57  SignonDaemon *parent);
58  virtual ~SignonSessionCore();
59  quint32 id() const;
60  QString method() const;
61  bool setupPlugin();
62  /*
63  * just for any case
64  * */
65  static void stopAllAuthSessions();
66  static QStringList loadedPluginMethods(const QString &method);
67 
68  void destroy();
69 
70 public Q_SLOTS:
71  QStringList queryAvailableMechanisms(const QStringList &wantedMechanisms);
72 
73  void process(const QDBusConnection &connection,
74  const QDBusMessage &message,
75  const QVariantMap &sessionDataVa,
76  const QString &mechanism,
77  const QString &cancelKey);
78 
79  void cancel(const QString &cancelKey);
80  void setId(quint32 id);
81 
82  /* When the credentials system is ready, session processing will begin.
83  * This mechanism helps avoiding the display of eroneous secure storage
84  * related messages on query credentials dialogs (e.g. The `No key present`
85  * scenario - keys might actually be present but the querying of them is
86  * not complete at the time of the auth. session processing).
87  */
88  void credentialsSystemReady();
89 
90 Q_SIGNALS:
91  void stateChanged(const QString &requestId,
92  int state,
93  const QString &message);
94 
95 private Q_SLOTS:
96  void startNewRequest();
97 
98  void processResultReply(const QString &cancelKey, const QVariantMap &data);
99  void processStore(const QString &cancelKey, const QVariantMap &data);
100  void processUiRequest(const QString &cancelKey, const QVariantMap &data);
101  void processRefreshRequest(const QString &cancelKey,
102  const QVariantMap &data);
103  void processError(const QString &cancelKey, int err, const QString &message);
104  void stateChangedSlot(const QString &cancelKey,
105  int state,
106  const QString &message);
107 
108  void queryUiSlot(QDBusPendingCallWatcher *call);
109 
110 protected:
111  SignonSessionCore(quint32 id,
112  const QString &method,
113  int timeout,
114  SignonDaemon *parent);
115 
116  void childEvent(QChildEvent *ce);
117  void customEvent(QEvent *event);
118 
119 private:
120  void startProcess();
121  void replyError(const QDBusConnection &conn,
122  const QDBusMessage &msg,
123  int err,
124  const QString &message);
125  void processStoreOperation(const StoreOperation &operation);
126 
127 private:
128  PluginProxy *m_plugin;
129  QQueue<RequestData> m_listOfRequests;
130  SignonUiAdaptor *m_signonui;
131 
132  QDBusPendingCallWatcher *m_watcher;
133 
134  QString m_canceled;
135 
136  uint m_id;
137  QString m_method;
138  /* the original request parameters, for the request currently being
139  * processed */
140  QVariantMap m_clientData;
141 
142  //Temporary caching
143  QString m_tmpUsername;
144  QString m_tmpPassword;
145 
146  /* Flag used for handling post ui querying results' processing.
147  * Secure storage not available events won't be posted if the current
148  * session processing was not preceded by a signon UI query credentials
149  * interaction, when this flag is set to true. */
150  bool m_queryCredsUiDisplayed;
151 
152  Q_DISABLE_COPY(SignonSessionCore)
153 }; //class SignonDaemon
154 
155 } //namespace SignonDaemonNS
156 
157 #endif //SIGNONSESSIONQUEUE_H_