[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:26:41 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=3eb6eca
The following commit has been merged in the master branch:
commit 3eb6ecaa3f70e326afcab163af84059a463a2824
Author: Albert Vaca <albertvaka at gmail.com>
Date: Sun Jul 28 22:00:45 2013 +0200
Implemented batterypackageinterface
Fixed CMake macro
---
daemon/CMakeLists.txt | 37 ++++++++++++++++++----
daemon/daemon.cpp | 2 +-
daemon/device.cpp | 13 ++++++--
daemon/device.h | 7 +++-
.../packageinterfaces/batterypackageinterface.cpp | 37 +++++++++++++++++++---
daemon/packageinterfaces/batterypackageinterface.h | 16 ++++++++--
.../packageinterfaces/devicebatteryinformation_p.h | 10 +++---
daemon/packageinterfaces/packageinterface.cpp | 3 +-
daemon/packageinterfaces/packageinterface.h | 2 +-
kcm/CMakeLists.txt | 5 ++-
10 files changed, 105 insertions(+), 27 deletions(-)
diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt
index ce393c1..4e1d64a 100644
--- a/daemon/CMakeLists.txt
+++ b/daemon/CMakeLists.txt
@@ -33,17 +33,35 @@ target_link_libraries(kded_kdeconnect
${QJSON_LIBRARY}
)
-macro (generate_and_install_dbus_interface project_main_target header_file output_xml_file) #OPTIONS qdbus_options
- QT4_EXTRACT_OPTIONS(extra_files_ignore qdbus_options ${ARGN})
- qt4_generate_dbus_interface(${header_file} ${output_xml_file} OPTIONS ${qdbus_options})
- add_dependencies(${project_main_target} ${output_xml_file})
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${output_xml_file} DESTINATION ${DBUS_INTERFACES_INSTALL_DIR})
+macro (generate_and_install_dbus_interface main_project_target header_file output_xml_file) #OPTIONS qdbus_options
+ QT4_EXTRACT_OPTIONS(
+ extra_files_ignore
+ qdbus_options
+ ${ARGN}
+ )
+ qt4_generate_dbus_interface(
+ ${header_file}
+ ${output_xml_file}
+ OPTIONS ${qdbus_options}
+ )
+ add_custom_target(
+ ${output_xml_file}
+ SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${output_xml_file}
+ )
+ install(
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/${output_xml_file}
+ DESTINATION ${DBUS_INTERFACES_INSTALL_DIR}
+ )
+ add_dependencies(
+ ${main_project_target}
+ ${output_xml_file}
+ )
endmacro (generate_and_install_dbus_interface)
generate_and_install_dbus_interface(
kded_kdeconnect
daemon.h
- org.kde.kdeconnect.xml
+ org.kde.kdeconnect.daemon.xml
OPTIONS -a
)
@@ -61,6 +79,13 @@ generate_and_install_dbus_interface(
OPTIONS -a
)
+generate_and_install_dbus_interface(
+ kded_kdeconnect
+ packageinterfaces/batterypackageinterface.h
+ org.kde.kdeconnect.battery.xml
+ OPTIONS -a
+)
+
install(TARGETS kded_kdeconnect DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES kdeconnect.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded)
install(FILES kdeconnect.notifyrc DESTINATION ${DATA_INSTALL_DIR}/kdeconnect)
diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp
index 01171c8..244866e 100644
--- a/daemon/daemon.cpp
+++ b/daemon/daemon.cpp
@@ -64,7 +64,7 @@ Daemon::Daemon(QObject *parent, const QList<QVariant>&)
mPackageInterfaces.push_back(new NotificationPackageInterface());
mPackageInterfaces.push_back(new PauseMusicPackageInterface());
mPackageInterfaces.push_back(new ClipboardPackageInterface());
- mPackageInterfaces.push_back(new BatteryPackageInterface());
+ mPackageInterfaces.push_back(new BatteryPackageInterface(this));
//TODO: Do not hardcode the load of the device locators
//use: https://techbase.kde.org/Development/Tutorials/Services/Plugins
diff --git a/daemon/device.cpp b/daemon/device.cpp
index e158dbf..40bede5 100644
--- a/daemon/device.cpp
+++ b/daemon/device.cpp
@@ -77,6 +77,11 @@ void Device::addLink(DeviceLink* link)
connect(link, SIGNAL(receivedPackage(NetworkPackage)), this, SLOT(privateReceivedPackage(NetworkPackage)));
qSort(m_deviceLinks.begin(),m_deviceLinks.end(),lessThan);
+
+ if (m_deviceLinks.size() == 1) {
+ emit reachableStatusChanged();
+ }
+
}
void Device::linkDestroyed(QObject* o)
@@ -87,9 +92,13 @@ void Device::linkDestroyed(QObject* o)
void Device::removeLink(DeviceLink* link)
{
- qDebug() << "RemoveLink";
- //disconnect(link, SIGNAL(receivedPackage(NetworkPackage)), this, SLOT(privateReceivedPackage(NetworkPackage)));
m_deviceLinks.removeOne(link);
+
+ qDebug() << "RemoveLink"<< m_deviceLinks.size() << "links remaining";
+
+ if (m_deviceLinks.empty()) {
+ emit reachableStatusChanged();
+ }
}
bool Device::sendPackage(const NetworkPackage& np)
diff --git a/daemon/device.h b/daemon/device.h
index a0f279c..77b9c5b 100644
--- a/daemon/device.h
+++ b/daemon/device.h
@@ -29,7 +29,8 @@
class DeviceLink;
-class Device : public QObject
+class Device
+ : public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device")
@@ -55,6 +56,7 @@ public:
void addLink(DeviceLink*);
void removeLink(DeviceLink*);
+
//Send and receive
Q_SIGNALS:
void receivedPackage(const Device& device, const NetworkPackage& np);
@@ -69,6 +71,9 @@ public Q_SLOTS:
Q_SCRIPTABLE void setPair(bool b);
Q_SCRIPTABLE void sendPing();
+Q_SIGNALS:
+ void reachableStatusChanged();
+
private Q_SLOTS:
void linkDestroyed(QObject* o = 0);
void privateReceivedPackage(const NetworkPackage& np);
diff --git a/daemon/packageinterfaces/batterypackageinterface.cpp b/daemon/packageinterfaces/batterypackageinterface.cpp
index ec4a1a5..0478364 100644
--- a/daemon/packageinterfaces/batterypackageinterface.cpp
+++ b/daemon/packageinterfaces/batterypackageinterface.cpp
@@ -24,9 +24,17 @@
#include <kicon.h>
-BatteryPackageInterface::BatteryPackageInterface()
+BatteryPackageInterface::BatteryPackageInterface(QObject* parent)
+ : PackageInterface(parent)
{
//TODO: Get initial state of all devices
+
+ QDBusConnection::sessionBus().registerObject("/modules/kdeconnect/plugins/battery", this, QDBusConnection::ExportScriptableContents);
+ //The solid backend watches for this service to become available, because it is not possible to watch for a path
+ QDBusConnection::sessionBus().registerService("org.kde.kdeconnect.battery");
+
+ qDebug() << "BatteryPackageInterface registered in dbus";
+
}
bool BatteryPackageInterface::receivePackage(const Device& device, const NetworkPackage& np)
@@ -35,23 +43,42 @@ bool BatteryPackageInterface::receivePackage(const Device& device, const Network
QString id = device.id();
- if (!devices.contains(id)) {
+ if (!mDevices.contains(id)) {
//TODO: Avoid ugly const_cast
DeviceBatteryInformation* deviceInfo = new DeviceBatteryInformation(const_cast<Device*>(&device));
- devices[id] = deviceInfo;
+ mDevices[id] = deviceInfo;
+
+ emit batteryDeviceAdded(device.id());
+ connect(&device, SIGNAL(reachableStatusChanged()), this, SLOT(deviceReachableStatusChange()));
qDebug() << "Added battery info to device" << id;
}
bool isCharging = np.get<bool>("isCharging");
- devices[id]->setCharging(isCharging);
+ mDevices[id]->setCharging(isCharging);
int currentCharge = np.get<int>("currentCharge");
- devices[id]->setCharge(currentCharge);
+ mDevices[id]->setCharge(currentCharge);
return true;
}
+
+QStringList BatteryPackageInterface::getBatteryReportingDevices()
+{
+ return mDevices.keys();
+}
+
+void BatteryPackageInterface::deviceReachableStatusChange()
+{
+ Device* device = static_cast<Device*>(sender());
+ if (!device->reachable()) {
+ mDevices.remove(device->id());
+ emit batteryDeviceLost(device->id());
+ disconnect(device, SIGNAL(reachableStatusChanged()), this, SLOT(deviceReachableStatusChange()));
+ }
+}
+
diff --git a/daemon/packageinterfaces/batterypackageinterface.h b/daemon/packageinterfaces/batterypackageinterface.h
index f2d5afe..4d2fa8e 100644
--- a/daemon/packageinterfaces/batterypackageinterface.h
+++ b/daemon/packageinterfaces/batterypackageinterface.h
@@ -24,20 +24,32 @@
#include <knotification.h>
#include "packageinterface.h"
+#include <QDBusAbstractAdaptor>
#include "devicebatteryinformation_p.h"
class BatteryPackageInterface
: public PackageInterface
{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.battery")
public:
- BatteryPackageInterface();
+ BatteryPackageInterface(QObject* parent);
virtual bool receivePackage(const Device&, const NetworkPackage& np);
private:
- QHash<QString,DeviceBatteryInformation*> devices;
+ QHash<QString,DeviceBatteryInformation*> mDevices;
+public Q_SLOTS:
+ Q_SCRIPTABLE QStringList getBatteryReportingDevices();
+
+Q_SIGNALS:
+ Q_SCRIPTABLE void batteryDeviceAdded(const QString& id);
+ Q_SCRIPTABLE void batteryDeviceLost(const QString& id);
+
+public slots:
+ void deviceReachableStatusChange();
};
#endif
diff --git a/daemon/packageinterfaces/devicebatteryinformation_p.h b/daemon/packageinterfaces/devicebatteryinformation_p.h
index 1b2bda1..8f0dfab 100644
--- a/daemon/packageinterfaces/devicebatteryinformation_p.h
+++ b/daemon/packageinterfaces/devicebatteryinformation_p.h
@@ -28,24 +28,24 @@ class DeviceBatteryInformation
: public QDBusAbstractAdaptor
{
Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.battery")
- Q_PROPERTY( int charge READ charge )
+ Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.battery")
+ Q_PROPERTY( int charge READ charge NOTIFY chargingChange )
Q_PROPERTY( bool isCharging READ isCharging NOTIFY chargingChange )
public:
DeviceBatteryInformation(QObject* parent = 0);
int charge() { return mCharge; }
- void setCharge(int charge) { mCharge = charge; }
+ void setCharge(int charge) { mCharge = charge; emit chargingChange(); }
bool isCharging() { return mIsCharging; }
- void setCharging(bool isCharging) { mIsCharging = isCharging; }
+ void setCharging(bool isCharging) { mIsCharging = isCharging; emit chargingChange(); }
private:
bool mIsCharging;
int mCharge;
Q_SIGNALS:
- Q_SCRIPTABLE void chargingChange(bool charging);
+ Q_SCRIPTABLE void chargingChange();
};
diff --git a/daemon/packageinterfaces/packageinterface.cpp b/daemon/packageinterfaces/packageinterface.cpp
index d1f75cb..b5f5f72 100644
--- a/daemon/packageinterfaces/packageinterface.cpp
+++ b/daemon/packageinterfaces/packageinterface.cpp
@@ -20,7 +20,8 @@
#include "packageinterface.h"
-PackageInterface::PackageInterface()
+PackageInterface::PackageInterface(QObject* parent)
+ : QObject(parent)
{
//gcc complains if we don't add something to compile on a class with virtual functions
}
diff --git a/daemon/packageinterfaces/packageinterface.h b/daemon/packageinterfaces/packageinterface.h
index 89f2be9..9578cc0 100644
--- a/daemon/packageinterfaces/packageinterface.h
+++ b/daemon/packageinterfaces/packageinterface.h
@@ -32,7 +32,7 @@ class PackageInterface
Q_OBJECT
public:
- PackageInterface();
+ PackageInterface(QObject* parent = 0);
virtual ~PackageInterface() { }
public Q_SLOTS:
diff --git a/kcm/CMakeLists.txt b/kcm/CMakeLists.txt
index 2c15af2..8b5ed0a 100644
--- a/kcm/CMakeLists.txt
+++ b/kcm/CMakeLists.txt
@@ -7,7 +7,7 @@ set(kcm_SRCS devicesmodel.cpp
qt4_add_dbus_interface(
kcm_SRCS
- ${CMAKE_BINARY_DIR}/daemon/org.kde.kdeconnect.xml
+ ${CMAKE_BINARY_DIR}/daemon/org.kde.kdeconnect.daemon.xml
daemoninterface
)
@@ -29,9 +29,8 @@ target_link_libraries(kcm_kdeconnect
)
add_dependencies(kcm_kdeconnect
- org.kde.kdeconnect.xml
+ org.kde.kdeconnect.daemon.xml
org.kde.kdeconnect.device.xml
- org.kde.kdeconnect.device.battery.xml
)
install(TARGETS kcm_kdeconnect DESTINATION ${PLUGIN_INSTALL_DIR})
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list