[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:26:39 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=acadeef
The following commit has been merged in the master branch:
commit acadeef76dc7cc9b66c7ef900b6b2b36c88ebc65
Author: Albert Vaca <albertvaka at gmail.com>
Date: Thu Jul 4 19:17:22 2013 +0200
Rewritten old package emitters and receivers using the new package format
Splitted up ping receiver from notification receiver in KDE
Improved pausemusic receiver
Fixed same computer being discovered multiple times
Fixed some other minor bugs and compilation warnings
---
CMakeLists.txt | 4 ++
daemon/CMakeLists.txt | 3 +-
daemon/announcers/announcer.h | 2 +
daemon/announcers/avahiannouncer.cpp | 12 ++--
daemon/announcers/avahiannouncer.h | 6 +-
daemon/daemon.cpp | 39 ++++---------
daemon/daemon.h | 2 -
daemon/device.cpp | 18 ++++--
daemon/device.h | 9 ++-
.../{announcers/fakeannouncer.h => netaddress.h} | 32 +++++------
daemon/networkpackage.cpp | 1 -
daemon/networkpackage.h | 1 +
.../echodevicelink.cpp => networkpackagetypes.h} | 13 +++--
.../notificationpackagereceiver.cpp | 64 ++++++++++++----------
.../packagereceivers/notificationpackagereceiver.h | 4 +-
daemon/packagereceivers/packagereceiver.h | 3 +-
.../packagereceivers/pausemusicpackagereceiver.cpp | 40 +++++++++++---
.../packagereceivers/pausemusicpackagereceiver.h | 6 +-
...onpackagereceiver.h => pingpackagereceiver.cpp} | 28 +++++-----
...tionpackagereceiver.h => pingpackagereceiver.h} | 14 ++---
kcm/devicesmodel.cpp | 1 +
21 files changed, 162 insertions(+), 140 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8293e97..b1970ec 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,6 +3,10 @@ cmake_minimum_required(VERSION 2.6)
find_package(KDE4 REQUIRED)
+if(CMAKE_COMPILER_IS_GNUCXX)
+ add_definitions(-std=gnu++0x)
+endif()
+
include(KDE4Defaults)
include_directories(${KDE4_INCLUDES})
diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt
index cc20a9a..a5fadd1 100644
--- a/daemon/CMakeLists.txt
+++ b/daemon/CMakeLists.txt
@@ -9,8 +9,9 @@ set(kded_kdeconnect_SRCS
devicelinks/devicelink.cpp
packagereceivers/packagereceiver.cpp
- packagereceivers/pausemusicpackagereceiver.cpp
+ packagereceivers/pingpackagereceiver.cpp
packagereceivers/notificationpackagereceiver.cpp
+ packagereceivers/pausemusicpackagereceiver.cpp
networkpackage.cpp
daemon.cpp
diff --git a/daemon/announcers/announcer.h b/daemon/announcers/announcer.h
index 6ce6de8..f080140 100644
--- a/daemon/announcers/announcer.h
+++ b/daemon/announcers/announcer.h
@@ -49,6 +49,8 @@ public:
virtual void setDiscoverable(bool b) = 0;
signals:
+ //NOTE: The announcer has to destroy the DeviceLink when it's no longer accessible,
+ // and every user should listen to the destroy signal to remove its references.
void onNewDeviceLink(const QString& id, const QString& name, DeviceLink*);
signals:
diff --git a/daemon/announcers/avahiannouncer.cpp b/daemon/announcers/avahiannouncer.cpp
index 8542fbb..f3d6f4b 100644
--- a/daemon/announcers/avahiannouncer.cpp
+++ b/daemon/announcers/avahiannouncer.cpp
@@ -51,9 +51,8 @@ void AvahiAnnouncer::readPendingNotifications()
QByteArray datagram;
datagram.resize(mUdpSocket->pendingDatagramSize());
- QHostAddress sender;
- quint16 senderPort;
- mUdpSocket->readDatagram(datagram.data(), datagram.size(), &sender, &senderPort);
+ NetAddress sender;
+ mUdpSocket->readDatagram(datagram.data(), datagram.size(), &(sender.ip), &(sender.port));
//log.write(datagram);
qDebug() << "AvahiAnnouncer incomming udp datagram: " << datagram;
@@ -68,8 +67,11 @@ void AvahiAnnouncer::readPendingNotifications()
qDebug() << "AvahiAnnouncer creating link to device" << id;
- DeviceLink* dl = new UdpDeviceLink(id, this, sender, 10600);
- links.append(dl);
+ DeviceLink* dl = new UdpDeviceLink(id, this, sender.ip, 10600);
+
+ if (links.contains(sender)) delete links[sender]; //Delete old link if we already know it, probably it is down if this happens.
+
+ links[sender] = dl;
emit onNewDeviceLink(id, name, dl);
} else {
diff --git a/daemon/announcers/avahiannouncer.h b/daemon/announcers/avahiannouncer.h
index 67647ce..eb3c1db 100644
--- a/daemon/announcers/avahiannouncer.h
+++ b/daemon/announcers/avahiannouncer.h
@@ -28,6 +28,7 @@
#include <KDE/DNSSD/PublicService>
#include "announcer.h"
+#include "netaddress.h"
class AvahiAnnouncer
: public Announcer
@@ -50,10 +51,7 @@ private:
DNSSD::PublicService* service;
QUdpSocket* mUdpSocket;
- QVector<DeviceLink*> links;
-
- QHostAddress mIp;
- quint16 mPort;
+ QMap<NetAddress, DeviceLink*> links;
};
diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp
index 95c85d0..160ff00 100644
--- a/daemon/daemon.cpp
+++ b/daemon/daemon.cpp
@@ -20,6 +20,7 @@
#include "daemon.h"
#include "networkpackage.h"
+#include "packagereceivers/pingpackagereceiver.h"
#include "packagereceivers/notificationpackagereceiver.h"
#include "packagereceivers/pausemusicpackagereceiver.h"
#include "announcers/avahiannouncer.h"
@@ -52,6 +53,7 @@ Daemon::Daemon(QObject *parent, const QList<QVariant>&)
//TODO: Do not hardcode the load of the package receivers
//use: https://techbase.kde.org/Development/Tutorials/Services/Plugins
+ packageReceivers.push_back(new PingPackageReceiver());
packageReceivers.push_back(new NotificationPackageReceiver());
packageReceivers.push_back(new PauseMusicPackageReceiver());
@@ -72,8 +74,8 @@ Daemon::Daemon(QObject *parent, const QList<QVariant>&)
Device* device = new Device(id,name);
m_devices[id] = device;
Q_FOREACH (PackageReceiver* pr, packageReceivers) {
- connect(device,SIGNAL(receivedPackage(const NetworkPackage&)),
- pr,SLOT(receivePackage(const NetworkPackage&)));
+ connect(device,SIGNAL(receivedPackage(const Device&, const NetworkPackage&)),
+ pr,SLOT(receivePackage(const Device&, const NetworkPackage&)));
}
}
@@ -82,7 +84,7 @@ Daemon::Daemon(QObject *parent, const QList<QVariant>&)
connect(a,SIGNAL(onNewDeviceLink(QString,QString,DeviceLink*)),
this,SLOT(onNewDeviceLink(QString,QString,DeviceLink*)));
}
-
+
QDBusConnection::sessionBus().registerService("org.kde.kdeconnect");
setDiscoveryEnabled(true);
@@ -109,6 +111,8 @@ void Daemon::onNewDeviceLink(const QString& id, const QString& name, DeviceLink*
qDebug() << "Device discovered" << dl->deviceId();
if (m_devices.contains(dl->deviceId())) {
+ qDebug() << "It is a known device";
+
Device* device = m_devices[dl->deviceId()];
device->addLink(dl);
@@ -117,42 +121,23 @@ void Daemon::onNewDeviceLink(const QString& id, const QString& name, DeviceLink*
notification->setComponentData(KComponentData("kdeconnect", "kdeconnect"));
notification->setTitle(device->name());
notification->setText("Succesfully connected");
+ notification->sendEvent();
emit deviceStatusChanged(id);
} else {
+ qDebug() << "It is a new device";
+
Device* device = new Device(id,name,dl);
m_devices[dl->deviceId()] = device;
Q_FOREACH (PackageReceiver* pr, packageReceivers) {
- connect(device,SIGNAL(receivedPackage(const NetworkPackage&)),
- pr,SLOT(receivePackage(const NetworkPackage&)));
+ connect(device,SIGNAL(receivedPackage(const Device&, const NetworkPackage&)),
+ pr,SLOT(receivePackage(const Device&, const NetworkPackage&)));
}
emit newDeviceAdded(id);
}
}
-
-void Daemon::onLostDeviceLink(DeviceLink* dl)
-{
- qDebug() << "Device lost" << dl->deviceId();
-
- if (m_devices.contains(dl->deviceId())) {
- Device* device = m_devices[dl->deviceId()];
- device->removeLink(dl);
-
- KNotification* notification = new KNotification("pingReceived"); //KNotification::Persistent
- notification->setPixmap(KIcon("dialog-ok").pixmap(48, 48));
- notification->setComponentData(KComponentData("kdeconnect", "kdeconnect"));
- notification->setTitle(device->name());
- notification->setText("Disconnected");
-
- } else {
- qDebug() << "Lost unknown device, this should not happen (?)";
- }
-
-
-}
-
Daemon::~Daemon()
{
qDebug() << "SAYONARA BABY";
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 6e7f875..533da5d 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -69,9 +69,7 @@ Q_SIGNALS:
private Q_SLOTS:
-
void onNewDeviceLink(const QString& id, const QString& name, DeviceLink* dl);
- void onLostDeviceLink(DeviceLink* dl);
private:
diff --git a/daemon/device.cpp b/daemon/device.cpp
index 53883fe..adc92ab 100644
--- a/daemon/device.cpp
+++ b/daemon/device.cpp
@@ -63,19 +63,25 @@ static bool lessThan(DeviceLink* p1, DeviceLink* p2)
void Device::addLink(DeviceLink* link)
{
- Q_FOREACH(DeviceLink* existing, m_deviceLinks) {
- //Do not add duplicate links
- if (existing->announcer() == link->announcer()) return;
- }
+ qDebug() << "AddLink";
+ connect(link,SIGNAL(destroyed(QObject*)),this,SLOT(linkDestroyed(QObject*)));
+
m_deviceLinks.append(link);
connect(link, SIGNAL(receivedPackage(NetworkPackage)), this, SLOT(privateReceivedPackage(NetworkPackage)));
+
qSort(m_deviceLinks.begin(),m_deviceLinks.end(),lessThan);
}
+void Device::linkDestroyed(QObject* o)
+{
+ removeLink(static_cast<DeviceLink*>(o));
+}
+
void Device::removeLink(DeviceLink* link)
{
+ qDebug() << "RemoveLink";
disconnect(link, SIGNAL(receivedPackage(NetworkPackage)), this, SLOT(privateReceivedPackage(NetworkPackage)));
- m_deviceLinks.remove(m_deviceLinks.indexOf(link));
+ m_deviceLinks.removeOne(link);
}
bool Device::sendPackage(const NetworkPackage& np)
@@ -90,7 +96,7 @@ void Device::privateReceivedPackage(const NetworkPackage& np)
m_deviceName = np.get<QString>("deviceName");
} else if (m_paired) {
qDebug() << "package received from paired device";
- emit receivedPackage(np);
+ emit receivedPackage(*this, np);
} else {
qDebug() << "not paired, ignoring package";
}
diff --git a/daemon/device.h b/daemon/device.h
index 8055e48..583d3b9 100644
--- a/daemon/device.h
+++ b/daemon/device.h
@@ -46,15 +46,17 @@ public:
//(not supported yet, do we need it or we can rely on the device presenging itself?)
//Device(const QString& id, DeviceLink* dl);
+ //Add and remove links
void addLink(DeviceLink*);
void removeLink(DeviceLink*);
+ //Send and receive
bool sendPackage(const NetworkPackage& np);
-
Q_SIGNALS:
- void receivedPackage(const NetworkPackage& np);
+ void receivedPackage(const Device& device, const NetworkPackage& np);
public Q_SLOTS:
+ //Public dbus interface
Q_SCRIPTABLE QString id() const{ return m_deviceId; }
Q_SCRIPTABLE QString name() const { return m_deviceName; }
Q_SCRIPTABLE bool paired() const { return m_paired; }
@@ -63,13 +65,14 @@ public Q_SLOTS:
Q_SCRIPTABLE void sendPing();
private Q_SLOTS:
+ void linkDestroyed(QObject* o = 0);
void privateReceivedPackage(const NetworkPackage& np);
private:
bool m_paired;
QString m_deviceId;
QString m_deviceName;
- QVector<DeviceLink*> m_deviceLinks;
+ QList<DeviceLink*> m_deviceLinks;
bool m_knownIdentiy;
diff --git a/daemon/announcers/fakeannouncer.h b/daemon/netaddress.h
similarity index 71%
copy from daemon/announcers/fakeannouncer.h
copy to daemon/netaddress.h
index 2f00544..f264ba1 100644
--- a/daemon/announcers/fakeannouncer.h
+++ b/daemon/netaddress.h
@@ -18,26 +18,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef FAKEANNOUNCER_H
-#define FAKEANNOUNCER_H
+#ifndef NETADDRESS_H
+#define NETADDRESS_H
-#include "announcer.h"
+#include <QHostAddress>
-class FakeAnnouncer : public Announcer
-{
- Q_OBJECT
-public:
- FakeAnnouncer();
- ~FakeAnnouncer();
-
- QString name() { return "FakeAnnouncer"; }
- Priority priority() { return PRIORITY_LOW; }
-
- void setDiscoverable(bool b);
-
-private:
- DeviceLink* echoDeviceLink;
-
+struct NetAddress {
+ NetAddress() { }
+ NetAddress(QHostAddress _ip, quint16 _port) : ip(_ip), port(_port) { }
+ QHostAddress ip;
+ quint16 port;
};
-#endif
+inline bool operator< (const NetAddress& a, const NetAddress& b){
+ return (a.ip.toString()+a.port) < (b.ip.toString()+b.port);
+}
+
+#endif // NETADDRESS_H
diff --git a/daemon/networkpackage.cpp b/daemon/networkpackage.cpp
index 82b7d54..1cb97e3 100644
--- a/daemon/networkpackage.cpp
+++ b/daemon/networkpackage.cpp
@@ -71,7 +71,6 @@ void NetworkPackage::unserialize(QByteArray a, NetworkPackage* np)
qDebug() << "Warning: package version " << np->version() << " greater than supported version " << CURRENT_PACKAGE_VERSION;
}
-
//QVariant -> Object
//NetworkPackage np;
//QJSon json(a);
diff --git a/daemon/networkpackage.h b/daemon/networkpackage.h
index 3ee3454..b2d8179 100644
--- a/daemon/networkpackage.h
+++ b/daemon/networkpackage.h
@@ -21,6 +21,7 @@
#ifndef NETWORKPACKAGE_H
#define NETWORKPACKAGE_H
+#include "networkpackagetypes.h"
#include <QObject>
#include <QString>
#include <QVariant>
diff --git a/daemon/devicelinks/echodevicelink.cpp b/daemon/networkpackagetypes.h
similarity index 73%
copy from daemon/devicelinks/echodevicelink.cpp
copy to daemon/networkpackagetypes.h
index 004298e..3ea3cc7 100644
--- a/daemon/devicelinks/echodevicelink.cpp
+++ b/daemon/networkpackagetypes.h
@@ -18,12 +18,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "echodevicelink.h"
+#ifndef NETWORKPACKAGETYPES_H
+#define NETWORKPACKAGETYPES_H
-#include "announcers/fakeannouncer.h"
+#define PACKAGE_TYPE_IDENTITY QString("kdeconnect.identity")
+#define PACKAGE_TYPE_PING QString("kdeconnect.ping")
+#define PACKAGE_TYPE_NOTIFICATION QString("kdeconnect.notification")
+#define PACKAGE_TYPE_CALL QString("kdeconnect.call")
-EchoDeviceLink::EchoDeviceLink(const QString& d, FakeAnnouncer* a)
- : DeviceLink(d, a)
-{
-}
+#endif // NETWORKPACKAGETYPES_H
diff --git a/daemon/packagereceivers/notificationpackagereceiver.cpp b/daemon/packagereceivers/notificationpackagereceiver.cpp
index b0da06d..221caba 100644
--- a/daemon/packagereceivers/notificationpackagereceiver.cpp
+++ b/daemon/packagereceivers/notificationpackagereceiver.cpp
@@ -20,70 +20,74 @@
#include "notificationpackagereceiver.h"
+#include <QDebug>
#include <kicon.h>
-KNotification* NotificationPackageReceiver::createNotification(const NetworkPackage& np) {
+KNotification* NotificationPackageReceiver::createNotification(const QString& deviceName, const NetworkPackage& np) {
- QString title, type, icon;
+ QString npType = np.get<QString>("notificationType");
- if (np.type() == "RINGING") {
- title = "Incoming call";
+ QString title, content, type, icon;
+
+ title = deviceName;
+
+ if (npType == "ringing") {
type = "callReceived";
icon = "call-start";
- } else if (np.type() == "MISSED") {
- title = "Missed call";
- type = "callMissed";
+ content = "Incoming call from " + np.get<QString>("phoneNumber");
+ } else if (npType == "missedCall") {
+ type = "missedCall";
icon = "call-start";
- } else if (np.type() == "SMS") {
- title = "SMS Received";
+ content = "Missed call from " + np.get<QString>("phoneNumber");
+ } else if (npType == "sms") {
type = "smsReceived";
icon = "mail-receive";
- } else if (np.type() == "BATTERY") {
- title = "Battery status";
+ content = "SMS received from " + np.get<QString>("phoneNumber");
+ } else if (npType == "battery") {
type = "battery100";
- icon = "battery-100"; // Here we need to take all different cases into account. All
- // possible steps on battery charge level and state (discharging
- // or charging)
- } else if (np.type() == "NOTIFY") {
- title = "Notification";
- type = "pingReceived";
- icon = "dialog-ok";
- } else if (np.type() == "PING") {
- title = "Ping!";
+ icon = "battery-100";
+ content = "Battery at " + np.get<QString>("batteryLevel") + "%";
+ } else if (npType == "notification") {
type = "pingReceived";
icon = "dialog-ok";
+ content = np.get<QString>("notificationContent");
} else {
- //TODO: return if !debug
- title = "Unknown";
+ //TODO: return NULL if !debug
type = "unknownEvent";
icon = "pda";
+ content = "Unknown notification type: " + npType;
}
+ qDebug() << "Creating notification with type:" << type;
KNotification* notification = new KNotification(type); //KNotification::Persistent
notification->setPixmap(KIcon(icon).pixmap(48, 48));
notification->setComponentData(KComponentData("kdeconnect", "kdeconnect"));
notification->setTitle(title);
- notification->setText(np.get<QString>(QString("content")));
+ notification->setText(content);
return notification;
}
-bool NotificationPackageReceiver::receivePackage(const NetworkPackage& np) {
+bool NotificationPackageReceiver::receivePackage(const Device& device, const NetworkPackage& np) {
- //if (np.get("isCancel")) {
+ qDebug() << "LOLOLO" << np.serialize();
+
+ if (np.type() != PACKAGE_TYPE_NOTIFICATION) return false;
+
+ if (np.get<bool>("isCancel")) {
//It would be awesome to remove the old notification from the system tray here, but there is no way to do it :(
//Now I realize why at the end of the day I have hundreds of notifications from facebook messages that I HAVE ALREADY READ,
- //...it's just because the telepathy client has no way to remove them! even when it knows that I have read those messages lol
+ //...it's just because the telepathy client has no way to remove them! even when it knows that I have read those messages!
- //} else {
+ } else {
- KNotification* n = createNotification(np);
- n->sendEvent();
+ KNotification* n = createNotification(device.name(), np);
+ if (n != NULL) n->sendEvent();
- //}
+ }
return true;
diff --git a/daemon/packagereceivers/notificationpackagereceiver.h b/daemon/packagereceivers/notificationpackagereceiver.h
index cb1117c..eb4fe53 100644
--- a/daemon/packagereceivers/notificationpackagereceiver.h
+++ b/daemon/packagereceivers/notificationpackagereceiver.h
@@ -30,10 +30,10 @@ class NotificationPackageReceiver
{
public:
- virtual bool receivePackage(const NetworkPackage& np);
+ virtual bool receivePackage(const Device&, const NetworkPackage& np);
private:
- static KNotification* createNotification(const NetworkPackage& np);
+ static KNotification* createNotification(const QString& deviceName,const NetworkPackage& np);
};
diff --git a/daemon/packagereceivers/packagereceiver.h b/daemon/packagereceivers/packagereceiver.h
index 525b6f4..35ef271 100644
--- a/daemon/packagereceivers/packagereceiver.h
+++ b/daemon/packagereceivers/packagereceiver.h
@@ -24,6 +24,7 @@
#include <QObject>
#include "networkpackage.h"
+#include "device.h"
class PackageReceiver
: public QObject
@@ -36,7 +37,7 @@ public:
public Q_SLOTS:
//Returns true if it has handled the package in some way
- virtual bool receivePackage(const NetworkPackage& np) = 0;
+ virtual bool receivePackage(const Device& device, const NetworkPackage& np) = 0;
};
#endif // PACKAGERECEIVER_H
diff --git a/daemon/packagereceivers/pausemusicpackagereceiver.cpp b/daemon/packagereceivers/pausemusicpackagereceiver.cpp
index 7a85d6f..90fda01 100644
--- a/daemon/packagereceivers/pausemusicpackagereceiver.cpp
+++ b/daemon/packagereceivers/pausemusicpackagereceiver.cpp
@@ -20,25 +20,49 @@
#include "pausemusicpackagereceiver.h"
+#include <QDebug>
+
PauseMusicPackageReceiver::PauseMusicPackageReceiver()
{
-
- pauseOnlyAfterAnswering = false;
+ //TODO: Be able to change this from settings
+ pauseWhen = PauseWhenTalking;
+ paused = false;
}
-bool PauseMusicPackageReceiver::receivePackage ( const NetworkPackage& np )
+bool PauseMusicPackageReceiver::receivePackage (const Device& device, const NetworkPackage& np)
{
+ Q_UNUSED(device);
+
+ bool pauseConditionFulfilled = false;
- if (np.get<QString>("eventType","") != "ring") return false; //TODO: Consider pauseOnlyAfterAnswering
+ //TODO: I have manually tested it and it works for both cases, but I should somehow write a test for this logic
+ if (pauseWhen == PauseWhenRinging) {
+ if (np.type() == PACKAGE_TYPE_NOTIFICATION) {
+ if (np.get<QString>("notificationType") != "ringing") return false;
+ pauseConditionFulfilled = !np.get<bool>("isCancel");
+ } else if (np.type() == PACKAGE_TYPE_CALL) {
+ pauseConditionFulfilled = !np.get<bool>("isCancel");
+ } else {
+ return false;
+ }
+ } else if (pauseWhen == PauseWhenTalking){
+ if (np.type() != PACKAGE_TYPE_CALL) return false;
+ pauseConditionFulfilled = !np.get<bool>("isCancel");
+ }
+
+ qDebug() << "PauseMusicPackageReceiver - PauseCondition:" << pauseConditionFulfilled;
- //TODO: Use KDE DBUS API
- if (np.get<QString>("eventDetails") == "hang") {
- system("qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play");
- } else {
+ if (pauseConditionFulfilled && !paused) {
+ //TODO: Use KDE DBUS API
system("qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause");
+ } if (!pauseConditionFulfilled && paused) {
+ //FIXME: Play does not work, using PlayPause
+ system("qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause");
}
+ paused = pauseConditionFulfilled;
+
return true;
}
diff --git a/daemon/packagereceivers/pausemusicpackagereceiver.h b/daemon/packagereceivers/pausemusicpackagereceiver.h
index 1f1ff2d..179ac8e 100644
--- a/daemon/packagereceivers/pausemusicpackagereceiver.h
+++ b/daemon/packagereceivers/pausemusicpackagereceiver.h
@@ -28,10 +28,12 @@ class PauseMusicPackageReceiver
{
public:
PauseMusicPackageReceiver();
- virtual bool receivePackage(const NetworkPackage& np);
+ virtual bool receivePackage(const Device& device, const NetworkPackage& np);
private:
- bool pauseOnlyAfterAnswering; //if set to false it will pause when ringing too
+ enum PauseCondtions { PauseWhenTalking, PauseWhenRinging, NeverPause };
+ PauseCondtions pauseWhen;
+ bool paused;
};
diff --git a/daemon/packagereceivers/notificationpackagereceiver.h b/daemon/packagereceivers/pingpackagereceiver.cpp
similarity index 59%
copy from daemon/packagereceivers/notificationpackagereceiver.h
copy to daemon/packagereceivers/pingpackagereceiver.cpp
index cb1117c..993fc39 100644
--- a/daemon/packagereceivers/notificationpackagereceiver.h
+++ b/daemon/packagereceivers/pingpackagereceiver.cpp
@@ -18,24 +18,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef NOTIFICATIONPACKAGERECEIVER_H
-#define NOTIFICATIONPACKAGERECEIVER_H
+#include "pingpackagereceiver.h"
-#include <knotification.h>
+#include <QDebug>
+#include <kicon.h>
-#include "packagereceiver.h"
+bool PingPackageReceiver::receivePackage(const Device& device, const NetworkPackage& np) {
-class NotificationPackageReceiver
- : public PackageReceiver
-{
+ qDebug() << np.type();
-public:
- virtual bool receivePackage(const NetworkPackage& np);
+ if (np.type() != PACKAGE_TYPE_PING) return false;
-private:
- static KNotification* createNotification(const NetworkPackage& np);
+ KNotification* notification = new KNotification("pingReceived"); //KNotification::Persistent
+ notification->setPixmap(KIcon("dialog-ok").pixmap(48, 48));
+ notification->setComponentData(KComponentData("kdeconnect", "kdeconnect"));
+ notification->setTitle("Ping!");
+ notification->setText(device.name());
+ notification->sendEvent();
+ return true;
-};
-
-#endif // NOTIFICATIONPACKAGERECEIVER_H
+}
diff --git a/daemon/packagereceivers/notificationpackagereceiver.h b/daemon/packagereceivers/pingpackagereceiver.h
similarity index 77%
copy from daemon/packagereceivers/notificationpackagereceiver.h
copy to daemon/packagereceivers/pingpackagereceiver.h
index cb1117c..841e7cc 100644
--- a/daemon/packagereceivers/notificationpackagereceiver.h
+++ b/daemon/packagereceivers/pingpackagereceiver.h
@@ -18,24 +18,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef NOTIFICATIONPACKAGERECEIVER_H
-#define NOTIFICATIONPACKAGERECEIVER_H
+#ifndef PINGPACKAGERECEIVER_H
+#define PINGPACKAGERECEIVER_H
#include <knotification.h>
#include "packagereceiver.h"
-class NotificationPackageReceiver
+class PingPackageReceiver
: public PackageReceiver
{
public:
- virtual bool receivePackage(const NetworkPackage& np);
-
-private:
- static KNotification* createNotification(const NetworkPackage& np);
-
+ virtual bool receivePackage(const Device& device, const NetworkPackage& np);
};
-#endif // NOTIFICATIONPACKAGERECEIVER_H
+#endif // PINGPACKAGERECEIVER_H
diff --git a/kcm/devicesmodel.cpp b/kcm/devicesmodel.cpp
index c6d4297..58f8344 100644
--- a/kcm/devicesmodel.cpp
+++ b/kcm/devicesmodel.cpp
@@ -47,6 +47,7 @@ DevicesModel::~DevicesModel()
void DevicesModel::deviceStatusChanged(const QString& id)
{
+ Q_UNUSED(id);
qDebug() << "deviceStatusChanged";
emit dataChanged(index(0),index(rowCount()));
}
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list