From c47315faa12bbb36772c3f5897751bf74fa122f4 Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Fri, 18 Jul 2014 23:36:05 +0200 Subject: Implemented settings skeleton and notifications --- app/qml/pages/ManagerPage.qml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/qml/pages/ManagerPage.qml b/app/qml/pages/ManagerPage.qml index 92d79b1..a6b6699 100644 --- a/app/qml/pages/ManagerPage.qml +++ b/app/qml/pages/ManagerPage.qml @@ -32,10 +32,17 @@ import QtQuick 2.0 import QtQml 2.1 import Sailfish.Silica 1.0 +import org.nemomobile.configuration 1.0 Page { id: page + ConfigurationGroup { + id: settings + path: "/org/pebbled/settings" + property bool silentWhenConnected: false + } + SilicaFlickable { anchors.fill: parent @@ -121,10 +128,10 @@ Page { } TextSwitch { text: qsTr("Silent when connected") - checked: false + checked: settings.silentWhenConnected automaticCheck: false onClicked: { - console.log('settings.silentConnected'); + settings.silentWhenConnected = !settings.silentWhenConnected; } } } -- cgit v1.2.3 From 3c1e7d693aad55658c4d6d3b061b3368fd145610 Mon Sep 17 00:00:00 2001 From: Philipp Andreas Date: Tue, 22 Jul 2014 22:18:00 +0200 Subject: Adding settings for notifications --- app/qml/pages/ManagerPage.qml | 69 ++++++++++++++++++++++++++++++++++++++++++ daemon/manager.cpp | 2 ++ daemon/notificationmanager.cpp | 41 +++++++++++++++++++++++++ daemon/notificationmanager.h | 3 ++ daemon/settings.h | 18 +++++++++++ 5 files changed, 133 insertions(+) (limited to 'app') diff --git a/app/qml/pages/ManagerPage.qml b/app/qml/pages/ManagerPage.qml index 6f94e4b..04035da 100644 --- a/app/qml/pages/ManagerPage.qml +++ b/app/qml/pages/ManagerPage.qml @@ -41,6 +41,12 @@ Page { id: settings path: "/org/pebbled/settings" property bool silentWhenConnected: false + property bool notificationsCommhistoryd: true + property bool notificationsMissedCall: true + property bool notificationsEmails: false + property bool notificationsMitakuuluu: true + property bool notificationsOther: true + property bool notificationsAll: false } SilicaFlickable { @@ -140,6 +146,69 @@ Page { settings.silentWhenConnected = !settings.silentWhenConnected; } } + + Label { + text: qsTr("Notifications") + font.family: Theme.fontFamilyHeading + color: Theme.highlightColor + anchors.right: parent.right + anchors.rightMargin: Theme.paddingMedium + } + + TextSwitch { + text: qsTr("Messaging (SMS and IM)") + checked: settings.notificationsCommhistoryd + automaticCheck: false + onClicked: { + settings.notificationsCommhistoryd = !settings.notificationsCommhistoryd; + } + } + + TextSwitch { + text: qsTr("Missed call") + checked: settings.notificationsMissedCall + automaticCheck: false + onClicked: { + settings.notificationsMissedCall = !settings.notificationsMissedCall; + } + } + + TextSwitch { + text: qsTr("Emails") + checked: settings.notificationsEmails + automaticCheck: false + onClicked: { + settings.notificationsEmails = !settings.notificationsEmails; + } + } + + TextSwitch { + text: qsTr("Mitakuuluu") + checked: settings.notificationsMitakuuluu + automaticCheck: false + onClicked: { + settings.notificationsMitakuuluu = !settings.notificationsMitakuuluu; + } + } + + TextSwitch { + text: qsTr("Other phone notification") + checked: settings.notificationsOther + automaticCheck: false + onClicked: { + settings.notificationsOther = !settings.notificationsOther; + } + } + + TextSwitch { + text: qsTr("All phone notifications") + checked: settings.notificationsAll + automaticCheck: false + enabled: settings.notificationsOther + onClicked: { + settings.notificationsAll = !settings.notificationsAll; + } + } } } } 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 #include "Logger" +#include "settings.h" #include #include @@ -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: -- cgit v1.2.3 From 5f3e8fd022e29d3014b4e0888f310a5ac512b467 Mon Sep 17 00:00:00 2001 From: Philipp Andreas Date: Wed, 23 Jul 2014 22:12:07 +0200 Subject: Added Twitter support and prepared facebook support --- app/qml/pages/ManagerPage.qml | 21 +++++++++++++++++++++ daemon/manager.cpp | 21 ++++++++++++++------- daemon/manager.h | 2 ++ daemon/notificationmanager.cpp | 12 ++++++++++++ daemon/notificationmanager.h | 2 ++ daemon/settings.h | 6 ++++++ daemon/watchconnector.cpp | 2 +- daemon/watchconnector.h | 2 +- 8 files changed, 59 insertions(+), 9 deletions(-) (limited to 'app') diff --git a/app/qml/pages/ManagerPage.qml b/app/qml/pages/ManagerPage.qml index 04035da..ecb7610 100644 --- a/app/qml/pages/ManagerPage.qml +++ b/app/qml/pages/ManagerPage.qml @@ -45,6 +45,8 @@ Page { property bool notificationsMissedCall: true property bool notificationsEmails: false property bool notificationsMitakuuluu: true + property bool notificationsTwitter: true + property bool notificationsFacebook: true property bool notificationsOther: true property bool notificationsAll: false } @@ -191,6 +193,25 @@ Page { } } + TextSwitch { + text: qsTr("Twitter") + checked: settings.notificationsTwitter + automaticCheck: false + onClicked: { + settings.notificationsTwitter = !settings.notificationsTwitter; + } + } + + TextSwitch { + visible: false //not yet supported + text: qsTr("Facebook") + checked: settings.notificationsFacebook + automaticCheck: false + onClicked: { + settings.notificationsFacebook = !settings.notificationsFacebook; + } + } + TextSwitch { text: qsTr("Other phone notification") checked: settings.notificationsOther diff --git a/daemon/manager.cpp b/daemon/manager.cpp index 4253465..bdda77b 100644 --- a/daemon/manager.cpp +++ b/daemon/manager.cpp @@ -31,6 +31,8 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan connect(notifications, SIGNAL(error(const QString &)), SLOT(onNotifyError(const QString &))); connect(notifications, SIGNAL(emailNotify(const QString &,const QString &,const QString &)), SLOT(onEmailNotify(const QString &,const QString &,const QString &))); connect(notifications, SIGNAL(smsNotify(const QString &,const QString &)), SLOT(onSmsNotify(const QString &,const QString &))); + connect(notifications, SIGNAL(twitterNotify(const QString &,const QString &)), SLOT(onTwitterNotify(const QString &,const QString &))); + connect(notifications, SIGNAL(facebookNotify(const QString &,const QString &)), SLOT(onFacebookNotify(const QString &,const QString &))); connect(watch, SIGNAL(messageDecoded(uint,QByteArray)), commands, SLOT(processMessage(uint,QByteArray))); connect(commands, SIGNAL(hangup()), SLOT(hangupAll())); @@ -197,18 +199,23 @@ void Manager::onNotifyError(const QString &message) void Manager::onSmsNotify(const QString &sender, const QString &data) { - logger()->debug() << "SMS:"; - logger()->debug() << sender; - logger()->debug() << data; watch->sendSMSNotification(sender, data); } +void Manager::onTwitterNotify(const QString &sender, const QString &data) +{ + watch->sendTwitterNotification(sender, data); +} + + +void Manager::onFacebookNotify(const QString &sender, const QString &data) +{ + watch->sendFacebookNotification(sender, data); +} + + void Manager::onEmailNotify(const QString &sender, const QString &data,const QString &subject) { - logger()->debug() << "Email:"; - logger()->debug() << sender; - logger()->debug() << data; - logger()->debug() << subject; watch->sendEmailNotification(sender, data, subject); } diff --git a/daemon/manager.h b/daemon/manager.h index 9a82603..41e614b 100644 --- a/daemon/manager.h +++ b/daemon/manager.h @@ -76,6 +76,8 @@ protected slots: void onActiveVoiceCallStatusChanged(); void onNotifyError(const QString &message); void onSmsNotify(const QString &sender, const QString &data); + void onTwitterNotify(const QString &sender, const QString &data); + void onFacebookNotify(const QString &sender, const QString &data); void onEmailNotify(const QString &sender, const QString &data,const QString &subject); void onMprisPropertiesChanged(QString,QMap,QStringList); void setMprisMetadata(QDBusArgument metadata); diff --git a/daemon/notificationmanager.cpp b/daemon/notificationmanager.cpp index 58bb685..ad2c98f 100644 --- a/daemon/notificationmanager.cpp +++ b/daemon/notificationmanager.cpp @@ -166,6 +166,18 @@ void NotificationManager::Notify(const QString &app_name, uint replaces_id, cons emit this->smsNotify(hints.value("x-nemo-preview-body", "default").toString(), hints.value("x-nemo-preview-summary", "default").toString() ); + + } else if (app_name == "twitter-notifications-client") { + + if (!settings->property("notificationsTwitter").toBool()) { + logger()->debug() << "Ignoring twitter notification because of setting!"; + return; + } + + emit this->twitterNotify(hints.value("x-nemo-preview-body", body).toString(), + hints.value("x-nemo-preview-summary", summary).toString() + ); + } else { //Prioritize x-nemo-preview* over dbus direct summary and body QString subject = hints.value("x-nemo-preview-summary", "").toString(); diff --git a/daemon/notificationmanager.h b/daemon/notificationmanager.h index b1e8e1f..4695db9 100644 --- a/daemon/notificationmanager.h +++ b/daemon/notificationmanager.h @@ -26,6 +26,8 @@ public: Q_SIGNALS: void error(const QString &message); void smsNotify(const QString &sender, const QString &data); + void twitterNotify(const QString &sender, const QString &data); + void facebookNotify(const QString &sender, const QString &data); void emailNotify(const QString &sender, const QString &data,const QString &subject); public Q_SLOTS: diff --git a/daemon/settings.h b/daemon/settings.h index c685c31..1f2e2e5 100644 --- a/daemon/settings.h +++ b/daemon/settings.h @@ -12,6 +12,8 @@ class Settings : public MDConfGroup 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 notificationsTwitter MEMBER notificationsTwitter NOTIFY notificationsTwitterChanged) + Q_PROPERTY(bool notificationsFacebook MEMBER notificationsFacebook NOTIFY notificationsFacebookChanged) Q_PROPERTY(bool notificationsOther MEMBER notificationsOther NOTIFY notificationsOtherChanged) Q_PROPERTY(bool notificationsAll MEMBER notificationsAll NOTIFY notificationsAllChanged) bool silentWhenConnected; @@ -19,6 +21,8 @@ class Settings : public MDConfGroup bool notificationsMissedCall; bool notificationsEmails; bool notificationsMitakuuluu; + bool notificationsTwitter; + bool notificationsFacebook; bool notificationsOther; bool notificationsAll; @@ -33,6 +37,8 @@ signals: void notificationsMissedCallChanged(bool); void notificationsEmailsChanged(bool); void notificationsMitakuuluuChanged(bool); + void notificationsTwitterChanged(bool); + void notificationsFacebookChanged(bool); void notificationsOtherChanged(bool); void notificationsAllChanged(bool); diff --git a/daemon/watchconnector.cpp b/daemon/watchconnector.cpp index 7e70b50..2ad147e 100644 --- a/daemon/watchconnector.cpp +++ b/daemon/watchconnector.cpp @@ -266,7 +266,7 @@ void WatchConnector::sendSMSNotification(QString sender, QString data) sendNotification(leadSMS, sender, data, ""); } -void WatchConnector::sendFaceBookNotification(QString sender, QString data) +void WatchConnector::sendFacebookNotification(QString sender, QString data) { sendNotification(leadFACEBOOK, sender, data, ""); } diff --git a/daemon/watchconnector.h b/daemon/watchconnector.h index d09a8e3..31e861c 100644 --- a/daemon/watchconnector.h +++ b/daemon/watchconnector.h @@ -150,7 +150,7 @@ public slots: void sendNotification(uint lead, QString sender, QString data, QString subject); void sendSMSNotification(QString sender, QString data); void sendEmailNotification(QString sender, QString data, QString subject); - void sendFaceBookNotification(QString sender, QString data); + void sendFacebookNotification(QString sender, QString data); void sendTwitterNotification(QString sender, QString data); void sendMusicNowPlaying(QString track, QString album, QString artist); void sendPhoneVersion(); -- cgit v1.2.3