File 0001-Notifications-Fix-grouping.patch of Package plasma5-workspace.7768
From 8164beac15ea34ec0d1564f0557fe3e742bdd938 Mon Sep 17 00:00:00 2001
From: Kai Uwe Broulik <kde@privat.broulik.de>
Date: Mon, 5 Feb 2018 13:53:17 +0100
Subject: [PATCH] [Notifications] Fix grouping
Sanitize the body before doing anything else.
Cleanup grouping logic.
Differential Revision: https://phabricator.kde.org/D10315
---
dataengines/notifications/notificationsengine.cpp | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/dataengines/notifications/notificationsengine.cpp b/dataengines/notifications/notificationsengine.cpp
index 9fbd3617..4c1854e1 100644
--- a/dataengines/notifications/notificationsengine.cpp
+++ b/dataengines/notifications/notificationsengine.cpp
@@ -202,18 +202,19 @@ uint NotificationsEngine::Notify(const QString &app_name, uint replaces_id,
qDebug() << "Currrent active notifications:" << m_activeNotifications;
qDebug() << "Guessing partOf as:" << partOf;
qDebug() << " New Notification: " << summary << body << timeout << "& Part of:" << partOf;
- QString _body;
+ QString bodyFinal = NotificationSanitizer::parse(body);
if (partOf > 0) {
const QString source = QStringLiteral("notification %1").arg(partOf);
Plasma::DataContainer *container = containerForSource(source);
if (container) {
// append the body text
- _body = container->data()[QStringLiteral("body")].toString();
- if (_body != body) {
- _body.append("\n").append(body);
- } else {
- _body = body;
+ const QString previousBody = container->data()[QStringLiteral("body")].toString();
+ if (previousBody != bodyFinal) {
+ // FIXME: This will just append the entire old XML document to another one, leading to:
+ // <?xml><html>old</html><br><?xml><html>new</html>
+ // It works but is not very clean.
+ bodyFinal = previousBody + QStringLiteral("<br/>") + bodyFinal;
}
replaces_id = partOf;
@@ -246,7 +247,7 @@ uint NotificationsEngine::Notify(const QString &app_name, uint replaces_id,
const int AVERAGE_WORD_LENGTH = 6;
const int WORD_PER_MINUTE = 250;
- int count = summary.length() + body.length();
+ int count = summary.length() + body.length() - strlen("<?xml version=\"1.0\"><html></html>");
// -1 is "server default", 0 is persistent with "server default" display time,
// anything more should honor the setting
@@ -261,9 +262,6 @@ uint NotificationsEngine::Notify(const QString &app_name, uint replaces_id,
const QString source = QStringLiteral("notification %1").arg(id);
- QString bodyFinal = (partOf == 0 ? body : _body);
- bodyFinal = NotificationSanitizer::parse(bodyFinal);
-
Plasma::DataEngine::Data notificationData;
notificationData.insert(QStringLiteral("id"), QString::number(id));
notificationData.insert(QStringLiteral("eventId"), eventId);
--
2.16.0