[telepathy-qt4/master] PendingHandles: Return ConnectionPtr on connection() method.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Tue Mar 31 15:25:30 PDT 2009


---
 TelepathyQt4/Client/pending-handles.cpp |   18 +++++++++---------
 TelepathyQt4/Client/pending-handles.h   |    8 ++++----
 tests/pinocchio/handles.cpp             |    2 +-
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/TelepathyQt4/Client/pending-handles.cpp b/TelepathyQt4/Client/pending-handles.cpp
index 07f0431..55fe1dd 100644
--- a/TelepathyQt4/Client/pending-handles.cpp
+++ b/TelepathyQt4/Client/pending-handles.cpp
@@ -46,7 +46,7 @@ namespace Client
 
 struct PendingHandles::Private
 {
-    Connection *connection;
+    ConnectionPtr connection;
     uint handleType;
     bool isRequest;
     QStringList namesRequested;
@@ -75,9 +75,9 @@ struct PendingHandles::Private
  * Connection::referenceHandles().
  */
 
-PendingHandles::PendingHandles(Connection *connection, uint handleType,
+PendingHandles::PendingHandles(const ConnectionPtr &connection, uint handleType,
         const QStringList &names)
-    : PendingOperation(connection),
+    : PendingOperation(connection.data()),
       mPriv(new Private)
 {
     debug() << "PendingHandles(request)";
@@ -98,10 +98,10 @@ PendingHandles::PendingHandles(Connection *connection, uint handleType,
             SLOT(onRequestHandlesFinished(QDBusPendingCallWatcher *)));
 }
 
-PendingHandles::PendingHandles(Connection *connection, uint handleType,
+PendingHandles::PendingHandles(const ConnectionPtr &connection, uint handleType,
         const UIntList &handles, const UIntList &alreadyHeld,
         const UIntList &notYetHeld)
-    : PendingOperation(connection),
+    : PendingOperation(connection.data()),
       mPriv(new Private)
 {
     debug() << "PendingHandles(reference)";
@@ -143,7 +143,7 @@ PendingHandles::~PendingHandles()
  *
  * \return Pointer to the Connection.
  */
-Connection *PendingHandles::connection() const
+ConnectionPtr PendingHandles::connection() const
 {
     return mPriv->connection;
 }
@@ -281,7 +281,7 @@ void PendingHandles::onRequestHandlesFinished(QDBusPendingCallWatcher *watcher)
                             error.message()));
             }
             setFinishedWithError(error);
-            connection()->handleRequestLanded(mPriv->handleType);
+            mPriv->connection->handleRequestLanded(mPriv->handleType);
             watcher->deleteLater();
             return;
         }
@@ -295,7 +295,7 @@ void PendingHandles::onRequestHandlesFinished(QDBusPendingCallWatcher *watcher)
                     QPair<QString, QString>(error.name(),
                         error.message()));
             setFinished();
-            connection()->handleRequestLanded(mPriv->handleType);
+            mPriv->connection->handleRequestLanded(mPriv->handleType);
             watcher->deleteLater();
             return;
         }
@@ -402,7 +402,7 @@ void PendingHandles::onRequestHandlesFallbackFinished(QDBusPendingCallWatcher *w
                             error.message()));
             }
             setFinishedWithError(error);
-            connection()->handleRequestLanded(mPriv->handleType);
+            mPriv->connection->handleRequestLanded(mPriv->handleType);
             watcher->deleteLater();
             return;
         }
diff --git a/TelepathyQt4/Client/pending-handles.h b/TelepathyQt4/Client/pending-handles.h
index 1af55dd..4c73a27 100644
--- a/TelepathyQt4/Client/pending-handles.h
+++ b/TelepathyQt4/Client/pending-handles.h
@@ -27,6 +27,7 @@
 #endif
 
 #include <TelepathyQt4/Client/PendingOperation>
+#include <TelepathyQt4/Client/Types>
 #include <TelepathyQt4/Types>
 
 #include <QHash>
@@ -40,7 +41,6 @@ namespace Telepathy
 namespace Client
 {
 
-class Connection;
 class PendingHandles;
 class ReferencedHandles;
 
@@ -52,7 +52,7 @@ class PendingHandles : public PendingOperation
 public:
     ~PendingHandles();
 
-    Connection *connection() const;
+    ConnectionPtr connection() const;
 
     uint handleType() const;
 
@@ -81,8 +81,8 @@ private Q_SLOTS:
 private:
     friend class Connection;
 
-    PendingHandles(Connection *connection, uint handleType, const QStringList &names);
-    PendingHandles(Connection *connection, uint handleType, const UIntList &handles,
+    PendingHandles(const ConnectionPtr &connection, uint handleType, const QStringList &names);
+    PendingHandles(const ConnectionPtr &connection, uint handleType, const UIntList &handles,
             const UIntList &alreadyHeld, const UIntList &notYetHeld);
 
     struct Private;
diff --git a/tests/pinocchio/handles.cpp b/tests/pinocchio/handles.cpp
index 1b9b3cb..6ac1440 100644
--- a/tests/pinocchio/handles.cpp
+++ b/tests/pinocchio/handles.cpp
@@ -183,7 +183,7 @@ void TestHandles::testBasics()
     // Check that the closure is consistent with what we asked for
     QVERIFY(pending->isRequest());
     QCOMPARE(pending->namesRequested(), ids);
-    QCOMPARE(pending->connection(), mConn1a.data());
+    QCOMPARE(pending->connection(), mConn1a);
     QCOMPARE(pending->handleType(), static_cast<uint>(Telepathy::HandleTypeContact));
 
     // Finish the request and extract the resulting ReferencedHandles
-- 
1.5.6.5




More information about the telepathy-commits mailing list