[Telepathy-commits] [telepathy-qt4/master] Connection: Proper check for status when using some methods.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Wed Feb 25 09:18:18 PST 2009


Some methods are used internally before the connection emits statusChanged and
the status() returns Connected. For example ensureChannel is used by
FeatureRoster but the connection status may not be Connected yet (waiting for
all features to become ready before changing status).
---
 TelepathyQt4/Client/connection.cpp |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/TelepathyQt4/Client/connection.cpp b/TelepathyQt4/Client/connection.cpp
index 03990c2..2642974 100644
--- a/TelepathyQt4/Client/connection.cpp
+++ b/TelepathyQt4/Client/connection.cpp
@@ -1048,7 +1048,7 @@ ConnectionInterface *Connection::baseInterface() const
  */
 PendingChannel *Connection::createChannel(const QVariantMap &request)
 {
-    if (mPriv->status != StatusConnected) {
+    if (mPriv->pendingStatus != StatusConnected) {
         warning() << "Calling createChannel with connection not yet connected";
         return new PendingChannel(this, TELEPATHY_ERROR_NOT_AVAILABLE,
                 "Connection not yet connected");
@@ -1099,7 +1099,7 @@ PendingChannel *Connection::createChannel(const QVariantMap &request)
  */
 PendingChannel *Connection::ensureChannel(const QVariantMap &request)
 {
-    if (mPriv->status != StatusConnected) {
+    if (mPriv->pendingStatus != StatusConnected) {
         warning() << "Calling ensureChannel with connection not yet connected";
         return new PendingChannel(this, TELEPATHY_ERROR_NOT_AVAILABLE,
                 "Connection not yet connected");
@@ -1393,9 +1393,7 @@ PendingContactAttributes *Connection::getContactAttributes(const UIntList &handl
 
 QStringList Connection::contactAttributeInterfaces() const
 {
-    if (!isReady()) {
-        warning() << "Connection::contactAttributeInterfaces() used when not ready";
-    } else if (status() != StatusConnected) {
+    if (mPriv->pendingStatus != StatusConnected) {
         warning() << "Connection::contactAttributeInterfaces() used with status"
             << status() << "!= StatusConnected";
     } else if (!this->interfaces().contains(TELEPATHY_INTERFACE_CONNECTION_INTERFACE_CONTACTS)) {
-- 
1.5.6.5




More information about the telepathy-commits mailing list