mirror of
https://github.com/vale981/tdesktop
synced 2025-03-05 09:41:41 -05:00
Divide autoupdate paths for OS versions.
This commit is contained in:
parent
f9d10094ac
commit
f463d3ec6d
5 changed files with 54 additions and 18 deletions
|
@ -499,21 +499,7 @@ bool ParseCommonMap(
|
|||
return false;
|
||||
}
|
||||
const auto platforms = document.object();
|
||||
const auto platform = [&] {
|
||||
if (Platform::IsWindows()) {
|
||||
return "win";
|
||||
} else if (Platform::IsMacOldBuild()) {
|
||||
return "mac32";
|
||||
} else if (Platform::IsMac()) {
|
||||
return "mac";
|
||||
} else if (Platform::IsLinux32Bit()) {
|
||||
return "linux32";
|
||||
} else if (Platform::IsLinux64Bit()) {
|
||||
return "linux";
|
||||
} else {
|
||||
Unexpected("Platform in ParseCommonMap.");
|
||||
}
|
||||
}();
|
||||
const auto platform = Platform::AutoUpdateKey();
|
||||
const auto it = platforms.constFind(platform);
|
||||
if (it == platforms.constEnd()) {
|
||||
LOG(("Update Error: MTP platform '%1' not found in response."
|
||||
|
@ -621,7 +607,11 @@ HttpChecker::HttpChecker(bool testing) : Checker(testing) {
|
|||
}
|
||||
|
||||
void HttpChecker::start() {
|
||||
auto url = QUrl(Local::readAutoupdatePrefix() + qstr("/current"));
|
||||
const auto updaterVersion = Platform::AutoUpdateVersion();
|
||||
const auto path = Local::readAutoupdatePrefix()
|
||||
+ qstr("/current")
|
||||
+ (updaterVersion > 1 ? QString::number(updaterVersion) : QString());
|
||||
auto url = QUrl(path);
|
||||
DEBUG_LOG(("Update Info: requesting update state"));
|
||||
const auto request = QNetworkRequest(url);
|
||||
_manager = std::make_unique<QNetworkAccessManager>();
|
||||
|
@ -896,8 +886,10 @@ void MtpChecker::start() {
|
|||
crl::on_main(this, [=] { fail(); });
|
||||
return;
|
||||
}
|
||||
constexpr auto kFeed = "tdhbcfeed";
|
||||
MTP::ResolveChannel(&_mtp, kFeed, [=](const MTPInputChannel &channel) {
|
||||
const auto updaterVersion = Platform::AutoUpdateVersion();
|
||||
const auto feed = "tdhbcfeed"
|
||||
+ (updaterVersion > 1 ? QString::number(updaterVersion) : QString());
|
||||
MTP::ResolveChannel(&_mtp, feed, [=](const MTPInputChannel &channel) {
|
||||
_mtp.send(
|
||||
MTPmessages_GetHistory(
|
||||
MTP_inputPeerChannel(
|
||||
|
|
|
@ -42,4 +42,18 @@ QDate WhenSystemBecomesOutdated() {
|
|||
return QDate();
|
||||
}
|
||||
|
||||
int AutoUpdateVersion() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
QString AutoUpdateKey() {
|
||||
if (IsLinux32Bit()) {
|
||||
return "linux32";
|
||||
} else if (IsLinux64Bit()) {
|
||||
return "linux";
|
||||
} else {
|
||||
Unexpected("Platform in AutoUpdateKey.");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Platform
|
||||
|
|
|
@ -122,6 +122,23 @@ QDate WhenSystemBecomesOutdated() {
|
|||
return QDate();
|
||||
}
|
||||
|
||||
int AutoUpdateVersion() {
|
||||
if (!IsMac10_10OrGreater()) {
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
QString AutoUpdateKey() {
|
||||
if (IsMacOldBuild()) {
|
||||
return "mac32";
|
||||
} else if (!IsMac10_12OrGreater()) {
|
||||
return "osx";
|
||||
} else {
|
||||
return "mac";
|
||||
}
|
||||
}
|
||||
|
||||
bool IsMac10_6OrGreater() {
|
||||
return IsMacThatOrGreater<6>();
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace Platform {
|
|||
[[nodiscard]] QString SystemCountry();
|
||||
[[nodiscard]] QString SystemLanguage();
|
||||
[[nodiscard]] QDate WhenSystemBecomesOutdated();
|
||||
[[nodiscard]] int AutoUpdateVersion();
|
||||
[[nodiscard]] QString AutoUpdateKey();
|
||||
|
||||
[[nodiscard]] constexpr bool IsWindows();
|
||||
[[nodiscard]] constexpr bool IsWindowsStoreBuild();
|
||||
|
|
|
@ -218,6 +218,17 @@ QDate WhenSystemBecomesOutdated() {
|
|||
return QDate();
|
||||
}
|
||||
|
||||
int AutoUpdateVersion() {
|
||||
if (!IsWindows7OrGreater()) {
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
QString AutoUpdateKey() {
|
||||
return "win";
|
||||
}
|
||||
|
||||
bool IsWindowsXPOrGreater() {
|
||||
static const auto result = ::IsWindowsXPOrGreater();
|
||||
return result;
|
||||
|
|
Loading…
Add table
Reference in a new issue