From dc6a3ba907eebef904b8b4cb8c17fba2b6b04524 Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Sun, 14 Aug 2016 22:56:26 +0300
Subject: [PATCH] Alpha version 0.10.2: first GYP/Ninja build, some bug and
 crash fixes.

Counting round radius dynamically to work fine with all font sizes.
Added GYP and Ninja to Third-party section. Fix of build script.
---
 README.md                                     |  4 +-
 Telegram/Resources/basic.style                |  2 -
 Telegram/Resources/winrc/Telegram.rc          |  8 +--
 Telegram/Resources/winrc/Updater.rc           |  8 +--
 Telegram/SourceFiles/app.cpp                  | 28 ++++++----
 Telegram/SourceFiles/core/version.h           |  6 +--
 Telegram/SourceFiles/history.cpp              |  6 +--
 Telegram/SourceFiles/history/history.style    |  4 --
 .../history/history_service_layout.cpp        | 52 ++++++++++++++-----
 Telegram/Telegram.xcodeproj/project.pbxproj   |  4 +-
 Telegram/build/build.bat                      | 39 ++++++++++----
 Telegram/build/version                        |  8 +--
 12 files changed, 109 insertions(+), 60 deletions(-)

diff --git a/README.md b/README.md
index 78cc4d452..e3f7f6469 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ The source code is published under GPLv3 with OpenSSL exception, the license is
 * Ubuntu 12.04 - Ubuntu 16.04
 * Fedora 22
 
