diff --git a/src/imports/notifications/CMakeLists.txt b/src/imports/notifications/CMakeLists.txt index f06c0cb..0d6b9eb 100644 --- a/src/imports/notifications/CMakeLists.txt +++ b/src/imports/notifications/CMakeLists.txt @@ -6,25 +6,12 @@ liri_add_qml_plugin(NotificationsQmlPlugin OUTPUT_NAME "lirinotificationsplugin" SOURCES - notificationimagesstorage.cpp - notificationimagesstorage.h - notifications.cpp - notificationsdaemon.cpp - notificationsdaemon.h - notifications.h - notificationsimageutils.cpp - notificationsimageutils.h - notificationsimageprovider.cpp - notificationsimageprovider.h plugin.cpp QML_FILES qmldir - DBUS_ADAPTOR_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/../../notifications/org.freedesktop.Notifications.xml" DEFINES QT_NO_CAST_FROM_ASCII QT_NO_FOREACH - LIBLIRI_VERSION="${PROJECT_VERSION}" PUBLIC_LIBRARIES Liri::Notifications ) diff --git a/src/imports/notifications/notificationimagesstorage.cpp b/src/imports/notifications/notificationimagesstorage.cpp deleted file mode 100644 index a396fb5..0000000 --- a/src/imports/notifications/notificationimagesstorage.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -#include - -#include "notificationimagesstorage.h" - -Q_GLOBAL_STATIC(NotificationImagesStorage, globalStorage) - -NotificationImagesStorage::NotificationImagesStorage() -{ -} - -NotificationImagesStorage::~NotificationImagesStorage() -{ - qDeleteAll(m_images); -} - -NotificationImage *NotificationImagesStorage::get(uint id) const -{ - return m_images.value(id); -} - -void NotificationImagesStorage::add(uint id, NotificationImage *image) -{ - remove(id); - m_images[id] = image; -} - -void NotificationImagesStorage::remove(uint id) -{ - if (m_images.contains(id)) - delete m_images.take(id); -} - -NotificationImagesStorage *NotificationImagesStorage::instance() -{ - return globalStorage; -} diff --git a/src/imports/notifications/notificationimagesstorage.h b/src/imports/notifications/notificationimagesstorage.h deleted file mode 100644 index 9a1802c..0000000 --- a/src/imports/notifications/notificationimagesstorage.h +++ /dev/null @@ -1,31 +0,0 @@ - -#ifndef NOTIFICATIONIMAGESSTORAGE_H -#define NOTIFICATIONIMAGESSTORAGE_H - -#include -#include - -struct NotificationImage { - QPixmap image; - QString iconName; - QString entryIconName; -}; - -class NotificationImagesStorage -{ -public: - NotificationImagesStorage(); - ~NotificationImagesStorage(); - - NotificationImage *get(uint id) const; - - void add(uint id, NotificationImage *image); - void remove(uint id); - - static NotificationImagesStorage *instance(); - -private: - QHash m_images; -}; - -#endif // NOTIFICATIONIMAGESSTORAGE_H diff --git a/src/imports/notifications/notifications.cpp b/src/imports/notifications/notifications.cpp deleted file mode 100644 index c0369ab..0000000 --- a/src/imports/notifications/notifications.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** - * This file is part of Liri. - * - * Copyright (C) 2018 Pier Luigi Fiorini - * - * $BEGIN_LICENSE:LGPLv3+$ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - * - * $END_LICENSE$ - ***************************************************************************/ - -#include "notifications.h" -#include "notificationsdaemon.h" - -Notifications::Notifications(QObject *parent) - : QObject(parent) - , m_daemon(new NotificationsDaemon(this)) -{ -} - -bool Notifications::isActive() const -{ - return m_active; -} - -void Notifications::invokeAction(uint id, const QString &actionId) -{ - Q_EMIT m_daemon->ActionInvoked(id, actionId); -} - -void Notifications::closeNotification(uint id, const CloseReason &reason) -{ - if (m_daemon->m_notifications.remove(id) > 0) - Q_EMIT m_daemon->NotificationClosed(id, (uint)reason); -} - -void Notifications::componentComplete() -{ - // Register service - if (m_daemon->registerService()) { - m_active = true; - Q_EMIT activeChanged(); - } -} diff --git a/src/imports/notifications/notifications.h b/src/imports/notifications/notifications.h deleted file mode 100644 index 8f762cc..0000000 --- a/src/imports/notifications/notifications.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** - * This file is part of Liri. - * - * Copyright (C) 2018 Pier Luigi Fiorini - * - * $BEGIN_LICENSE:LGPLv3+$ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - * - * $END_LICENSE$ - ***************************************************************************/ - -#ifndef NOTIFICATIONS_H -#define NOTIFICATIONS_H - -#include -#include - -class NotificationsDaemon; - -class Notifications : public QObject, public QQmlParserStatus -{ - Q_OBJECT - Q_PROPERTY(bool active READ isActive NOTIFY activeChanged) - Q_INTERFACES(QQmlParserStatus) -public: - enum CloseReason { - CloseReasonExpired = 1, - CloseReasonByUser, - CloseReasonByApplication - }; - Q_ENUM(CloseReason) - - explicit Notifications(QObject *parent = nullptr); - - bool isActive() const; - - Q_INVOKABLE void invokeAction(uint id, const QString &actionId); - - Q_INVOKABLE void closeNotification(uint id, const Notifications::CloseReason &reason); - - void classBegin() override {} - void componentComplete() override; - -Q_SIGNALS: - void activeChanged(); - void notificationReceived(uint notificationId, const QString &appName, - const QString &appIcon, bool hasIcon, - const QString &summary, const QString &body, - const QVariantList &actions, bool isPersistent, - int expireTimeout, const QVariantMap &hints); - void notificationClosed(uint notificationId, uint reason); - void actionInvoked(uint notificationId, const QString &actionKey); - -private: - bool m_active = false; - NotificationsDaemon *m_daemon = nullptr; -}; - -#endif // NOTIFICATIONS_H diff --git a/src/imports/notifications/notificationsdaemon.cpp b/src/imports/notifications/notificationsdaemon.cpp deleted file mode 100644 index db52163..0000000 --- a/src/imports/notifications/notificationsdaemon.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/**************************************************************************** - * This file is part of Liri. - * - * Copyright (C) 2018 Pier Luigi Fiorini - * - * $BEGIN_LICENSE:LGPLv3+$ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - * - * $END_LICENSE$ - ***************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "notificationimagesstorage.h" -#include "notifications.h" -#include "notificationsdaemon.h" -#include "notifications_adaptor.h" -#include "notificationsimageutils.h" - -/* - * Latest specifications: - * http://people.gnome.org/~mccann/docs/notification-spec/notification-spec-latest.html - */ - -const QString serviceName(QStringLiteral("org.freedesktop.Notifications")); -const QString servicePath(QStringLiteral("/org/freedesktop/Notifications")); - -Q_LOGGING_CATEGORY(NOTIFICATIONS, "liri.notifications") - -NotificationsDaemon::NotificationsDaemon(Notifications *parent) - : QObject(parent) - , m_parent(parent) -{ - // Create the DBus adaptor - new NotificationsAdaptor(this); - - // Create a seed for notifications identifiers, starting from 1 - m_idSeed = new QAtomicInt(1); - - // List of applications that will send us too many notifications - // TODO: Add more from configuration - m_spamApplications << QStringLiteral("Clementine") << QStringLiteral("Spotify"); - - // Forward our signals to parent - connect(this, &NotificationsDaemon::NotificationClosed, - m_parent, &Notifications::notificationClosed); - connect(this, &NotificationsDaemon::ActionInvoked, - m_parent, &Notifications::actionInvoked); -} - -NotificationsDaemon::~NotificationsDaemon() -{ - unregisterService(); - delete m_idSeed; -} - -bool NotificationsDaemon::registerService() -{ - QDBusConnection bus = QDBusConnection::sessionBus(); - - if (!bus.registerObject(servicePath, this)) { - qCWarning(NOTIFICATIONS, - "Failed to register D-Bus object \"%s\" on session bus: \"%s\"", - qPrintable(servicePath), - qPrintable(bus.lastError().message())); - return false; - } - - if (!bus.registerService(serviceName)) { - qCWarning(NOTIFICATIONS, - "Failed to register D-Bus service \"%s\" on session bus: \"%s\"", - qPrintable(serviceName), - qPrintable(bus.lastError().message())); - return false; - } - - return true; -} - -void NotificationsDaemon::unregisterService() -{ - QDBusConnection bus = QDBusConnection::sessionBus(); - bus.unregisterObject(servicePath); - bus.unregisterService(serviceName); -} - -uint NotificationsDaemon::Notify(const QString &appName, uint replacesId, - const QString &appIcon, const QString &summary, - const QString &body, - const QStringList &actions, - const QVariantMap &hints, int timeout) -{ - // Don't create a new notification if it comes from the same source - if (m_notifications.values().contains(appName + summary)) - replacesId = m_notifications.key(appName + summary); - - // Calculate identifier - uint id = replacesId > 0 ? replacesId : nextId(); - - // Some applications (mostly media players) will send too many notifications, - // for them we want to replace an older notification (if applicable) - if (m_spamApplications.contains(appName)) { - if (m_replaceableNotifications.contains(appName)) - id = m_replaceableNotifications.value(appName); - else - m_replaceableNotifications.insert(appName, id); - } - - qCDebug(NOTIFICATIONS) - << "Notification:" - << "ID =" << id - << "replaced =" << (replacesId == id) - << appName << appIcon << summary << body - << actions << hints << timeout; - - // Rectify appName if needed - QString realAppName = appName; - if (realAppName.isEmpty()) - realAppName = tr("Unknown Application"); - - // Recalculate timeout depending on text, but ensure it last at least 5s - bool isPersistent = timeout == 0; - const int averageWordLength = 6; - const int wordPerMinute = 250; - int totalLength = summary.length() + body.length(); - timeout = 2000 + qMax(60000 * totalLength / averageWordLength / wordPerMinute, 3000); - - // Notification image - NotificationImage *notificationImage = new NotificationImage(); - notificationImage->iconName = appIcon; - - // Fetch the image hint (we also support the obsolete icon_data hint which - // is still used by applications compatible with the specification version - if (hints.contains(QStringLiteral("image_data"))) - notificationImage->image.convertFromImage(decodeImageHint(hints[QStringLiteral("image_data")].value())); - else if (hints.contains(QStringLiteral("image-data"))) - notificationImage->image.convertFromImage(decodeImageHint(hints[QStringLiteral("image-data")].value())); - else if (hints.contains(QStringLiteral("image_path"))) - notificationImage->image = QPixmap(hints[QStringLiteral("image_path")].toString()); - else if (hints.contains(QStringLiteral("image-path"))) - notificationImage->image = QPixmap(hints[QStringLiteral("image-path")].toString()); - else if (hints.contains(QStringLiteral("icon_data"))) - notificationImage->image.convertFromImage(decodeImageHint(hints[QStringLiteral("icon_data")].value())); - - // Retrieve icon from desktop entry, if any - if (hints.contains(QStringLiteral("desktop-entry"))) { - QString fileName = QStandardPaths::locate(QStandardPaths::ApplicationsLocation, - hints[QStringLiteral("desktop-entry")].toString()); - QSettings desktopEntry(fileName, QSettings::IniFormat); - notificationImage->entryIconName = desktopEntry.value(QStringLiteral("Icon"), appIcon).toString(); - } - - // Store image - NotificationImagesStorage::instance()->add(id, notificationImage); - - // Create actions property map - QVariantList actionsList; - for (int i = 0; i < actions.size(); i += 2) { - QVariantMap actionsMap; - actionsMap[QStringLiteral("id")] = actions.at(i); - actionsMap[QStringLiteral("text")] = actions.at(i + 1); - actionsList.append(actionsMap); - } - - // Create notification - m_notifications.insert(id, appName + summary); - bool hasIcon = !notificationImage->image.isNull() || - !notificationImage->iconName.isEmpty() || - !notificationImage->entryIconName.isEmpty(); - Q_EMIT m_parent->notificationReceived(id, realAppName, appIcon, hasIcon, - summary, body, actionsList, - isPersistent, timeout, hints); - - return id; -} - -void NotificationsDaemon::CloseNotification(uint id) -{ - if (m_notifications.remove(id) > 0) { - NotificationImagesStorage::instance()->remove(id); - Q_EMIT NotificationClosed(id, (uint)Notifications::CloseReasonByApplication); - } -} - -QStringList NotificationsDaemon::GetCapabilities() -{ - return QStringList() - << QStringLiteral("body") - << QStringLiteral("body-hyperlinks") - << QStringLiteral("body-markup") - << QStringLiteral("icon-static") - << QStringLiteral("actions") - << QStringLiteral("persistence"); -} - -QString NotificationsDaemon::GetServerInformation(QString &vendor, QString &version, QString &specVersion) -{ - vendor = QStringLiteral("Liri"); - version = QStringLiteral(LIBLIRI_VERSION); - specVersion = QStringLiteral("1.1"); - return QStringLiteral("Liri"); -} - -uint NotificationsDaemon::nextId() -{ - return (uint)m_idSeed->fetchAndAddAcquire(1); -} diff --git a/src/imports/notifications/notificationsdaemon.h b/src/imports/notifications/notificationsdaemon.h deleted file mode 100644 index 64eab47..0000000 --- a/src/imports/notifications/notificationsdaemon.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** - * This file is part of Liri. - * - * Copyright (C) 2018 Pier Luigi Fiorini - * - * $BEGIN_LICENSE:LGPLv3+$ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - * - * $END_LICENSE$ - ***************************************************************************/ - -#ifndef NOTIFICATIONSDAEMON_H -#define NOTIFICATIONSDAEMON_H - -#include -#include -#include - -class QAtomicInt; -class Notifications; - -Q_DECLARE_LOGGING_CATEGORY(NOTIFICATIONS) - -class NotificationsDaemon : public QObject -{ - Q_OBJECT -public: - explicit NotificationsDaemon(Notifications *parent); - ~NotificationsDaemon(); - - bool registerService(); - void unregisterService(); - -public Q_SLOTS: - uint Notify(const QString &appName, uint replacesId, const QString &appIcon, - const QString &summary, const QString &body, const QStringList &actions, - const QVariantMap &hints, int timeout); - - void CloseNotification(uint id); - - QStringList GetCapabilities(); - - QString GetServerInformation(QString &vendor, QString &version, QString &specVersion); - -Q_SIGNALS: - void NotificationClosed(uint id, uint reason); - void ActionInvoked(uint id, const QString &actionKey); - -private: - Notifications *m_parent; - QAtomicInt *m_idSeed; - bool m_valid; - bool m_active; - QSet m_spamApplications; - QHash m_replaceableNotifications; - QHash m_notifications; - - uint nextId(); - - friend class Notifications; -}; - -#endif // NOTIFICATIONSDAEMON_H diff --git a/src/imports/notifications/notificationsimageprovider.cpp b/src/imports/notifications/notificationsimageprovider.cpp deleted file mode 100644 index 49bbc82..0000000 --- a/src/imports/notifications/notificationsimageprovider.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** - * This file is part of Liri. - * - * Copyright (C) 2018 Pier Luigi Fiorini - * - * $BEGIN_LICENSE:LGPLv3+$ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - * - * $END_LICENSE$ - ***************************************************************************/ - -#include - -#include "notificationimagesstorage.h" -#include "notificationsdaemon.h" -#include "notificationsimageprovider.h" - -NotificationsImageProvider::NotificationsImageProvider() - : QQuickImageProvider(QQuickImageProvider::Pixmap) -{ -} - -QPixmap NotificationsImageProvider::requestPixmap(const QString &id, QSize *realSize, const QSize &requestedSize) -{ - // Sanitize requested size - QSize size(requestedSize); - if (size.width() < 1) - size.setWidth(1); - if (size.height() < 1) - size.setHeight(1); - - // Return real size - if (realSize) - *realSize = size; - - // Convert identifier (the second part is just a timestamp to make sure Image - // is always reloaded) - QString realId = id.split(QLatin1Char('/'), QString::SkipEmptyParts).at(0); - bool ok = false; - int notificationId = realId.toInt(&ok); - if (!ok) - return QPixmap(); - - // Get image from the daemon - NotificationImage *image = NotificationImagesStorage::instance()->get(notificationId); - if (!image) - return QPixmap(); - - // Pixmap - if (!image->image.isNull() && realSize) { - *realSize = image->image.size(); - return image->image; - } - - // Icon - if (!image->iconName.isEmpty()) { - QIcon icon = QIcon::fromTheme(image->iconName); - if (!icon.isNull()) - return icon.pixmap(size); - } - - // Application icon - if (!image->entryIconName.isEmpty()) { - QIcon icon = QIcon::fromTheme(image->entryIconName); - if (!icon.isNull()) - return icon.pixmap(size); - } - - // Default icon - return QIcon::fromTheme(QStringLiteral("dialog-information")).pixmap(size); -} diff --git a/src/imports/notifications/notificationsimageprovider.h b/src/imports/notifications/notificationsimageprovider.h deleted file mode 100644 index 300e01e..0000000 --- a/src/imports/notifications/notificationsimageprovider.h +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** - * This file is part of Liri. - * - * Copyright (C) 2018 Pier Luigi Fiorini - * - * $BEGIN_LICENSE:LGPLv3+$ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - * - * $END_LICENSE$ - ***************************************************************************/ - -#ifndef NOTIFICATIONSIMAGEPROVIDER_H -#define NOTIFICATIONSIMAGEPROVIDER_H - -#include - -class NotificationsImageProvider : public QQuickImageProvider -{ -public: - explicit NotificationsImageProvider(); - - QPixmap requestPixmap(const QString &id, QSize *realSize, const QSize &requestedSize); -}; - -#endif // NOTIFICATIONSIMAGEPROVIDER_H diff --git a/src/imports/notifications/notificationsimageutils.cpp b/src/imports/notifications/notificationsimageutils.cpp deleted file mode 100644 index dd78d8e..0000000 --- a/src/imports/notifications/notificationsimageutils.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** - * This file is part of Liri. - * - * Copyright (C) 2018 Pier Luigi Fiorini - * Copyright (C) 2008 Dmitry Suzdalev - * - * $BEGIN_LICENSE:LGPLv3+$ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - * - * $END_LICENSE$ - ***************************************************************************/ - -#include - -#include "notificationsimageutils.h" - -inline void copyLineRGB32(QRgb *dst, const char *src, int width) -{ - const char *end = src + width * 3; - for (; src != end; ++dst, src += 3) - * dst = qRgb(src[0], src[1], src[2]); -} - -inline void copyLineARGB32(QRgb *dst, const char *src, int width) -{ - const char *end = src + width * 4; - for (; src != end; ++dst, src += 4) - * dst = qRgba(src[0], src[1], src[2], src[3]); -} - -QImage decodeImageHint(const QDBusArgument &arg) -{ - int width, height, stride, hasAlpha, bitsPerSample, channels; - QByteArray pixels; - - // Decode hint - arg.beginStructure(); - arg >> width >> height >> stride >> hasAlpha - >> bitsPerSample >> channels >> pixels; - arg.endStructure(); - - char *ptr, *end; - - // Sanity check - if ((width <= 0) || (width >= 2048) || (height <= 0) || - (height >= 2048) || (stride <= 0)) { - qWarning() << "Image hint is not valid!"; - return QImage(); - } - - QImage::Format format = QImage::Format_Invalid; - void (*function)(QRgb *, const char *, int) = 0; - if (bitsPerSample == 8) { - if (channels == 4) { - format = QImage::Format_ARGB32; - function = copyLineARGB32; - } else if (channels == 3) { - format = QImage::Format_RGB32; - function = copyLineRGB32; - } - } - - if (format == QImage::Format_Invalid) { - qWarning() << "Unsupported image format received from hint (hasAlpha:" - << hasAlpha << "bitsPerSample:" << bitsPerSample - << "channels:" << channels << ")"; - return QImage(); - } - - QImage image(width, height, format); - ptr = pixels.data(); - end = ptr + pixels.length(); - for (int y = 0; y < height; ++y, ptr += stride) { - if (ptr + channels * width > end) { - qWarning() << "Image data is incomplete. y:" << y << "height:" << height; - break; - } - function((QRgb *)(void *)image.scanLine(y), ptr, width); - } - - return image; -} diff --git a/src/imports/notifications/notificationsimageutils.h b/src/imports/notifications/notificationsimageutils.h deleted file mode 100644 index 9fb0e66..0000000 --- a/src/imports/notifications/notificationsimageutils.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** - * This file is part of Liri. - * - * Copyright (C) 2018 Pier Luigi Fiorini - * Copyright (C) 2008 Dmitry Suzdalev - * - * $BEGIN_LICENSE:LGPLv3+$ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - * - * $END_LICENSE$ - ***************************************************************************/ - -#ifndef NOTIFICATIONSIMAGE_H -#define NOTIFICATIONSIMAGE_H - -#include -#include - -QImage decodeImageHint(const QDBusArgument &arg); - -#endif // NOTIFICATIONSIMAGE_H diff --git a/src/imports/notifications/plugin.cpp b/src/imports/notifications/plugin.cpp index d723860..d5ef5be 100644 --- a/src/imports/notifications/plugin.cpp +++ b/src/imports/notifications/plugin.cpp @@ -25,29 +25,16 @@ #include -#include "notifications.h" -#include "notificationsimageprovider.h" - class LiriNotificationsPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: - void initializeEngine(QQmlEngine *engine, const char *uri) override - { - // @uri Liri.Notifications - Q_ASSERT(QLatin1String(uri) == QLatin1String("Liri.Notifications")); - - engine->addImageProvider(QStringLiteral("notifications"), - new NotificationsImageProvider()); - } - void registerTypes(const char *uri) override { // @uri Liri.Notifications Q_ASSERT(QLatin1String(uri) == QLatin1String("Liri.Notifications")); - qmlRegisterType(uri, 1, 0, "NotificationsServer"); qmlRegisterType(uri, 1, 0, "Notification"); } }; diff --git a/src/imports/notifications/plugins.qmltypes b/src/imports/notifications/plugins.qmltypes deleted file mode 100644 index 88ea7e1..0000000 --- a/src/imports/notifications/plugins.qmltypes +++ /dev/null @@ -1,107 +0,0 @@ -import QtQuick.tooling 1.2 - -// This file describes the plugin-supplied types contained in the library. -// It is used for QML tooling purposes only. -// -// This file was auto-generated by: -// 'qmlplugindump-qt5 -noinstantiate -nonrelocatable Liri.Notifications 1.0 /home/plfiorini/git/liri/lirios/.build/install-root/lib/qml' - -Module { - dependencies: ["QtQuick 2.8"] - Component { - name: "Liri::Notification" - prototype: "QObject" - exports: ["Liri.Notifications/Notification 1.0"] - exportMetaObjectRevisions: [0] - Enum { - name: "Urgency" - values: { - "UrgencyLow": 0, - "UrgencyNormal": 1, - "UrgencyCritical": 2 - } - } - Enum { - name: "CloseReason" - values: { - "Expired": 1, - "DismissedByUser": 2, - "Closed": 3 - } - } - Property { name: "applicationName"; type: "string" } - Property { name: "applicationIcon"; type: "string" } - Property { name: "summary"; type: "string" } - Property { name: "body"; type: "string" } - Property { name: "replacesId"; type: "uint" } - Property { name: "urgency"; type: "Urgency" } - Property { name: "timeout"; type: "int" } - Signal { name: "defaultActionChanged" } - Signal { name: "sendFailed" } - Signal { - name: "sendSucceeded" - Parameter { name: "id"; type: "uint" } - } - Signal { - name: "actionInvoked" - Parameter { name: "action"; type: "string" } - } - Signal { - name: "closed" - Parameter { name: "reason"; type: "CloseReason" } - } - Method { name: "send" } - Method { name: "close" } - } - Component { - name: "Notifications" - prototype: "QObject" - exports: ["Liri.Notifications/NotificationsService 1.0"] - isCreatable: false - isSingleton: true - exportMetaObjectRevisions: [0] - Enum { - name: "CloseReason" - values: { - "CloseReasonExpired": 1, - "CloseReasonByUser": 2, - "CloseReasonByApplication": 3 - } - } - Property { name: "valid"; type: "bool"; isReadonly: true } - Property { name: "active"; type: "bool" } - Signal { - name: "notificationReceived" - Parameter { name: "notificationId"; type: "uint" } - Parameter { name: "appName"; type: "string" } - Parameter { name: "appIcon"; type: "string" } - Parameter { name: "hasIcon"; type: "bool" } - Parameter { name: "summary"; type: "string" } - Parameter { name: "body"; type: "string" } - Parameter { name: "actions"; type: "QVariantList" } - Parameter { name: "isPersistent"; type: "bool" } - Parameter { name: "expireTimeout"; type: "int" } - Parameter { name: "hints"; type: "QVariantMap" } - } - Signal { - name: "notificationClosed" - Parameter { name: "notificationId"; type: "uint" } - Parameter { name: "reason"; type: "uint" } - } - Signal { - name: "actionInvoked" - Parameter { name: "notificationId"; type: "uint" } - Parameter { name: "actionKey"; type: "string" } - } - Method { - name: "invokeAction" - Parameter { name: "id"; type: "uint" } - Parameter { name: "actionId"; type: "string" } - } - Method { - name: "closeNotification" - Parameter { name: "id"; type: "uint" } - Parameter { name: "reason"; type: "Notifications::CloseReason" } - } - } -}