[SCM] ktp-accounts-kcm packaging branch, master, updated. debian/15.12.1-1-1157-gc4589c5

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:02:33 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=900824a

The following commit has been merged in the master branch:
commit 900824a2f8ea5eb35a483e40498a593842bdb7ce
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Thu Sep 20 21:37:22 2012 +0100

    Check connection manager supports protocol listed in profile.
    
    This should fix the issue of skype appearing in the list when telpeathy-haze was installed but pidgin-skype was not.
    ConnectionManagers require having becomeReady() called before the list of protocols they support can be used, hence converting from a list of CMs to a hash of CmPtrs
    
    REVIEW: 106515
    BUG: 302122
---
 src/KCMTelepathyAccounts/profile-list-model.cpp | 47 +++++++++++++++++++++----
 src/KCMTelepathyAccounts/profile-list-model.h   |  4 ++-
 2 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/src/KCMTelepathyAccounts/profile-list-model.cpp b/src/KCMTelepathyAccounts/profile-list-model.cpp
index 35ced7c..d785ecc 100644
--- a/src/KCMTelepathyAccounts/profile-list-model.cpp
+++ b/src/KCMTelepathyAccounts/profile-list-model.cpp
@@ -27,6 +27,8 @@
 #include <TelepathyQt/PendingReady>
 #include <TelepathyQt/ProfileManager>
 #include <TelepathyQt/PendingStringList>
+#include <TelepathyQt/PendingComposite>
+
 
 #include <KDebug>
 #include <KIcon>
@@ -120,9 +122,10 @@ bool ProfileListModel::hasNonFakeProfile(const Tp::ProfilePtr& profile, const QL
             // check if this profile is for a special service or for this protocol in general
             if (otherProfile->serviceName() == otherProfile->cmName().append(QLatin1Char('-')).append(otherProfile->protocolName())
             || otherProfile->serviceName() == otherProfile->protocolName()) {
-                
+
                 //check we have a valid CM for the non-fake profile
-                if (m_connectionManagerNames.contains(otherProfile->cmName())) {
+
+                if (hasValidCM(otherProfile)) {
                     return true;
                 }
             }
@@ -132,6 +135,22 @@ bool ProfileListModel::hasNonFakeProfile(const Tp::ProfilePtr& profile, const QL
     return false;
 }
 
+bool ProfileListModel::hasValidCM(const Tp::ProfilePtr &profile) const
+{
+    //check we have a valid CM for the non-fake profile
+    if (!m_connectionManagers.contains(profile->cmName())) {
+        return false;
+    }
+
+    //if cm exists but doesn't support protocol in profile.
+    if (!m_connectionManagers[profile->cmName()]->hasProtocol(profile->protocolName())) {
+        return false;
+    }
+
+
+    return true;
+}
+
 void ProfileListModel::populateList()
 {
     Q_FOREACH (ProfileItem *item, m_profileItems) {
@@ -151,20 +170,21 @@ void ProfileListModel::populateList()
             }
         }
 
+
         //don't include profiles which we don't have a CM for
-        if (! m_connectionManagerNames.contains(profile->cmName())) {
+        if (!hasValidCM(profile)) {
             continue;
         }
 
         //Hide all IRC accounts
         //this is a deliberate decision from Akademy meeting 2012
-        //"no, we don't support IRC", it's a different usage and in order to have a semi-decent IRC experience 
+        //"no, we don't support IRC", it's a different usage and in order to have a semi-decent IRC experience
         //we need to add a lot more that we simply don't have resources to do.
         //It's a better user experience to learn how to use a different app than to try using this.
-        
+
         //Remove this "continue" to re-enable IRC support, for personal reasons or hacking
         //this topic can be discussed again as of July 2013
-        
+
         if(profile->serviceName() == QLatin1String("irc")) {
                 continue;
         }
@@ -186,8 +206,21 @@ void ProfileListModel::onConnectionManagerNamesFetched(Tp::PendingOperation *ope
     Tp::PendingStringList* connectionManagerNamesOperation = qobject_cast<Tp::PendingStringList*>(operation);
 
     Q_ASSERT(connectionManagerNamesOperation);
-    m_connectionManagerNames = connectionManagerNamesOperation->result();
 
+    QList<Tp::PendingOperation*> pendingOps;
+
+    Q_FOREACH(const QString &cmName, connectionManagerNamesOperation->result()) {
+        Tp::ConnectionManagerPtr cm = Tp::ConnectionManager::create(QDBusConnection::sessionBus(), cmName);
+        pendingOps.append(cm->becomeReady());
+        m_connectionManagers[cmName] = cm;
+    }
+
+    connect(new Tp::PendingComposite(pendingOps, m_profileManager), SIGNAL(finished(Tp::PendingOperation*)), SLOT(onConnectionManagersLoaded(Tp::PendingOperation*)));
+}
+
+void ProfileListModel::onConnectionManagersLoaded(Tp::PendingOperation *op)
+{
+    Q_UNUSED(op)
     populateList();
 }
 
diff --git a/src/KCMTelepathyAccounts/profile-list-model.h b/src/KCMTelepathyAccounts/profile-list-model.h
index d133ffc..8b313d1 100644
--- a/src/KCMTelepathyAccounts/profile-list-model.h
+++ b/src/KCMTelepathyAccounts/profile-list-model.h
@@ -56,15 +56,17 @@ public:
 
 private Q_SLOTS:
     void onConnectionManagerNamesFetched(Tp::PendingOperation*);
+    void onConnectionManagersLoaded(Tp::PendingOperation *op);
     void onProfileManagerReady(Tp::PendingOperation *op);
 
 private:
     bool hasNonFakeProfile(const Tp::ProfilePtr &profile, const QList<Tp::ProfilePtr> &profiles) const;
+    bool hasValidCM(const Tp::ProfilePtr &profile) const;
     void populateList();
 
     Tp::ProfileManagerPtr m_profileManager;
     QList<ProfileItem*> m_profileItems;
-    QStringList m_connectionManagerNames;
+    QHash<QString, Tp::ConnectionManagerPtr> m_connectionManagers;
 };
 
 

-- 
ktp-accounts-kcm packaging



More information about the pkg-kde-commits mailing list