Skip to content

Commit

Permalink
Merge branch 'upstream' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
xmdnx committed Apr 7, 2024
2 parents 49b4baa + e1ad716 commit 3c8b5ef
Show file tree
Hide file tree
Showing 21 changed files with 99 additions and 96 deletions.
2 changes: 1 addition & 1 deletion Telegram/Resources/uwp/AppX/AppxManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Identity Name="TelegramMessengerLLP.TelegramDesktop"
ProcessorArchitecture="ARCHITECTURE"
Publisher="CN=536BC709-8EE1-4478-AF22-F0F0F26FF64A"
Version="4.16.3.0" />
Version="4.16.4.0" />
<Properties>
<DisplayName>rabbitGram Desktop</DisplayName>
<PublisherDisplayName>xmdnx</PublisherDisplayName>
Expand Down
8 changes: 4 additions & 4 deletions Telegram/Resources/winrc/Telegram.rc
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 4,16,3,0
PRODUCTVERSION 4,16,3,0
FILEVERSION 4,16,4,0
PRODUCTVERSION 4,16,4,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -62,10 +62,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "xmdnx"
VALUE "FileDescription", "rabbitGram Desktop"
VALUE "FileVersion", "4.16.3.0"
VALUE "FileVersion", "4.16.4.0"
VALUE "LegalCopyright", "Copyright (C) 2023-2024"
VALUE "ProductName", "rabbitGram Desktop"
VALUE "ProductVersion", "4.16.3.0"
VALUE "ProductVersion", "4.16.4.0"
END
END
BLOCK "VarFileInfo"
Expand Down
8 changes: 4 additions & 4 deletions Telegram/Resources/winrc/Updater.rc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 4,16,3,0
PRODUCTVERSION 4,16,3,0
FILEVERSION 4,16,4,0
PRODUCTVERSION 4,16,4,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -53,10 +53,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "xmdnx"
VALUE "FileDescription", "rabbitGram Desktop Updater"
VALUE "FileVersion", "4.16.3.0"
VALUE "FileVersion", "4.16.4.0"
VALUE "LegalCopyright", "Copyright (C) 2023-2024"
VALUE "ProductName", "rabbitGram Desktop"
VALUE "ProductVersion", "4.16.3.0"
VALUE "ProductVersion", "4.16.4.0"
END
END
BLOCK "VarFileInfo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,9 @@ void ChooseSourceProcess::setupGeometryWithParent(
not_null<QWidget*> parent) {
_window->createWinId();
const auto parentScreen = [&] {
if (!::Platform::IsWayland()) {
if (const auto screen = QGuiApplication::screenAt(
if (const auto screen = QGuiApplication::screenAt(
parent->geometry().center())) {
return screen;
}
return screen;
}
return parent->screen();
}();
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/core/file_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void Launch(const QString &filepath) {
void ShowInFolder(const QString &filepath) {
crl::on_main([=] {
Ui::PreventDelayedActivation();
if (Platform::IsLinux()) {
if (Platform::IsX11()) {
// Hide mediaview to make other apps visible.
Core::App().hideMediaView();
}
Expand Down
4 changes: 2 additions & 2 deletions Telegram/SourceFiles/core/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ constexpr auto AppId = "{4356CE01-4137-4C55-9F8B-FB4EEBB6EC0C}"_cs;
constexpr auto AppNameOld = "rabbitGram Win (Unofficial)"_cs;
constexpr auto AppName = "rabbitGram Desktop"_cs;
constexpr auto AppFile = "rabbitGram"_cs;
constexpr auto AppVersion = 4016003;
constexpr auto AppVersionStr = "4.16.3";
constexpr auto AppVersion = 4016004;
constexpr auto AppVersionStr = "4.16.4";
constexpr auto AppBetaVersion = true;
constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION;
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/history/history_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4506,7 +4506,7 @@ void HistoryWidget::chooseAttach(
}

const auto filter = (overrideSendImagesAsPhotos == true)
? FileDialog::ImagesOrAllFilter()
? FileDialog::PhotoVideoFilesFilter()
: FileDialog::AllOrImagesFilter();

FileDialog::GetOpenPaths(this, tr::lng_choose_files(tr::now), filter, crl::guard(this, [=](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ void RepliesWidget::chooseAttach(
}

const auto filter = (overrideSendImagesAsPhotos == true)
? FileDialog::ImagesOrAllFilter()
? FileDialog::PhotoVideoFilesFilter()
: FileDialog::AllOrImagesFilter();
FileDialog::GetOpenPaths(this, tr::lng_choose_files(tr::now), filter, crl::guard(this, [=](
FileDialog::OpenResult &&result) {
Expand Down
10 changes: 9 additions & 1 deletion Telegram/SourceFiles/iv/iv_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,9 @@ void Instance::show(
_shownSession = session;
_shown->events() | rpl::start_with_next([=](Controller::Event event) {
using Type = Controller::Event::Type;
const auto lower = event.url.toLower();
const auto urlChecked = lower.startsWith("http://")
|| lower.startsWith("https://");
switch (event.type) {
case Type::Close:
_shown = nullptr;
Expand All @@ -852,7 +855,9 @@ void Instance::show(
processJoinChannel(event.context);
break;
case Type::OpenLinkExternal:
File::OpenUrl(event.url);
if (urlChecked) {
File::OpenUrl(event.url);
}
closeAll();
break;
case Type::OpenMedia:
Expand Down Expand Up @@ -891,6 +896,9 @@ void Instance::show(
break;
case Type::OpenPage:
case Type::OpenLink:
if (!urlChecked) {
break;
}
_shownSession->api().request(MTPmessages_GetWebPage(
MTP_string(event.url),
MTP_int(0)
Expand Down
67 changes: 31 additions & 36 deletions Telegram/SourceFiles/iv/iv_prepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ template <typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
return Number(base::SafeRound(value * 10000.) / 100.);
};

[[nodiscard]] QByteArray EscapeAttr(QByteArray value) {
[[nodiscard]] QByteArray Escape(QByteArray value) {
auto result = QByteArray();
result.reserve(value.size());
for (const auto &ch : value) {
Expand All @@ -67,8 +67,8 @@ template <typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
return result;
}

[[nodiscard]] QByteArray EscapeText(QByteArray value) {
return EscapeAttr(value);
[[nodiscard]] QByteArray Date(TimeId date) {
return Escape(langDateTimeFull(base::unixtime::parse(date)).toUtf8());
}

class Parser final {
Expand Down Expand Up @@ -391,9 +391,7 @@ QByteArray Parser::block(const MTPDpageBlockSubtitle &data) {
QByteArray Parser::block(const MTPDpageBlockAuthorDate &data) {
auto inner = rich(data.vauthor());
if (const auto date = data.vpublished_date().v) {
const auto parsed = base::unixtime::parse(date);
inner += " \xE2\x80\xA2 "
+ tag("time", EscapeText(langDateTimeFull(parsed).toUtf8()));
inner += " \xE2\x80\xA2 " + tag("time", Date(date));
}
return tag("address", inner);
}
Expand All @@ -412,7 +410,7 @@ QByteArray Parser::block(const MTPDpageBlockParagraph &data) {

QByteArray Parser::block(const MTPDpageBlockPreformatted &data) {
auto list = Attributes();
const auto language = EscapeAttr(utf(data.vlanguage()));
const auto language = utf(data.vlanguage());
if (!language.isEmpty()) {
list.push_back({ "data-language", language });
list.push_back({ "class", "lang-" + language });
Expand All @@ -430,7 +428,7 @@ QByteArray Parser::block(const MTPDpageBlockDivider &data) {
}

QByteArray Parser::block(const MTPDpageBlockAnchor &data) {
return tag("a", { { "name", EscapeAttr(utf(data.vname())) } });
return tag("a", { { "name", utf(data.vname()) } });
}

QByteArray Parser::block(const MTPDpageBlockList &data) {
Expand Down Expand Up @@ -507,15 +505,13 @@ QByteArray Parser::block(
};
auto result = tag("div", attributes, inner);

const auto href = data.vurl()
? utf(*data.vurl())
: photoFullUrl(photo);
const auto href = data.vurl() ? utf(*data.vurl()) : photoFullUrl(photo);
const auto id = Number(photo.id);
result = tag("a", {
{ "href", href },
{ "oncontextmenu", data.vurl() ? QByteArray() : "return false;" },
{ "data-context", data.vurl() ? QByteArray() : "viewer-photo" + id },
}, result);
}, result);
if (!slideshow) {
result += caption(data.vcaption());
}
Expand Down Expand Up @@ -621,9 +617,9 @@ QByteArray Parser::block(const MTPDpageBlockEmbed &data) {
attributes.push_back({ "height", iframeHeight });
if (const auto url = data.vurl()) {
if (!autosize) {
attributes.push_back({ "src", EscapeAttr(utf(url)) });
attributes.push_back({ "src", utf(url) });
} else {
attributes.push_back({ "srcdoc", EscapeAttr(utf(url)) });
attributes.push_back({ "srcdoc", utf(url) });
}
} else if (const auto html = data.vhtml()) {
attributes.push_back({ "src", embedUrl(html->v) });
Expand Down Expand Up @@ -661,12 +657,10 @@ QByteArray Parser::block(const MTPDpageBlockEmbedPost &data) {
address += tag(
"a",
{ { "rel", "author" }, { "onclick", "return false;" } },
EscapeText(utf(data.vauthor())));
utf(data.vauthor()));
if (const auto date = data.vdate().v) {
const auto parsed = base::unixtime::parse(date);
address += tag(
"time",
EscapeText(langDateTimeFull(parsed).toUtf8()));
address += tag("time", Date(date));
}
const auto inner = tag("address", address) + list(data.vblocks());
result = tag("blockquote", { { "class", "embed-post" } }, inner);
Expand All @@ -675,7 +669,7 @@ QByteArray Parser::block(const MTPDpageBlockEmbedPost &data) {
const auto inner = tag("strong", utf(data.vauthor()))
+ tag(
"small",
tag("a", { { "href", EscapeAttr(url) } }, EscapeText(url)));
tag("a", { { "href", url } }, url));
result = tag("section", { { "class", "embed-post" } }, inner);
}
result += caption(data.vcaption());
Expand Down Expand Up @@ -732,7 +726,7 @@ QByteArray Parser::block(const MTPDpageBlockChannel &data) {
: "https://t.me/" + username;
result = tag(
"a",
{ { "href", EscapeAttr(link) }, { "data-context", "channel" + id } },
{ { "href", link }, { "data-context", "channel" + id } },
result);
_result.channelIds.emplace(id);
return tag("section", {
Expand Down Expand Up @@ -839,23 +833,21 @@ QByteArray Parser::block(const MTPDpageRelatedArticle &data) {
inner += tag(
"span",
{ { "class", "related-link-title" } },
EscapeText(utf(*title)));
utf(*title));
}
if (description) {
inner += tag(
"span",
{ { "class", "related-link-desc" } },
EscapeText(utf(*description)));
utf(*description));
}
if (author || published) {
const auto separator = (author && published) ? ", " : "";
const auto parsed = base::unixtime::parse(published->v);
inner += tag(
"span",
{ { "class", "related-link-source" } },
EscapeText((author ? utf(*author) : QByteArray())
+ separator
+ langDateTimeFull(parsed).toUtf8()));
((author ? utf(*author) : QByteArray())
+ ((author && published) ? ", " : QByteArray())
+ (published ? Date(published->v) : QByteArray())));
}
result += tag("span", {
{ "class", "related-link-content" },
Expand Down Expand Up @@ -912,22 +904,25 @@ QByteArray Parser::block(const MTPDpageListItemBlocks &data) {
}

QByteArray Parser::block(const MTPDpageListOrderedItemText &data) {
return tag("li", { { "value", utf(data.vnum()) } }, rich(data.vtext()));
return tag(
"li",
{ { "value", utf(data.vnum()) } },
rich(data.vtext()));
}

QByteArray Parser::block(const MTPDpageListOrderedItemBlocks &data) {
return tag(
"li",
{ { "value", EscapeAttr(utf(data.vnum())) } },
{ { "value", utf(data.vnum()) } },
list(data.vblocks()));
}

QByteArray Parser::utf(const MTPstring &text) {
return text.v;
return Escape(text.v);
}

QByteArray Parser::utf(const tl::conditional<MTPstring> &text) {
return text ? text->v : QByteArray();
return text ? utf(*text) : QByteArray();
}

QByteArray Parser::tag(
Expand Down Expand Up @@ -965,7 +960,7 @@ QByteArray Parser::rich(const MTPRichText &text) {
{ "\xE2\x81\xA8", "<span dir=\"auto\">" },
{ "\xE2\x81\xA9", "</span>" },
};
auto text = EscapeText(utf(data.vtext()));
auto text = utf(data.vtext());
for (const auto &[from, to] : replacements) {
text.replace(from, to);
}
Expand Down Expand Up @@ -1016,8 +1011,8 @@ QByteArray Parser::rich(const MTPRichText &text) {
}, rich(data.vtext()));
}, [&](const MTPDtextEmail &data) {
return tag("a", {
{ "href", "mailto:" + EscapeAttr(utf(data.vemail())) },
}, rich(data.vtext()));
{ "href", "mailto:" + utf(data.vemail()) },
}, rich(data.vtext()));
}, [&](const MTPDtextSubscript &data) {
return tag("sub", rich(data.vtext()));
}, [&](const MTPDtextSuperscript &data) {
Expand All @@ -1026,11 +1021,11 @@ QByteArray Parser::rich(const MTPRichText &text) {
return tag("mark", rich(data.vtext()));
}, [&](const MTPDtextPhone &data) {
return tag("a", {
{ "href", "tel:" + EscapeAttr(utf(data.vphone())) },
{ "href", "tel:" + utf(data.vphone()) },
}, rich(data.vtext()));
}, [&](const MTPDtextAnchor &data) {
const auto inner = rich(data.vtext());
const auto name = EscapeAttr(utf(data.vname()));
const auto name = utf(data.vname());
return inner.isEmpty()
? tag("a", { { "name", name } })
: tag(
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/media/stories/media_stories_reply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ void ReplyArea::chooseAttach(
}

const auto filter = (overrideSendImagesAsPhotos == true)
? FileDialog::ImagesOrAllFilter()
? FileDialog::PhotoVideoFilesFilter()
: FileDialog::AllOrImagesFilter();
const auto weak = make_weak(&_shownPeerGuard);
const auto callback = [=](FileDialog::OpenResult &&result) {
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/platform/linux/specific_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ QString SingleInstanceLocalServerName(const QString &hash) {

#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
std::optional<bool> IsDarkMode() {
const auto result = base::Platform::XDP::ReadSetting(
auto result = base::Platform::XDP::ReadSetting(
"org.freedesktop.appearance",
"color-scheme");

Expand Down
4 changes: 2 additions & 2 deletions Telegram/SourceFiles/rabbit/rabbit_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ For license and copyright information please follow this link:
*/
#pragma once

constexpr auto AppRabbitVersion = 4016003;
constexpr auto AppRabbitVersionStr = "4.16.3";
constexpr auto AppRabbitVersion = 4016004;
constexpr auto AppRabbitVersionStr = "4.16.4";
constexpr auto AppRabbitBetaVersion = true;
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ void ShortcutMessages::chooseAttach(
_choosingAttach = false;

const auto filter = (overrideSendImagesAsPhotos == true)
? FileDialog::ImagesOrAllFilter()
? FileDialog::PhotoVideoFilesFilter()
: FileDialog::AllOrImagesFilter();
FileDialog::GetOpenPaths(this, tr::lng_choose_files(tr::now), filter, crl::guard(this, [=](
FileDialog::OpenResult &&result) {
Expand Down
4 changes: 3 additions & 1 deletion Telegram/SourceFiles/ui/boxes/boost_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,9 @@ void BoostBox(
close->parentWidget(),
MakeTitle(
box,
rpl::duplicate(title),
(data.group
? tr::lng_boost_group_button
: tr::lng_boost_channel_button)(),
rpl::duplicate(repeated),
false));
const auto titleInner = faded.data();
Expand Down
Loading

0 comments on commit 3c8b5ef

Please sign in to comment.