From 43999b41595becd5e0f657bedfc14bd441273032 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Wed, 20 Jan 2016 23:47:15 +0100 Subject: Notification filtering Exclude transient category and notifications. Workaround for messages: accept categories that end in preview or summary. --- daemon/notificationmanager.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/daemon/notificationmanager.cpp b/daemon/notificationmanager.cpp index a04e99b..8e21ad9 100644 --- a/daemon/notificationmanager.cpp +++ b/daemon/notificationmanager.cpp @@ -6,6 +6,7 @@ #include #include #include +//#include "PersonalNotification.h" class NotificationManagerPrivate { @@ -123,21 +124,31 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons Q_ASSERT(calledFromDBus()); setDelayedReply(true); - QString category = hints.value("category", "").toString(); - QStringHash categoryParams = this->getCategoryParams(category); - - // Ignore transient notifications - if (!category.endsWith("preview") && categoryParams.value("transient", "false") == "true") { - qCDebug(l) << "Ignoring transient notification from " << owner; - return 0; - } - + QString category = hints.value("category", "").toString(); + QStringHash categoryParams = this->getCategoryParams(category); + + // Ignore transient notifications (notif hints override category hints) + // Hack this to accept transient -preview and -summary notifications, as we don't know how to decode the actual notifs yet + if (!category.endsWith("preview") && !category.endsWith("summary") && + hints.value("transient", categoryParams.value("transient", "false")).toString() == "true") { + qCDebug(l) << "Ignoring transient notification from " << owner; + return 0; + } + if (app_name == "messageserver5" || owner == "messageserver5") { if (!settings->property("notificationsEmails").toBool()) { qCDebug(l) << "Ignoring email notification because of setting!"; return 0; } +// This is how we should obtain messaging notifications, if we manage to deserialize this 'PersonalNotification'. +// QByteArray commdata = hints.value("x-commhistoryd-data", "no data").toByteArray(); +// if (!commdata.contains((char)0)) +// data = QByteArray::fromBase64(commdata); +// QDataStream stream(commdata); +// stream.setVersion(QDataStream::Qt_5_0); +// stream >> + QString subject = hints.value("x-nemo-preview-summary", "").toString(); QString data = hints.value("x-nemo-preview-body", "").toString(); -- cgit v1.2.3