void SnorePlugin::Freedesktop::slotActionInvoked(const uint id, const QString &actionID) { qCDebug(SNORE) << id << m_dbusIdMap[id]; Snore::Notification noti = m_dbusIdMap[id]; if (!noti.isValid()) { return; } slotNotificationActionInvoked(noti, noti.actions().value(actionID.toInt()));; }
void SnorePlugin::Freedesktop::slotNotify(Snore::Notification noti) { if (noti.data()->sourceAndTargetAreSimilar(this)) { return; } QStringList actions; foreach(int k, noti.actions().keys()) { actions << QString::number(k) << noti.actions()[k].name(); } QVariantMap hints; FreedesktopImageHint image(noti.icon().pixmap(QSize(128, 128)).toImage()); hints.insert(QStringLiteral("image_data"), QVariant::fromValue(image)); char urgency = 1; if (noti.priority() < 0) { urgency = 0; } else if (noti.priority() > 2) { urgency = 2; } hints.insert(QStringLiteral("urgency"), urgency); if (noti.application().constHints().contains("desktop-entry")) { hints.insert(QStringLiteral("desktop-entry"), noti.application().constHints().value("desktop-entry")); } hints.insert(QStringLiteral("suppress-sound"), noti.constHints().value("silent").toBool()); uint updateId = 0; if (noti.isUpdate()) { updateId = noti.old().hints().privateValue(this, "id").toUInt(); m_dbusIdMap.take(updateId); } QString title = noti.application().name() + QLatin1String(" - ") + noti.title(m_supportsRichtext ? Snore::Utils::AllMarkup : Snore::Utils::NoMarkup); QString body(noti.text(m_supportsRichtext ? Snore::Utils::AllMarkup : Snore::Utils::NoMarkup)); //TODO: add app icon hint? QDBusPendingReply<uint> id = m_interface->Notify(noti.application().name(), updateId, QString(), title, body, actions, hints, noti.isSticky() ? -1 : noti.timeout() * 1000); id.waitForFinished(); noti.hints().setPrivateValue(this, "id", id.value()); m_dbusIdMap[id.value()] = noti; slotNotificationDisplayed(noti); qCDebug(SNORE) << noti.id() << "|" << id.value(); }