diff --git a/daemon/plugins/CMakeLists.txt b/daemon/plugins/CMakeLists.txt index 5818863b6..053be0749 100644 --- a/daemon/plugins/CMakeLists.txt +++ b/daemon/plugins/CMakeLists.txt @@ -5,3 +5,4 @@ add_subdirectory(ping) add_subdirectory(pausemusic) add_subdirectory(mpriscontrol) add_subdirectory(clipboard) +add_subdirectory(telephony) \ No newline at end of file diff --git a/daemon/plugins/telephony/CMakeLists.txt b/daemon/plugins/telephony/CMakeLists.txt new file mode 100644 index 000000000..c376981b4 --- /dev/null +++ b/daemon/plugins/telephony/CMakeLists.txt @@ -0,0 +1,20 @@ +find_package(KDE4 REQUIRED) +include (KDE4Defaults) +include_directories(${KDE4_INCLUDES}) + +set(kdeconnect_telephony_SRCS + telephonyplugin.cpp + ../kdeconnectplugin.cpp +) + +kde4_add_plugin(kdeconnect_telephony ${kdeconnect_telephony_SRCS}) + +target_link_libraries(kdeconnect_telephony + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${QT_QTNETWORK_LIBRARY} + qjson +) + +install(TARGETS kdeconnect_telephony DESTINATION ${PLUGIN_INSTALL_DIR} ) +install(FILES kdeconnect_telephony.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/daemon/plugins/telephony/kdeconnect_telephony.desktop b/daemon/plugins/telephony/kdeconnect_telephony.desktop new file mode 100644 index 000000000..ea16130f4 --- /dev/null +++ b/daemon/plugins/telephony/kdeconnect_telephony.desktop @@ -0,0 +1,15 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Service +ServiceTypes=KdeConnect/Plugin +X-KDE-Library=kdeconnect_telephony +X-KDE-PluginInfo-Author=Albert Vaca +X-KDE-PluginInfo-Email=albertvaka@gmail.com +X-KDE-PluginInfo-Name=kdeconnect_telephony +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Website=http://albertvaka.wordpress.com +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true +Icon=preferences-desktop-notification +Name=Telephony integration +Comment=Currently it only shows notifications for calls and SMS diff --git a/daemon/plugins/eventnotifications/notificationpackageinterface.cpp b/daemon/plugins/telephony/telephonyplugin.cpp similarity index 77% rename from daemon/plugins/eventnotifications/notificationpackageinterface.cpp rename to daemon/plugins/telephony/telephonyplugin.cpp index 48695bd5d..67e814181 100644 --- a/daemon/plugins/eventnotifications/notificationpackageinterface.cpp +++ b/daemon/plugins/telephony/telephonyplugin.cpp @@ -18,23 +18,21 @@ * along with this program. If not, see . */ -#include "notificationpackageinterface.h" +#include "telephonyplugin.h" #include #include -NotificationPackageInterface::NotificationPackageInterface(QObject* parent) - : PackageInterface(parent) +TelephonyPlugin::TelephonyPlugin(QObject *parent, const QVariantList &args) + : KdeConnectPlugin(parent, args) { - //TODO: Split in EventNotificationInterface and NotificationDrawerSyncInterface - trayIcon = new KStatusNotifierItem(parent); trayIcon->setIconByName("pda"); trayIcon->setTitle("KdeConnect"); connect(trayIcon,SIGNAL(activateRequested(bool,QPoint)),this,SLOT(showPendingNotifications())); } -KNotification* NotificationPackageInterface::createNotification(const QString& deviceName, const NetworkPackage& np) +KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np) { QString id = QString::number(np.id()); @@ -44,8 +42,7 @@ KNotification* NotificationPackageInterface::createNotification(const QString& d QString title, content, type, icon; bool transient; - title = deviceName; - + title = device()->name(); if (npType == "ringing") { type = "callReceived"; @@ -65,16 +62,6 @@ KNotification* NotificationPackageInterface::createNotification(const QString& d + ":\n" + np.get("messageBody",""); transient = true; - } else if (npType == "battery") { - type = "battery100"; - icon = "battery-100"; - content = "Battery at " + np.get("batteryLevel") + "%"; - transient = false; - } else if (npType == "notification") { - type = "pingReceived"; - icon = "dialog-ok"; - content = np.get("notificationContent"); - transient = false; } else { //TODO: return NULL if !debug type = "unknownEvent"; @@ -89,7 +76,7 @@ KNotification* NotificationPackageInterface::createNotification(const QString& d if (transient) { trayIcon->setStatus(KStatusNotifierItem::Active); - KNotification* notification = new KNotification(type); //KNotification::Persistent + KNotification* notification = new KNotification(type); notification->setPixmap(KIcon(icon).pixmap(48, 48)); notification->setComponentData(KComponentData("kdeconnect", "kdeconnect")); notification->setTitle(title); @@ -98,7 +85,8 @@ KNotification* NotificationPackageInterface::createNotification(const QString& d pendingNotifications.insert(id, notification); } - KNotification* notification = new KNotification(type); //KNotification::Persistent + + KNotification* notification = new KNotification(type); //, KNotification::Persistent notification->setPixmap(KIcon(icon).pixmap(48, 48)); notification->setComponentData(KComponentData("kdeconnect", "kdeconnect")); notification->setTitle(title); @@ -112,7 +100,7 @@ KNotification* NotificationPackageInterface::createNotification(const QString& d } -void NotificationPackageInterface::notificationAttended() +void TelephonyPlugin::notificationAttended() { KNotification* normalNotification = (KNotification*)sender(); QString id = normalNotification->property("id").toString(); @@ -125,7 +113,7 @@ void NotificationPackageInterface::notificationAttended() } } -void NotificationPackageInterface::showPendingNotifications() +void TelephonyPlugin::showPendingNotifications() { trayIcon->setStatus(KStatusNotifierItem::Passive); Q_FOREACH (KNotification* notification, pendingNotifications) { @@ -134,7 +122,7 @@ void NotificationPackageInterface::showPendingNotifications() pendingNotifications.clear(); } -bool NotificationPackageInterface::receivePackage(const Device& device, const NetworkPackage& np) +bool TelephonyPlugin::receivePackage(const NetworkPackage& np) { if (np.type() != PACKAGE_TYPE_NOTIFICATION) return false; @@ -147,7 +135,7 @@ bool NotificationPackageInterface::receivePackage(const Device& device, const Ne } else { - KNotification* n = createNotification(device.name(), np); + KNotification* n = createNotification(np); if (n != NULL) n->sendEvent(); } diff --git a/daemon/plugins/eventnotifications/notificationpackageinterface.h b/daemon/plugins/telephony/telephonyplugin.h similarity index 74% rename from daemon/plugins/eventnotifications/notificationpackageinterface.h rename to daemon/plugins/telephony/telephonyplugin.h index b898bcfbe..d1931e618 100644 --- a/daemon/plugins/eventnotifications/notificationpackageinterface.h +++ b/daemon/plugins/telephony/telephonyplugin.h @@ -18,33 +18,33 @@ * along with this program. If not, see . */ -#ifndef NOTIFICATIONPACKAGEINTERFACE_H -#define NOTIFICATIONPACKAGEINTERFACE_H +#ifndef TELEPHONYPLUGIN_H +#define TELEPHONYPLUGIN_H #include -#include "packageinterface.h" +#include "../kdeconnectplugin.h" #include -class NotificationPackageInterface - : public PackageInterface +class TelephonyPlugin + : public KdeConnectPlugin { Q_OBJECT public: - NotificationPackageInterface(QObject* parent = 0); + explicit TelephonyPlugin(QObject *parent, const QVariantList &args); - virtual bool receivePackage(const Device&, const NetworkPackage& np); +public Q_SLOTS: + virtual bool receivePackage(const NetworkPackage& np); + void showPendingNotifications(); + void notificationAttended(); private: - KNotification* createNotification(const QString& deviceName,const NetworkPackage& np); + KNotification* createNotification(const NetworkPackage& np); KStatusNotifierItem* trayIcon; QHash pendingNotifications; -public slots: - void showPendingNotifications(); - void notificationAttended(); }; #endif