[SCM] ktp-contact-applet packaging branch, master, updated. debian/15.12.1-1-966-gde83ac5
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:13:56 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-desktop-applets.git;a=commitdiff;h=5223ed6
The following commit has been merged in the master branch:
commit 5223ed6661b04eaf98149e11ce55b6165a194171
Author: Mikhail Krishtop <mikhailkrishtop at gmail.com>
Date: Wed Mar 28 22:23:16 2012 +0100
Add "Add Contact" action
BUG:292882
REVIEW:104430
---
presence/CMakeLists.txt | 2 ++
presence/src/presence-applet.cpp | 50 ++++++++++++++++++++++++++++++++++++++++
presence/src/presence-applet.h | 3 +++
3 files changed, 55 insertions(+)
diff --git a/presence/CMakeLists.txt b/presence/CMakeLists.txt
index 48c6796..7becc7e 100644
--- a/presence/CMakeLists.txt
+++ b/presence/CMakeLists.txt
@@ -38,6 +38,8 @@ target_link_libraries(plasma_applet_ktp_presence
${KDE4_KDEUI_LIBS}
${TELEPATHY_QT4_LIBRARIES}
${KTP_LIBRARIES}
+ ${KTP_MODELS_LIBRARIES}
+ ${KTP_WIDGETS_LIBRARIES}
)
install(TARGETS plasma_applet_ktp_presence DESTINATION ${PLUGIN_INSTALL_DIR})
diff --git a/presence/src/presence-applet.cpp b/presence/src/presence-applet.cpp
index 53e23b1..de3ae5c 100644
--- a/presence/src/presence-applet.cpp
+++ b/presence/src/presence-applet.cpp
@@ -27,13 +27,18 @@
#include <KConfigGroup>
#include <KToolInvocation>
#include <KUser>
+#include <KMessageBox>
#include <KTp/global-presence.h>
+#include <KTp/Models/accounts-model.h>
+#include <KTp/Widgets/add-contact-dialog.h>
#include <Plasma/ToolTipManager>
#include <TelepathyQt/PendingOperation>
+#include <TelepathyQt/PendingContacts>
#include <TelepathyQt/PendingReady>
+#include <TelepathyQt/Account>
TelepathyPresenceApplet::TelepathyPresenceApplet(QObject *parent, const QVariantList &args)
: Plasma::PopupApplet(parent, args),
@@ -85,6 +90,7 @@ void TelepathyPresenceApplet::init()
Tp::ConnectionFactoryPtr connectionFactory = Tp::ConnectionFactory::create(QDBusConnection::sessionBus(),
Tp::Features() << Tp::Connection::FeatureCore
+ << Tp::Connection::FeatureRoster
<< Tp::Connection::FeatureSelfContact);
Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
@@ -123,6 +129,7 @@ void TelepathyPresenceApplet::setupContextMenuActions()
// application actions
KAction *showAccountManagerAction = new KAction(KIcon("telepathy-kde"), i18n("Account Manager"), this);
KAction *showContactListAction = new KAction(KIcon("meeting-attending"), i18n("Contact List"), this);
+ KAction *addContactAction = new KAction(KIcon("list-add-user"), i18n("Add New Contacts"), this);
// connect actions
connect(goOnlineAction, SIGNAL(triggered()), this, SLOT(onPresenceActionClicked()));
@@ -134,6 +141,7 @@ void TelepathyPresenceApplet::setupContextMenuActions()
connect(showAccountManagerAction, SIGNAL(triggered()), this, SLOT(startAccountManager()));
connect(showContactListAction, SIGNAL(triggered()), this, SLOT(startContactList()));
+ connect(addContactAction, SIGNAL(triggered()),this, SLOT(onAddContactRequest()));
m_contextActions.append(goOnlineAction);
m_contextActions.append(goBusyAction);
@@ -147,6 +155,9 @@ void TelepathyPresenceApplet::setupContextMenuActions()
m_contextActions.append(showContactListAction);
m_contextActions.append(moreMenu->addSeparator());
+ m_contextActions.append(addContactAction);
+
+ m_contextActions.append(moreMenu->addSeparator());
}
void TelepathyPresenceApplet::onAccountManagerReady(Tp::PendingOperation* op)
@@ -176,6 +187,45 @@ void TelepathyPresenceApplet::startContactList()
KToolInvocation::startServiceByDesktopName("ktp-contactlist");
}
+void TelepathyPresenceApplet::onAddContactRequest() {
+ QWeakPointer<AccountsModel> accountModel = new AccountsModel();
+ accountModel.data()->setAccountManager(m_accountManager);
+
+ QWeakPointer<KTp::AddContactDialog> dialog = new KTp::AddContactDialog(accountModel.data(), 0);
+ if (dialog.data()->exec() == QDialog::Accepted) {
+ Tp::AccountPtr account = dialog.data()->account();
+ if (account.isNull()) {
+ KMessageBox::error(dialog.data(),
+ i18n("Seems like you forgot to select an account. Also do not forget to connect it first."),
+ i18n("No Account Selected"));
+ }
+ else if (account->connection().isNull()) {
+ KMessageBox::error(dialog.data(),
+ i18n("An error we did not anticipate just happened and so the contact could not be added. Sorry."),
+ i18n("Account Error"));
+ } else {
+ QStringList identifiers = QStringList() << dialog.data()->screenName();
+ Tp::PendingContacts* pendingContacts = account->connection()->contactManager()->contactsForIdentifiers(identifiers);
+ connect(pendingContacts, SIGNAL(finished(Tp::PendingOperation*)), SLOT(onAddContactRequestFoundContacts(Tp::PendingOperation*)));
+ }
+ }
+ delete dialog.data();
+ delete accountModel.data();
+}
+
+void TelepathyPresenceApplet::onAddContactRequestFoundContacts(Tp::PendingOperation *operation) {
+ Tp::PendingContacts *pendingContacts = qobject_cast<Tp::PendingContacts*>(operation);
+
+ if (! pendingContacts->isError()) {
+ //request subscription
+ pendingContacts->manager()->requestPresenceSubscription(pendingContacts->contacts());
+ }
+ else {
+ kDebug() << pendingContacts->errorName();
+ kDebug() << pendingContacts->errorMessage();
+ }
+}
+
void TelepathyPresenceApplet::onPresenceChanged(KTp::Presence presence)
{
setPopupIcon(presence.icon());
diff --git a/presence/src/presence-applet.h b/presence/src/presence-applet.h
index 9c0533f..4f1a2d5 100644
--- a/presence/src/presence-applet.h
+++ b/presence/src/presence-applet.h
@@ -24,6 +24,7 @@
#include <Plasma/DeclarativeWidget>
#include <TelepathyQt/AccountManager>
+#include <TelepathyQt/ContactManager>
#include <TelepathyQt/Presence>
#include <KTp/presence.h>
@@ -65,6 +66,8 @@ private Q_SLOTS:
void startAccountManager();
void startContactList();
+ void onAddContactRequest();
+ void onAddContactRequestFoundContacts(Tp::PendingOperation *operation);
private:
/** used only upon creation to setup a list of actions for the context menu */
--
ktp-contact-applet packaging
More information about the pkg-kde-commits
mailing list