Changeset View
Changeset View
Standalone View
Standalone View
src/knotificationmanager.cpp
Show All 34 Lines | |||||
35 | #endif | 35 | #endif | ||
36 | 36 | | |||
37 | #include "knotifyconfig.h" | 37 | #include "knotifyconfig.h" | ||
38 | #include "knotificationplugin.h" | 38 | #include "knotificationplugin.h" | ||
39 | 39 | | |||
40 | #include "notifybylogfile.h" | 40 | #include "notifybylogfile.h" | ||
41 | #include "notifybytaskbar.h" | 41 | #include "notifybytaskbar.h" | ||
42 | #include "notifybyexecute.h" | 42 | #include "notifybyexecute.h" | ||
43 | #ifndef Q_OS_ANDROID | 43 | | ||
44 | #if defined(Q_OS_ANDROID) | ||||
45 | #include "notifybyandroid.h" | ||||
46 | #elif defined(Q_OS_WIN) | ||||
47 | #include "notifybysnore.h" | ||||
48 | #else | ||||
44 | #include "notifybypopup.h" | 49 | #include "notifybypopup.h" | ||
45 | #include "notifybyportal.h" | 50 | #include "notifybyportal.h" | ||
46 | #else | | |||
47 | #include "notifybyandroid.h" | | |||
48 | #endif | 51 | #endif | ||
pino: #elif defined(Q_OS_WIN) | |||||
52 | | ||||
do not add spaces before the # of C preprocessor tokens, as it is undefined/nonstandard behaviour pino: do not add spaces before the `#` of C preprocessor tokens, as it is undefined/nonstandard… | |||||
49 | #include "debug_p.h" | 53 | #include "debug_p.h" | ||
50 | 54 | | |||
51 | #if defined(HAVE_CANBERRA) | 55 | #if defined(HAVE_CANBERRA) | ||
52 | #include "notifybyaudio_canberra.h" | 56 | #include "notifybyaudio_canberra.h" | ||
53 | #elif defined(HAVE_PHONON4QT5) | 57 | #elif defined(HAVE_PHONON4QT5) | ||
54 | #include "notifybyaudio_phonon.h" | 58 | #include "notifybyaudio_phonon.h" | ||
55 | #endif | 59 | #endif | ||
56 | 60 | | |||
57 | #ifdef HAVE_SPEECH | 61 | #ifdef HAVE_SPEECH | ||
58 | #include "notifybytts.h" | 62 | #include "notifybytts.h" | ||
59 | #endif | 63 | #endif | ||
60 | 64 | | |||
61 | typedef QHash<QString, QString> Dict; | 65 | typedef QHash<QString, QString> Dict; | ||
62 | 66 | | |||
63 | struct Q_DECL_HIDDEN KNotificationManager::Private { | 67 | struct Q_DECL_HIDDEN KNotificationManager::Private { | ||
64 | QHash<int, KNotification *> notifications; | 68 | QHash<int, KNotification *> notifications; | ||
65 | QHash<QString, KNotificationPlugin *> notifyPlugins; | 69 | QHash<QString, KNotificationPlugin *> notifyPlugins; | ||
66 | 70 | | |||
67 | // incremental ids for notifications | 71 | // incremental ids for notifications | ||
68 | int notifyIdCounter; | 72 | int notifyIdCounter; | ||
69 | QStringList dirtyConfigCache; | 73 | QStringList dirtyConfigCache; | ||
70 | bool portalDBusServiceExists = false; | 74 | bool portalDBusServiceExists = false; | ||
pino: this does not seem related to snoretoast | |||||
yeah, looks like it picked up changes from commits on master. apologies for this. brute4s99: yeah, looks like it picked up changes from commits on master. apologies for this. | |||||
71 | }; | 75 | }; | ||
72 | 76 | | |||
73 | class KNotificationManagerSingleton | 77 | class KNotificationManagerSingleton | ||
74 | { | 78 | { | ||
75 | public: | 79 | public: | ||
76 | KNotificationManager instance; | 80 | KNotificationManager instance; | ||
77 | }; | 81 | }; | ||
78 | 82 | | |||
79 | Q_GLOBAL_STATIC(KNotificationManagerSingleton, s_self) | 83 | Q_GLOBAL_STATIC(KNotificationManagerSingleton, s_self) | ||
80 | 84 | | |||
81 | KNotificationManager *KNotificationManager::self() | 85 | KNotificationManager *KNotificationManager::self() | ||
82 | { | 86 | { | ||
83 | return &s_self()->instance; | 87 | return &s_self()->instance; | ||
84 | } | 88 | } | ||
85 | 89 | | |||
86 | KNotificationManager::KNotificationManager() | 90 | KNotificationManager::KNotificationManager() | ||
87 | : d(new Private) | 91 | : d(new Private) | ||
88 | { | 92 | { | ||
89 | d->notifyIdCounter = 0; | 93 | d->notifyIdCounter = 0; | ||
90 | qDeleteAll(d->notifyPlugins); | 94 | qDeleteAll(d->notifyPlugins); | ||
91 | d->notifyPlugins.clear(); | 95 | d->notifyPlugins.clear(); | ||
92 | 96 | | |||
93 | #ifdef QT_DBUS_LIB | 97 | #ifdef QT_DBUS_LIB | ||
94 | const bool inSandbox = QFileInfo::exists(QLatin1String("/.flatpak-info")) || qEnvironmentVariableIsSet("SNAP"); | 98 | const bool inSandbox = QFileInfo::exists(QLatin1String("/.flatpak-info")) || qEnvironmentVariableIsSet("SNAP"); | ||
95 | 99 | | |||
96 | if (inSandbox) { | 100 | if (inSandbox) { | ||
97 | QDBusConnectionInterface *interface = QDBusConnection::sessionBus().interface(); | 101 | QDBusConnectionInterface *interface = QDBusConnection::sessionBus().interface(); | ||
pino: this does not seem related to snoretoast | |||||
98 | d->portalDBusServiceExists = interface->isServiceRegistered(QStringLiteral("org.freedesktop.portal.Desktop")); | 102 | d->portalDBusServiceExists = interface->isServiceRegistered(QStringLiteral("org.freedesktop.portal.Desktop")); | ||
99 | } | 103 | } | ||
100 | 104 | | |||
101 | QDBusConnection::sessionBus().connect(QString(), | 105 | QDBusConnection::sessionBus().connect(QString(), | ||
102 | QStringLiteral("/Config"), | 106 | QStringLiteral("/Config"), | ||
103 | QStringLiteral("org.kde.knotification"), | 107 | QStringLiteral("org.kde.knotification"), | ||
104 | QStringLiteral("reparseConfiguration"), | 108 | QStringLiteral("reparseConfiguration"), | ||
105 | this, | 109 | this, | ||
Show All 22 Lines | 128 | auto addPlugin = [this](KNotificationPlugin *plugin) { | |||
128 | connect(plugin, &KNotificationPlugin::actionInvoked, | 132 | connect(plugin, &KNotificationPlugin::actionInvoked, | ||
129 | this, &KNotificationManager::notificationActivated); | 133 | this, &KNotificationManager::notificationActivated); | ||
130 | }; | 134 | }; | ||
131 | 135 | | |||
132 | // Load plugin. | 136 | // Load plugin. | ||
133 | // We have a series of built-ins up first, and fall back to trying | 137 | // We have a series of built-ins up first, and fall back to trying | ||
134 | // to instantiate an externally supplied plugin. | 138 | // to instantiate an externally supplied plugin. | ||
135 | if (action == QLatin1String("Popup")) { | 139 | if (action == QLatin1String("Popup")) { | ||
136 | #ifndef Q_OS_ANDROID | 140 | #if defined(Q_OS_ANDROID) | ||
141 | plugin = new NotifyByAndroid(this); | ||||
142 | #elif defined(Q_OS_WIN) | ||||
143 | plugin = new NotifyBySnore(this); | ||||
144 | #else | ||||
137 | if (d->portalDBusServiceExists) { | 145 | if (d->portalDBusServiceExists) { | ||
138 | plugin = new NotifyByPortal(this); | 146 | plugin = new NotifyByPortal(this); | ||
139 | } else { | 147 | } else { | ||
140 | plugin = new NotifyByPopup(this); | 148 | plugin = new NotifyByPopup(this); | ||
141 | } | 149 | } | ||
142 | #else | | |||
143 | plugin = new NotifyByAndroid(this); | | |||
144 | #endif | 150 | #endif | ||
145 | | ||||
146 | addPlugin(plugin); | 151 | addPlugin(plugin); | ||
nicolasfella: No space before macro | |||||
147 | } else if (action == QLatin1String("Taskbar")) { | 152 | } else if (action == QLatin1String("Taskbar")) { | ||
148 | plugin = new NotifyByTaskbar(this); | 153 | plugin = new NotifyByTaskbar(this); | ||
pino: #elif defined(Q_OS_WIN) | |||||
149 | addPlugin(plugin); | 154 | addPlugin(plugin); | ||
150 | } else if (action == QLatin1String("Sound")) { | 155 | } else if (action == QLatin1String("Sound")) { | ||
this change is still unrelated -- are you really sure you rebased your work on top of the current master branch? pino: this change is still unrelated -- are you really sure you rebased your work on top of the… | |||||
151 | #if defined(HAVE_PHONON4QT5) || defined(HAVE_CANBERRA) | 156 | #if defined(HAVE_PHONON4QT5) || defined(HAVE_CANBERRA) | ||
152 | plugin = new NotifyByAudio(this); | 157 | plugin = new NotifyByAudio(this); | ||
153 | addPlugin(plugin); | 158 | addPlugin(plugin); | ||
154 | #endif | 159 | #endif | ||
155 | } else if (action == QLatin1String("Execute")) { | 160 | } else if (action == QLatin1String("Execute")) { | ||
156 | plugin = new NotifyByExecute(this); | 161 | plugin = new NotifyByExecute(this); | ||
157 | addPlugin(plugin); | 162 | addPlugin(plugin); | ||
158 | } else if (action == QLatin1String("Logfile")) { | 163 | } else if (action == QLatin1String("Logfile")) { | ||
▲ Show 20 Lines • Show All 193 Lines • ▼ Show 20 Line(s) | |||||
352 | 357 | | |||
353 | void KNotificationManager::reparseConfiguration(const QString &app) | 358 | void KNotificationManager::reparseConfiguration(const QString &app) | ||
354 | { | 359 | { | ||
355 | if (!d->dirtyConfigCache.contains(app)) { | 360 | if (!d->dirtyConfigCache.contains(app)) { | ||
356 | d->dirtyConfigCache << app; | 361 | d->dirtyConfigCache << app; | ||
357 | } | 362 | } | ||
358 | } | 363 | } | ||
359 | 364 | | |||
360 | #include "moc_knotificationmanager_p.cpp" | 365 | #include "moc_knotificationmanager_p.cpp" | ||
vonreth: pls fix the duplication |
#elif defined(Q_OS_WIN)