diff options
| author | Philipp Andreas <github@smurfy.de> | 2014-07-22 22:18:00 +0200 |
|---|---|---|
| committer | Philipp Andreas <github@smurfy.de> | 2014-07-22 22:18:00 +0200 |
| commit | 3c1e7d693aad55658c4d6d3b061b3368fd145610 (patch) | |
| tree | 1cc6b732c6f42a1162f6b9ac056ae7537587ba32 /daemon | |
| parent | ee7c3abcc960f5d4fd8686f3f3478c6f77e39b82 (diff) | |
Adding settings for notifications
Diffstat (limited to 'daemon')
| -rw-r--r-- | daemon/manager.cpp | 2 | ||||
| -rw-r--r-- | daemon/notificationmanager.cpp | 41 | ||||
| -rw-r--r-- | daemon/notificationmanager.h | 3 | ||||
| -rw-r--r-- | daemon/settings.h | 18 |
4 files changed, 64 insertions, 0 deletions
diff --git a/daemon/manager.cpp b/daemon/manager.cpp index 41617e4..4253465 100644 --- a/daemon/manager.cpp +++ b/daemon/manager.cpp @@ -9,6 +9,8 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan QObject(0), watch(watch), dbus(dbus), voice(voice), notifications(notifications), commands(new WatchCommands(watch, this)), settings(settings), notification(MNotification::DeviceEvent) { + notifications->setSettings(settings);; + connect(settings, SIGNAL(valueChanged(QString)), SLOT(onSettingChanged(const QString&))); connect(settings, SIGNAL(valuesChanged()), SLOT(onSettingsChanged())); //connect(settings, SIGNAL(silentWhenConnectedChanged(bool)), SLOT(onSilentWhenConnectedChanged(bool))); diff --git a/daemon/notificationmanager.cpp b/daemon/notificationmanager.cpp index b758df2..58bb685 100644 --- a/daemon/notificationmanager.cpp +++ b/daemon/notificationmanager.cpp @@ -104,6 +104,11 @@ QStringHash NotificationManager::getCategoryParams(QString category) return QStringHash(); } +void NotificationManager::setSettings(Settings *settings) +{ + this->settings = settings; +} + void NotificationManager::Notify(const QString &app_name, uint replaces_id, const QString &app_icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantHash &hints, int expire_timeout) { @@ -118,8 +123,15 @@ void NotificationManager::Notify(const QString &app_name, uint replaces_id, cons } logger()->debug() << Q_FUNC_INFO << "Got notification via dbus from" << this->getCleanAppName(app_name); + logger()->debug() << hints; if (app_name == "messageserver5") { + + if (!settings->property("notificationsEmails").toBool()) { + logger()->debug() << "Ignoring email notification because of setting!"; + return; + } + QString subject = hints.value("x-nemo-preview-summary", "").toString(); QString data = hints.value("x-nemo-preview-body", "").toString(); if (!data.isEmpty() && !subject.isEmpty()) { @@ -127,11 +139,30 @@ void NotificationManager::Notify(const QString &app_name, uint replaces_id, cons } } else if (app_name == "commhistoryd") { if (summary == "" && body == "") { + QString category = hints.value("category", "").toString(); + + if (category == "x-nemo.call.missed") { + if (!settings->property("notificationsMissedCall").toBool()) { + logger()->debug() << "Ignoring MissedCall notification because of setting!"; + return; + } + } else { + if (!settings->property("notificationsCommhistoryd").toBool()) { + logger()->debug() << "Ignoring commhistoryd notification because of setting!"; + return; + } + } emit this->smsNotify(hints.value("x-nemo-preview-summary", "default").toString(), hints.value("x-nemo-preview-body", "default").toString() ); } } else if (app_name == "harbour-mitakuuluu2-server") { + + if (!settings->property("notificationsMitakuuluu").toBool()) { + logger()->debug() << "Ignoring mitakuuluu notification because of setting!"; + return; + } + emit this->smsNotify(hints.value("x-nemo-preview-body", "default").toString(), hints.value("x-nemo-preview-summary", "default").toString() ); @@ -145,6 +176,16 @@ void NotificationManager::Notify(const QString &app_name, uint replaces_id, cons logger()->debug() << "MSG Prio:" << prio; + if (!settings->property("notificationsAll").toBool() && prio <= 10) { + logger()->debug() << "Ignoring notification because of setting! (all)"; + return; + } + + if (!settings->property("notificationsOther").toBool() && prio < 90) { + logger()->debug() << "Ignoring notification because of setting! (other)"; + return; + } + if (subject.isEmpty()) { subject = summary; } diff --git a/daemon/notificationmanager.h b/daemon/notificationmanager.h index d2640eb..b1e8e1f 100644 --- a/daemon/notificationmanager.h +++ b/daemon/notificationmanager.h @@ -3,6 +3,7 @@ #include <QObject> #include "Logger" +#include "settings.h" #include <QDBusInterface> #include <QDBusPendingCallWatcher> @@ -29,6 +30,7 @@ Q_SIGNALS: public Q_SLOTS: void Notify(const QString &app_name, uint replaces_id, const QString &app_icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantHash &hints, int expire_timeout); + void setSettings(Settings *settings); protected Q_SLOTS: void initialize(bool notifyError = false); @@ -38,6 +40,7 @@ private: QString getCleanAppName(QString app_name); QStringHash getCategoryParams(QString category); + Settings *settings; Q_DISABLE_COPY(NotificationManager) Q_DECLARE_PRIVATE(NotificationManager) diff --git a/daemon/settings.h b/daemon/settings.h index 50ffd86..c685c31 100644 --- a/daemon/settings.h +++ b/daemon/settings.h @@ -8,7 +8,19 @@ class Settings : public MDConfGroup Q_OBJECT Q_PROPERTY(bool silentWhenConnected MEMBER silentWhenConnected NOTIFY silentWhenConnectedChanged) + Q_PROPERTY(bool notificationsCommhistoryd MEMBER notificationsCommhistoryd NOTIFY notificationsCommhistorydChanged) + Q_PROPERTY(bool notificationsMissedCall MEMBER notificationsMissedCall NOTIFY notificationsMissedCallChanged) + Q_PROPERTY(bool notificationsEmails MEMBER notificationsEmails NOTIFY notificationsEmailsChanged) + Q_PROPERTY(bool notificationsMitakuuluu MEMBER notificationsMitakuuluu NOTIFY notificationsMitakuuluuChanged) + Q_PROPERTY(bool notificationsOther MEMBER notificationsOther NOTIFY notificationsOtherChanged) + Q_PROPERTY(bool notificationsAll MEMBER notificationsAll NOTIFY notificationsAllChanged) bool silentWhenConnected; + bool notificationsCommhistoryd; + bool notificationsMissedCall; + bool notificationsEmails; + bool notificationsMitakuuluu; + bool notificationsOther; + bool notificationsAll; public: explicit Settings(QObject *parent = 0) : @@ -17,6 +29,12 @@ public: signals: void silentWhenConnectedChanged(bool); + void notificationsCommhistorydChanged(bool); + void notificationsMissedCallChanged(bool); + void notificationsEmailsChanged(bool); + void notificationsMitakuuluuChanged(bool); + void notificationsOtherChanged(bool); + void notificationsAllChanged(bool); public slots: |