-## Third-party libraries
+## Third-party
 
 * Qt 5.3.2 and 5.6.0, slightly patched ([LGPL](http://doc.qt.io/qt-5/lgpl.html))
 * OpenSSL 1.0.1g ([OpenSSL License](https://www.openssl.org/source/license.html))
@@ -24,6 +24,8 @@ The source code is published under GPLv3 with OpenSSL exception, the license is
 * liblzma ([public domain](http://tukaani.org/xz/))
 * Google Breakpad ([License](https://chromium.googlesource.com/breakpad/breakpad/+/master/LICENSE))
 * Google Crashpad ([Apache License 2.0](https://chromium.googlesource.com/crashpad/crashpad/+/master/LICENSE))
+* GYP ([BSD license](https://github.com/bnoordhuis/gyp/blob/master/LICENSE))
+* Ninja ([Apache License 2.0](https://github.com/ninja-build/ninja/blob/master/COPYING))
 * OpenAL Soft ([LGPL](http://kcat.strangesoft.net/openal.html))
 * Opus codec ([BSD license](http://www.opus-codec.org/license/))
 * FFmpeg ([LGPL](https://www.ffmpeg.org/legal.html))
diff --git a/Telegram/Resources/basic.style b/Telegram/Resources/basic.style
index 049fffee2..570cc6603 100644
--- a/Telegram/Resources/basic.style
+++ b/Telegram/Resources/basic.style
@@ -665,7 +665,6 @@ scrollDef: flatScroll {
 	hiding: 1000;
 }
 
-msgRadius: 16px;
 dateRadius: 10px;
 buttonRadius: 3px;
 
@@ -1049,7 +1048,6 @@ msgServiceNameFont: semiboldFont;
 msgServicePhotoWidth: 100px;
 msgDateFont: font(13px);
 msgMinWidth: 190px;
-msgMinTextHeight: 18px;
 msgPhotoSize: 33px;
 msgPhotoSkip: 40px;
 msgPadding: margins(13px, 7px, 13px, 8px);
diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc
index 5e643374e..b0e73a599 100644
--- a/Telegram/Resources/winrc/Telegram.rc
+++ b/Telegram/Resources/winrc/Telegram.rc
@@ -34,8 +34,8 @@ IDI_ICON1               ICON                    "..\\art\\icon256.ico"
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 0,10,1,0
- PRODUCTVERSION 0,10,1,0
+ FILEVERSION 0,10,2,0
+ PRODUCTVERSION 0,10,2,0
  FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -51,10 +51,10 @@ BEGIN
         BLOCK "040904b0"
         BEGIN
             VALUE "CompanyName", "Telegram Messenger LLP"
-            VALUE "FileVersion", "0.10.1.0"
+            VALUE "FileVersion", "0.10.2.0"
             VALUE "LegalCopyright", "Copyright (C) 2014-2016"
             VALUE "ProductName", "Telegram Desktop"
-            VALUE "ProductVersion", "0.10.1.0"
+            VALUE "ProductVersion", "0.10.2.0"
         END
     END
     BLOCK "VarFileInfo"
diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc
index ce3e1b6a4..4c73c83cc 100644
--- a/Telegram/Resources/winrc/Updater.rc
+++ b/Telegram/Resources/winrc/Updater.rc
@@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 0,10,1,0
- PRODUCTVERSION 0,10,1,0
+ FILEVERSION 0,10,2,0
+ PRODUCTVERSION 0,10,2,0
  FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -43,10 +43,10 @@ BEGIN
         BEGIN
             VALUE "CompanyName", "Telegram Messenger LLP"
             VALUE "FileDescription", "Telegram Updater"
-            VALUE "FileVersion", "0.10.1.0"
+            VALUE "FileVersion", "0.10.2.0"
             VALUE "LegalCopyright", "Copyright (C) 2014-2016"
             VALUE "ProductName", "Telegram Desktop"
-            VALUE "ProductVersion", "0.10.1.0"
+            VALUE "ProductVersion", "0.10.2.0"
         END
     END
     BLOCK "VarFileInfo"
diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp
index 54cf58492..4d3dbf8f4 100644
--- a/Telegram/SourceFiles/app.cpp
+++ b/Telegram/SourceFiles/app.cpp
@@ -2127,6 +2127,14 @@ namespace {
 		}
 	}
 
+	int msgRadius() {
+		static int MsgRadius = ([]() {
+			auto minMsgHeight = (st::msgPadding.top() + st::msgFont->height + st::msgPadding.bottom());
+			return minMsgHeight / 2;
+		})();
+		return MsgRadius;
+	}
+
 	void initMedia() {
 		audioInit();
 
@@ -2150,7 +2158,7 @@ namespace {
 		}
 
 		QImage mask[4];
-		prepareCorners(LargeMaskCorners, st::msgRadius, st::white, nullptr, mask);
+		prepareCorners(LargeMaskCorners, msgRadius(), st::white, nullptr, mask);
 		for (int i = 0; i < 4; ++i) {
 			::cornersMaskLarge[i] = new QImage(mask[i].convertToFormat(QImage::Format_ARGB32_Premultiplied));
 			::cornersMaskLarge[i]->setDevicePixelRatio(cRetinaFactor());
@@ -2164,12 +2172,12 @@ namespace {
 		prepareCorners(StickerCorners, st::dateRadius, st::msgServiceBg);
 		prepareCorners(StickerSelectedCorners, st::dateRadius, st::msgServiceSelectBg);
 		prepareCorners(SelectedOverlaySmallCorners, st::buttonRadius, st::msgSelectOverlay);
-		prepareCorners(SelectedOverlayLargeCorners, st::msgRadius, st::msgSelectOverlay);
+		prepareCorners(SelectedOverlayLargeCorners, msgRadius(), st::msgSelectOverlay);
 		prepareCorners(DateCorners, st::dateRadius, st::msgDateImgBg);
 		prepareCorners(DateSelectedCorners, st::dateRadius, st::msgDateImgBgSelected);
-		prepareCorners(InShadowCorners, st::msgRadius, st::msgInShadow);
-		prepareCorners(InSelectedShadowCorners, st::msgRadius, st::msgInShadowSelected);
-		prepareCorners(ForwardCorners, st::msgRadius, st::forwardBg);
+		prepareCorners(InShadowCorners, msgRadius(), st::msgInShadow);
+		prepareCorners(InSelectedShadowCorners, msgRadius(), st::msgInShadowSelected);
+		prepareCorners(ForwardCorners, msgRadius(), st::forwardBg);
 		prepareCorners(MediaviewSaveCorners, st::mediaviewControllerRadius, st::medviewSaveMsg);
 		prepareCorners(EmojiHoverCorners, st::buttonRadius, st::emojiPanHover);
 		prepareCorners(StickerHoverCorners, st::buttonRadius, st::emojiPanHover);
@@ -2183,10 +2191,10 @@ namespace {
 		prepareCorners(DocRedCorners, st::buttonRadius, st::msgFileRedColor);
 		prepareCorners(DocYellowCorners, st::buttonRadius, st::msgFileYellowColor);
 
-		prepareCorners(MessageInCorners, st::msgRadius, st::msgInBg, &st::msgInShadow);
-		prepareCorners(MessageInSelectedCorners, st::msgRadius, st::msgInBgSelected, &st::msgInShadowSelected);
-		prepareCorners(MessageOutCorners, st::msgRadius, st::msgOutBg, &st::msgOutShadow);
-		prepareCorners(MessageOutSelectedCorners, st::msgRadius, st::msgOutBgSelected, &st::msgOutShadowSelected);
+		prepareCorners(MessageInCorners, msgRadius(), st::msgInBg, &st::msgInShadow);
+		prepareCorners(MessageInSelectedCorners, msgRadius(), st::msgInBgSelected, &st::msgInShadowSelected);
+		prepareCorners(MessageOutCorners, msgRadius(), st::msgOutBg, &st::msgOutShadow);
+		prepareCorners(MessageOutSelectedCorners, msgRadius(), st::msgOutBgSelected, &st::msgOutShadowSelected);
 	}
 
 	void clearHistories() {
@@ -2653,7 +2661,7 @@ namespace {
 			QImage images[4];
 			switch (radius) {
 			case ImageRoundRadius::Small: prepareCorners(SmallMaskCorners, st::buttonRadius, bg, nullptr, images); break;
-			case ImageRoundRadius::Large: prepareCorners(LargeMaskCorners, st::msgRadius, bg, nullptr, images); break;
+			case ImageRoundRadius::Large: prepareCorners(LargeMaskCorners, msgRadius(), bg, nullptr, images); break;
 			default: p.fillRect(x, y, w, h, bg); return;
 			}
 
diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h
index 5eb7aa526..a64039b9b 100644
--- a/Telegram/SourceFiles/core/version.h
+++ b/Telegram/SourceFiles/core/version.h
@@ -24,7 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
 
 #define BETA_VERSION_MACRO (0ULL)
 
-constexpr int AppVersion = 10001;
-constexpr str_const AppVersionStr = "0.10.1";
-constexpr bool AppAlphaVersion = false;
+constexpr int AppVersion = 10002;
+constexpr str_const AppVersionStr = "0.10.2";
+constexpr bool AppAlphaVersion = true;
 constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO;
diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp
index 095603bec..fe109c655 100644
--- a/Telegram/SourceFiles/history.cpp
+++ b/Telegram/SourceFiles/history.cpp
@@ -6949,7 +6949,7 @@ void HistoryMessage::initDimensions() {
 		if (_text.isEmpty()) {
 			_minh = 0;
 		} else {
-			_minh = st::msgPadding.top() + qMax(_text.minHeight(), st::msgMinTextHeight) + st::msgPadding.bottom();
+			_minh = st::msgPadding.top() + _text.minHeight() + st::msgPadding.bottom();
 		}
 		if (_media && _media->isDisplayed()) {
 			int32 maxw = _media->maxWidth();
@@ -7609,7 +7609,7 @@ int HistoryMessage::performResizeGetHeight(int width) {
 				if (textWidth != _textWidth) {
 					textstyleSet(&((out() && !isPost()) ? st::outTextStyle : st::inTextStyle));
 					_textWidth = textWidth;
-					_textHeight = qMax(_text.countHeight(textWidth), st::msgMinTextHeight);
+					_textHeight = _text.countHeight(textWidth);
 					textstyleRestore();
 				}
 				_height = st::msgPadding.top() + _textHeight + st::msgPadding.bottom();
@@ -8217,7 +8217,7 @@ int32 HistoryService::resizeGetHeight_(int32 width) {
 		width -= st::msgServiceMargin.left() + st::msgServiceMargin.left(); // two small margins
 		if (width < st::msgServicePadding.left() + st::msgServicePadding.right() + 1) width = st::msgServicePadding.left() + st::msgServicePadding.right() + 1;
 
-		int32 nwidth = qMax(width - st::msgPadding.left() - st::msgPadding.right(), 0);
+		int32 nwidth = qMax(width - st::msgServicePadding.left() - st::msgServicePadding.right(), 0);
 		if (nwidth != _textWidth) {
 			_textWidth = nwidth;
 			textstyleSet(&st::serviceTextStyle);
diff --git a/Telegram/SourceFiles/history/history.style b/Telegram/SourceFiles/history/history.style
index efcc20934..7fc5fe6d0 100644
--- a/Telegram/SourceFiles/history/history.style
+++ b/Telegram/SourceFiles/history/history.style
@@ -45,7 +45,3 @@ membersInnerDropdown: InnerDropdown(defaultInnerDropdown) {
 	scrollMargin: margins(0px, 5px, 0px, 5px);
 	scrollPadding: margins(0px, 3px, 8px, 3px);
 }
-
-historyServiceMsgRadius: 12px;
-historyServiceMsgInvertedRadius: 6px;
-historyServiceMsgInvertedShrink: 4px;
diff --git a/Telegram/SourceFiles/history/history_service_layout.cpp b/Telegram/SourceFiles/history/history_service_layout.cpp
index 4771f21ff..fa0db9f69 100644
--- a/Telegram/SourceFiles/history/history_service_layout.cpp
+++ b/Telegram/SourceFiles/history/history_service_layout.cpp
@@ -55,20 +55,43 @@ public:
 };
 Data::GlobalStructurePointer<ServiceMessageStyleData> serviceMessageStyle;
 
+int historyServiceMsgRadius() {
+	static int HistoryServiceMsgRadius = ([]() {
+		auto minMsgHeight = (st::msgServiceFont->height + st::msgServicePadding.top() + st::msgServicePadding.bottom());
+		return minMsgHeight / 2;
+	})();
+	return HistoryServiceMsgRadius;
+}
+
+int historyServiceMsgInvertedRadius() {
+	static int HistoryServiceMsgInvertedRadius = ([]() {
+		auto minRowHeight = st::msgServiceFont->height;
+		return minRowHeight - historyServiceMsgRadius();
+	})();
+	return HistoryServiceMsgInvertedRadius;
+}
+
+int historyServiceMsgInvertedShrink() {
+	static int HistoryServiceMsgInvertedShrink = ([]() {
+		return (historyServiceMsgInvertedRadius() * 2) / 3;
+	})();
+	return HistoryServiceMsgInvertedShrink;
+}
+
 void createCircleMasks() {
 	serviceMessageStyle.createIfNull();
 	if (!serviceMessageStyle->circle[NormalMask].isNull()) return;
 
-	int size = st::historyServiceMsgRadius * 2;
+	int size = historyServiceMsgRadius() * 2;
 	serviceMessageStyle->circle[NormalMask] = style::createCircleMask(size);
-	int sizeInverted = st::historyServiceMsgInvertedRadius * 2;
+	int sizeInverted = historyServiceMsgInvertedRadius() * 2;
 	serviceMessageStyle->circle[InvertedMask] = style::createInvertedCircleMask(sizeInverted);
 }
 
 QPixmap circleCorner(int corner) {
 	if (serviceMessageStyle->corners[corner].isNull()) {
 		int maskType = corner / MaskMultiplier;
-		int radius = (maskType == NormalMask ? st::historyServiceMsgRadius : st::historyServiceMsgInvertedRadius);
+		int radius = (maskType == NormalMask ? historyServiceMsgRadius() : historyServiceMsgInvertedRadius());
 		int size = radius * cIntRetinaFactor();
 
 		int xoffset = 0, yoffset = 0;
@@ -118,10 +141,10 @@ int paintBubbleSide(Painter &p, int x, int y, int width, SideStyle style, Corner
 	return 0;
 }
 
-void paintBubblePart(Painter &p, int x, int y, int width, int height, SideStyle topStyle, SideStyle bottomStyle) {
-	if (topStyle == SideStyle::Inverted || bottomStyle == SideStyle::Inverted) {
-		width -= st::historyServiceMsgInvertedShrink * 2;
-		x += st::historyServiceMsgInvertedShrink;
+void paintBubblePart(Painter &p, int x, int y, int width, int height, SideStyle topStyle, SideStyle bottomStyle, bool forceShrink = false) {
+	if (topStyle == SideStyle::Inverted || bottomStyle == SideStyle::Inverted || forceShrink) {
+		width -= historyServiceMsgInvertedShrink() * 2;
+		x += historyServiceMsgInvertedShrink();
 	}
 
 	if (int skip = paintBubbleSide(p, x, y, width, topStyle, CornerTop)) {
@@ -130,9 +153,9 @@ void paintBubblePart(Painter &p, int x, int y, int width, int height, SideStyle
 	}
 	int bottomSize = 0;
 	if (bottomStyle == SideStyle::Rounded) {
-		bottomSize = st::historyServiceMsgRadius;
+		bottomSize = historyServiceMsgRadius();
 	} else if (bottomStyle == SideStyle::Inverted) {
-		bottomSize = st::historyServiceMsgInvertedRadius;
+		bottomSize = historyServiceMsgInvertedRadius();
 	}
 	if (int skip = paintBubbleSide(p, x, y + height - bottomSize, width, bottomStyle, CornerBottom)) {
 		height -= skip;
@@ -230,7 +253,8 @@ void ServiceMessagePainter::paintComplexBubble(Painter &p, int left, int width,
 
 	auto lineWidths = countLineWidths(text, textRect);
 
-	int y = st::msgServiceMargin.top();
+	int y = st::msgServiceMargin.top(), previousRichWidth = 0;
+	bool previousShrink = false, forceShrink = false;
 	SideStyle topStyle = SideStyle::Rounded, bottomStyle;
 	for (int i = 0, count = lineWidths.size(); i < count; ++i) {
 		auto lineWidth = lineWidths.at(i);
@@ -259,9 +283,13 @@ void ServiceMessagePainter::paintComplexBubble(Painter &p, int left, int width,
 		} else if (bottomStyle == SideStyle::Inverted) {
 			richHeight -= st::msgServicePadding.top();
 		}
-		paintBubblePart(p, left + ((width - richWidth) / 2), y, richWidth, richHeight, topStyle, bottomStyle);
+		forceShrink = previousShrink && (richWidth == previousRichWidth);
+		paintBubblePart(p, left + ((width - richWidth) / 2), y, richWidth, richHeight, topStyle, bottomStyle, forceShrink);
 		y += richHeight;
 
+		previousShrink = forceShrink || (topStyle == SideStyle::Inverted) || (bottomStyle == SideStyle::Inverted);
+		previousRichWidth = richWidth;
+
 		if (bottomStyle == SideStyle::Inverted) {
 			topStyle = SideStyle::Rounded;
 		} else if (bottomStyle == SideStyle::Rounded) {
@@ -278,7 +306,7 @@ QVector<int> ServiceMessagePainter::countLineWidths(const Text &text, const QRec
 	lineWidths.reserve(linesCount);
 	text.countLineWidths(textRect.width(), &lineWidths);
 
-	int minDelta = 2 * (st::historyServiceMsgRadius + st::historyServiceMsgInvertedRadius - st::historyServiceMsgInvertedShrink);
+	int minDelta = 2 * (historyServiceMsgRadius() + historyServiceMsgInvertedRadius() - historyServiceMsgInvertedShrink());
 	for (int i = 0, count = lineWidths.size(); i < count; ++i) {
 		int width = qMax(lineWidths.at(i), 0);
 		if (i > 0) {
diff --git a/Telegram/Telegram.xcodeproj/project.pbxproj b/Telegram/Telegram.xcodeproj/project.pbxproj
index c153dc14f..2b81157ab 100644
--- a/Telegram/Telegram.xcodeproj/project.pbxproj
+++ b/Telegram/Telegram.xcodeproj/project.pbxproj
@@ -2559,7 +2559,7 @@
 				SDKROOT = macosx;
 				SYMROOT = ./../Mac;
 				TDESKTOP_MAJOR_VERSION = 0.10;
-				TDESKTOP_VERSION = 0.10.1;
+				TDESKTOP_VERSION = 0.10.2;
 			};
 			name = Release;
 		};
@@ -2700,7 +2700,7 @@
 				SDKROOT = macosx;
 				SYMROOT = ./../Mac;
 				TDESKTOP_MAJOR_VERSION = 0.10;
-				TDESKTOP_VERSION = 0.10.1;
+				TDESKTOP_VERSION = 0.10.2;
 			};
 			name = Debug;
 		};
diff --git a/Telegram/build/build.bat b/Telegram/build/build.bat
index 28289def6..7e7fd05da 100644
--- a/Telegram/build/build.bat
+++ b/Telegram/build/build.bat
@@ -92,7 +92,7 @@ echo Version %AppVersionStrFull% build successfull. Preparing..
 echo .
 
 echo Dumping debug symbols..
-call "%SolutionPath%\..\Libraries\breakpad\src\tools\windows\dump_syms\Release\dump_syms.exe" "%ReleasePath%\%BinaryName%.pdb" > "%ReleasePath%\%BinaryName%.sym"
+call "%SolutionPath%\..\Libraries\breakpad\src\tools\windows\dump_syms\Release\dump_syms.exe" "%ReleasePath%\%BinaryName%.exe.pdb" > "%ReleasePath%\%BinaryName%.exe.sym"
 echo Done!
 
 set "PATH=%PATH%;C:\Program Files\7-Zip;C:\Program Files (x86)\Inno Setup 5"
@@ -133,29 +133,31 @@ if %BetaVersion% neq 0 (
 
 for /f ^"usebackq^ eol^=^
 
-^ delims^=^" %%a in (%ReleasePath%\%BinaryName%.sym) do (
+^ delims^=^" %%a in (%ReleasePath%\%BinaryName%.exe.sym) do (
   set "SymbolsHashLine=%%a"
   goto symbolslinedone
 )
 :symbolslinedone
 FOR /F "tokens=1,2,3,4* delims= " %%i in ("%SymbolsHashLine%") do set "SymbolsHash=%%l"
 
-echo Copying %BinaryName%.sym to %DropboxSymbolsPath%\%BinaryName%.pdb\%SymbolsHash%
-if not exist %DropboxSymbolsPath%\%BinaryName%.pdb mkdir %DropboxSymbolsPath%\%BinaryName%.pdb
-if not exist %DropboxSymbolsPath%\%BinaryName%.pdb\%SymbolsHash% mkdir %DropboxSymbolsPath%\%BinaryName%.pdb\%SymbolsHash%
-xcopy "%ReleasePath%\%BinaryName%.sym" %DropboxSymbolsPath%\%BinaryName%.pdb\%SymbolsHash%\
+echo Copying %BinaryName%.exe.sym to %DropboxSymbolsPath%\%BinaryName%.exe.pdb\%SymbolsHash%
+if not exist %DropboxSymbolsPath%\%BinaryName%.exe.pdb mkdir %DropboxSymbolsPath%\%BinaryName%.exe.pdb
+if not exist %DropboxSymbolsPath%\%BinaryName%.exe.pdb\%SymbolsHash% mkdir %DropboxSymbolsPath%\%BinaryName%.exe.pdb\%SymbolsHash%
+xcopy "%ReleasePath%\%BinaryName%.exe.sym" %DropboxSymbolsPath%\%BinaryName%.exe.pdb\%SymbolsHash%\
 echo Done!
 
 if not exist "%ReleasePath%\deploy" mkdir "%ReleasePath%\deploy"
 if not exist "%ReleasePath%\deploy\%AppVersionStrMajor%" mkdir "%ReleasePath%\deploy\%AppVersionStrMajor%"
 mkdir "%DeployPath%"
-mkdir "%DeployPath%\Telegram"
+mkdir "%DeployPath%\%BinaryName%"
 if %errorlevel% neq 0 goto error
 
-move "%ReleasePath%\Telegram.exe" "%DeployPath%\Telegram\"
+move "%ReleasePath%\%BinaryName%.exe" "%DeployPath%\%BinaryName%\"
 move "%ReleasePath%\Updater.exe" "%DeployPath%\"
-move "%ReleasePath%\Telegram.pdb" "%DeployPath%\"
-move "%ReleasePath%\Updater.pdb" "%DeployPath%\"
+xcopy "%ReleasePath%\%BinaryName%.pdb" "%DeployPath%\"
+xcopy "%ReleasePath%\Updater.pdb" "%DeployPath%\"
+move "%ReleasePath%\%BinaryName%.exe.pdb" "%DeployPath%\"
+move "%ReleasePath%\Updater.exe.pdb" "%DeployPath%\"
 if %BetaVersion% equ 0 (
   move "%ReleasePath%\%SetupFile%" "%DeployPath%\"
 ) else (
@@ -165,7 +167,7 @@ move "%ReleasePath%\%UpdateFile%" "%DeployPath%\"
 if %errorlevel% neq 0 goto error
 
 cd "%DeployPath%"
-7z a -mx9 %PortableFile% Telegram\
+7z a -mx9 %PortableFile% %BinaryName%\
 if %errorlevel% neq 0 goto error
 
 echo .
@@ -175,16 +177,29 @@ echo .
 set "FinalReleasePath=Z:\TBuild\tother\tsetup"
 set "FinalDeployPath=%FinalReleasePath%\%AppVersionStrMajor%\%AppVersionStrFull%"
 
+echo 1
 if not exist "%DeployPath%\%UpdateFile%" goto error
+echo 2
 if not exist "%DeployPath%\%PortableFile%" goto error
+echo 3
 if %BetaVersion% equ 0 (
   if not exist "%DeployPath%\%SetupFile%" goto error
 )
+echo 4
 if not exist "%DeployPath%\%BinaryName%.pdb" goto error
+echo 5
+if not exist "%DeployPath%\%BinaryName%.exe.pdb" goto error
+echo 6
 if not exist "%DeployPath%\Updater.exe" goto error
+echo 7
 if not exist "%DeployPath%\Updater.pdb" goto error
+echo 8
+if not exist "%DeployPath%\Updater.exe.pdb" goto error
+echo 9
 if not exist "%FinalReleasePath%\%AppVersionStrMajor%" mkdir "%FinalReleasePath%\%AppVersionStrMajor%"
+echo 10
 if not exist "%FinalDeployPath%" mkdir "%FinalDeployPath%"
+echo 11
 
 xcopy "%DeployPath%\%UpdateFile%" "%FinalDeployPath%\"
 xcopy "%DeployPath%\%PortableFile%" "%FinalDeployPath%\"
@@ -194,8 +209,10 @@ if %BetaVersion% equ 0 (
   xcopy "%DeployPath%\%BetaKeyFile%" "%FinalDeployPath%\" /Y
 )
 xcopy "%DeployPath%\%BinaryName%.pdb" "%FinalDeployPath%\"
+xcopy "%DeployPath%\%BinaryName%.exe.pdb" "%FinalDeployPath%\"
 xcopy "%DeployPath%\Updater.exe" "%FinalDeployPath%\"
 xcopy "%DeployPath%\Updater.pdb" "%FinalDeployPath%\"
+xcopy "%DeployPath%\Updater.exe.pdb" "%FinalDeployPath%\"
 
 echo Version %AppVersionStrFull% is ready!
 
diff --git a/Telegram/build/version b/Telegram/build/version
index 07f50c58a..cfe823ff8 100644
--- a/Telegram/build/version
+++ b/Telegram/build/version
@@ -1,6 +1,6 @@
-AppVersion         10001
+AppVersion         10002
 AppVersionStrMajor 0.10
-AppVersionStrSmall 0.10.1
-AppVersionStr      0.10.1
-AlphaChannel       0
+AppVersionStrSmall 0.10.2
+AppVersionStr      0.10.2
+AlphaChannel       1
 BetaVersion        0