diff options
Diffstat (limited to 'daemon/notificationmanager.cpp')
| -rw-r--r-- | daemon/notificationmanager.cpp | 120 |
1 files changed, 61 insertions, 59 deletions
diff --git a/daemon/notificationmanager.cpp b/daemon/notificationmanager.cpp index 8e21ad9..0c56bc2 100644 --- a/daemon/notificationmanager.cpp +++ b/daemon/notificationmanager.cpp @@ -114,7 +114,7 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons Q_UNUSED(expire_timeout); // new place to check notification owner in Sailfish 1.1.6 - QString owner = hints.value("x-nemo-owner", "none").toString(); + QString owner = hints.value("x-nemo-owner", "Unknown").toString(); qCDebug(l) << Q_FUNC_INFO << "Got notification via dbus from" << this->getCleanAppName(app_name) << " Owner: " << owner; qCDebug(l) << hints; @@ -127,79 +127,81 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons QString category = hints.value("category", "").toString(); QStringHash categoryParams = this->getCategoryParams(category); - // Ignore transient notifications (notif hints override category hints) - // Hack this to accept transient -preview and -summary notifications, as we don't know how to decode the actual notifs yet - if (!category.endsWith("preview") && !category.endsWith("summary") && - hints.value("transient", categoryParams.value("transient", "false")).toString() == "true") { - qCDebug(l) << "Ignoring transient notification from " << owner; - return 0; - } - - if (app_name == "messageserver5" || owner == "messageserver5") { + if (category == "x-nemo.email") { if (!settings->property("notificationsEmails").toBool()) { qCDebug(l) << "Ignoring email notification because of setting!"; return 0; } - -// This is how we should obtain messaging notifications, if we manage to deserialize this 'PersonalNotification'. -// QByteArray commdata = hints.value("x-commhistoryd-data", "no data").toByteArray(); -// if (!commdata.contains((char)0)) -// data = QByteArray::fromBase64(commdata); -// QDataStream stream(commdata); -// stream.setVersion(QDataStream::Qt_5_0); -// stream >> - - QString subject = hints.value("x-nemo-preview-summary", "").toString(); - QString data = hints.value("x-nemo-preview-body", "").toString(); - - // Prioritize subject over data - if (subject.isEmpty() && !data.isEmpty()) { - subject = data; - data = ""; - } - - if (!subject.isEmpty()) { - emit this->emailNotify(subject, data, ""); - } - } else if (app_name == "commhistoryd" || owner == "commhistoryd") { - if (summary == "" && body == "") { - if (category == "x-nemo.call.missed") { - if (!settings->property("notificationsMissedCall").toBool()) { - qCDebug(l) << "Ignoring MissedCall notification because of setting!"; - return 0; - } - } else { - if (!settings->property("notificationsCommhistoryd").toBool()) { - qCDebug(l) << "Ignoring commhistoryd notification because of setting!"; - return 0; - } - } - 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" || owner == "harbour-mitakuuluu2-server") { - if (!settings->property("notificationsMitakuuluu").toBool()) { - qCDebug(l) << "Ignoring mitakuuluu notification because of setting!"; + emit this->emailNotify(summary, body, app_name); + } + else if (category == "x-nemo.call.missed") { + if (!settings->property("notificationsMissedCall").toBool()) { + qCDebug(l) << "Ignoring MissedCall notification because of setting!"; return 0; } - - emit this->smsNotify(hints.value("x-nemo-preview-body", "default").toString(), - hints.value("x-nemo-preview-summary", "default").toString() + emit this->smsNotify(hints.value("x-nemo-preview-summary", summary).toString(), + hints.value("x-nemo-preview-body", body).toString() + ); + } + else if (category == "x-nemo.messaging.sms.preview") { + if (!settings->property("notificationsCommhistoryd").toBool()) { + qCDebug(l) << "Ignoring commhistoryd notification because of setting!"; + return 0; + } + emit this->smsNotify(hints.value("x-nemo-preview-summary", summary).toString(), + hints.value("x-nemo-preview-body", body).toString() ); - } else if (app_name == "twitter-notifications-client" || owner == "twitter-notifications-client") { + } + else if (app_name.toLower().contains("whatsapp") || app_name.toLower().contains("whatsup")) { + if (!settings->property("notificationsWhatsapp").toBool()) { + qCDebug(l) << "Ignoring whatsapp notification because of setting!"; + return 0; + } + emit this->whatsappNotify(hints.value("x-nemo-preview-summary", summary).toString(), + hints.value("x-nemo-preview-body", body).toString() + ); + } + else if (hints.value("x-nemo-origin-package").toString() == "org.telegram.messenger" + || category.startsWith("harbour.sailorgram")) { + if (!settings->property("notificationsTelegram").toBool()) { + qCDebug(l) << "Ignoring telegram notification because of setting!"; + return 0; + } + emit this->telegramNotify(hints.value("x-nemo-preview-summary", summary).toString(), + hints.value("x-nemo-preview-body", body).toString() + ); + } + else if (app_name.toLower().contains("hangouts") || app_name.toLower().contains("hangish")) { + if (!settings->property("notificationsHangouts").toBool()) { + qCDebug(l) << "Ignoring telegram notification because of setting!"; + return 0; + } + emit this->hangoutNotify(hints.value("x-nemo-preview-summary", summary).toString(), + hints.value("x-nemo-preview-body", body).toString() + ); + } + else if (app_name == "twitter-notifications-client" || owner == "twitter-notifications-client") { if (!settings->property("notificationsTwitter").toBool()) { qCDebug(l) << "Ignoring twitter notification because of setting!"; return 0; } - emit this->twitterNotify(hints.value("x-nemo-preview-body", body).toString(), - hints.value("x-nemo-preview-summary", summary).toString() + emit this->twitterNotify(hints.value("x-nemo-preview-summary", summary).toString(), + hints.value("x-nemo-preview-body", body).toString() ); } else { + + // Ignore transient notifications (notif hints override category hints) + // Hack this to accept transient -preview and -summary notifications, as we don't know how to decode the actual notifs yet + if (!category.endsWith("preview") && !category.endsWith("summary") && + hints.value("transient", categoryParams.value("transient", "false")).toString() == "true") { + qCDebug(l) << "Ignoring transient notification from " << owner; + return 0; + } + // 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 subject = hints.value("x-nemo-preview-summary", summary).toString(); + QString data = hints.value("x-nemo-preview-body", body).toString(); int prio = categoryParams.value("x-nemo-priority", "0").toInt(); qCDebug(l) << "MSG Prio:" << prio; |
