2019-06-02 15:03:11 +01:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de>
|
2019-06-02 15:03:11 +01:00
|
|
|
*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2019-06-02 15:03:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "notificationserverinfo.h"
|
|
|
|
|
|
|
|
#include <QDBusMessage>
|
|
|
|
#include <QDBusPendingCallWatcher>
|
2022-09-10 22:23:52 +01:00
|
|
|
#include <QDBusPendingReply>
|
2019-06-09 19:45:03 +01:00
|
|
|
|
|
|
|
#include "dbushelper.h"
|
2019-06-02 15:03:11 +01:00
|
|
|
|
|
|
|
#include "core_debug.h"
|
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
NotificationServerInfo &NotificationServerInfo::instance()
|
2019-06-02 15:03:11 +01:00
|
|
|
{
|
|
|
|
static NotificationServerInfo instance;
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotificationServerInfo::init()
|
|
|
|
{
|
2022-09-10 22:23:52 +01:00
|
|
|
QDBusMessage query = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.Notifications"),
|
|
|
|
QStringLiteral("/org/freedesktop/Notifications"),
|
|
|
|
QStringLiteral("org.freedesktop.Notifications"),
|
|
|
|
QStringLiteral("GetCapabilities"));
|
2019-06-02 15:03:11 +01:00
|
|
|
|
2022-04-12 06:40:03 +01:00
|
|
|
QDBusPendingReply<QStringList> reply = QDBusConnection::sessionBus().asyncCall(query);
|
2019-06-02 15:03:11 +01:00
|
|
|
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
|
|
|
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, reply, watcher] {
|
|
|
|
watcher->deleteLater();
|
|
|
|
|
|
|
|
if (reply.isError()) {
|
|
|
|
qCWarning(KDECONNECT_CORE) << "Could not query capabilities from notifications server";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (reply.value().contains(QLatin1String("x-kde-display-appname"))) {
|
|
|
|
m_supportedHints |= X_KDE_DISPLAY_APPNAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (reply.value().contains(QLatin1String("x-kde-origin-name"))) {
|
|
|
|
m_supportedHints |= X_KDE_ORIGIN_NAME;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
NotificationServerInfo::Hints NotificationServerInfo::supportedHints()
|
|
|
|
{
|
|
|
|
return m_supportedHints;
|
|
|
|
}
|