My Project
authpluginif.h
1 /*
2  * This file is part of signon
3  *
4  * Copyright (C) 2009-2010 Nokia Corporation.
5  * Copyright (C) 2012-2016 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  */
28 #ifndef AUTHPLUGINIF_H
29 #define AUTHPLUGINIF_H
30 
31 #include <QtCore/qobject.h>
32 #include <QtCore/qpointer.h>
33 #include <QtCore/qplugin.h>
34 
35 #include <QVariantMap>
36 #include <SignOn/sessiondata.h>
37 #include <SignOn/uisessiondata.h>
38 #include <SignOn/signonerror.h>
39 
40 QT_BEGIN_NAMESPACE
41 class QString;
42 class QStringList;
43 class QByteArray;
44 class QVariant;
45 QT_END_NAMESPACE
46 
50 enum AuthPluginState {
51  PLUGIN_STATE_NONE = 0,
52  PLUGIN_STATE_RESOLVING,
53  PLUGIN_STATE_CONNECTING,
54  PLUGIN_STATE_SENDING,
55  PLUGIN_STATE_WAITING,
56  PLUGIN_STATE_PENDING,
57  PLUGIN_STATE_REFRESHING,
58  PLUGIN_STATE_CANCELING,
59  PLUGIN_STATE_HOLDING,
60  PLUGIN_STATE_DONE
61 };
62 
67 #define SIGNON_PLUGIN_INSTANCE(pluginclass) \
68  { \
69  static AuthPluginInterface *_instance = 0; \
70  if (!_instance) \
71  _instance = static_cast<AuthPluginInterface *>(new pluginclass()); \
72  return _instance; \
73  }
74 
75 #define SIGNON_DECL_AUTH_PLUGIN(pluginclass) \
76  Q_EXTERN_C AuthPluginInterface *auth_plugin_instance() \
77  SIGNON_PLUGIN_INSTANCE(pluginclass)
78 
83 class AuthPluginInterface : public QObject
84 {
85  Q_OBJECT
86 
87 public:
88  AuthPluginInterface(QObject *parent = 0) : QObject(parent)
89  { qRegisterMetaType<SignOn::Error>("SignOn::Error"); }
90 
94  virtual ~AuthPluginInterface() {}
95 
101  virtual QString type() const = 0;
102 
108  virtual QStringList mechanisms() const = 0;
109 
116  virtual void cancel() {}
117 
124  virtual void abort() {}
125 
139  virtual void process(const SignOn::SessionData &inData,
140  const QString &mechanism = QString()) = 0;
141 
142 Q_SIGNALS:
149  void result(const SignOn::SessionData &data);
150 
161  void store(const SignOn::SessionData &data);
162 
170  void error(const SignOn::Error &err);
171 
184  void userActionRequired(const SignOn::UiSessionData &data);
185 
193  void refreshed(const SignOn::UiSessionData &data);
194 
202  void statusChanged(const AuthPluginState state,
203  const QString &message = QString());
204 
205 public Q_SLOTS:
216  virtual void userActionFinished(const SignOn::UiSessionData &data) {
217  Q_UNUSED(data);
218  }
219 
232  virtual void refresh(const SignOn::UiSessionData &data) {
233  emit refreshed(data);
234  }
235 
236 };
237 
238 QT_BEGIN_NAMESPACE
239  Q_DECLARE_INTERFACE(AuthPluginInterface,
240  "com.nokia.SingleSignOn.PluginInterface/1.3")
241 QT_END_NAMESPACE
242 #endif // AUTHPLUGINIF_H
SignOn::UiSessionData
Definition: uisessiondata.h:76
AuthPluginInterface::statusChanged
void statusChanged(const AuthPluginState state, const QString &message=QString())
Emitted to report status of authentication process to signond for informing client application.
AuthPluginInterface::type
virtual QString type() const =0
Gets the type of the plugin.
AuthPluginInterface::userActionFinished
virtual void userActionFinished(const SignOn::UiSessionData &data)
User interaction completed.
Definition: authpluginif.h:216
AuthPluginInterface::store
void store(const SignOn::SessionData &data)
Emitted when authentication process want to store session data parameters for later use.
AuthPluginInterface::mechanisms
virtual QStringList mechanisms() const =0
Gets the list of supported mechanisms.
AuthPluginInterface::refreshed
void refreshed(const SignOn::UiSessionData &data)
Emitted when authentication process has completed refresh request.
AuthPluginInterface::cancel
virtual void cancel()
Requests to cancel the process.
Definition: authpluginif.h:116
AuthPluginInterface::refresh
virtual void refresh(const SignOn::UiSessionData &data)
Refreshes given session.
Definition: authpluginif.h:232
AuthPluginInterface::result
void result(const SignOn::SessionData &data)
Emitted when authentication process has been completed for given data and there are no errors.
AuthPluginInterface::userActionRequired
void userActionRequired(const SignOn::UiSessionData &data)
Emitted when authentication process need to interact with user.
AuthPluginInterface::process
virtual void process(const SignOn::SessionData &inData, const QString &mechanism=QString())=0
Process authentication.
AuthPluginInterface::abort
virtual void abort()
Requests to abort the process.
Definition: authpluginif.h:124
AuthPluginInterface::~AuthPluginInterface
virtual ~AuthPluginInterface()
Destructor.
Definition: authpluginif.h:94
AuthPluginInterface
Definition: authpluginif.h:83
AuthPluginInterface::error
void error(const SignOn::Error &err)
Emitted when authentication process has been completed for given data and resulting an error.