2017-12-29 21:17:07 +03:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-12-29 21:17:07 +03:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-12-29 21:17:07 +03:00
|
|
|
*/
|
|
|
|
#include "core/changelogs.h"
|
|
|
|
|
|
|
|
#include "lang/lang_keys.h"
|
2020-06-15 20:25:02 +04:00
|
|
|
#include "core/application.h"
|
2020-06-18 22:04:16 +04:00
|
|
|
#include "main/main_domain.h"
|
2020-06-09 20:57:05 +04:00
|
|
|
#include "main/main_session.h"
|
2020-06-18 22:04:16 +04:00
|
|
|
#include "storage/storage_domain.h"
|
2018-01-04 13:22:53 +03:00
|
|
|
#include "data/data_session.h"
|
2022-01-24 19:33:30 +03:00
|
|
|
#include "base/qt/qt_common_adapters.h"
|
2017-12-29 21:17:07 +03:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "apiwrap.h"
|
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
namespace {
|
|
|
|
|
2018-09-26 17:58:09 +03:00
|
|
|
std::map<int, const char*> BetaLogs() {
|
2017-12-29 21:17:07 +03:00
|
|
|
return {
|
2023-01-10 15:23:19 +04:00
|
|
|
{
|
|
|
|
4005004,
|
|
|
|
"- Allow wide range of interface scale options.\n"
|
|
|
|
|
|
|
|
"- Show opened chat name in the window title.\n"
|
|
|
|
|
|
|
|
"- Bug fixes and other minor improvements.\n"
|
|
|
|
|
|
|
|
"- Fix updating on macOS older than 10.14.\n"
|
2023-01-12 21:35:44 +04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
4005006,
|
|
|
|
"- Try enabling non-fractional scale "
|
|
|
|
"High DPI support on Windows and Linux.\n"
|
|
|
|
|
|
|
|
"- Experimental setting for fractional scale "
|
|
|
|
"High DPI support on Windows and Linux.\n"
|
|
|
|
|
|
|
|
"- Fix navigation to bottom problems in groups you didn't join.\n"
|
|
|
|
|
|
|
|
"- Fix a crash in chat export settings changes.\n"
|
|
|
|
|
|
|
|
"- Fix a crash in sending some of JPEG images.\n"
|
|
|
|
|
|
|
|
"- Fix CJK fonts on Windows.\n"
|
2023-01-13 13:17:39 +04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
4005007,
|
|
|
|
"- Fix glitches after moving window to another screen.\n",
|
2023-01-21 21:27:45 +04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
4005008,
|
|
|
|
"- Allow opening another account in a new window "
|
|
|
|
"(see Settings > Advanced > Experimental Settings).\n"
|
|
|
|
|
|
|
|
"- A lot of bugfixes for working with more than one window.\n"
|
2023-02-18 15:17:26 +04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
4006004,
|
|
|
|
"- Allow media viewer to exit fullscreen and become a normal window."
|
2023-03-01 17:45:44 +04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
4006006,
|
|
|
|
"- Confirmation window before starting a call.\n"
|
|
|
|
|
|
|
|
"- New \"Battery and Animations\" settings section.\n"
|
|
|
|
|
2023-03-02 19:36:57 +04:00
|
|
|
"- \"Save Power on Low Battery\" option for laptops.\n"
|
2023-03-01 17:45:44 +04:00
|
|
|
|
|
|
|
"- Improved windowed mode support for media viewer.\n"
|
|
|
|
|
|
|
|
"- Hardware accelerated video playback fix on macOS.\n"
|
2023-03-10 11:09:29 +04:00
|
|
|
|
2023-03-01 17:45:44 +04:00
|
|
|
"- New application icon on macOS following the system guidelines.\n"
|
2023-03-02 19:36:57 +04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
4006007,
|
|
|
|
"- Fix crash when accepting incoming calls.\n"
|
|
|
|
|
|
|
|
"- Remove sound when cancelling an unconfirmed call.\n"
|
2023-03-09 19:12:44 +04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
4006008,
|
|
|
|
"- Improve quality of voice messages with changed playback speed.\n"
|
|
|
|
|
|
|
|
"- Show when your message was read in small groups.\n"
|
|
|
|
|
|
|
|
"- Fix pasting images from Firefox on Windows.\n"
|
2023-03-10 11:09:29 +04:00
|
|
|
|
2023-03-09 19:12:44 +04:00
|
|
|
"- Improve memory usage for custom emoji.\n"
|
2023-03-12 08:42:24 +04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
4006010,
|
|
|
|
"- Suggest sending an invite link if user forbids "
|
|
|
|
"inviting him to groups.\n"
|
|
|
|
|
|
|
|
"- Show when a reaction was left on your message in small groups.\n"
|
|
|
|
|
|
|
|
"- Fix a crash in video chats on Windows.\n"
|
|
|
|
|
|
|
|
"- Fix a crash in audio speed change.\n"
|
2023-03-15 17:38:16 +04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
4006011,
|
|
|
|
"- Allow larger interface scale values on high-dpi screens.\n"
|
|
|
|
|
|
|
|
"- Implement new voice and video speed change interface (up to 2.5x).\n"
|
|
|
|
|
|
|
|
"- Support global Fn+F shortcut to toggle fullscreen on macOS.\n"
|
|
|
|
|
|
|
|
"- Silent notification sound in Focus Mode on macOS.\n"
|
|
|
|
|
|
|
|
"- Fix media viewer on macOS with several screens.\n"
|
|
|
|
|
|
|
|
"- Fix a crash in connection type box.\n"
|
|
|
|
|
|
|
|
"- Fix possible crash on quit.\n"
|
2023-03-17 21:15:37 +04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
4006011,
|
|
|
|
"- Fix several possible crashes.\n"
|
|
|
|
|
|
|
|
"- Deprecate macOS 10.12, Ubuntu 18.04 and CentOS 7 in July.\n"
|
2021-11-26 23:06:39 +04:00
|
|
|
}
|
2017-12-29 21:17:07 +03:00
|
|
|
};
|
2019-07-04 16:59:42 +02:00
|
|
|
};
|
2017-12-29 21:17:07 +03:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2019-07-24 13:45:24 +02:00
|
|
|
Changelogs::Changelogs(not_null<Main::Session*> session, int oldVersion)
|
2017-12-29 21:17:07 +03:00
|
|
|
: _session(session)
|
|
|
|
, _oldVersion(oldVersion) {
|
2019-04-18 12:28:43 +04:00
|
|
|
_session->data().chatsListChanges(
|
|
|
|
) | rpl::filter([](Data::Folder *folder) {
|
|
|
|
return !folder;
|
|
|
|
}) | rpl::start_with_next([=] {
|
|
|
|
requestCloudLogs();
|
|
|
|
}, _chatsSubscription);
|
2017-12-29 21:17:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<Changelogs> Changelogs::Create(
|
2019-07-24 13:45:24 +02:00
|
|
|
not_null<Main::Session*> session) {
|
2020-06-18 22:04:16 +04:00
|
|
|
auto &local = Core::App().domain().local();
|
2020-06-15 20:25:02 +04:00
|
|
|
const auto oldVersion = local.oldVersion();
|
|
|
|
local.clearOldVersion();
|
2017-12-29 21:17:07 +03:00
|
|
|
return (oldVersion > 0 && oldVersion < AppVersion)
|
|
|
|
? std::make_unique<Changelogs>(session, oldVersion)
|
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Changelogs::requestCloudLogs() {
|
2019-04-18 12:28:43 +04:00
|
|
|
_chatsSubscription.destroy();
|
2017-12-29 21:17:07 +03:00
|
|
|
|
|
|
|
const auto callback = [this](const MTPUpdates &result) {
|
|
|
|
_session->api().applyUpdates(result);
|
|
|
|
|
|
|
|
auto resultEmpty = true;
|
|
|
|
switch (result.type()) {
|
|
|
|
case mtpc_updateShortMessage:
|
|
|
|
case mtpc_updateShortChatMessage:
|
|
|
|
case mtpc_updateShort:
|
|
|
|
resultEmpty = false;
|
|
|
|
break;
|
|
|
|
case mtpc_updatesCombined:
|
2019-07-05 15:38:38 +02:00
|
|
|
resultEmpty = result.c_updatesCombined().vupdates().v.isEmpty();
|
2017-12-29 21:17:07 +03:00
|
|
|
break;
|
|
|
|
case mtpc_updates:
|
2019-07-05 15:38:38 +02:00
|
|
|
resultEmpty = result.c_updates().vupdates().v.isEmpty();
|
2017-12-29 21:17:07 +03:00
|
|
|
break;
|
|
|
|
case mtpc_updatesTooLong:
|
|
|
|
case mtpc_updateShortSentMessage:
|
|
|
|
LOG(("API Error: Bad updates type in app changelog."));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (resultEmpty) {
|
|
|
|
addLocalLogs();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
_session->api().requestChangelog(
|
|
|
|
FormatVersionPrecise(_oldVersion),
|
2018-06-04 18:35:11 +03:00
|
|
|
crl::guard(this, callback));
|
2017-12-29 21:17:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Changelogs::addLocalLogs() {
|
2018-09-26 18:11:16 +03:00
|
|
|
if (AppBetaVersion || cAlphaVersion()) {
|
2018-09-26 17:58:09 +03:00
|
|
|
addBetaLogs();
|
2017-12-29 21:17:07 +03:00
|
|
|
}
|
|
|
|
if (!_addedSomeLocal) {
|
2019-06-19 18:39:25 +02:00
|
|
|
const auto text = tr::lng_new_version_wrap(
|
|
|
|
tr::now,
|
2017-12-29 21:17:07 +03:00
|
|
|
lt_version,
|
2018-11-08 09:50:18 +04:00
|
|
|
QString::fromLatin1(AppVersionStr),
|
2017-12-29 21:17:07 +03:00
|
|
|
lt_changes,
|
2019-06-19 17:09:03 +02:00
|
|
|
tr::lng_new_version_minor(tr::now),
|
2017-12-29 21:17:07 +03:00
|
|
|
lt_link,
|
2021-02-04 20:42:32 +04:00
|
|
|
Core::App().changelogLink());
|
2017-12-29 21:17:07 +03:00
|
|
|
addLocalLog(text.trimmed());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Changelogs::addLocalLog(const QString &text) {
|
|
|
|
auto textWithEntities = TextWithEntities{ text };
|
|
|
|
TextUtilities::ParseEntities(textWithEntities, TextParseLinks);
|
2019-02-11 15:50:35 +03:00
|
|
|
_session->data().serviceNotification(textWithEntities);
|
2017-12-29 21:17:07 +03:00
|
|
|
_addedSomeLocal = true;
|
|
|
|
};
|
|
|
|
|
2018-09-26 17:58:09 +03:00
|
|
|
void Changelogs::addBetaLogs() {
|
2021-09-08 13:53:54 +03:00
|
|
|
for (const auto &[version, changes] : BetaLogs()) {
|
2018-09-26 17:58:09 +03:00
|
|
|
addBetaLog(version, changes);
|
2017-12-29 21:17:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-26 17:58:09 +03:00
|
|
|
void Changelogs::addBetaLog(int changeVersion, const char *changes) {
|
2017-12-29 21:17:07 +03:00
|
|
|
if (_oldVersion >= changeVersion) {
|
|
|
|
return;
|
|
|
|
}
|
2020-07-02 22:11:53 +04:00
|
|
|
const auto text = [&] {
|
|
|
|
static const auto simple = u"\n- "_q;
|
|
|
|
static const auto separator = QString::fromUtf8("\n\xE2\x80\xA2 ");
|
|
|
|
auto result = QString::fromUtf8(changes).trimmed();
|
2021-10-19 17:00:21 +04:00
|
|
|
if (result.startsWith(base::StringViewMid(simple, 1))) {
|
2020-07-02 23:02:59 +04:00
|
|
|
result = separator.mid(1) + result.mid(simple.size() - 1);
|
2020-07-02 22:11:53 +04:00
|
|
|
}
|
|
|
|
return result.replace(simple, separator);
|
|
|
|
}();
|
2017-12-29 21:17:07 +03:00
|
|
|
const auto version = FormatVersionDisplay(changeVersion);
|
2022-11-30 00:46:36 +03:00
|
|
|
const auto log = u"New in version %1 beta:\n\n"_q.arg(version) + text;
|
2020-07-02 22:11:53 +04:00
|
|
|
addLocalLog(log);
|
2017-12-29 21:17:07 +03:00
|
|
|
}
|
|
|
|
|
2020-09-08 18:01:12 +03:00
|
|
|
QString FormatVersionDisplay(int version) {
|
|
|
|
return QString::number(version / 1000000)
|
|
|
|
+ '.' + QString::number((version % 1000000) / 1000)
|
|
|
|
+ ((version % 1000)
|
|
|
|
? ('.' + QString::number(version % 1000))
|
|
|
|
: QString());
|
|
|
|
}
|
|
|
|
|
|
|
|
QString FormatVersionPrecise(int version) {
|
|
|
|
return QString::number(version / 1000000)
|
|
|
|
+ '.' + QString::number((version % 1000000) / 1000)
|
|
|
|
+ '.' + QString::number(version % 1000);
|
|
|
|
}
|
|
|
|
|
2017-12-29 21:17:07 +03:00
|
|
|
} // namespace Core
|