[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9

Maximiliano Curia maxy at moszumanska.debian.org
Mon May 9 09:07:49 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=5d16a6d

The following commit has been merged in the master branch:
commit 5d16a6d03cd6c26fdbabdeeccb7d837a2728c56d
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Fri Nov 8 15:27:58 2013 +0100

    Port to kpeople2
---
 KTp/CMakeLists.txt                     |   3 +
 KTp/Models/contacts-model.cpp          |  13 ---
 KTp/Models/kpeopletranslationproxy.cpp | 200 ++++++++++++++++-----------------
 KTp/core.cpp                           |   3 +-
 KTp/im-persons-data-source.cpp         |  67 ++++-------
 KTp/im-persons-data-source.h           |   6 +-
 kpeople/CMakeLists.txt                 |   6 +-
 7 files changed, 134 insertions(+), 164 deletions(-)

diff --git a/KTp/CMakeLists.txt b/KTp/CMakeLists.txt
index ec1760d..590b1c1 100644
--- a/KTp/CMakeLists.txt
+++ b/KTp/CMakeLists.txt
@@ -1,3 +1,5 @@
+find_package (KdepimLibs REQUIRED)
+
 include_directories (${CMAKE_CURRENT_BINARY_DIR}
                      ${CMAKE_CURRENT_SOURCE_DIR})
 
@@ -69,6 +71,7 @@ set (ktp_private_LIBS
                        ${KDE4_KIO_LIBS}
                        ${TELEPATHY_QT4_LIBRARIES}
                        ${KDE4_KDEUI_LIBS}
+                       ${KDEPIMLIBS_KABC_LIBS}
 )
 
 if (TELEPATHY_LOGGER_QT4_FOUND)
diff --git a/KTp/Models/contacts-model.cpp b/KTp/Models/contacts-model.cpp
index 0f69eb5..023519f 100644
--- a/KTp/Models/contacts-model.cpp
+++ b/KTp/Models/contacts-model.cpp
@@ -65,19 +65,6 @@ KTp::ContactsModel::ContactsModel(QObject *parent)
         kDebug() << "Nepomuk is enabled, using kpeople model";
         KPeople::PersonsModel *personsModel = new KPeople::PersonsModel(this);
 
-        KPeople::PersonsModelFeature accountFeature;
-        QHash<QString, int> bindingMap;
-        bindingMap[QLatin1String("account")] = KPeople::PersonsModel::UserRole;
-        accountFeature.setBindingsMap(bindingMap);
-        accountFeature.setOptional(false);
-        accountFeature.setQueryPart(QLatin1String("?uri nco:hasIMAccount ?imAccount . ?imAccount nco:isAccessedBy ?accessedBy . ?accessedBy telepathy:accountIdentifier ?account . "));
-
-        personsModel->startQuery(QList<KPeople::PersonsModelFeature>() << KPeople::PersonsModelFeature::imModelFeature(KPeople::PersonsModelFeature::Mandatory)
-                                                            << accountFeature
-                                                            << KPeople::PersonsModelFeature::avatarModelFeature()
-                                                            << KPeople::PersonsModelFeature::groupsModelFeature()
-                                                            << KPeople::PersonsModelFeature::fullNameModelFeature()
-                                                            << KPeople::PersonsModelFeature::nicknameModelFeature());
         connect(personsModel, SIGNAL(modelInitialized()),
                 this, SIGNAL(modelInitialized()));
 
diff --git a/KTp/Models/kpeopletranslationproxy.cpp b/KTp/Models/kpeopletranslationproxy.cpp
index a9bce37..cbac2ed 100644
--- a/KTp/Models/kpeopletranslationproxy.cpp
+++ b/KTp/Models/kpeopletranslationproxy.cpp
@@ -49,107 +49,107 @@ QVariant KPeopleTranslationProxy::data(const QModelIndex &proxyIndex, int role)
         return QVariant();
     }
 
