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

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:26:49 UTC 2016


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

The following commit has been merged in the master branch:
commit e91300d8e90bd35ef883c4f346aa8cc6954e49e8
Author: Albert Vaca <albertvaka at gmail.com>
Date:   Tue Aug 20 13:55:03 2013 +0200

    Ooops missing files from last commit
---
 .../notification.cpp}                              |  32 +++---
 .../notification.h}                                |  45 +++++---
 .../notifications/notificationsdbusinterface.cpp   | 118 +++++++++++++++++++++
 .../notifications/notificationsdbusinterface.h     |  65 ++++++++++++
 4 files changed, 231 insertions(+), 29 deletions(-)

diff --git a/daemon/plugins/battery/batterydbusinterface.cpp b/daemon/plugins/notifications/notification.cpp
similarity index 59%
copy from daemon/plugins/battery/batterydbusinterface.cpp
copy to daemon/plugins/notifications/notification.cpp
index 4efdd37..501fa04 100644
--- a/daemon/plugins/battery/batterydbusinterface.cpp
+++ b/daemon/plugins/notifications/notification.cpp
@@ -1,5 +1,6 @@
-/**
- * Copyright 2013 Albert Vaca <albertvaka at gmail.com>
+/*
+ * <one line to give the library's name and an idea of what it does.>
+ * Copyright 2013  <copyright holder> <email>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -16,28 +17,31 @@
  *
  * 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 "batterydbusinterface.h"
+#include "notification.h"
 
+#include <QDBusConnection>
 #include <QDebug>
 
-BatteryDbusInterface::BatteryDbusInterface(QObject *parent)
-    : QDBusAbstractAdaptor(parent)
+Notification::Notification(const NetworkPackage& np, QObject* parent)
+    : QObject(parent)
 {
+    mId = np.get<QString>("id");
+    mAppName = np.get<QString>("appName");
+    mTicker = np.get<QString>("ticker");
+    mDismissable = np.get<bool>("isClearable");
 }
 
-BatteryDbusInterface::~BatteryDbusInterface()
+Notification::~Notification()
 {
-    qDebug() << "Destroying BatteryDbusInterface";
+    qDebug() << "Destroying notification" << mId;
 }
 
-void BatteryDbusInterface::updateValues(bool isCharging, int currentCharge)
+void Notification::dismiss()
 {
-    mIsCharging = isCharging;
-    mCharge = currentCharge;
-
-    Q_EMIT chargingChange();
+    if (mDismissable) {
+        Q_EMIT dismissRequested(this);
+    }
 }
-
-
diff --git a/daemon/plugins/clipboard/clipboardplugin.h b/daemon/plugins/notifications/notification.h
similarity index 50%
copy from daemon/plugins/clipboard/clipboardplugin.h
copy to daemon/plugins/notifications/notification.h
index 3d06564..50898e7 100644
--- a/daemon/plugins/clipboard/clipboardplugin.h
+++ b/daemon/plugins/notifications/notification.h
@@ -1,5 +1,6 @@
-/**
- * Copyright 2013 Albert Vaca <albertvaka at gmail.com>
+/*
+ * <one line to give the library's name and an idea of what it does.>
+ * Copyright 2013  <copyright holder> <email>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -16,35 +17,49 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
  */
 
-#ifndef CLIPBOARDPLUGIN_H
-#define CLIPBOARDPLUGIN_H
+#ifndef NOTIFICATION_H
+#define NOTIFICATION_H
 
 #include <QObject>
-#include <QClipboard>
+#include <QString>
 
-#include "../kdeconnectplugin.h"
 #include "../../networkpackage.h"
-#include "../../device.h"
 
-class ClipboardPlugin
-    : public KdeConnectPlugin
+class Notification
+    : public QObject
 {
     Q_OBJECT
+    Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.notifications.notification")
+    Q_PROPERTY(QString internalId READ internalId)
+    Q_PROPERTY(QString appName READ appName)
+    Q_PROPERTY(QString ticker READ ticker)
+    Q_PROPERTY(QString dismissable READ dismissable)
 
 public:
-    explicit ClipboardPlugin(QObject *parent, const QVariantList &args);
+    Notification(const NetworkPackage& np, QObject* parent);
+    virtual ~Notification();
+
+    QString internalId() { return mId; }
+    QString appName() { return mAppName; }
+    QString ticker() { return mTicker; }
+    bool dismissable() { return mDismissable; }
 
 public Q_SLOTS:
-    virtual bool receivePackage(const NetworkPackage& np);
+    Q_SCRIPTABLE void dismiss();
 
-private Q_SLOTS:
-    void clipboardChanged(QClipboard::Mode mode);
+Q_SIGNALS:
+    void dismissRequested(Notification* self);
 
 private:
-    bool ignore_next_clipboard_change;
-    QClipboard *clipboard;
+    QString mId;
+    QString mAppName;
+    QString mTicker;
+    //QIcon mIcon;
+    bool mDismissable;
+
 };
 
 #endif
