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

Maximiliano Curia maxy at moszumanska.debian.org
Fri May 27 23:59:46 UTC 2016


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

The following commit has been merged in the master branch:
commit ad3846baab5dbdf69683b2c685fb5955c449664b
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Mon Jul 11 23:20:13 2011 +0100

    Only list profiles which have a valid CM.
    
    REVIEW: 101926
    BUG: 277534
---
 src/KCMTelepathyAccounts/profile-list-model.cpp | 68 +++++++++++++++++--------
 src/KCMTelepathyAccounts/profile-list-model.h   | 10 ++++
 2 files changed, 56 insertions(+), 22 deletions(-)

diff --git a/src/KCMTelepathyAccounts/profile-list-model.cpp b/src/KCMTelepathyAccounts/profile-list-model.cpp
index f3b5065..c7536ab 100644
--- a/src/KCMTelepathyAccounts/profile-list-model.cpp
+++ b/src/KCMTelepathyAccounts/profile-list-model.cpp
@@ -24,6 +24,8 @@
 #include "profile-item.h"
 
 #include <TelepathyQt4/ProfileManager>
+#include <TelepathyQt4/PendingStringList>
+
 #include <KIcon>
 #include <KDebug>
 
@@ -75,15 +77,42 @@ QVariant ProfileListModel::data(const QModelIndex &index, int role) const
 
 void ProfileListModel::setProfileManager(Tp::ProfileManagerPtr profileManager)
 {
-    kDebug() << "Setting ProfileManager to:"
-             << profileManager.data();
+    m_profileManager = profileManager;
+    Tp::PendingStringList* pendingNames = Tp::ConnectionManager::listNames();
+    connect(pendingNames, SIGNAL(finished(Tp::PendingOperation*)), SLOT(onConnectionManagerNamesFetched(Tp::PendingOperation*)));
+}
+
+ProfileItem *ProfileListModel::itemForIndex(const QModelIndex &index) const
+{
+    return m_profileItems.at(index.row());
+}
+
+bool ProfileListModel::hasNonFakeProfile(const Tp::ProfilePtr& profile, const QList<Tp::ProfilePtr> &profiles) const
+{
+    foreach(const Tp::ProfilePtr &otherProfile, profiles) {
+        if(profile->protocolName() == otherProfile->protocolName() && !otherProfile->isFake())
+        {
+            // check if this profile is for a special service or for this protocol in general
+            if(otherProfile->serviceName() == otherProfile->cmName().append("-").append(otherProfile->protocolName())
+            || otherProfile->serviceName() == otherProfile->protocolName()) {
+                return true;
+            }
+        }
+    }
+
+    return false;
+}
 
+void ProfileListModel::populateList()
+{
     foreach (ProfileItem *item, m_profileItems) {
         delete item;
         item = 0;
     }
 
-    QList<Tp::ProfilePtr> profiles = profileManager->profiles();
+    m_profileItems.clear();
+
+    QList<Tp::ProfilePtr> profiles = m_profileManager->profiles();
 
     QList<ProfileItem*> insertItems;
     foreach(const Tp::ProfilePtr &profile, profiles) {
@@ -92,39 +121,34 @@ void ProfileListModel::setProfileManager(Tp::ProfileManagerPtr profileManager)
                 continue;
             }
         }
+
+        //don't include profiles which we don't have a CM for
+        if (! m_connectionManagerNames.contains(profile->cmName())) {
+            continue;
+        }
+
         insertItems.append(new ProfileItem(profile, this));
     }
-    
+
     if( insertItems.size() > 0 )
     {
       beginInsertRows(QModelIndex(), 0, insertItems.size()-1);
       m_profileItems.append(insertItems);
       endInsertRows();
     }
-    else
+    else {
       return;
-    
+    }
 }
 
-ProfileItem *ProfileListModel::itemForIndex(const QModelIndex &index) const
+void ProfileListModel::onConnectionManagerNamesFetched(Tp::PendingOperation *operation)
 {
-    return m_profileItems.at(index.row());
-}
+    Tp::PendingStringList* connectionManagerNamesOperation = qobject_cast<Tp::PendingStringList*>(operation);
 
-bool ProfileListModel::hasNonFakeProfile(const Tp::ProfilePtr& profile, const QList<Tp::ProfilePtr> &profiles) const
-{
-    foreach(const Tp::ProfilePtr &otherProfile, profiles) {
-        if(profile->protocolName() == otherProfile->protocolName() && !otherProfile->isFake())
-        {
-            // check if this profile is for a special service or for this protocol in general
-            if(otherProfile->serviceName() == otherProfile->cmName().append("-").append(otherProfile->protocolName())
-            || otherProfile->serviceName() == otherProfile->protocolName()) {
-                return true;
-            }
-        }
-    }
+    Q_ASSERT(connectionManagerNamesOperation);
+    m_connectionManagerNames = connectionManagerNamesOperation->result();
 
-    return false;
+    populateList();
 }
 
 
diff --git a/src/KCMTelepathyAccounts/profile-list-model.h b/src/KCMTelepathyAccounts/profile-list-model.h
index 8f95895..63e5a16 100644
--- a/src/KCMTelepathyAccounts/profile-list-model.h
+++ b/src/KCMTelepathyAccounts/profile-list-model.h
@@ -26,6 +26,10 @@
 
 #include <TelepathyQt4/ConnectionManager>
 
+namespace TelepathyQt4 {
+    class PendingOperation;
+}
+
 class ProfileItem;
 
 class ProfileListModel : public QAbstractListModel
@@ -44,10 +48,16 @@ public:
 
     void setProfileManager(Tp::ProfileManagerPtr profileManager);
 
+private slots:
+    void onConnectionManagerNamesFetched(Tp::PendingOperation*);
+
 private:
     bool hasNonFakeProfile(const Tp::ProfilePtr &profile, const QList<Tp::ProfilePtr> &profiles) const;
+    void populateList();
 
+    Tp::ProfileManagerPtr m_profileManager;
     QList<ProfileItem*> m_profileItems;
+    QStringList m_connectionManagerNames;
 };
 
 

-- 
ktp-accounts-kcm packaging



More information about the pkg-kde-commits mailing list