[telepathy-qt4/master] ClientRegistrar: Add multiple interfaces support on Client.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Wed May 6 10:11:45 PDT 2009


Removed AbstractClient, as there is no way to multiple inherit and use SharedPtr
at the same time, in favor of ClientObject.
To implement multiple interfaces clients will create a ClientObject and set it's
handler, approver, observer accordingly.
For now ClientObject only support handlers, but approver and observer support
will be added in the future when they exist.
---
 TelepathyQt4/ClientObject                |   13 ++++++
 TelepathyQt4/Makefile.am                 |    4 +-
 TelepathyQt4/abstract-client.cpp         |    9 ----
 TelepathyQt4/abstract-client.h           |   20 +--------
 TelepathyQt4/client-object.cpp           |   58 +++++++++++++++++++++++++++
 TelepathyQt4/client-object.h             |   57 +++++++++++++++++++++++++++
 TelepathyQt4/client-registrar-internal.h |   18 +++++----
 TelepathyQt4/client-registrar.cpp        |   48 ++++++++++++-----------
 TelepathyQt4/client-registrar.h          |    6 +-
 TelepathyQt4/types.h                     |    6 ++-
 tests/dbus/client-handler.cpp            |   63 +++++++++++++++++------------
 11 files changed, 212 insertions(+), 90 deletions(-)
 create mode 100644 TelepathyQt4/ClientObject
 create mode 100644 TelepathyQt4/client-object.cpp
 create mode 100644 TelepathyQt4/client-object.h

diff --git a/TelepathyQt4/ClientObject b/TelepathyQt4/ClientObject
new file mode 100644
index 0000000..722d250
--- /dev/null
+++ b/TelepathyQt4/ClientObject
@@ -0,0 +1,13 @@
+#ifndef _TelepathyQt4_Client_ClientObject_HEADER_GUARD_
+#define _TelepathyQt4_Client_ClientObject_HEADER_GUARD_
+
+#ifndef IN_TELEPATHY_QT4_HEADER
+#define IN_TELEPATHY_QT4_HEADER
+#endif
+
+#include <TelepathyQt4/client-object.h>
+
+#undef IN_TELEPATHY_QT4_HEADER
+
+#endif
+// vim:set ft=cpp:
diff --git a/TelepathyQt4/Makefile.am b/TelepathyQt4/Makefile.am
index 65e9876..dea87cd 100644
--- a/TelepathyQt4/Makefile.am
+++ b/TelepathyQt4/Makefile.am
@@ -52,6 +52,7 @@ libtelepathy_qt4_la_SOURCES = \
     channel.cpp \
     channel-request.cpp \
     client-handler.cpp \
+    client-object.cpp \
     client-registrar.cpp \
     client-registrar-internal.h \
     connection.cpp \
@@ -115,7 +116,6 @@ nodist_libtelepathy_qt4_la_SOURCES = \
     _gen/cli-properties-body.hpp \
     _gen/cli-properties.moc.hpp \
     _gen/types-body.hpp \
-    _gen/abstract-client.moc.hpp \
     _gen/abstract-interface.moc.hpp \
     _gen/account.moc.hpp \
     _gen/account-manager.moc.hpp \
@@ -157,6 +157,7 @@ tpqt4include_HEADERS = \
     Channel \
     ChannelRequest \
     ClientHandler \
+    ClientObject \
     ClientRegistrar \
     Connection \
     ConnectionManager \
@@ -243,6 +244,7 @@ tpqt4include_HEADERS = \
     channel.h \
     channel-request.h \
     client-handler.h \
+    client-object.h \
     client-registrar.h \
     connection.h \
     connection-manager.h \
diff --git a/TelepathyQt4/abstract-client.cpp b/TelepathyQt4/abstract-client.cpp
index dda5056..df1127b 100644
--- a/TelepathyQt4/abstract-client.cpp
+++ b/TelepathyQt4/abstract-client.cpp
@@ -23,20 +23,11 @@
 
 #include "TelepathyQt4/_gen/abstract-client.moc.hpp"
 
