Compare commits

...

5 Commits

Author SHA1 Message Date
Jiaxun Yang 9bfef9cc5d
Merge bff52594e8 into 471831bcd6 2024-04-25 17:47:13 +04:00
Ilya Fedin 471831bcd6 Revert "Remove not really needed notification capability checks"
This reverts commit abdfa4f785.
2024-04-25 15:07:51 +04:00
Ilya Fedin b1e64419a5 Fix setting application icon in Linux notifications 2024-04-25 11:31:43 +04:00
Ilya Fedin e2f17f1131 Remove unneeded includes from notifications_manager_linux 2024-04-25 11:31:43 +04:00
Jiaxun Yang bff52594e8 Perfer IPv6 over IPv4 for connection test
It is almost 2024 and there is no reason to perfer IPv4 over
IPv6, especially in tdesktop user still need to toggle a switch
to enable IPv6.

For tdesktop's connect test, if user does not have a routable
IPv6 address, onDisconnect will be called promptly to fallback
to another connection. If user's IPv6 connection is somehow
filtering out connection to telegram's server, it will wait
until kWaitForBetterTimeout and then fallback to another
connection.

This implementation is actually in spirit of happy eyeballs
recommandation.

Fixes: https://github.com/telegramdesktop/tdesktop/issues/2198
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
2023-12-01 21:28:51 +00:00
2 changed files with 66 additions and 56 deletions

View File

@ -187,7 +187,7 @@ void SessionPrivate::appendTestConnection(
const bytes::vector &protocolSecret) {
QWriteLocker lock(&_stateMutex);
const auto priority = (qthelp::is_ipv6(ip) ? 0 : 1)
const auto priority = (qthelp::is_ipv6(ip) ? 1 : 0)
+ (protocol == DcOptions::Variants::Tcp ? 1 : 0)
+ (protocolSecret.empty() ? 0 : 1);
_testConnections.push_back({

View File

@ -17,12 +17,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_forum_topic.h"
#include "history/history.h"
#include "history/history_item.h"
#include "ui/empty_userpic.h"
#include "main/main_session.h"
#include "lang/lang_keys.h"
#include "base/weak_ptr.h"
#include "window/notifications_utilities.h"
#include "styles/style_window.h"
#include <QtCore/QBuffer>
#include <QtCore/QVersionNumber>
@ -302,21 +300,25 @@ bool NotificationData::init(
_body = msg.toStdString();
}
_actions.push_back("default");
_actions.push_back(tr::lng_open_link(tr::now).toStdString());
if (HasCapability("actions")) {
_actions.push_back("default");
_actions.push_back(tr::lng_open_link(tr::now).toStdString());
if (!options.hideMarkAsRead) {
// 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(tr::lng_context_mark_read(tr::now).toStdString());
}
if (!options.hideMarkAsRead) {
// 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(
tr::lng_context_mark_read(tr::now).toStdString());
}
if (HasCapability("inline-reply") && !options.hideReplyButton) {
_actions.push_back("inline-reply");
_actions.push_back(tr::lng_notification_reply(tr::now).toStdString());
if (HasCapability("inline-reply")
&& !options.hideReplyButton) {
_actions.push_back("inline-reply");
_actions.push_back(
tr::lng_notification_reply(tr::now).toStdString());
_notificationRepliedSignalId
= _interface.signal_notification_replied().connect([=](
_notificationRepliedSignalId
= _interface.signal_notification_replied().connect([=](
XdgNotifications::Notifications,
uint id,
std::string text) {
@ -328,51 +330,59 @@ bool NotificationData::init(
}
});
});
}
_actionInvokedSignalId = _interface.signal_action_invoked().connect(
[=](
XdgNotifications::Notifications,
uint id,
std::string actionName) {
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
if (id == _notificationId) {
if (actionName == "default") {
_manager->notificationActivated(_id);
} else if (actionName == "mail-mark-read") {
_manager->notificationReplied(_id, {});
}
}
});
});
_activationTokenSignalId
= _interface.signal_activation_token().connect([=](
XdgNotifications::Notifications,
uint id,
std::string token) {
if (id == _notificationId) {
GLib::setenv("XDG_ACTIVATION_TOKEN", token, true);
}
});
}
_actionInvokedSignalId = _interface.signal_action_invoked().connect([=](
XdgNotifications::Notifications,
uint id,
std::string actionName) {
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
if (id == _notificationId) {
if (actionName == "default") {
_manager->notificationActivated(_id);
} else if (actionName == "mail-mark-read") {
_manager->notificationReplied(_id, {});
}
}
});
});
_activationTokenSignalId = _interface.signal_activation_token().connect(
[=](
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));
if (HasCapability("action-icons")) {
_hints.insert_value("action-icons", GLib::Variant::new_boolean(true));
}
// suppress system sound if telegram sound activated,
// otherwise use system sound
if (Core::App().settings().soundNotify()) {
_hints.insert_value(
"suppress-sound",
GLib::Variant::new_boolean(true));
} else {
// sound name according to http://0pointer.de/public/sound-naming-spec.html
_hints.insert_value(
"sound-name",
GLib::Variant::new_string("message-new-instant"));
if (HasCapability("sound")) {
if (Core::App().settings().soundNotify()) {
_hints.insert_value(
"suppress-sound",
GLib::Variant::new_boolean(true));
} else {
// sound name according to http://0pointer.de/public/sound-naming-spec.html
_hints.insert_value(
"sound-name",
GLib::Variant::new_string("message-new-instant"));
}
}
_hints.insert_value(
"x-canonical-append",
GLib::Variant::new_string("true"));
if (HasCapability("x-canonical-append")) {
_hints.insert_value(
"x-canonical-append",
GLib::Variant::new_string("true"));
}
_hints.insert_value("category", GLib::Variant::new_string("im.received"));
@ -438,9 +448,9 @@ void NotificationData::show() {
const auto weak = base::make_weak(this);
StartServiceAsync(_proxy.get_connection(), crl::guard(weak, [=] {
const auto iconName = _imageKey.empty()
|| _hints.lookup_value(_imageKey)
? std::string()
: base::IconName().toStdString();
|| !_hints.lookup_value(_imageKey)
? base::IconName().toStdString()
: std::string();
auto actions = _actions
| ranges::views::transform(&std::string::c_str)