MailJDTourDownloadDocsQualityTestsCoverage

Which source lines and branches the tests execute. Lines 91.5 %, branches 75.0 % (minimum 85 % and 72 %). main @ 399ffe3d · 21 October 2026 · pipeline 7238.

GCC Code Coverage Report


Directory: src/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 1 / 0 / 1
Functions: 100.0% 1 / 0 / 1
Branches: -% 0 / 0 / 0

service/DesktopNotifier.h
Line Branch Exec Source
1 #pragma once
2
3 #include <QDeadlineTimer>
4 #include <QMap>
5 #include <QObject>
6 #include <QStringList>
7
8 #ifdef MAILJD_KDE_INTEGRATION
9 class KNotification;
10 #endif
11
12 class QDBusInterface;
13 class QDBusMessage;
14
15 class DesktopNotifier : public QObject {
16 13 Q_OBJECT
17 #if defined(MAILJD_UNIT_TEST)
18 friend class TestDesktopNotifier;
19 #ifdef MAILJD_KDE_INTEGRATION
20 friend class TestDesktopNotifierKde;
21 #endif
22 #endif
23 public:
24 explicit DesktopNotifier(QObject *parent = nullptr);
25 ~DesktopNotifier() override;
26
27 // replacesId (67.A2): non-zero replaces the still-visible notification
28 // with that id in place (org.freedesktop.Notifications replaces_id).
29 uint notify(const QString &summary, const QString &body = {},
30 const QString &iconName = {}, int timeoutMs = 5000,
31 uint replacesId = 0);
32
33 // 67.A2: summary notification for a clustered new-mail burst.
34 // Only offers the "open" action (mark-read makes no sense for N mails).
35 uint notifySummary(const QString &title, const QString &body,
36 uint replacesId = 0);
37
38 // Sprint 93 S93.5.1: appointment reminder ("appointment-reminder" KDE
39 // event, persistent) with its own actions as (key, label) pairs; the
40 // first action must be "open" — it is the default (body click), which
41 // the freedesktop path reports as "open". actionInvoked reports keys.
42 uint notifyReminder(const QString &title, const QString &body,
43 const QList<QPair<QString, QString>> &actions, uint replacesId = 0);
44
45 void close(uint id);
46 bool isAvailable() const;
47
48 static QString formatNotificationText(QString text, bool supportsMarkup);
49
50 signals:
51 void actionInvoked(uint id, const QString &actionKey,
52 const QString &activationToken);
53 void notificationClosed(uint id);
54
55 private:
56 bool m_available = false;
57 bool m_useKde = false;
58 // Test seam: without a notification server sendEvent() closes at once.
59 bool m_sendKdeEvents = true;
60 uint m_nextId = 1;
61 QMap<uint, QObject *> m_activeNotifications;
62 ::QDBusInterface *m_dbus = nullptr;
63 QStringList m_capabilities;
64 bool m_capabilitiesLoaded = false;
65 // S106-212: after a call the daemon did not answer in time, the
66 // freedesktop path stays quiet until this expires (default: expired).
67 QDeadlineTimer m_daemonPause;
68 QDBusMessage callDaemon(const QString &method, const QList<QVariant> &arguments);
69 struct PendingActivationToken {
70 QString value;
71 QDeadlineTimer expiry;
72 };
73 QMap<uint, PendingActivationToken> m_activationTokens;
74 void setupDBusConnections();
75 const QStringList &capabilities();
76 QString takeActivationToken(uint id);
77 void expireActivationToken(uint id, const QString &expectedValue);
78 void clearNotificationState(uint id);
79 void resetBackendGeneration();
80
81 #ifdef MAILJD_KDE_INTEGRATION
82 KNotification *kdeEvent(const QString &eventId, const QString &title, const QString &text,
83 const QString &iconName, bool persistent = false);
84 void configureKdeActions(KNotification *notification, uint id,
85 bool includeMarkRead);
86 // Sprint 77 (T-77.A4) test seam: KF6's addAction does not reparent the
87 // KNotificationAction to the notification, and KNotification::actions() is
88 // private (QML-only), so a test cannot retrieve added actions post-hoc.
89 // configureKdeActions records every action it creates here so the friend
90 // test (TestDesktopNotifierKde) can drive them directly. Empty in normal use.
91 QList<QObject *> m_kdeActionsForTest;
92 #endif
93
94 private slots:
95 void onDBusActionInvoked(uint id, const QString &action);
96 void onDBusNotificationClosed(uint id, uint reason);
97 void onDBusActivationToken(uint id, const QString &activationToken);
98 };
99