diff --git a/daemon/plugins/notifications/notificationsdbusinterface.cpp b/daemon/plugins/notifications/notificationsdbusinterface.cpp
new file mode 100644
index 0000000..e3a578d
--- /dev/null
+++ b/daemon/plugins/notifications/notificationsdbusinterface.cpp
@@ -0,0 +1,118 @@
+/**
+ * Copyright 2013 Albert Vaca <albertvaka at gmail.com>
+ *
+ * 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 "notificationsdbusinterface.h"
+
+#include <QDebug>
+#include <QDBusConnection>
+
+NotificationsDbusInterface::NotificationsDbusInterface(Device* device, QObject *parent)
+    : QDBusAbstractAdaptor(parent)
+    , mDevice(device)
+    , mLastId(0)
+{
+
+}
+
+NotificationsDbusInterface::~NotificationsDbusInterface()
+{
+    qDeleteAll(mNotifications);
+}
+
+QStringList NotificationsDbusInterface::activeNotifications()
+{
+    return mNotifications.keys();
+}
+
+void NotificationsDbusInterface::processPackage(const NetworkPackage& np)
+{
+    if (np.get<bool>("isCancel")) {
+        removeNotification(np.get<QString>("id"));
+    } else {
+        Notification* noti = new Notification(np, this);
+        addNotification(noti);
+    }
+}
+
+void NotificationsDbusInterface::addNotification(Notification* noti)
+{
+    const QString& internalId = noti->internalId();
+
+    if (mInternalIdToPublicId.contains(internalId)) {
+        removeNotification(internalId);
+    }
+
+    connect(noti, SIGNAL(dismissRequested(Notification*)),
+            this, SLOT(dismissRequested(Notification*)));
+
+    const QString& publicId = newId();
+    mNotifications[publicId] = noti;
+    mInternalIdToPublicId[internalId] = publicId;
+
+    QDBusConnection::sessionBus().registerObject(mDevice->dbusPath()+"/notifications/"+publicId, noti, QDBusConnection::ExportScriptableContents);
+    Q_EMIT notificationPosted(publicId);
+}
+
+void NotificationsDbusInterface::removeNotification(const QString& internalId)
+{
+    qDebug() << "removeNotification" << internalId;
+
+    if (!mInternalIdToPublicId.contains(internalId)) {
+        qDebug() << "Not found";
+        return;
+    }
+
+    QString publicId = mInternalIdToPublicId[internalId];
+    mInternalIdToPublicId.remove(internalId);
+
+    if (!mNotifications.contains(publicId)) {
+        qDebug() << "Not found";
+        return;
+    }
+
+    Notification* noti = mNotifications[publicId];
+    mNotifications.remove(publicId);
+
+    //Deleting the notification will unregister it automatically?
+    //QDBusConnection::sessionBus().unregisterObject(mDevice->dbusPath()+"/notifications/"+publicId);
+    noti->deleteLater();
+
+    Q_EMIT notificationRemoved(publicId);
+
+}
+
+void NotificationsDbusInterface::dismissRequested(Notification* notification)
+{
+    const QString& internalId = notification->internalId();
+
+    NetworkPackage np(PACKAGE_TYPE_NOTIFICATION);
+    np.set<QString>("cancel", internalId);
+    mDevice->sendPackage(np);
+
+    //This should be called automatically back from server
+    //removeNotification(internalId);
+}
+
+QString NotificationsDbusInterface::newId()
+{
+    return QString::number(++mLastId);
+}
+
+
diff --git a/daemon/plugins/notifications/notificationsdbusinterface.h b/daemon/plugins/notifications/notificationsdbusinterface.h
new file mode 100644
index 0000000..cd722ab
--- /dev/null
+++ b/daemon/plugins/notifications/notificationsdbusinterface.h
@@ -0,0 +1,65 @@
+/**
+ * Copyright 2013 Albert Vaca <albertvaka at gmail.com>
+ *
+ * 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/>.
+ */
+
+#ifndef NOTIFICATIONSDBUSINTERFACE_H
+#define NOTIFICATIONSDBUSINTERFACE_H
+
+#include <QDBusAbstractAdaptor>
+#include <QHash>
+#include <QString>
+#include <QStringList>
+
+#include "../../device.h"
+#include "notification.h"
+
+class NotificationsDbusInterface
+    : public QDBusAbstractAdaptor
+{
+    Q_OBJECT
+    Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.notifications")
+
+public:
+    explicit NotificationsDbusInterface(Device* device, QObject *parent);
+    virtual ~NotificationsDbusInterface();
+
+    void processPackage(const NetworkPackage& np);
+
+public Q_SLOTS:
+    Q_SCRIPTABLE QStringList activeNotifications();
+    void dismissRequested(Notification* notification);
+
+Q_SIGNALS:
+    void notificationPosted(const QString& publicId);
+    void notificationRemoved(const QString& publicId);
+
+private /*methods*/:
+    void addNotification(Notification* noti);
+    void removeNotification(const QString& internalId);
+    QString newId(); //Generates successive identifitiers to use as public ids
+
+private /*attributes*/:
+    Device* mDevice;
+    QHash<QString, Notification*> mNotifications;
+    QHash<QString, QString> mInternalIdToPublicId;
+    int mLastId;
+
+};
+
+#endif

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list