diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index 2397a3b35..a1c5f3e0a 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -712,8 +712,8 @@ sendMediaFileThumbSkip: 10px; sendMediaFileNameTop: 7px; sendMediaFileStatusTop: 37px; -proxyUsePadding: margins(22px, 0px, 22px, 12px); -proxyTryIPv6Padding: margins(22px, 12px, 22px, 0px); +proxyUsePadding: margins(22px, 8px, 22px, 12px); +proxyTryIPv6Padding: margins(22px, 12px, 22px, 8px); proxyRowPadding: margins(22px, 8px, 8px, 8px); proxyRowIconSkip: 32px; proxyRowSkip: 2px; diff --git a/Telegram/SourceFiles/core/update_checker.cpp b/Telegram/SourceFiles/core/update_checker.cpp index 77d6f1b0e..3548dcaa3 100644 --- a/Telegram/SourceFiles/core/update_checker.cpp +++ b/Telegram/SourceFiles/core/update_checker.cpp @@ -31,7 +31,6 @@ namespace { constexpr auto kCheckTimeout = TimeMs(10000); constexpr auto kMaxResponseSize = 1024 * 1024; -const auto kUpdateUrl = "http://updates.tdesktop.com"; #ifdef Q_OS_WIN using VersionInt = DWORD; @@ -397,7 +396,7 @@ bool Updater::checkResponse(const QByteArray &response) { startDownloadThread( bestAvailableVersion, bestIsAvailableBeta, - kUpdateUrl + bestLink); + Local::readAutoupdatePrefix() + bestLink); return true; } @@ -515,7 +514,7 @@ void Updater::start(bool forceWait) { if (sendRequest) { clearSentRequest(); - auto url = QUrl(kUpdateUrl + QString("/current")); + auto url = QUrl(Local::readAutoupdatePrefix() + qstr("/current")); DEBUG_LOG(("Update Info: requesting update state from '%1'" ).arg(url.toDisplayString())); const auto request = QNetworkRequest(url); diff --git a/Telegram/SourceFiles/mtproto/mtp_instance.cpp b/Telegram/SourceFiles/mtproto/mtp_instance.cpp index fceb1d570..d366c66cc 100644 --- a/Telegram/SourceFiles/mtproto/mtp_instance.cpp +++ b/Telegram/SourceFiles/mtproto/mtp_instance.cpp @@ -620,7 +620,7 @@ void Instance::Private::configLoadDone(const MTPConfig &result) { _configLoader.reset(); _lastConfigLoadedTime = getms(true); - auto &data = result.c_config(); + const auto &data = result.c_config(); DEBUG_LOG(("MTP Info: got config, chat_size_max: %1, date: %2, test_mode: %3, this_dc: %4, dc_options.length: %5").arg(data.vchat_size_max.v).arg(data.vdate.v).arg(mtpIsTrue(data.vtest_mode)).arg(data.vthis_dc.v).arg(data.vdc_options.v.size())); if (data.vdc_options.v.empty()) { LOG(("MTP Error: config with empty dc_options received!")); @@ -659,8 +659,14 @@ void Instance::Private::configLoadDone(const MTPConfig &result) { } Global::SetBlockedMode(data.is_blocked_mode()); - Lang::CurrentCloudManager().setSuggestedLanguage(data.has_suggested_lang_code() ? qs(data.vsuggested_lang_code) : QString()); + const auto lang = data.has_suggested_lang_code() + ? qs(data.vsuggested_lang_code) + : QString(); + Lang::CurrentCloudManager().setSuggestedLanguage(lang); + if (data.has_autoupdate_url_prefix()) { + Local::writeAutoupdatePrefix(qs(data.vautoupdate_url_prefix)); + } Local::writeSettings(); _configExpiresAt = getms(true) diff --git a/Telegram/SourceFiles/storage/localstorage.cpp b/Telegram/SourceFiles/storage/localstorage.cpp index 3e882e649..7d388d659 100644 --- a/Telegram/SourceFiles/storage/localstorage.cpp +++ b/Telegram/SourceFiles/storage/localstorage.cpp @@ -2517,6 +2517,54 @@ void writeMtpData() { _writeMtpData(); } +const QString &AutoupdatePrefix(const QString &replaceWith = {}) { + static auto value = QString(); + if (!replaceWith.isEmpty()) { + value = replaceWith; + } + return value; +} + +QString autoupdatePrefixFile() { + return cWorkingDir() + "tdata/prefix"; +} + +const QString &readAutoupdatePrefixRaw() { + const auto &result = AutoupdatePrefix(); + if (!result.isEmpty()) { + return result; + } + QFile f(autoupdatePrefixFile()); + if (f.open(QIODevice::ReadOnly)) { + const auto value = QString::fromUtf8(f.readAll()); + if (!value.isEmpty()) { + return AutoupdatePrefix(value); + } + } + return AutoupdatePrefix("http://updates.tdesktop.com"); +} + +void writeAutoupdatePrefix(const QString &prefix) { + const auto current = readAutoupdatePrefixRaw(); + if (current != prefix) { + AutoupdatePrefix(prefix); + QFile f(autoupdatePrefixFile()); + if (f.open(QIODevice::WriteOnly)) { + f.write(prefix.toUtf8()); + f.close(); + } + if (cAutoUpdate()) { + Core::UpdateChecker checker; + checker.start(); + } + } +} + +QString readAutoupdatePrefix() { + auto result = readAutoupdatePrefixRaw(); + return result.replace(QRegularExpression("/+$"), QString()); +} + void reset() { if (_localLoader) { _localLoader->stop(); diff --git a/Telegram/SourceFiles/storage/localstorage.h b/Telegram/SourceFiles/storage/localstorage.h index d27c09293..cd6185f97 100644 --- a/Telegram/SourceFiles/storage/localstorage.h +++ b/Telegram/SourceFiles/storage/localstorage.h @@ -27,6 +27,9 @@ void writeSettings(); void writeUserSettings(); void writeMtpData(); +void writeAutoupdatePrefix(const QString &prefix); +QString readAutoupdatePrefix(); + void reset(); bool checkPasscode(const QByteArray &passcode);