[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:28:25 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=8f77704

The following commit has been merged in the master branch:
commit 8f777040f7044d72bc491ce0e34fa6ef9fad2b03
Author: Aleix Pol <aleixpol at kde.org>
Date:   Tue Mar 24 12:26:37 2015 +0100

    Remove KNotifications dependency from libkdeconnectcore
    
    Moves the implementation into the actual daemon. This opens the
    possibility for different ways to expose these notifications depending on
    where the libkdeconnect will be deployed.
    
    REVIEW: 123076
---
 CMakeLists.txt                             |  2 +-
 core/CMakeLists.txt                        |  1 -
 core/daemon.cpp                            | 10 +++++++++
 core/daemon.h                              | 10 +++++++++
 core/device.cpp                            | 14 ++----------
 core/kdeconnectconfig.cpp                  | 11 +++++-----
 daemon/CMakeLists.txt                      |  4 +++-
 daemon/kdeconnectd.cpp                     | 34 +++++++++++++++++++++++++++++-
 plugins/battery/CMakeLists.txt             |  2 ++
 plugins/notifications/CMakeLists.txt       |  2 ++
 plugins/ping/CMakeLists.txt                |  2 ++
 plugins/screensaver-inhibit/CMakeLists.txt |  2 ++
 plugins/sftp/CMakeLists.txt                |  2 ++
 plugins/share/CMakeLists.txt               |  3 +++
 plugins/telephony/CMakeLists.txt           |  2 ++
 15 files changed, 79 insertions(+), 22 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 05a1b2c..516f517 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,7 @@ find_package(ECM 0.0.9 REQUIRED NO_MODULE)
 set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_SOURCE_DIR}/cmake)
 
 find_package(Qt5 5.2 REQUIRED COMPONENTS Quick Test)
-find_package(KF5 REQUIRED COMPONENTS I18n KIO Notifications ConfigWidgets DBusAddons KCMUtils IconThemes)
+find_package(KF5 REQUIRED COMPONENTS I18n KIO ConfigWidgets DBusAddons KCMUtils IconThemes)
 find_package(Qca-qt5 2.1.0 REQUIRED)
 
 include_directories(${CMAKE_SOURCE_DIR})
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index 2026317..623c637 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -41,7 +41,6 @@ PRIVATE
     Qt5::Gui
     KF5::I18n
     KF5::ConfigCore
