[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [ktp-common-internals/kpeople2] kpeople/actionsplugin: Port the actions plugin to kpeople2
From: Martin Klapetek <mklapetek () kde ! org>
Date: 2013-11-17 10:55:10
Message-ID: E1Vi00U-0002yt-KV () scm ! kde ! org
[Download RAW message or body]
Git commit 9ef405b1979653351588395512977b75ba39d204 by Martin Klapetek.
Committed on 17/11/2013 at 10:52.
Pushed by mklapetek into branch 'kpeople2'.
Port the actions plugin to kpeople2
M +31 -21 kpeople/actionsplugin/kpeople-actions-plugin.cpp
M +3 -1 kpeople/actionsplugin/kpeople-actions-plugin.h
http://commits.kde.org/telepathy-common-internals/9ef405b1979653351588395512977b75ba39d204
diff --git a/kpeople/actionsplugin/kpeople-actions-plugin.cpp \
b/kpeople/actionsplugin/kpeople-actions-plugin.cpp index f98c57e..2737a63 100644
--- a/kpeople/actionsplugin/kpeople-actions-plugin.cpp
+++ b/kpeople/actionsplugin/kpeople-actions-plugin.cpp
@@ -28,12 +28,12 @@
#include "KTp/contact.h"
#include "KTp/actions.h"
-#include "KTp/im-persons-data-source.h"
+#include "KTp/core.h"
+#include "KTp/global-contact-manager.h"
#include <TelepathyQt/Account>
#include <TelepathyQt/ContactManager>
-
#include <kpeople/personpluginmanager.h>
#include <KPeople/PersonData>
@@ -101,35 +101,44 @@ QUrl IMAction::uri() const
return m_uri;
}
-KPeopleActionsPlugin::KPeopleActionsPlugin(QObject* parent, const QVariantList \
&args):
-AbstractPersonPlugin(parent)
+KPeopleActionsPlugin::KPeopleActionsPlugin(QObject *parent, const QVariantList \
&args) + : AbstractPersonPlugin(parent)
{
Q_UNUSED(args);
}
-QList<QAction*> KPeopleActionsPlugin::actionsForPerson(const KPeople::PersonDataPtr \
&personData, QObject *parent) +QList<QAction*> \
KPeopleActionsPlugin::actionsForPerson(const KABC::Addressee &person, + \
const KABC::AddresseeList &contacts, + \
QObject *parent) const {
QList<QAction*> actions;
- IMPersonsDataSource *dataSource = \
dynamic_cast<IMPersonsDataSource*>(KPeople::PersonPluginManager::presencePlugin());
- if (!dataSource) {
- return actions;
- }
+ const QString &accountPath = person.custom(QLatin1String("telepathy"), \
QLatin1String("accountPath")); + const QString &contactId = \
person.custom(QLatin1String("telepathy"), QLatin1String("contactId")); +
+ // List of pair<accountPath, contactId> - these two always need to be together
+ QList<QPair<QString, QString> > accountContactList;
- QStringList imContactsIds = personData->imAccounts();
+ accountContactList << qMakePair(accountPath, contactId);
+
+ Q_FOREACH (const KABC::Addressee &contact, contacts) {
+ accountContactList << qMakePair(contact.custom(QLatin1String("telepathy"), \
QLatin1String("accountPath")), + \
contact.custom(QLatin1String("telepathy"), QLatin1String("contactId"))); + }
- for (int i = 0; i < imContactsIds.size(); i++) {
- const QString contactId = imContactsIds[i];
- const KTp::ContactPtr contact = dataSource->contactForContactId(contactId);
+ for (int i = 0; i < accountContactList.size(); i++) {
+ const KTp::ContactPtr contact = \
KTp::contactManager()->contactForContactId(accountContactList.at(i).first, + \
accountContactList.at(i).second); if (!contact || !contact->manager()) {
continue;
}
- const Tp::AccountPtr account = dataSource->accountForContact(contact);
+ const Tp::AccountPtr account = \
KTp::contactManager()->accountForAccountPath(accountContactList.at(i).first);
if (!account) {
continue;
}
+ //FIXME - already in master
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 Using %1...", \
account->displayName()), KIcon(QLatin1String("text-x-generic")),
@@ -184,13 +193,14 @@ QList<QAction*> KPeopleActionsPlugin::actionsForPerson(const \
KPeople::PersonData }
}
- QAction *action = new IMAction(i18n("Open Log Viewer..."),
- KIcon(QLatin1String("documentation")),
- personData->uri(),
- LogViewer,
- parent);
- connect(action, SIGNAL(triggered(bool)), SLOT(onActionTriggered()));
- actions << action;
+ //FIXME-KPEOPLE
+// QAction *action = new IMAction(i18n("Open Log Viewer..."),
+// KIcon(QLatin1String("documentation")),
+// personData->uri(),
+// LogViewer,
+// parent);
+// connect(action, SIGNAL(triggered(bool)), SLOT(onActionTriggered()));
+// actions << action;
return actions;
}
diff --git a/kpeople/actionsplugin/kpeople-actions-plugin.h \
b/kpeople/actionsplugin/kpeople-actions-plugin.h index 4169dc0..219b173 100644
--- a/kpeople/actionsplugin/kpeople-actions-plugin.h
+++ b/kpeople/actionsplugin/kpeople-actions-plugin.h
@@ -26,7 +26,9 @@ class KPeopleActionsPlugin : public KPeople::AbstractPersonPlugin
Q_OBJECT
public:
KPeopleActionsPlugin(QObject *parent, const QVariantList &args);
- virtual QList<QAction*> actionsForPerson(const KPeople::PersonDataPtr \
&personData, QObject *parent); + virtual QList<QAction*> actionsForPerson(const \
KABC::Addressee &person, + const \
KABC::AddresseeList &contacts, + QObject \
*parent) const;
private Q_SLOTS:
void onActionTriggered();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic