Remove not really needed notification capability checks
If the notification daemon doesn't support any of the hints, it will just ignore them
This commit is contained in:
parent
5394717ddc
commit
abdfa4f785
1 changed files with 53 additions and 65 deletions
|
@ -277,89 +277,77 @@ bool NotificationData::init(
|
||||||
_body = msg.toStdString();
|
_body = msg.toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HasCapability("actions")) {
|
_actions.push_back("default");
|
||||||
_actions.push_back("default");
|
_actions.push_back(tr::lng_open_link(tr::now).toStdString());
|
||||||
_actions.push_back(tr::lng_open_link(tr::now).toStdString());
|
|
||||||
|
|
||||||
if (!options.hideMarkAsRead) {
|
if (!options.hideMarkAsRead) {
|
||||||
// icon name according to https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
|
// icon name according to https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
|
||||||
_actions.push_back("mail-mark-read");
|
_actions.push_back("mail-mark-read");
|
||||||
_actions.push_back(
|
_actions.push_back(tr::lng_context_mark_read(tr::now).toStdString());
|
||||||
tr::lng_context_mark_read(tr::now).toStdString());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (HasCapability("inline-reply")
|
if (HasCapability("inline-reply") && !options.hideReplyButton) {
|
||||||
&& !options.hideReplyButton) {
|
_actions.push_back("inline-reply");
|
||||||
_actions.push_back("inline-reply");
|
_actions.push_back(tr::lng_notification_reply(tr::now).toStdString());
|
||||||
_actions.push_back(
|
|
||||||
tr::lng_notification_reply(tr::now).toStdString());
|
|
||||||
|
|
||||||
_notificationRepliedSignalId =
|
_notificationRepliedSignalId =
|
||||||
_interface.signal_notification_replied().connect([=](
|
_interface.signal_notification_replied().connect([=](
|
||||||
XdgNotifications::Notifications,
|
|
||||||
uint id,
|
|
||||||
std::string text) {
|
|
||||||
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
|
|
||||||
if (id == _notificationId) {
|
|
||||||
_manager->notificationReplied(
|
|
||||||
_id,
|
|
||||||
{ QString::fromStdString(text), {} });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_actionInvokedSignalId = _interface.signal_action_invoked().connect(
|
|
||||||
[=](
|
|
||||||
XdgNotifications::Notifications,
|
XdgNotifications::Notifications,
|
||||||
uint id,
|
uint id,
|
||||||
std::string actionName) {
|
std::string text) {
|
||||||
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
|
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
|
||||||
if (id == _notificationId) {
|
if (id == _notificationId) {
|
||||||
if (actionName == "default") {
|
_manager->notificationReplied(
|
||||||
_manager->notificationActivated(_id);
|
_id,
|
||||||
} else if (actionName == "mail-mark-read") {
|
{ QString::fromStdString(text), {} });
|
||||||
_manager->notificationReplied(_id, {});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
_activationTokenSignalId =
|
_actionInvokedSignalId = _interface.signal_action_invoked().connect([=](
|
||||||
_interface.signal_activation_token().connect([=](
|
XdgNotifications::Notifications,
|
||||||
XdgNotifications::Notifications,
|
uint id,
|
||||||
uint id,
|
std::string actionName) {
|
||||||
std::string token) {
|
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
|
||||||
if (id == _notificationId) {
|
if (id == _notificationId) {
|
||||||
GLib::setenv("XDG_ACTIVATION_TOKEN", token, true);
|
if (actionName == "default") {
|
||||||
|
_manager->notificationActivated(_id);
|
||||||
|
} else if (actionName == "mail-mark-read") {
|
||||||
|
_manager->notificationReplied(_id, {});
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
});
|
||||||
|
|
||||||
if (HasCapability("action-icons")) {
|
_activationTokenSignalId = _interface.signal_activation_token().connect(
|
||||||
_hints.insert_value("action-icons", GLib::Variant::new_boolean(true));
|
[=](
|
||||||
}
|
XdgNotifications::Notifications,
|
||||||
|
uint id,
|
||||||
|
std::string token) {
|
||||||
|
if (id == _notificationId) {
|
||||||
|
GLib::setenv("XDG_ACTIVATION_TOKEN", token, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
_hints.insert_value("action-icons", GLib::Variant::new_boolean(true));
|
||||||
|
|
||||||
// suppress system sound if telegram sound activated,
|
// suppress system sound if telegram sound activated,
|
||||||
// otherwise use system sound
|
// otherwise use system sound
|
||||||
if (HasCapability("sound")) {
|
if (Core::App().settings().soundNotify()) {
|
||||||
if (Core::App().settings().soundNotify()) {
|
_hints.insert_value(
|
||||||
_hints.insert_value(
|
"suppress-sound",
|
||||||
"suppress-sound",
|
GLib::Variant::new_boolean(true));
|
||||||
GLib::Variant::new_boolean(true));
|
} else {
|
||||||
} else {
|
// sound name according to http://0pointer.de/public/sound-naming-spec.html
|
||||||
// sound name according to http://0pointer.de/public/sound-naming-spec.html
|
_hints.insert_value(
|
||||||
_hints.insert_value(
|
"sound-name",
|
||||||
"sound-name",
|
GLib::Variant::new_string("message-new-instant"));
|
||||||
GLib::Variant::new_string("message-new-instant"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HasCapability("x-canonical-append")) {
|
_hints.insert_value(
|
||||||
_hints.insert_value(
|
"x-canonical-append",
|
||||||
"x-canonical-append",
|
GLib::Variant::new_string("true"));
|
||||||
GLib::Variant::new_string("true"));
|
|
||||||
}
|
|
||||||
|
|
||||||
_hints.insert_value("category", GLib::Variant::new_string("im.received"));
|
_hints.insert_value("category", GLib::Variant::new_string("im.received"));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue