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

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


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

The following commit has been merged in the master branch:
commit 0779377337f7001280304c02ceb98faabf7e3b4f
Author: Pramod Dematagoda <pmdematagoda at mykolab.ch>
Date:   Mon Dec 29 00:03:41 2014 -0800

    Added a plugin to inhibit the screensaver when a device is connected.
    
    The inhibition is lifted when the plugin disconnects.
    
    REVIEW: 121692
---
 plugins/CMakeLists.txt                             |  1 +
 plugins/screensaver-inhibit/CMakeLists.txt         | 10 +++
 plugins/screensaver-inhibit/README                 |  3 +
 .../kdeconnect_screensaver_inhibit.desktop         | 15 +++++
 .../screensaverinhibitplugin.cpp                   | 78 ++++++++++++++++++++++
 .../screensaverinhibitplugin.h}                    | 22 +++---
 6 files changed, 116 insertions(+), 13 deletions(-)

diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index de1131d..ed1efe0 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -11,6 +11,7 @@ add_subdirectory(mousepad)
 add_subdirectory(share)
 add_subdirectory(notifications)
 add_subdirectory(sftp)
+add_subdirectory(screensaver-inhibit)
 
 #FIXME: If we split notifications in several files, they won't appear in the same group in the Notifications KCM
 install(FILES kdeconnect.notifyrc DESTINATION ${DATA_INSTALL_DIR}/kdeconnect)
