From 6dada1294e502dd4aafd0bc46abec034772ac4d5 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 5 Feb 2015 14:49:50 +0000 Subject: [PATCH] dev-channel versions added --- Telegram/PrepareWin.bat | 34 +++++++++++++++++------- Telegram/Setup.iss | 2 +- Telegram/SourceFiles/_other/packer.cpp | 19 ++++++++++--- Telegram/SourceFiles/_other/prepare.cpp | 26 +++++++++++------- Telegram/SourceFiles/application.cpp | 5 +++- Telegram/SourceFiles/boxes/aboutbox.cpp | 2 +- Telegram/SourceFiles/config.h | 13 +++++++-- Telegram/SourceFiles/pspecific_wnd.cpp | 2 +- Telegram/Telegram.rc | Bin 5540 -> 5540 bytes 9 files changed, 75 insertions(+), 28 deletions(-) diff --git a/Telegram/PrepareWin.bat b/Telegram/PrepareWin.bat index 3c582c26b..12cd0abc8 100644 --- a/Telegram/PrepareWin.bat +++ b/Telegram/PrepareWin.bat @@ -1,11 +1,25 @@ @echo OFF -set "AppVersionStrSmall=0.7.10" -set "AppVersionStr=0.7.10" -set "AppVersionStrFull=0.7.10.0" +set "AppVersionStrSmall=0.7.11" +set "AppVersionStr=0.7.11" +set "AppVersionStrFull=0.7.11.0" +set "DevChannel=1" + +if %DevChannel% neq 0 goto preparedev + +set "DevPostfix=" +set "DevParam=" +goto devprepared + +:preparedev + +set "DevPostfix=.dev" +set "DevParam=-dev" + +:devprepared echo. -echo Preparing version %AppVersionStr%.. +echo Preparing version %AppVersionStr%%DevPostfix%.. echo. set "PATH=%PATH%;C:\Program Files\7-Zip;C:\Program Files (x86)\Inno Setup 5" @@ -17,23 +31,23 @@ if %errorlevel% neq 0 goto error1 call ..\..\..\TelegramPrivate\Sign.bat Updater.exe if %errorlevel% neq 0 goto error1 -iscc /dMyAppVersion=%AppVersionStrSmall% /dMyAppVersionZero=%AppVersionStr% /dMyAppFullVersion=%AppVersionStrFull% ..\..\Telegram\Setup.iss +iscc /dMyAppVersion=%AppVersionStrSmall% /dMyAppVersionZero=%AppVersionStr% /dMyAppFullVersion=%AppVersionStrFull% /dMyAppVersionForExe=%AppVersionStr%%DevPostfix% ..\..\Telegram\Setup.iss if %errorlevel% neq 0 goto error1 -call ..\..\..\TelegramPrivate\Sign.bat tsetup.%AppVersionStr%.exe +call ..\..\..\TelegramPrivate\Sign.bat tsetup.%AppVersionStr%%DevPostfix%.exe if %errorlevel% neq 0 goto error1 -call Prepare.exe -path Telegram.exe -path Updater.exe +call Prepare.exe -path Telegram.exe -path Updater.exe %DevParam% if %errorlevel% neq 0 goto error1 -cd deploy\%AppVersionStr% +cd deploy\%AppVersionStr%%DevPostfix% mkdir Telegram move Telegram.exe Telegram\ -7z a -mx9 tportable.%AppVersionStr%.zip Telegram\ +7z a -mx9 tportable.%AppVersionStr%%DevPostfix%.zip Telegram\ if %errorlevel% neq 0 goto error2 echo . -echo Version %AppVersionStr% is ready for deploy! +echo Version %AppVersionStr%%DevPostfix% is ready for deploy! echo . cd ..\..\..\..\Telegram diff --git a/Telegram/Setup.iss b/Telegram/Setup.iss index 846d1d9f7..041c43c47 100644 --- a/Telegram/Setup.iss +++ b/Telegram/Setup.iss @@ -24,7 +24,7 @@ DefaultDirName={userappdata}\{#MyAppName} DefaultGroupName={#MyAppName} AllowNoIcons=yes OutputDir=.\..\Win32\Deploy -OutputBaseFilename=tsetup.{#MyAppVersionZero} +OutputBaseFilename=tsetup.{#MyAppVersionForExe} SetupIconFile=.\SourceFiles\art\icon256.ico UninstallDisplayIcon={app}\Telegram.exe Compression=lzma diff --git a/Telegram/SourceFiles/_other/packer.cpp b/Telegram/SourceFiles/_other/packer.cpp index 61480de98..deb0ed572 100644 --- a/Telegram/SourceFiles/_other/packer.cpp +++ b/Telegram/SourceFiles/_other/packer.cpp @@ -32,6 +32,8 @@ Q_IMPORT_PLUGIN(QWbmpPlugin) Q_IMPORT_PLUGIN(QWebpPlugin) #endif +bool DevChannel = false; + const char *publicKey = "\ -----BEGIN RSA PUBLIC KEY-----\n\ MIGJAoGBAMA4ViQrjkPZ9xj0lrer3r23JvxOnrtE8nI69XLGSr+sRERz9YnUptnU\n\ @@ -40,8 +42,17 @@ BZpkIfKaRcl6XzNJiN28cVwO1Ui5JSa814UAiDHzWUqCaXUiUEQ6NmNTneiGx2sQ\n\ -----END RSA PUBLIC KEY-----\ "; +const char *publicDevKey = "\ +-----BEGIN RSA PUBLIC KEY-----\n\ +MIGJAoGBALWu9GGs0HED7KG7BM73CFZ6o0xufKBRQsdnq3lwA8nFQEvmdu+g/I1j\n\ +0LQ+0IQO7GW4jAgzF/4+soPDb6uHQeNFrlVx1JS9DZGhhjZ5rf65yg11nTCIHZCG\n\ +w/CVnbwQOw0g5GBwwFV3r0uTTvy44xx8XXxk+Qknu4eBCsmrAFNnAgMBAAE=\n\ +-----END RSA PUBLIC KEY-----\ +"; + extern const char *privateKey; -#include "../../../../TelegramPrivate/packer_private.h" // RSA PRIVATE KEY for update signing +extern const char *privateDevKey; +#include "../../../../TelegramPrivate/packer_private.h" // RSA PRIVATE KEYS for update signing // sha1 hash typedef unsigned char uchar; @@ -151,6 +162,8 @@ int main(int argc, char *argv[]) if (remove.isEmpty()) remove = info.canonicalPath() + "/"; } else if (string("-version") == argv[i] && i + 1 < argc) { version = QString(argv[i + 1]).toInt(); + } else if (string("-dev") == argv[i]) { + DevChannel = true; } } @@ -388,7 +401,7 @@ int main(int argc, char *argv[]) uint32 siglen = 0; cout << "Signing..\n"; - RSA *prKey = PEM_read_bio_RSAPrivateKey(BIO_new_mem_buf(const_cast(privateKey), -1), 0, 0, 0); + RSA *prKey = PEM_read_bio_RSAPrivateKey(BIO_new_mem_buf(const_cast(DevChannel ? privateDevKey : privateKey), -1), 0, 0, 0); if (!prKey) { cout << "Could not read RSA private key!\n"; return -1; @@ -411,7 +424,7 @@ int main(int argc, char *argv[]) } cout << "Checking signature..\n"; - RSA *pbKey = PEM_read_bio_RSAPublicKey(BIO_new_mem_buf(const_cast(publicKey), -1), 0, 0, 0); + RSA *pbKey = PEM_read_bio_RSAPublicKey(BIO_new_mem_buf(const_cast(DevChannel ? publicDevKey : publicKey), -1), 0, 0, 0); if (!pbKey) { cout << "Could not read RSA public key!\n"; return -1; diff --git a/Telegram/SourceFiles/_other/prepare.cpp b/Telegram/SourceFiles/_other/prepare.cpp index df694278f..4c05acb57 100644 --- a/Telegram/SourceFiles/_other/prepare.cpp +++ b/Telegram/SourceFiles/_other/prepare.cpp @@ -17,6 +17,8 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org */ #include "prepare.h" +bool DevChannel = false; + int prepare(QFileInfo f, QStringList paths) { if (paths.isEmpty()) { cout << "No -path args were passed :(\n"; @@ -28,7 +30,7 @@ int prepare(QFileInfo f, QStringList paths) { QFileInfo last; QFileInfoList l = f.absoluteDir().entryInfoList(QDir::Files); for (QFileInfoList::iterator i = l.begin(), e = l.end(); i != e; ++i) { - QRegularExpressionMatch m = QRegularExpression("/tsetup.((\\d+).(\\d+).(\\d+)).exe$").match(i->absoluteFilePath()); + QRegularExpressionMatch m = QRegularExpression("/tsetup\\.((\\d+)\\.(\\d+)\\.(\\d+))(?:\\.dev)?\\.exe$").match(i->absoluteFilePath()); if (!m.hasMatch()) continue; int version = m.captured(2).toInt() * 1000000 + m.captured(3).toInt() * 1000 + m.captured(4).toInt(); @@ -40,15 +42,18 @@ int prepare(QFileInfo f, QStringList paths) { } if (!lastVersion) { - cout << "No tsetup.X.Y.Z.exe found :(\n"; + cout << "No tsetup.X.Y.Z.exe or tsetup.X.Y.Z.dev.exe found :(\n"; return -1; } - cout << "Last version: " << lastVersionStr.toUtf8().constData() << " (" << lastVersion << "), executing packer..\n"; + cout << "Last version: " << (lastVersionStr + (DevChannel ? ".dev" : "")).toUtf8().constData() << " (" << lastVersion << "), executing packer..\n"; - QDir dir("deploy/" + lastVersionStr); + QDir dir("deploy/" + lastVersionStr + (DevChannel ? ".dev" : "")); if (dir.exists()) { - cout << "Version " << lastVersionStr.toUtf8().constData() << " already exists in /deploy..\n"; + cout << "Version " << (lastVersionStr + (DevChannel ? ".dev" : "")).toUtf8().constData() << " already exists in /deploy..\n"; + return -1; + } else if (QDir("deploy/" + lastVersionStr + (DevChannel ? "" : ".dev")).exists()) { + cout << "Version " << (lastVersionStr + (DevChannel ? "" : ".dev")).toUtf8().constData() << " already exists in /deploy..\n"; return -1; } @@ -56,6 +61,7 @@ int prepare(QFileInfo f, QStringList paths) { for (QStringList::iterator i = paths.begin(), e = paths.end(); i != e; ++i) { packer += " -path " + *i; } + if (DevChannel) packer += " -dev"; int res = system(packer.toUtf8().constData()); @@ -65,11 +71,11 @@ int prepare(QFileInfo f, QStringList paths) { paths.push_back("Telegram.pdb"); paths.push_back("Updater.pdb"); - paths.push_back("tsetup." + lastVersionStr + ".exe"); + paths.push_back("tsetup." + lastVersionStr + (DevChannel ? ".dev" : "") + ".exe"); paths.push_back(QString("tupdate%1").arg(lastVersion)); for (QStringList::iterator i = paths.begin(), e = paths.end(); i != e; ++i) { - if (!QFile::copy(*i, "deploy/" + lastVersionStr + "/" + *i)) { - cout << "Could not copy " << i->toUtf8().constData() << " to deploy/" << lastVersionStr.toUtf8().constData() << "\n"; + if (!QFile::copy(*i, "deploy/" + lastVersionStr + (DevChannel ? ".dev" : "") + "/" + *i)) { + cout << "Could not copy " << i->toUtf8().constData() << " to deploy/" << (lastVersionStr + (DevChannel ? ".dev" : "")).toUtf8().constData() << "\n"; return -1; } cout << "Copied " << i->toUtf8().constData() << "..\n"; @@ -78,7 +84,7 @@ int prepare(QFileInfo f, QStringList paths) { QFile::remove(*i); } - cout << "Update created in deploy/" << lastVersionStr.toUtf8().constData() << "\n"; + cout << "Update created in deploy/" << (lastVersionStr + (DevChannel ? ".dev" : "")).toUtf8().constData() << "\n"; return 0; } @@ -91,6 +97,8 @@ int main(int argc, char *argv[]) for (int i = 1; i < argc; ++i) { if (string(argv[i]) == "-path" && i + 1 < argc) { paths.push_back(QString(argv[i + 1])); + } else if (string(argv[i]) == "-dev") { + DevChannel = true; } } int res = prepare(f, paths); diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index 7f66e763c..34951a0cb 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -527,7 +527,10 @@ void Application::startUpdateCheck(bool forceWait) { if (cManyInstance() && !cDebug()) return; // only main instance is updating if (sendRequest) { - QNetworkRequest checkVersion(cUpdateURL()); + QUrl url(cUpdateURL()); + if (DevChannel) url.setQuery("dev=1"); + QString u = url.toString(); + QNetworkRequest checkVersion(url); if (updateReply) updateReply->deleteLater(); App::setProxySettings(updateManager); diff --git a/Telegram/SourceFiles/boxes/aboutbox.cpp b/Telegram/SourceFiles/boxes/aboutbox.cpp index 3c2eaf3bd..6d7a399a0 100644 --- a/Telegram/SourceFiles/boxes/aboutbox.cpp +++ b/Telegram/SourceFiles/boxes/aboutbox.cpp @@ -24,7 +24,7 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org AboutBox::AboutBox() : _done(this, lang(lng_about_done), st::aboutCloseButton), -_version(this, qsl("[a href=\"https://desktop.telegram.org/#changelog\"]") + textClean(lng_about_version(lt_version, QString::fromWCharArray(AppVersionStr))) + qsl("[/a]"), st::aboutVersion, st::defaultTextStyle), +_version(this, qsl("[a href=\"https://desktop.telegram.org/#changelog\"]") + textClean(lng_about_version(lt_version, QString::fromWCharArray(AppVersionStr) + (DevChannel ? " dev" : ""))) + qsl("[/a]"), st::aboutVersion, st::defaultTextStyle), _text(this, lang(lng_about_text), st::aboutLabel, st::aboutTextStyle), _hiding(false), a_opacity(0, 1) { diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h index b67af9f33..efad94986 100644 --- a/Telegram/SourceFiles/config.h +++ b/Telegram/SourceFiles/config.h @@ -17,8 +17,9 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org */ #pragma once -static const int32 AppVersion = 7010; -static const wchar_t *AppVersionStr = L"0.7.10"; +static const int32 AppVersion = 7011; +static const wchar_t *AppVersionStr = L"0.7.11"; +static const bool DevChannel = true; static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)"; static const wchar_t *AppName = L"Telegram Desktop"; @@ -189,6 +190,14 @@ BZpkIfKaRcl6XzNJiN28cVwO1Ui5JSa814UAiDHzWUqCaXUiUEQ6NmNTneiGx2sQ\n\ -----END RSA PUBLIC KEY-----\ "; +static const char *UpdatesPublicDevKey = "\ +-----BEGIN RSA PUBLIC KEY-----\n\ +MIGJAoGBALWu9GGs0HED7KG7BM73CFZ6o0xufKBRQsdnq3lwA8nFQEvmdu+g/I1j\n\ +0LQ+0IQO7GW4jAgzF/4+soPDb6uHQeNFrlVx1JS9DZGhhjZ5rf65yg11nTCIHZCG\n\ +w/CVnbwQOw0g5GBwwFV3r0uTTvy44xx8XXxk+Qknu4eBCsmrAFNnAgMBAAE=\n\ +-----END RSA PUBLIC KEY-----\ +"; + #ifdef CUSTOM_API_ID #include "../../../TelegramPrivate/custom_api_id.h" // Custom API id and API hash #else diff --git a/Telegram/SourceFiles/pspecific_wnd.cpp b/Telegram/SourceFiles/pspecific_wnd.cpp index 4c9be6d7c..ba86a81ee 100644 --- a/Telegram/SourceFiles/pspecific_wnd.cpp +++ b/Telegram/SourceFiles/pspecific_wnd.cpp @@ -1622,7 +1622,7 @@ void PsUpdateDownloader::unpackUpdate() { return fatalFail(); } - RSA *pbKey = PEM_read_bio_RSAPublicKey(BIO_new_mem_buf(const_cast(UpdatesPublicKey), -1), 0, 0, 0); + RSA *pbKey = PEM_read_bio_RSAPublicKey(BIO_new_mem_buf(const_cast(DevChannel ? UpdatesPublicDevKey : UpdatesPublicKey), -1), 0, 0, 0); if (!pbKey) { LOG(("Update Error: cant read public rsa key!")); return fatalFail(); diff --git a/Telegram/Telegram.rc b/Telegram/Telegram.rc index 3a0df26682e90852eb90e661f1aed0063c05631f..7317f5e9ea49c7371673e5b68d6fd56dc0c2e18c 100644 GIT binary patch delta 53 zcmZ3Yy+nIM5ig_R)3