KDECore
DBusHelperProxy.h
Go to the documentation of this file.
00001 /* 00002 * Copyright (C) 2008 Nicola Gigante <nicola.gigante@gmail.com> 00003 * Copyright (C) 2009 Dario Freddi <drf@kde.org> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU Lesser General Public License as published by 00007 * the Free Software Foundation; either version 2.1 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public License 00016 * along with this program; if not, write to the 00017 * Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . 00019 */ 00020 00021 #ifndef DBUS_HELPER_PROXY_H 00022 #define DBUS_HELPER_PROXY_H 00023 00024 #include <QVariant> 00025 #include "HelperProxy.h" 00026 #include "kauthactionreply.h" 00027 00028 namespace KAuth 00029 { 00030 00031 class DBusHelperProxy : public HelperProxy 00032 { 00033 Q_OBJECT 00034 Q_INTERFACES(KAuth::HelperProxy) 00035 00036 QObject *responder; 00037 QString m_name; 00038 QString m_currentAction; 00039 bool m_stopRequest; 00040 QList<QString> m_actionsInProgress; 00041 00042 enum SignalType { 00043 ActionStarted, // The blob argument is empty 00044 ActionPerformed, // The blob argument contains the ActionReply 00045 DebugMessage, // The blob argument contains the debug level and the message (in this order) 00046 ProgressStepIndicator, // The blob argument contains the step indicator 00047 ProgressStepData // The blob argument contains the QVariantMap 00048 }; 00049 00050 public: 00051 DBusHelperProxy() : responder(0), m_stopRequest(false) {} 00052 00053 virtual bool executeActions(const QList<QPair<QString, QVariantMap> > &list, const QString &helperID); 00054 virtual ActionReply executeAction(const QString &action, const QString &helperID, const QVariantMap &arguments); 00055 virtual Action::AuthStatus authorizeAction(const QString& action, const QString& helperID); 00056 virtual void stopAction(const QString &action, const QString &helperID); 00057 00058 virtual bool initHelper(const QString &name); 00059 virtual void setHelperResponder(QObject *o); 00060 virtual bool hasToStopAction(); 00061 virtual void sendDebugMessage(int level, const char *msg); 00062 virtual void sendProgressStep(int step); 00063 virtual void sendProgressStep(const QVariantMap &data); 00064 00065 public slots: 00066 void stopAction(const QString &action); 00067 void performActions(QByteArray blob, const QByteArray &callerID); 00068 QByteArray performAction(const QString &action, const QByteArray &callerID, QByteArray arguments); 00069 uint authorizeAction(const QString &action, const QByteArray &callerID); 00070 00071 signals: 00072 void remoteSignal(int type, const QString &action, const QByteArray &blob); // This signal is sent from the helper to the app 00073 00074 private slots: 00075 void remoteSignalReceived(int type, const QString &action, QByteArray blob); 00076 }; 00077 00078 } // namespace Auth 00079 00080 #endif
KDE 4.6 API Reference