[Telepathy-commits] [telepathy-qt4/master] Change the Channel class parent to QObject and make the ChannelInterface a member of the private struct. Get everything compiling and working as before. Methods not currently in the convenience class still need to be added.

George Goldberg george.goldberg at collabora.co.uk
Wed Nov 19 06:03:09 PST 2008


---
 TelepathyQt4/cli-channel.cpp |   23 ++++++++++++++++-------
 TelepathyQt4/cli-channel.h   |   17 ++++++++++++++---
 2 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/TelepathyQt4/cli-channel.cpp b/TelepathyQt4/cli-channel.cpp
index 3d4d0b2..89bfb2a 100644
--- a/TelepathyQt4/cli-channel.cpp
+++ b/TelepathyQt4/cli-channel.cpp
@@ -41,6 +41,9 @@ struct Channel::Private
     // Public object
     Channel& parent;
 
+    // Instance of generated interface class
+    ChannelInterface* baseInterface;
+
     // Optional interface proxies
     ChannelInterfaceGroupInterface* group;
     DBus::PropertiesInterface* properties;
@@ -82,6 +85,7 @@ struct Channel::Private
     {
         debug() << "Creating new Channel";
 
+        baseInterface = 0;
         group = 0;
         properties = 0;
         readiness = ReadinessJustCreated;
@@ -122,7 +126,7 @@ struct Channel::Private
     {
         debug() << "Calling Channel::GetChannelType()";
         QDBusPendingCallWatcher* watcher =
-            new QDBusPendingCallWatcher(parent.GetChannelType(), &parent);
+            new QDBusPendingCallWatcher(baseInterface->GetChannelType(), &parent);
         parent.connect(watcher,
                        SIGNAL(finished(QDBusPendingCallWatcher*)),
                        SLOT(gotChannelType(QDBusPendingCallWatcher*)));
@@ -132,7 +136,7 @@ struct Channel::Private
     {
         debug() << "Calling Channel::GetHandle()";
         QDBusPendingCallWatcher* watcher =
-            new QDBusPendingCallWatcher(parent.GetHandle(), &parent);
+            new QDBusPendingCallWatcher(baseInterface->GetHandle(), &parent);
         parent.connect(watcher,
                        SIGNAL(finished(QDBusPendingCallWatcher*)),
                        SLOT(gotHandle(QDBusPendingCallWatcher*)));
@@ -142,7 +146,7 @@ struct Channel::Private
     {
         debug() << "Calling Channel::GetInterfaces()";
         QDBusPendingCallWatcher* watcher =
-            new QDBusPendingCallWatcher(parent.GetInterfaces(), &parent);
+            new QDBusPendingCallWatcher(baseInterface->GetInterfaces(), &parent);
         parent.connect(watcher,
                        SIGNAL(finished(QDBusPendingCallWatcher*)),
                        SLOT(gotInterfaces(QDBusPendingCallWatcher*)));
@@ -376,9 +380,9 @@ struct Channel::Private
 Channel::Channel(const QString& serviceName,
                  const QString& objectPath,
                  QObject* parent)
-    : ChannelInterface(serviceName, objectPath, parent),
-      mPriv(new Private(*this))
+    : mPriv(new Private(*this))
 {
+    mPriv->baseInterface = new ChannelInterface(serviceName, objectPath, this);
     mPriv->continueIntrospection();
 }
 
@@ -386,9 +390,9 @@ Channel::Channel(const QDBusConnection& connection,
                  const QString& serviceName,
                  const QString& objectPath,
                  QObject* parent)
-    : ChannelInterface(connection, serviceName, objectPath, parent),
-      mPriv(new Private(*this))
+    : mPriv(new Private(*this))
 {
+    mPriv->baseInterface = new ChannelInterface(serviceName, objectPath, this);
     mPriv->continueIntrospection();
 }
 
@@ -535,6 +539,11 @@ Channel::GroupMemberChangeInfo Channel::groupSelfRemoveInfo() const
     return mPriv->groupSelfRemoveInfo;
 }
 
+ChannelInterface* Channel::baseInterface() const
+{
+    return mPriv->baseInterface;
+}
+
 void Channel::gotMainProperties(QDBusPendingCallWatcher* watcher)
 {
     QDBusPendingReply<QVariantMap> reply = *watcher;
diff --git a/TelepathyQt4/cli-channel.h b/TelepathyQt4/cli-channel.h
index e3e1445..71f0366 100644
--- a/TelepathyQt4/cli-channel.h
+++ b/TelepathyQt4/cli-channel.h
@@ -81,7 +81,7 @@ namespace Client
  * present) will be cached in the introspection process, and also tracked for
  * any changes.
  */
-class Channel : public ChannelInterface, private OptionalInterfaceFactory
+class Channel : public QObject, private OptionalInterfaceFactory
 {
     Q_OBJECT
     Q_ENUMS(Readiness)
@@ -563,7 +563,7 @@ public:
             return 0;
 
         // If present or forced, delegate to OptionalInterfaceFactory
-        return OptionalInterfaceFactory::interface<Interface>(*this);
+        return OptionalInterfaceFactory::interface<Interface>(*baseInterface());
     }
 
     /**
@@ -689,7 +689,7 @@ public:
             return 0;
 
         // If correct type or check bypassed, delegate to OIF
-        return OptionalInterfaceFactory::interface<Interface>(*this);
+        return OptionalInterfaceFactory::interface<Interface>(*baseInterface());
     }
 
     /**
@@ -736,6 +736,17 @@ public:
         return typeInterface<ChannelTypeTubesInterface>(check);
     }
 
+protected:
+    /**
+     * Get the base ChannelInterface for this Channel class. This method is
+     * protected since the convenience methods provided by this class should
+     * always be used instead of the interface directly by consumers of the
+     * class.
+     *
+     * \return <code>channelInterface<ChannelInterface></code>
+     */
+    ChannelInterface* baseInterface() const;
+
     //@}
 
 private Q_SLOTS:
-- 
1.5.6.5




More information about the Telepathy-commits mailing list