Support toggling installs of beta versions.

This commit is contained in:
John Preston 2018-09-26 18:11:16 +03:00
parent 6e566e0165
commit 971d0efda9
10 changed files with 32 additions and 18 deletions

View File

@ -20,7 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/update_checker.h"
AboutBox::AboutBox(QWidget *parent)
: _version(this, lng_about_version(lt_version, QString::fromLatin1(AppVersionStr.c_str()) + (cBetaVersion() ? " beta" : "") + (cAlphaVersion() ? qsl(" alpha %1").arg(cAlphaVersion()) : QString())), st::aboutVersionLink)
: _version(this, lng_about_version(lt_version, QString::fromLatin1(AppVersionStr.c_str()) + (AppBetaVersion ? " beta" : "") + (cAlphaVersion() ? qsl(" alpha %1").arg(cAlphaVersion()) : QString())), st::aboutVersionLink)
, _text1(this, lang(lng_about_text_1), Ui::FlatLabel::InitType::Rich, st::aboutLabel)
, _text2(this, lang(lng_about_text_2), Ui::FlatLabel::InitType::Rich, st::aboutLabel)
, _text3(this, st::aboutLabel) {
@ -99,7 +99,7 @@ QString telegramFaqLink() {
QString currentVersionText() {
auto result = QString::fromLatin1(AppVersionStr.c_str());
if (cBetaVersion()) {
if (AppBetaVersion) {
result += " beta";
}
if (cAlphaVersion()) {

View File

@ -118,7 +118,7 @@ void Changelogs::requestCloudLogs() {
}
void Changelogs::addLocalLogs() {
if (cBetaVersion() || cAlphaVersion()) {
if (AppBetaVersion || cAlphaVersion()) {
addBetaLogs();
}
if (!_addedSomeLocal) {

View File

@ -228,7 +228,7 @@ LastCrashedWindow::LastCrashedWindow()
: std::make_unique<UpdaterData>(this)) {
excludeReportUsername();
if (!cBetaVersion() && !cAlphaVersion()) { // currently accept crash reports only from testers
if (!cInstallBetaVersion() && !cAlphaVersion()) { // currently accept crash reports only from testers
_sendingState = SendingNoReport;
}
if (_sendingState != SendingNoReport) {

View File

@ -310,7 +310,7 @@ void StartCatching() {
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
ProcessAnnotations["Binary"] = cExeName().toUtf8().constData();
ProcessAnnotations["ApiId"] = QString::number(ApiId).toUtf8().constData();
ProcessAnnotations["Version"] = (cAlphaVersion() ? qsl("%1 alpha").arg(cAlphaVersion()) : (cBetaVersion() ? qsl("%1 beta") : qsl("%1")).arg(AppVersion)).toUtf8().constData();
ProcessAnnotations["Version"] = (cAlphaVersion() ? qsl("%1 alpha").arg(cAlphaVersion()) : (AppBetaVersion ? qsl("%1 beta") : qsl("%1")).arg(AppVersion)).toUtf8().constData();
ProcessAnnotations["Launched"] = QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss").toUtf8().constData();
ProcessAnnotations["Platform"] = cPlatformString().toUtf8().constData();
ProcessAnnotations["UserTag"] = QString::number(Sandbox::UserTag(), 16).toUtf8().constData();

View File

@ -398,7 +398,7 @@ bool UnpackUpdate(const QString &filepath) {
}
if (RSA_verify(NID_sha1, (const uchar*)(compressed.constData() + hSigLen), hShaLen, (const uchar*)(compressed.constData()), hSigLen, pbKey) != 1) { // verify signature
RSA_free(pbKey);
if (cBetaVersion() || cAlphaVersion()) { // try other public key, if we are in beta or alpha version
if (cInstallBetaVersion() || cAlphaVersion()) { // try other public key, if we are in beta or alpha version
pbKey = PEM_read_bio_RSAPublicKey(BIO_new_mem_buf(const_cast<char*>(AppBetaVersion ? UpdatesPublicKey : UpdatesPublicBetaKey), -1), 0, 0, 0);
if (!pbKey) {
LOG(("Update Error: cant read public rsa key!"));
@ -655,7 +655,7 @@ bool ParseCommonMap(
const auto list = [&]() -> std::vector<QString> {
if (cAlphaVersion()) {
return { "alpha", "beta", "stable" };
} else if (cBetaVersion()) {
} else if (cInstallBetaVersion()) {
return { "beta", "stable" };
}
return { "stable" };

View File

@ -447,14 +447,18 @@ void WorkingDirReady() {
&& QFile(cWorkingDir() + qsl("tdata/withdebug")).exists()) {
Logs::SetDebugEnabled(true);
}
const auto installBetaPath = cWorkingDir() + qsl("tdata/devversion");
if (cAlphaVersion()) {
cSetBetaVersion(false);
} else if (!cBetaVersion() && QFile(cWorkingDir() + qsl("tdata/devversion")).exists()) {
cSetBetaVersion(true);
cSetInstallBetaVersion(false);
} else if (QFile(installBetaPath).exists()) {
QFile f(installBetaPath);
if (f.open(QIODevice::ReadOnly)) {
cSetInstallBetaVersion(f.read(1) != "0");
}
} else if (AppBetaVersion) {
QFile f(cWorkingDir() + qsl("tdata/devversion"));
if (!f.exists() && f.open(QIODevice::WriteOnly)) {
f.write("1");
QFile f(installBetaPath);
if (f.open(QIODevice::WriteOnly)) {
f.write(cInstallBetaVersion() ? "1" : "0");
}
}

View File

@ -25,7 +25,7 @@ namespace {
void SendToBannedHelp(const QString &phone) {
const auto version = QString::fromLatin1(AppVersionStr.c_str())
+ (cBetaVersion() ? " beta" : "")
+ (AppBetaVersion ? " beta" : "")
+ (cAlphaVersion() ? qsl(" alpha %1").arg(cAlphaVersion()) : QString());
const auto subject = qsl("Banned phone number: ") + phone;

View File

@ -397,14 +397,24 @@ void start(not_null<Core::Launcher*> launcher) {
LogsData = 0;
}
LOG(("Launched version: %1, beta: %2, alpha: %3, debug mode: %4, test dc: %5").arg(AppVersion).arg(Logs::b(cBetaVersion())).arg(cAlphaVersion()).arg(Logs::b(DebugEnabled())).arg(Logs::b(cTestMode())));
LOG(("Launched version: %1, "
"install beta: %2, "
"alpha: %3, "
"debug mode: %4, "
"test dc: %5"
).arg(AppVersion
).arg(Logs::b(cInstallBetaVersion())
).arg(cAlphaVersion()
).arg(Logs::b(DebugEnabled())
).arg(Logs::b(cTestMode())));
LOG(("Executable dir: %1, name: %2").arg(cExeDir()).arg(cExeName()));
LOG(("Initial working dir: %1").arg(initialWorkingDir));
LOG(("Working dir: %1").arg(cWorkingDir()));
LOG(("Command line: %1").arg(launcher->argumentsString()));
if (!LogsData) {
LOG(("FATAL: Could not open '%1' for writing log!").arg(_logsFilePath(LogDataMain, qsl("_startXX"))));
LOG(("FATAL: Could not open '%1' for writing log!"
).arg(_logsFilePath(LogDataMain, qsl("_startXX"))));
return;
}

View File

@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
bool gRtl = false;
Qt::LayoutDirection gLangDir = gRtl ? Qt::RightToLeft : Qt::LeftToRight;
bool gBetaVersion = AppBetaVersion;
bool gInstallBetaVersion = AppBetaVersion;
uint64 gAlphaVersion = AppAlphaVersion;
uint64 gRealAlphaVersion = AppAlphaVersion;
QByteArray gAlphaPrivateKey;

View File

@ -28,7 +28,7 @@ inline bool rtl() {
return cRtl();
}
DeclareSetting(bool, BetaVersion);
DeclareSetting(bool, InstallBetaVersion);
DeclareSetting(uint64, AlphaVersion);
DeclareSetting(uint64, RealAlphaVersion);
DeclareSetting(QByteArray, AlphaPrivateKey);