-#include <QObject>
 #include <QString>
 
 namespace Tp
 {
 
-AbstractClient::AbstractClient()
-{
-}
-
-AbstractClient::~AbstractClient()
-{
-}
-
 struct AbstractClientHandler::Private
 {
     ChannelClassList channelFilter;
diff --git a/TelepathyQt4/abstract-client.h b/TelepathyQt4/abstract-client.h
index a599428..97cc99c 100644
--- a/TelepathyQt4/abstract-client.h
+++ b/TelepathyQt4/abstract-client.h
@@ -39,25 +39,9 @@ namespace Tp
 
 class PendingClientOperation;
 
-class AbstractClient : public QObject, public RefCounted
+class AbstractClientHandler : public RefCounted
 {
-    Q_OBJECT
-
-public:
-    virtual ~AbstractClient();
-
-protected:
-    AbstractClient();
-
-private:
-    struct Private;
-    friend struct Private;
-    Private *mPriv;
-};
-
-class AbstractClientHandler : public AbstractClient
-{
-    Q_OBJECT
+    Q_DISABLE_COPY(AbstractClientHandler)
 
 public:
     virtual ~AbstractClientHandler();
diff --git a/TelepathyQt4/client-object.cpp b/TelepathyQt4/client-object.cpp
new file mode 100644
index 0000000..f44a595
--- /dev/null
+++ b/TelepathyQt4/client-object.cpp
@@ -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
+ */
+
+#include <TelepathyQt4/ClientObject>
+
+#include <TelepathyQt4/AbstractClient>
+
+namespace Tp
+{
+
+struct ClientObject::Private
+{
+    AbstractClientHandlerPtr clientHandler;
+};
+
+ClientObjectPtr ClientObject::create(const AbstractClientHandlerPtr &clientHandler)
+{
+    if (!clientHandler) {
+        return ClientObjectPtr();
+    }
+    return ClientObjectPtr(new ClientObject(clientHandler));
+}
+
+ClientObject::ClientObject(const AbstractClientHandlerPtr &clientHandler)
+    : mPriv(new Private)
+{
+    mPriv->clientHandler = clientHandler;
+}
+
+ClientObject::~ClientObject()
+{
+    delete mPriv;
+}
+
+AbstractClientHandlerPtr ClientObject::clientHandler() const
+{
+    return mPriv->clientHandler;
+}
+
+} // Tp
diff --git a/TelepathyQt4/client-object.h b/TelepathyQt4/client-object.h
new file mode 100644
index 0000000..8791d6a
--- /dev/null
+++ b/TelepathyQt4/client-object.h
@@ -0,0 +1,57 @@
+/*
+ * 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_cli_client_object_h_HEADER_GUARD_
+#define _TelepathyQt4_cli_client_object_h_HEADER_GUARD_
+
+#ifndef IN_TELEPATHY_QT4_HEADER
+#error IN_TELEPATHY_QT4_HEADER
+#endif
+
+#include <TelepathyQt4/RefCounted>
+#include <TelepathyQt4/Types>
+
+#include <QObject>
+
+namespace Tp
+{
+
+class ClientObject : public QObject, public RefCounted
+{
+    Q_DISABLE_COPY(ClientObject)
+
+public:
+    static ClientObjectPtr create(const AbstractClientHandlerPtr &clientHandler);
+    ~ClientObject();
+
+    AbstractClientHandlerPtr clientHandler() const;
+
+private:
+    ClientObject(const AbstractClientHandlerPtr &clientHandler);
+
+    struct Private;
+    friend struct Private;
+    Private *mPriv;
+};
+
+} // Tp
+
+#endif
diff --git a/TelepathyQt4/client-registrar-internal.h b/TelepathyQt4/client-registrar-internal.h
index cf86b6a..b504f07 100644
--- a/TelepathyQt4/client-registrar-internal.h
+++ b/TelepathyQt4/client-registrar-internal.h
@@ -87,7 +87,8 @@ class ClientHandlerAdaptor : public QDBusAbstractAdaptor
 
 public:
     ClientHandlerAdaptor(const QDBusConnection &bus,
-            AbstractClientHandler *client);
+            const AbstractClientHandlerPtr &client,
+            QObject *parent);
     virtual ~ClientHandlerAdaptor();
 
 public: // Properties
@@ -128,7 +129,7 @@ private:
     class HandleChannelsCall;
 
     QDBusConnection mBus;
-    AbstractClientHandler *mClient;
+    AbstractClientHandlerPtr mClient;
     QQueue<HandleChannelsCall*> mHandleChannelsQueue;
     bool mProcessingHandleChannels;
 };
@@ -138,7 +139,7 @@ class ClientHandlerAdaptor::HandleChannelsCall : public QObject
     Q_OBJECT
 
 public:
-    HandleChannelsCall(AbstractClientHandler *client,
+    HandleChannelsCall(const AbstractClientHandlerPtr &client,
             const QDBusObjectPath &account,
             const QDBusObjectPath &connection,
             const ChannelDetailsList &channels,
@@ -164,7 +165,7 @@ private:
     void setFinishedWithError(const QString &errorName,
             const QString &errorMessage);
 
-    AbstractClientHandler *mClient;
+    AbstractClientHandlerPtr mClient;
     QDBusObjectPath mAccountPath;
     QDBusObjectPath mConnectionPath;
     ChannelDetailsList mChannelDetailsList;
@@ -200,7 +201,8 @@ class ClientHandlerRequestsAdaptor : public QDBusAbstractAdaptor
 
 public:
     ClientHandlerRequestsAdaptor(const QDBusConnection &bus,
-            AbstractClientHandler *client);
+            const AbstractClientHandlerPtr &client,
+            QObject *parent);
     virtual ~ClientHandlerRequestsAdaptor();
 
 public Q_SLOTS: // Methods
@@ -220,7 +222,7 @@ private:
     class AddRequestCall;
 
     QDBusConnection mBus;
-    AbstractClientHandler *mClient;
+    AbstractClientHandlerPtr mClient;
     QQueue<AddRequestCall*> mAddRequestQueue;
     bool mProcessingAddRequest;
 };
@@ -230,7 +232,7 @@ class ClientHandlerRequestsAdaptor::AddRequestCall : public QObject
     Q_OBJECT
 
 public:
-    AddRequestCall(AbstractClientHandler *client,
+    AddRequestCall(const AbstractClientHandlerPtr &client,
             const QDBusObjectPath &request,
             const QVariantMap &requestProperties,
             const QDBusConnection &bus,
@@ -246,7 +248,7 @@ private Q_SLOTS:
     void onChannelRequestReady(Tp::PendingOperation *op);
 
 private:
-    AbstractClientHandler *mClient;
+    AbstractClientHandlerPtr mClient;
     QDBusObjectPath mRequestPath;
     QVariantMap mRequestProperties;
     QDBusConnection mBus;
diff --git a/TelepathyQt4/client-registrar.cpp b/TelepathyQt4/client-registrar.cpp
index c63f323..5ee9c9d 100644
--- a/TelepathyQt4/client-registrar.cpp
+++ b/TelepathyQt4/client-registrar.cpp
@@ -30,6 +30,7 @@
 #include <TelepathyQt4/Account>
 #include <TelepathyQt4/Channel>
 #include <TelepathyQt4/ChannelRequest>
+#include <TelepathyQt4/ClientObject>
 #include <TelepathyQt4/Connection>
 #include <TelepathyQt4/PendingClientOperation>
 #include <TelepathyQt4/PendingReady>
@@ -49,8 +50,9 @@ ClientAdaptor::~ClientAdaptor()
 }
 
 ClientHandlerAdaptor::ClientHandlerAdaptor(const QDBusConnection &bus,
-        AbstractClientHandler *client)
-    : QDBusAbstractAdaptor(client),
+        const AbstractClientHandlerPtr &client,
+        QObject *parent)
+    : QDBusAbstractAdaptor(parent),
       mBus(bus),
       mClient(client),
       mProcessingHandleChannels(false)
@@ -99,7 +101,7 @@ void ClientHandlerAdaptor::processHandleChannelsQueue()
 }
 
 ClientHandlerAdaptor::HandleChannelsCall::HandleChannelsCall(
-        AbstractClientHandler *client,
+        const AbstractClientHandlerPtr &client,
         const QDBusObjectPath &account,
         const QDBusObjectPath &connection,
         const ChannelDetailsList &channels,
@@ -218,8 +220,9 @@ void ClientHandlerAdaptor::HandleChannelsCall::setFinishedWithError(const QStrin
 
 ClientHandlerRequestsAdaptor::ClientHandlerRequestsAdaptor(
         const QDBusConnection &bus,
-        AbstractClientHandler *client)
-    : QDBusAbstractAdaptor(client),
+        const AbstractClientHandlerPtr &client,
+        QObject *parent)
+    : QDBusAbstractAdaptor(parent),
       mBus(bus),
       mClient(client),
       mProcessingAddRequest(false)
@@ -277,7 +280,7 @@ void ClientHandlerRequestsAdaptor::onAddRequestCallFinished()
 }
 
 ClientHandlerRequestsAdaptor::AddRequestCall::AddRequestCall(
-        AbstractClientHandler *client,
+        const AbstractClientHandlerPtr &client,
         const QDBusObjectPath &request,
         const QVariantMap &requestProperties,
         const QDBusConnection &bus,
@@ -328,7 +331,7 @@ struct ClientRegistrar::Private
     QDBusConnection bus;
     QString busName;
     QString clientName;
-    QHash<AbstractClientPtr, QString> clients;
+    QHash<ClientObjectPtr, QString> clients;
     QSet<QString> services;
 };
 
@@ -370,12 +373,12 @@ QString ClientRegistrar::clientName() const
     return mPriv->clientName;
 }
 
-QList<AbstractClientPtr> ClientRegistrar::registeredClients() const
+QList<ClientObjectPtr> ClientRegistrar::registeredClients() const
 {
     return mPriv->clients.keys();
 }
 
-bool ClientRegistrar::registerClient(const AbstractClientPtr &client,
+bool ClientRegistrar::registerClient(const ClientObjectPtr &client,
         bool unique)
 {
     if (!client) {
@@ -397,7 +400,7 @@ bool ClientRegistrar::registerClient(const AbstractClientPtr &client,
                 .arg(mPriv->bus.baseService()
                     .replace(':', '_')
                     .replace('.', "._"))
-                .arg((ulong) client.data()));
+                .arg((ulong) object));
     }
 
     if (mPriv->services.contains(busName) ||
@@ -411,17 +414,16 @@ bool ClientRegistrar::registerClient(const AbstractClientPtr &client,
 
     ClientHandlerAdaptor *clientHandlerAdaptor = 0;
     ClientHandlerRequestsAdaptor *clientHandlerRequestsAdaptor = 0;
-    AbstractClientHandler *handler =
-        qobject_cast<AbstractClientHandler*>(object);
+    AbstractClientHandlerPtr handler = client->clientHandler();
     if (handler) {
         // export o.f.T.Client.Handler
-        clientHandlerAdaptor = new ClientHandlerAdaptor(mPriv->bus, handler);
+        clientHandlerAdaptor = new ClientHandlerAdaptor(mPriv->bus, handler, object);
         interfaces.append(
                 QLatin1String("org.freedesktop.Telepathy.Client.Handler"));
         if (handler->isListeningRequests()) {
             // export o.f.T.Client.Interface.Requests
             clientHandlerRequestsAdaptor =
-                new ClientHandlerRequestsAdaptor(mPriv->bus, handler);
+                new ClientHandlerRequestsAdaptor(mPriv->bus, handler, object);
             interfaces.append(
                     QLatin1String(
                         "org.freedesktop.Telepathy.Client.Interface.Requests"));
@@ -455,7 +457,7 @@ bool ClientRegistrar::registerClient(const AbstractClientPtr &client,
     }
 
     debug() << "Client registered - busName:" << busName <<
-        "objectPath:" << objectPath;
+        "objectPath:" << objectPath << "interfaces:" << interfaces;
 
     mPriv->services.insert(busName);
     mPriv->clients.insert(client, objectPath);
@@ -463,7 +465,7 @@ bool ClientRegistrar::registerClient(const AbstractClientPtr &client,
     return true;
 }
 
-bool ClientRegistrar::unregisterClient(const AbstractClientPtr &client)
+bool ClientRegistrar::unregisterClient(const ClientObjectPtr &client)
 {
     if (!mPriv->clients.contains(client)) {
         warning() << "Trying to unregister an unregistered client";
@@ -475,20 +477,20 @@ bool ClientRegistrar::unregisterClient(const AbstractClientPtr &client)
     mPriv->clients.remove(client);
 
     QString busName = objectPath.mid(1).replace('/', '.');
-    if (busName != mPriv->busName) {
-        // unique
-        mPriv->bus.unregisterService(busName);
-        mPriv->services.remove(busName);
-    }
+    mPriv->bus.unregisterService(busName);
+    mPriv->services.remove(busName);
+
+    debug() << "Client unregistered - busName:" << busName <<
+        "objectPath:" << objectPath;
 
     return true;
 }
 
 void ClientRegistrar::unregisterClients()
 {
-    QHash<AbstractClientPtr, QString>::const_iterator end =
+    QHash<ClientObjectPtr, QString>::const_iterator end =
         mPriv->clients.constEnd();
-    QHash<AbstractClientPtr, QString>::const_iterator it =
+    QHash<ClientObjectPtr, QString>::const_iterator it =
         mPriv->clients.constBegin();
     while (it != end) {
         mPriv->bus.unregisterObject(it.value());
diff --git a/TelepathyQt4/client-registrar.h b/TelepathyQt4/client-registrar.h
index 9b8acb1..f14ebdc 100644
--- a/TelepathyQt4/client-registrar.h
+++ b/TelepathyQt4/client-registrar.h
@@ -50,9 +50,9 @@ public:
     QDBusConnection dbusConnection() const;
     QString clientName() const;
 
-    QList<AbstractClientPtr> registeredClients() const;
-    bool registerClient(const AbstractClientPtr &client, bool unique = false);
-    bool unregisterClient(const AbstractClientPtr &client);
+    QList<ClientObjectPtr> registeredClients() const;
+    bool registerClient(const ClientObjectPtr &client, bool unique = false);
+    bool unregisterClient(const ClientObjectPtr &client);
     void unregisterClients();
 
 private:
diff --git a/TelepathyQt4/types.h b/TelepathyQt4/types.h
index 2a68c70..8238d59 100644
--- a/TelepathyQt4/types.h
+++ b/TelepathyQt4/types.h
@@ -33,11 +33,12 @@
 namespace Tp
 {
 
-class AbstractClient;
+class AbstractClientHandler;
 class Account;
 class AccountManager;
 class Channel;
 class ChannelRequest;
+class ClientObject;
 class ClientRegistrar;
 class Connection;
 class ConnectionManager;
@@ -47,11 +48,12 @@ class MediaStream;
 class StreamedMediaChannel;
 class TextChannel;
 
-typedef SharedPtr<AbstractClient> AbstractClientPtr;
+typedef SharedPtr<AbstractClientHandler> AbstractClientHandlerPtr;
 typedef SharedPtr<Account> AccountPtr;
 typedef SharedPtr<AccountManager> AccountManagerPtr;
 typedef SharedPtr<Channel> ChannelPtr;
 typedef SharedPtr<ChannelRequest> ChannelRequestPtr;
+typedef SharedPtr<ClientObject> ClientObjectPtr;
 typedef SharedPtr<ClientRegistrar> ClientRegistrarPtr;
 typedef SharedPtr<Connection> ConnectionPtr;
 typedef SharedPtr<ConnectionManager> ConnectionManagerPtr;
diff --git a/tests/dbus/client-handler.cpp b/tests/dbus/client-handler.cpp
index 66f3bfe..c5d4902 100644
--- a/tests/dbus/client-handler.cpp
+++ b/tests/dbus/client-handler.cpp
@@ -14,6 +14,7 @@
 #include <TelepathyQt4/ChannelRequest>
 #include <TelepathyQt4/ClientHandlerInterface>
 #include <TelepathyQt4/ClientInterfaceRequestsInterface>
+#include <TelepathyQt4/ClientObject>
 #include <TelepathyQt4/ClientRegistrar>
 #include <TelepathyQt4/Connection>
 #include <TelepathyQt4/Debug>
@@ -126,11 +127,19 @@ private:
     QStringList mInterfaces;
 };
 
-class MyHandler : public AbstractClientHandler
+class MyHandler : public QObject, public AbstractClientHandler
 {
     Q_OBJECT
 
 public:
+    static AbstractClientHandlerPtr create(const ChannelClassList &channelFilter,
+            bool bypassApproval = false,
+            bool listenRequests = false)
+    {
+        return AbstractClientHandlerPtr(new MyHandler(channelFilter,
+                    bypassApproval, listenRequests));
+    }
+
     MyHandler(const ChannelClassList &channelFilter,
             bool bypassApproval = false,
             bool listenRequests = false)
@@ -248,9 +257,9 @@ private:
     ClientRegistrarPtr mClientRegistrar;
     QString mChannelRequestBusName;
     QString mChannelRequestPath;
-    SharedPtr<MyHandler> mHandler;
-    QString mHandlerBusName;
-    QString mHandlerPath;
+    ClientObjectPtr mClientObject;
+    QString mClientObjectBusName;
+    QString mClientObjectPath;
     uint mUserActionTime;
 };
 
@@ -373,9 +382,9 @@ void TestClientHandler::testRegister()
     filter.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandleType"),
                   QDBusVariant(Tp::HandleTypeContact));
     filters.append(filter);
-    mHandler = SharedPtr<MyHandler>(
-            new MyHandler(filters, false, true));
-    mClientRegistrar->registerClient(AbstractClientPtr::dynamicCast(mHandler));
+    mClientObject = ClientObject::create(
+            MyHandler::create(filters, false, true));
+    mClientRegistrar->registerClient(mClientObject);
 
     QDBusConnection bus = mClientRegistrar->dbusConnection();
     QDBusConnectionInterface *busIface = bus.interface();
@@ -383,41 +392,42 @@ void TestClientHandler::testRegister()
     QVERIFY(registeredServicesNames.contains(
                 "org.freedesktop.Telepathy.Client.foo"));
 
-    mHandlerBusName = "org.freedesktop.Telepathy.Client.foo";
-    mHandlerPath = "/org/freedesktop/Telepathy/Client/foo";
+    mClientObjectBusName = "org.freedesktop.Telepathy.Client.foo";
+    mClientObjectPath = "/org/freedesktop/Telepathy/Client/foo";
 }
 
 void TestClientHandler::testRequests()
 {
     QDBusConnection bus = mClientRegistrar->dbusConnection();
     ClientInterfaceRequestsInterface *handlerRequestsIface = new ClientInterfaceRequestsInterface(bus,
-            mHandlerBusName, mHandlerPath, this);
+            mClientObjectBusName, mClientObjectPath, this);
 
-    connect(mHandler.data(),
+    MyHandler *handler = dynamic_cast<MyHandler*>(mClientObject->clientHandler().data());
+    connect(handler,
             SIGNAL(requestAdded(const Tp::ChannelRequestPtr &)),
             SLOT(expectRequestChange()));
     handlerRequestsIface->AddRequest(QDBusObjectPath(mChannelRequestPath), QVariantMap());
-    if (!mHandler->mAddRequestRequest) {
+    if (!handler->mAddRequestRequest) {
         QCOMPARE(mLoop->exec(), 0);
     }
-    QCOMPARE(mHandler->mAddRequestRequest->objectPath(),
+    QCOMPARE(handler->mAddRequestRequest->objectPath(),
              mChannelRequestPath);
 
-    connect(mHandler.data(),
+    connect(handler,
             SIGNAL(requestRemoved(const Tp::ChannelRequestPtr &,
                                   const QString &,
                                   const QString &)),
             SLOT(expectRequestChange()));
     handlerRequestsIface->RemoveRequest(QDBusObjectPath(mChannelRequestPath),
             TELEPATHY_ERROR_NOT_AVAILABLE, "Not available");
-    if (!mHandler->mRemoveRequestRequest) {
+    if (!handler->mRemoveRequestRequest) {
         QCOMPARE(mLoop->exec(), 0);
     }
-    QCOMPARE(mHandler->mRemoveRequestRequest->objectPath(),
+    QCOMPARE(handler->mRemoveRequestRequest->objectPath(),
              mChannelRequestPath);
-    QCOMPARE(mHandler->mRemoveRequestErrorName,
+    QCOMPARE(handler->mRemoveRequestErrorName,
              QString(TELEPATHY_ERROR_NOT_AVAILABLE));
-    QCOMPARE(mHandler->mRemoveRequestErrorMessage,
+    QCOMPARE(handler->mRemoveRequestErrorMessage,
              QString("Not available"));
 }
 
@@ -425,9 +435,10 @@ void TestClientHandler::testHandleChannels()
 {
     QDBusConnection bus = mClientRegistrar->dbusConnection();
     ClientHandlerInterface *handlerIface = new ClientHandlerInterface(bus,
-            mHandlerBusName, mHandlerPath, this);
+            mClientObjectBusName, mClientObjectPath, this);
 
-    connect(mHandler.data(),
+    MyHandler *handler = dynamic_cast<MyHandler*>(mClientObject->clientHandler().data());
+    connect(handler,
             SIGNAL(handleChannelsFinished()),
             SLOT(expectRequestChange()));
     ChannelDetailsList channelDetailsList;
@@ -439,15 +450,15 @@ void TestClientHandler::testHandleChannels()
             ObjectPathList() << QDBusObjectPath(mChannelRequestPath),
             mUserActionTime,
             QVariantMap());
-    if (!mHandler->mHandleChannelsAccount) {
+    if (!handler->mHandleChannelsAccount) {
         QCOMPARE(mLoop->exec(), 0);
     }
 
-    QCOMPARE(mHandler->mHandleChannelsAccount->objectPath(), mAccount->objectPath());
-    QCOMPARE(mHandler->mHandleChannelsConnection->objectPath(), mConn->objectPath());
-    QCOMPARE(mHandler->mHandleChannelsChannels.first()->objectPath(), mTextChanPath);
-    QCOMPARE(mHandler->mHandleChannelsRequestsSatisfied.first()->objectPath(), mChannelRequestPath);
-    QCOMPARE(mHandler->mHandleChannelsUserActionTime.toTime_t(), mUserActionTime);
+    QCOMPARE(handler->mHandleChannelsAccount->objectPath(), mAccount->objectPath());
+    QCOMPARE(handler->mHandleChannelsConnection->objectPath(), mConn->objectPath());
+    QCOMPARE(handler->mHandleChannelsChannels.first()->objectPath(), mTextChanPath);
+    QCOMPARE(handler->mHandleChannelsRequestsSatisfied.first()->objectPath(), mChannelRequestPath);
+    QCOMPARE(handler->mHandleChannelsUserActionTime.toTime_t(), mUserActionTime);
 }
 void TestClientHandler::cleanup()
 {
-- 
1.5.6.5




More information about the telepathy-commits mailing list