[Telepathy-commits] [telepathy-qt4/master] ReadyObject/ReadinessHelper: Removed DBusProxy from constructors and receive just a QObject.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Fri Mar 20 06:35:30 PDT 2009
If the QObject is a DBusProxy, properly handle proxy invalidation.
---
TelepathyQt4/Client/readiness-helper.cpp | 19 ++++++++---------
TelepathyQt4/Client/readiness-helper.h | 3 +-
TelepathyQt4/Client/ready-object.cpp | 25 ++++-------------------
TelepathyQt4/Client/ready-object.h | 5 +---
TelepathyQt4/Client/streamed-media-channel.cpp | 2 +-
5 files changed, 17 insertions(+), 37 deletions(-)
diff --git a/TelepathyQt4/Client/readiness-helper.cpp b/TelepathyQt4/Client/readiness-helper.cpp
index 87c747c..dd06be2 100644
--- a/TelepathyQt4/Client/readiness-helper.cpp
+++ b/TelepathyQt4/Client/readiness-helper.cpp
@@ -25,6 +25,7 @@
#include "TelepathyQt4/debug-internal.h"
+#include <TelepathyQt4/Client/DBusProxy>
#include <TelepathyQt4/Client/PendingReady>
#include <TelepathyQt4/Constants>
@@ -40,7 +41,6 @@ struct ReadinessHelper::Private
{
Private(ReadinessHelper *parent,
QObject *object,
- DBusProxy *proxy,
uint currentStatus,
const Introspectables &introspectables);
~Private();
@@ -76,12 +76,11 @@ struct ReadinessHelper::Private
ReadinessHelper::Private::Private(
ReadinessHelper *parent,
QObject *object,
- DBusProxy *proxy,
uint currentStatus,
const Introspectables &introspectables)
: parent(parent),
object(object),
- proxy(proxy),
+ proxy(qobject_cast<DBusProxy*>(object)),
currentStatus(currentStatus),
introspectables(introspectables),
pendingStatusChange(false),
@@ -98,6 +97,12 @@ ReadinessHelper::Private::Private(
++i;
}
+ if (proxy) {
+ parent->connect(proxy,
+ SIGNAL(invalidated(Telepathy::Client::DBusProxy *, const QString &, const QString &)),
+ SLOT(onProxyInvalidated(Telepathy::Client::DBusProxy *, const QString &, const QString &)));
+ }
+
debug() << "ReadinessHelper: supportedStatuses =" << supportedStatuses;
debug() << "ReadinessHelper: supportedFeatures =" << supportedFeatures;
}
@@ -284,18 +289,12 @@ void ReadinessHelper::Private::abortOperations(const QString &errorName,
}
ReadinessHelper::ReadinessHelper(QObject *object,
- DBusProxy *proxy,
uint currentStatus,
const Introspectables &introspectables,
QObject *parent)
: QObject(parent),
- mPriv(new Private(this, object, proxy, currentStatus, introspectables))
+ mPriv(new Private(this, object, currentStatus, introspectables))
{
- if (proxy) {
- connect(proxy,
- SIGNAL(invalidated(Telepathy::Client::DBusProxy *, const QString &, const QString &)),
- SLOT(onProxyInvalidated(Telepathy::Client::DBusProxy *, const QString &, const QString &)));
- }
}
ReadinessHelper::~ReadinessHelper()
diff --git a/TelepathyQt4/Client/readiness-helper.h b/TelepathyQt4/Client/readiness-helper.h
index e9dae1a..51db440 100644
--- a/TelepathyQt4/Client/readiness-helper.h
+++ b/TelepathyQt4/Client/readiness-helper.h
@@ -26,7 +26,6 @@
#error IN_TELEPATHY_QT4_HEADER
#endif
-#include <TelepathyQt4/Client/DBusProxy>
#include <TelepathyQt4/Client/Feature>
#include <QMap>
@@ -40,6 +39,7 @@ namespace Telepathy
namespace Client
{
+class DBusProxy;
class PendingReady;
class ReadinessHelper : public QObject
@@ -85,7 +85,6 @@ public:
typedef QMap<Feature, Introspectable> Introspectables;
ReadinessHelper(QObject *object,
- DBusProxy *proxy,
uint currentStatus = 0,
const Introspectables &introspectables = Introspectables(),
QObject *parent = 0);
diff --git a/TelepathyQt4/Client/ready-object.cpp b/TelepathyQt4/Client/ready-object.cpp
index d30b20f..2a05dea 100644
--- a/TelepathyQt4/Client/ready-object.cpp
+++ b/TelepathyQt4/Client/ready-object.cpp
@@ -33,7 +33,7 @@ namespace Client
struct ReadyObject::Private
{
- Private(ReadyObject *parent, QObject *object, DBusProxy *proxy,
+ Private(ReadyObject *parent, QObject *object,
Feature featureCore);
~Private();
@@ -43,10 +43,10 @@ struct ReadyObject::Private
};
ReadyObject::Private::Private(ReadyObject *parent, QObject *object,
- DBusProxy *proxy, Feature featureCore)
+ Feature featureCore)
: parent(parent),
featureCore(featureCore),
- readinessHelper(new ReadinessHelper(object, proxy))
+ readinessHelper(new ReadinessHelper(object))
{
}
@@ -65,25 +65,10 @@ ReadyObject::Private::~Private()
* Construct a new ReadyObject object.
*
* \param object The QObject the object refers to.
- * \param proxy The DBusProxy the object refers to.
* \param featureCore The core feature of the object.
*/
-ReadyObject::ReadyObject(QObject *object, DBusProxy *proxy,
- const Feature &featureCore)
- : mPriv(new Private(this, object, proxy, featureCore))
-{
-}
-
-/**
- * Construct a new ReadyObject object.
- *
- * The object will be same as proxy.
- *
- * \param proxy The DBusProxy the object refers to.
- * \param featureCore The core feature of the object.
- */
-ReadyObject::ReadyObject(DBusProxy *proxy, const Feature &featureCore)
- : mPriv(new Private(this, proxy, proxy, featureCore))
+ReadyObject::ReadyObject(QObject *object, const Feature &featureCore)
+ : mPriv(new Private(this, object, featureCore))
{
}
diff --git a/TelepathyQt4/Client/ready-object.h b/TelepathyQt4/Client/ready-object.h
index b9629b0..b442861 100644
--- a/TelepathyQt4/Client/ready-object.h
+++ b/TelepathyQt4/Client/ready-object.h
@@ -44,10 +44,7 @@ class ReadyObject
Q_DISABLE_COPY(ReadyObject)
public:
- ReadyObject(QObject *object, DBusProxy *proxy,
- const Feature &featureCore);
- ReadyObject(DBusProxy *proxy,
- const Feature &featureCore);
+ ReadyObject(QObject *object, const Feature &featureCore);
~ReadyObject();
virtual bool isReady(const Features &features = Features()) const;
diff --git a/TelepathyQt4/Client/streamed-media-channel.cpp b/TelepathyQt4/Client/streamed-media-channel.cpp
index 0bad606..a81e375 100644
--- a/TelepathyQt4/Client/streamed-media-channel.cpp
+++ b/TelepathyQt4/Client/streamed-media-channel.cpp
@@ -225,7 +225,7 @@ MediaStream::MediaStream(StreamedMediaChannel *channel, uint id,
MediaStreamState state, MediaStreamDirection direction,
MediaStreamPendingSend pendingSend)
: QObject(),
- ReadyObject(this, 0, FeatureContact),
+ ReadyObject(this, FeatureContact),
mPriv(new Private(this, channel, id, contactHandle, type,
state, direction, pendingSend))
{
--
1.5.6.5
More information about the telepathy-commits
mailing list