-    IMPersonsDataSource *imPlugin = qobject_cast<IMPersonsDataSource*>(PersonPluginManager::presencePlugin());
-
-    if (!imPlugin) {
-        kWarning() << "No imPlugin";
-        return QVariant();
-    }
-
-    switch (role) {
-        case KTp::ContactPresenceTypeRole:
-            return translatePresence(mapToSource(proxyIndex).data(PersonsModel::PresenceTypeRole));
-        case KTp::ContactPresenceIconRole:
-            return mapToSource(proxyIndex).data(PersonsModel::PresenceIconNameRole);
-        case KTp::ContactPresenceNameRole:
-            return mapToSource(proxyIndex).data(PersonsModel::PresenceDisplayRole);
-        case Qt::DisplayRole:
-            return mapToSource(proxyIndex).data(Qt::DisplayRole);
-        case KTp::RowTypeRole:
-            //if the person has max 1 child, it's a fake person, so treat it as contact row
-            if (mapToSource(proxyIndex).parent().isValid() || sourceModel()->rowCount(mapToSource(proxyIndex)) <= 1) {
-                return KTp::ContactRowType;
-            } else {
-                return KTp::PersonRowType;
-            }
-        case KTp::ContactAvatarPathRole:
-            return mapToSource(proxyIndex).data(PersonsModel::PhotosRole);
-        case KTp::ContactAvatarPixmapRole:
-            return contactPixmap(proxyIndex);
-        case KTp::IdRole:
-            return mapToSource(proxyIndex).data(PersonsModel::IMsRole);
-        case KTp::HeaderTotalUsersRole:
-            return sourceModel()->rowCount(mapToSource(proxyIndex));
-        case KTp::ContactGroupsRole:
-            return mapToSource(proxyIndex).data(PersonsModel::GroupsRole);
-        case KTp::NepomukUriRole:
-            return mapToSource(proxyIndex).data(PersonsModel::UriRole);
-    }
-
-    int j = sourceModel()->rowCount(mapToSource(proxyIndex));
-    
-
-    KTp::ContactPtr contact;
-
-    if (j > 0) {
-        KTp::ContactPtr mostOnlineContact;
-
-        Q_FOREACH(const QVariant &v, mapToSource(proxyIndex).data(PersonsModel::IMsRole).toList()) {
-            KTp::ContactPtr c = imPlugin->contactForContactId(v.toString());
-            if (mostOnlineContact.isNull() && !c.isNull()) {
-                mostOnlineContact = c;
-                continue;
-            }
-            if (!c.isNull()) {
-                if (c->presence() < mostOnlineContact->presence()) {
-                    mostOnlineContact = c;
-                }
-            }
-        }
-        contact = mostOnlineContact;
-    } else if (j == 0) {
-        contact = imPlugin->contactForContactId(mapToSource(proxyIndex).data(PersonsModel::IMsRole).toString());
-    }
-
-    if (!contact.isNull()) {
-        switch (role) {
-            case KTp::AccountRole:
-                return QVariant::fromValue<Tp::AccountPtr>(imPlugin->accountForContact(contact));
-                break;
-            case KTp::ContactRole:
-                return QVariant::fromValue<KTp::ContactPtr>(contact);
-                break;
-            case KTp::ContactPresenceMessageRole:
-                return contact->presence().statusMessage();
-                break;
-            case KTp::ContactIsBlockedRole:
-                return contact->isBlocked();
-                break;
-            case KTp::ContactCanTextChatRole:
-                return true;
-                break;
-            case KTp::ContactCanAudioCallRole:
-                return contact->audioCallCapability();
-                break;
-            case KTp::ContactCanVideoCallRole:
-                return contact->videoCallCapability();
-                break;
-            case KTp::ContactCanFileTransferRole:
-                return contact->fileTransferCapability();
-                break;
-            case KTp::ContactClientTypesRole:
-                return contact->clientTypes();
-                break;
-        }
-    } else if (contact.isNull() && role == KTp::AccountRole) {
-        QVariant accountPath = mapToSource(proxyIndex).data(PersonsModel::UserRole);
-        if (accountPath.type() == QVariant::List) {
-            return QVariant::fromValue<Tp::AccountPtr>(imPlugin->accountManager()->accountForObjectPath(accountPath.toList().first().toString()));
-        } else {
-            return QVariant::fromValue<Tp::AccountPtr>(imPlugin->accountManager()->accountForObjectPath(accountPath.toString()));
-        }
-    }
+//     IMPersonsDataSource *imPlugin = qobject_cast<IMPersonsDataSource*>(PersonPluginManager::presencePlugin());
+//
+//     if (!imPlugin) {
+//         kWarning() << "No imPlugin";
+//         return QVariant();
+//     }
+//
+//     switch (role) {
+//         case KTp::ContactPresenceTypeRole:
+//             return translatePresence(mapToSource(proxyIndex).data(PersonsModel::PresenceTypeRole));
+//         case KTp::ContactPresenceIconRole:
+//             return mapToSource(proxyIndex).data(PersonsModel::PresenceIconNameRole);
+//         case KTp::ContactPresenceNameRole:
+//             return mapToSource(proxyIndex).data(PersonsModel::PresenceDisplayRole);
+//         case Qt::DisplayRole:
+//             return mapToSource(proxyIndex).data(Qt::DisplayRole);
+//         case KTp::RowTypeRole:
+//             //if the person has max 1 child, it's a fake person, so treat it as contact row
+//             if (mapToSource(proxyIndex).parent().isValid() || sourceModel()->rowCount(mapToSource(proxyIndex)) <= 1) {
+//                 return KTp::ContactRowType;
+//             } else {
+//                 return KTp::PersonRowType;
+//             }
+//         case KTp::ContactAvatarPathRole:
+//             return mapToSource(proxyIndex).data(PersonsModel::PhotosRole);
+//         case KTp::ContactAvatarPixmapRole:
+//             return contactPixmap(proxyIndex);
+//         case KTp::IdRole:
+//             return mapToSource(proxyIndex).data(PersonsModel::IMsRole);
+//         case KTp::HeaderTotalUsersRole:
+//             return sourceModel()->rowCount(mapToSource(proxyIndex));
+//         case KTp::ContactGroupsRole:
+//             return mapToSource(proxyIndex).data(PersonsModel::GroupsRole);
+//         case KTp::NepomukUriRole:
+//             return mapToSource(proxyIndex).data(PersonsModel::UriRole);
+//     }
+//
+//     int j = sourceModel()->rowCount(mapToSource(proxyIndex));
+//
+//
+//     KTp::ContactPtr contact;
+//
+//     if (j > 0) {
+//         KTp::ContactPtr mostOnlineContact;
+//
+//         Q_FOREACH(const QVariant &v, mapToSource(proxyIndex).data(PersonsModel::IMsRole).toList()) {
+//             KTp::ContactPtr c = imPlugin->contactForContactId(v.toString());
+//             if (mostOnlineContact.isNull() && !c.isNull()) {
+//                 mostOnlineContact = c;
+//                 continue;
+//             }
+//             if (!c.isNull()) {
+//                 if (c->presence() < mostOnlineContact->presence()) {
+//                     mostOnlineContact = c;
+//                 }
+//             }
+//         }
+//         contact = mostOnlineContact;
+//     } else if (j == 0) {
+//         contact = imPlugin->contactForContactId(mapToSource(proxyIndex).data(PersonsModel::IMsRole).toString());
+//     }
+//
+//     if (!contact.isNull()) {
+//         switch (role) {
+//             case KTp::AccountRole:
+//                 return QVariant::fromValue<Tp::AccountPtr>(imPlugin->accountForContact(contact));
+//                 break;
+//             case KTp::ContactRole:
+//                 return QVariant::fromValue<KTp::ContactPtr>(contact);
+//                 break;
+//             case KTp::ContactPresenceMessageRole:
+//                 return contact->presence().statusMessage();
+//                 break;
+//             case KTp::ContactIsBlockedRole:
+//                 return contact->isBlocked();
+//                 break;
+//             case KTp::ContactCanTextChatRole:
+//                 return true;
+//                 break;
+//             case KTp::ContactCanAudioCallRole:
+//                 return contact->audioCallCapability();
+//                 break;
+//             case KTp::ContactCanVideoCallRole:
+//                 return contact->videoCallCapability();
+//                 break;
+//             case KTp::ContactCanFileTransferRole:
+//                 return contact->fileTransferCapability();
+//                 break;
+//             case KTp::ContactClientTypesRole:
+//                 return contact->clientTypes();
+//                 break;
+//         }
+//     } else if (contact.isNull() && role == KTp::AccountRole) {
+//         QVariant accountPath = mapToSource(proxyIndex).data(PersonsModel::UserRole);
+//         if (accountPath.type() == QVariant::List) {
+//             return QVariant::fromValue<Tp::AccountPtr>(imPlugin->accountManager()->accountForObjectPath(accountPath.toList().first().toString()));
+//         } else {
+//             return QVariant::fromValue<Tp::AccountPtr>(imPlugin->accountManager()->accountForObjectPath(accountPath.toString()));
+//         }
 //     }