-    KF5::Notifications
 )
 
 set_target_properties(kdeconnectcore PROPERTIES
diff --git a/core/daemon.cpp b/core/daemon.cpp
index 4e9cec4..ec1fee7 100644
--- a/core/daemon.cpp
+++ b/core/daemon.cpp
@@ -36,6 +36,8 @@
 #include "backends/devicelink.h"
 #include "backends/linkprovider.h"
 
+Q_GLOBAL_STATIC(Daemon*, s_instance)
+
 struct DaemonPrivate
 {
     //Different ways to find devices and connect to them
@@ -45,10 +47,18 @@ struct DaemonPrivate
     QMap<QString, Device*> mDevices;
 };
 
+Daemon* Daemon::instance()
+{
+    Q_ASSERT(s_instance.exists());
+    return *s_instance;
+}
+
 Daemon::Daemon(QObject *parent)
     : QObject(parent)
     , d(new DaemonPrivate)
 {
+    Q_ASSERT(!s_instance.exists());
+    *s_instance = this;
     qCDebug(KDECONNECT_CORE) << "KdeConnect daemon starting";
 
     //Load backends
diff --git a/core/daemon.h b/core/daemon.h
index 1817bdf..654441f 100644
--- a/core/daemon.h
+++ b/core/daemon.h
@@ -30,6 +30,7 @@
 class DaemonPrivate;
 class NetworkPackage;
 class DeviceLink;
+class Device;
 
 class KDECONNECTCORE_EXPORT Daemon
     : public QObject
@@ -42,6 +43,12 @@ public:
     ~Daemon();
 
 public Q_SLOTS:
+    /**
+     * Returns the daemon.
+     *
+     * Note this can't be called before constructing the Daemon.
+     */
+    static Daemon* instance();
 
     //After calling this, signal deviceDiscovered will be triggered for each device
     Q_SCRIPTABLE void setDiscoveryEnabled(bool b);
@@ -54,6 +61,9 @@ public Q_SLOTS:
     //Returns a list of ids. The respective devices can be manipulated using the dbus path: "/modules/kdeconnect/Devices/"+id
     Q_SCRIPTABLE QStringList devices(bool onlyReachable = false, bool onlyVisible = false) const;
 
+    virtual void requestPairing(Device *d) = 0;
+    virtual void reportError(const QString &title, const QString &description) = 0;
+
 Q_SIGNALS:
     Q_SCRIPTABLE void deviceAdded(const QString& id);
     Q_SCRIPTABLE void deviceRemoved(const QString& id); //Note that paired devices will never be removed
diff --git a/core/device.cpp b/core/device.cpp
index 96c62b5..c8a28bd 100644
--- a/core/device.cpp
+++ b/core/device.cpp
@@ -30,7 +30,6 @@
 
 #include <KSharedConfig>
 #include <KConfigGroup>
-#include <KNotification>
 #include <KLocalizedString>
 #include <QIcon>
 #include <QDir>
@@ -43,6 +42,7 @@
 #include "backends/linkprovider.h"
 #include "networkpackage.h"
 #include "kdeconnectconfig.h"
+#include "daemon.h"
 
 Q_LOGGING_CATEGORY(KDECONNECT_CORE, "kdeconnect.core")
 
@@ -352,21 +352,11 @@ void Device::privateReceivedPackage(const NetworkPackage& np)
                 setAsPaired();
 
             } else {
-
                 qCDebug(KDECONNECT_CORE) << "Pair request";
 
-                KNotification* notification = new KNotification("pairingRequest");
-                notification->setIconName(QStringLiteral("dialog-information"));
-                notification->setComponentName("kdeconnect");
-                notification->setText(i18n("Pairing request from %1", m_deviceName));
-                notification->setActions(QStringList() << i18n("Accept") << i18n("Reject"));
-                connect(notification, &KNotification::ignored, this, &Device::rejectPairing);
-                connect(notification, &KNotification::action1Activated, this, &Device::acceptPairing);
-                connect(notification, &KNotification::action2Activated, this, &Device::rejectPairing);
-                notification->sendEvent();
+                Daemon::instance()->requestPairing(this);
 
                 m_pairStatus = Device::RequestedByPeer;
-
             }
 
         } else {
diff --git a/core/kdeconnectconfig.cpp b/core/kdeconnectconfig.cpp
index 1356f43..d72fe95 100644
--- a/core/kdeconnectconfig.cpp
+++ b/core/kdeconnectconfig.cpp
@@ -20,7 +20,6 @@
 
 #include "kdeconnectconfig.h"
 
-#include <KNotification>
 #include <KLocalizedString>
 
 #include <QtCrypto>
@@ -37,6 +36,7 @@
 
 #include "core_debug.h"
 #include "dbushelper.h"
+#include "daemon.h"
 
 struct KdeConnectConfigPrivate {
 
@@ -61,9 +61,9 @@ KdeConnectConfig::KdeConnectConfig()
 {
     //qCDebug(KDECONNECT_CORE) << "QCA supported capabilities:" << QCA::supportedFeatures().join(",");
     if(!QCA::isSupported("rsa")) {
-        KNotification::event(KNotification::Error,
-                             QLatin1String("KDE Connect failed to start"), //Should not happen, not worth i18n
-                             QLatin1String("Could not find support for RSA in your QCA installation. If your"
+        Daemon::instance()->reportError(
+                             i18n("KDE Connect failed to start"),
+                             i18n("Could not find support for RSA in your QCA installation. If your"
                                   "distribution provides separate packages for QCA-ossl and QCA-gnupg,"
                                   "make sure you have them installed and try again."));
         return;
@@ -99,8 +99,7 @@ KdeConnectConfig::KdeConnectConfig()
         d->privateKey = QCA::KeyGenerator().createRSA(2048);
 
         if (!privKey.open(QIODevice::ReadWrite | QIODevice::Truncate))  {
-            KNotification::event(KNotification::StandardEvent::Error, QLatin1String("KDE Connect"),
-                                 i18n("Could not store private key file: %1", keyPath));
+            Daemon::instance()->reportError(QLatin1String("KDE Connect"), i18n("Could not store private key file: %1", keyPath));
         } else {
             privKey.setPermissions(strict);
             privKey.write(d->privateKey.toPEM().toLatin1());
diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt
index 8847c32..d3133a3 100644
--- a/daemon/CMakeLists.txt
+++ b/daemon/CMakeLists.txt
@@ -1,9 +1,11 @@
 project(kdeconnectd)
 
+find_package(KF5 REQUIRED COMPONENTS Notifications)
+
 add_definitions(-DTRANSLATION_DOMAIN="kdeconnect-daemon")
 
 add_executable(kdeconnectd kdeconnectd.cpp)
-target_link_libraries(kdeconnectd kdeconnectcore KF5::DBusAddons Qt5::Widgets)
+target_link_libraries(kdeconnectd kdeconnectcore KF5::DBusAddons KF5::Notifications KF5::I18n Qt5::Widgets)
 
 configure_file(kdeconnectd.desktop.cmake ${CMAKE_CURRENT_BINARY_DIR}/kdeconnectd.desktop)
 configure_file(org.kde.kdeconnect.service.in ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kdeconnect.service)
diff --git a/daemon/kdeconnectd.cpp b/daemon/kdeconnectd.cpp
index cb7de79..25632fd 100644
--- a/daemon/kdeconnectd.cpp
+++ b/daemon/kdeconnectd.cpp
@@ -27,8 +27,11 @@
 #include <QApplication>
 
 #include <KDBusService>
+#include <KNotification>
+#include <KLocalizedString>
 
 #include "core/daemon.h"
+#include "core/device.h"
 #include "kdeconnect-version.h"
 
 static int sigtermfd[2];
@@ -58,6 +61,33 @@ void initializeTermHandlers(QCoreApplication* app, Daemon* daemon)
     sigaction(SIGINT, &action, NULL);
 }
 
+class DesktopDaemon : public Daemon
+{
+    Q_OBJECT
+public:
+    DesktopDaemon(QObject* parent = Q_NULLPTR)
+        : Daemon(parent)
+    {}
+
+    void requestPairing(Device* d) Q_DECL_OVERRIDE
+    {
+        KNotification* notification = new KNotification("pairingRequest");
+        notification->setIconName(QStringLiteral("dialog-information"));
+        notification->setComponentName("kdeconnect");
+        notification->setText(i18n("Pairing request from %1", d->name()));
+        notification->setActions(QStringList() << i18n("Accept") << i18n("Reject"));
+        connect(notification, &KNotification::ignored, d, &Device::rejectPairing);
+        connect(notification, &KNotification::action1Activated, d, &Device::acceptPairing);
+        connect(notification, &KNotification::action2Activated, d, &Device::rejectPairing);
+        notification->sendEvent();
+    }
+
+    void reportError(const QString & title, const QString & description) Q_DECL_OVERRIDE
+    {
+        KNotification::event(KNotification::Error, title, description);
+    }
+};
+
 int main(int argc, char* argv[])
 {
     QApplication app(argc, argv);
@@ -68,9 +98,11 @@ int main(int argc, char* argv[])
 
     KDBusService dbusService(KDBusService::Unique);
 
-    Daemon* daemon = new Daemon(0);
+    Daemon* daemon = new DesktopDaemon;
     QObject::connect(daemon, SIGNAL(destroyed(QObject*)), &app, SLOT(quit()));
     initializeTermHandlers(&app, daemon);
 
     return app.exec();
 }
+
+#include "kdeconnectd.moc"
diff --git a/plugins/battery/CMakeLists.txt b/plugins/battery/CMakeLists.txt
index f6a6c5b..15b697a 100644
--- a/plugins/battery/CMakeLists.txt
+++ b/plugins/battery/CMakeLists.txt
@@ -1,3 +1,5 @@
+find_package(KF5 REQUIRED COMPONENTS Notifications)
+
 set(kdeconnect_battery_SRCS
     batteryplugin.cpp
     batterydbusinterface.cpp
diff --git a/plugins/notifications/CMakeLists.txt b/plugins/notifications/CMakeLists.txt
index 565bf7f..341381a 100644
--- a/plugins/notifications/CMakeLists.txt
+++ b/plugins/notifications/CMakeLists.txt
@@ -1,3 +1,5 @@
+find_package(KF5 REQUIRED COMPONENTS Notifications)
+
 set(kdeconnect_notifications_SRCS
     notification.cpp
     notificationsplugin.cpp
diff --git a/plugins/ping/CMakeLists.txt b/plugins/ping/CMakeLists.txt
index 15daa70..e50f88f 100644
--- a/plugins/ping/CMakeLists.txt
+++ b/plugins/ping/CMakeLists.txt
@@ -1,3 +1,5 @@
+find_package(KF5 REQUIRED COMPONENTS Notifications)
+
 set(kdeconnect_ping_SRCS
     pingplugin.cpp
 )
diff --git a/plugins/screensaver-inhibit/CMakeLists.txt b/plugins/screensaver-inhibit/CMakeLists.txt
index 8936930..10a0928 100644
--- a/plugins/screensaver-inhibit/CMakeLists.txt
+++ b/plugins/screensaver-inhibit/CMakeLists.txt
@@ -1,3 +1,5 @@
+find_package(KF5 REQUIRED COMPONENTS Notifications)
+
 set(kdeconnect_screensaver_inhibit_SRCS
     screensaverinhibitplugin.cpp
 )
diff --git a/plugins/sftp/CMakeLists.txt b/plugins/sftp/CMakeLists.txt
index cecedf8..3407031 100644
--- a/plugins/sftp/CMakeLists.txt
+++ b/plugins/sftp/CMakeLists.txt
@@ -1,3 +1,5 @@
+find_package(KF5 REQUIRED COMPONENTS Notifications)
+
 set(kdeconnect_sftp_SRCS
     mounter.cpp
     mountloop.cpp
diff --git a/plugins/share/CMakeLists.txt b/plugins/share/CMakeLists.txt
index fed160c..fa70800 100644
--- a/plugins/share/CMakeLists.txt
+++ b/plugins/share/CMakeLists.txt
@@ -1,3 +1,5 @@
+find_package(KF5 REQUIRED COMPONENTS Notifications)
+
 set(kdeconnect_share_SRCS
     shareplugin.cpp
     autoclosingqfile.cpp
@@ -27,6 +29,7 @@ target_link_libraries( kdeconnect_share_config
     KF5::CoreAddons
     KF5::ConfigWidgets
     KF5::KIOWidgets
+    KF5::Notifications
 )
 
 install(TARGETS kdeconnect_share_config DESTINATION ${PLUGIN_INSTALL_DIR} )
diff --git a/plugins/telephony/CMakeLists.txt b/plugins/telephony/CMakeLists.txt
index 9ec3027..c6ef824 100644
--- a/plugins/telephony/CMakeLists.txt
+++ b/plugins/telephony/CMakeLists.txt
@@ -1,3 +1,5 @@
+find_package(KF5 REQUIRED COMPONENTS Notifications)
+
 set(kdeconnect_telephony_SRCS
     telephonyplugin.cpp
 )

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list