signon  8.42
signonauthsession.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  * Copyright (C) 2012 Canonical Ltd.
6  *
7  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * version 2.1 as published by the Free Software Foundation.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  */
23 
24 #ifndef SIGNONAUTHSESSION_H_
25 #define SIGNONAUTHSESSION_H_
26 
27 #include <QtCore>
28 #include <QtDBus>
29 
30 /*
31  * TODO: remove invocation of plugin operations into the main signond process
32  */
33 #include "signond-common.h"
34 #include "signonsessioncore.h"
35 
36 using namespace SignOn;
37 
38 namespace SignonDaemonNS {
39 
45 class SignonAuthSession: public QObject, protected QDBusContext
46 {
47  Q_OBJECT
48 
49 public:
50  inline SignonSessionCore *parent() const
51  {
52  return static_cast<SignonSessionCore *>(QObject::parent());
53  }
54 
56 
57  static QString getAuthSessionObjectPath(const quint32 id,
58  const QString &method,
59  SignonDaemon *parent,
60  bool &supportsAuthMethod,
61  pid_t ownerPid);
62  static void stopAllAuthSessions();
63  quint32 id() const;
64  QString method() const;
65  void objectRegistered();
66  pid_t ownerPid() const;
67 
68 public Q_SLOTS:
69  QStringList queryAvailableMechanisms(const QStringList &wantedMechanisms);
70  QVariantMap process(const QVariantMap &sessionDataVa,
71  const QString &mechanism);
72  void cancel();
73  void setId(quint32 id);
74  void objectUnref();
75 
76 Q_SIGNALS:
77  void stateChanged(int state, const QString &message);
78  void unregistered();
79 
80 private Q_SLOTS:
81  void stateChangedSlot(const QString &sessionKey,
82  int state,
83  const QString &message);
84 
85 protected:
86  SignonAuthSession(quint32 id, const QString &method, pid_t ownerPid);
87  virtual ~SignonAuthSession();
88 
89 private:
90  quint32 m_id;
91  QString m_method;
92  bool m_registered;
93  pid_t m_ownerPid;
94 
95  Q_DISABLE_COPY(SignonAuthSession)
96 }; //class SignonDaemon
97 
98 } //namespace SignonDaemonNS
99 
100 #endif //SIGNONAUTHSESSION_H_