diff --git a/src/imageconverter.h b/src/imageconverter.h --- a/src/imageconverter.h +++ b/src/imageconverter.h @@ -25,7 +25,7 @@ /** * Returns a variant representing an image using the format describe in the - * galago spec + * freedesktop.org spec */ QVariant variantForImage(const QImage &image); diff --git a/src/notifybypopup.h b/src/notifybypopup.h --- a/src/notifybypopup.h +++ b/src/notifybypopup.h @@ -46,13 +46,13 @@ private Q_SLOTS: // slot which gets called when DBus signals that some notification action was invoked - void onGalagoNotificationActionInvoked(uint notificationId, const QString &actionKey); + void onNotificationActionInvoked(uint notificationId, const QString &actionKey); // slot which gets called when DBus signals that some notification was closed - void onGalagoNotificationClosed(uint, uint); + void onNotificationClosed(uint, uint); - void onGalagoServerReply(QDBusPendingCallWatcher *callWatcher); + void onServerReply(QDBusPendingCallWatcher *callWatcher); - void onGalagoServerCapabilitiesReceived(const QStringList &capabilities); + void onServerCapabilitiesReceived(const QStringList &capabilities); private: // TODO KF6, replace current public notify/update diff --git a/src/notifybypopup.cpp b/src/notifybypopup.cpp --- a/src/notifybypopup.cpp +++ b/src/notifybypopup.cpp @@ -63,12 +63,8 @@ * Otherwise will put new notification on screen * @return true for success or false if there was an error. */ - bool sendNotificationToGalagoServer(KNotification *notification, const KNotifyConfig &config, bool update = false); - /** - * Sends request to close Notification with id to DBus "org.freedesktop.notifications" interface - * @param id knotify-side notification ID to close - */ - void closeGalagoNotification(KNotification *notification); + bool sendNotificationToServer(KNotification *notification, const KNotifyConfig &config, bool update = false); + /** * Find the caption and the icon name of the application */ @@ -102,7 +98,7 @@ * As we communicate with the notification server over dbus * we use only ids, this is for fast KNotifications lookup */ - QHash> galagoNotifications; + QHash> notifications; NotifyByPopup * const q; @@ -121,7 +117,7 @@ QString::fromLatin1(dbusInterfaceName), QStringLiteral("ActionInvoked"), this, - SLOT(onGalagoNotificationActionInvoked(uint,QString))); + SLOT(onNotificationActionInvoked(uint,QString))); if (!connected) { qCWarning(LOG_KNOTIFICATIONS) << "warning: failed to connect to ActionInvoked dbus signal"; } @@ -131,7 +127,7 @@ QString::fromLatin1(dbusInterfaceName), QStringLiteral("NotificationClosed"), this, - SLOT(onGalagoNotificationClosed(uint,uint))); + SLOT(onNotificationClosed(uint,uint))); if (!connected) { qCWarning(LOG_KNOTIFICATIONS) << "warning: failed to connect to NotificationClosed dbus signal"; } @@ -150,7 +146,7 @@ void NotifyByPopup::notify(KNotification *notification, const KNotifyConfig ¬ifyConfig) { - if (d->galagoNotifications.contains(notification->id())) { + if (d->notifications.contains(notification->id())) { // notification is already on the screen, do nothing finish(notification); return; @@ -163,7 +159,7 @@ d->notificationQueue.append(qMakePair(notification, notifyConfig)); d->queryPopupServerCapabilities(); } else { - if (!d->sendNotificationToGalagoServer(notification, notifyConfig)) { + if (!d->sendNotificationToServer(notification, notifyConfig)) { finish(notification); //an error occurred. } } @@ -176,12 +172,30 @@ void NotifyByPopup::update(KNotification *notification, const KNotifyConfig ¬ifyConfig) { - d->sendNotificationToGalagoServer(notification, notifyConfig, true); + d->sendNotificationToServer(notification, notifyConfig, true); } void NotifyByPopup::close(KNotification *notification) { - d->closeGalagoNotification(notification); + uint id = d->notifications.key(notification, 0); + + if (id == 0) { + qCDebug(LOG_KNOTIFICATIONS) << "not found dbus id to close" << notification->id(); + return; + } + + QDBusMessage m = QDBusMessage::createMethodCall(QString::fromLatin1(dbusServiceName), QString::fromLatin1(dbusPath), + QString::fromLatin1(dbusInterfaceName), QStringLiteral("CloseNotification")); + QList args; + args.append(id); + m.setArguments(args); + + // send(..) does not block + bool queued = QDBusConnection::sessionBus().send(m); + + if (!queued) { + qCWarning(LOG_KNOTIFICATIONS) << "Failed to queue dbus message for closing a notification"; + } QMutableListIterator > iter(d->notificationQueue); while (iter.hasNext()) { @@ -192,10 +206,10 @@ } } -void NotifyByPopup::onGalagoNotificationActionInvoked(uint notificationId, const QString &actionKey) +void NotifyByPopup::onNotificationActionInvoked(uint notificationId, const QString &actionKey) { - auto iter = d->galagoNotifications.find(notificationId); - if (iter == d->galagoNotifications.end()) { + auto iter = d->notifications.find(notificationId); + if (iter == d->notifications.end()) { return; } @@ -207,18 +221,18 @@ emit actionInvoked(n->id(), actionKey.toUInt()); } } else { - d->galagoNotifications.erase(iter); + d->notifications.erase(iter); } } -void NotifyByPopup::onGalagoNotificationClosed(uint dbus_id, uint reason) +void NotifyByPopup::onNotificationClosed(uint dbus_id, uint reason) { - auto iter = d->galagoNotifications.find(dbus_id); - if (iter == d->galagoNotifications.end()) { + auto iter = d->notifications.find(dbus_id); + if (iter == d->notifications.end()) { return; } KNotification *n = *iter; - d->galagoNotifications.remove(dbus_id); + d->notifications.remove(dbus_id); if (n) { emit finished(n); @@ -233,7 +247,7 @@ } } -void NotifyByPopup::onGalagoServerReply(QDBusPendingCallWatcher *watcher) +void NotifyByPopup::onServerReply(QDBusPendingCallWatcher *watcher) { // call deleteLater first, since we might return in the middle of the function watcher->deleteLater(); @@ -245,10 +259,10 @@ QDBusPendingReply reply = *watcher; - d->galagoNotifications.insert(reply.argumentAt<0>(), notification); + d->notifications.insert(reply.argumentAt<0>(), notification); } -void NotifyByPopup::onGalagoServerCapabilitiesReceived(const QStringList &capabilities) +void NotifyByPopup::onServerCapabilitiesReceived(const QStringList &capabilities) { d->popupServerCapabilities = capabilities; d->dbusServiceCapCacheDirty = false; @@ -274,9 +288,9 @@ } } -bool NotifyByPopupPrivate::sendNotificationToGalagoServer(KNotification *notification, const KNotifyConfig ¬ifyConfig_nocheck, bool update) +bool NotifyByPopupPrivate::sendNotificationToServer(KNotification *notification, const KNotifyConfig ¬ifyConfig_nocheck, bool update) { - uint updateId = galagoNotifications.key(notification, 0); + uint updateId = notifications.key(notification, 0); if (update) { if (updateId == 0) { @@ -314,7 +328,7 @@ args.append(title); // summary args.append(text); // body - // galago spec defines action list to be list like + // freedesktop.org spec defines action list to be list like // (act_id1, action1, act_id2, action2, ...) // // assign id's to actions like it's done in fillPopup() method @@ -339,7 +353,7 @@ QVariantMap hintsMap; // Add the application name to the hints. - // According to fdo spec, the app_name is supposed to be the application's "pretty name" + // According to freedesktop.org spec, the app_name is supposed to be the application's "pretty name" // but in some places it's handy to know the application name itself if (!notification->appName().isEmpty()) { hintsMap[QStringLiteral("x-kde-appname")] = notification->appName(); @@ -380,7 +394,7 @@ break; case KNotification::NormalUrgency: Q_FALLTHROUGH(); - // galago notifications only know low, normal, critical + // freedesktop.org notifications only know low, normal, critical case KNotification::HighUrgency: urgency = 1; break; @@ -426,34 +440,11 @@ watcher->setProperty("notificationObject", QVariant::fromValue(notification)); QObject::connect(watcher, &QDBusPendingCallWatcher::finished, - q, &NotifyByPopup::onGalagoServerReply); + q, &NotifyByPopup::onServerReply); return true; } -void NotifyByPopupPrivate::closeGalagoNotification(KNotification *notification) -{ - uint galagoId = galagoNotifications.key(notification, 0); - - if (galagoId == 0) { - qCDebug(LOG_KNOTIFICATIONS) << "not found dbus id to close" << notification->id(); - return; - } - - QDBusMessage m = QDBusMessage::createMethodCall(QString::fromLatin1(dbusServiceName), QString::fromLatin1(dbusPath), - QString::fromLatin1(dbusInterfaceName), QStringLiteral("CloseNotification")); - QList args; - args.append(galagoId); - m.setArguments(args); - - // send(..) does not block - bool queued = QDBusConnection::sessionBus().send(m); - - if (!queued) { - qCWarning(LOG_KNOTIFICATIONS) << "Failed to queue dbus message for closing a notification"; - } -} - void NotifyByPopupPrivate::queryPopupServerCapabilities() { if (dbusServiceCapCacheDirty) { @@ -464,7 +455,7 @@ QDBusConnection::sessionBus().callWithCallback(m, q, - SLOT(onGalagoServerCapabilitiesReceived(QStringList)), + SLOT(onServerCapabilitiesReceived(QStringList)), nullptr, -1); } diff --git a/src/notifybyportal.cpp b/src/notifybyportal.cpp --- a/src/notifybyportal.cpp +++ b/src/notifybyportal.cpp @@ -286,7 +286,7 @@ portalArgs.insert(QStringLiteral("priority"), priority); } - // galago spec defines action list to be list like + // freedesktop.org spec defines action list to be list like // (act_id1, action1, act_id2, action2, ...) // // assign id's to actions like it's done in fillPopup() method