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
40QT_BEGIN_NAMESPACE
41class QString;
42#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
43using QStringList = class QList<QString>;
44#else
45class QStringList;
46#endif
47class QByteArray;
48class QVariant;
49QT_END_NAMESPACE
50
54enum AuthPluginState {
55 PLUGIN_STATE_NONE = 0,
56 PLUGIN_STATE_RESOLVING,
57 PLUGIN_STATE_CONNECTING,
58 PLUGIN_STATE_SENDING,
59 PLUGIN_STATE_WAITING,
60 PLUGIN_STATE_PENDING,
61 PLUGIN_STATE_REFRESHING,
62 PLUGIN_STATE_CANCELING,
63 PLUGIN_STATE_HOLDING,
64 PLUGIN_STATE_DONE
65};
66
71#define SIGNON_PLUGIN_INSTANCE(pluginclass) \
72 { \
73 static AuthPluginInterface *_instance = 0; \
74 if (!_instance) \
75 _instance = static_cast<AuthPluginInterface *>(new pluginclass()); \
76 return _instance; \
77 }
78
79#ifndef Q_EXTERN_C
80# ifdef __cplusplus
81# define Q_EXTERN_C extern "C"
82# else
83# define Q_EXTERN_C extern
84# endif
85#endif
86
87#define SIGNON_DECL_AUTH_PLUGIN(pluginclass) \
88 Q_EXTERN_C AuthPluginInterface *auth_plugin_instance() \
89 SIGNON_PLUGIN_INSTANCE(pluginclass)
90
95class AuthPluginInterface : public QObject
96{
97 Q_OBJECT
98
99public:
100 AuthPluginInterface(QObject *parent = 0) : QObject(parent)
101 { qRegisterMetaType<SignOn::Error>("SignOn::Error"); }
102
107
113 virtual QString type() const = 0;
114
120 virtual QStringList mechanisms() const = 0;
121
128 virtual void cancel() {}
129
136 virtual void abort() {}
137
151 virtual void process(const SignOn::SessionData &inData,
152 const QString &mechanism = QString()) = 0;
153
154Q_SIGNALS:
161 void result(const SignOn::SessionData &data);
162
173 void store(const SignOn::SessionData &data);
174
182 void error(const SignOn::Error &err);
183
197
206
214 void statusChanged(const AuthPluginState state,
215 const QString &message = QString());
216
217public Q_SLOTS:
228 virtual void userActionFinished(const SignOn::UiSessionData &data) {
229 Q_UNUSED(data);
230 }
231
244 virtual void refresh(const SignOn::UiSessionData &data) {
245 emit refreshed(data);
246 }
247
248};
249
250QT_BEGIN_NAMESPACE
251 Q_DECLARE_INTERFACE(AuthPluginInterface,
252 "com.nokia.SingleSignOn.PluginInterface/1.3")
253QT_END_NAMESPACE
254#endif // AUTHPLUGINIF_H
virtual QStringList mechanisms() const =0
Gets the list of supported mechanisms.
void refreshed(const SignOn::UiSessionData &data)
Emitted when authentication process has completed refresh request.
void statusChanged(const AuthPluginState state, const QString &message=QString())
Emitted to report status of authentication process to signond for informing client application.
virtual void userActionFinished(const SignOn::UiSessionData &data)
User interaction completed.
Definition: authpluginif.h:228
virtual QString type() const =0
Gets the type of the plugin.
void error(const SignOn::Error &err)
Emitted when authentication process has been completed for given data and resulting an error.
virtual void process(const SignOn::SessionData &inData, const QString &mechanism=QString())=0
Process authentication.
virtual ~AuthPluginInterface()
Destructor.
Definition: authpluginif.h:106
virtual void abort()
Requests to abort the process.
Definition: authpluginif.h:136
void result(const SignOn::SessionData &data)
Emitted when authentication process has been completed for given data and there are no errors.
virtual void cancel()
Requests to cancel the process.
Definition: authpluginif.h:128
virtual void refresh(const SignOn::UiSessionData &data)
Refreshes given session.
Definition: authpluginif.h:244
void userActionRequired(const SignOn::UiSessionData &data)
Emitted when authentication process need to interact with user.
void store(const SignOn::SessionData &data)
Emitted when authentication process want to store session data parameters for later use.
Data container to hold values for authentication session.
Definition: uisessiondata.h:77