[Telepathy-commits] [telepathy-qt4/master] PendingOperation: Separate PendingVoidMethodCall into a new header, and add PendingSuccess and PendingFailure

Simon McVittie simon.mcvittie at collabora.co.uk
Mon Dec 8 07:35:49 PST 2008


Library-user code will usually only need
<TelepathyQt4/Client/PendingOperation>, whereas library extension
implementors can use PendingVoidMethodCall, PendingSuccess and
PendingFailure.
---
 TelepathyQt4/Client/PendingFailure           |    8 ++
 TelepathyQt4/Client/PendingSuccess           |    7 ++
 TelepathyQt4/Client/PendingVoidMethodCall    |    8 ++
 TelepathyQt4/Makefile.am                     |    7 ++-
 TelepathyQt4/cli-connection.cpp              |    2 +
 TelepathyQt4/cli-pending-operation.cpp       |    2 +
 TelepathyQt4/cli-pending-operation.h         |   32 --------
 TelepathyQt4/cli-simple-pending-operations.h |  111 ++++++++++++++++++++++++++
 8 files changed, 144 insertions(+), 33 deletions(-)
 create mode 100644 TelepathyQt4/Client/PendingFailure
 create mode 100644 TelepathyQt4/Client/PendingSuccess
 create mode 100644 TelepathyQt4/Client/PendingVoidMethodCall
 create mode 100644 TelepathyQt4/cli-simple-pending-operations.h

diff --git a/TelepathyQt4/Client/PendingFailure b/TelepathyQt4/Client/PendingFailure
new file mode 100644
index 0000000..a49d428
--- /dev/null
+++ b/TelepathyQt4/Client/PendingFailure
@@ -0,0 +1,8 @@
+#ifndef _TelepathyQt4_Client_PendingFailure_HEADER_GUARD_
+#define _TelepathyQt4_Client_PendingFailure_HEADER_GUARD_
+
+#include <TelepathyQt4/cli-simple-pending-operations.h>
+
+#endif
+// vim:set ft=cpp:
+
diff --git a/TelepathyQt4/Client/PendingSuccess b/TelepathyQt4/Client/PendingSuccess
new file mode 100644
index 0000000..8f9d66a
--- /dev/null
+++ b/TelepathyQt4/Client/PendingSuccess
@@ -0,0 +1,7 @@
+#ifndef _TelepathyQt4_Client_PendingSuccess_HEADER_GUARD_
+#define _TelepathyQt4_Client_PendingSuccess_HEADER_GUARD_
+
+#include <TelepathyQt4/cli-simple-pending-operations.h>
+
+#endif
+// vim:set ft=cpp:
diff --git a/TelepathyQt4/Client/PendingVoidMethodCall b/TelepathyQt4/Client/PendingVoidMethodCall
new file mode 100644
index 0000000..9e3a183
--- /dev/null
+++ b/TelepathyQt4/Client/PendingVoidMethodCall
@@ -0,0 +1,8 @@
+#ifndef _TelepathyQt4_Client_PendingVoidMethodCall_HEADER_GUARD_
+#define _TelepathyQt4_Client_PendingVoidMethodCall_HEADER_GUARD_
+
+#include <TelepathyQt4/cli-simple-pending-operations.h>
+
+#endif
+// vim:set ft=cpp:
+
diff --git a/TelepathyQt4/Makefile.am b/TelepathyQt4/Makefile.am
index 303a804..d9fdc3c 100644
--- a/TelepathyQt4/Makefile.am
+++ b/TelepathyQt4/Makefile.am
@@ -75,7 +75,8 @@ nodist_libtelepathy_qt4_la_SOURCES = \
     cli-channel.moc.hpp \
     cli-connection.moc.hpp \
     cli-dbus-proxy.moc.hpp \
-    cli-pending-operation.moc.hpp
+    cli-pending-operation.moc.hpp \
+    cli-simple-pending-operations.moc.hpp
 
 tpqt4include_HEADERS = \
     Constants \
@@ -93,6 +94,7 @@ tpqt4include_HEADERS = \
     cli-optional-interface-factory.h \
     cli-pending-operation.h \
     cli-properties.h \
+    cli-simple-pending-operations.h \
     constants.h \
     debug.h \
     types.h
@@ -107,7 +109,10 @@ tpqt4clientinclude_HEADERS = \
     Client/MediaSessionHandler \
     Client/MediaStreamHandler \
     Client/OptionalInterfaceFactory \
+    Client/PendingFailure \
     Client/PendingOperation \
+    Client/PendingSuccess \
+    Client/PendingVoidMethodCall \
     Client/Properties
 
 nodist_geninclude_HEADERS = \
diff --git a/TelepathyQt4/cli-connection.cpp b/TelepathyQt4/cli-connection.cpp
index 372dd9c..c3ca4c4 100644
--- a/TelepathyQt4/cli-connection.cpp
+++ b/TelepathyQt4/cli-connection.cpp
@@ -30,6 +30,8 @@
 #include <QString>
 #include <QtGlobal>
 
