[Telepathy-commits] [telepathy-qt4/master] Connection: Moved readiness internally and expose statusChanged.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Sat Jan 24 18:21:12 PST 2009
---
TelepathyQt4/Client/channel.cpp | 15 ++--
TelepathyQt4/Client/channel.h | 2 +-
TelepathyQt4/Client/connection.cpp | 148 +++++++++++++++++++++---------------
TelepathyQt4/Client/connection.h | 14 +---
tests/dbus/handles.cpp | 78 ++++++-------------
tests/pinocchio/chan-basics.cpp | 36 ++++------
tests/pinocchio/conn-basics.cpp | 122 ++++++------------------------
tests/pinocchio/handles.cpp | 36 ++++------
8 files changed, 168 insertions(+), 283 deletions(-)
diff --git a/TelepathyQt4/Client/channel.cpp b/TelepathyQt4/Client/channel.cpp
index ec68400..d0e41b2 100644
--- a/TelepathyQt4/Client/channel.cpp
+++ b/TelepathyQt4/Client/channel.cpp
@@ -108,15 +108,16 @@ struct Channel::Private
debug() << " Connection to owning connection's lifetime signals";
parent.connect(connection,
- SIGNAL(readinessChanged(uint)),
- SLOT(onConnectionReadinessChanged(uint)));
+ SIGNAL(invalidated(Telepathy::Client::DBusProxy *proxy,
+ QString errorName, QString errorMessage)),
+ SLOT(onConnectionInvalidated()));
parent.connect(connection,
SIGNAL(destroyed()),
SLOT(onConnectionDestroyed()));
- if (connection->readiness() == Connection::ReadinessDead) {
- warning() << "Connection given as the owner for a Channel was already dead! Channel will be stillborn.";
+ if (!connection->isValid()) {
+ warning() << "Connection given as the owner for a Channel was invalid! Channel will be stillborn.";
readiness = ReadinessDead;
}
@@ -668,9 +669,9 @@ void Channel::onClosed()
invalidate(TELEPATHY_ERROR_CANCELLED, "Closed");
}
-void Channel::onConnectionReadinessChanged(uint readiness)
+void Channel::onConnectionInvalidated()
{
- if (readiness == Connection::ReadinessDead && mPriv->readiness != ReadinessDead) {
+ if (mPriv->readiness != ReadinessDead) {
debug() << "Owning connection died leaving an orphan Channel, changing to ReadinessDead";
mPriv->changeReadiness(ReadinessDead);
}
@@ -680,7 +681,7 @@ void Channel::onConnectionDestroyed()
{
debug() << "Owning connection destroyed, cutting off dangling pointer";
mPriv->connection = 0;
- return onConnectionReadinessChanged(Connection::ReadinessDead);
+ onConnectionInvalidated();
}
void Channel::gotGroupProperties(QDBusPendingCallWatcher* watcher)
diff --git a/TelepathyQt4/Client/channel.h b/TelepathyQt4/Client/channel.h
index dd1df5a..7b5a909 100644
--- a/TelepathyQt4/Client/channel.h
+++ b/TelepathyQt4/Client/channel.h
@@ -779,7 +779,7 @@ private Q_SLOTS:
void gotInterfaces(QDBusPendingCallWatcher* watcher);
void onClosed();
- void onConnectionReadinessChanged(uint readiness);
+ void onConnectionInvalidated();
void onConnectionDestroyed();
void gotGroupProperties(QDBusPendingCallWatcher* watcher);
diff --git a/TelepathyQt4/Client/connection.cpp b/TelepathyQt4/Client/connection.cpp
index fe03b58..7fda95b 100644
--- a/TelepathyQt4/Client/connection.cpp
+++ b/TelepathyQt4/Client/connection.cpp
@@ -66,6 +66,45 @@ namespace Client
struct Connection::Private
{
+ /*
+ * \enum Connection::Private::Readiness
+ *
+ * Describes readiness of the Connection for usage. The readiness depends
+ * on the state of the remote object. In suitable states, an asynchronous
+ * introspection process is started, and the Connection becomes more ready
+ * when that process is completed.
+ *
+ * \value ReadinessJustCreated, The object has just been created and introspection
+ * is still in progress. No functionality is available.
+ * The readiness can change to any other state depending
+ * on the result of the initial state query to the remote
+ * object.
+ * \value ReadinessNotYetConnected The remote object is in the Disconnected state and
+ * introspection relevant to that state has been completed.
+ * This state is useful for being able to set your presence status
+ * (through the SimplePresence interface) before connecting. Most other
+ * functionality is unavailable, though.
+ * The readiness can change to ReadinessConnecting and ReadinessDead.
+ * \value ReadinessConnecting The remote object is in the Connecting state. Most functionality is
+ * unavailable.
+ * The readiness can change to ReadinessFull and ReadinessDead.
+ * \value ReadinessFull The connection is in the Connected state and all introspection
+ * has been completed. Most functionality is available.
+ * The readiness can change to ReadinessDead.
+ * \value ReadinessDead The remote object has gone into a state where it can no longer be
+ * used. No functionality is available.
+ * No further readiness changes are possible.
+ * \value _ReadinessInvalid The remote object has gone into a invalid state.
+ */
+ enum Readiness {
+ ReadinessJustCreated = 0,
+ ReadinessNotYetConnected = 5,
+ ReadinessConnecting = 10,
+ ReadinessFull = 15,
+ ReadinessDead = 20,
+ _ReadinessInvalid = 0xffff
+ };
+
Private(Connection *parent);
~Private();
@@ -107,6 +146,10 @@ struct Connection::Private
Connection::Features missingFeatures;
// Introspected properties
+ // keep pendingStatus and pendingStatusReason until we emit statusChanged
+ // so Connection::status() and Connection::statusReason() are consistent
+ uint pendingStatus;
+ uint pendingStatusReason;
uint status;
uint statusReason;
bool haveInitialStatus;
@@ -173,6 +216,8 @@ Connection::Private::Private(Connection *parent)
properties(0),
initialIntrospection(false),
readiness(ReadinessJustCreated),
+ pendingStatus(ConnectionStatusDisconnected),
+ pendingStatusReason(ConnectionStatusReasonNoneSpecified),
status(ConnectionStatusDisconnected),
statusReason(ConnectionStatusReasonNoneSpecified),
haveInitialStatus(false),
@@ -185,6 +230,11 @@ Connection::Private::~Private()
{
QMutexLocker locker(&handleContextsLock);
+ if (!handleContext) {
+ // initial introspection is not done
+ return;
+ }
+
// All handle contexts locked, so safe
if (!--handleContext->refcount) {
debug() << "Destroying HandleContext";
@@ -323,6 +373,8 @@ void Connection::Private::introspectSimplePresence()
void Connection::Private::changeReadiness(Readiness newReadiness)
{
+ debug() << "changing readiness from" << readiness <<
+ "to" << newReadiness;
Q_ASSERT(newReadiness != readiness);
switch (readiness) {
@@ -346,7 +398,16 @@ void Connection::Private::changeReadiness(Readiness newReadiness)
debug() << "Readiness changed from" << readiness << "to" << newReadiness;
readiness = newReadiness;
- emit parent->readinessChanged(newReadiness);
+
+ // emit statusChanged only here as we are now in the correct readiness
+ // e.g: status was already Connected but readiness != ReadinessFull so the user was
+ // not able to call Connection::aliasFlags() for example.
+ if (status != pendingStatus ||
+ statusReason != pendingStatusReason) {
+ status = pendingStatus;
+ statusReason = pendingStatusReason;
+ emit parent->statusChanged(status, statusReason);
+ }
}
void Connection::Private::updatePendingOperations()
@@ -395,37 +456,6 @@ QMutex Connection::Private::handleContextsLock;
*/
/**
- * \enum Connection::Readiness
- *
- * Describes readiness of the Connection for usage. The readiness depends
- * on the state of the remote object. In suitable states, an asynchronous
- * introspection process is started, and the Connection becomes more ready
- * when that process is completed.
- *
- * \value ReadinessJustCreated, The object has just been created and introspection
- * is still in progress. No functionality is available.
- * The readiness can change to any other state depending
- * on the result of the initial state query to the remote
- * object.
- * \value ReadinessNotYetConnected The remote object is in the Disconnected state and
- * introspection relevant to that state has been completed.
- * This state is useful for being able to set your presence status
- * (through the SimplePresence interface) before connecting. Most other
- * functionality is unavailable, though.
- * The readiness can change to ReadinessConnecting and ReadinessDead.
- * \value ReadinessConnecting The remote object is in the Connecting state. Most functionality is
- * unavailable.
- * The readiness can change to ReadinessFull and ReadinessDead.
- * \value ReadinessFull The connection is in the Connected state and all introspection
- * has been completed. Most functionality is available.
- * The readiness can change to ReadinessDead.
- * \value ReadinessDead The remote object has gone into a state where it can no longer be
- * used. No functionality is available.
- * No further readiness changes are possible.
- * \value _ReadinessInvalid The remote object has gone into a invalid state.
- */
-
-/**
* \enum Connection::InterfaceSupportedChecking
*
* Specifies if the interface being supported by the remote object should be
@@ -488,16 +518,6 @@ Connection::~Connection()
}
/**
- * Return the current readiness of the Connection.
- *
- * \return The readiness, as defined in #Readiness.
- */
-Connection::Readiness Connection::readiness() const
-{
- return mPriv->readiness;
-}
-
-/**
* Return the connection's status.
*
* The returned value may have changed whenever readinessChanged() is
@@ -508,7 +528,7 @@ Connection::Readiness Connection::readiness() const
*/
uint Connection::status() const
{
- if (mPriv->readiness == ReadinessJustCreated) {
+ if (mPriv->readiness == Private::ReadinessJustCreated) {
warning() << "Connection::status() used with readiness ReadinessJustCreated";
}
@@ -523,7 +543,7 @@ uint Connection::status() const
*/
uint Connection::statusReason() const
{
- if (mPriv->readiness == ReadinessJustCreated) {
+ if (mPriv->readiness == Private::ReadinessJustCreated) {
warning() << "Connection::statusReason() used with readiness ReadinessJustCreated";
}
@@ -545,12 +565,12 @@ QStringList Connection::interfaces() const
// Different check than the others, because the optional interface getters
// may be used internally with the knowledge about getting the interfaces
// list, so we don't want this to cause warnings.
- if (mPriv->readiness != ReadinessNotYetConnected &&
- mPriv->readiness != ReadinessFull &&
+ if (mPriv->readiness != Private::ReadinessNotYetConnected &&
+ mPriv->readiness != Private::ReadinessFull &&
mPriv->interfaces.empty()) {
warning() << "Connection::interfaces() used possibly before the list of interfaces has been received";
}
- else if (mPriv->readiness == ReadinessDead) {
+ else if (mPriv->readiness == Private::ReadinessDead) {
warning() << "Connection::interfaces() used with readiness ReadinessDead";
}
@@ -740,25 +760,25 @@ void Connection::onStatusChanged(uint status, uint reason)
if (!mPriv->haveInitialStatus) {
debug() << "Still haven't got the GetStatus reply, ignoring StatusChanged until we have (but saving reason)";
- mPriv->statusReason = reason;
+ mPriv->pendingStatusReason = reason;
return;
}
- if (mPriv->status == status) {
+ if (mPriv->pendingStatus == status) {
warning() << "New status was the same as the old status! Ignoring redundant StatusChanged";
return;
}
if (status == ConnectionStatusConnected &&
- mPriv->status != ConnectionStatusConnecting) {
+ mPriv->pendingStatus != ConnectionStatusConnecting) {
// CMs aren't meant to go straight from Disconnected to
// Connected; recover by faking Connecting
warning() << " Non-compliant CM - went straight to Connected! Faking a transition through Connecting";
onStatusChanged(ConnectionStatusConnecting, reason);
}
- mPriv->status = status;
- mPriv->statusReason = reason;
+ mPriv->pendingStatus = status;
+ mPriv->pendingStatusReason = reason;
switch (status) {
case ConnectionStatusConnected:
@@ -768,8 +788,8 @@ void Connection::onStatusChanged(uint status, uint reason)
break;
case ConnectionStatusConnecting:
- if (mPriv->readiness < ReadinessConnecting) {
- mPriv->changeReadiness(ReadinessConnecting);
+ if (mPriv->readiness < Private::ReadinessConnecting) {
+ mPriv->changeReadiness(Private::ReadinessConnecting);
}
else {
warning() << " Got unexpected status change to Connecting";
@@ -777,7 +797,7 @@ void Connection::onStatusChanged(uint status, uint reason)
break;
case ConnectionStatusDisconnected:
- if (mPriv->readiness != ReadinessDead) {
+ if (mPriv->readiness != Private::ReadinessDead) {
const char *errorName;
// This is the best we can do right now: in an imminent
@@ -817,7 +837,7 @@ void Connection::onStatusChanged(uint status, uint reason)
invalidate(QLatin1String(errorName),
QString("ConnectionStatusReason = %1").arg(uint(reason)));
- mPriv->changeReadiness(ReadinessDead);
+ mPriv->changeReadiness(Private::ReadinessDead);
}
else {
warning() << " Got unexpected status change to Disconnected";
@@ -837,14 +857,16 @@ void Connection::gotStatus(QDBusPendingCallWatcher *watcher)
if (reply.isError()) {
warning().nospace() << "GetStatus() failed with" <<
reply.error().name() << ":" << reply.error().message();
- mPriv->changeReadiness(ReadinessDead);
+ invalidate(QLatin1String(TELEPATHY_ERROR_DISCONNECTED),
+ QString("ConnectionStatusReason = %1").arg(uint(mPriv->pendingStatusReason)));
+ mPriv->changeReadiness(Private::ReadinessDead);
return;
}
uint status = reply.value();
debug() << "Got connection status" << status;
- mPriv->status = status;
+ mPriv->pendingStatus = status;
mPriv->haveInitialStatus = true;
// Don't do any introspection yet if the connection is in the Connecting
@@ -852,7 +874,7 @@ void Connection::gotStatus(QDBusPendingCallWatcher *watcher)
// connection ever gets to the Connected state.
if (status == ConnectionStatusConnecting) {
debug() << "Not introspecting yet because the connection is currently Connecting";
- mPriv->changeReadiness(ReadinessConnecting);
+ mPriv->changeReadiness(Private::ReadinessConnecting);
return;
}
@@ -1351,13 +1373,13 @@ void Connection::continueIntrospection()
if (mPriv->introspectQueue.isEmpty()) {
if (mPriv->initialIntrospection) {
mPriv->initialIntrospection = false;
- if (mPriv->readiness < ReadinessNotYetConnected) {
- mPriv->changeReadiness(ReadinessNotYetConnected);
+ if (mPriv->readiness < Private::ReadinessNotYetConnected) {
+ mPriv->changeReadiness(Private::ReadinessNotYetConnected);
}
}
else {
- if (mPriv->readiness != ReadinessDead) {
- mPriv->changeReadiness(ReadinessFull);
+ if (mPriv->readiness != Private::ReadinessDead) {
+ mPriv->changeReadiness(Private::ReadinessFull);
// we should have all interfaces now, so if an interface is not
// present and we have a feature for it, add the feature to missing
// features.
diff --git a/TelepathyQt4/Client/connection.h b/TelepathyQt4/Client/connection.h
index 148ade6..2fd17dc 100644
--- a/TelepathyQt4/Client/connection.h
+++ b/TelepathyQt4/Client/connection.h
@@ -54,7 +54,6 @@ class Connection : public StatefulDBusProxy,
{
Q_OBJECT
Q_DISABLE_COPY(Connection)
- Q_ENUMS(Readiness);
public:
enum Feature {
@@ -65,15 +64,6 @@ public:
};
Q_DECLARE_FLAGS(Features, Feature)
- enum Readiness {
- ReadinessJustCreated = 0,
- ReadinessNotYetConnected = 5,
- ReadinessConnecting = 10,
- ReadinessFull = 15,
- ReadinessDead = 20,
- _ReadinessInvalid = 0xffff
- };
-
Connection(const QString &serviceName,
const QString &objectPath,
QObject *parent = 0);
@@ -85,8 +75,6 @@ public:
~Connection();
- Readiness readiness() const;
-
uint status() const;
uint statusReason() const;
@@ -161,7 +149,7 @@ public:
PendingOperation *becomeReady(Features features = 0);
Q_SIGNALS:
- void readinessChanged(uint newReadiness);
+ void statusChanged(uint newStatus, uint newStatusReason);
public:
ConnectionInterface *baseInterface() const;
diff --git a/tests/dbus/handles.cpp b/tests/dbus/handles.cpp
index 16200a0..2e47ae5 100644
--- a/tests/dbus/handles.cpp
+++ b/tests/dbus/handles.cpp
@@ -29,8 +29,8 @@ public:
ReferencedHandles mHandles;
protected Q_SLOTS:
- void expectConnReady(uint newReadiness);
- void expectConnDead(uint newReadiness);
+ void expectConnReady(uint newStatus, uint newStatusReason);
+ void expectConnInvalidated();
void expectSuccessfulCall(Telepathy::Client::PendingOperation*);
void expectPendingHandlesFinished(Telepathy::Client::PendingOperation*);
@@ -44,65 +44,31 @@ private Q_SLOTS:
void cleanupTestCase();
};
-void TestHandles::expectConnReady(uint newReadiness)
+void TestHandles::expectConnReady(uint newStatus, uint newStatusReason)
{
- switch (newReadiness) {
- case Connection::ReadinessJustCreated:
- qWarning() << "Changing from JustCreated to JustCreated is silly";
+ switch (newStatus) {
+ case Telepathy::ConnectionStatusDisconnected:
+ qWarning() << "Disconnected";
mLoop->exit(1);
break;
- case Connection::ReadinessNotYetConnected:
- // Connect (for now, using the 1:1 API)
- mConn->baseInterface()->Connect();
- break;
- case Connection::ReadinessConnecting:
+ case Telepathy::ConnectionStatusConnecting:
/* do nothing */
break;
- case Connection::ReadinessFull:
+ case Telepathy::ConnectionStatusConnected:
qDebug() << "Ready";
mLoop->exit(0);
break;
- case Connection::ReadinessDead:
- qWarning() << "Dead!";
- mLoop->exit(3);
- break;
default:
- qWarning().nospace() << "What sort of readiness is "
- << newReadiness << "?!";
- mLoop->exit(4);
+ qWarning().nospace() << "What sort of status is "
+ << newStatus << "?!";
+ mLoop->exit(2);
break;
}
}
-void TestHandles::expectConnDead(uint newReadiness)
+void TestHandles::expectConnInvalidated()
{
- switch (newReadiness) {
- case Connection::ReadinessJustCreated:
- qWarning() << "Changing from Full to JustCreated is silly";
- mLoop->exit(1);
- break;
- case Connection::ReadinessNotYetConnected:
- qWarning() << "Changing from Full to NYC is silly";
- mLoop->exit(2);
- break;
- case Connection::ReadinessConnecting:
- qWarning() << "Changing from Full to Connecting is silly";
- mLoop->exit(3);
- break;
- case Connection::ReadinessFull:
- qWarning() << "Changing from Full to Full is silly";
- mLoop->exit(4);
- break;
- case Connection::ReadinessDead:
- qWarning() << "Dead!";
- mLoop->exit(0);
- break;
- default:
- qWarning().nospace() << "What sort of readiness is "
- << newReadiness << "?!";
- mLoop->exit(5);
- break;
- }
+ mLoop->exit(0);
}
void TestHandles::expectSuccessfulCall(PendingOperation *op)
@@ -188,11 +154,12 @@ void TestHandles::init()
mConn = new Connection(mConnName, mConnPath);
- QVERIFY(connect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectConnReady(uint))));
+ mConn->baseInterface()->Connect();
+ QVERIFY(connect(mConn, SIGNAL(statusChanged(uint, uint)),
+ this, SLOT(expectConnReady(uint, uint))));
QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectConnReady(uint))));
+ QVERIFY(disconnect(mConn, SIGNAL(statusChanged(uint, uint)),
+ this, SLOT(expectConnReady(uint, uint))));
}
void TestHandles::testRequestAndRelease()
@@ -253,10 +220,11 @@ void TestHandles::cleanup()
SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation*))));
QCOMPARE(mLoop->exec(), 0);
- if (mConn->readiness() != Connection::ReadinessDead) {
- QVERIFY(this->connect(mConn,
- SIGNAL(readinessChanged(uint)),
- SLOT(expectConnDead(uint))));
+ if (mConn->isValid()) {
+ QVERIFY(connect(mConn,
+ SIGNAL(invalidated(Telepathy::Client::DBusProxy *proxy,
+ QString errorName, QString errorMessage)),
+ SLOT(expectConnInvalidated())));
QCOMPARE(mLoop->exec(), 0);
}
}
diff --git a/tests/pinocchio/chan-basics.cpp b/tests/pinocchio/chan-basics.cpp
index f616f0a..3e1180f 100644
--- a/tests/pinocchio/chan-basics.cpp
+++ b/tests/pinocchio/chan-basics.cpp
@@ -32,7 +32,7 @@ private:
protected Q_SLOTS:
// these ought to be private, but if they were, QTest would think they
// were test cases. So, they're protected instead
- void expectConnReady(uint);
+ void expectConnReady(uint, uint);
void expectChanReady(uint);
void expectPendingChannelFinished(Telepathy::Client::PendingOperation*);
void expectPendingChannelError(Telepathy::Client::PendingOperation*);
@@ -50,32 +50,24 @@ private Q_SLOTS:
};
-void TestChanBasics::expectConnReady(uint newReadiness)
+void TestChanBasics::expectConnReady(uint newStatus, uint newStatusReason)
{
- switch (newReadiness) {
- case Connection::ReadinessJustCreated:
- qWarning() << "Changing from NYC to JustCreated is silly";
+ switch (newStatus) {
+ case Telepathy::ConnectionStatusDisconnected:
+ qWarning() << "Disconnected";
mLoop->exit(1);
break;
- case Connection::ReadinessNotYetConnected:
- qWarning() << "Changing from NYC to NYC is silly";
- mLoop->exit(2);
- break;
- case Connection::ReadinessConnecting:
+ case Telepathy::ConnectionStatusConnecting:
/* do nothing */
break;
- case Connection::ReadinessFull:
+ case Telepathy::ConnectionStatusConnected:
qDebug() << "Ready";
mLoop->exit(0);
break;
- case Connection::ReadinessDead:
- qWarning() << "Dead!";
- mLoop->exit(3);
- break;
default:
- qWarning().nospace() << "What sort of readiness is "
- << newReadiness << "?!";
- mLoop->exit(4);
+ qWarning().nospace() << "What sort of status is "
+ << newStatus << "?!";
+ mLoop->exit(2);
break;
}
}
@@ -122,11 +114,11 @@ void TestChanBasics::initTestCase()
QCOMPARE(mLoop->exec(), 0);
delete watcher;
- QVERIFY(connect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectConnReady(uint))));
+ QVERIFY(connect(mConn, SIGNAL(statusChanged(uint, uint)),
+ this, SLOT(expectConnReady(uint, uint))));
QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectConnReady(uint))));
+ QVERIFY(disconnect(mConn, SIGNAL(statusChanged(uint, uint)),
+ this, SLOT(expectConnReady(uint, uint))));
// Using direct access to low-level stuff here, so we can test the
// Channel constructor directly
diff --git a/tests/pinocchio/conn-basics.cpp b/tests/pinocchio/conn-basics.cpp
index f8631df..8737845 100644
--- a/tests/pinocchio/conn-basics.cpp
+++ b/tests/pinocchio/conn-basics.cpp
@@ -26,8 +26,7 @@ private:
Connection *mConn;
protected Q_SLOTS:
- void expectNotYetConnected(uint);
- void expectReady(uint);
+ void expectReady(uint, uint);
private Q_SLOTS:
void initTestCase();
@@ -97,78 +96,36 @@ void TestConnBasics::init()
}
-void TestConnBasics::expectNotYetConnected(uint newReadiness)
-{
- switch (newReadiness) {
- case Connection::ReadinessJustCreated:
- qWarning() << "Changing from JustCreated to JustCreated is silly";
- mLoop->exit(1);
- break;
- case Connection::ReadinessNotYetConnected:
- qDebug() << "Correctly changed to NotYetConnected";
- mLoop->exit(0);
- break;
- case Connection::ReadinessConnecting:
- case Connection::ReadinessFull:
- case Connection::ReadinessDead:
- qWarning() << "Got too far!";
- mLoop->exit(2);
- break;
- default:
- qWarning().nospace() << "What sort of readiness is "
- << newReadiness << "?!";
- mLoop->exit(3);
- break;
- }
-}
-
-
void TestConnBasics::testInitialIntrospection()
{
mConn = new Connection(mConnBusName, mConnObjectPath);
- QCOMPARE(mConn->readiness(), Connection::ReadinessJustCreated);
QCOMPARE(static_cast<uint>(mConn->status()),
static_cast<uint>(Telepathy::ConnectionStatusDisconnected));
- // Wait for introspection to run (readiness changes to NYC)
- QVERIFY(connect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectNotYetConnected(uint))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectNotYetConnected(uint))));
-
delete mConn;
mConn = NULL;
}
-void TestConnBasics::expectReady(uint newReadiness)
+void TestConnBasics::expectReady(uint newStatus, uint newStatusReason)
{
- switch (newReadiness) {
- case Connection::ReadinessJustCreated:
- qWarning() << "Changing from NYC to JustCreated is silly";
+ switch (newStatus) {
+ case Telepathy::ConnectionStatusDisconnected:
+ qWarning() << "Disconnected";
mLoop->exit(1);
break;
- case Connection::ReadinessNotYetConnected:
- qWarning() << "Changing from NYC to NYC is silly";
- mLoop->exit(2);
- break;
- case Connection::ReadinessConnecting:
+ case Telepathy::ConnectionStatusConnecting:
/* do nothing */
break;
- case Connection::ReadinessFull:
+ case Telepathy::ConnectionStatusConnected:
qDebug() << "Ready";
mLoop->exit(0);
break;
- case Connection::ReadinessDead:
- qWarning() << "Dead!";
- mLoop->exit(3);
- break;
default:
- qWarning().nospace() << "What sort of readiness is "
- << newReadiness << "?!";
- mLoop->exit(4);
+ qWarning().nospace() << "What sort of status is "
+ << newStatus << "?!";
+ mLoop->exit(2);
break;
}
}
@@ -178,17 +135,9 @@ void TestConnBasics::testConnect()
{
mConn = new Connection(mConnBusName, mConnObjectPath);
- QCOMPARE(mConn->readiness(), Connection::ReadinessJustCreated);
QCOMPARE(static_cast<uint>(mConn->status()),
static_cast<uint>(Telepathy::ConnectionStatusDisconnected));
- // Wait for introspection to run (readiness changes to NYC)
- QVERIFY(connect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectNotYetConnected(uint))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectNotYetConnected(uint))));
-
QVERIFY(connect(mConn->becomeReady(),
SIGNAL(finished(Telepathy::Client::PendingOperation*)),
this,
@@ -209,13 +158,12 @@ void TestConnBasics::testConnect()
// Wait for readiness to reach Full
qDebug() << "waiting for Full readiness";
- QVERIFY(connect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectReady(uint))));
+ QVERIFY(connect(mConn, SIGNAL(statusChanged(uint, uint)),
+ this, SLOT(expectReady(uint, uint))));
QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectReady(uint))));
+ QVERIFY(disconnect(mConn, SIGNAL(statusChanged(uint, uint)),
+ this, SLOT(expectReady(uint, uint))));
- QCOMPARE(mConn->readiness(), Connection::ReadinessFull);
QVERIFY(connect(mConn->becomeReady(Connection::FeatureAliasing),
SIGNAL(finished(Telepathy::Client::PendingOperation*)),
this,
@@ -262,7 +210,6 @@ void TestConnBasics::testConnect()
SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation*))));
QCOMPARE(mLoop->exec(), 0);
- QCOMPARE(mConn->readiness(), Connection::ReadinessDead);
QCOMPARE(static_cast<uint>(mConn->status()),
static_cast<uint>(Telepathy::ConnectionStatusDisconnected));
QCOMPARE(static_cast<uint>(mConn->statusReason()),
@@ -277,13 +224,6 @@ void TestConnBasics::testAlreadyConnected()
{
mConn = new Connection(mConnBusName, mConnObjectPath);
- // Wait for introspection to run (readiness changes to NYC)
- QVERIFY(connect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectNotYetConnected(uint))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectNotYetConnected(uint))));
-
// FIXME: should have convenience API so we don't have to use
// baseInterface directly
qDebug() << "calling Connect()";
@@ -297,24 +237,22 @@ void TestConnBasics::testAlreadyConnected()
// Wait for readiness to reach Full
qDebug() << "waiting for Full readiness";
- QVERIFY(connect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectReady(uint))));
+ QVERIFY(connect(mConn, SIGNAL(statusChanged(uint, uint)),
+ this, SLOT(expectReady(uint, uint))));
QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectReady(uint))));
-
- QCOMPARE(mConn->readiness(), Connection::ReadinessFull);
+ QVERIFY(disconnect(mConn, SIGNAL(statusChanged(uint, uint)),
+ this, SLOT(expectReady(uint, uint))));
// delete proxy, make a new one
delete mConn;
mConn = new Connection(mConnBusName, mConnObjectPath);
// Wait for introspection to run (readiness changes to Full immediately)
- QVERIFY(connect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectReady(uint))));
+ QVERIFY(connect(mConn, SIGNAL(statusChanged(uint, uint)),
+ this, SLOT(expectReady(uint, uint))));
QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectReady(uint))));
+ QVERIFY(disconnect(mConn, SIGNAL(statusChanged(uint, uint)),
+ this, SLOT(expectReady(uint, uint))));
QVERIFY(connect(mConn->requestDisconnect(),
SIGNAL(finished(Telepathy::Client::PendingOperation*)),
@@ -332,17 +270,9 @@ void TestConnBasics::testInterfaceFactory()
mConn = new Connection(QDBusConnection::sessionBus(),
mConnBusName, mConnObjectPath);
- QCOMPARE(mConn->readiness(), Connection::ReadinessJustCreated);
QCOMPARE(static_cast<uint>(mConn->status()),
static_cast<uint>(Telepathy::ConnectionStatusDisconnected));
- // Wait for introspection to run (readiness changes to NYC)
- QVERIFY(connect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectNotYetConnected(uint))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectNotYetConnected(uint))));
-
PropertiesInterface* props = mConn->propertiesInterface();
QVERIFY(props != NULL);
@@ -371,17 +301,9 @@ void TestConnBasics::testSpecifiedBus()
mConn = new Connection(QDBusConnection::sessionBus(),
mConnBusName, mConnObjectPath);
- QCOMPARE(mConn->readiness(), Connection::ReadinessJustCreated);
QCOMPARE(static_cast<uint>(mConn->status()),
static_cast<uint>(Telepathy::ConnectionStatusDisconnected));
- // Wait for introspection to run (readiness changes to NYC)
- QVERIFY(connect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectNotYetConnected(uint))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(mConn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectNotYetConnected(uint))));
-
delete mConn;
mConn = NULL;
}
diff --git a/tests/pinocchio/handles.cpp b/tests/pinocchio/handles.cpp
index f9fbbcb..6c944ec 100644
--- a/tests/pinocchio/handles.cpp
+++ b/tests/pinocchio/handles.cpp
@@ -39,7 +39,7 @@ private:
protected Q_SLOTS:
// these ought to be private, but if they were, QTest would think they
// were test cases. So, they're protected instead
- void expectConnReady(uint);
+ void expectConnReady(uint, uint);
void expectPendingHandlesFinished(Telepathy::Client::PendingOperation*);
private Q_SLOTS:
@@ -53,32 +53,24 @@ private Q_SLOTS:
void cleanupTestCase();
};
-void TestHandles::expectConnReady(uint newReadiness)
+void TestHandles::expectConnReady(uint newStatus, uint newStatusReason)
{
- switch (newReadiness) {
- case Connection::ReadinessJustCreated:
- qWarning() << "Changing from NYC to JustCreated is silly";
+ switch (newStatus) {
+ case Telepathy::ConnectionStatusDisconnected:
+ qWarning() << "Disconnected";
mLoop->exit(1);
break;
- case Connection::ReadinessNotYetConnected:
- qWarning() << "Changing from NYC to NYC is silly";
- mLoop->exit(2);
- break;
- case Connection::ReadinessConnecting:
+ case Telepathy::ConnectionStatusConnecting:
/* do nothing */
break;
- case Connection::ReadinessFull:
+ case Telepathy::ConnectionStatusConnected:
qDebug() << "Ready";
mLoop->exit(0);
break;
- case Connection::ReadinessDead:
- qWarning() << "Dead!";
- mLoop->exit(3);
- break;
default:
qWarning().nospace() << "What sort of readiness is "
- << newReadiness << "?!";
- mLoop->exit(4);
+ << newStatus << "?!";
+ mLoop->exit(2);
break;
}
}
@@ -134,16 +126,16 @@ void TestHandles::initTestCase()
for (int i = 0; i < 3; ++i) {
Connection *conn = connections[i];
- if (conn->readiness() == Connection::ReadinessFull) {
+ if (conn->status() == Telepathy::ConnectionStatusConnected) {
qDebug() << conn << "Already ready";
continue;
}
- QVERIFY(connect(conn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectConnReady(uint))));
+ QVERIFY(connect(conn, SIGNAL(statusChanged(uint, uint)),
+ this, SLOT(expectConnReady(uint, uint))));
QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(conn, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectConnReady(uint))));
+ QVERIFY(disconnect(conn, SIGNAL(statusChanged(uint, uint)),
+ this, SLOT(expectConnReady(uint, uint))));
}
}
--
1.5.6.5
More information about the Telepathy-commits
mailing list