[Telepathy-commits] [telepathy-qt4/master] Add function for checking whether the Contacts/ContactManager functionality is supported

Olli Salli olli.salli at collabora.co.uk
Wed Jan 28 23:27:28 PST 2009


---
 TelepathyQt4/Client/contact-manager.cpp |   13 +++++++++++++
 TelepathyQt4/Client/contact-manager.h   |    2 ++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/TelepathyQt4/Client/contact-manager.cpp b/TelepathyQt4/Client/contact-manager.cpp
index dda2a0d..9ed3bb6 100644
--- a/TelepathyQt4/Client/contact-manager.cpp
+++ b/TelepathyQt4/Client/contact-manager.cpp
@@ -70,6 +70,19 @@ Connection *ContactManager::connection() const
     return mPriv->conn;
 }
 
+bool ContactManager::isSupported() const
+{
+    if (!connection()->isReady()) {
+        warning() << "ContactManager::isSupported() used before the connection is ready!";
+        return false;
+    } else if (connection()->status() != Connection::StatusConnected) {
+        warning() << "ContactManager::isSupported() used before the connection is connected!";
+        return false;
+    }
+
+    return connection()->interfaces().contains(TELEPATHY_INTERFACE_CONNECTION_INTERFACE_CONTACTS);
+}
+
 namespace
 {
 QString featureToInterface(Contact::Feature feature)
diff --git a/TelepathyQt4/Client/contact-manager.h b/TelepathyQt4/Client/contact-manager.h
index 0d1938d..88ca66e 100644
--- a/TelepathyQt4/Client/contact-manager.h
+++ b/TelepathyQt4/Client/contact-manager.h
@@ -46,6 +46,8 @@ class ContactManager
 
         Connection *connection() const;
 
+        bool isSupported() const;
+
         PendingContacts *contactsForHandles(const UIntList &handles,
                 const QSet<Contact::Feature> &features = QSet<Contact::Feature>());
         PendingContacts *contactsForHandles(const ReferencedHandles &handles,
-- 
1.5.6.5




More information about the telepathy-commits mailing list