File indexing completed on 2024-04-21 04:56:45
0001 /** 0002 * SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #include "notificationserverinfo.h" 0008 0009 #include <QDBusMessage> 0010 #include <QDBusPendingCallWatcher> 0011 #include <QDBusPendingReply> 0012 0013 #include "dbushelper.h" 0014 0015 #include "core_debug.h" 0016 0017 NotificationServerInfo &NotificationServerInfo::instance() 0018 { 0019 static NotificationServerInfo instance; 0020 return instance; 0021 } 0022 0023 void NotificationServerInfo::init() 0024 { 0025 QDBusMessage query = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.Notifications"), 0026 QStringLiteral("/org/freedesktop/Notifications"), 0027 QStringLiteral("org.freedesktop.Notifications"), 0028 QStringLiteral("GetCapabilities")); 0029 0030 QDBusPendingReply<QStringList> reply = QDBusConnection::sessionBus().asyncCall(query); 0031 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); 0032 connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, reply, watcher] { 0033 watcher->deleteLater(); 0034 0035 if (reply.isError()) { 0036 qCWarning(KDECONNECT_CORE) << "Could not query capabilities from notifications server"; 0037 return; 0038 } 0039 0040 if (reply.value().contains(QLatin1String("x-kde-display-appname"))) { 0041 m_supportedHints |= X_KDE_DISPLAY_APPNAME; 0042 } 0043 0044 if (reply.value().contains(QLatin1String("x-kde-origin-name"))) { 0045 m_supportedHints |= X_KDE_ORIGIN_NAME; 0046 } 0047 }); 0048 } 0049 0050 NotificationServerInfo::Hints NotificationServerInfo::supportedHints() 0051 { 0052 return m_supportedHints; 0053 } 0054 0055 #include "moc_notificationserverinfo.cpp"