signon  8.58
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 QVariantMap &data);
99  void processStore(const QVariantMap &data);
100  void processUiRequest(const QVariantMap &data);
101  void processRefreshRequest(const QVariantMap &data);
102  void processError(int err, const QString &message);
103  void stateChangedSlot(int state,
104  const QString &message);
105 
106  void queryUiSlot(QDBusPendingCallWatcher *call);
107 
108 protected:
109  SignonSessionCore(quint32 id,
110  const QString &method,
111  int timeout,
112  QObject *parent);
113 
114  void childEvent(QChildEvent *ce);
115  void customEvent(QEvent *event);
116 
117 private:
118  void startProcess();
119  void replyError(const QDBusConnection &conn,
120  const QDBusMessage &msg,
121  int err,
122  const QString &message);
123  void processStoreOperation(const StoreOperation &operation);
124  void requestDone();
125 
126 private:
127  PluginProxy *m_plugin;
128  QQueue<RequestData> m_listOfRequests;
129  SignonUiAdaptor *m_signonui;
130 
131  QDBusPendingCallWatcher *m_watcher;
132 
133  bool m_requestIsActive;
134  bool 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_
Base class for server objects that can be automatically destroyed after a certain period of inactivit...
Describes a credentials store operatation.
Daemon side representation of authentication session.
RemotePluginProcess * process
Definition: main.cpp:43