signon  8.58
remotepluginprocess.h
Go to the documentation of this file.
00001 /*
00002  * This file is part of signon
00003  *
00004  * Copyright (C) 2009-2010 Nokia Corporation.
00005  *
00006  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public License
00010  * version 2.1 as published by the Free Software Foundation.
00011  *
00012  * This library is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00020  * 02110-1301 USA
00021  */
00022 
00023 #ifndef REMOTEPLUGINPROCESS_H
00024 #define REMOTEPLUGINPROCESS_H
00025 
00026 #include <QCoreApplication>
00027 #include <QString>
00028 #include <QStringList>
00029 #include <QDataStream>
00030 #include <QByteArray>
00031 #include <QVariant>
00032 #include <QMap>
00033 #include <QIODevice>
00034 #include <QFile>
00035 #include <QDir>
00036 #include <QLibrary>
00037 #include <QSocketNotifier>
00038 #include <QThread>
00039 
00040 #include "SignOn/uisessiondata.h"
00041 #include "SignOn/authpluginif.h"
00042 
00043 extern "C" {
00044 #include <sys/types.h>
00045 #include <sys/socket.h>
00046 #include <signal.h>
00047 }
00048 
00049 #ifndef SIGNOND_PLUGINS_DIR
00050       #define SIGNOND_PLUGINS_DIR "/usr/lib/signon"
00051 #endif
00052 
00053 #ifndef SIGNON_PLUGIN_PREFIX
00054     #define SIGNON_PLUGIN_PREFIX "lib"
00055 #endif
00056 
00057 #ifndef SIGNON_PLUGIN_SUFFIX
00058     #define SIGNON_PLUGIN_SUFFIX "plugin.so"
00059 #endif
00060 
00061 using namespace SignOn;
00062 
00063 namespace SignOn {
00064     class BlobIOHandler;
00065 };
00066 
00067 namespace RemotePluginProcessNS {
00068 
00073 class CancelEventThread: public QThread
00074 {
00075     Q_OBJECT
00076 
00077 public:
00078     CancelEventThread(AuthPluginInterface *plugin);
00079     ~CancelEventThread();
00080 
00081     void run();
00082 
00083 public Q_SLOTS:
00084     void cancel();
00085 
00086 private:
00087     AuthPluginInterface *m_plugin;
00088     QSocketNotifier *m_cancelNotifier;
00089 };
00090 
00095 class RemotePluginProcess: public QObject
00096 {
00097     Q_OBJECT
00098 
00099 public:
00100     RemotePluginProcess(QObject *parent);
00101     ~RemotePluginProcess();
00102 
00103     static RemotePluginProcess* createRemotePluginProcess(QString &type,
00104                                                           QObject *parent);
00105 
00106     bool loadPlugin(QString &type);
00107     bool setupDataStreams();
00108     bool setupProxySettings();
00109 
00110 public Q_SLOTS:
00111     void startTask();
00112     void sessionDataReceived(const QVariantMap &sessionDataMap);
00113 
00114 private:
00115     AuthPluginInterface *m_plugin;
00116 
00117     QFile m_inFile;
00118     QFile m_outFile;
00119 
00120     QSocketNotifier *m_readnotifier;
00121     QSocketNotifier *m_errnotifier;
00122 
00123     BlobIOHandler *m_blobIOHandler;
00124 
00125     //Requiered for async session data reading
00126     quint32 m_currentOperation;
00127     QString m_currentMechanism;
00128 
00129 private:
00130     QString getPluginName(const QString &type);
00131     void type();
00132     void mechanism();
00133     void mechanisms();
00134 
00135     void process();
00136     void userActionFinished();
00137     void refresh();
00138 
00139     void enableCancelThread();
00140     void disableCancelThread();
00141 
00142 private Q_SLOTS:
00143     void result(const SignOn::SessionData &data);
00144     void store(const SignOn::SessionData &data);
00145     void error(const SignOn::Error &err);
00146     void userActionRequired(const SignOn::UiSessionData &data);
00147     void refreshed(const SignOn::UiSessionData &data);
00148     void statusChanged(const AuthPluginState state, const QString &message);
00149     void blobIOError();
00150 
00151 Q_SIGNALS :
00152     void processStopped();
00153 };
00154 
00155 } //namespace RemotePluginProcessNS
00156 
00157 #endif /* REMOTEPLUGINPROCESS_H */