Changeset View
Changeset View
Standalone View
Standalone View
src/knotificationmanager.cpp
Show First 20 Lines • Show All 201 Lines • ▼ Show 20 Line(s) | 201 | } else { | |||
---|---|---|---|---|---|
202 | return false; | 202 | return false; | ||
203 | } | 203 | } | ||
204 | } | 204 | } | ||
205 | 205 | | |||
206 | return true; | 206 | return true; | ||
207 | }, | 207 | }, | ||
208 | this); | 208 | this); | ||
209 | 209 | | |||
210 | Q_FOREACH (QObject *pluginObj, plugins) { | 210 | for (QObject *pluginObj : qAsConst(plugins)) { | ||
211 | KNotificationPlugin *notifyPlugin = qobject_cast<KNotificationPlugin*>(pluginObj); | 211 | KNotificationPlugin *notifyPlugin = qobject_cast<KNotificationPlugin*>(pluginObj); | ||
212 | 212 | | |||
213 | if (notifyPlugin) { | 213 | if (notifyPlugin) { | ||
214 | // We try to avoid unnecessary instantiations (see above), but | 214 | // We try to avoid unnecessary instantiations (see above), but | ||
215 | // when they happen keep the resulting plugins around. | 215 | // when they happen keep the resulting plugins around. | ||
216 | addPlugin(notifyPlugin); | 216 | addPlugin(notifyPlugin); | ||
217 | 217 | | |||
218 | // Get ready to return the plugin we got asked for. | 218 | // Get ready to return the plugin we got asked for. | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 269 | if (force || d->notifications.contains(id)) { | |||
275 | // will call finish() which may close-and-delete the KNotification object | 275 | // will call finish() which may close-and-delete the KNotification object | ||
276 | // before it finishes calling close on all the other plugins. | 276 | // before it finishes calling close on all the other plugins. | ||
277 | // For example: Action=Popup is a single actions but there is 5 loaded | 277 | // For example: Action=Popup is a single actions but there is 5 loaded | ||
278 | // plugins, calling close() on the second would already close-and-delete | 278 | // plugins, calling close() on the second would already close-and-delete | ||
279 | // the notification | 279 | // the notification | ||
280 | KNotifyConfig notifyConfig(n->appName(), n->contexts(), n->eventId()); | 280 | KNotifyConfig notifyConfig(n->appName(), n->contexts(), n->eventId()); | ||
281 | QString notifyActions = notifyConfig.readEntry(QStringLiteral("Action")); | 281 | QString notifyActions = notifyConfig.readEntry(QStringLiteral("Action")); | ||
282 | 282 | | |||
283 | Q_FOREACH (const QString &action, notifyActions.split(QLatin1Char('|'))) { | 283 | const auto listActions = notifyActions.split(QLatin1Char('|')); | ||
284 | for (const QString &action : listActions) { | ||||
284 | if (!d->notifyPlugins.contains(action)) { | 285 | if (!d->notifyPlugins.contains(action)) { | ||
285 | qCDebug(LOG_KNOTIFICATIONS) << "No plugin for action" << action; | 286 | qCDebug(LOG_KNOTIFICATIONS) << "No plugin for action" << action; | ||
286 | continue; | 287 | continue; | ||
287 | } | 288 | } | ||
288 | 289 | | |||
289 | d->notifyPlugins[action]->close(n); | 290 | d->notifyPlugins[action]->close(n); | ||
290 | } | 291 | } | ||
291 | } | 292 | } | ||
Show All 14 Lines | 306 | if (notifyActions.isEmpty() || notifyActions == QLatin1String("None")) { | |||
306 | // this will cause KNotification closing itself fast | 307 | // this will cause KNotification closing itself fast | ||
307 | n->ref(); | 308 | n->ref(); | ||
308 | n->deref(); | 309 | n->deref(); | ||
309 | return -1; | 310 | return -1; | ||
310 | } | 311 | } | ||
311 | 312 | | |||
312 | d->notifications.insert(d->notifyIdCounter, n); | 313 | d->notifications.insert(d->notifyIdCounter, n); | ||
313 | 314 | | |||
314 | Q_FOREACH (const QString &action, notifyActions.split(QLatin1Char('|'))) { | 315 | const auto actionsList = notifyActions.split(QLatin1Char('|')); | ||
316 | for (const QString &action : actionsList) { | ||||
315 | KNotificationPlugin *notifyPlugin = pluginForAction(action); | 317 | KNotificationPlugin *notifyPlugin = pluginForAction(action); | ||
316 | 318 | | |||
317 | if (!notifyPlugin) { | 319 | if (!notifyPlugin) { | ||
318 | qCDebug(LOG_KNOTIFICATIONS) << "No plugin for action" << action; | 320 | qCDebug(LOG_KNOTIFICATIONS) << "No plugin for action" << action; | ||
319 | continue; | 321 | continue; | ||
320 | } | 322 | } | ||
321 | 323 | | |||
322 | n->ref(); | 324 | n->ref(); | ||
323 | qCDebug(LOG_KNOTIFICATIONS) << "Calling notify on" << notifyPlugin->optionName(); | 325 | qCDebug(LOG_KNOTIFICATIONS) << "Calling notify on" << notifyPlugin->optionName(); | ||
324 | notifyPlugin->notify(n, ¬ifyConfig); | 326 | notifyPlugin->notify(n, ¬ifyConfig); | ||
325 | } | 327 | } | ||
326 | 328 | | |||
327 | connect(n, &KNotification::closed, this, &KNotificationManager::notificationClosed); | 329 | connect(n, &KNotification::closed, this, &KNotificationManager::notificationClosed); | ||
328 | return d->notifyIdCounter++; | 330 | return d->notifyIdCounter++; | ||
329 | } | 331 | } | ||
330 | 332 | | |||
331 | void KNotificationManager::update(KNotification *n) | 333 | void KNotificationManager::update(KNotification *n) | ||
332 | { | 334 | { | ||
333 | KNotifyConfig notifyConfig(n->appName(), n->contexts(), n->eventId()); | 335 | KNotifyConfig notifyConfig(n->appName(), n->contexts(), n->eventId()); | ||
334 | 336 | | |||
335 | Q_FOREACH (KNotificationPlugin *p, d->notifyPlugins) { | 337 | for (KNotificationPlugin *p : qAsConst(d->notifyPlugins)) { | ||
336 | p->update(n, ¬ifyConfig); | 338 | p->update(n, ¬ifyConfig); | ||
337 | } | 339 | } | ||
338 | } | 340 | } | ||
339 | 341 | | |||
340 | void KNotificationManager::reemit(KNotification *n) | 342 | void KNotificationManager::reemit(KNotification *n) | ||
341 | { | 343 | { | ||
342 | notify(n); | 344 | notify(n); | ||
343 | } | 345 | } | ||
Show All 9 Lines |