2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Add '-externalupdater' command-line argument.

Now no-autoupdater mode can be switched on in runtime.
Also TDESKTOP_DISABLE_AUTOUPDATE build is disabled in CI (trivial).

Fixes #4895.
This commit is contained in:
John Preston
2018-07-12 01:14:44 +03:00
parent e2bc6990c7
commit 52e7ddf079
29 changed files with 449 additions and 420 deletions

View File

@@ -194,6 +194,11 @@ void NotStartedWindow::resizeEvent(QResizeEvent *e) {
_close.setGeometry(width() - padding - _close.width(), height() - padding - _close.height(), _close.width(), _close.height());
}
LastCrashedWindow::UpdaterData::UpdaterData(QWidget *buttonParent)
: check(buttonParent)
, skip(buttonParent, false) {
}
LastCrashedWindow::LastCrashedWindow()
: _port(80)
, _label(this)
@@ -218,11 +223,9 @@ LastCrashedWindow::LastCrashedWindow()
, _sendingTotal(0)
, _checkReply(0)
, _sendReply(0)
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
, _updatingCheck(this)
, _updatingSkip(this, false)
#endif // !TDESKTOP_DISABLE_AUTOUPDATE
{
, _updaterData(Core::UpdaterDisabled()
? nullptr
: std::make_unique<UpdaterData>(this)) {
excludeReportUsername();
if (!cAlphaVersion() && !cBetaVersion()) { // currently accept crash reports only from testers
@@ -293,49 +296,49 @@ LastCrashedWindow::LastCrashedWindow()
_label.setText(qsl("Last time Telegram Desktop crashed :("));
}
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
_updatingCheck.setText(qsl("TRY AGAIN"));
connect(&_updatingCheck, SIGNAL(clicked()), this, SLOT(onUpdateRetry()));
_updatingSkip.setText(qsl("SKIP"));
connect(&_updatingSkip, SIGNAL(clicked()), this, SLOT(onUpdateSkip()));
if (_updaterData) {
_updaterData->check.setText(qsl("TRY AGAIN"));
connect(&_updaterData->check, SIGNAL(clicked()), this, SLOT(onUpdateRetry()));
_updaterData->skip.setText(qsl("SKIP"));
connect(&_updaterData->skip, SIGNAL(clicked()), this, SLOT(onUpdateSkip()));
Core::UpdateChecker checker;
using Progress = Core::UpdateChecker::Progress;
checker.checking(
) | rpl::start_with_next([=] { onUpdateChecking(); }, _lifetime);
checker.isLatest(
) | rpl::start_with_next([=] { onUpdateLatest(); }, _lifetime);
checker.progress(
) | rpl::start_with_next([=](const Progress &result) {
onUpdateDownloading(result.already, result.size);
}, _lifetime);
checker.failed(
) | rpl::start_with_next([=] { onUpdateFailed(); }, _lifetime);
checker.ready(
) | rpl::start_with_next([=] { onUpdateReady(); }, _lifetime);
Core::UpdateChecker checker;
using Progress = Core::UpdateChecker::Progress;
checker.checking(
) | rpl::start_with_next([=] { onUpdateChecking(); }, _lifetime);
checker.isLatest(
) | rpl::start_with_next([=] { onUpdateLatest(); }, _lifetime);
checker.progress(
) | rpl::start_with_next([=](const Progress &result) {
onUpdateDownloading(result.already, result.size);
}, _lifetime);
checker.failed(
) | rpl::start_with_next([=] { onUpdateFailed(); }, _lifetime);
checker.ready(
) | rpl::start_with_next([=] { onUpdateReady(); }, _lifetime);
switch (checker.state()) {
case Core::UpdateChecker::State::Download:
setUpdatingState(UpdatingDownload, true);
setDownloadProgress(checker.already(), checker.size());
break;
case Core::UpdateChecker::State::Ready:
setUpdatingState(UpdatingReady, true);
break;
default:
setUpdatingState(UpdatingCheck, true);
break;
switch (checker.state()) {
case Core::UpdateChecker::State::Download:
setUpdatingState(UpdatingDownload, true);
setDownloadProgress(checker.already(), checker.size());
break;
case Core::UpdateChecker::State::Ready:
setUpdatingState(UpdatingReady, true);
break;
default:
setUpdatingState(UpdatingCheck, true);
break;
}
cSetLastUpdateCheck(0);
checker.start();
} else {
_updating.setText(qsl("Please check if there is a new version available."));
if (_sendingState != SendingNoReport) {
_sendingState = SendingNone;
}
}
cSetLastUpdateCheck(0);
checker.start();
#else // !TDESKTOP_DISABLE_AUTOUPDATE
_updating.setText(qsl("Please check if there is a new version available."));
if (_sendingState != SendingNoReport) {
_sendingState = SendingNone;
}
#endif // else for !TDESKTOP_DISABLE_AUTOUPDATE
_pleaseSendReport.setText(qsl("Please send us a crash report."));
_yourReportName.setText(qsl("Your Report Tag: %1\nYour User Tag: %2").arg(QString(_minidumpName).replace(".dmp", "")).arg(Sandbox::UserTag(), 0, 16));
_yourReportName.setCursor(style::cur_text);
@@ -552,69 +555,41 @@ void LastCrashedWindow::updateControls() {
int padding = _size, h = padding + _networkSettings.height() + padding;
_label.show();
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
h += _networkSettings.height() + padding;
if (_updatingState == UpdatingFail && (_sendingState == SendingNoReport || _sendingState == SendingUpdateCheck)) {
_networkSettings.show();
_updatingCheck.show();
_updatingSkip.show();
_send.hide();
_sendSkip.hide();
_continue.hide();
_pleaseSendReport.hide();
_yourReportName.hide();
_includeUsername.hide();
_getApp.hide();
_showReport.hide();
_report.hide();
_minidump.hide();
_saveReport.hide();
h += padding + _updatingCheck.height() + padding;
} else {
if (_updatingState == UpdatingCheck || _sendingState == SendingFail || _sendingState == SendingProgress) {
if (_updaterData) {
h += _networkSettings.height() + padding;
if (_updaterData->state == UpdatingFail && (_sendingState == SendingNoReport || _sendingState == SendingUpdateCheck)) {
_networkSettings.show();
_updaterData->check.show();
_updaterData->skip.show();
_send.hide();
_sendSkip.hide();
_continue.hide();
_pleaseSendReport.hide();
_yourReportName.hide();
_includeUsername.hide();
_getApp.hide();
_showReport.hide();
_report.hide();
_minidump.hide();
_saveReport.hide();
h += padding + _updaterData->check.height() + padding;
} else {
_networkSettings.hide();
}
if (_updatingState == UpdatingNone || _updatingState == UpdatingLatest || _updatingState == UpdatingFail) {
h += padding + _updatingCheck.height() + padding;
if (_sendingState == SendingNoReport) {
_pleaseSendReport.hide();
_yourReportName.hide();
_includeUsername.hide();
_getApp.hide();
_showReport.hide();
_report.hide();
_minidump.hide();
_saveReport.hide();
_send.hide();
_sendSkip.hide();
_continue.show();
if (_updaterData->state == UpdatingCheck
|| _sendingState == SendingFail
|| _sendingState == SendingProgress) {
_networkSettings.show();
} else {
h += _showReport.height() + padding + _yourReportName.height() + padding;
_pleaseSendReport.show();
_yourReportName.show();
if (_reportUsername.isEmpty()) {
_networkSettings.hide();
}
if (_updaterData->state == UpdatingNone
|| _updaterData->state == UpdatingLatest
|| _updaterData->state == UpdatingFail) {
h += padding + _updaterData->check.height() + padding;
if (_sendingState == SendingNoReport) {
_pleaseSendReport.hide();
_yourReportName.hide();
_includeUsername.hide();
} else {
h += _includeUsername.height() + padding;
_includeUsername.show();
}
if (_sendingState == SendingTooOld || _sendingState == SendingUnofficial) {
QString verStr = getReportField(qstr("version"), qstr("Version:"));
qint64 ver = verStr.isEmpty() ? 0 : verStr.toLongLong();
if (!ver || (ver == AppVersion) || (ver < 0 && (-ver / 1000) == AppVersion)) {
h += _getApp.height() + padding;
_getApp.show();
h -= _yourReportName.height() + padding; // hide report name
_yourReportName.hide();
if (!_reportUsername.isEmpty()) {
h -= _includeUsername.height() + padding;
_includeUsername.hide();
}
} else {
_getApp.hide();
}
_getApp.hide();
_showReport.hide();
_report.hide();
_minidump.hide();
@@ -623,48 +598,104 @@ void LastCrashedWindow::updateControls() {
_sendSkip.hide();
_continue.show();
} else {
_getApp.hide();
if (_reportShown) {
h += (_pleaseSendReport.height() * 12.5) + padding + (_minidumpName.isEmpty() ? 0 : (_minidump.height() + padding));
_report.show();
if (_minidumpName.isEmpty()) {
_minidump.hide();
h += _showReport.height() + padding + _yourReportName.height() + padding;
_pleaseSendReport.show();
_yourReportName.show();
if (_reportUsername.isEmpty()) {
_includeUsername.hide();
} else {
h += _includeUsername.height() + padding;
_includeUsername.show();
}
if (_sendingState == SendingTooOld || _sendingState == SendingUnofficial) {
QString verStr = getReportField(qstr("version"), qstr("Version:"));
qint64 ver = verStr.isEmpty() ? 0 : verStr.toLongLong();
if (!ver || (ver == AppVersion) || (ver < 0 && (-ver / 1000) == AppVersion)) {
h += _getApp.height() + padding;
_getApp.show();
h -= _yourReportName.height() + padding; // hide report name
_yourReportName.hide();
if (!_reportUsername.isEmpty()) {
h -= _includeUsername.height() + padding;
_includeUsername.hide();
}
} else {
_minidump.show();
}
if (_reportSaved || _sendingState == SendingFail || _sendingState == SendingProgress || _sendingState == SendingUploading) {
_saveReport.hide();
} else {
_saveReport.show();
_getApp.hide();
}
_showReport.hide();
} else {
_report.hide();
_minidump.hide();
_saveReport.hide();
if (_sendingState == SendingFail || _sendingState == SendingProgress || _sendingState == SendingUploading) {
_showReport.hide();
} else {
_showReport.show();
}
}
if (_sendingState == SendingTooMany || _sendingState == SendingDone) {
_send.hide();
_sendSkip.hide();
_continue.show();
} else {
if (_sendingState == SendingProgress || _sendingState == SendingUploading) {
_send.hide();
_getApp.hide();
if (_reportShown) {
h += (_pleaseSendReport.height() * 12.5) + padding + (_minidumpName.isEmpty() ? 0 : (_minidump.height() + padding));
_report.show();
if (_minidumpName.isEmpty()) {
_minidump.hide();
} else {
_minidump.show();
}
if (_reportSaved || _sendingState == SendingFail || _sendingState == SendingProgress || _sendingState == SendingUploading) {
_saveReport.hide();
} else {
_saveReport.show();
}
_showReport.hide();
} else {
_send.show();
_report.hide();
_minidump.hide();
_saveReport.hide();
if (_sendingState == SendingFail || _sendingState == SendingProgress || _sendingState == SendingUploading) {
_showReport.hide();
} else {
_showReport.show();
}
}
if (_sendingState == SendingTooMany || _sendingState == SendingDone) {
_send.hide();
_sendSkip.hide();
_continue.show();
} else {
if (_sendingState == SendingProgress || _sendingState == SendingUploading) {
_send.hide();
} else {
_send.show();
}
_sendSkip.show();
_continue.hide();
}
_sendSkip.show();
_continue.hide();
}
}
} else {
_getApp.hide();
_pleaseSendReport.hide();
_yourReportName.hide();
_includeUsername.hide();
_showReport.hide();
_report.hide();
_minidump.hide();
_saveReport.hide();
_send.hide();
_sendSkip.hide();
_continue.hide();
}
} else {
_getApp.hide();
_updaterData->check.hide();
if (_updaterData->state == UpdatingCheck
|| _updaterData->state == UpdatingDownload) {
h += padding + _updaterData->skip.height() + padding;
_updaterData->skip.show();
} else {
_updaterData->skip.hide();
}
}
} else {
h += _networkSettings.height() + padding;
h += padding + _send.height() + padding;
if (_sendingState == SendingNoReport) {
_pleaseSendReport.hide();
_yourReportName.hide();
_includeUsername.hide();
@@ -672,91 +703,68 @@ void LastCrashedWindow::updateControls() {
_report.hide();
_minidump.hide();
_saveReport.hide();
_send.hide();
_sendSkip.hide();
_continue.hide();
}
_updatingCheck.hide();
if (_updatingState == UpdatingCheck || _updatingState == UpdatingDownload) {
h += padding + _updatingSkip.height() + padding;
_updatingSkip.show();
} else {
_updatingSkip.hide();
}
}
#else // !TDESKTOP_DISABLE_AUTOUPDATE
h += _networkSettings.height() + padding;
h += padding + _send.height() + padding;
if (_sendingState == SendingNoReport) {
_pleaseSendReport.hide();
_yourReportName.hide();
_includeUsername.hide();
_showReport.hide();
_report.hide();
_minidump.hide();
_saveReport.hide();
_send.hide();
_sendSkip.hide();
_continue.show();
_networkSettings.hide();
} else {
h += _showReport.height() + padding + _yourReportName.height() + padding;
_pleaseSendReport.show();
_yourReportName.show();
if (_reportUsername.isEmpty()) {
_includeUsername.hide();
} else {
h += _includeUsername.height() + padding;
_includeUsername.show();
}
if (_reportShown) {
h += (_pleaseSendReport.height() * 12.5) + padding + (_minidumpName.isEmpty() ? 0 : (_minidump.height() + padding));
_report.show();
if (_minidumpName.isEmpty()) {
_minidump.hide();
} else {
_minidump.show();
}
_showReport.hide();
if (_reportSaved || _sendingState == SendingFail || _sendingState == SendingProgress || _sendingState == SendingUploading) {
_saveReport.hide();
} else {
_saveReport.show();
}
} else {
_report.hide();
_minidump.hide();
_saveReport.hide();
if (_sendingState == SendingFail || _sendingState == SendingProgress || _sendingState == SendingUploading) {
_showReport.hide();
} else {
_showReport.show();
}
}
if (_sendingState == SendingDone) {
_send.hide();
_sendSkip.hide();
_continue.show();
_networkSettings.hide();
} else {
if (_sendingState == SendingProgress || _sendingState == SendingUploading) {
h += _showReport.height() + padding + _yourReportName.height() + padding;
_pleaseSendReport.show();
_yourReportName.show();
if (_reportUsername.isEmpty()) {
_includeUsername.hide();
} else {
h += _includeUsername.height() + padding;
_includeUsername.show();
}
if (_reportShown) {
h += (_pleaseSendReport.height() * 12.5) + padding + (_minidumpName.isEmpty() ? 0 : (_minidump.height() + padding));
_report.show();
if (_minidumpName.isEmpty()) {
_minidump.hide();
} else {
_minidump.show();
}
_showReport.hide();
if (_reportSaved || _sendingState == SendingFail || _sendingState == SendingProgress || _sendingState == SendingUploading) {
_saveReport.hide();
} else {
_saveReport.show();
}
} else {
_report.hide();
_minidump.hide();
_saveReport.hide();
if (_sendingState == SendingFail || _sendingState == SendingProgress || _sendingState == SendingUploading) {
_showReport.hide();
} else {
_showReport.show();
}
}
if (_sendingState == SendingDone) {
_send.hide();
} else {
_send.show();
}
_sendSkip.show();
if (_sendingState == SendingFail) {
_networkSettings.show();
} else {
_sendSkip.hide();
_continue.show();
_networkSettings.hide();
} else {
if (_sendingState == SendingProgress || _sendingState == SendingUploading) {
_send.hide();
} else {
_send.show();
}
_sendSkip.show();
if (_sendingState == SendingFail) {
_networkSettings.show();
} else {
_networkSettings.hide();
}
_continue.hide();
}
_continue.hide();
}
}
_getApp.show();
h += _networkSettings.height() + padding;
#endif // else for !TDESKTOP_DISABLE_AUTOUPDATE
_getApp.show();
h += _networkSettings.height() + padding;
}
QRect scr(QApplication::primaryScreen()->availableGeometry());
QSize s(2 * padding + QFontMetrics(_label.font()).width(qsl("Last time Telegram Desktop was not closed properly.")) + padding + _networkSettings.width(), h);
@@ -801,24 +809,27 @@ void LastCrashedWindow::onNetworkSettingsSaved(
Sandbox::refreshGlobalProxy();
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
if ((_updatingState == UpdatingFail && (_sendingState == SendingNoReport || _sendingState == SendingUpdateCheck)) || (_updatingState == UpdatingCheck)) {
if (_updaterData
&& ((_updaterData->state == UpdatingCheck)
|| (_updaterData->state == UpdatingFail
&& (_sendingState == SendingNoReport
|| _sendingState == SendingUpdateCheck)))) {
Core::UpdateChecker checker;
checker.stop();
cSetLastUpdateCheck(0);
checker.start();
} else
#endif // !TDESKTOP_DISABLE_AUTOUPDATE
if (_sendingState == SendingFail || _sendingState == SendingProgress) {
} else if (_sendingState == SendingFail
|| _sendingState == SendingProgress) {
onSendReport();
}
activate();
}
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
void LastCrashedWindow::setUpdatingState(UpdatingState state, bool force) {
if (_updatingState != state || force) {
_updatingState = state;
Expects(_updaterData != nullptr);
if (_updaterData->state != state || force) {
_updaterData->state = state;
switch (state) {
case UpdatingLatest:
_updating.setText(qsl("Latest version is installed."));
@@ -850,29 +861,35 @@ void LastCrashedWindow::setUpdatingState(UpdatingState state, bool force) {
}
void LastCrashedWindow::setDownloadProgress(qint64 ready, qint64 total) {
Expects(_updaterData != nullptr);
qint64 readyTenthMb = (ready * 10 / (1024 * 1024)), totalTenthMb = (total * 10 / (1024 * 1024));
QString readyStr = QString::number(readyTenthMb / 10) + '.' + QString::number(readyTenthMb % 10);
QString totalStr = QString::number(totalTenthMb / 10) + '.' + QString::number(totalTenthMb % 10);
QString res = qsl("Downloading update {ready} / {total} MB..").replace(qstr("{ready}"), readyStr).replace(qstr("{total}"), totalStr);
if (_newVersionDownload != res) {
_newVersionDownload = res;
_updating.setText(_newVersionDownload);
if (_updaterData->newVersionDownload != res) {
_updaterData->newVersionDownload = res;
_updating.setText(_updaterData->newVersionDownload);
updateControls();
}
}
void LastCrashedWindow::onUpdateRetry() {
Expects(_updaterData != nullptr);
cSetLastUpdateCheck(0);
Core::UpdateChecker checker;
checker.start();
}
void LastCrashedWindow::onUpdateSkip() {
Expects(_updaterData != nullptr);
if (_sendingState == SendingNoReport) {
onContinue();
} else {
if (_updatingState == UpdatingCheck
|| _updatingState == UpdatingDownload) {
if (_updaterData->state == UpdatingCheck
|| _updaterData->state == UpdatingDownload) {
Core::UpdateChecker checker;
checker.stop();
setUpdatingState(UpdatingFail);
@@ -883,26 +900,35 @@ void LastCrashedWindow::onUpdateSkip() {
}
void LastCrashedWindow::onUpdateChecking() {
Expects(_updaterData != nullptr);
setUpdatingState(UpdatingCheck);
}
void LastCrashedWindow::onUpdateLatest() {
Expects(_updaterData != nullptr);
setUpdatingState(UpdatingLatest);
}
void LastCrashedWindow::onUpdateDownloading(qint64 ready, qint64 total) {
Expects(_updaterData != nullptr);
setUpdatingState(UpdatingDownload);
setDownloadProgress(ready, total);
}
void LastCrashedWindow::onUpdateReady() {
Expects(_updaterData != nullptr);
setUpdatingState(UpdatingReady);
}
void LastCrashedWindow::onUpdateFailed() {
Expects(_updaterData != nullptr);
setUpdatingState(UpdatingFail);
}
#endif // !TDESKTOP_DISABLE_AUTOUPDATE
void LastCrashedWindow::onContinue() {
if (CrashReports::Restart() == CrashReports::CantOpen) {
@@ -973,36 +999,37 @@ void LastCrashedWindow::resizeEvent(QResizeEvent *e) {
_updating.move(padding, padding * 2 + _networkSettings.height() + (_networkSettings.height() - _updating.height()) / 2);
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
_pleaseSendReport.move(padding, padding * 2 + _networkSettings.height() + _networkSettings.height() + padding + (_showReport.height() - _pleaseSendReport.height()) / 2);
_showReport.move(padding * 2 + _pleaseSendReport.width(), padding * 2 + _networkSettings.height() + _networkSettings.height() + padding);
_yourReportName.move(padding, _showReport.y() + _showReport.height() + padding);
_includeUsername.move(padding, _yourReportName.y() + _yourReportName.height() + padding);
_getApp.move((width() - _getApp.width()) / 2, _showReport.y() + _showReport.height() + padding);
if (_updaterData) {
_pleaseSendReport.move(padding, padding * 2 + _networkSettings.height() + _networkSettings.height() + padding + (_showReport.height() - _pleaseSendReport.height()) / 2);
_showReport.move(padding * 2 + _pleaseSendReport.width(), padding * 2 + _networkSettings.height() + _networkSettings.height() + padding);
_yourReportName.move(padding, _showReport.y() + _showReport.height() + padding);
_includeUsername.move(padding, _yourReportName.y() + _yourReportName.height() + padding);
_getApp.move((width() - _getApp.width()) / 2, _showReport.y() + _showReport.height() + padding);
if (_sendingState == SendingFail || _sendingState == SendingProgress) {
_networkSettings.move(padding * 2 + _pleaseSendReport.width(), padding * 2 + _networkSettings.height() + _networkSettings.height() + padding);
if (_sendingState == SendingFail || _sendingState == SendingProgress) {
_networkSettings.move(padding * 2 + _pleaseSendReport.width(), padding * 2 + _networkSettings.height() + _networkSettings.height() + padding);
} else {
_networkSettings.move(padding * 2 + _updating.width(), padding * 2 + _networkSettings.height());
}
if (_updaterData->state == UpdatingCheck
|| _updaterData->state == UpdatingDownload) {
_updaterData->check.move(width() - padding - _updaterData->check.width(), height() - padding - _updaterData->check.height());
_updaterData->skip.move(width() - padding - _updaterData->skip.width(), height() - padding - _updaterData->skip.height());
} else {
_updaterData->check.move(width() - padding - _updaterData->check.width(), height() - padding - _updaterData->check.height());
_updaterData->skip.move(width() - padding - _updaterData->check.width() - padding - _updaterData->skip.width(), height() - padding - _updaterData->skip.height());
}
} else {
_networkSettings.move(padding * 2 + _updating.width(), padding * 2 + _networkSettings.height());
_getApp.move((width() - _getApp.width()) / 2, _updating.y() + _updating.height() + padding);
_pleaseSendReport.move(padding, padding * 2 + _networkSettings.height() + _networkSettings.height() + padding + _getApp.height() + padding + (_showReport.height() - _pleaseSendReport.height()) / 2);
_showReport.move(padding * 2 + _pleaseSendReport.width(), padding * 2 + _networkSettings.height() + _networkSettings.height() + padding + _getApp.height() + padding);
_yourReportName.move(padding, _showReport.y() + _showReport.height() + padding);
_includeUsername.move(padding, _yourReportName.y() + _yourReportName.height() + padding);
_networkSettings.move(padding * 2 + _pleaseSendReport.width(), padding * 2 + _networkSettings.height() + _networkSettings.height() + padding + _getApp.height() + padding);
}
if (_updatingState == UpdatingCheck || _updatingState == UpdatingDownload) {
_updatingCheck.move(width() - padding - _updatingCheck.width(), height() - padding - _updatingCheck.height());
_updatingSkip.move(width() - padding - _updatingSkip.width(), height() - padding - _updatingSkip.height());
} else {
_updatingCheck.move(width() - padding - _updatingCheck.width(), height() - padding - _updatingCheck.height());
_updatingSkip.move(width() - padding - _updatingCheck.width() - padding - _updatingSkip.width(), height() - padding - _updatingSkip.height());
}
#else // !TDESKTOP_DISABLE_AUTOUPDATE
_getApp.move((width() - _getApp.width()) / 2, _updating.y() + _updating.height() + padding);
_pleaseSendReport.move(padding, padding * 2 + _networkSettings.height() + _networkSettings.height() + padding + _getApp.height() + padding + (_showReport.height() - _pleaseSendReport.height()) / 2);
_showReport.move(padding * 2 + _pleaseSendReport.width(), padding * 2 + _networkSettings.height() + _networkSettings.height() + padding + _getApp.height() + padding);
_yourReportName.move(padding, _showReport.y() + _showReport.height() + padding);
_includeUsername.move(padding, _yourReportName.y() + _yourReportName.height() + padding);
_networkSettings.move(padding * 2 + _pleaseSendReport.width(), padding * 2 + _networkSettings.height() + _networkSettings.height() + padding + _getApp.height() + padding);
#endif // else for !TDESKTOP_DISABLE_AUTOUPDATE
if (_reportUsername.isEmpty()) {
_report.setGeometry(padding, _yourReportName.y() + _yourReportName.height() + padding, width() - 2 * padding, _pleaseSendReport.height() * 12.5);
} else {

View File

@@ -95,7 +95,6 @@ public slots:
void onSendingFinished();
void onSendingProgress(qint64 uploaded, qint64 total);
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
void onUpdateRetry();
void onUpdateSkip();
@@ -104,7 +103,6 @@ public slots:
void onUpdateDownloading(qint64 ready, qint64 total);
void onUpdateReady();
void onUpdateFailed();
#endif // !TDESKTOP_DISABLE_AUTOUPDATE
protected:
void closeEvent(QCloseEvent *e);
@@ -153,8 +151,6 @@ private:
QNetworkAccessManager _sendManager;
QNetworkReply *_checkReply, *_sendReply;
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
PreLaunchButton _updatingCheck, _updatingSkip;
enum UpdatingState {
UpdatingNone,
UpdatingCheck,
@@ -163,12 +159,17 @@ private:
UpdatingFail,
UpdatingReady
};
UpdatingState _updatingState;
QString _newVersionDownload;
struct UpdaterData {
UpdaterData(QWidget *buttonParent);
PreLaunchButton check, skip;
UpdatingState state;
QString newVersionDownload;
};
const std::unique_ptr<UpdaterData> _updaterData;
void setUpdatingState(UpdatingState state, bool force = false);
void setDownloadProgress(qint64 ready, qint64 total);
#endif // !TDESKTOP_DISABLE_AUTOUPDATE
rpl::lifetime _lifetime;

View File

@@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "platform/platform_specific.h"
#include "core/crash_reports.h"
#include "core/main_queue_processor.h"
#include "core/update_checker.h"
#include "application.h"
namespace Core {
@@ -61,15 +62,12 @@ int Launcher::exec() {
DEBUG_LOG(("Telegram finished, result: %1").arg(result));
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
if (cRestartingUpdate()) {
if (!UpdaterDisabled() && cRestartingUpdate()) {
DEBUG_LOG(("Application Info: executing updater to install update..."));
if (!launchUpdater(UpdaterLaunch::PerformUpdate)) {
psDeleteDir(cWorkingDir() + qsl("tupdates/temp"));
}
} else
#endif // !TDESKTOP_DISABLE_AUTOUPDATE
if (cRestarting()) {
} else if (cRestarting()) {
DEBUG_LOG(("Application Info: executing Telegram, because of restart..."));
launchUpdater(UpdaterLaunch::JustRelaunch);
}
@@ -178,19 +176,20 @@ void Launcher::processArguments() {
AllLeftValues,
};
auto parseMap = std::map<QByteArray, KeyFormat> {
{ "-testmode" , KeyFormat::NoValues },
{ "-debug" , KeyFormat::NoValues },
{ "-many" , KeyFormat::NoValues },
{ "-key" , KeyFormat::OneValue },
{ "-autostart" , KeyFormat::NoValues },
{ "-fixprevious", KeyFormat::NoValues },
{ "-cleanup" , KeyFormat::NoValues },
{ "-noupdate" , KeyFormat::NoValues },
{ "-tosettings" , KeyFormat::NoValues },
{ "-startintray", KeyFormat::NoValues },
{ "-sendpath" , KeyFormat::AllLeftValues },
{ "-workdir" , KeyFormat::OneValue },
{ "--" , KeyFormat::OneValue },
{ "-testmode" , KeyFormat::NoValues },
{ "-debug" , KeyFormat::NoValues },
{ "-many" , KeyFormat::NoValues },
{ "-key" , KeyFormat::OneValue },
{ "-autostart" , KeyFormat::NoValues },
{ "-fixprevious" , KeyFormat::NoValues },
{ "-cleanup" , KeyFormat::NoValues },
{ "-noupdate" , KeyFormat::NoValues },
{ "-externalupdater", KeyFormat::NoValues },
{ "-tosettings" , KeyFormat::NoValues },
{ "-startintray" , KeyFormat::NoValues },
{ "-sendpath" , KeyFormat::AllLeftValues },
{ "-workdir" , KeyFormat::OneValue },
{ "--" , KeyFormat::OneValue },
};
auto parseResult = QMap<QByteArray, QStringList>();
auto parsingKey = QByteArray();
@@ -215,6 +214,9 @@ void Launcher::processArguments() {
}
}
if (parseResult.contains("-externalupdater")) {
SetUpdaterDisabledAtStartup();
}
gTestMode = parseResult.contains("-testmode");
Logs::SetDebugEnabled(parseResult.contains("-debug"));
gManyInstance = parseResult.contains("-many");

View File

@@ -32,9 +32,6 @@ extern "C" {
#endif // else of Q_OS_WIN
namespace Core {
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
namespace {
constexpr auto kUpdaterTimeout = 10 * TimeMs(1000);
@@ -42,6 +39,12 @@ constexpr auto kMaxResponseSize = 1024 * 1024;
constexpr auto kMaxUpdateSize = 256 * 1024 * 1024;
constexpr auto kChunkSize = 128 * 1024;
#ifdef TDESKTOP_DISABLE_AUTOUPDATE
bool UpdaterIsDisabled = true;
#else // TDESKTOP_DISABLE_AUTOUPDATE
bool UpdaterIsDisabled = false;
#endif // TDESKTOP_DISABLE_AUTOUPDATE
std::weak_ptr<Updater> UpdaterInstance;
using ErrorSignal = void(QNetworkReply::*)(QNetworkReply::NetworkError);
@@ -1560,6 +1563,16 @@ Fn<void(const RPCError &)> MtpLoader::failHandler() {
} // namespace
bool UpdaterDisabled() {
return UpdaterIsDisabled;
}
void SetUpdaterDisabledAtStartup() {
Expects(UpdaterInstance.lock() == nullptr);
UpdaterIsDisabled = true;
}
class Updater : public base::has_weak_ptr {
public:
Updater();
@@ -2099,36 +2112,32 @@ bool checkReadyUpdate() {
}
void UpdateApplication() {
cSetLastUpdateCheck(0);
Core::UpdateChecker().start();
if (const auto window = App::wnd()) {
auto settings = Box<Settings::Widget>();
const auto weak = make_weak(settings.data());
window->showSpecialLayer(std::move(settings), anim::type::normal);
if (weak) {
weak->scrollToUpdateRow();
if (UpdaterDisabled()) {
const auto url = [&] {
#ifdef OS_WIN_STORE
return "https://www.microsoft.com/en-us/store/p/telegram-desktop/9nztwsqntd0s";
#elif defined OS_MAC_STORE // OS_WIN_STORE
return "https://itunes.apple.com/ae/app/telegram-desktop/id946399090";
#else // OS_WIN_STORE || OS_MAC_STORE
return "https://desktop.telegram.org";
#endif // OS_WIN_STORE || OS_MAC_STORE
}();
UrlClickHandler::Open(url);
} else {
cSetLastUpdateCheck(0);
Core::UpdateChecker().start();
if (const auto window = App::wnd()) {
auto settings = Box<Settings::Widget>();
const auto weak = make_weak(settings.data());
window->showSpecialLayer(std::move(settings), anim::type::normal);
if (weak) {
weak->scrollToUpdateRow();
}
window->showFromTray();
}
window->showFromTray();
}
}
#else // !TDESKTOP_DISABLE_AUTOUPDATE
void UpdateApplication() {
const auto url = [&] {
#ifdef OS_WIN_STORE
return "https://www.microsoft.com/en-us/store/p/telegram-desktop/9nztwsqntd0s";
#elif defined OS_MAC_STORE // OS_WIN_STORE
return "https://itunes.apple.com/ae/app/telegram-desktop/id946399090";
#else // OS_WIN_STORE || OS_MAC_STORE
return "https://desktop.telegram.org";
#endif // OS_WIN_STORE || OS_MAC_STORE
}();
UrlClickHandler::doOpen(url);
}
#endif // !TDESKTOP_DISABLE_AUTOUPDATE
QString countBetaVersionSignature(uint64 version) { // duplicated in packer.cpp
if (cBetaPrivateKey().isEmpty()) {
LOG(("Error: Trying to count beta version signature without beta private key!"));

View File

@@ -13,7 +13,8 @@ class Instance;
namespace Core {
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
bool UpdaterDisabled();
void SetUpdaterDisabledAtStartup();
class Updater;
@@ -53,13 +54,6 @@ private:
};
bool checkReadyUpdate();
#else // TDESKTOP_DISABLE_AUTOUPDATE
class UpdateChecker {
};
#endif // TDESKTOP_DISABLE_AUTOUPDATE
void UpdateApplication();
QString countBetaVersionSignature(uint64 version);