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/watchconnector.cpp') 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 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/watchconnector.cpp') 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 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/watchconnector.cpp') 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 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/watchconnector.cpp') 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/watchconnector.cpp') 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