+#include <TelepathyQt4/Client/PendingVoidMethodCall>
+
 #include "debug-internal.hpp"
 
 namespace Telepathy
diff --git a/TelepathyQt4/cli-pending-operation.cpp b/TelepathyQt4/cli-pending-operation.cpp
index e1e4910..1cc1acb 100644
--- a/TelepathyQt4/cli-pending-operation.cpp
+++ b/TelepathyQt4/cli-pending-operation.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "cli-pending-operation.h"
+#include "cli-simple-pending-operations.h"
 
 #include <QTimer>
 
@@ -27,6 +28,7 @@
 #include <QDBusPendingCallWatcher>
 
 #include "cli-pending-operation.moc.hpp"
+#include "cli-simple-pending-operations.moc.hpp"
 #include "debug-internal.hpp"
 
 namespace Telepathy
diff --git a/TelepathyQt4/cli-pending-operation.h b/TelepathyQt4/cli-pending-operation.h
index ec7d649..937ed8a 100644
--- a/TelepathyQt4/cli-pending-operation.h
+++ b/TelepathyQt4/cli-pending-operation.h
@@ -170,38 +170,6 @@ private:
 };
 
 
-/**
- * Generic subclass of %PendingOperation representing a pending D-Bus method
- * call that does not return anything (or returns a result that is not
- * interesting).
- *
- * Objects of this class indicate the success or failure of the method call,
- * but if the method call succeeds, no additional information is available.
- */
-class PendingVoidMethodCall : public PendingOperation
-{
-    Q_OBJECT
-
-public:
-    /**
-     * Constructor.
-     *
-     * \param parent The object on which this pending operation takes place
-     * \param call A pending call as returned by the auto-generated low level
-     *             Telepathy API; if the method returns anything, the return
-     *             value(s) will be ignored
-     */
-    PendingVoidMethodCall(QObject* parent, QDBusPendingCall call);
-
-private Q_SLOTS:
-    void watcherFinished(QDBusPendingCallWatcher*);
-
-private:
-    // just ABI padding at the moment
-    struct Private;
-    Private *mPriv;
-};
-
 } // Telepathy::Client
 } // Telepathy
 
diff --git a/TelepathyQt4/cli-simple-pending-operations.h b/TelepathyQt4/cli-simple-pending-operations.h
new file mode 100644
index 0000000..bd1f5e2
--- /dev/null
+++ b/TelepathyQt4/cli-simple-pending-operations.h
@@ -0,0 +1,111 @@
+/*
+ * This file is part of TelepathyQt4
+ *
+ * Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2008 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_cli_pending_operations_h_HEADER_GUARD_
+#define _TelepathyQt4_cli_pending_operations_h_HEADER_GUARD_
+
+#include <QObject>
+
+#include <TelepathyQt4/Client/PendingOperation>
+
+namespace Telepathy
+{
+namespace Client
+{
+
+
+/**
+ * A %PendingOperation that is always successful.
+ */
+class PendingSuccess : public PendingOperation
+{
+    Q_OBJECT
+
+public:
+    PendingSuccess(QObject* parent)
+        : PendingOperation(parent)
+    {
+        setFinished();
+    }
+};
+
+
+/**
+ * A %PendingOperation that always fails with the error passed to the
+ * constructor.
+ */
+class PendingFailure : public PendingOperation
+{
+    Q_OBJECT
+
+public:
+    PendingFailure(QObject* parent, const QString& name,
+            const QString& message)
+        : PendingOperation(parent)
+    {
+        setFinishedWithError(name, message);
+    }
+
+    PendingFailure(QObject* parent, const QDBusError& error)
+        : PendingOperation(parent)
+    {
+        setFinishedWithError(error);
+    }
+};
+
+
+/**
+ * Generic subclass of %PendingOperation representing a pending D-Bus method
+ * call that does not return anything (or returns a result that is not
+ * interesting).
+ *
+ * Objects of this class indicate the success or failure of the method call,
+ * but if the method call succeeds, no additional information is available.
+ */
+class PendingVoidMethodCall : public PendingOperation
+{
+    Q_OBJECT
+
+public:
+    /**
+     * Constructor.
+     *
+     * \param parent The object on which this pending operation takes place
+     * \param call A pending call as returned by the auto-generated low level
+     *             Telepathy API; if the method returns anything, the return
+     *             value(s) will be ignored
+     */
+    PendingVoidMethodCall(QObject* parent, QDBusPendingCall call);
+
+private Q_SLOTS:
+    void watcherFinished(QDBusPendingCallWatcher*);
+
+private:
+    // just ABI padding at the moment
+    struct Private;
+    Private *mPriv;
+};
+
+
+} // Telepathy::Client
+} // Telepathy
+
+#endif
-- 
1.5.6.5



More information about the Telepathy-commits mailing list