2014-01-28 22:22:59 +00:00
|
|
|
|
|
|
|
#ifndef RESPONSE_WAITER_H
|
|
|
|
#define RESPONSE_WAITER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
#include <QDeclarativeEngine>
|
|
|
|
|
|
|
|
class QDBusPendingCall;
|
|
|
|
class QDBusPendingCallWatcher;
|
|
|
|
|
2014-01-31 10:06:21 +00:00
|
|
|
class DBusResponseWaiter : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
static DBusResponseWaiter* instance();
|
|
|
|
|
|
|
|
///extract QDbusPendingCall from \p variant and blocks untill completed
|
|
|
|
Q_INVOKABLE QVariant waitForReply(QVariant variant) const;
|
|
|
|
|
|
|
|
const QDBusPendingCall* extractPendingCall(QVariant& variant) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DBusResponseWaiter();
|
|
|
|
|
|
|
|
static DBusResponseWaiter* m_instance;
|
|
|
|
QList<int> m_registered;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class DBusAsyncResponse : public QObject
|
2014-01-28 22:22:59 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2014-01-30 16:25:22 +00:00
|
|
|
Q_PROPERTY(QVariant pendingCall WRITE setPendingCall)
|
2014-01-28 22:22:59 +00:00
|
|
|
|
|
|
|
public:
|
2014-01-31 10:06:21 +00:00
|
|
|
DBusAsyncResponse(QObject* parent = 0) : QObject(parent) {}
|
|
|
|
virtual ~DBusAsyncResponse() {};
|
2014-01-28 22:22:59 +00:00
|
|
|
|
|
|
|
void setPendingCall(QVariant e);
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
2014-01-30 16:25:22 +00:00
|
|
|
void success(QVariant result);
|
|
|
|
void error(QString message);
|
2014-01-28 22:22:59 +00:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void onCallFinished(QDBusPendingCallWatcher* watcher);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|