mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -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;
|
return false;
|
||||||
}
|
}
|
||||||
const auto platforms = document.object();
|
const auto platforms = document.object();
|
||||||
const auto platform = [&] {
|
const auto platform = Platform::AutoUpdateKey();
|
||||||
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 it = platforms.constFind(platform);
|
const auto it = platforms.constFind(platform);
|
||||||
if (it == platforms.constEnd()) {
|
if (it == platforms.constEnd()) {
|
||||||
LOG(("Update Error: MTP platform '%1' not found in response."
|
LOG(("Update Error: MTP platform '%1' not found in response."
|
||||||
|
@ -621,7 +607,11 @@ HttpChecker::HttpChecker(bool testing) : Checker(testing) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpChecker::start() {
|
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"));
|
DEBUG_LOG(("Update Info: requesting update state"));
|
||||||
const auto request = QNetworkRequest(url);
|
const auto request = QNetworkRequest(url);
|
||||||
_manager = std::make_unique<QNetworkAccessManager>();
|
_manager = std::make_unique<QNetworkAccessManager>();
|
||||||
|
@ -896,8 +886,10 @@ void MtpChecker::start() {
|
||||||
crl::on_main(this, [=] { fail(); });
|
crl::on_main(this, [=] { fail(); });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
constexpr auto kFeed = "tdhbcfeed";
|
const auto updaterVersion = Platform::AutoUpdateVersion();
|
||||||
MTP::ResolveChannel(&_mtp, kFeed, [=](const MTPInputChannel &channel) {
|
const auto feed = "tdhbcfeed"
|
||||||
|
+ (updaterVersion > 1 ? QString::number(updaterVersion) : QString());
|
||||||
|
MTP::ResolveChannel(&_mtp, feed, [=](const MTPInputChannel &channel) {
|
||||||
_mtp.send(
|
_mtp.send(
|
||||||
MTPmessages_GetHistory(
|
MTPmessages_GetHistory(
|
||||||
MTP_inputPeerChannel(
|
MTP_inputPeerChannel(
|
||||||
|
|
|
@ -42,4 +42,18 @@ QDate WhenSystemBecomesOutdated() {
|
||||||
return QDate();
|
return QDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AutoUpdateVersion() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AutoUpdateKey() {
|
||||||
|
if (IsLinux32Bit()) {
|
||||||
|
return "linux32";
|
||||||
|
} else if (IsLinux64Bit()) {
|
||||||
|
return "linux";
|
||||||
|
} else {
|
||||||
|
Unexpected("Platform in AutoUpdateKey.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
|
|
@ -122,6 +122,23 @@ QDate WhenSystemBecomesOutdated() {
|
||||||
return QDate();
|
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() {
|
bool IsMac10_6OrGreater() {
|
||||||
return IsMacThatOrGreater<6>();
|
return IsMacThatOrGreater<6>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@ namespace Platform {
|
||||||
[[nodiscard]] QString SystemCountry();
|
[[nodiscard]] QString SystemCountry();
|
||||||
[[nodiscard]] QString SystemLanguage();
|
[[nodiscard]] QString SystemLanguage();
|
||||||
[[nodiscard]] QDate WhenSystemBecomesOutdated();
|
[[nodiscard]] QDate WhenSystemBecomesOutdated();
|
||||||
|
[[nodiscard]] int AutoUpdateVersion();
|
||||||
|
[[nodiscard]] QString AutoUpdateKey();
|
||||||
|
|
||||||
[[nodiscard]] constexpr bool IsWindows();
|
[[nodiscard]] constexpr bool IsWindows();
|
||||||
[[nodiscard]] constexpr bool IsWindowsStoreBuild();
|
[[nodiscard]] constexpr bool IsWindowsStoreBuild();
|
||||||
|
|
|
@ -218,6 +218,17 @@ QDate WhenSystemBecomesOutdated() {
|
||||||
return QDate();
|
return QDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AutoUpdateVersion() {
|
||||||
|
if (!IsWindows7OrGreater()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AutoUpdateKey() {
|
||||||
|
return "win";
|
||||||
|
}
|
||||||
|
|
||||||
bool IsWindowsXPOrGreater() {
|
bool IsWindowsXPOrGreater() {
|
||||||
static const auto result = ::IsWindowsXPOrGreater();
|
static const auto result = ::IsWindowsXPOrGreater();
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Add table
Reference in a new issue