[Telepathy-commits] [telepathy-qt4/master] AccountManager: work around Mission Control 5 <= 5.0.beta45 type mismatch

Simon McVittie simon.mcvittie at collabora.co.uk
Wed Dec 10 11:29:08 PST 2008


telepathy-spec says ValidAccounts is an array of object paths, 'ao',
but in Mission Control <= 5.0.beta45 it's implemented as an array of
strings, 'as'. I've checked in a fix to MC, but until it gets released,
we'll need something like this.
---
 TelepathyQt4/Prototype/AccountManager.cpp |   37 ++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/TelepathyQt4/Prototype/AccountManager.cpp b/TelepathyQt4/Prototype/AccountManager.cpp
index 3d3f941..00ea6c3 100644
--- a/TelepathyQt4/Prototype/AccountManager.cpp
+++ b/TelepathyQt4/Prototype/AccountManager.cpp
@@ -60,7 +60,42 @@ public:
     {
         Q_ASSERT(m_propertiesInterface);
 
-        return m_pInterface->ValidAccounts();
+        QDBusPendingReply<QDBusVariant> get = m_propertiesInterface->Get(
+                "org.freedesktop.Telepathy.AccountManager", "ValidAccounts");
+        get.waitForFinished();
+
+        if (!get.isValid())
+        {
+            qWarning().nospace() << get.error().name() << ": "
+                << get.error().message();
+            return Telepathy::ObjectPathList();
+        }
+
+        Telepathy::ObjectPathList paths = qdbus_cast<Telepathy::ObjectPathList>(
+                get.value().variant());
+
+        if (paths.size() == 0)
+        {
+            // maybe the AccountManager is buggy, like Mission Control
+            // 5.0.beta45, and returns an array of strings rather than
+            // an array of object paths?
+
+            QStringList wronglyTypedPaths = qdbus_cast<QStringList>(
+                    get.value().variant());
+
+            if (wronglyTypedPaths.size() > 0)
+            {
+                qWarning() << "AccountManager returned wrong type "
+                    "(expected 'ao', got 'as'); workaround active";
+
+                Q_FOREACH (QString path, wronglyTypedPaths)
+                {
+                    paths << QDBusObjectPath(path);
+                }
+            }
+        }
+
+        return paths;
     }
 
     void removeAccount( const QString& handle )
-- 
1.5.6.5



More information about the Telepathy-commits mailing list