From cd3011c3ca4eb24627870326d676551edda1c030 Mon Sep 17 00:00:00 2001 From: Philipp Andreas Date: Thu, 10 Jul 2014 21:54:43 +0200 Subject: Never send notifications with empty parts. replace empty strings by one space (or the message does not get displayed) --- daemon/watchconnector.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'daemon') diff --git a/daemon/watchconnector.cpp b/daemon/watchconnector.cpp index dbcd831..ff64a02 100644 --- a/daemon/watchconnector.cpp +++ b/daemon/watchconnector.cpp @@ -249,10 +249,10 @@ QString WatchConnector::timeStamp() void WatchConnector::sendNotification(unsigned int lead, QString sender, QString data, QString subject) { QStringList tmp; - tmp.append(sender); - tmp.append(data); + tmp.append(sender.isEmpty() ? " " : sender); + tmp.append(data.isEmpty() ? " " : data); tmp.append(timeStamp()); - if (lead == 0) tmp.append(subject); + if (lead == 0) tmp.append(subject.isEmpty() ? " " : subject); QByteArray res = buildMessageData(lead, tmp); -- cgit v1.2.3 From a4084dcd38a78dfc9113168e378b5fa7f7e9f6ea Mon Sep 17 00:00:00 2001 From: Philipp Andreas Date: Thu, 10 Jul 2014 21:56:19 +0200 Subject: Adding support for default notifications. --- daemon/daemon.cpp | 3 +- daemon/daemon.pro | 6 +- daemon/manager.cpp | 31 ++++++++++- daemon/manager.h | 8 ++- daemon/notificationmanager.cpp | 124 +++++++++++++++++++++++++++++++++++++++++ daemon/notificationmanager.h | 41 ++++++++++++++ 6 files changed, 206 insertions(+), 7 deletions(-) create mode 100644 daemon/notificationmanager.cpp create mode 100644 daemon/notificationmanager.h (limited to 'daemon') diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp index ab61171..66352fd 100644 --- a/daemon/daemon.cpp +++ b/daemon/daemon.cpp @@ -50,8 +50,9 @@ int main(int argc, char *argv[]) watch::WatchConnector watch; DBusConnector dbus; VoiceCallManager voice; + NotificationManager notifications; - Manager manager(&watch, &dbus, &voice); + Manager manager(&watch, &dbus, &voice, ¬ifications); signal(SIGINT, signalhandler); signal(SIGTERM, signalhandler); diff --git a/daemon/daemon.pro b/daemon/daemon.pro index deadea0..2c4894a 100644 --- a/daemon/daemon.pro +++ b/daemon/daemon.pro @@ -16,7 +16,8 @@ SOURCES += \ voicecallhandler.cpp \ watchconnector.cpp \ dbusconnector.cpp \ - dbusadaptor.cpp + dbusadaptor.cpp \ + notificationmanager.cpp HEADERS += \ manager.h \ @@ -24,7 +25,8 @@ HEADERS += \ voicecallhandler.h \ watchconnector.h \ dbusconnector.h \ - dbusadaptor.h + dbusadaptor.h \ + notificationmanager.h INSTALLS += target pebbled diff --git a/daemon/manager.cpp b/daemon/manager.cpp index f25e724..11444fe 100644 --- a/daemon/manager.cpp +++ b/daemon/manager.cpp @@ -5,8 +5,8 @@ #include #include -Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice) : - QObject(0), watch(watch), dbus(dbus), voice(voice), +Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice, NotificationManager *notifications) : + QObject(0), watch(watch), dbus(dbus), voice(voice), notifications(notifications), notification(MNotification::DeviceEvent) { // We don't need to handle presence changes, so report them separately and ignore them @@ -24,6 +24,10 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan connect(voice, SIGNAL(activeVoiceCallChanged()), SLOT(onActiveVoiceCallChanged())); connect(voice, SIGNAL(error(const QString &)), SLOT(onVoiceError(const QString &))); + 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 &))); + // Watch instantiated hangup, follow the orders connect(watch, SIGNAL(hangup()), SLOT(hangupAll())); connect(watch, SIGNAL(connectedChanged()), SLOT(onConnectedChanged())); @@ -145,6 +149,29 @@ void Manager::onVoiceError(const QString &message) qWarning() << "Error: " << message; } + +void Manager::onNotifyError(const QString &message) +{ + qWarning() << "Error: " << message; +} + +void Manager::onSmsNotify(const QString &sender, const QString &data) +{ + qDebug() << "SMS:"; + qDebug() << sender; + qDebug() << data; + watch->sendSMSNotification(sender, data); +} + +void Manager::onEmailNotify(const QString &sender, const QString &data,const QString &subject) +{ + qDebug() << "Email:"; + qDebug() << sender; + qDebug() << data; + qDebug() << subject; + watch->sendEmailNotification(sender, data, subject); +} + void Manager::hangupAll() { foreach (VoiceCallHandler* handler, voice->voiceCalls()) { diff --git a/daemon/manager.h b/daemon/manager.h index 8d3c8de..9ad611e 100644 --- a/daemon/manager.h +++ b/daemon/manager.h @@ -4,6 +4,7 @@ #include "watchconnector.h" #include "dbusconnector.h" #include "voicecallmanager.h" +#include "notificationmanager.h" #include #include @@ -26,6 +27,7 @@ class Manager : public QObject watch::WatchConnector *watch; DBusConnector *dbus; VoiceCallManager *voice; + NotificationManager *notifications; MNotification notification; @@ -34,7 +36,7 @@ class Manager : public QObject GroupManager *conversations; public: - explicit Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice); + explicit Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice, NotificationManager *notifications); Q_INVOKABLE QString findPersonByNumber(QString number); Q_INVOKABLE void processUnreadMessages(GroupObject *group); @@ -52,7 +54,9 @@ protected slots: void onActiveVoiceCallStatusChanged(); void onConversationGroupAdded(GroupObject *group); void onUnreadMessagesChanged(); - + void onNotifyError(const QString &message); + void onSmsNotify(const QString &sender, const QString &data); + void onEmailNotify(const QString &sender, const QString &data,const QString &subject); }; class PebbledProxy : public QObject diff --git a/daemon/notificationmanager.cpp b/daemon/notificationmanager.cpp new file mode 100644 index 0000000..f6b745a --- /dev/null +++ b/daemon/notificationmanager.cpp @@ -0,0 +1,124 @@ +#include "notificationmanager.h" + +#include +#include +#include +#include +#include +#include + +class NotificationManagerPrivate +{ + Q_DECLARE_PUBLIC(NotificationManager) + +public: + NotificationManagerPrivate(NotificationManager *q) + : q_ptr(q), + interface(NULL), + connected(false) + { /*...*/ } + + NotificationManager *q_ptr; + + QDBusInterface *interface; + + bool connected; +}; + +NotificationManager::NotificationManager(QObject *parent) + : QObject(parent), d_ptr(new NotificationManagerPrivate(this)) +{ + Q_D(NotificationManager); + QDBusConnection::sessionBus().registerObject("/org/freedesktop/Notifications", this, QDBusConnection::ExportAllSlots); + + d->interface = new QDBusInterface("org.freedesktop.DBus", + "/org/freedesktop/DBus", + "org.freedesktop.DBus"); + + d->interface->call("AddMatch", "interface='org.freedesktop.Notifications',member='Notify',type='method_call',eavesdrop='true'"); + + this->initialize(); +} + +NotificationManager::~NotificationManager() +{ + Q_D(NotificationManager); + delete d; +} + + +void NotificationManager::initialize(bool notifyError) +{ + Q_D(NotificationManager); + bool success = false; + + if(d->interface->isValid()) + { + success = true; + } + + if(!(d->connected = success)) + { + QTimer::singleShot(2000, this, SLOT(initialize())); + if(notifyError) emit this->error("Failed to connect to Notifications D-Bus service."); + } +} + +QDBusInterface* NotificationManager::interface() const +{ + Q_D(const NotificationManager); + return d->interface; +} + +QString NotificationManager::detectCleanAppname(QString app_name) +{ + QString desktopFile = "/usr/share/applications/" + app_name + ".desktop"; + QFile testFile(desktopFile); + if (testFile.exists()) { + QSettings settings(desktopFile, QSettings::IniFormat); + settings.beginGroup("Desktop Entry"); + QString cleanName = settings.value("Name").toString(); + settings.endGroup(); + if (!cleanName.isEmpty()) { + return cleanName; + } + } + return app_name; +} + +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) { + + //Ignore notifcations from myself + if (app_name == "pebbled") { + return; + } + + qDebug() << "Got notification via dbus from" << detectCleanAppname(app_name); + + if (app_name == "messageserver5") { + emit this->emailNotify(hints.value("x-nemo-preview-summary", detectCleanAppname(app_name)).toString(), + "", + hints.value("x-nemo-preview-body", "").toString() + ); + } else if (app_name == "commhistoryd") { + if (summary == "" && body == "") { + emit this->smsNotify(hints.value("x-nemo-preview-summary", "default").toString(), + hints.value("x-nemo-preview-body", "default").toString() + ); + } + } else { + QString data = summary; + QString subject = body; + if (data.isEmpty()) { + data = hints.value("x-nemo-preview-summary", "").toString(); + } + if (subject.isEmpty()) { + subject = hints.value("x-nemo-preview-body", "").toString(); + } + if (subject.isEmpty() && !data.isEmpty()) { + subject = data; + data = ""; + } + emit this->emailNotify(detectCleanAppname(app_name), data, subject); + } +} diff --git a/daemon/notificationmanager.h b/daemon/notificationmanager.h new file mode 100644 index 0000000..dd3f8bb --- /dev/null +++ b/daemon/notificationmanager.h @@ -0,0 +1,41 @@ +#ifndef NOTIFICATIONMANAGER_H +#define NOTIFICATIONMANAGER_H + +#include + +#include +#include + +class NotificationManager : public QObject +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Notifications") + + Q_PROPERTY(QDBusInterface* interface READ interface) +public: + explicit NotificationManager(QObject *parent = 0); + ~NotificationManager(); + + QDBusInterface* interface() const; + +Q_SIGNALS: + void error(const QString &message); + void smsNotify(const QString &sender, const QString &data); + void emailNotify(const QString &sender, const QString &data,const QString &subject); + +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); + +protected Q_SLOTS: + void initialize(bool notifyError = false); + +private: + class NotificationManagerPrivate *d_ptr; + + QString detectCleanAppname(QString app_name); + + Q_DISABLE_COPY(NotificationManager) + Q_DECLARE_PRIVATE(NotificationManager) +}; + +#endif // NOTIFICATIONMANAGER_H -- cgit v1.2.3 From ca5dfb4d10067d98c10822a31d6081e093dfdf4b Mon Sep 17 00:00:00 2001 From: Philipp Andreas Date: Fri, 11 Jul 2014 20:44:38 +0200 Subject: Removed commhistory interface to get new messages --- daemon/manager.cpp | 39 --------------------------------------- daemon/manager.h | 6 ------ 2 files changed, 45 deletions(-) (limited to 'daemon') diff --git a/daemon/manager.cpp b/daemon/manager.cpp index 11444fe..f02dc0c 100644 --- a/daemon/manager.cpp +++ b/daemon/manager.cpp @@ -17,10 +17,6 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan numberFilter.setDetailType(QContactDetail::TypePhoneNumber, QContactPhoneNumber::FieldNumber); numberFilter.setMatchFlags(QContactFilter::MatchPhoneNumber); - conversations = new GroupManager(this); - connect(conversations, SIGNAL(groupAdded(GroupObject*)), SLOT(onConversationGroupAdded(GroupObject*))); - conversations->getGroups(); - connect(voice, SIGNAL(activeVoiceCallChanged()), SLOT(onActiveVoiceCallChanged())); connect(voice, SIGNAL(error(const QString &)), SLOT(onVoiceError(const QString &))); @@ -178,38 +174,3 @@ void Manager::hangupAll() handler->hangup(); } } - -void Manager::onConversationGroupAdded(GroupObject *group) -{ - if (!group) { - qWarning() << "Got null conversation group"; - return; - } - - connect(group, SIGNAL(unreadMessagesChanged()), SLOT(onUnreadMessagesChanged())); - if (group->unreadMessages()) processUnreadMessages(group); -} - - -void Manager::onUnreadMessagesChanged() -{ - GroupObject *group = qobject_cast(sender()); - if (!group) { - qWarning() << "Got unreadMessagesChanged for null group"; - return; - } - processUnreadMessages(group); -} - -void Manager::processUnreadMessages(GroupObject *group) -{ - if (group->unreadMessages()) { - QString name = group->contactName(); - QString message = group->lastMessageText(); - qDebug() << "Msg:" << message; - qDebug() << "From:" << name; - watch->sendSMSNotification(name.isEmpty()?"Unknown":name, message); - } else { - qWarning() << "Got processUnreadMessages for group with no new messages"; - } -} diff --git a/daemon/manager.h b/daemon/manager.h index 9ad611e..4bf8f98 100644 --- a/daemon/manager.h +++ b/daemon/manager.h @@ -10,11 +10,9 @@ #include #include #include -#include #include using namespace QtContacts; -using namespace CommHistory; class Manager : public QObject { @@ -33,13 +31,11 @@ class Manager : public QObject QContactManager *contacts; QContactDetailFilter numberFilter; - GroupManager *conversations; public: explicit Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice, NotificationManager *notifications); Q_INVOKABLE QString findPersonByNumber(QString number); - Q_INVOKABLE void processUnreadMessages(GroupObject *group); signals: @@ -52,8 +48,6 @@ protected slots: void onActiveVoiceCallChanged(); void onVoiceError(const QString &message); void onActiveVoiceCallStatusChanged(); - void onConversationGroupAdded(GroupObject *group); - void onUnreadMessagesChanged(); void onNotifyError(const QString &message); void onSmsNotify(const QString &sender, const QString &data); void onEmailNotify(const QString &sender, const QString &data,const QString &subject); -- cgit v1.2.3 From 64aec8ec9808de66dfc185dfb82fc9d6cd1f004c Mon Sep 17 00:00:00 2001 From: Philipp Andreas Date: Fri, 11 Jul 2014 22:25:56 +0200 Subject: Sending the string as it is even if empty, but always \0 terminate all strings. Fixes empty string to get received. Also an empty subject does not occupy space on the pebble notification. --- daemon/watchconnector.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'daemon') diff --git a/daemon/watchconnector.cpp b/daemon/watchconnector.cpp index ff64a02..955ba13 100644 --- a/daemon/watchconnector.cpp +++ b/daemon/watchconnector.cpp @@ -214,8 +214,9 @@ void WatchConnector::buildData(QByteArray &res, QStringList data) for (QString d : data) { QByteArray tmp = d.left(0xF0).toUtf8(); - res.append(tmp.length() & 0xFF); + res.append((tmp.length() + 1) & 0xFF); res.append(tmp); + res.append('\0'); } } @@ -249,10 +250,10 @@ QString WatchConnector::timeStamp() void WatchConnector::sendNotification(unsigned int lead, QString sender, QString data, QString subject) { QStringList tmp; - tmp.append(sender.isEmpty() ? " " : sender); - tmp.append(data.isEmpty() ? " " : data); + tmp.append(sender); + tmp.append(data); tmp.append(timeStamp()); - if (lead == 0) tmp.append(subject.isEmpty() ? " " : subject); + if (lead == 0) tmp.append(subject); QByteArray res = buildMessageData(lead, tmp); -- cgit v1.2.3 From 8405d4e2318291b0337812e5476a9d1e44ec9152 Mon Sep 17 00:00:00 2001 From: Philipp Andreas Date: Fri, 11 Jul 2014 22:27:49 +0200 Subject: Prioritize data not the subject. If subject is empty it does not get displayed. Also the data value get shown in the notification overview screen, while the subject is not. --- daemon/notificationmanager.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'daemon') diff --git a/daemon/notificationmanager.cpp b/daemon/notificationmanager.cpp index f6b745a..8a2129e 100644 --- a/daemon/notificationmanager.cpp +++ b/daemon/notificationmanager.cpp @@ -97,8 +97,8 @@ void NotificationManager::Notify(const QString &app_name, uint replaces_id, cons if (app_name == "messageserver5") { emit this->emailNotify(hints.value("x-nemo-preview-summary", detectCleanAppname(app_name)).toString(), - "", - hints.value("x-nemo-preview-body", "").toString() + hints.value("x-nemo-preview-body", "").toString(), + "" ); } else if (app_name == "commhistoryd") { if (summary == "" && body == "") { @@ -115,9 +115,9 @@ void NotificationManager::Notify(const QString &app_name, uint replaces_id, cons if (subject.isEmpty()) { subject = hints.value("x-nemo-preview-body", "").toString(); } - if (subject.isEmpty() && !data.isEmpty()) { - subject = data; - data = ""; + if (data.isEmpty() && !subject.isEmpty()) { + data = subject; + subject = ""; } emit this->emailNotify(detectCleanAppname(app_name), data, subject); } -- cgit v1.2.3 From 959e251f2336e21d3615b1525a38773fe58ab2e7 Mon Sep 17 00:00:00 2001 From: Philipp Andreas Date: Fri, 11 Jul 2014 22:34:02 +0200 Subject: Fix for the \0 termination to trim the original string to max 239 bytes instead of 240. --- daemon/watchconnector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'daemon') diff --git a/daemon/watchconnector.cpp b/daemon/watchconnector.cpp index 955ba13..9d8676e 100644 --- a/daemon/watchconnector.cpp +++ b/daemon/watchconnector.cpp @@ -213,7 +213,7 @@ void WatchConnector::buildData(QByteArray &res, QStringList data) { for (QString d : data) { - QByteArray tmp = d.left(0xF0).toUtf8(); + QByteArray tmp = d.left(0xEF).toUtf8(); res.append((tmp.length() + 1) & 0xFF); res.append(tmp); res.append('\0'); -- cgit v1.2.3 From b8e1190847ff8cad9276bc1bc751aef454a713d4 Mon Sep 17 00:00:00 2001 From: Philipp Andreas Date: Sat, 12 Jul 2014 09:45:33 +0200 Subject: Using log4qt logging instead of qDebug() --- daemon/notificationmanager.cpp | 2 +- daemon/notificationmanager.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'daemon') diff --git a/daemon/notificationmanager.cpp b/daemon/notificationmanager.cpp index 8a2129e..8524083 100644 --- a/daemon/notificationmanager.cpp +++ b/daemon/notificationmanager.cpp @@ -93,7 +93,7 @@ void NotificationManager::Notify(const QString &app_name, uint replaces_id, cons return; } - qDebug() << "Got notification via dbus from" << detectCleanAppname(app_name); + logger()->debug() << Q_FUNC_INFO << "Got notification via dbus from" << detectCleanAppname(app_name); if (app_name == "messageserver5") { emit this->emailNotify(hints.value("x-nemo-preview-summary", detectCleanAppname(app_name)).toString(), diff --git a/daemon/notificationmanager.h b/daemon/notificationmanager.h index dd3f8bb..45ae090 100644 --- a/daemon/notificationmanager.h +++ b/daemon/notificationmanager.h @@ -2,6 +2,7 @@ #define NOTIFICATIONMANAGER_H #include +#include "Logger" #include #include @@ -9,6 +10,7 @@ class NotificationManager : public QObject { Q_OBJECT + LOG4QT_DECLARE_QCLASS_LOGGER Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Notifications") Q_PROPERTY(QDBusInterface* interface READ interface) -- cgit v1.2.3 From 851dfd95c158607a25c35ce25f97f80a3f57ad74 Mon Sep 17 00:00:00 2001 From: Philipp Andreas Date: Sat, 12 Jul 2014 10:01:23 +0200 Subject: Changed notifications prio and added a error logging --- daemon/notificationmanager.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'daemon') diff --git a/daemon/notificationmanager.cpp b/daemon/notificationmanager.cpp index 8524083..a0a99e0 100644 --- a/daemon/notificationmanager.cpp +++ b/daemon/notificationmanager.cpp @@ -97,7 +97,7 @@ void NotificationManager::Notify(const QString &app_name, uint replaces_id, cons if (app_name == "messageserver5") { emit this->emailNotify(hints.value("x-nemo-preview-summary", detectCleanAppname(app_name)).toString(), - hints.value("x-nemo-preview-body", "").toString(), + hints.value("x-nemo-preview-body", "default").toString(), "" ); } else if (app_name == "commhistoryd") { @@ -107,18 +107,29 @@ void NotificationManager::Notify(const QString &app_name, uint replaces_id, cons ); } } else { - QString data = summary; - QString subject = body; - if (data.isEmpty()) { - data = hints.value("x-nemo-preview-summary", "").toString(); - } + //Prioritize x-nemo-preview* over dbus direct summary and body + QString subject = hints.value("x-nemo-preview-summary", "").toString(); + QString data = hints.value("x-nemo-preview-body", "").toString(); + if (subject.isEmpty()) { - subject = hints.value("x-nemo-preview-body", "").toString(); + subject = summary; + } + if (data.isEmpty()) { + data = body; } + + //Prioritize data over subject if (data.isEmpty() && !subject.isEmpty()) { data = subject; subject = ""; } + + //Never send empty data and subject + if (data.isEmpty() && subject.isEmpty()) { + logger()->warn() << Q_FUNC_INFO << "Empty subject and data in dbus app " << app_name; + return; + } + emit this->emailNotify(detectCleanAppname(app_name), data, subject); } } -- cgit v1.2.3 From c911932934f0a7d8bf1c252be4a3e718859b3b09 Mon Sep 17 00:00:00 2001 From: Philipp Andreas Date: Sat, 12 Jul 2014 19:07:33 +0200 Subject: Adding basic Mitakuuluu support, started reading the notification category, a bit cleanup --- daemon/notificationmanager.cpp | 37 ++++++++++++++++++++++++++++++++----- daemon/notificationmanager.h | 5 ++++- 2 files changed, 36 insertions(+), 6 deletions(-) (limited to 'daemon') diff --git a/daemon/notificationmanager.cpp b/daemon/notificationmanager.cpp index a0a99e0..917a245 100644 --- a/daemon/notificationmanager.cpp +++ b/daemon/notificationmanager.cpp @@ -70,9 +70,9 @@ QDBusInterface* NotificationManager::interface() const return d->interface; } -QString NotificationManager::detectCleanAppname(QString app_name) +QString NotificationManager::getCleanAppName(QString app_name) { - QString desktopFile = "/usr/share/applications/" + app_name + ".desktop"; + QString desktopFile = QString("/usr/share/applications/%1.desktop").arg(app_name); QFile testFile(desktopFile); if (testFile.exists()) { QSettings settings(desktopFile, QSettings::IniFormat); @@ -86,6 +86,24 @@ QString NotificationManager::detectCleanAppname(QString app_name) return app_name; } +QStringHash NotificationManager::getCategoryParams(QString category) +{ + if (!category.isEmpty()) { + QString categoryConfigFile = QString("/usr/share/lipstick/notificationcategories/%1.conf").arg(category); + QFile testFile(categoryConfigFile); + if (testFile.exists()) { + QStringHash categories; + QSettings settings(categoryConfigFile, QSettings::IniFormat); + const QStringList settingKeys = settings.allKeys(); + foreach (const QString &settingKey, settingKeys) { + categories[settingKey] = settings.value(settingKey).toString(); + } + return categories; + } + } + return QStringHash(); +} + 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) { //Ignore notifcations from myself @@ -93,10 +111,10 @@ void NotificationManager::Notify(const QString &app_name, uint replaces_id, cons return; } - logger()->debug() << Q_FUNC_INFO << "Got notification via dbus from" << detectCleanAppname(app_name); + logger()->debug() << Q_FUNC_INFO << "Got notification via dbus from" << this->getCleanAppName(app_name); if (app_name == "messageserver5") { - emit this->emailNotify(hints.value("x-nemo-preview-summary", detectCleanAppname(app_name)).toString(), + emit this->emailNotify(hints.value("x-nemo-preview-summary", this->getCleanAppName(app_name)).toString(), hints.value("x-nemo-preview-body", "default").toString(), "" ); @@ -106,10 +124,19 @@ void NotificationManager::Notify(const QString &app_name, uint replaces_id, cons hints.value("x-nemo-preview-body", "default").toString() ); } + } else if (app_name == "harbour-mitakuuluu2-server") { + emit this->smsNotify(hints.value("x-nemo-preview-body", "default").toString(), + hints.value("x-nemo-preview-summary", "default").toString() + ); } else { //Prioritize x-nemo-preview* over dbus direct summary and body QString subject = hints.value("x-nemo-preview-summary", "").toString(); QString data = hints.value("x-nemo-preview-body", "").toString(); + QString category = hints.value("category", "").toString(); + QStringHash categoryParams = this->getCategoryParams(category); + int prio = categoryParams.value("x-nemo-priority", "0").toInt(); + + logger()->debug() << "MSG Prio:" << prio; if (subject.isEmpty()) { subject = summary; @@ -130,6 +157,6 @@ void NotificationManager::Notify(const QString &app_name, uint replaces_id, cons return; } - emit this->emailNotify(detectCleanAppname(app_name), data, subject); + emit this->emailNotify(this->getCleanAppName(app_name), data, subject); } } diff --git a/daemon/notificationmanager.h b/daemon/notificationmanager.h index 45ae090..d2640eb 100644 --- a/daemon/notificationmanager.h +++ b/daemon/notificationmanager.h @@ -7,6 +7,8 @@ #include #include +typedef QHash QStringHash; + class NotificationManager : public QObject { Q_OBJECT @@ -34,7 +36,8 @@ protected Q_SLOTS: private: class NotificationManagerPrivate *d_ptr; - QString detectCleanAppname(QString app_name); + QString getCleanAppName(QString app_name); + QStringHash getCategoryParams(QString category); Q_DISABLE_COPY(NotificationManager) Q_DECLARE_PRIVATE(NotificationManager) -- cgit v1.2.3 From 648e0cc8e5ebac749554dd4b037a0d200f577c5f Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Mon, 14 Jul 2014 17:13:16 +0200 Subject: Removed commhistory-qt5 dependency --- daemon/daemon.pro | 3 +-- rpm/pebble.spec | 11 +++++------ rpm/pebble.yaml | 1 - 3 files changed, 6 insertions(+), 9 deletions(-) (limited to 'daemon') diff --git a/daemon/daemon.pro b/daemon/daemon.pro index cfcdae1..9642a81 100644 --- a/daemon/daemon.pro +++ b/daemon/daemon.pro @@ -5,7 +5,7 @@ CONFIG += link_pkgconfig QT -= gui QT += bluetooth dbus contacts -PKGCONFIG += commhistory-qt5 mlite5 +PKGCONFIG += mlite5 QMAKE_CXXFLAGS += -std=c++0x LIBS += -L$$OUT_PWD/../ext/Log4Qt/ -llog4qt @@ -61,5 +61,4 @@ lib.files += $$OUT_PWD/../ext/Log4Qt/*.s* lib.path = /usr/share/pebble/lib # unnecesary includes, just so QtCreator could find headers... :-( -INCLUDEPATH += $$[QT_HOST_PREFIX]/include/commhistory-qt5 INCLUDEPATH += $$[QT_HOST_PREFIX]/include/mlite5 diff --git a/rpm/pebble.spec b/rpm/pebble.spec index 2ccceb0..1eda359 100644 --- a/rpm/pebble.spec +++ b/rpm/pebble.spec @@ -28,7 +28,6 @@ BuildRequires: pkgconfig(Qt5Contacts) BuildRequires: pkgconfig(Qt5Quick) BuildRequires: pkgconfig(Qt5Qml) BuildRequires: pkgconfig(Qt5Core) -BuildRequires: pkgconfig(commhistory-qt5) BuildRequires: pkgconfig(mlite5) BuildRequires: pkgconfig(sailfishapp) >= 0.0.10 BuildRequires: desktop-file-utils @@ -69,6 +68,11 @@ desktop-file-install --delete-original \ --dir %{buildroot}%{_datadir}/applications \ %{buildroot}%{_datadir}/applications/*.desktop +%post +# >> post +systemctl --user daemon-reload +# << post + %files %defattr(-,root,root,-) %{_bindir} @@ -81,8 +85,3 @@ desktop-file-install --delete-original \ %{_datadir}/%{name}/lib # >> files # << files - -%post -# >> post -systemctl --user daemon-reload -# << post diff --git a/rpm/pebble.yaml b/rpm/pebble.yaml index 16f3f2c..b976617 100644 --- a/rpm/pebble.yaml +++ b/rpm/pebble.yaml @@ -18,7 +18,6 @@ PkgConfigBR: - Qt5Quick - Qt5Qml - Qt5Core -- commhistory-qt5 - mlite5 - sailfishapp >= 0.0.10 Requires: -- cgit v1.2.3 From 9bbba72939248388dfc832a5bf20cb9539ab0675 Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Mon, 14 Jul 2014 17:13:34 +0200 Subject: Supress unused parameter warnings --- daemon/notificationmanager.cpp | 8 +++++++- daemon/watchcommands.cpp | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'daemon') diff --git a/daemon/notificationmanager.cpp b/daemon/notificationmanager.cpp index 917a245..17e98bc 100644 --- a/daemon/notificationmanager.cpp +++ b/daemon/notificationmanager.cpp @@ -104,7 +104,13 @@ QStringHash NotificationManager::getCategoryParams(QString category) return QStringHash(); } -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) { +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) +{ + Q_UNUSED(replaces_id); + Q_UNUSED(app_icon); + Q_UNUSED(actions); + Q_UNUSED(expire_timeout); //Ignore notifcations from myself if (app_name == "pebbled") { diff --git a/daemon/watchcommands.cpp b/daemon/watchcommands.cpp index 7fc84fc..1df811a 100644 --- a/daemon/watchcommands.cpp +++ b/daemon/watchcommands.cpp @@ -8,6 +8,8 @@ WatchCommands::WatchCommands(WatchConnector *watch, QObject *parent) : void WatchCommands::processMessage(uint endpoint, uint datalen, QByteArray data) { + Q_UNUSED(datalen); + logger()->debug() << __FUNCTION__ << endpoint << "/" << data.length(); switch (endpoint) { case WatchConnector::watchPHONE_VERSION: -- cgit v1.2.3 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 +++++++++-- daemon/daemon.cpp | 4 +++- daemon/daemon.pro | 3 ++- daemon/manager.cpp | 18 ++++++++++++++++-- daemon/manager.h | 7 ++++++- daemon/settings.h | 25 +++++++++++++++++++++++++ 6 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 daemon/settings.h (limited to 'daemon') 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; } } } diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp index a2cb900..b891680 100644 --- a/daemon/daemon.cpp +++ b/daemon/daemon.cpp @@ -86,7 +86,9 @@ int main(int argc, char *argv[]) DBusConnector dbus; VoiceCallManager voice; - Manager manager(&watch, &dbus, &voice); + Settings settings; + + Manager manager(&watch, &dbus, &voice, &settings); signal(SIGINT, signalhandler); signal(SIGTERM, signalhandler); diff --git a/daemon/daemon.pro b/daemon/daemon.pro index 3db6918..cf6d5b9 100644 --- a/daemon/daemon.pro +++ b/daemon/daemon.pro @@ -29,7 +29,8 @@ HEADERS += \ watchconnector.h \ dbusconnector.h \ dbusadaptor.h \ - watchcommands.h + watchcommands.h \ + settings.h OTHER_FILES += \ org.pebbled.xml \ diff --git a/daemon/manager.cpp b/daemon/manager.cpp index a2365b4..8e07d52 100644 --- a/daemon/manager.cpp +++ b/daemon/manager.cpp @@ -5,10 +5,14 @@ #include #include -Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice) : +Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice, Settings *settings) : QObject(0), watch(watch), dbus(dbus), voice(voice), commands(new WatchCommands(watch, this)), - notification(MNotification::DeviceEvent) + settings(settings), notification(MNotification::DeviceEvent) { + connect(settings, SIGNAL(valueChanged(QString)), SLOT(onSettingChanged(const QString&))); + connect(settings, SIGNAL(valuesChanged()), SLOT(onSettingsChanged())); + connect(settings, SIGNAL(silentWhenConnectedChanged()), SLOT(onSettingsChanged())); + // We don't need to handle presence changes, so report them separately and ignore them QMap parameters; parameters.insert(QString::fromLatin1("mergePresenceChanges"), QString::fromLatin1("false")); @@ -54,6 +58,16 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan connect(this, SIGNAL(mprisMetadataChanged(QVariantMap)), commands, SLOT(onMprisMetadataChanged(QVariantMap))); } +void Manager::onSettingChanged(const QString &key) +{ + logger()->debug() << __FUNCTION__ << key << ":" << settings->property(qPrintable(key)); +} + +void Manager::onSettingsChanged() +{ + logger()->warn() << __FUNCTION__ << "Not implemented!"; +} + void Manager::onPebbleChanged() { const QVariantMap & pebble = dbus->pebble(); diff --git a/daemon/manager.h b/daemon/manager.h index e967dae..64dbcce 100644 --- a/daemon/manager.h +++ b/daemon/manager.h @@ -5,6 +5,7 @@ #include "dbusconnector.h" #include "voicecallmanager.h" #include "watchcommands.h" +#include "settings.h" #include #include @@ -38,6 +39,8 @@ class Manager : WatchCommands *commands; + Settings *settings; + MNotification notification; QContactManager *contacts; @@ -47,7 +50,7 @@ class Manager : QString lastSeenMpris; public: - explicit Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice); + explicit Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice, Settings *settings); Q_INVOKABLE QString findPersonByNumber(QString number); Q_INVOKABLE void processUnreadMessages(GroupObject *group); @@ -62,6 +65,8 @@ public slots: void hangupAll(); protected slots: + void onSettingChanged(const QString &key); + void onSettingsChanged(); void onPebbleChanged(); void onConnectedChanged(); void onActiveVoiceCallChanged(); diff --git a/daemon/settings.h b/daemon/settings.h new file mode 100644 index 0000000..50ffd86 --- /dev/null +++ b/daemon/settings.h @@ -0,0 +1,25 @@ +#ifndef SETTINGS_H +#define SETTINGS_H + +#include + +class Settings : public MDConfGroup +{ + Q_OBJECT + + Q_PROPERTY(bool silentWhenConnected MEMBER silentWhenConnected NOTIFY silentWhenConnectedChanged) + bool silentWhenConnected; + +public: + explicit Settings(QObject *parent = 0) : + MDConfGroup("/org/pebbled/settings", parent, BindProperties) + { resolveMetaObject(); } + +signals: + void silentWhenConnectedChanged(bool); + +public slots: + +}; + +#endif // SETTINGS_H -- cgit v1.2.3 From ee7c3abcc960f5d4fd8686f3f3478c6f77e39b82 Mon Sep 17 00:00:00 2001 From: Philipp Andreas Date: Tue, 22 Jul 2014 19:49:49 +0200 Subject: Don't push empty email notifications to pebble --- daemon/notificationmanager.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'daemon') diff --git a/daemon/notificationmanager.cpp b/daemon/notificationmanager.cpp index 17e98bc..b758df2 100644 --- a/daemon/notificationmanager.cpp +++ b/daemon/notificationmanager.cpp @@ -120,10 +120,11 @@ 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); if (app_name == "messageserver5") { - emit this->emailNotify(hints.value("x-nemo-preview-summary", this->getCleanAppName(app_name)).toString(), - hints.value("x-nemo-preview-body", "default").toString(), - "" - ); + QString subject = hints.value("x-nemo-preview-summary", "").toString(); + QString data = hints.value("x-nemo-preview-body", "").toString(); + if (!data.isEmpty() && !subject.isEmpty()) { + emit this->emailNotify(subject, data, ""); + } } else if (app_name == "commhistoryd") { if (summary == "" && body == "") { emit this->smsNotify(hints.value("x-nemo-preview-summary", "default").toString(), -- 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 'daemon') 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 33d912d5ea022352c8614c386d5ae3c25e4e5aa6 Mon Sep 17 00:00:00 2001 From: Philipp Andreas Date: Wed, 23 Jul 2014 21:21:35 +0200 Subject: Adding Facebook and Twitter notification leads --- daemon/watchconnector.cpp | 10 ++++++++++ daemon/watchconnector.h | 4 ++++ 2 files changed, 14 insertions(+) (limited to 'daemon') diff --git a/daemon/watchconnector.cpp b/daemon/watchconnector.cpp index 63e476f..7e70b50 100644 --- a/daemon/watchconnector.cpp +++ b/daemon/watchconnector.cpp @@ -266,6 +266,16 @@ void WatchConnector::sendSMSNotification(QString sender, QString data) sendNotification(leadSMS, sender, data, ""); } +void WatchConnector::sendFaceBookNotification(QString sender, QString data) +{ + sendNotification(leadFACEBOOK, sender, data, ""); +} + +void WatchConnector::sendTwitterNotification(QString sender, QString data) +{ + sendNotification(leadTWITTER, sender, data, ""); +} + void WatchConnector::sendEmailNotification(QString sender, QString data, QString subject) { sendNotification(leadEMAIL, sender, data, subject); diff --git a/daemon/watchconnector.h b/daemon/watchconnector.h index 936deff..d09a8e3 100644 --- a/daemon/watchconnector.h +++ b/daemon/watchconnector.h @@ -102,6 +102,8 @@ public: enum { leadEMAIL = 0, leadSMS = 1, + leadFACEBOOK = 2, + leadTWITTER = 3, leadNOW_PLAYING_DATA = 16 }; enum { @@ -148,6 +150,8 @@ 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 sendTwitterNotification(QString sender, QString data); void sendMusicNowPlaying(QString track, QString album, QString artist); void sendPhoneVersion(); -- 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 'daemon') 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