Changeset View
Changeset View
Standalone View
Standalone View
dataengines/devicenotifications/devicenotificationsengine.cpp
Show All 18 Lines | |||||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "devicenotificationsengine.h" | 21 | #include "devicenotificationsengine.h" | ||
22 | 22 | | |||
23 | #include <Plasma/DataContainer> | 23 | #include <Plasma/DataContainer> | ||
24 | 24 | | |||
25 | DeviceNotificationsEngine::DeviceNotificationsEngine( QObject* parent, const QVariantList& args ) | 25 | DeviceNotificationsEngine::DeviceNotificationsEngine( QObject* parent, const QVariantList& args ) | ||
26 | : Plasma::DataEngine( parent, args ), | 26 | : Plasma::DataEngine( parent, args ), | ||
27 | m_id(0), | | |||
28 | m_solidNotify(new KSolidNotify(this)) | 27 | m_solidNotify(new KSolidNotify(this)) | ||
29 | { | 28 | { | ||
30 | connect(m_solidNotify, &KSolidNotify::notify, this, &DeviceNotificationsEngine::notify); | 29 | connect(m_solidNotify, &KSolidNotify::notify, this, &DeviceNotificationsEngine::notify); | ||
30 | connect(m_solidNotify, &KSolidNotify::clearNotification, this, &DeviceNotificationsEngine::clearNotification); | ||||
31 | } | 31 | } | ||
32 | 32 | | |||
33 | DeviceNotificationsEngine::~DeviceNotificationsEngine() | 33 | DeviceNotificationsEngine::~DeviceNotificationsEngine() | ||
34 | { | 34 | { | ||
35 | } | 35 | } | ||
36 | 36 | | |||
37 | void DeviceNotificationsEngine::notify(Solid::ErrorType solidError, const QString& error, const QString& errorDetails, const QString &udi) | 37 | void DeviceNotificationsEngine::notify(Solid::ErrorType solidError, const QString& error, const QString& errorDetails, const QString &udi) | ||
38 | { | 38 | { | ||
39 | const QString source = QStringLiteral("notification %1").arg(m_id++); | 39 | const QString source = QStringLiteral("%1 notification").arg(udi); | ||
broulik: This potentially breaks applets relying on the structure of that name? Not sure how big of an… | |||||
The only user I could find is the device notifier, which relies on the contents of the container only for matching, and does not require any specific format for the source name. bruns: The only user I could find is the device notifier, which relies on the contents of the… | |||||
40 | 40 | | |||
41 | Plasma::DataEngine::Data notificationData; | 41 | Plasma::DataEngine::Data notificationData; | ||
42 | notificationData.insert(QStringLiteral("solidError"), solidError); | 42 | notificationData.insert(QStringLiteral("solidError"), solidError); | ||
43 | notificationData.insert(QStringLiteral("error"), error); | 43 | notificationData.insert(QStringLiteral("error"), error); | ||
44 | notificationData.insert(QStringLiteral("errorDetails"), errorDetails); | 44 | notificationData.insert(QStringLiteral("errorDetails"), errorDetails); | ||
45 | notificationData.insert(QStringLiteral("udi"), udi); | 45 | notificationData.insert(QStringLiteral("udi"), udi); | ||
46 | 46 | | |||
47 | setData(source, notificationData ); | 47 | setData(source, notificationData ); | ||
48 | } | 48 | } | ||
49 | 49 | | |||
50 | void DeviceNotificationsEngine::clearNotification(const QString &udi) | ||||
51 | { | ||||
52 | removeSource(QStringLiteral("%1 notification").arg(udi)); | ||||
53 | } | ||||
54 | | ||||
50 | K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(devicenotifications, DeviceNotificationsEngine, "plasma-dataengine-devicenotifications.json") | 55 | K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(devicenotifications, DeviceNotificationsEngine, "plasma-dataengine-devicenotifications.json") | ||
51 | 56 | | |||
52 | #include "devicenotificationsengine.moc" | 57 | #include "devicenotificationsengine.moc" |
This potentially breaks applets relying on the structure of that name? Not sure how big of an issue this is as far as "API promise" we give for dataengines but perhaps at least keep the notification part first