[Telepathy-commits] [telepathy-qt4/master] ConnectionManager: add a skeletal ConnectionManager class

Simon McVittie simon.mcvittie at collabora.co.uk
Fri Dec 5 07:13:04 PST 2008


---
 TelepathyQt4/Makefile.am                |    1 +
 TelepathyQt4/cli-connection-manager.cpp |   74 +++++++++++++++++++++++++++++++
 TelepathyQt4/cli-connection-manager.h   |   55 +++++++++++++++++++++++
 3 files changed, 130 insertions(+), 0 deletions(-)

diff --git a/TelepathyQt4/Makefile.am b/TelepathyQt4/Makefile.am
index 8e8d265..cdd0d43 100644
--- a/TelepathyQt4/Makefile.am
+++ b/TelepathyQt4/Makefile.am
@@ -75,6 +75,7 @@ nodist_libtelepathy_qt4_la_SOURCES = \
     _gen/types-body.hpp \
     cli-channel.moc.hpp \
     cli-connection.moc.hpp \
+    cli-connection-manager.moc.hpp \
     cli-dbus-proxy.moc.hpp \
     cli-pending-channel.moc.hpp \
     cli-pending-operation.moc.hpp \
diff --git a/TelepathyQt4/cli-connection-manager.cpp b/TelepathyQt4/cli-connection-manager.cpp
index 35a4b0a..a0aca31 100644
--- a/TelepathyQt4/cli-connection-manager.cpp
+++ b/TelepathyQt4/cli-connection-manager.cpp
@@ -19,5 +19,79 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include "cli-connection-manager.h"
+
+#include <TelepathyQt4/Constants>
+
+#include "TelepathyQt4/debug-internal.hpp"
+
+namespace Telepathy
+{
+namespace Client
+{
+
+
+struct ConnectionManager::Private
+{
+    ConnectionManager& parent;
+
+    ConnectionManagerInterface* baseInterface;
+
+    static inline QString makeBusName(const QString& name)
+    {
+        return QString::fromAscii(
+                TELEPATHY_CONNECTION_MANAGER_BUS_NAME_BASE).append(name);
+    }
+
+    static inline QString makeObjectPath(const QString& name)
+    {
+        return QString::fromAscii(
+                TELEPATHY_CONNECTION_MANAGER_OBJECT_PATH_BASE).append(name);
+    }
+
+    inline Private(ConnectionManager& parent)
+        : parent(parent),
+          baseInterface(new ConnectionManagerInterface(parent.dbusConnection(),
+                      parent.busName(), parent.objectPath(), &parent))
+    {
+        debug() << "Creating new ConnectionManager:" << parent.busName();
+    }
+};
+
+
+ConnectionManager::ConnectionManager(const QString& name, QObject* parent)
+    : StatelessDBusProxy(QDBusConnection::sessionBus(),
+            Private::makeBusName(name), Private::makeObjectPath(name),
+            parent),
+      mPriv(new Private(*this))
+{
+}
+
+
+ConnectionManager::ConnectionManager(const QDBusConnection& bus,
+        const QString& name, QObject* parent)
+    : StatelessDBusProxy(bus, Private::makeBusName(name),
+            Private::makeObjectPath(name), parent),
+      mPriv(new Private(*this))
+{
+}
+
+
+ConnectionManager::~ConnectionManager()
+{
+    delete mPriv;
+}
+
+
+ConnectionManagerInterface* ConnectionManager::baseInterface() const
+{
+    return mPriv->baseInterface;
+}
+
+
+} // Telepathy::Client
+} // Telepathy
+
 #include <TelepathyQt4/_gen/cli-connection-manager-body.hpp>
 #include <TelepathyQt4/_gen/cli-connection-manager.moc.hpp>
+#include <TelepathyQt4/cli-connection-manager.moc.hpp>
diff --git a/TelepathyQt4/cli-connection-manager.h b/TelepathyQt4/cli-connection-manager.h
index 97b8095..9484534 100644
--- a/TelepathyQt4/cli-connection-manager.h
+++ b/TelepathyQt4/cli-connection-manager.h
@@ -42,4 +42,59 @@
 
 #include <TelepathyQt4/_gen/cli-connection-manager.h>
 
+#include <TelepathyQt4/Client/DBusProxy>
+#include <TelepathyQt4/Client/OptionalInterfaceFactory>
+
+namespace Telepathy
+{
+namespace Client
+{
+
+
+/**
+ * \class ConnectionManager
+ * \ingroup clientcm
+ * \headerfile TelepathyQt4/cli-connection-manager.h <TelepathyQt4/Client/ConnectionManager>
+ *
+ * Object representing a Telepathy connection manager. Connection managers
+ * allow connections to be made on one or more protocols.
+ *
+ * Most client applications should use this functionality via the
+ * %AccountManager, to allow connections to be shared between client
+ * applications.
+ */
+class ConnectionManager : public StatelessDBusProxy,
+        private OptionalInterfaceFactory
+{
+    Q_OBJECT
+
+public:
+    ConnectionManager(const QString& name, QObject* parent = 0);
+    ConnectionManager(const QDBusConnection& bus,
+            const QString& name, QObject* parent = 0);
+
+    virtual ~ConnectionManager();
+
+protected:
+    /**
+     * Get the ConnectionManagerInterface for this ConnectionManager. This
+     * method is protected since the convenience methods provided by this
+     * class should generally be used instead of calling D-Bus methods
+     * directly.
+     *
+     * \return A pointer to the existing ConnectionManagerInterface for this
+     *         ConnectionManager
+     */
+    ConnectionManagerInterface* baseInterface() const;
+
+private:
+    struct Private;
+    friend struct Private;
+    Private *mPriv;
+};
+
+
+}
+}
+
 #endif
-- 
1.5.6.5




More information about the Telepathy-commits mailing list