[OpenDocString] kdeconnect-kde (cpp)
notificationserverinfo.cpp
NotificationServerInfo &NotificationServerInfo::instance()
{
    static NotificationServerInfo instance;
    return instance;
}
This implements the singleton design pattern and returns a reference to a static instance of the NotificationServerInfo class. The object is created only once and persists for the lifetime of the program.
void NotificationServerInfo::init()
{
    QDBusMessage query = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.Notifications"),
                                                        QStringLiteral("/org/freedesktop/Notifications"),
                                                        QStringLiteral("org.freedesktop.Notifications"),
                                                        QStringLiteral("GetCapabilities"));

    QDBusPendingReply reply = QDBusConnection::sessionBus().asyncCall(query);
    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;
        }
    });
}
This method is responsible for retrieving the capabilities from the notifications server.
NotificationServerInfo::Hints NotificationServerInfo::supportedHints()
{
    return m_supportedHints;
}
Returns the list of supported hints.