[Telepathy-commits] [telepathy-qt4/master] Add stub Connection high-level proxy

Olli Salli olli.salli at collabora.co.uk
Mon Sep 22 04:58:08 PDT 2008


---
 TelepathyQt4/cli-connection.cpp |   43 +++++++++++++++++++++++
 TelepathyQt4/cli-connection.h   |   71 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 114 insertions(+), 0 deletions(-)

diff --git a/TelepathyQt4/cli-connection.cpp b/TelepathyQt4/cli-connection.cpp
index 9020c42..e1c86e1 100644
--- a/TelepathyQt4/cli-connection.cpp
+++ b/TelepathyQt4/cli-connection.cpp
@@ -19,5 +19,48 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <TelepathyQt4/Client/Connection>
+
 #include <TelepathyQt4/_gen/cli-connection-body.hpp>
 #include <TelepathyQt4/_gen/cli-connection.moc.hpp>
+
+namespace Telepathy
+{
+namespace Client
+{
+
+struct Connection::Private
+{
+    ConnectionInterface interface;
+
+    Private(const QDBusConnection& connection, const QString& serviceName, const QString& objectPath, QObject* parent)
+        : interface(connection, serviceName, objectPath, parent) {}
+};
+
+Connection::Connection(const QString& serviceName, const QString& objectPath, QObject* parent)
+    : mPriv(new Private(QDBusConnection::sessionBus(), serviceName, objectPath, parent))
+{
+}
+
+Connection::Connection(const QDBusConnection& connection, const QString& serviceName, const QString& objectPath, QObject* parent)
+    : mPriv(new Private(connection, serviceName, objectPath, parent))
+{
+}
+
+Connection::~Connection()
+{
+    delete mPriv;
+}
+
+ConnectionInterface& Connection::interface()
+{
+    return mPriv->interface;
+}
+
+const ConnectionInterface& Connection::interface() const
+{
+    return mPriv->interface;
+}
+
+}
+}
diff --git a/TelepathyQt4/cli-connection.h b/TelepathyQt4/cli-connection.h
index 45b0da2..fb8d561 100644
--- a/TelepathyQt4/cli-connection.h
+++ b/TelepathyQt4/cli-connection.h
@@ -43,4 +43,75 @@
 
 #include <TelepathyQt4/_gen/cli-connection.h>
 
+namespace Telepathy
+{
+namespace Client
+{
+
+/**
+ * \class Connection
+ * \ingroup clientconn
+ *
+ * High-level proxy object for accessing remote %Telepathy %Connection objects.
+ *
+ * It adds the following features compared to using ConnectionInterface alone:
+ * <ul>
+ *  <li>%Connection status tracking</li>
+ *  <li>Calling GetInterfaces automatically</li>
+ * </ul>
+ */
+class Connection : public QObject
+{
+    Q_OBJECT
+public:
+    /**
+     * Creates a Connection associated with the given object on the session bus.
+     *
+     * \param serviceName Name of the service the object is on.
+     * \param objectPath  Path to the object on the service.
+     * \param parent      Passed to the parent class constructor.
+     */
+    Connection(const QString& serviceName,
+               const QString& objectPath,
+               QObject* parent = 0);
+
+    /**
+     * Creates a Connection associated with the given object on the given bus.
+     *
+     * \param connection  The bus via which the object can be reached.
+     * \param serviceName Name of the service the object is on.
+     * \param objectPath  Path to the object on the service.
+     * \param parent      Passed to the parent class constructor.
+     */
+    Connection(const QDBusConnection& connection,
+               const QString &serviceName,
+               const QString &objectPath,
+               QObject* parent = 0);
+
+    /**
+     * Class destructor.
+     */
+    ~Connection();
+
+    /**
+     * Returns a reference to the underlying ConnectionInterface instance for
+     * easy direct access to the D-Bus properties, methods and signals on the
+     * remote object.
+     *
+     * Note that this class provides a more convenient interface for some
+     * functionality than using the interface class directly.
+     *
+     * \return A reference to the underlying ConnectionInterface instance.
+     */
+    ConnectionInterface& interface();
+    const ConnectionInterface& interface() const;
+
+private:
+    struct Private;
+    Private *mPriv;
+};
+
+}
+}
+
 #endif
-- 
1.5.6.5




More information about the Telepathy-commits mailing list