+// //     }
 
     return mapToSource(proxyIndex).data(role);
 }
diff --git a/KTp/core.cpp b/KTp/core.cpp
index df16443..87efe15 100644
--- a/KTp/core.cpp
+++ b/KTp/core.cpp
@@ -69,7 +69,8 @@ CorePrivate::CorePrivate()
     Tp::ContactFactoryPtr contactFactory = KTp::ContactFactory::create(Tp::Features()  << Tp::Contact::FeatureAlias
                                                                                        << Tp::Contact::FeatureSimplePresence
                                                                                        << Tp::Contact::FeatureCapabilities
-                                                                                       << Tp::Contact::FeatureClientTypes);
+                                                                                       << Tp::Contact::FeatureClientTypes
+                                                                                       << Tp::Contact::FeatureAvatarData);
 
     Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
 
diff --git a/KTp/im-persons-data-source.cpp b/KTp/im-persons-data-source.cpp
index 49b9045..25767e8 100644
--- a/KTp/im-persons-data-source.cpp
+++ b/KTp/im-persons-data-source.cpp
@@ -55,14 +55,14 @@ void IMPersonsDataSource::Private::onAllKnownContactsChanged(const Tp::Contacts
     if (!contacts.isEmpty()) {
         Q_FOREACH (const Tp::ContactPtr &contact, contactsRemoved) {
             contacts.remove(contact->id());
+            Q_EMIT q->contactRemoved(contact->id());
         }
     }
 
     Q_FOREACH (const Tp::ContactPtr &contact, contactsAdded) {
         KTp::ContactPtr ktpContact = KTp::ContactPtr::qObjectCast(contact);
         contacts.insert(contact->id(), ktpContact);
-
-        Q_EMIT q->contactChanged(contact->id());
+        Q_EMIT q->contactAdded(contact->id());
 
         connect(ktpContact.data(), SIGNAL(presenceChanged(Tp::Presence)),
                 q, SLOT(onContactChanged()));
@@ -72,9 +72,6 @@ void IMPersonsDataSource::Private::onAllKnownContactsChanged(const Tp::Contacts
 
         connect(ktpContact.data(), SIGNAL(invalidated()),
                 q, SLOT(onContactInvalidated()));
-
-        //TODO: add other stuff here etc
-
     }
 }
 
@@ -99,50 +96,28 @@ IMPersonsDataSource::~IMPersonsDataSource()
     delete d;
 }
 
