[telepathy-qt4/master] PendingStringList: Added constructor that takes a QDBusPendingCall that returns a QStringList.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Thu May 7 13:22:41 PDT 2009


---
 TelepathyQt4/pending-string-list.cpp |   27 +++++++++++++++++++++++++++
 TelepathyQt4/pending-string-list.h   |    4 ++++
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/TelepathyQt4/pending-string-list.cpp b/TelepathyQt4/pending-string-list.cpp
index 24f9e1a..db378a4 100644
--- a/TelepathyQt4/pending-string-list.cpp
+++ b/TelepathyQt4/pending-string-list.cpp
@@ -45,6 +45,16 @@ PendingStringList::PendingStringList(QObject *parent)
 {
 }
 
+PendingStringList::PendingStringList(QDBusPendingCall call, QObject *parent)
+    : PendingOperation(parent),
+      mPriv(new Private)
+{
+    connect(new QDBusPendingCallWatcher(call),
+            SIGNAL(finished(QDBusPendingCallWatcher*)),
+            this,
+            SLOT(watcherFinished(QDBusPendingCallWatcher*)));
+}
+
 /**
  * Class destructor.
  */
@@ -63,4 +73,21 @@ void PendingStringList::setResult(const QStringList &result)
     mPriv->result = result;
 }
 
+void PendingStringList::watcherFinished(QDBusPendingCallWatcher* watcher)
+{
+    QDBusPendingReply<QStringList> reply = *watcher;
+
+    if (!reply.isError()) {
+        debug() << "Got reply to PendingStringList call";
+        setResult(reply.value());
+        setFinished();
+    } else {
+        debug().nospace() << "PendingStringList call failed: " <<
+            reply.error().name() << ": " << reply.error().message();
+        setFinishedWithError(reply.error());
+    }
+
+    watcher->deleteLater();
+}
+
 } // Tp
diff --git a/TelepathyQt4/pending-string-list.h b/TelepathyQt4/pending-string-list.h
index b41ca73..cae1452 100644
--- a/TelepathyQt4/pending-string-list.h
+++ b/TelepathyQt4/pending-string-list.h
@@ -39,6 +39,7 @@ class PendingStringList : public PendingOperation
 
 public:
     PendingStringList(QObject *parent = 0);
+    PendingStringList(QDBusPendingCall call, QObject *parent = 0);
     ~PendingStringList();
 
     QStringList result() const;
@@ -46,6 +47,9 @@ public:
 protected:
     void setResult(const QStringList &result);
 
+private Q_SLOTS:
+    void watcherFinished(QDBusPendingCallWatcher*);
+
 private:
     Q_DISABLE_COPY(PendingStringList);
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list