From 263d7a48a38d2d1acf707d99b31f6b98ccf6fde5 Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Mon, 23 Aug 2021 18:22:12 +0300 Subject: [PATCH] Rework versioning --- Telegram/CMakeLists.txt | 2 +- Telegram/SourceFiles/_other/packer.cpp | 4 ++++ Telegram/SourceFiles/boxes/about_box.cpp | 9 ++++++-- .../SourceFiles/boxes/confirm_phone_box.cpp | 7 +++--- Telegram/SourceFiles/core/changelogs.cpp | 3 ++- .../SourceFiles/core/crash_report_window.cpp | 3 ++- Telegram/SourceFiles/core/crash_reports.cpp | 3 ++- Telegram/SourceFiles/core/launcher.cpp | 7 +++++- Telegram/SourceFiles/core/update_checker.cpp | 15 +++++++------ Telegram/SourceFiles/core/version.h | 3 +-- Telegram/SourceFiles/kotato/json_settings.cpp | 1 + Telegram/SourceFiles/kotato/kotato_version.h | 22 +++++++++++++++++++ Telegram/SourceFiles/kotato/version.h | 11 ---------- Telegram/SourceFiles/logs.cpp | 6 +++-- .../SourceFiles/mtproto/session_private.cpp | 5 ++++- Telegram/SourceFiles/settings.cpp | 7 +++--- Telegram/SourceFiles/storage/localstorage.cpp | 2 ++ 17 files changed, 74 insertions(+), 36 deletions(-) create mode 100644 Telegram/SourceFiles/kotato/kotato_version.h delete mode 100644 Telegram/SourceFiles/kotato/version.h diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 4475f5a6d..ea8584385 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -750,7 +750,7 @@ PRIVATE kotato/settings_menu.h kotato/settings.cpp kotato/settings.h - kotato/version.h + kotato/kotato_version.h lang/lang_cloud_manager.cpp lang/lang_cloud_manager.h lang/lang_instance.cpp diff --git a/Telegram/SourceFiles/_other/packer.cpp b/Telegram/SourceFiles/_other/packer.cpp index 86fba4786..1b8789ecc 100644 --- a/Telegram/SourceFiles/_other/packer.cpp +++ b/Telegram/SourceFiles/_other/packer.cpp @@ -182,10 +182,12 @@ int main(int argc, char *argv[]) AlphaVersion = QString(argv[i + 1]).toULongLong(); if (AlphaVersion > version * 1000ULL && AlphaVersion < (version + 1) * 1000ULL) { BetaChannel = false; + /* AlphaSignature = countAlphaVersionSignature(AlphaVersion); if (AlphaSignature.isEmpty()) { return -1; } + */ } else { cout << "Bad -alpha param value passed, should be for the same version: " << version << ", alpha: " << AlphaVersion << "\n"; return -1; @@ -506,9 +508,11 @@ int main(int argc, char *argv[]) #else #error Unknown platform! #endif + /* if (AlphaVersion) { outName += "_" + AlphaSignature; } + */ QFile out(outName); if (!out.open(QIODevice::WriteOnly)) { cout << "Can't open '" << outName.toUtf8().constData() << "' for write..\n"; diff --git a/Telegram/SourceFiles/boxes/about_box.cpp b/Telegram/SourceFiles/boxes/about_box.cpp index aa35aa52d..9f3605af5 100644 --- a/Telegram/SourceFiles/boxes/about_box.cpp +++ b/Telegram/SourceFiles/boxes/about_box.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "boxes/about_box.h" +#include "kotato/kotato_version.h" #include "lang/lang_keys.h" #include "lang/lang_instance.h" #include "mainwidget.h" @@ -105,6 +106,7 @@ void AboutBox::resizeEvent(QResizeEvent *e) { } void AboutBox::showVersionHistory() { + /* if (cRealAlphaVersion()) { auto url = qsl("https://tdesktop.com/"); if (Platform::IsWindows32Bit()) { @@ -126,8 +128,11 @@ void AboutBox::showVersionHistory() { Ui::show(Box("The link to the current private alpha version of Telegram Desktop was copied to the clipboard.")); } else { + */ UrlClickHandler::Open(Core::App().changelogLink()); + /* } + */ } void AboutBox::keyPressEvent(QKeyEvent *e) { @@ -158,8 +163,8 @@ QString telegramFaqLink() { QString currentVersionText() { auto result = QString::fromLatin1(AppKotatoVersionStr); if (cAlphaVersion()) { - result += qsl(" alpha %1").arg(cAlphaVersion() % 1000); - } else if (AppBetaVersion) { + result += qsl("-%1.%2").arg(AppKotatoTestBranch).arg(AppKotatoTestVersion); + } else if (AppKotatoBetaVersion) { result += " beta"; } if (Platform::IsWindows64Bit()) { diff --git a/Telegram/SourceFiles/boxes/confirm_phone_box.cpp b/Telegram/SourceFiles/boxes/confirm_phone_box.cpp index 3d960f668..ca8d00aaa 100644 --- a/Telegram/SourceFiles/boxes/confirm_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/confirm_phone_box.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "boxes/confirm_phone_box.h" +#include "kotato/kotato_version.h" #include "boxes/confirm_box.h" #include "ui/widgets/buttons.h" #include "ui/widgets/input_fields.h" @@ -29,10 +30,10 @@ namespace { object_ptr CurrentConfirmPhoneBox = { nullptr }; void SendToBannedHelp(const QString &phone) { - const auto version = QString::fromLatin1(AppVersionStr) + const auto version = QString::fromLatin1(AppKotatoVersionStr) + (cAlphaVersion() - ? qsl(" alpha %1").arg(cAlphaVersion()) - : (AppBetaVersion ? " beta" : "")); + ? qsl("-%1.%2").arg(AppKotatoTestBranch).arg(AppKotatoTestVersion) + : (AppKotatoBetaVersion ? " beta" : "")); const auto subject = qsl("Banned phone number: ") + phone; diff --git a/Telegram/SourceFiles/core/changelogs.cpp b/Telegram/SourceFiles/core/changelogs.cpp index 72aeec152..c905a587f 100644 --- a/Telegram/SourceFiles/core/changelogs.cpp +++ b/Telegram/SourceFiles/core/changelogs.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "core/changelogs.h" +#include "kotato/kotato_version.h" #include "storage/localstorage.h" #include "lang/lang_keys.h" #include "lang/lang_instance.h" @@ -247,7 +248,7 @@ void Changelogs::requestCloudLogs() { } void Changelogs::addLocalLogs() { - if (AppBetaVersion || cAlphaVersion()) { + if (AppKotatoBetaVersion || cAlphaVersion()) { addBetaLogs(); } if (!_addedSomeLocal) { diff --git a/Telegram/SourceFiles/core/crash_report_window.cpp b/Telegram/SourceFiles/core/crash_report_window.cpp index 8e87ddaba..f607fb5b0 100644 --- a/Telegram/SourceFiles/core/crash_report_window.cpp +++ b/Telegram/SourceFiles/core/crash_report_window.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "core/crash_report_window.h" +#include "kotato/kotato_version.h" #include "core/crash_reports.h" #include "core/launcher.h" #include "core/sandbox.h" @@ -482,7 +483,7 @@ QString LastCrashedWindow::getReportField(const QLatin1String &name, const QLati QString data = lines.at(i).trimmed().mid(prefix.size()).trimmed(); if (name == qstr("version")) { - if (data.endsWith(qstr(" alpha"))) { + if (data.endsWith(qstr(" %1").arg(AppKotatoTestBranch))) { data = QString::number(-data.replace(QRegularExpression(qsl("[^\\d]")), "").toLongLong()); } else { data = QString::number(data.replace(QRegularExpression(qsl("[^\\d]")), "").toLongLong()); diff --git a/Telegram/SourceFiles/core/crash_reports.cpp b/Telegram/SourceFiles/core/crash_reports.cpp index cdb563f05..e40113275 100644 --- a/Telegram/SourceFiles/core/crash_reports.cpp +++ b/Telegram/SourceFiles/core/crash_reports.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "core/crash_reports.h" +#include "kotato/kotato_version.h" #include "platform/platform_specific.h" #include "base/platform/base_platform_info.h" #include "core/launcher.h" @@ -311,7 +312,7 @@ void StartCatching(not_null launcher) { #ifndef DESKTOP_APP_DISABLE_CRASH_REPORTS ProcessAnnotations["Binary"] = cExeName().toUtf8().constData(); ProcessAnnotations["ApiId"] = QString::number(cApiId()).toUtf8().constData(); - ProcessAnnotations["Version"] = (cAlphaVersion() ? qsl("%1 alpha").arg(cAlphaVersion()) : (AppBetaVersion ? qsl("%1 beta") : qsl("%1")).arg(AppKotatoVersion)).toUtf8().constData(); + ProcessAnnotations["Version"] = (cAlphaVersion() ? qsl("%1 %2").arg(cAlphaVersion()).arg(AppKotatoTestBranch) : (AppBetaVersion ? qsl("%1 beta") : qsl("%1")).arg(AppKotatoVersion)).toUtf8().constData(); ProcessAnnotations["Launched"] = QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss").toUtf8().constData(); ProcessAnnotations["Platform"] = PlatformString().toUtf8().constData(); ProcessAnnotations["UserTag"] = QString::number(launcher->installationTag(), 16).toUtf8().constData(); diff --git a/Telegram/SourceFiles/core/launcher.cpp b/Telegram/SourceFiles/core/launcher.cpp index 97cecbcb4..9bef2003f 100644 --- a/Telegram/SourceFiles/core/launcher.cpp +++ b/Telegram/SourceFiles/core/launcher.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "core/launcher.h" +#include "kotato/kotato_version.h" #include "platform/platform_launcher.h" #include "platform/platform_specific.h" #include "base/platform/base_platform_info.h" @@ -150,7 +151,7 @@ void ComputeInstallBetaVersions() { if (f.open(QIODevice::ReadOnly)) { cSetInstallBetaVersion(f.read(1) != "0"); } - } else if (AppBetaVersion) { + } else if (AppKotatoBetaVersion) { WriteInstallBetaVersionsSetting(); } } @@ -221,10 +222,13 @@ bool CheckPortableVersionFolder() { const auto portable = cExeDir() + qsl("TelegramForcePortable"); QFile key(portable + qsl("/tdata/alpha")); if (cAlphaVersion()) { + /* Assert(*AlphaPrivateKey != 0); + */ cForceWorkingDir(portable + '/'); QDir().mkpath(cWorkingDir() + qstr("tdata")); + /* cSetAlphaPrivateKey(QByteArray(AlphaPrivateKey)); if (!key.open(QIODevice::WriteOnly)) { LOG(("FATAL: Could not open '%1' for writing private key!" @@ -234,6 +238,7 @@ bool CheckPortableVersionFolder() { QDataStream dataStream(&key); dataStream.setVersion(QDataStream::Qt_5_3); dataStream << quint64(cRealAlphaVersion()) << cAlphaPrivateKey(); + */ return true; } if (!QDir(portable).exists()) { diff --git a/Telegram/SourceFiles/core/update_checker.cpp b/Telegram/SourceFiles/core/update_checker.cpp index 5edcc42d8..b533c6f7b 100644 --- a/Telegram/SourceFiles/core/update_checker.cpp +++ b/Telegram/SourceFiles/core/update_checker.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "core/update_checker.h" +#include "kotato/kotato_version.h" #include "platform/platform_specific.h" #include "base/platform/base_platform_info.h" #include "base/platform/base_platform_file_utilities.h" @@ -304,7 +305,7 @@ bool UnpackUpdate(const QString &filepath) { RSA *pbKey = [] { const auto bio = MakeBIO( const_cast( - AppBetaVersion + AppKotatoBetaVersion ? UpdatesPublicBetaKey : UpdatesPublicKey), -1); @@ -321,7 +322,7 @@ bool UnpackUpdate(const QString &filepath) { pbKey = [] { const auto bio = MakeBIO( const_cast( - AppBetaVersion + AppKotatoBetaVersion ? UpdatesPublicKey : UpdatesPublicBetaKey), -1); @@ -550,7 +551,7 @@ bool ParseCommonMap( const auto types = (*it).toObject(); const auto list = [&]() -> std::vector { if (cAlphaVersion()) { - return { "alpha", "beta", "stable" }; + return { AppKotatoTestBranch }; } else if (cInstallBetaVersion()) { return { "beta", "stable" }; } @@ -573,7 +574,7 @@ bool ParseCommonMap( if (version == map.constEnd()) { continue; } - const auto isAvailableAlpha = (type == "alpha"); + const auto isAvailableAlpha = (type == AppKotatoTestBranch); const auto availableVersion = [&] { if ((*version).isString()) { const auto string = (*version).toString(); @@ -1520,12 +1521,12 @@ bool checkReadyUpdate() { if (versionNum == 0x7FFFFFFF) { // alpha version quint64 alphaVersion = 0; if (fVersion.read((char*)&alphaVersion, sizeof(quint64)) != sizeof(quint64)) { - LOG(("Update Error: cant read alpha version from file '%1'").arg(versionPath)); + LOG(("Update Error: cant read test version from file '%1'").arg(versionPath)); ClearAll(); return false; } if (!cAlphaVersion() || alphaVersion <= cAlphaVersion()) { - LOG(("Update Error: cant install alpha version %1 having alpha version %2").arg(alphaVersion).arg(cAlphaVersion())); + LOG(("Update Error: cant install test version %1 having %2 version %3").arg(alphaVersion).arg(AppKotatoTestBranch).arg(cAlphaVersion())); ClearAll(); return false; } @@ -1660,7 +1661,7 @@ void UpdateApplication() { QString countAlphaVersionSignature(uint64 version) { // duplicated in packer.cpp if (cAlphaPrivateKey().isEmpty()) { - LOG(("Error: Trying to count alpha version signature without alpha private key!")); + //LOG(("Error: Trying to count alpha version signature without alpha private key!")); return QString(); } diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index abbf6b697..7edada1f6 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once #include "base/const_string.h" -#include "kotato/version.h" #define TDESKTOP_REQUESTED_ALPHA_VERSION (0ULL) @@ -25,5 +24,5 @@ constexpr auto AppName = "Kotatogram Desktop"_cs; constexpr auto AppFile = "Kotatogram"_cs; constexpr auto AppVersion = 2008011; constexpr auto AppVersionStr = "2.8.11"; -constexpr auto AppBetaVersion = true; +constexpr auto AppBetaVersion = false; constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION; diff --git a/Telegram/SourceFiles/kotato/json_settings.cpp b/Telegram/SourceFiles/kotato/json_settings.cpp index 53c480de7..300721b38 100644 --- a/Telegram/SourceFiles/kotato/json_settings.cpp +++ b/Telegram/SourceFiles/kotato/json_settings.cpp @@ -7,6 +7,7 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL */ #include "kotato/json_settings.h" +#include "kotato/kotato_version.h" #include "mainwindow.h" #include "mainwidget.h" #include "window/window_controller.h" diff --git a/Telegram/SourceFiles/kotato/kotato_version.h b/Telegram/SourceFiles/kotato/kotato_version.h new file mode 100644 index 000000000..96d9d91db --- /dev/null +++ b/Telegram/SourceFiles/kotato/kotato_version.h @@ -0,0 +1,22 @@ +/* +This file is part of Kotatogram Desktop, +the unofficial app based on Telegram Desktop. + +For license and copyright information please follow this link: +https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL +*/ +#pragma once + +constexpr auto AppKotatoVersion = 1004002; +constexpr auto AppKotatoVersionStr = "1.4.2"; +constexpr auto AppKotatoBetaVersion = true; + +//#define KTGDESKTOP_IS_TEST_VERSION +constexpr auto AppKotatoTestBranch = "dev"; +constexpr auto AppKotatoTestVersion = 0; + +#ifdef KTGDESKTOP_IS_TEST_VERSION +constexpr auto AppKotatoTestVersionFull = (1000ULL * AppKotatoVersion + AppKotatoTestVersion); +#else // KTGDESKTOP_IS_TEST_VERSION +constexpr auto AppKotatoTestVersionFull = (0ULL); +#endif // KTGDESKTOP_IS_TEST_VERSION diff --git a/Telegram/SourceFiles/kotato/version.h b/Telegram/SourceFiles/kotato/version.h deleted file mode 100644 index ec936872d..000000000 --- a/Telegram/SourceFiles/kotato/version.h +++ /dev/null @@ -1,11 +0,0 @@ -/* -This file is part of Kotatogram Desktop, -the unofficial app based on Telegram Desktop. - -For license and copyright information please follow this link: -https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL -*/ -#pragma once - -constexpr auto AppKotatoVersion = 1004002; -constexpr auto AppKotatoVersionStr = "1.4.2"; diff --git a/Telegram/SourceFiles/logs.cpp b/Telegram/SourceFiles/logs.cpp index 37789816d..c638c6d4b 100644 --- a/Telegram/SourceFiles/logs.cpp +++ b/Telegram/SourceFiles/logs.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "logs.h" +#include "kotato/kotato_version.h" #include "platform/platform_specific.h" #include "core/crash_reports.h" #include "core/launcher.h" @@ -428,10 +429,11 @@ void start(not_null launcher) { LogsData = nullptr; } - LOG(("Launched version: %1, install beta: %2, alpha: %3, debug mode: %4" + LOG(("Launched version: %1, install beta: %2, %3: %4, debug mode: %5" ).arg(AppVersion ).arg(Logs::b(cInstallBetaVersion()) - ).arg(cAlphaVersion() + ).arg(AppKotatoTestBranch + ).arg(AppKotatoTestVersion ).arg(Logs::b(DebugEnabled()))); LOG(("Executable dir: %1, name: %2").arg(cExeDir(), cExeName())); LOG(("Initial working dir: %1").arg(initialWorkingDir)); diff --git a/Telegram/SourceFiles/mtproto/session_private.cpp b/Telegram/SourceFiles/mtproto/session_private.cpp index 7d2a74771..eb37538f4 100644 --- a/Telegram/SourceFiles/mtproto/session_private.cpp +++ b/Telegram/SourceFiles/mtproto/session_private.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "mtproto/session_private.h" +#include "kotato/kotato_version.h" #include "mtproto/details/mtproto_bound_key_creator.h" #include "mtproto/details/mtproto_dcenter.h" #include "mtproto/details/mtproto_dump_to_text.h" @@ -88,7 +89,9 @@ using namespace details; #else // OS_MAC_STORE || OS_WIN_STORE || (defined Q_OS_UNIX && !defined Q_OS_MAC) return Platform::IsWindows64Bit() ? u" x64"_q : QString(); #endif // OS_MAC_STORE || OS_WIN_STORE || (defined Q_OS_UNIX && !defined Q_OS_MAC) - })() + qsl(" (TD %1)").arg(AppVersionStr); + })() + (cAlphaVersion() + ? qsl("-%1.%2").arg(AppKotatoTestBranch).arg(AppKotatoTestVersion) + : QString()); } void WrapInvokeAfter( diff --git a/Telegram/SourceFiles/settings.cpp b/Telegram/SourceFiles/settings.cpp index bd6f3a56b..0874d20d0 100644 --- a/Telegram/SourceFiles/settings.cpp +++ b/Telegram/SourceFiles/settings.cpp @@ -7,13 +7,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "settings.h" +#include "kotato/kotato_version.h" #include "ui/emoji_config.h" Qt::LayoutDirection gLangDir = Qt::LeftToRight; -bool gInstallBetaVersion = AppBetaVersion; -uint64 gAlphaVersion = AppAlphaVersion; -uint64 gRealAlphaVersion = AppAlphaVersion; +bool gInstallBetaVersion = AppKotatoBetaVersion; +uint64 gAlphaVersion = AppKotatoTestVersionFull; +uint64 gRealAlphaVersion = AppKotatoTestVersionFull; QByteArray gAlphaPrivateKey; bool gManyInstance = false; diff --git a/Telegram/SourceFiles/storage/localstorage.cpp b/Telegram/SourceFiles/storage/localstorage.cpp index 3450b2814..02b77fe29 100644 --- a/Telegram/SourceFiles/storage/localstorage.cpp +++ b/Telegram/SourceFiles/storage/localstorage.cpp @@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "storage/localstorage.h" // + +#include "kotato/kotato_version.h" #include "storage/serialize_common.h" #include "storage/storage_account.h" #include "storage/details/storage_file_utilities.h"