diff --git a/plugins/screensaver-inhibit/CMakeLists.txt b/plugins/screensaver-inhibit/CMakeLists.txt
new file mode 100644
index 0000000..2f0d56d
--- /dev/null
+++ b/plugins/screensaver-inhibit/CMakeLists.txt
@@ -0,0 +1,10 @@
+set(kdeconnect_screensaver_inhibit_SRCS
+    screensaverinhibitplugin.cpp
+)
+
+kde4_add_plugin(kdeconnect_screensaver_inhibit ${kdeconnect_screensaver_inhibit_SRCS})
+
+target_link_libraries(kdeconnect_screensaver_inhibit kdeconnectcore ${KDE4_KDEUI_LIBS})
+
+install(TARGETS kdeconnect_screensaver_inhibit DESTINATION ${PLUGIN_INSTALL_DIR} )
+install(FILES kdeconnect_screensaver_inhibit.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
diff --git a/plugins/screensaver-inhibit/README b/plugins/screensaver-inhibit/README
new file mode 100644
index 0000000..9f1b7ee
--- /dev/null
+++ b/plugins/screensaver-inhibit/README
@@ -0,0 +1,3 @@
+This plugin inhibits the screensaver from kicking in when the device is connected
+to kdeconnect, it then uninhibits the screensaver if the device was to go out of
+range or be disconnected.
\ No newline at end of file
diff --git a/plugins/screensaver-inhibit/kdeconnect_screensaver_inhibit.desktop b/plugins/screensaver-inhibit/kdeconnect_screensaver_inhibit.desktop
new file mode 100644
index 0000000..80f7279
--- /dev/null
+++ b/plugins/screensaver-inhibit/kdeconnect_screensaver_inhibit.desktop
@@ -0,0 +1,15 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Service
+ServiceTypes=KdeConnect/Plugin
+X-KDE-Library=kdeconnect_screensaver_inhibit
+X-KDE-PluginInfo-Author=Pramod Dematagoda
+X-KDE-PluginInfo-Email=pmdematagoda at mykolab.ch
+X-KDE-PluginInfo-Name=kdeconnect_screensaver_inhibit
+X-KDE-PluginInfo-Version=0.1
+X-KDE-PluginInfo-Website=http://albertvaka.wordpress.com
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=false
+Icon=preferences-desktop-screensaver
+Name=Inhibit screensaver
+Comment=Inhibit the screensaver when the device is connected
\ No newline at end of file
diff --git a/plugins/screensaver-inhibit/screensaverinhibitplugin.cpp b/plugins/screensaver-inhibit/screensaverinhibitplugin.cpp
new file mode 100644
index 0000000..85ac199
--- /dev/null
+++ b/plugins/screensaver-inhibit/screensaverinhibitplugin.cpp
@@ -0,0 +1,78 @@
+/**
+ * Copyright 2014 Pramod Dematagoda <pmdematagoda at mykolab.ch>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License or (at your option) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "screensaverinhibitplugin.h"
+
+#include <KNotification>
+#include <KIcon>
+#include <KLocalizedString>
+
+#include <core/kdebugnamespace.h>
+#include <core/device.h>
+#include <QDBusConnection>
+#include <QDBusInterface>
+
+K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< ScreensaverInhibitPlugin >(); )
+K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_screensaver_inhibit", "kdeconnect-plugins") )
+
+const QString INHIBIT_SERVICE = "org.freedesktop.ScreenSaver";
+const QString INHIBIT_INTERFACE = INHIBIT_SERVICE;
+const QString INHIBIT_PATH = "/ScreenSaver";
+const QString INHIBIT_METHOD = "Inhibit";
+const QString UNINHIBIT_METHOD = "UnInhibit";
+const QString SIMULATE_ACTIVITY_METHOD = "SimulateUserActivity";
+
+ScreensaverInhibitPlugin::ScreensaverInhibitPlugin(QObject* parent, const QVariantList& args)
+    : KdeConnectPlugin(parent, args)
+{
+     QDBusInterface inhibitInterface(INHIBIT_SERVICE, INHIBIT_PATH, INHIBIT_INTERFACE);
+
+     QDBusMessage reply = inhibitInterface.call(INHIBIT_METHOD, "kdeconnect", "Phone is connected");
+
+     if (reply.errorMessage() != NULL) {
+	    kDebug(debugArea()) << "Unable to inhibit the screensaver: " << reply.errorMessage();
+     } else {
+	    // Store the cookie we receive, this will be sent back when sending the uninhibit call.
+	    this->inhibitCookie = reply.arguments().first().toUInt();
+     }
+}
+
+ScreensaverInhibitPlugin::~ScreensaverInhibitPlugin()
+{
+      QDBusInterface inhibitInterface(INHIBIT_SERVICE, INHIBIT_PATH, INHIBIT_INTERFACE);
+      inhibitInterface.call(UNINHIBIT_METHOD, this->inhibitCookie);
+
+      /*
+       * Simulate user activity because what ever manages the screensaver does not seem to start the timer
+       * automatically when all inhibitions are lifted and the user does nothing which results in an
+       * unlocked desktop which would be dangerous. Ideally we should not be doing this and the screen should
+       * be locked anyway.
+       */
+      inhibitInterface.call(SIMULATE_ACTIVITY_METHOD);
+}
+
+void ScreensaverInhibitPlugin::connected()
+{}
+
+bool ScreensaverInhibitPlugin::receivePackage(const NetworkPackage& np)
+{
+      return false;
+}
+
diff --git a/plugins/telephony/telephonyplugin.h b/plugins/screensaver-inhibit/screensaverinhibitplugin.h
similarity index 70%
copy from plugins/telephony/telephonyplugin.h
copy to plugins/screensaver-inhibit/screensaverinhibitplugin.h
index 1b11ad2..460ac60 100644
--- a/plugins/telephony/telephonyplugin.h
+++ b/plugins/screensaver-inhibit/screensaverinhibitplugin.h
@@ -1,5 +1,5 @@
 /**
- * Copyright 2013 Albert Vaca <albertvaka at gmail.com>
+ * Copyright 2014 Pramod Dematagoda <pmdematagoda at mykolab.ch>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -18,32 +18,28 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef TELEPHONYPLUGIN_H
-#define TELEPHONYPLUGIN_H
+#ifndef SCREENSAVERINHIBITPLUGIN_H
+#define SCREENSAVERINHIBITPLUGIN_H
 
-#include <knotification.h>
+#include <QObject>
 
 #include <core/kdeconnectplugin.h>
 
-#include <KStatusNotifierItem>
-
-#define PACKAGE_TYPE_TELEPHONY QLatin1String("kdeconnect.telephony")
-
-class TelephonyPlugin
+class KDE_EXPORT ScreensaverInhibitPlugin
     : public KdeConnectPlugin
 {
     Q_OBJECT
 
 public:
-    explicit TelephonyPlugin(QObject *parent, const QVariantList &args);
+    explicit ScreensaverInhibitPlugin(QObject *parent, const QVariantList &args);
+    virtual ~ScreensaverInhibitPlugin();
 
 public Q_SLOTS:
     virtual bool receivePackage(const NetworkPackage& np);
-    virtual void connected() { }
+    virtual void connected();
 
 private:
-    KNotification* createNotification(const NetworkPackage& np);
-
+    uint inhibitCookie;
 };
 
 #endif

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list