[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:08:38 UTC 2016


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

The following commit has been merged in the master branch:
commit 9fc95114d87a874dfac9e0941820366c80e47aad
Author: Aleix Pol <aleixpol at kde.org>
Date:   Fri Jan 9 15:01:05 2015 +0100

    Adapt to changes in libkpeople involving dropping KContacts dependency
    
    Implement AbstractContact on the KPeople backend.
    Properly use the model and PersonData when exposing KPeople in KTp
    frontends.
    
    REVIEW: 121657
---
 KTp/Models/kpeopletranslationproxy.cpp             |  52 ++++----
 kpeople/actionsplugin/CMakeLists.txt               |   1 +
 kpeople/actionsplugin/kpeople-actions-plugin.cpp   |   9 +-
 kpeople/actionsplugin/kpeople-actions-plugin.h     |   5 +-
 .../datasourceplugin/im-persons-data-source.cpp    | 148 ++++++++++++---------
 kpeople/uiplugins/CMakeLists.txt                   |   1 +
 kpeople/uiplugins/chatplugin/CMakeLists.txt        |   1 +
 .../uiplugins/chatplugin/kpeople_chat_plugin.cpp   |  18 +--
 kpeople/uiplugins/chatplugin/kpeople_chat_plugin.h |   2 +-
 kpeople/uiplugins/imdetailswidget.cpp              |  15 +--
 kpeople/uiplugins/imdetailswidget.h                |   2 +-
 tests/CMakeLists.txt                               |   1 +
 12 files changed, 137 insertions(+), 118 deletions(-)

diff --git a/KTp/Models/kpeopletranslationproxy.cpp b/KTp/Models/kpeopletranslationproxy.cpp
index d61b026..d241047 100644
--- a/KTp/Models/kpeopletranslationproxy.cpp
+++ b/KTp/Models/kpeopletranslationproxy.cpp
@@ -27,7 +27,6 @@
 #include <global-contact-manager.h>
 
 #include <KIconLoader>
-#include <KContacts/Addressee>
 
 #include <QPixmapCache>
 
@@ -57,71 +56,66 @@ QVariant KPeopleTranslationProxy::data(const QModelIndex &proxyIndex, int role)
 //         return QVariant();
 //     }
 //
-    const KContacts::Addressee &contact = mapToSource(proxyIndex).data(KPeople::PersonsModel::PersonVCardRole).value<KContacts::Addressee>();
+    const QModelIndex sourceIndex = mapToSource(proxyIndex);
+    AbstractContact::Ptr contact = sourceIndex.data(KPeople::PersonsModel::PersonVCardRole).value<AbstractContact::Ptr>();
 
     switch (role) {
         case KTp::ContactPresenceTypeRole:
-            return translatePresence(contact.custom(QLatin1String("telepathy"), QLatin1String("presence")));
+            return translatePresence(contact->customProperty(QStringLiteral("telepathy-presence")));
         case KTp::ContactPresenceIconRole:
-            return KPeople::iconNameForPresenceString(contact.custom(QLatin1String("telepathy"), QLatin1String("presence")));
+            return KPeople::iconNameForPresenceString(contact->customProperty(QStringLiteral("telepathy-presence")).toString());
 //         case KTp::ContactPresenceNameRole:
-//             return mapToSource(proxyIndex).data(PersonsModel::PresenceDisplayRole);
+//             return sourceIndex.data(PersonsModel::PresenceDisplayRole);
         case Qt::DisplayRole:
-            return mapToSource(proxyIndex).data(KPeople::PersonsModel::FormattedNameRole);
+            return sourceIndex.data(KPeople::PersonsModel::FormattedNameRole);
         case KTp::RowTypeRole:
-            if (proxyIndex.parent().isValid() || sourceModel()->rowCount(mapToSource(proxyIndex)) <= 1) {
+            if (proxyIndex.parent().isValid() || sourceModel()->rowCount(sourceIndex) <= 1) {
                 return KTp::ContactRowType;
             } else {
                 return KTp::PersonRowType;
             }
 //             //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) {
+//             if (sourceIndex.parent().isValid() || sourceModel()->rowCount(sourceIndex) <= 1) {
 //                 return KTp::ContactRowType;
 //             } else {
 //                 return KTp::PersonRowType;
 //             }
 //         case KTp::ContactAvatarPathRole:
-//             return mapToSource(proxyIndex).data(PersonsModel::PhotosRole);
+//             return sourceIndex.data(PersonsModel::PhotosRole);
         case KTp::ContactAvatarPixmapRole:
-            return mapToSource(proxyIndex).data(KPeople::PersonsModel::PhotoRole);
+            return sourceIndex.data(KPeople::PersonsModel::PhotoRole);
         case KTp::IdRole:
-            return contact.custom(QLatin1String("telepathy"), QLatin1String("contactId"));
+            return contact->customProperty(QStringLiteral("telepathy-contactId"));
 //         case KTp::HeaderTotalUsersRole:
-//             return sourceModel()->rowCount(mapToSource(proxyIndex));
+//             return sourceModel()->rowCount(sourceIndex);
         case KTp::ContactGroupsRole:
-            return mapToSource(proxyIndex).data(PersonsModel::GroupsRole);
+            return sourceIndex.data(PersonsModel::GroupsRole);
         case KTp::PersonIdRole:
-            return mapToSource(proxyIndex).data(PersonsModel::PersonIdRole);
+            return sourceIndex.data(PersonsModel::PersonIdRole);
         case KTp::ContactVCardRole:
-            return mapToSource(proxyIndex).data(KPeople::PersonsModel::PersonVCardRole);
+            return sourceIndex.data(KPeople::PersonsModel::PersonVCardRole);
     }
 
-    const KContacts::Addressee::List &contacts = mapToSource(proxyIndex).data(PersonsModel::ContactsVCardRole).value<KContacts::Addressee::List>();
+    AbstractContact::List contacts = sourceIndex.data(PersonsModel::ContactsVCardRole).value<AbstractContact::List>();
 
     int mostOnlineIndex = 0;
 
     for (int i = 0; i < contacts.size(); i++) {
-        if (KPeople::presenceSortPriority(contact.custom(QLatin1String("telepathy"), QLatin1String("presence")))
-            < KPeople::presenceSortPriority(contacts.at(mostOnlineIndex).custom(QLatin1String("telepathy"), QLatin1String("presence")))) {
+        if (KPeople::presenceSortPriority(contact->customProperty(QStringLiteral("telepathy-presence")).toString())
+            < KPeople::presenceSortPriority(contacts.at(mostOnlineIndex)->customProperty(QStringLiteral("telepathy-presence")).toString())) {
 
             mostOnlineIndex = i;
         }
     }
 
     QVariant rValue;
-
-    if (contacts.size() == 0) {
-        rValue = dataForKTpContact(contact.custom(QLatin1String("telepathy"), QLatin1String("accountPath")),
-                                 contact.custom(QLatin1String("telepathy"), QLatin1String("contactId")),
-                                 role);
-    } else {
-        rValue = dataForKTpContact(contacts.at(mostOnlineIndex).custom(QLatin1String("telepathy"), QLatin1String("accountPath")),
-                                 contacts.at(mostOnlineIndex).custom(QLatin1String("telepathy"), QLatin1String("contactId")),
+    AbstractContact::Ptr informationContact = contacts.isEmpty() ? contact : contacts.at(mostOnlineIndex);
+    rValue = dataForKTpContact(informationContact->customProperty(QStringLiteral("telepathy-accountPath")).toString(),
+                               informationContact->customProperty(QStringLiteral("telepathy-contactId")).toString(),
                                  role);
-    }
 
     if (rValue.isNull()) {
-        return mapToSource(proxyIndex).data(role);
+        return sourceIndex.data(role);
     } else {
         return rValue;
     }
@@ -171,7 +165,7 @@ bool KPeopleTranslationProxy::filterAcceptsRow(int source_row, const QModelIndex
     QModelIndex sourceIndex = sourceModel()->index(source_row, 0, source_parent);
 
     //if no valid presence (not even "offline") .. reject the contact
-    return !sourceIndex.data(KPeople::PersonsModel::PersonVCardRole).value<KContacts::Addressee>().custom(QLatin1String("telepathy"), QLatin1String("presence")).isEmpty();
+    return !sourceIndex.data(KPeople::PersonsModel::PersonVCardRole).value<KPeople::AbstractContact::Ptr>()->customProperty(QStringLiteral("telepathy-presence")).isNull();
 }
 
 QVariant KPeopleTranslationProxy::translatePresence(const QVariant &presenceName) const
diff --git a/kpeople/actionsplugin/CMakeLists.txt b/kpeople/actionsplugin/CMakeLists.txt
index f8fd47b..cc918bf 100644
--- a/kpeople/actionsplugin/CMakeLists.txt
+++ b/kpeople/actionsplugin/CMakeLists.txt
@@ -5,6 +5,7 @@ add_library (ktp_kpeople_plugin MODULE
 target_link_libraries (ktp_kpeople_plugin
     KF5::People
     KF5::I18n
+    KF5::Service
     KTp::CommonInternals
 )
 
diff --git a/kpeople/actionsplugin/kpeople-actions-plugin.cpp b/kpeople/actionsplugin/kpeople-actions-plugin.cpp
index da10e36..24712a8 100644
--- a/kpeople/actionsplugin/kpeople-actions-plugin.cpp
+++ b/kpeople/actionsplugin/kpeople-actions-plugin.cpp
@@ -105,8 +105,7 @@ KPeopleActionsPlugin::KPeopleActionsPlugin(QObject *parent, const QVariantList &
     Q_UNUSED(args);
 }
 
-QList<QAction*> KPeopleActionsPlugin::actionsForPerson(const KContacts::Addressee &person,
-                                                       const KContacts::Addressee::List &contacts,
+QList<QAction*> KPeopleActionsPlugin::actionsForPerson(const KPeople::PersonData &person,
                                                        QObject *parent) const
 {
     QList<QAction*> actions;
@@ -116,10 +115,8 @@ QList<QAction*> KPeopleActionsPlugin::actionsForPerson(const KContacts::Addresse
     // the subcontacts for all capabilities and fill them in on the Person, so if eg. one of
     // the subcontacts can do audio calls and the other can do video calls, the Person
     // should have both actions present.
-    Q_UNUSED(contacts);
-
-    const QString &accountPath = person.custom(QLatin1String("telepathy"), QLatin1String("accountPath"));
-    const QString &contactId = person.custom(QLatin1String("telepathy"), QLatin1String("contactId"));
+    QString accountPath = person.contactCustomProperty(QLatin1String("telepathy-accountPath")).toString();
+    QString contactId = person.contactCustomProperty(QLatin1String("telepathy-contactId")).toString();
 
     const Tp::AccountPtr account = KTp::contactManager()->accountForAccountPath(accountPath);
     if (!account) {
diff --git a/kpeople/actionsplugin/kpeople-actions-plugin.h b/kpeople/actionsplugin/kpeople-actions-plugin.h
index bacd7b5..b80bef8 100644
--- a/kpeople/actionsplugin/kpeople-actions-plugin.h
+++ b/kpeople/actionsplugin/kpeople-actions-plugin.h
@@ -26,9 +26,8 @@ class KPeopleActionsPlugin : public KPeople::AbstractPersonAction
     Q_OBJECT
 public:
     KPeopleActionsPlugin(QObject *parent, const QVariantList &args);
-    virtual QList<QAction*> actionsForPerson(const KContacts::Addressee &person,
-                                             const KContacts::Addressee::List &contacts,
-                                             QObject *parent) const;
+    virtual QList< QAction* > actionsForPerson(const KPeople::PersonData &data,
+                                               QObject *parent) const Q_DECL_OVERRIDE;
 
 private Q_SLOTS:
     void onActionTriggered();
diff --git a/kpeople/datasourceplugin/im-persons-data-source.cpp b/kpeople/datasourceplugin/im-persons-data-source.cpp
index 18598d0..297d465 100644
--- a/kpeople/datasourceplugin/im-persons-data-source.cpp
+++ b/kpeople/datasourceplugin/im-persons-data-source.cpp
@@ -34,7 +34,6 @@
 #include "debug.h"
 
 #include <KPeopleBackend/AllContactsMonitor>
-#include <KContacts/Addressee>
 
 #include <KPluginFactory>
 #include <KPluginLoader>
@@ -44,14 +43,13 @@
 
 using namespace KPeople;
 
-
 class KTpAllContacts : public AllContactsMonitor
 {
     Q_OBJECT
 public:
     KTpAllContacts();
     ~KTpAllContacts();
-    virtual KContacts::Addressee::Map contacts();
+    virtual QMap<QString, AbstractContact::Ptr> contacts() Q_DECL_OVERRIDE;
 
 private Q_SLOTS:
     void loadCache();
@@ -62,34 +60,75 @@ private Q_SLOTS:
 
 private:
     QString createUri(const KTp::ContactPtr &contact) const;
-    KContacts::Addressee contactToAddressee(const Tp::ContactPtr &contact) const;
 
     //presence names indexed by ConnectionPresenceType
-    QVector<QString> m_presenceStrings;
     QHash<QString, KTp::ContactPtr> m_contacts;
-    KContacts::Addressee::Map m_contactVCards;
+    QMap<QString, AbstractContact::Ptr> m_contactVCards;
+};
+
+static const QString S_KPEOPLE_PROPERTY_ACCOUNT_PATH = QString::fromLatin1("telepathy-accountPath");
+static const QString S_KPEOPLE_PROPERTY_CONTACT_ID = QString::fromLatin1("telepathy-contactId");
+static const QString S_KPEOPLE_PROPERTY_PRESENCE = QString::fromLatin1("telepathy-presence");
+const QHash<Tp::ConnectionPresenceType, QString> s_presenceStrings = {
+        { Tp::ConnectionPresenceTypeUnset, QString() },
+        { Tp::ConnectionPresenceTypeOffline, QString::fromLatin1("offline") },
+        { Tp::ConnectionPresenceTypeAvailable, QString::fromLatin1("available") },
+        { Tp::ConnectionPresenceTypeAway, QString::fromLatin1("away") },
+        { Tp::ConnectionPresenceTypeExtendedAway, QString::fromLatin1("xa") },
+        { Tp::ConnectionPresenceTypeHidden, QString::fromLatin1("hidden") }, //of 'offline' ?
+        { Tp::ConnectionPresenceTypeBusy, QString::fromLatin1("busy") },
+        { Tp::ConnectionPresenceTypeUnknown, QString() },
+        { Tp::ConnectionPresenceTypeError, QString() }
 };
 
-static const QString S_KABC_PRODUCT = QString::fromLatin1("telepathy");
-static const QString S_KABC_FIELD_ACCOUNT_PATH = QString::fromLatin1("accountPath");
-static const QString S_KABC_FIELD_CONTACT_ID = QString::fromLatin1("contactId");
-static const QString S_KABC_FIELD_PRESENCE = QString::fromLatin1("presence");
+class TelepathyContact : public KPeople::AbstractContact
+{
+public:
+    virtual QVariant customProperty(const QString &key) const Q_DECL_OVERRIDE
+    {
+        if (m_contact && m_account) {
+            if (key == AbstractContact::NameProperty)
+                return m_contact->alias();
+            else if(key == AbstractContact::GroupsProperty)
+                return m_contact->groups();
+            else if(key == S_KPEOPLE_PROPERTY_CONTACT_ID)
+                return m_contact->id();
+            else if(key == S_KPEOPLE_PROPERTY_ACCOUNT_PATH)
+                return m_account->objectPath();
+            else if(key == S_KPEOPLE_PROPERTY_PRESENCE)
+                return s_presenceStrings.value(m_contact->presence().type());
+            else if (key == AbstractContact::PictureProperty && !m_contact->avatarData().fileName.isEmpty()) {
+                return QUrl::fromLocalFile(m_contact->avatarData().fileName);
+            }
+        }
+        return m_properties[key];
+    }
+
+    void insertProperty(const QString &key, const QVariant &value)
+    {
+        m_properties[key] = value;
+    }
+
+    void setContact(const Tp::ContactPtr &contact)
+    {
+        m_contact = contact;
+    }
+
+    void setAccount(const Tp::AccountPtr &account)
+    {
+        m_account = account;
+    }
+
+private:
+    Tp::ContactPtr m_contact;
+    Tp::AccountPtr m_account;
+    QVariantMap m_properties;
+};
 
 KTpAllContacts::KTpAllContacts()
 {
     Tp::registerTypes();
 
-    m_presenceStrings.reserve(9);
-    m_presenceStrings.insert(Tp::ConnectionPresenceTypeUnset, QString());
-    m_presenceStrings.insert(Tp::ConnectionPresenceTypeOffline, QString::fromLatin1("offline"));
-    m_presenceStrings.insert(Tp::ConnectionPresenceTypeAvailable, QString::fromLatin1("available"));
-    m_presenceStrings.insert(Tp::ConnectionPresenceTypeAway, QString::fromLatin1("away"));
-    m_presenceStrings.insert(Tp::ConnectionPresenceTypeExtendedAway, QString::fromLatin1("xa"));
-    m_presenceStrings.insert(Tp::ConnectionPresenceTypeHidden, QString::fromLatin1("hidden")); //of 'offline' ?
-    m_presenceStrings.insert(Tp::ConnectionPresenceTypeBusy, QString::fromLatin1("busy"));
-    m_presenceStrings.insert(Tp::ConnectionPresenceTypeUnknown, QString());
-    m_presenceStrings.insert(Tp::ConnectionPresenceTypeError, QString());
-
     loadCache();
 }
 
@@ -122,15 +161,15 @@ void KTpAllContacts::loadCache()
     }
 
     while (query.next()) {
-        KContacts::Addressee addressee;
+        QExplicitlySharedDataPointer<TelepathyContact> addressee(new TelepathyContact);
 
         const QString accountId =  query.value(0).toString();
         const QString contactId =  query.value(1).toString();
-        addressee.setFormattedName(query.value(2).toString());
-        addressee.setPhoto(KContacts::Picture(query.value(3).toString()));
+        addressee->insertProperty(AbstractContact::NameProperty, query.value(2).toString());
+        addressee->insertProperty(AbstractContact::PictureProperty, QUrl::fromLocalFile(query.value(3).toString()));
 
         if (!groupsList.isEmpty()) {
-            QStringList contactGroups;
+            QVariantList contactGroups;
 
             Q_FOREACH (const QString &groupIdStr, query.value(4).toString().split(QLatin1String(","))) {
                 bool convSuccess;
@@ -141,12 +180,12 @@ void KTpAllContacts::loadCache()
                 contactGroups.append(groupsList.at(groupId));
             }
 
-            addressee.setCategories(contactGroups);
+            addressee->insertProperty(QStringLiteral("groups"), contactGroups);
         }
 
-        addressee.insertCustom(S_KABC_PRODUCT, S_KABC_FIELD_CONTACT_ID, contactId);
-        addressee.insertCustom(S_KABC_PRODUCT, S_KABC_FIELD_ACCOUNT_PATH, TP_QT_ACCOUNT_OBJECT_PATH_BASE + QLatin1Char('/') + accountId);
-        addressee.insertCustom(S_KABC_PRODUCT, S_KABC_FIELD_PRESENCE, m_presenceStrings.at(Tp::ConnectionPresenceTypeOffline));
+        addressee->insertProperty(S_KPEOPLE_PROPERTY_CONTACT_ID, contactId);
+        addressee->insertProperty(S_KPEOPLE_PROPERTY_ACCOUNT_PATH, TP_QT_ACCOUNT_OBJECT_PATH_BASE + QLatin1Char('/') + accountId);
+        addressee->insertProperty(S_KPEOPLE_PROPERTY_PRESENCE, s_presenceStrings[Tp::ConnectionPresenceTypeOffline]);
 
         const QString uri = QLatin1String("ktp://") + accountId + QLatin1Char('?') + contactId;
 
@@ -202,18 +241,22 @@ void KTpAllContacts::onAllKnownContactsChanged(const Tp::Contacts &contactsAdded
         KTp::ContactPtr ktpContact = KTp::ContactPtr::qObjectCast(contact);
         const QString uri = createUri(ktpContact);
 
-        const KContacts::Addressee vcard = contactToAddressee(contact);
+        AbstractContact::Ptr vcard = m_contactVCards.value(uri);
+        bool added = false;
+        if (!vcard) {
+            vcard = AbstractContact::Ptr(new TelepathyContact);
+            m_contactVCards[uri] = vcard;
+            added = true;
+        }
+        static_cast<TelepathyContact*>(vcard.data())->setContact(ktpContact);
+        static_cast<TelepathyContact*>(vcard.data())->setAccount(KTp::contactManager()->accountForContact(ktpContact));
 
         m_contacts.insert(uri, ktpContact);
 
-        //TODO OPTIMISATION if we already exist we shouldn't create a whole new KABC object, just update the existing one
-        //onContactChanged should be split into the relevant onAliasChanged etc.
-        if (m_contactVCards.contains(uri)) {
-            m_contactVCards[uri] = vcard;
-            Q_EMIT contactChanged(uri, vcard);
-        } else {
-            m_contactVCards.insert(uri, vcard);
+        if (added) {
             Q_EMIT contactAdded(uri, vcard);
+        } else {
+            Q_EMIT contactChanged(uri, vcard);
         }
 
         connect(ktpContact.data(), SIGNAL(presenceChanged(Tp::Presence)),
@@ -239,8 +282,8 @@ void KTpAllContacts::onAllKnownContactsChanged(const Tp::Contacts &contactsAdded
 void KTpAllContacts::onContactChanged()
 {
     const KTp::ContactPtr contact(qobject_cast<KTp::Contact*>(sender()));
-    m_contactVCards.insert(createUri(contact), contactToAddressee(contact));
-    Q_EMIT contactChanged(createUri(contact), contactToAddressee(contact));
+    const QString uri = createUri(contact);
+    Q_EMIT contactChanged(uri, m_contactVCards.value(uri));
 }
 
 void KTpAllContacts::onContactInvalidated()
@@ -251,34 +294,17 @@ void KTpAllContacts::onContactInvalidated()
     m_contacts.remove(uri);
 
     //set to offline and emit changed
-    KContacts::Addressee &vcard = m_contactVCards[uri];
-    vcard.insertCustom(S_KABC_PRODUCT, S_KABC_FIELD_PRESENCE, QLatin1String("offline"));
+    AbstractContact::Ptr vcard = m_contactVCards[uri];
+    TelepathyContact *tpContact = static_cast<TelepathyContact*>(vcard.data());
+    tpContact->insertProperty(S_KPEOPLE_PROPERTY_PRESENCE, QStringLiteral("offline"));
     Q_EMIT contactChanged(uri, vcard);
 }
 
-KContacts::Addressee::Map KTpAllContacts::contacts()
+QMap<QString, AbstractContact::Ptr> KTpAllContacts::contacts()
 {
     return m_contactVCards;
 }
 
-KContacts::Addressee KTpAllContacts::contactToAddressee(const Tp::ContactPtr &contact) const
-{
-    KContacts::Addressee vcard;
-    Tp::AccountPtr account = KTp::contactManager()->accountForContact(contact);
-    if (contact && account) {
-        vcard.setFormattedName(contact->alias());
-        vcard.setCategories(contact->groups());
-
-        vcard.insertCustom(S_KABC_PRODUCT, S_KABC_FIELD_CONTACT_ID, contact->id());
-        vcard.insertCustom(S_KABC_PRODUCT, S_KABC_FIELD_ACCOUNT_PATH, account->objectPath());
-        vcard.insertCustom(S_KABC_PRODUCT, S_KABC_FIELD_PRESENCE, m_presenceStrings.at(contact->presence().type()));
-        if (!contact->avatarData().fileName.isEmpty()) {
-            vcard.setPhoto(KContacts::Picture(contact->avatarData().fileName));
-        }
-    }
-    return vcard;
-}
-
 IMPersonsDataSource::IMPersonsDataSource(QObject *parent, const QVariantList &args)
     : BasePersonsDataSource(parent)
 {
@@ -291,7 +317,7 @@ IMPersonsDataSource::~IMPersonsDataSource()
 
 QString IMPersonsDataSource::sourcePluginId() const
 {
-    return QLatin1String("ktp");
+    return QStringLiteral("ktp");
 }
 
 AllContactsMonitor* IMPersonsDataSource::createAllContactsMonitor()
diff --git a/kpeople/uiplugins/CMakeLists.txt b/kpeople/uiplugins/CMakeLists.txt
index e9289d7..220cdf3 100644
--- a/kpeople/uiplugins/CMakeLists.txt
+++ b/kpeople/uiplugins/CMakeLists.txt
@@ -4,6 +4,7 @@ add_library(imdetailswidgetplugin MODULE imdetailswidget.cpp)
 target_link_libraries(imdetailswidgetplugin Qt5::Core
     Qt5::Gui
     KF5::PeopleWidgets
+    KF5::CoreAddons
     KF5::I18n
     KTp::CommonInternals
 )
diff --git a/kpeople/uiplugins/chatplugin/CMakeLists.txt b/kpeople/uiplugins/chatplugin/CMakeLists.txt
index ece13d8..dc9a7f7 100644
--- a/kpeople/uiplugins/chatplugin/CMakeLists.txt
+++ b/kpeople/uiplugins/chatplugin/CMakeLists.txt
@@ -1,6 +1,7 @@
 add_library(kpeople_chat_plugin MODULE chatlistviewdelegate.cpp kpeople_chat_plugin.cpp)
 target_link_libraries(kpeople_chat_plugin ${QT_QTCORE_LIBRARY}
     KF5::PeopleWidgets
+    KF5::CoreAddons
     KF5::I18n
     KTp::Logger
     KTp::CommonInternals
diff --git a/kpeople/uiplugins/chatplugin/kpeople_chat_plugin.cpp b/kpeople/uiplugins/chatplugin/kpeople_chat_plugin.cpp
index 8b91f0f..93cd641 100644
--- a/kpeople/uiplugins/chatplugin/kpeople_chat_plugin.cpp
+++ b/kpeople/uiplugins/chatplugin/kpeople_chat_plugin.cpp
@@ -26,9 +26,9 @@
 #include <QVBoxLayout>
 #include <QScrollArea>
 #include <KLocalizedString>
-#include <KContacts/Addressee>
 #include <KPluginFactory>
 #include <KLocalizedString>
+#include <KPeople/PersonData>
 
 #include <KTp/core.h>
 #include <KTp/Logger/log-manager.h>
@@ -51,9 +51,8 @@ ChatWidgetFactory::ChatWidgetFactory(QObject *parent, const QVariantList &args):
     m_model = new QStandardItemModel();
 }
 
-QWidget *ChatWidgetFactory::createDetailsWidget(const KContacts::Addressee &person, const KContacts::Addressee::List &contacts, QWidget *parent) const
+QWidget *ChatWidgetFactory::createDetailsWidget(const KPeople::PersonData &person, QWidget *parent) const
 {
-    Q_UNUSED(contacts);
     QWidget *widget = new QWidget(parent);
 
     QScrollArea *scrollArea = new QScrollArea();
@@ -70,19 +69,20 @@ QWidget *ChatWidgetFactory::createDetailsWidget(const KContacts::Addressee &pers
     chatlistView->setModel(m_model);
     layout->setContentsMargins(0, 0, 0, 0);
 
-    if (person.custom(QLatin1String("telepathy"), QLatin1String("accountPath")).isEmpty()) {
-        layout->addWidget(new QLabel(QLatin1String("Chat for current contact is not supported")));
+    QString accountPath = person.contactCustomProperty(QStringLiteral("telepathy-accountPath")).toString();
+    if (accountPath.isNull()) {
+        layout->addWidget(new QLabel(i18n("Chat for current contact is not supported")));
     } else {
         KTp::LogManager *logManager = KTp::LogManager::instance();
         logManager->setAccountManager(KTp::accountManager());
-        KTp::LogEntity logEntity(Tp::HandleTypeContact, person.custom(QLatin1String("telepathy"), QLatin1String("contactId")));
+        KTp::LogEntity logEntity(Tp::HandleTypeContact, person.contactCustomProperty(QStringLiteral("telepathy-contactId")).toString());
 
         Tp::AccountPtr account;
 
-        if (person.custom(QLatin1String("telepathy"), QLatin1String("accountPath")).contains(QLatin1String(TP_ACCOUNT_OBJECT_PATH_BASE))) {
-            account = KTp::accountManager().data()->accountForObjectPath(person.custom(QLatin1String("telepathy"), QLatin1String("accountPath")));
+        if (accountPath.contains(QLatin1String(TP_ACCOUNT_OBJECT_PATH_BASE))) {
+            account = KTp::accountManager().data()->accountForObjectPath(accountPath);
         } else {
-            account = KTp::accountManager().data()->accountForObjectPath(QLatin1String(TP_ACCOUNT_OBJECT_PATH_BASE) + person.custom(QLatin1String("telepathy"), QLatin1String("accountPath")));
+            account = KTp::accountManager().data()->accountForObjectPath(QLatin1String(TP_ACCOUNT_OBJECT_PATH_BASE) + accountPath);
         }
 
         if (account.isNull()) {
diff --git a/kpeople/uiplugins/chatplugin/kpeople_chat_plugin.h b/kpeople/uiplugins/chatplugin/kpeople_chat_plugin.h
index d1d76e2..b24238a 100644
--- a/kpeople/uiplugins/chatplugin/kpeople_chat_plugin.h
+++ b/kpeople/uiplugins/chatplugin/kpeople_chat_plugin.h
@@ -34,7 +34,7 @@ public:
     explicit ChatWidgetFactory(QObject *parent, const QVariantList &args);
     virtual QString label() const;
     virtual int sortWeight() const;
-    virtual QWidget *createDetailsWidget(const KContacts::Addressee &person, const KContacts::Addressee::List &contacts, QWidget *parent) const;
+    virtual QWidget* createDetailsWidget(const KPeople::PersonData &person, QWidget *parent) const Q_DECL_OVERRIDE;
 
 private Q_SLOTS:
     void onPendingDates(KTp::PendingLoggerOperation *);
diff --git a/kpeople/uiplugins/imdetailswidget.cpp b/kpeople/uiplugins/imdetailswidget.cpp
index d33e99a..476cd1d 100644
--- a/kpeople/uiplugins/imdetailswidget.cpp
+++ b/kpeople/uiplugins/imdetailswidget.cpp
@@ -26,7 +26,6 @@
 
 #include <KLocalizedString>
 #include <KPluginFactory>
-#include <KContacts/Addressee>
 
 #include <KPeople/PersonData>
 #include <TelepathyQt/AccountManager>
@@ -48,17 +47,17 @@ QString ImDetailsWidget::label() const
     return i18n("IM");
 }
 
-QWidget* ImDetailsWidget::createDetailsWidget(const KContacts::Addressee& person, const KContacts::Addressee::List &contacts, QWidget* parent) const
+QWidget* ImDetailsWidget::createDetailsWidget(const KPeople::PersonData &person, QWidget *parent) const
 {
-    Q_UNUSED(person);
     QWidget *root = new QWidget(parent);
     QGridLayout *layout = new QGridLayout(root);
     root->setLayout(layout);
 
     int row = 0;
-    Q_FOREACH(const KContacts::Addressee &contact, contacts) {
-        const QString contactId = contact.custom(QLatin1String("telepathy"), QLatin1String("contactId"));
-        const QString accountPath = contact.custom(QLatin1String("telepathy"), QLatin1String("accountPath")); //probably unused till we fix everything properly
+    for(const QString &contactId: person.contactIds()) {
+        PersonData contact(contactId);
+        const QString tpcontactId = contact.contactCustomProperty(QStringLiteral("telepathy-contactId")).toString();
+        const QString accountPath = contact.contactCustomProperty(QStringLiteral("telepathy-accountPath")).toString(); //probably unused till we fix everything properly
 
         Tp::AccountPtr account = KTp::accountManager()->accountForObjectPath(accountPath);
         if (!account) {
@@ -70,10 +69,10 @@ QWidget* ImDetailsWidget::createDetailsWidget(const KContacts::Addressee& person
         iconLabel->setPixmap(QIcon::fromTheme(account->iconName()).pixmap(iconSize, iconSize));
         layout->addWidget(iconLabel, row, 0);
 
-        QLabel *label = new QLabel(contactId, root);
+        QLabel *label = new QLabel(tpcontactId, root);
         label->setTextInteractionFlags(Qt::TextSelectableByMouse);
         layout->addWidget(label, row, 1);
-        qDebug() << contactId;
+
         row++;
         //FUTURE - presence here + blocked + presence subscription
     }
diff --git a/kpeople/uiplugins/imdetailswidget.h b/kpeople/uiplugins/imdetailswidget.h
index f8d4304..a2ff16d 100644
--- a/kpeople/uiplugins/imdetailswidget.h
+++ b/kpeople/uiplugins/imdetailswidget.h
@@ -31,7 +31,7 @@ class ImDetailsWidget : public KPeople::AbstractFieldWidgetFactory
 public:
     explicit ImDetailsWidget(QObject *parent, const QVariantList &args);
     QString label() const;
-    virtual QWidget* createDetailsWidget(const KContacts::Addressee& person, const KContacts::Addressee::List &contacts, QWidget* parent) const;
+    virtual QWidget* createDetailsWidget(const KPeople::PersonData &person, QWidget *parent) const;
 };
 
 #endif // IM_DETAILS_WIDGET_H
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index ed01b3f..47819c4 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -38,6 +38,7 @@ if (KF5People_FOUND)
 
     KF5::I18n
     KF5::People
+    KF5::CoreAddons
     KTp::CommonInternals
     KTp::Models
     )

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list