// Copyright (C) 2021 The Qt Company Ltd. // Copyright (C) 2019 Luxoft Sweden AB // Copyright (C) 2018 Pelagicore AG // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include #if defined(Q_OS_UNIX) # include #endif #include "notificationmanager.h" #include "notifications_adaptor.h" //NOTE: The header for this class is autogenerated from the XML interface definition. // We are NOT using the generated cpp, but instead implement the adaptor manually. using namespace Qt::StringLiterals; QT_USE_NAMESPACE_AM NotificationsAdaptor::NotificationsAdaptor(QObject *parent) : QDBusAbstractAdaptor(parent) { auto nm = NotificationManager::instance(); connect(&nm->internalSignals, &NotificationManagerInternalSignals::actionInvoked, this, &NotificationsAdaptor::ActionInvoked); connect(&nm->internalSignals, &NotificationManagerInternalSignals::notificationClosed, this, &NotificationsAdaptor::NotificationClosed); } NotificationsAdaptor::~NotificationsAdaptor() { } QStringList NotificationsAdaptor::GetCapabilities() { static const QStringList caps { u"action-icons"_s, u"actions"_s, u"body"_s, u"body-hyperlinks"_s, u"body-images"_s, u"body-markup"_s, u"icon-static"_s, u"persistence"_s, }; return caps; } QString NotificationsAdaptor::GetServerInformation(QString &vendor, QString &version, QString &spec_version) { vendor = qApp->organizationName(); version = u"1.0"_s; spec_version = u"1.2"_s; return qApp->applicationName(); } uint NotificationsAdaptor::Notify(const QString &app_name, uint replaces_id, const QString &app_icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantMap &hints, int timeout) { return NotificationManager::instance()->showNotification(app_name, replaces_id, app_icon, summary, body, actions, hints, timeout); } void NotificationsAdaptor::CloseNotification(uint id) { NotificationManager::instance()->closeNotification(id); }