[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:06:54 UTC 2016


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

The following commit has been merged in the master branch:
commit 10271d5d00707238f82d38716c7497a08a953a99
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Wed Jun 26 14:52:27 2013 +0100

    Import the KPeople KTP integration plugins
    
    There are two plugins, one for the datasource which provides
    IM data in real time.
    
    The other is an actions plugin which provides actions that can be started on a PersonsData.
    
    REVIEW: 111256
---
 CMakeLists.txt                                     |   9 +-
 KTp/CMakeLists.txt                                 |  26 ++-
 KTp/Models/CMakeLists.txt                          |   5 +-
 KTp/im-persons-data-source.cpp                     | 252 +++++++++++++++++++++
 KTp/im-persons-data-source.h                       |  59 +++++
 kpeople/actionsplugin/CMakeLists.txt               |  25 ++
 kpeople/actionsplugin/kpeople-actions-plugin.cpp   | 200 ++++++++++++++++
 kpeople/actionsplugin/kpeople-actions-plugin.h     |  37 +++
 kpeople/actionsplugin/ktp_kpeople_plugin.desktop   |  21 ++
 kpeople/datasourceplugin/CMakeLists.txt            |  31 +++
 .../im-persons-data-source-plugin.cpp              |   9 +
 .../im_persons_data_source_plugin.desktop          |  20 ++
 12 files changed, 682 insertions(+), 12 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f6c3a9e..b2d0dc2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,9 +27,6 @@ include (MacroLibrary)
 macro_log_feature(KPEOPLE_FOUND "KPeople" "Support for KDE Contact Aggregation" "https://projects.kde.org/libkpeople" FALSE "" "")
 macro_display_feature_log()
 
-if (KPEOPLE_FOUND)
-    add_definitions(-DHAVE_KPEOPLE)
-endif (KPEOPLE_FOUND)
 
 add_definitions (${KDE4_DEFINITIONS}
                  ${TELEPATHY_LOGGER_QT4_DEFINITIONS}
@@ -44,6 +41,12 @@ include_directories (${KDE4_INCLUDES}
                      ${TELEPATHY_LOGGER_QT4_INCLUDE_DIRS}
 )
 
+if (KPEOPLE_FOUND)
+    add_definitions(-DHAVE_KPEOPLE)
+    add_subdirectory(kpeople)
+endif (KPEOPLE_FOUND)
+
+
 configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h @ONLY)
 
 set(KTP_GLOBAL_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/global.cpp)
diff --git a/KTp/CMakeLists.txt b/KTp/CMakeLists.txt
index 6b3de56..fa8223a 100644
--- a/KTp/CMakeLists.txt
+++ b/KTp/CMakeLists.txt
@@ -62,6 +62,26 @@ set (ktp_common_internals_private_HDRS
      ktp-export.h
 )
 
+set (ktp_private_LIBS
+                       ${KDE4_KDECORE_LIBS}
+                       ${KDE4_KIO_LIBS}
+                       ${TELEPATHY_QT4_LIBRARIES}
+                       ${TELEPATHY_LOGGER_QT4_LIBRARIES}
+                       ${KDE4_KDEUI_LIBS}
+)
+
+if (KPEOPLE_FOUND)
+        set (ktp_models_private_SRCS
+         ${ktp_models_private_SRCS}
+         im-persons-data-source.cpp
+         )
+
+    set (ktp_private_LIBS
+         ${ktp_private_LIBS}
+         kpeople
+         )
+endif(KPEOPLE_FOUND)
+
 kde4_add_library (ktpcommoninternalsprivate SHARED
                  ${ktp_common_internals_private_SRCS}
 )
@@ -73,11 +93,7 @@ set_target_properties(ktpcommoninternalsprivate PROPERTIES
                                                          DEFINE_SYMBOL MAKE_KTP_LIB)
 
 target_link_libraries (ktpcommoninternalsprivate
-                       ${KDE4_KDECORE_LIBS}
-                       ${KDE4_KIO_LIBS}
-                       ${TELEPATHY_QT4_LIBRARIES}
-                       ${TELEPATHY_LOGGER_QT4_LIBRARIES}
-                       ${KDE4_KDEUI_LIBS}
+                      ${ktp_private_LIBS}
 )
 
 install (TARGETS ktpcommoninternalsprivate
diff --git a/KTp/Models/CMakeLists.txt b/KTp/Models/CMakeLists.txt
index 263c630..bcb3af4 100644
--- a/KTp/Models/CMakeLists.txt
+++ b/KTp/Models/CMakeLists.txt
@@ -1,11 +1,7 @@
-
 include_directories (${CMAKE_CURRENT_BINARY_DIR}
                      ${CMAKE_CURRENT_SOURCE_DIR}
 )
 
-
-
-
 set (ktp_models_private_SRCS
     ${KTP_GLOBAL_SOURCES}
     abstract-grouping-proxy-model.cpp
@@ -40,6 +36,7 @@ set (ktp_models_private_LIBS
 
 if (KPEOPLE_FOUND)
     add_definitions(-DHAVE_KPEOPLE)
+
     set (ktp_models_private_SRCS
          ${ktp_models_private_SRCS}
          kpeopletranslationproxy.cpp
diff --git a/KTp/im-persons-data-source.cpp b/KTp/im-persons-data-source.cpp
new file mode 100644
index 0000000..9d30d4e
--- /dev/null
+++ b/KTp/im-persons-data-source.cpp
@@ -0,0 +1,252 @@
+/*
+    Copyright (C) 2013  Martin Klapetek <mklapetek at kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+
+#include "impersonsdatasource.h"
+
+#include <KPeople/PersonsModel>
+
+#include <TelepathyQt/AccountManager>
+#include <TelepathyQt/AccountFactory>
+#include <TelepathyQt/ContactManager>
+#include <TelepathyQt/PendingOperation>
+#include <TelepathyQt/PendingReady>
+#include <TelepathyQt/Presence>
+
+#include "KTp/contact-factory.h"
+#include "KTp/global-contact-manager.h"
+#include "KTp/types.h"
+
+#include <KDebug>
+
+#include <Soprano/Model>
+#include <Soprano/QueryResultIterator>
+#include <Nepomuk2/ResourceManager>
+
+using namespace KPeople;
+
+class IMPersonsDataSource::Private {
+public:
+    KTp::GlobalContactManager *contactManager;
+    Tp::AccountManagerPtr accountManager;
+    QHash<QString, KTp::ContactPtr> contacts;
+    IMPersonsDataSource *q;
+
+    void onAllKnownContactsChanged(const Tp::Contacts &contactsAdded, const Tp::Contacts &contactsRemoved);
+};
+
+void IMPersonsDataSource::Private::onAllKnownContactsChanged(const Tp::Contacts &contactsAdded, const Tp::Contacts &contactsRemoved)
+{
+    if (!contacts.isEmpty()) {
+        Q_FOREACH (const Tp::ContactPtr &contact, contactsRemoved) {
+            contacts.remove(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());
+
+        connect(ktpContact.data(), SIGNAL(presenceChanged(Tp::Presence)),
+                q, SLOT(onContactChanged()));
+
+        connect(ktpContact.data(), SIGNAL(capabilitiesChanged(Tp::ContactCapabilities)),
+                q, SLOT(onContactChanged()));
+
+        connect(ktpContact.data(), SIGNAL(invalidated()),
+                q, SLOT(onContactInvalidated()));
+
+        //TODO: add other stuff here etc
+
+    }
+}
+
+//-----------------------------------------------------------------------------
+
+IMPersonsDataSource::IMPersonsDataSource(QObject *parent, const QVariantList &data)
+    : BasePersonsDataSource(parent)
+    , d(new Private)
+{
+    d->q = this;
+    Tp::registerTypes();
+    Tp::AccountFactoryPtr  accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus(),
+                                                                       Tp::Features() << Tp::Account::FeatureCore
+                                                                       << Tp::Account::FeatureCapabilities
+                                                                       << Tp::Account::FeatureProtocolInfo
+                                                                       << Tp::Account::FeatureProfile);
+
+    Tp::ConnectionFactoryPtr connectionFactory = Tp::ConnectionFactory::create(QDBusConnection::sessionBus(),
+                                                                               Tp::Features() << Tp::Connection::FeatureCore
+                                                                               << Tp::Connection::FeatureRoster
+                                                                               << Tp::Connection::FeatureRosterGroups
+                                                                               << Tp::Connection::FeatureSelfContact);
+
+    Tp::ContactFactoryPtr contactFactory = KTp::ContactFactory::create(Tp::Features()  << Tp::Contact::FeatureAlias
+    << Tp::Contact::FeatureSimplePresence
+    << Tp::Contact::FeatureCapabilities
+    << Tp::Contact::FeatureClientTypes);
+
+    Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
+
+    d->accountManager = Tp::AccountManager::create(QDBusConnection::sessionBus(),
+                                                   accountFactory,
+                                                   connectionFactory,
+                                                   channelFactory,
+                                                   contactFactory);
+
+    connect(d->accountManager->becomeReady(), SIGNAL(finished(Tp::PendingOperation*)),
+            this, SLOT(onAccountManagerReady(Tp::PendingOperation*)));
+}
+
+IMPersonsDataSource::~IMPersonsDataSource()
+{
+    delete d;
+}
+
+QVariant IMPersonsDataSource::dataForContact(const QString &contactId, int role) const
+{
+    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();
+            }
+    }
+
+    return QVariant();
+}
+
+void IMPersonsDataSource::onAccountManagerReady(Tp::PendingOperation *op)
+{
+    if (op->isError()) {
+        kWarning() << "Failed to initialize AccountManager:" << op->errorName();
+        kWarning() << op->errorMessage();
+
+        return;
+    }
+
+    kDebug() << "Account manager ready";
+
+    d->contactManager = new KTp::GlobalContactManager(d->accountManager, this);
+    connect(d->contactManager, SIGNAL(allKnownContactsChanged(Tp::Contacts,Tp::Contacts)),
+            this, SLOT(onAllKnownContactsChanged(Tp::Contacts,Tp::Contacts)));
+
+    d->onAllKnownContactsChanged(d->contactManager->allKnownContacts(), Tp::Contacts());
+}
+
+void IMPersonsDataSource::onContactChanged()
+{
+    QString id = qobject_cast<Tp::Contact*>(sender())->id();
+
+    Q_EMIT contactChanged(id);
+}
+
+void IMPersonsDataSource::onContactInvalidated()
+{
+    QString id = qobject_cast<Tp::Contact*>(sender())->id();
+
+    d->contacts.remove(id);
+
+    Q_EMIT contactChanged(id);
+}
+
+KTp::ContactPtr IMPersonsDataSource::contactForContactId(const QString &contactId) const
+{
+    return d->contacts.value(contactId);
+}
+
+Tp::AccountPtr IMPersonsDataSource::accountForContact(const KTp::ContactPtr &contact) const
+{
+    return d->contactManager->accountForContact(contact);
+}
+
+Tp::AccountPtr IMPersonsDataSource::accountForContactId(const QString &contactId) const
+{
+    if (contactId.isEmpty()) {
+        kDebug() << "empty contact id";
+    }
+
+    KTp::ContactPtr contact = contactForContactId(contactId);
+    if (contact.isNull()) {
+        QString query = QString::fromUtf8(
+            "select DISTINCT ?a "
+            "WHERE { "
+                "?x a nco:ContactMedium . "
+                "?x nco:imID \"%1\"^^xsd:string . "
+                "?x nco:isAccessedBy ?c . "
+                "?c telepathy:accountIdentifier ?a . "
+                "}").arg(contactId);
+
+                kDebug() << query;
+
+        Soprano::Model *model = Nepomuk2::ResourceManager::instance()->mainModel();
+        Soprano::QueryResultIterator it = model->executeQuery(query, Soprano::Query::QueryLanguageSparql);
+
+        QString accountPath;
+
+        it.next(); //set the iterator to first entry
+        accountPath = it[0].literal().toString();
+        kDebug() << "got account path" << accountPath;
+        //nepomuk stores account path, which is in form /org/freedesktop/Telepathy/Account/...
+        //while GCM looks for uniqueIdentifier(), which is without this^ prefix, so we need to chop it off first
+        return d->contactManager->accountForAccountId(accountPath.remove(0,35));
+    } else {
+        return accountForContact(contact);
+    }
+}
+
+Tp::AccountManagerPtr IMPersonsDataSource::accountManager() const
+{
+    return d->accountManager;
+}
+
diff --git a/KTp/im-persons-data-source.h b/KTp/im-persons-data-source.h
new file mode 100644
index 0000000..dda7701
--- /dev/null
+++ b/KTp/im-persons-data-source.h
@@ -0,0 +1,59 @@
+/*
+    Copyright (C) 2013  Martin Klapetek <mklapetek at kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+
+#ifndef IM_PERSONS_DATA_SOURCE_H
+#define IM_PERSONS_DATA_SOURCE_H
+
+#include <KPeople/BasePersonsDataSource>
+
+#include <TelepathyQt/Types>
+
+#include "KTp/contact.h"
+#include "KTp/ktp-export.h"
+
+namespace KTp { class GlobalContactManager; }
+namespace Tp { class PendingOperation; }
+
+class KTP_EXPORT IMPersonsDataSource : public KPeople::BasePersonsDataSource
+{
+    Q_OBJECT
+public:
+    IMPersonsDataSource(QObject *parent, const QVariantList &data);
+    virtual ~IMPersonsDataSource();
+
+    QVariant dataForContact(const QString &contactId, int role) const;
+    KTp::ContactPtr contactForContactId(const QString &contactId) const;
+    Tp::AccountPtr accountForContact(const KTp::ContactPtr &contact) const;
+    Tp::AccountPtr accountForContactId(const QString &contactId) const;
+
+    Tp::AccountManagerPtr accountManager() const;
+
+private Q_SLOTS:
+    void onAccountManagerReady(Tp::PendingOperation *op);
+    void onContactChanged();
+    void onContactInvalidated();
+
+private:
+    Q_PRIVATE_SLOT(d, void onAllKnownContactsChanged(const Tp::Contacts &contactsAdded, const Tp::Contacts &contactsRemoved) )
+
+    class Private;
+    Private* d;
+};
+
+#endif // IM_PERSONS_DATA_SOURCE_H
diff --git a/kpeople/actionsplugin/CMakeLists.txt b/kpeople/actionsplugin/CMakeLists.txt
new file mode 100644
index 0000000..f5203d5
--- /dev/null
+++ b/kpeople/actionsplugin/CMakeLists.txt
@@ -0,0 +1,25 @@
+set (ktp_kpeople_plugin_SRCS
+     kpeople-actions-plugin.cpp
+)
+
+kde4_add_plugin (ktp_kpeople_plugin
+                 ${ktp_kpeople_plugin_SRCS}
+)
+
+target_link_libraries (ktp_kpeople_plugin
+    ${QT_LIBRARIES}
+    ${TELEPATHY_QT4_LIBRARIES}
+    ${KDE4_KDEUI_LIBS}
+    ${NEPOMUK_CORE_LIBRARY}
+    ${KPEOPLE_LIBS}
+    ktpcommoninternalsprivate
+)
+
+# Install:
+install (TARGETS ktp_kpeople_plugin
+         DESTINATION ${PLUGIN_INSTALL_DIR}
+)
+
+install (FILES ktp_kpeople_plugin.desktop
+         DESTINATION ${SERVICES_INSTALL_DIR}
+)
diff --git a/kpeople/actionsplugin/kpeople-actions-plugin.cpp b/kpeople/actionsplugin/kpeople-actions-plugin.cpp
new file mode 100644
index 0000000..9bbaa9e
--- /dev/null
+++ b/kpeople/actionsplugin/kpeople-actions-plugin.cpp
@@ -0,0 +1,200 @@
+/*
+    Copyright (C) 2013  David Edmundson <davidedmundson at kde.org>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+#include "kpeople-actions-plugin.h"
+
+#include <QAction>
+
+#include <KIcon>
+#include <KLocalizedString>
+#include <KPluginFactory>
+#include <kdemacros.h>
+
+#include "KTp/contact.h"
+#include "KTp/actions.h"
+#include "KTp/im-persons-data-source.h"
+
+#include <TelepathyQt/Account>
+#include <TelepathyQt/ContactManager>
+
+
+#include <kpeople/personpluginmanager.h>
+#include <KPeople/PersonData>
+
+enum IMActionType {
+    TextChannel,
+    AudioChannel,
+    VideoChannel,
+    FileTransfer,
+    LogViewer
+};
+
+class IMAction : public QAction {
+    Q_OBJECT
+public:
+    IMAction(const QString &text, const KIcon &icon, const KTp::ContactPtr &contact,
+             const Tp::AccountPtr &account, IMActionType type, QObject *parent);
+    KTp::ContactPtr contact() const;
+    Tp::AccountPtr account() const;
+    IMActionType type() const;
+private:
+    KTp::ContactPtr m_contact;
+    Tp::AccountPtr m_account;
+    IMActionType m_type;
+};
+
+IMAction::IMAction(const QString &text, const KIcon &icon, const KTp::ContactPtr &contact,
+                   const Tp::AccountPtr &account, IMActionType type, QObject *parent):
+    QAction(icon, text, parent),
+    m_contact(contact),
+    m_account(account),
+    m_type(type)
+{
+}
+
+KTp::ContactPtr IMAction::contact() const
+{
+    return m_contact;
+}
+
+Tp::AccountPtr IMAction::account() const
+{
+    return m_account;
+}
+
+
+IMActionType IMAction::type() const
+{
+    return m_type;
+}
+
+KPeopleActionsPlugin::KPeopleActionsPlugin(QObject* parent, const QVariantList &args):
+AbstractPersonPlugin(parent)
+{
+}
+
+QList<QAction*> KPeopleActionsPlugin::actionsForPerson(KPeople::PersonData *personData, QObject *parent)
+{
+    QList<QAction*> actions;
+
+    IMPersonsDataSource *dataSource = dynamic_cast<IMPersonsDataSource*>(KPeople::PersonPluginManager::presencePlugin());
+    if (!dataSource) {
+        return actions;
+    }
+
+    QStringList imContactsIds = personData->imAccounts();
+
+    for (int i=0;i<imContactsIds.size();i+=3) { //FIXME imAccounts() returns a silly datatype
+        const QString contactId = imContactsIds[i+2];
+        const KTp::ContactPtr contact = dataSource->contactForContactId(contactId);
+        if (!contact || !contact->manager()) {
+            continue;
+        }
+        const Tp::AccountPtr account = dataSource->accountForContact(contact);
+
+        if (!account) {
+            continue;
+        }
+
+        if (true) { //no such query for text chat capability, added an "if true" because makes the code look consistent
+            QAction *action = new IMAction(i18n("Start Chat"),
+                                KIcon(QLatin1String("text-x-generic")),
+                                contact,
+                                account,
+                                TextChannel,
+                                parent);
+            connect (action, SIGNAL(triggered(bool)), SLOT(onActionTriggered()));
+            actions << action;
+        }
+        if (contact->audioCallCapability()) {
+            QAction *action = new IMAction(i18n("Start Audio Call"),
+                                KIcon(QLatin1String("audio-headset")),
+                                contact,
+                                account,
+                                AudioChannel,
+                                parent);
+            connect (action, SIGNAL(triggered(bool)), SLOT(onActionTriggered()));
+            actions << action;
+        }
+        if (contact->videoCallCapability()) {
+            QAction *action = new IMAction(i18n("Start Video Call"),
+                                KIcon(QLatin1String("camera-web")),
+                                contact,
+                                account,
+                                VideoChannel,
+                                parent);
+            connect (action, SIGNAL(triggered(bool)), SLOT(onActionTriggered()));
+            actions << action;
+        }
+
+        if (contact->fileTransferCapability()) {
+            QAction *action = new IMAction(i18n("Send a file"),
+                                        KIcon(QLatin1String("mail-attachment")),
+                                        contact,
+                                        account,
+                                        FileTransfer,
+                                        parent);
+            action->setDisabled(true); //FIXME: we need to prompt for file
+            connect (action, SIGNAL(triggered(bool)), SLOT(onActionTriggered()));
+            actions << action;
+        }
+
+        QAction *action = new IMAction(i18n("Open Log Viewer"),
+                                    KIcon(QLatin1String("documentation")),
+                                    contact,
+                                    account,
+                                    LogViewer,
+                                    parent);
+        connect(action, SIGNAL(triggered(bool)), SLOT(onActionTriggered()));
+        actions << action;
+    }
+    return actions;
+}
+
+void KPeopleActionsPlugin::onActionTriggered()
+{
+    IMAction *action = qobject_cast<IMAction*>(sender());
+    KTp::ContactPtr contact = action->contact();
+    Tp::AccountPtr account = action->account();
+    IMActionType type = action->type();
+
+    switch (type) {
+        case TextChannel:
+            KTp::Actions::startChat(account, contact);
+            break;
+        case AudioChannel:
+            KTp::Actions::startAudioCall(account, contact);
+            break;
+        case VideoChannel:
+            KTp::Actions::startAudioVideoCall(account, contact);
+            break;
+        case FileTransfer:
+            //TODO: add filetransfer
+            break;
+        case LogViewer:
+            KTp::Actions::openLogViewer(account, contact);
+            break;
+    }
+}
+
+#include "kpeople-actions-plugin.moc"
+#include "moc_kpeople-actions-plugin.cpp"
+
+
+K_PLUGIN_FACTORY( KPeopleActionsPluginFactory, registerPlugin<KPeopleActionsPlugin>(); )
+K_EXPORT_PLUGIN( KPeopleActionsPluginFactory("ktp_kpeople_plugin") )
diff --git a/kpeople/actionsplugin/kpeople-actions-plugin.h b/kpeople/actionsplugin/kpeople-actions-plugin.h
new file mode 100644
index 0000000..66a54c7
--- /dev/null
+++ b/kpeople/actionsplugin/kpeople-actions-plugin.h
@@ -0,0 +1,37 @@
+/*
+    Copyright (C) 2013  David Edmundson <davidedmundson at kde.org>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+#ifndef IM_PLUGIN_H
+#define IM_PLUGIN_H
+
+#include <KPeople/AbstractPersonPlugin>
+
+class PersonData;
+
+class KPeopleActionsPlugin : public KPeople::AbstractPersonPlugin
+{
+    Q_OBJECT
+public:
+    KPeopleActionsPlugin(QObject *parent, const QVariantList &args);
+    virtual QList<QAction*> actionsForPerson(KPeople::PersonData *personData, QObject *parent);
+
+private Q_SLOTS:
+    void onActionTriggered();
+};
+
+#endif // IM_PLUGIN_H
diff --git a/kpeople/actionsplugin/ktp_kpeople_plugin.desktop b/kpeople/actionsplugin/ktp_kpeople_plugin.desktop
new file mode 100644
index 0000000..a378799
--- /dev/null
+++ b/kpeople/actionsplugin/ktp_kpeople_plugin.desktop
@@ -0,0 +1,21 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=KPeople KTp Plugin
+Name[cs]=Modul KPeople KTp
+Name[fr]=Module externe KPeople KTp
+Name[nl]=KPeople KTp-plug-in
+Name[pt]='Plugin' do KPeople para o KTp
+Name[pt_BR]=Plugin do KTp para o KPeople
+Name[sk]=KPeople KTp Plugin
+Name[sv]=KPeople KTp-insticksprogram
+Name[uk]=Додаток KTp KPeople
+Name[x-test]=xxKPeople KTp Pluginxx
+Type=Service
+ServiceTypes=KPeople/Plugin
+X-KDE-Library=ktp_kpeople_plugin
+X-KDE-PluginInfo-Author=David Edmundson
+X-KDE-PluginInfo-Email=daivdedmundson at kde.org
+X-KDE-PluginInfo-Name=ktp
+X-KDE-PluginInfo-Version=0.1
+X-KDE-PluginInfo-License=LGPL
+X-KDE-PluginInfo-EnabledByDefault=true
diff --git a/kpeople/datasourceplugin/CMakeLists.txt b/kpeople/datasourceplugin/CMakeLists.txt
new file mode 100644
index 0000000..3b88db2
--- /dev/null
+++ b/kpeople/datasourceplugin/CMakeLists.txt
@@ -0,0 +1,31 @@
+set (im_persons_data_source_SRCS
+     im-persons-data-source-plugin.cpp
+)
+
+kde4_add_plugin (im_persons_data_source_plugin
+                 ${im_persons_data_source_SRCS}
+)
+
+target_link_libraries (im_persons_data_source_plugin
+    ${QT_LIBRARIES}
+    ${TELEPATHY_QT4_LIBRARIES}
+    ${KDE4_KDEUI_LIBS}
+    ${NEPOMUK_CORE_LIBRARY}
+    kpeople
+    ktpcommoninternalsprivate
+)
+
+# Install:
+install (TARGETS im_persons_data_source_plugin
+         DESTINATION ${PLUGIN_INSTALL_DIR}
+)
+
+install (FILES im_persons_data_source_plugin.desktop
+         DESTINATION ${SERVICES_INSTALL_DIR}
+)
+
+
+install (FILES impersonsdatasource.h
+         DESTINATION ${INCLUDE_INSTALL_DIR}/kpeople
+         COMPONENT Devel
+)
diff --git a/kpeople/datasourceplugin/im-persons-data-source-plugin.cpp b/kpeople/datasourceplugin/im-persons-data-source-plugin.cpp
new file mode 100644
index 0000000..6ee5862
--- /dev/null
+++ b/kpeople/datasourceplugin/im-persons-data-source-plugin.cpp
@@ -0,0 +1,9 @@
+#include <KPluginFactory>
+#include <KPluginLoader>
+
+#include "KTp/im-persons-data-source.h"
+
+//this is a new file so that IMPluginDataSource can be used from it's own plugin (this) and from the normal plugin
+
+K_PLUGIN_FACTORY( IMPersonsDataSourceFactory, registerPlugin<IMPersonsDataSource>(); )
+K_EXPORT_PLUGIN( IMPersonsDataSourceFactory("im_persons_data_source_plugin") )
diff --git a/kpeople/datasourceplugin/im_persons_data_source_plugin.desktop b/kpeople/datasourceplugin/im_persons_data_source_plugin.desktop
new file mode 100644
index 0000000..8997b0b
--- /dev/null
+++ b/kpeople/datasourceplugin/im_persons_data_source_plugin.desktop
@@ -0,0 +1,20 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=Person Data Source Provider
+Name[fr]=Fournisseur de source de données personnelles
+Name[nl]=Leverancier van gegevensbron met personen
+Name[pt]=Fornecedor da Fonte de Dados Pessoais
+Name[pt_BR]=Fornecedor de Fonte de Dados Pessoais
+Name[sk]=Poskytovateľ dátových zdrojov osôb
+Name[sv]=Datakälla för personinformation
+Name[uk]=Надавач даних щодо особи
+Name[x-test]=xxPerson Data Source Providerxx
+Type=Service
+ServiceTypes=KPeople/DataSource
+X-KDE-Library=im_persons_data_source_plugin
+X-KDE-PluginInfo-Author=Martin Klapetek
+X-KDE-PluginInfo-Email=mklapetek at kde.org
+X-KDE-PluginInfo-Name=IMProvider
+X-KDE-PluginInfo-Version=0.1
+X-KDE-PluginInfo-License=LGPL
+X-KDE-PluginInfo-EnabledByDefault=true

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list