-QVariant IMPersonsDataSource::dataForContact(const QString &contactId, int role) const
+const KABC::Addressee::Map IMPersonsDataSource::allContacts()
 {
-    KTp::ContactPtr contact = d->contacts.value(contactId);
-
-    //we need to handle only few roles here, all the rest must go to the source model
-    switch (role) {
-        case PersonsModel::PresenceTypeRole:
-            if (!contact.isNull()) {
-                return contact->presence().status();
-            } else if (!contactId.isEmpty()) {
-                return QLatin1String("offline");
-            } else if (contactId.isEmpty()) {
-                return QLatin1String("unknown");
-            }
-        break;
-        case PersonsModel::PresenceDisplayRole:
-            if (!contact.isNull()) {
-                return contact->presence().displayString();
-            } else if (!contactId.isEmpty()) {
-                return KTp::Presence(Tp::Presence::offline()).displayString();
-            } else if (contactId.isEmpty()) {
-                return QVariant();
-            }
-        break;
-        case PersonsModel::PresenceDecorationRole:
-            if (!contact.isNull()) {
-                return contact->presence().icon();
-            } else if (!contactId.isEmpty()) {
-                return KTp::Presence(Tp::Presence::offline()).icon();
-            } else if (contactId.isEmpty()) {
-                return QVariant();
-            }
-        break;
-        case PersonsModel::PresenceIconNameRole:
-            if (!contact.isNull()) {
-                return contact->presence().iconName();
-            } else if (!contactId.isEmpty()) {
-                return QString(QLatin1String("user-offline"));
-            } else if (contactId.isEmpty()) {
-                return QVariant();
-            }
+    KABC::Addressee::Map contacts;
+    Q_FOREACH(const QString &key, d->contacts.keys()) {
+        contacts.insert(key, contact(key));
     }
+    return contacts;
+}
 
-    return QVariant();
+const KABC::Addressee IMPersonsDataSource::contact(const QString &contactId)
+{
+    KABC::Addressee vcard;
+
+    qDebug() << "running ktp datasource" << contactId;
+    KTp::ContactPtr contact = d->contacts[contactId];
+    if (contact) {
+        vcard.setFormattedName(contact->alias());
+        vcard.insertCustom(QLatin1String("telepathy"), QLatin1String("contactId"), contact->id());
+//         vcard.insertCustom("telepathy", "accountId", contact->id());
+        vcard.setPhoto(KABC::Picture(contact->avatarData().fileName));
+    }
+    return vcard;
 }
 
 void IMPersonsDataSource::onAccountManagerReady(Tp::PendingOperation *op)
diff --git a/KTp/im-persons-data-source.h b/KTp/im-persons-data-source.h
index e6a3229..6635613 100644
--- a/KTp/im-persons-data-source.h
+++ b/KTp/im-persons-data-source.h
@@ -27,6 +27,8 @@
 #include "KTp/contact.h"
 #include "KTp/ktp-export.h"
 
+#include <KABC/Addressee>
+
 namespace KTp { class GlobalContactManager; }
 namespace Tp { class PendingOperation; }
 
@@ -37,7 +39,9 @@ public:
     IMPersonsDataSource(QObject *parent, const QVariantList &data);
     virtual ~IMPersonsDataSource();
 
-    QVariant dataForContact(const QString &contactId, int role) const;
+    virtual const KABC::Addressee contact(const QString &contactId);
+    virtual const KABC::Addressee::Map allContacts();
+
     KTp::ContactPtr contactForContactId(const QString &contactId) const;
     Tp::AccountPtr accountForContact(const KTp::ContactPtr &contact) const;
 
diff --git a/kpeople/CMakeLists.txt b/kpeople/CMakeLists.txt
index 7cec3ac..42741d8 100644
--- a/kpeople/CMakeLists.txt
+++ b/kpeople/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_subdirectory(actionsplugin)
+# add_subdirectory(actionsplugin)
 add_subdirectory(datasourceplugin)
-add_subdirectory(uiplugins)
-add_subdirectory(nepomuk-feeder)
+# add_subdirectory(uiplugins)
+# add_subdirectory(nepomuk-feeder)

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list