[telepathy-qt4/master] PendingVariant: Added PendingVariant class.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Mon Sep 28 19:03:43 PDT 2009
PendingVariant is a new PendingOperation that can handle QDBusPendingCalls that
return a QVariant. The result can be retrieved using PendingVariant::result().
---
TelepathyQt4/Makefile.am | 4 ++
TelepathyQt4/PendingVariant | 13 ++++++
TelepathyQt4/pending-variant.cpp | 82 ++++++++++++++++++++++++++++++++++++++
TelepathyQt4/pending-variant.h | 58 +++++++++++++++++++++++++++
4 files changed, 157 insertions(+), 0 deletions(-)
create mode 100644 TelepathyQt4/PendingVariant
create mode 100644 TelepathyQt4/pending-variant.cpp
create mode 100644 TelepathyQt4/pending-variant.h
diff --git a/TelepathyQt4/Makefile.am b/TelepathyQt4/Makefile.am
index 266124e..e0dde82 100644
--- a/TelepathyQt4/Makefile.am
+++ b/TelepathyQt4/Makefile.am
@@ -90,6 +90,7 @@ libtelepathy_qt4_la_SOURCES = \
pending-operation.cpp \
pending-ready.cpp \
pending-string-list.cpp \
+ pending-variant.cpp \
properties.cpp \
readiness-helper.cpp \
ready-object.cpp \
@@ -156,6 +157,7 @@ nodist_libtelepathy_qt4_la_SOURCES = \
_gen/pending-operation.moc.hpp \
_gen/pending-ready.moc.hpp \
_gen/pending-string-list.moc.hpp \
+ _gen/pending-variant.moc.hpp \
_gen/readiness-helper.moc.hpp \
_gen/room-list-channel.moc.hpp \
_gen/simple-pending-operations.moc.hpp \
@@ -205,6 +207,7 @@ tpqt4include_HEADERS = \
PendingReady \
PendingSuccess \
PendingStringList \
+ PendingVariant \
PendingVoidMethodCall \
Properties \
ReadinessHelper \
@@ -298,6 +301,7 @@ tpqt4include_HEADERS = \
pending-operation.h \
pending-ready.h \
pending-string-list.h \
+ pending-variant.h \
properties.h \
readiness-helper.h \
ready-object.h \
diff --git a/TelepathyQt4/PendingVariant b/TelepathyQt4/PendingVariant
new file mode 100644
index 0000000..d2473d3
--- /dev/null
+++ b/TelepathyQt4/PendingVariant
@@ -0,0 +1,13 @@
+#ifndef _TelepathyQt4_PendingVariant_HEADER_GUARD_
+#define _TelepathyQt4_PendingVariant_HEADER_GUARD_
+
+#ifndef IN_TELEPATHY_QT4_HEADER
+#define IN_TELEPATHY_QT4_HEADER
+#endif
+
+#include <TelepathyQt4/pending-variant.h>
+
+#undef IN_TELEPATHY_QT4_HEADER
+
+#endif
+// vim:set ft=cpp:
diff --git a/TelepathyQt4/pending-variant.cpp b/TelepathyQt4/pending-variant.cpp
new file mode 100644
index 0000000..027e526
--- /dev/null
+++ b/TelepathyQt4/pending-variant.cpp
@@ -0,0 +1,82 @@
+/*
+ * This file is part of TelepathyQt4
+ *
+ * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2009 Nokia Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <TelepathyQt4/PendingVariant>
+
+#include "TelepathyQt4/_gen/pending-variant.moc.hpp"
+#include "TelepathyQt4/debug-internal.h"
+
+#include <QDBusPendingReply>
+
+namespace Tp
+{
+
+struct PendingVariant::Private
+{
+ QVariant result;
+};
+
+/**
+ * \class PendingVariant
+ * \headerfile <TelepathyQt4/pending-variant.h> <TelepathyQt4/PendingVariant>
+ */
+
+PendingVariant::PendingVariant(QDBusPendingCall call, QObject *parent)
+ : PendingOperation(parent),
+ mPriv(new Private)
+{
+ connect(new QDBusPendingCallWatcher(call),
+ SIGNAL(finished(QDBusPendingCallWatcher*)),
+ this,
+ SLOT(watcherFinished(QDBusPendingCallWatcher*)));
+}
+
+/**
+ * Class destructor.
+ */
+PendingVariant::~PendingVariant()
+{
+ delete mPriv;
+}
+
+QVariant PendingVariant::result() const
+{
+ return mPriv->result;
+}
+
+void PendingVariant::watcherFinished(QDBusPendingCallWatcher* watcher)
+{
+ QDBusPendingReply<QVariant> reply = *watcher;
+
+ if (!reply.isError()) {
+ debug() << "Got reply to PendingVariant call";
+ mPriv->result = reply.value();
+ setFinished();
+ } else {
+ debug().nospace() << "PendingVariant call failed: " <<
+ reply.error().name() << ": " << reply.error().message();
+ setFinishedWithError(reply.error());
+ }
+
+ watcher->deleteLater();
+}
+
+} // Tp
diff --git a/TelepathyQt4/pending-variant.h b/TelepathyQt4/pending-variant.h
new file mode 100644
index 0000000..744f526
--- /dev/null
+++ b/TelepathyQt4/pending-variant.h
@@ -0,0 +1,58 @@
+/*
+ * This file is part of TelepathyQt4
+ *
+ * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2009 Nokia Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _TelepathyQt4_pending_variant_h_HEADER_GUARD_
+#define _TelepathyQt4_pending_variant_h_HEADER_GUARD_
+
+#ifndef IN_TELEPATHY_QT4_HEADER
+#error IN_TELEPATHY_QT4_HEADER
+#endif
+
+#include <TelepathyQt4/PendingOperation>
+
+#include <QVariant>
+
+namespace Tp
+{
+
+class PendingVariant : public PendingOperation
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(PendingVariant);
+
+public:
+ PendingVariant(QDBusPendingCall call, QObject *parent = 0);
+ ~PendingVariant();
+
+ QVariant result() const;
+
+private Q_SLOTS:
+ void watcherFinished(QDBusPendingCallWatcher*);
+
+private:
+ struct Private;
+ friend struct Private;
+ Private *mPriv;
+};
+
+} // Tp
+
+#endif
--
1.5.6.5
More information about the telepathy-commits
mailing list