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