[SCM] ktp-kded-integration-module packaging branch, master, updated. debian/15.12.1-2-382-gbd961c2

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:14:32 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-kded-module.git;a=commitdiff;h=e0aa714

The following commit has been merged in the master branch:
commit e0aa714ea9a74c9e9c42386851e93c4e5e054966
Author: Rohan Garg <rohangarg at kubuntu.org>
Date:   Mon Sep 3 12:45:30 2012 +0530

    Implement contact notifications
---
 CMakeLists.txt                                  |  1 +
 contactnotify.cpp                               | 94 +++++++++++++++++++++++++
 config/nowplaying-lineedit.h => contactnotify.h | 33 +++++----
 telepathy-module.cpp                            |  2 +
 telepathy-module.h                              |  2 +
 5 files changed, 115 insertions(+), 17 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 96cedcf..024ad76 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,6 +36,7 @@ set (kded_ktp_integration_module_SRCS
      telepathy-mpris.cpp
      autoconnect.cpp
      error-handler.cpp
+     contactnotify.cpp
 )
 
 kde4_add_plugin (kded_ktp_integration_module
diff --git a/contactnotify.cpp b/contactnotify.cpp
new file mode 100644
index 0000000..a9d0ebc
--- /dev/null
+++ b/contactnotify.cpp
@@ -0,0 +1,94 @@
+/*
+    Copyright (C) 2012 Rohan Garg <rohangarg at kubuntu.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 "contactnotify.h"
+
+#include <KDebug>
+
+#include <TelepathyQt/ContactManager>
+#include <TelepathyQt/Account>
+#include <TelepathyQt/Contact>
+
+#include <KNotification>
+#include <KAboutData>
+
+#include <KTp/presence.h>
+
+ContactNotify::ContactNotify(const Tp::AccountManagerPtr accountMgr, QObject *parent) :
+    QObject(parent)
+{
+    m_accountManager = accountMgr;
+    if (!m_accountManager) {
+        return;
+    }
+
+    QList<Tp::AccountPtr> onlineAccounts = m_accountManager->allAccounts();
+    Q_FOREACH(const Tp::AccountPtr &account, onlineAccounts) {
+        // Accounts that are already online should be handled immediately
+        if (account.data()->isOnline()) {
+            kDebug() << "Account" << account.data()->normalizedName() << "is Online";
+            accountIsOnline(&account);
+        }
+
+        // Handle accounts coming online
+        connect(account.data(), SIGNAL(onlinenessChanged(bool)),
+                SLOT(accountCameOnline(bool)));
+    }
+}
+
+void ContactNotify::accountCameOnline(bool online)
+{
+    if (online) {
+        const Tp::AccountPtr *account = (Tp::AccountPtr *)QObject::sender();
+        accountIsOnline(account);
+    }
+}
+
+void ContactNotify::accountIsOnline(const Tp::AccountPtr *account)
+{
+    Tp::Contacts contacts = account->data()->connection()->contactManager()->allKnownContacts();
+    Q_FOREACH (const Tp::ContactPtr &contact, contacts) {
+        connect(contact.data(), SIGNAL(presenceChanged(Tp::Presence)),
+                SLOT(contactPresenceChanged(Tp::Presence)));
+    }
+}
+
+void ContactNotify::contactPresenceChanged(Tp::Presence presence)
+{
+    Tp::Contact *contact = (Tp::Contact *)QObject::sender();
+    KTp::Presence ktpPresence(presence);
+    sendNotification(i18nc("%1 is the contact name, %2 is the presence message",
+                           "%1 is now %2",
+                           contact->alias(),
+                           ktpPresence.displayString()),
+                     ktpPresence.icon());
+}
+
+void ContactNotify::sendNotification(QString text, KIcon icon)
+{
+    //The pointer is automatically deleted when the event is closed
+    KNotification *notification;
+    notification = new KNotification(QLatin1String("telepathyInfo"), KNotification::CloseOnTimeout);
+
+    KAboutData aboutData("ktelepathy",0,KLocalizedString(),0);
+    notification->setComponentData(KComponentData(aboutData));
+
+    notification->setPixmap(icon.pixmap(48));
+    notification->setText(text);
+    notification->sendEvent();
+}
diff --git a/config/nowplaying-lineedit.h b/contactnotify.h
similarity index 58%
copy from config/nowplaying-lineedit.h
copy to contactnotify.h
index 23f2fee..43033d7 100644
--- a/config/nowplaying-lineedit.h
+++ b/contactnotify.h
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Othmane Moustaouda <othmane.moustaouda at gmail.com>
+    Copyright (C) 2012 Rohan Garg <rohangarg at kubuntu.org>
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Lesser General Public
@@ -16,28 +16,27 @@
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
+#ifndef CONTACTNOTIFY_H
+#define CONTACTNOTIFY_H
 
-#ifndef NOWPLAYING_LINEEDIT_H
-#define NOWPLAYING_LINEEDIT_H
+#include <TelepathyQt/AccountManager>
+#include <KIcon>
 
-#include <QLineEdit>
-
-class NowPlayingLineEdit : public QLineEdit    //krazy:exclude=qclasses
+class ContactNotify : public QObject
 {
-     Q_OBJECT
-
+    Q_OBJECT
 public:
-    NowPlayingLineEdit(QWidget *parent = 0);
-    virtual ~NowPlayingLineEdit();
+    ContactNotify(Tp::AccountManagerPtr accountMgr, QObject *parent = 0);
 
-    void setLocalizedTagNames(QStringList tagNames);
+private:
+    Tp::AccountManagerPtr m_accountManager;
 
-protected:
-    void dropEvent(QDropEvent *event);
-    void mousePressEvent(QMouseEvent *event);
+private Q_SLOTS:
+    void accountCameOnline(bool);
+    void accountIsOnline(const Tp::AccountPtr*);
+    void contactPresenceChanged(Tp::Presence);
+    void sendNotification(QString, KIcon);
 
-private:
-    QStringList m_localizedTagNames;
 };
 
-#endif // NOWPLAYING_LINEEDIT_H
+#endif // CONTACTNOTIFY_H
diff --git a/telepathy-module.cpp b/telepathy-module.cpp
index 2085fea..7ab13b2 100644
--- a/telepathy-module.cpp
+++ b/telepathy-module.cpp
@@ -34,6 +34,7 @@
 #include "autoconnect.h"
 #include "error-handler.h"
 #include "telepathy-kded-module-plugin.h"
+#include "contactnotify.h"
 
 #include <KConfigGroup>
 #include "contact-request-handler.h"
@@ -120,6 +121,7 @@ void TelepathyModule::onAccountManagerReady(Tp::PendingOperation* op)
 
     m_errorHandler = new ErrorHandler(m_accountManager, this);
     m_contactHandler = new ContactRequestHandler(m_accountManager, this);
+    m_contactNotify = new ContactNotify(m_accountManager, this);
 }
 
 void TelepathyModule::onRequestedPresenceChanged(const KTp::Presence &presence)
diff --git a/telepathy-module.h b/telepathy-module.h
index 15666bc..748437d 100644
--- a/telepathy-module.h
+++ b/telepathy-module.h
@@ -40,6 +40,7 @@ class ErrorHandler;
 class TelepathyMPRIS;
 class AutoAway;
 class AutoConnect;
+class ContactNotify;
 
 class TelepathyModule : public KDEDModule
 {
@@ -70,6 +71,7 @@ private:
     ErrorHandler            *m_errorHandler;
     KTp::GlobalPresence     *m_globalPresence;
     ContactRequestHandler   *m_contactHandler;
+    ContactNotify           *m_contactNotify;
 
     QList<TelepathyKDEDModulePlugin*> m_pluginStack;
     KTp::Presence m_lastUserPresence;

-- 
ktp-kded-integration-module packaging



More information about the pkg-kde-commits mailing list