aboutsummaryrefslogtreecommitdiffstats
path: root/testing/telegram-desktop
diff options
context:
space:
mode:
authorAlex Raschi <raschi.alex@gmail.com>2019-01-02 12:51:39 +0100
committerLeonardo Arena <rnalrd@alpinelinux.org>2019-01-03 07:46:47 +0000
commit24e019a671801ed30486c490cc6b36406b144357 (patch)
tree3f7481813429b4397c72441b76b093f09b921e05 /testing/telegram-desktop
parent742447ce94bd771ee80df9e6859de15803d0d9bb (diff)
downloadaports-24e019a671801ed30486c490cc6b36406b144357.tar.bz2
aports-24e019a671801ed30486c490cc6b36406b144357.tar.xz
testing/telegram-desktop: new aport
https://desktop.telegram.org/ Telegram Desktop messaging app
Diffstat (limited to 'testing/telegram-desktop')
-rw-r--r--testing/telegram-desktop/APKBUILD150
-rw-r--r--testing/telegram-desktop/libtgvoip.patch16
-rw-r--r--testing/telegram-desktop/musl.patch10
-rw-r--r--testing/telegram-desktop/no-gtk2.patch27
-rw-r--r--testing/telegram-desktop/no-pulse.patch34
-rw-r--r--testing/telegram-desktop/system-wide-fonts.patch34
-rw-r--r--testing/telegram-desktop/tdesktop.patch596
-rw-r--r--testing/telegram-desktop/xdg.patch30
8 files changed, 897 insertions, 0 deletions
diff --git a/testing/telegram-desktop/APKBUILD b/testing/telegram-desktop/APKBUILD
new file mode 100644
index 0000000000..3ee605edd3
--- /dev/null
+++ b/testing/telegram-desktop/APKBUILD
@@ -0,0 +1,150 @@
+# Maintainer: Alex Raschi <raschi.alex@gmail.com>
+pkgname=telegram-desktop
+pkgver=1.5.4
+_pkgurl="https://github.com/telegramdesktop/tdesktop.git"
+# https://github.com/telegramdesktop/tdesktop/blob/v$pkgver/docs/building-cmake.md
+_gypver=702ac58e477214c635d9b541932e75a95d349352
+_gypurl="https://chromium.googlesource.com/external/gyp"
+_rangever=0.4.0
+_rangeurl="https://github.com/ericniebler/range-v3.git"
+pkgrel=0
+pkgdesc="Telegram Desktop messaging app"
+url="https://desktop.telegram.org/"
+arch="all"
+license="GPL-3.0-or-later WITH OpenSSL"
+depends="qt5-qtimageformats"
+makedepends="cmake
+ zlib-dev
+ opus-dev
+ libva-dev
+ libvdpau-dev
+ ffmpeg-dev
+ portaudio-dev
+ openal-soft-dev
+ openssl-dev
+ libxkbcommon-dev
+ qt5-qtbase-dev
+ libexif-dev
+ xz-dev
+ minizip-dev
+ alsa-lib-dev
+ libexecinfo-dev
+ python2
+ grep"
+source="http://dev.alpinelinux.org/archive/$pkgname/$pkgname-$pkgver.tar.gz
+ libtgvoip.patch
+ musl.patch
+ no-gtk2.patch
+ no-pulse.patch
+ tdesktop.patch
+ xdg.patch
+ system-wide-fonts.patch"
+builddir="$srcdir/$pkgname-$pkgver"
+_reldir="$builddir/out/Release"
+
+snapshot() {
+ local libs="$builddir"/Libraries
+
+ mkdir -p "$srcdir"
+ cd "$srcdir"
+ git clone --recurse-submodules "$_pkgurl" -b "v$pkgver" "$builddir"
+
+ # clone also gyp and range-v3
+ mkdir "$libs"
+ cd "$libs"
+ git clone --recurse-submodules "$_gypurl" -b "master" gyp
+ git clone --recurse-submodules "$_rangeurl" -b "$_rangever" range-v3
+ cd gyp
+ # chromium.googlesource.com doesn't support cloning commits
+ git reset --hard "$_gypver"
+
+ cd "$srcdir"
+ find "$builddir" -name .git -exec rm -rf {} +
+ # git archive doesn't support submodules
+ tar czf "$builddir".tar.gz "${builddir##*/}"
+ scp "$builddir".tar.gz dev.alpinelinux.org:/archive/$pkgname/
+}
+
+prepare() {
+ cd "$builddir/Telegram/ThirdParty"
+ rm -rf minizip # we have this system-wide
+
+ cd "$builddir/Libraries"
+ patch -p1 -i "$builddir"/Telegram/Patches/gyp.diff -d "gyp"
+
+ default_prepare
+}
+
+build() {
+ cd "$builddir/Telegram/gyp"
+ export CPPFLAGS="$CPPFLAGS -Winvalid-pch"
+ export CXXFLAGS="$CXXFLAGS -Winvalid-pch"
+
+ # https://git.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/telegram-desktop#n80
+ ../../Libraries/gyp/gyp \
+ -Dapi_id=17349 \
+ -Dapi_hash=344583e45741c457fe1862106095a5eb \
+ -Dbuild_defines="TDESKTOP_DISABLE_CRASH_REPORTS,TDESKTOP_DISABLE_AUTOUPDATE,TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME,TDESKTOP_DISABLE_GTK_INTEGRATION,TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION" \
+ -Gconfig=Release \
+ --depth=. \
+ --generator-output=../.. \
+ -Goutput_dir=out \
+ Telegram.gyp \
+ --format=cmake
+
+ cd "$_reldir"
+ printf '%s\n' 'set_target_properties(Telegram PROPERTIES SKIP_BUILD_RPATH TRUE)' >> CMakeLists.txt
+
+ if [ "$CBUILD" != "$CHOST" ]; then
+ CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
+ fi
+ cmake \
+ -DCMAKE_INSTALL_PREFIX=/usr \
+ -DBUILD_SHARED_LIBS=True \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_CXX_FLAGS="$CXXFLAGS" \
+ -DCMAKE_C_FLAGS="$CFLAGS" \
+ -DCMAKE_ASM_COMPILER=as \
+ ${CMAKE_CROSSOPTS}
+ make
+}
+
+check() {
+ local test
+
+ cd "$_reldir"
+ for test in tests_*; do
+ ./"$test"
+ done
+}
+
+package() {
+ local size
+
+ cd "$_reldir"
+ mkdir -p "$pkgdir"/usr/bin
+ mv Telegram "$pkgdir"/usr/bin/telegram-desktop
+
+ cd "$builddir"
+ mkdir -p "$pkgdir"/usr/share/applications
+ mv lib/xdg/telegramdesktop.desktop "$pkgdir"/usr/share/applications/telegram-desktop.desktop
+
+ mkdir -p "$pkgdir"/usr/share/kservices5
+ mv lib/xdg/tg.protocol "$pkgdir"/usr/share/kservices5
+
+ cd Telegram/Resources/art
+ mkdir -p "$pkgdir"/usr/share/icons/hicolor
+ for size in 16 32 48 64 128 256 512; do
+ mkdir -p "$pkgdir"/usr/share/icons/hicolor/"$size"x"$size"/apps
+ mv icon"$size".png "$pkgdir"/usr/share/icons/hicolor/"$size"x"$size"/apps/telegram.png
+ done
+}
+
+sha512sums="97fffa6435b391b126a2df79c7a76097e0edf4256729fccf49d8c95e231ef3975bbef79ddf326b91cb6fbdae0b5b5fe9c966c717a77c3c0463f83856c7441e3c telegram-desktop-1.5.4.tar.gz
+9ee0dbc4b04454a2f440daa381df765616962e8e8c4330e96851dbc5f2a283da687282d666d2667aac67c3467d2079a94e4fef358dbb18eb24a064d55adc7a40 libtgvoip.patch
+fc672d8168f6b2807e596570bc57f3b89296891b5d62b8e12b38193ed4919e4eb17efd72691c4086fb0ff4383de54695a9faf9874a0727a0980ef35e5ca4bee7 musl.patch
+cb01655dd097b68e89b15e6e4b1f6da10c52e8bec681eeef9807ca376283b10cb3da34acc976c790f3c8dea05acbef1ba1967612920a2e4acb3b9da79e251a0d no-gtk2.patch
+9df70f5057fd9938cab87529693ad9617da0fdbb9084ff57395cd540343a0dcc1ecfba4f868b0043b252fe1aca33d0d214fb07931860296e66fbf11825f95fb9 no-pulse.patch
+3cbfe1cb1bf9eb18e79c49ac67560e3290b70a7ceb1e397f4623bbfc39227468b3ab489a5813d371de31438b45751505bf3af7424f92e0e8905e23ab0d2b565d tdesktop.patch
+8de8c0508177da5fcac4f2dcee4d8baef4b99f74f1dca296567bc3689a6bd17a47c1c945df504abc8811b82a687010d0709503c7c32e47d2ebb1cf0e374c80c5 xdg.patch
+ce6be003220267bac5483caf8302b492e1581892bc36d35a61236ebf9f9d766b8bd2159557a1c36256aa85f461797a38bfaae57b12da7a72101b21c0b17ed653 system-wide-fonts.patch"
diff --git a/testing/telegram-desktop/libtgvoip.patch b/testing/telegram-desktop/libtgvoip.patch
new file mode 100644
index 0000000000..b41166198d
--- /dev/null
+++ b/testing/telegram-desktop/libtgvoip.patch
@@ -0,0 +1,16 @@
+--- a/Telegram/ThirdParty/libtgvoip/libtgvoip.gyp
++++ b/Telegram/ThirdParty/libtgvoip/libtgvoip.gyp
+@@ -14,11 +14,12 @@
+ 'variables': {
+ 'tgvoip_src_loc': '.',
+ 'official_build_target%': '',
+- 'linux_path_opus_include%': '<(DEPTH)/../../../Libraries/opus/include',
++ 'linux_path_opus_include%': '/usr/include/opus',
+ },
+ 'include_dirs': [
+ '<(tgvoip_src_loc)/webrtc_dsp',
+ '<(linux_path_opus_include)',
++ '/usr/include/openssl',
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
diff --git a/testing/telegram-desktop/musl.patch b/testing/telegram-desktop/musl.patch
new file mode 100644
index 0000000000..70e7415e1e
--- /dev/null
+++ b/testing/telegram-desktop/musl.patch
@@ -0,0 +1,10 @@
+--- a/Telegram/ThirdParty/libtgvoip/os/linux/AudioPulse.cpp
++++ b/Telegram/ThirdParty/libtgvoip/os/linux/AudioPulse.cpp
+@@ -6,6 +6,7 @@
+
+ #include "AudioPulse.h"
+ #include <dlfcn.h>
++#include <libgen.h>
+ #include "../../logging.h"
+
+ #define DECLARE_DL_FUNCTION(name) typeof(name)* AudioPulse::_import_##name=NULL
diff --git a/testing/telegram-desktop/no-gtk2.patch b/testing/telegram-desktop/no-gtk2.patch
new file mode 100644
index 0000000000..839a49bea5
--- /dev/null
+++ b/testing/telegram-desktop/no-gtk2.patch
@@ -0,0 +1,27 @@
+--- a/Telegram/SourceFiles/platform/linux/linux_libs.cpp
++++ b/Telegram/SourceFiles/platform/linux/linux_libs.cpp
+@@ -240,24 +240,12 @@ void start() {
+ indicatorLoaded = setupAppIndicator(lib_indicator);
+ }
+ }
+- if (!gtkLoaded || !indicatorLoaded) {
+- if (loadLibrary(lib_indicator, "ayatana-appindicator", 1) || loadLibrary(lib_indicator, "appindicator", 1)) {
+- if (loadLibrary(lib_gtk, "gtk-x11-2.0", 0)) {
+- gtkLoaded = indicatorLoaded = false;
+- gtkLoaded = setupGtkBase(lib_gtk);
+- indicatorLoaded = setupAppIndicator(lib_indicator);
+- }
+- }
+- }
+
+ // If no appindicator, try at least load gtk.
+ if (!gtkLoaded && !indicatorLoaded) {
+ if (loadLibrary(lib_gtk, "gtk-3", 0)) {
+ gtkLoaded = setupGtkBase(lib_gtk);
+ }
+- if (!gtkLoaded && loadLibrary(lib_gtk, "gtk-x11-2.0", 0)) {
+- gtkLoaded = setupGtkBase(lib_gtk);
+- }
+ }
+
+ if (gtkLoaded) {
diff --git a/testing/telegram-desktop/no-pulse.patch b/testing/telegram-desktop/no-pulse.patch
new file mode 100644
index 0000000000..39c965490f
--- /dev/null
+++ b/testing/telegram-desktop/no-pulse.patch
@@ -0,0 +1,34 @@
+--- a/Telegram/ThirdParty/libtgvoip/config.h.in
++++ b/Telegram/ThirdParty/libtgvoip/config.h.in
+@@ -197,7 +197,7 @@
+ #undef WITHOUT_ALSA
+
+ /* Define to disable PulseAudio support */
+-#undef WITHOUT_PULSE
++#define WITHOUT_PULSE
+
+ /* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+--- a/Telegram/ThirdParty/libtgvoip/libtgvoip.gyp
++++ b/Telegram/ThirdParty/libtgvoip/libtgvoip.gyp
+@@ -10,6 +10,7 @@
+ 'WEBRTC_APM_DEBUG_DUMP=0',
+ 'TGVOIP_USE_DESKTOP_DSP',
+ 'WEBRTC_NS_FLOAT',
++ 'WITHOUT_PULSE',
+ ],
+ 'variables': {
+ 'tgvoip_src_loc': '.',
+@@ -105,12 +106,6 @@
+ '<(tgvoip_src_loc)/os/linux/AudioInputALSA.h',
+ '<(tgvoip_src_loc)/os/linux/AudioOutputALSA.cpp',
+ '<(tgvoip_src_loc)/os/linux/AudioOutputALSA.h',
+- '<(tgvoip_src_loc)/os/linux/AudioOutputPulse.cpp',
+- '<(tgvoip_src_loc)/os/linux/AudioOutputPulse.h',
+- '<(tgvoip_src_loc)/os/linux/AudioInputPulse.cpp',
+- '<(tgvoip_src_loc)/os/linux/AudioInputPulse.h',
+- '<(tgvoip_src_loc)/os/linux/AudioPulse.cpp',
+- '<(tgvoip_src_loc)/os/linux/AudioPulse.h',
+
+ # POSIX
+ '<(tgvoip_src_loc)/os/posix/NetworkSocketPosix.cpp',
diff --git a/testing/telegram-desktop/system-wide-fonts.patch b/testing/telegram-desktop/system-wide-fonts.patch
new file mode 100644
index 0000000000..c89222986b
--- /dev/null
+++ b/testing/telegram-desktop/system-wide-fonts.patch
@@ -0,0 +1,34 @@
+Description: Remove links to packaged Open Sans font
+ This makes Telegram Desktop use system-wide fonts.
+ Warnings about non-existent fonts in resources are also disabled.
+Author: Nicholas Guriev <guriev-ns@ya.ru>
+Bug-Debian: https://bugs.debian.org/890341
+Last-Update: Sat, 31 Mar 2018 14:36:39 +0300
+
+--- a/Telegram/Resources/qrc/telegram.qrc
++++ b/Telegram/Resources/qrc/telegram.qrc
+@@ -42,9 +42,6 @@
+ <file alias="js/script.js">../export_html/js/script.js</file>
+ </qresource>
+ <qresource prefix="/gui">
+- <file alias="fonts/OpenSans-Regular.ttf">../fonts/OpenSans-Regular.ttf</file>
+- <file alias="fonts/OpenSans-Bold.ttf">../fonts/OpenSans-Bold.ttf</file>
+- <file alias="fonts/OpenSans-Semibold.ttf">../fonts/OpenSans-Semibold.ttf</file>
+ <file alias="art/bg.jpg">../art/bg.jpg</file>
+ <file alias="art/bg_initial.jpg">../art/bg_initial.jpg</file>
+ <file alias="art/logo_256.png">../art/logo_256.png</file>
+--- a/Telegram/SourceFiles/ui/twidget.cpp
++++ b/Telegram/SourceFiles/ui/twidget.cpp
+@@ -70,9 +70,9 @@ void Start() {
+ }
+ Started = true;
+
+- auto regular = LoadCustomFont(qsl(":/gui/fonts/OpenSans-Regular.ttf"), qsl("Open Sans"));
+- auto bold = LoadCustomFont(qsl(":/gui/fonts/OpenSans-Bold.ttf"), qsl("Open Sans"), style::internal::FontBold);
+- auto semibold = LoadCustomFont(qsl(":/gui/fonts/OpenSans-Semibold.ttf"), qsl("Open Sans Semibold"));
++ auto regular = ValidateFont(qsl("Open Sans"));
++ auto bold = ValidateFont(qsl("Open Sans"), style::internal::FontBold);
++ auto semibold = ValidateFont(qsl("Open Sans Semibold"));
+
+ #ifdef Q_OS_WIN
+ // Attempt to workaround a strange font bug with Open Sans Semibold not loading.
diff --git a/testing/telegram-desktop/tdesktop.patch b/testing/telegram-desktop/tdesktop.patch
new file mode 100644
index 0000000000..1fc6fcdf0c
--- /dev/null
+++ b/testing/telegram-desktop/tdesktop.patch
@@ -0,0 +1,596 @@
+--- a/Telegram/Resources/qrc/telegram_linux.qrc
++++ b/Telegram/Resources/qrc/telegram_linux.qrc
+@@ -1,6 +1,5 @@
+ <RCC>
+ <qresource prefix="/qt">
+- <file alias="etc/qt.conf">../etc/qt_linux.conf</file>
+ </qresource>
+ <qresource prefix="/fc">
+ <file alias="fc-custom.conf">../fc-custom.conf</file>
+--- a/Telegram/SourceFiles/core/launcher.cpp
++++ b/Telegram/SourceFiles/core/launcher.cpp
+@@ -39,9 +39,10 @@ void Launcher::init() {
+
+ QCoreApplication::setApplicationName(qsl("TelegramDesktop"));
+
+-#ifndef OS_MAC_OLD
++#if !defined(Q_OS_MAC) && QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
++ // Retina display support is working fine, others are not.
+ QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true);
+-#endif // OS_MAC_OLD
++#endif // not defined Q_OS_MAC and QT_VERSION >= 5.6.0
+
+ initHook();
+ }
+@@ -59,6 +60,13 @@ int Launcher::exec() {
+ Logs::start(this); // must be started before Platform is started
+ Platform::start(); // must be started before QApplication is created
+
++ // I don't know why path is not in QT_PLUGIN_PATH by default
++ QCoreApplication::addLibraryPath("/usr/lib/qt5/plugins");
++ // without this Telegram doesn't start on Ubuntu 17.04 due GTK errors
++ setenv("QT_STYLE_OVERRIDE", "qwerty", false);
++ // Telegram doesn't start when extraordinary theme is set, see launchpad.net/bugs/1680943
++ unsetenv("QT_QPA_PLATFORMTHEME");
++
+ auto result = executeApplication();
+
+ DEBUG_LOG(("Telegram finished, result: %1").arg(result));
+--- a/Telegram/SourceFiles/platform/linux/linux_libs.h
++++ b/Telegram/SourceFiles/platform/linux/linux_libs.h
+@@ -21,7 +21,7 @@ extern "C" {
+ } // extern "C"
+
+ #ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION
+-#include <unity/unity/unity.h>
++typedef void UnityLauncherEntry;
+ #endif // !TDESKTOP_DISABLE_UNITY_INTEGRATION
+ #endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
+
+--- /dev/null
++++ b/Telegram/SourceFiles/qt_functions.cpp
+@@ -0,0 +1,94 @@
++/****************************************************************************
++**
++** Copyright (C) 2015 The Qt Company Ltd.
++** Contact: http://www.qt.io/licensing/
++**
++** This file contains some parts of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:LGPL21$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see http://www.qt.io/terms-conditions. For further
++** information use the contact form at http://www.qt.io/contact-us.
++**
++** GNU Lesser General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU Lesser
++** General Public License version 2.1 or version 3 as published by the Free
++** Software Foundation and appearing in the file LICENSE.LGPLv21 and
++** LICENSE.LGPLv3 included in the packaging of this file. Please review the
++** following information to ensure the GNU Lesser General Public License
++** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
++**
++** As a special exception, The Qt Company gives you certain additional
++** rights. These rights are described in The Qt Company LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++/* TODO: find a dynamic library with these symbols. */
++
++/* Debian maintainer: this function is taken from qfiledialog.cpp */
++/*
++ Makes a list of filters from ;;-separated text.
++ Used by the mac and windows implementations
++*/
++QStringList qt_make_filter_list(const QString &filter)
++{
++ QString f(filter);
++
++ if (f.isEmpty())
++ return QStringList();
++
++ QString sep(QLatin1String(";;"));
++ int i = f.indexOf(sep, 0);
++ if (i == -1) {
++ if (f.indexOf(QLatin1Char('\n'), 0) != -1) {
++ sep = QLatin1Char('\n');
++ i = f.indexOf(sep, 0);
++ }
++ }
++
++ return f.split(sep);
++}
++
++/* Debian maintainer: this constructor is taken from qtextengine.cpp for TextPainter::drawLine */
++QTextItemInt::QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars_, int numChars, QFontEngine *fe, const QTextCharFormat &format)
++ : flags(0), justified(false), underlineStyle(QTextCharFormat::NoUnderline), charFormat(format),
++ num_chars(numChars), chars(chars_), logClusters(0), f(font), glyphs(g), fontEngine(fe)
++{
++}
++
++/* Debian maintainer: this method is also taken from qtextengine.cpp */
++// Fix up flags and underlineStyle with given info
++void QTextItemInt::initWithScriptItem(const QScriptItem &si)
++{
++ // explicitly initialize flags so that initFontAttributes can be called
++ // multiple times on the same TextItem
++ flags = 0;
++ if (si.analysis.bidiLevel %2)
++ flags |= QTextItem::RightToLeft;
++ ascent = si.ascent;
++ descent = si.descent;
++
++ if (charFormat.hasProperty(QTextFormat::TextUnderlineStyle)) {
++ underlineStyle = charFormat.underlineStyle();
++ } else if (charFormat.boolProperty(QTextFormat::FontUnderline)
++ || f->d->underline) {
++ underlineStyle = QTextCharFormat::SingleUnderline;
++ }
++
++ // compat
++ if (underlineStyle == QTextCharFormat::SingleUnderline)
++ flags |= QTextItem::Underline;
++
++ if (f->d->overline || charFormat.fontOverline())
++ flags |= QTextItem::Overline;
++ if (f->d->strikeOut || charFormat.fontStrikeOut())
++ flags |= QTextItem::StrikeOut;
++}
+--- a/Telegram/SourceFiles/qt_static_plugins.cpp
++++ b/Telegram/SourceFiles/qt_static_plugins.cpp
+@@ -15,14 +15,4 @@ Q_IMPORT_PLUGIN(QWebpPlugin)
+ Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin)
+ Q_IMPORT_PLUGIN(QGenericEnginePlugin)
+ #elif defined Q_OS_LINUX // Q_OS_WIN | Q_OS_MAC
+-Q_IMPORT_PLUGIN(QWebpPlugin)
+-Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
+-Q_IMPORT_PLUGIN(QConnmanEnginePlugin)
+-Q_IMPORT_PLUGIN(QGenericEnginePlugin)
+-Q_IMPORT_PLUGIN(QNetworkManagerEnginePlugin)
+-Q_IMPORT_PLUGIN(QComposePlatformInputContextPlugin)
+-Q_IMPORT_PLUGIN(QIbusPlatformInputContextPlugin)
+-Q_IMPORT_PLUGIN(QFcitxPlatformInputContextPlugin)
+-Q_IMPORT_PLUGIN(QHimePlatformInputContextPlugin)
+-Q_IMPORT_PLUGIN(NimfInputContextPlugin)
+ #endif // Q_OS_WIN | Q_OS_MAC | Q_OS_LINUX
+--- a/Telegram/SourceFiles/ui/text/text.cpp
++++ b/Telegram/SourceFiles/ui/text/text.cpp
+@@ -1760,11 +1760,11 @@ private:
+ if (item == -1)
+ return;
+
+-#ifdef OS_MAC_OLD
++#if defined(OS_MAC_OLD) || QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
+ auto end = _e->findItem(line.from + line.length - 1);
+-#else // OS_MAC_OLD
++#else
+ auto end = _e->findItem(line.from + line.length - 1, item);
+-#endif // OS_MAC_OLD
++#endif
+
+ auto blockIndex = _lineStartBlock;
+ auto currentBlock = _t->_blocks[blockIndex].get();
+--- a/Telegram/SourceFiles/ui/text/text_block.cpp
++++ b/Telegram/SourceFiles/ui/text/text_block.cpp
+@@ -332,6 +332,9 @@ TextBlock::TextBlock(const style::font &font, const QString &str, QFixed minResi
+
+ QStackTextEngine engine(part, blockFont->f);
+ BlockParser parser(&engine, this, minResizeWidth, _from, part);
++ QTextLayout layout(part, blockFont->f);
++ layout.beginLayout();
++ layout.createLine();
+
+ CrashReports::ClearAnnotationRef("CrashString");
+ }
+--- a/Telegram/SourceFiles/ui/twidget.cpp
++++ b/Telegram/SourceFiles/ui/twidget.cpp
+@@ -250,9 +250,9 @@ void sendSynteticMouseEvent(QWidget *widget, QEvent::Type type, Qt::MouseButton
+ , button
+ , QGuiApplication::mouseButtons() | button
+ , QGuiApplication::keyboardModifiers()
+-#ifndef OS_MAC_OLD
++#if !defined(OS_MAC_OLD) && QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
+ , Qt::MouseEventSynthesizedByApplication
+-#endif // OS_MAC_OLD
++#endif
+ );
+ ev.setTimestamp(getms());
+ QGuiApplication::sendEvent(windowHandle, &ev);
+--- a/Telegram/gyp/PrecompiledHeader.cmake
++++ b/Telegram/gyp/PrecompiledHeader.cmake
+@@ -114,7 +114,7 @@ function(add_precompiled_header _target _input)
+ set(_compiler_FLAGS "@${_pch_c_flags_file}")
+ add_custom_command(
+ OUTPUT "${_output_c}"
+- COMMAND "${CMAKE_C_COMPILER}" ${_compiler_FLAGS} -x c-header -o "${_output_c}" -c "${_pchfile}"
++ COMMAND "${CMAKE_C_COMPILER}" ${_compiler_FLAGS} "$(C_DEFINES)" "$(C_INCLUDES)" "$(C_FLAGS)" -x c-header -o "${_output_c}" -c "${_pchfile}"
+ DEPENDS "${_pchfile}" "${_pch_c_flags_file}"
+ IMPLICIT_DEPENDS C "${_pch_header}"
+ COMMENT "Precompiling ${_name} for ${_target} (C)")
+@@ -125,7 +125,7 @@ function(add_precompiled_header _target _input)
+ set(_compiler_FLAGS "@${_pch_cpp_flags_file}")
+ add_custom_command(
+ OUTPUT "${_output_cxx}"
+- COMMAND "${CMAKE_CXX_COMPILER}" ${_compiler_FLAGS} -x c++-header -o "${_output_cxx}" -c "${_pchfile}"
++ COMMAND "${CMAKE_CXX_COMPILER}" ${_compiler_FLAGS} "$(CXX_DEFINES)" "$(CXX_INCLUDES)" "$(CXX_FLAGS)" -x c++-header -o "${_output_cxx}" -c "${_pchfile}"
+ DEPENDS "${_pchfile}" "${_pch_cpp_flags_file}"
+ IMPLICIT_DEPENDS CXX "${_pch_header}"
+ COMMENT "Precompiling header ${_name} for ${_target} (C++)")
+--- a/Telegram/gyp/Telegram.gyp
++++ b/Telegram/gyp/Telegram.gyp
+@@ -12,7 +12,7 @@
+ 'target_name': 'Telegram',
+ 'variables': {
+ 'variables': {
+- 'libs_loc': '../../../Libraries',
++ 'libs_loc': '../../Libraries',
+ },
+ 'libs_loc': '<(libs_loc)',
+ 'src_loc': '../SourceFiles',
+@@ -75,7 +75,6 @@
+ 'codegen.gyp:codegen_numbers',
+ 'codegen.gyp:codegen_style',
+ 'tests/tests.gyp:tests',
+- 'utils.gyp:Updater',
+ '../ThirdParty/libtgvoip/libtgvoip.gyp:libtgvoip',
+ 'crl.gyp:crl',
+ 'lib_base.gyp:lib_base',
+@@ -84,7 +83,6 @@
+ ],
+
+ 'defines': [
+- 'AL_LIBTYPE_STATIC',
+ 'AL_ALEXT_PROTOTYPES',
+ 'TGVOIP_USE_CXX11_LIB',
+ 'XXH_INLINE_ALL',
+@@ -96,16 +94,9 @@
+ 'include_dirs': [
+ '<(src_loc)',
+ '<(SHARED_INTERMEDIATE_DIR)',
+- '<(libs_loc)/breakpad/src',
+- '<(libs_loc)/lzma/C',
+- '<(libs_loc)/zlib',
+- '<(libs_loc)/ffmpeg',
+- '<(libs_loc)/openal-soft/include',
+- '<(libs_loc)/opus/include',
+ '<(libs_loc)/range-v3/include',
+- '<(minizip_loc)',
+- '<(sp_media_key_tap_loc)',
+ '<(emoji_suggestions_loc)',
++ '/usr/include/minizip',
+ '<(submodules_loc)/GSL/include',
+ '<(submodules_loc)/variant/include',
+ '<(submodules_loc)/crl/src',
+--- a/Telegram/gyp/lib_base.gyp
++++ b/Telegram/gyp/lib_base.gyp
+@@ -23,7 +23,7 @@
+ 'variables': {
+ 'src_loc': '../SourceFiles',
+ 'res_loc': '../Resources',
+- 'libs_loc': '../../../Libraries',
++ 'libs_loc': '../../Libraries',
+ 'official_build_target%': '',
+ 'submodules_loc': '../ThirdParty',
+ 'pch_source': '<(src_loc)/base/base_pch.cpp',
+--- a/Telegram/gyp/lib_export.gyp
++++ b/Telegram/gyp/lib_export.gyp
+@@ -22,7 +22,7 @@
+ 'variables': {
+ 'src_loc': '../SourceFiles',
+ 'res_loc': '../Resources',
+- 'libs_loc': '../../../Libraries',
++ 'libs_loc': '../../Libraries',
+ 'official_build_target%': '',
+ 'submodules_loc': '../ThirdParty',
+ 'pch_source': '<(src_loc)/export/export_pch.cpp',
+--- a/Telegram/gyp/lib_storage.gyp
++++ b/Telegram/gyp/lib_storage.gyp
+@@ -23,7 +23,7 @@
+ 'variables': {
+ 'src_loc': '../SourceFiles',
+ 'res_loc': '../Resources',
+- 'libs_loc': '../../../Libraries',
++ 'libs_loc': '../../Libraries',
+ 'official_build_target%': '',
+ 'submodules_loc': '../ThirdParty',
+ 'pch_source': '<(src_loc)/storage/storage_pch.cpp',
+--- a/Telegram/gyp/qt.gypi
++++ b/Telegram/gyp/qt.gypi
+@@ -14,25 +14,21 @@
+ [ 'build_macold', {
+ 'qt_version%': '5.3.2',
+ }, {
+- 'qt_version%': '5.6.2',
++ 'qt_version%': '<!(echo /usr/include/QtCore/*/ | grep -Po "\d+\.\d+\.\d+")',
+ }]
+ ],
+ },
+ 'qt_libs': [
+- 'qwebp',
+- 'Qt5PrintSupport',
+- 'Qt5PlatformSupport',
+ 'Qt5Network',
+ 'Qt5Widgets',
+ 'Qt5Gui',
+- 'qtharfbuzzng',
+ ],
+ 'qt_version%': '<(qt_version)',
+ 'conditions': [
+ [ 'build_macold', {
+ 'linux_path_qt%': '/usr/local/macold/Qt-<(qt_version)',
+ }, {
+- 'linux_path_qt%': '/usr/local/tdesktop/Qt-<(qt_version)',
++ 'linux_path_qt%': '/usr/lib/qt5',
+ }]
+ ]
+ },
+@@ -72,32 +68,13 @@
+ ],
+ }],
+ [ 'build_linux', {
+- 'qt_lib_prefix': 'lib',
+- 'qt_lib_debug_postfix': '.a',
+- 'qt_lib_release_postfix': '.a',
++ 'qt_lib_prefix': '',
++ 'qt_lib_debug_postfix': '',
++ 'qt_lib_release_postfix': '',
+ 'qt_libs': [
+- 'qxcb',
+- 'Qt5XcbQpa',
+- 'qconnmanbearer',
+- 'qgenericbearer',
+- 'qnmbearer',
+ '<@(qt_libs)',
+ 'Qt5DBus',
+ 'Qt5Core',
+- 'qtpcre',
+- 'Xi',
+- 'Xext',
+- 'Xfixes',
+- 'SM',
+- 'ICE',
+- 'fontconfig',
+- 'expat',
+- 'freetype',
+- 'z',
+- 'xcb-shm',
+- 'xcb-xfixes',
+- 'xcb-render',
+- 'xcb-static',
+ ],
+ }],
+ ],
+@@ -127,11 +104,6 @@
+ # '<!@(python <(DEPTH)/list_sources.py [sources] <(qt_moc_list_sources_arg))'
+ # where [sources] contains all your source files
+ 'qt_moc_list_sources_arg': '--moc-prefix SHARED_INTERMEDIATE_DIR/<(_target_name)/moc/moc_',
+-
+- 'linux_path_xkbcommon%': '/usr/local',
+- 'linux_lib_ssl%': '/usr/local/ssl/lib/libssl.a',
+- 'linux_lib_crypto%': '/usr/local/ssl/lib/libcrypto.a',
+- 'linux_lib_icu%': 'libicutu.a libicui18n.a libicuuc.a libicudata.a',
+ },
+
+ 'configurations': {
+@@ -180,14 +152,14 @@
+ },
+
+ 'include_dirs': [
+- '<(qt_loc)/include',
+- '<(qt_loc)/include/QtCore',
+- '<(qt_loc)/include/QtGui',
+- '<(qt_loc)/include/QtDBus',
+- '<(qt_loc)/include/QtCore/<(qt_version)',
+- '<(qt_loc)/include/QtGui/<(qt_version)',
+- '<(qt_loc)/include/QtCore/<(qt_version)/QtCore',
+- '<(qt_loc)/include/QtGui/<(qt_version)/QtGui',
++ '/usr/include',
++ '/usr/include/QtCore',
++ '/usr/include/QtGui',
++ '/usr/include/QtDBus',
++ '/usr/include/QtCore/<(qt_version)',
++ '/usr/include/QtGui/<(qt_version)',
++ '/usr/include/QtCore/<(qt_version)/QtCore',
++ '/usr/include/QtGui/<(qt_version)/QtGui',
+ ],
+ 'library_dirs': [
+ '<(qt_loc)/lib',
+@@ -204,25 +176,14 @@
+ ],
+ 'conditions': [
+ [ 'build_linux', {
+- 'dependencies': [
+- '<(DEPTH)/linux_glibc_wraps.gyp:linux_glibc_wraps',
+- ],
+ 'library_dirs': [
+ '<(qt_loc)/plugins/platforminputcontexts',
+ ],
+ 'libraries': [
+- '<(PRODUCT_DIR)/obj.target/liblinux_glibc_wraps.a',
+- '<(linux_path_xkbcommon)/lib/libxkbcommon.a',
+ '<@(qt_libs_release)',
+- '<(linux_lib_ssl)',
+- '<(linux_lib_crypto)',
+- '<!@(python -c "for s in \'<(linux_lib_icu)\'.split(\' \'): print(s)")',
+- '-lxcb',
++ '-lcrypto',
+ '-lX11',
+- '-lX11-xcb',
+- '-ldbus-1',
+ '-ldl',
+- '-lgthread-2.0',
+ '-lglib-2.0',
+ '-lpthread',
+ ],
+@@ -230,7 +191,6 @@
+ '<(qt_loc)/mkspecs/linux-g++',
+ ],
+ 'ldflags': [
+- '-static-libstdc++',
+ '-pthread',
+ '-rdynamic',
+ ],
+--- a/Telegram/gyp/settings_linux.gypi
++++ b/Telegram/gyp/settings_linux.gypi
+@@ -11,7 +11,6 @@
+ 'linux_common_flags': [
+ '-pipe',
+ '-Wall',
+- '-Werror',
+ '-W',
+ '-fPIC',
+ '-Wno-unused-variable',
+@@ -60,7 +59,6 @@
+ ],
+ 'defines': [
+ '_REENTRANT',
+- 'QT_STATICPLUGIN',
+ 'QT_PLUGIN',
+ ],
+ 'cflags_c': [
+--- a/Telegram/gyp/telegram_linux.gypi
++++ b/Telegram/gyp/telegram_linux.gypi
+@@ -23,18 +23,20 @@
+ 'linux_path_va%': '/usr/local',
+ 'linux_path_vdpau%': '/usr/local',
+ 'linux_path_breakpad%': '/usr/local',
+- 'linux_path_opus_include%': '<(libs_loc)/opus/include',
++ 'linux_path_opus_include%': '/usr/include/opus',
+ 'linux_path_range%': '/usr/local',
+ },
+ 'include_dirs': [
++ '/usr/include/openssl',
+ '/usr/local/include',
+ '<(linux_path_ffmpeg)/include',
+ '<(linux_path_openal)/include',
+ '<(linux_path_breakpad)/include/breakpad',
+ '<(linux_path_opus_include)',
+- '<(linux_path_range)/include',
++ '<(libs_loc)/range-v3/include',
+ ],
+ 'library_dirs': [
++ '/usr/lib/openssl',
+ '/usr/local/lib',
+ '<(linux_path_ffmpeg)/lib',
+ '<(linux_path_openal)/lib',
+@@ -43,26 +45,16 @@
+ '<(linux_path_breakpad)/lib',
+ ],
+ 'libraries': [
+- 'breakpad_client',
+- 'composeplatforminputcontextplugin',
+- 'ibusplatforminputcontextplugin',
+- 'fcitxplatforminputcontextplugin',
+- 'himeplatforminputcontextplugin',
+- 'nimfplatforminputcontextplugin',
+- 'liblzma.a',
+- 'libopenal.a',
+- 'libavformat.a',
+- 'libavcodec.a',
+- 'libswresample.a',
+- 'libswscale.a',
+- 'libavutil.a',
+- 'libopus.a',
+- 'libva-x11.a',
+- 'libva-drm.a',
+- 'libva.a',
+- 'libvdpau.a',
+- 'libdrm.a',
+- 'libz.a',
++ 'openal',
++ 'avformat',
++ 'avcodec',
++ 'swresample',
++ 'swscale',
++ 'avutil',
++ 'minizip',
++ 'opus',
++ 'z',
++ 'lzma',
+ # '<!(pkg-config 2> /dev/null --libs <@(pkgconfig_libs))',
+ ],
+ 'cflags_cc': [
+@@ -70,9 +62,6 @@
+ '-Wno-maybe-uninitialized',
+ ],
+ 'ldflags': [
+- '-Wl,-wrap,aligned_alloc',
+- '-Wl,-wrap,secure_getenv',
+- '-Wl,-wrap,clock_gettime',
+ '-Wl,--no-as-needed,-lrt',
+ ],
+ 'configurations': {
+@@ -92,14 +81,10 @@
+ },
+ 'conditions': [
+ [ '"<!(uname -p)" != "x86_64"', {
+- 'ldflags': [
+- '-Wl,-wrap,__divmoddi4',
+- ],
+ }], ['not_need_gtk!="True"', {
+ 'cflags_cc': [
+- '<!(pkg-config 2> /dev/null --cflags gtk+-2.0)',
+- '<!(pkg-config 2> /dev/null --cflags glib-2.0)',
+- '<!(pkg-config 2> /dev/null --cflags dee-1.0)',
++ '<!(pkg-config 2> /dev/null --cflags appindicator3-0.1)',
++ '<!(pkg-config 2> /dev/null --cflags gtk+-3.0)',
+ ],
+ }], ['<!(pkg-config ayatana-appindicator3-0.1; echo $?) == 0', {
+ 'cflags_cc': [ '<!(pkg-config --cflags ayatana-appindicator3-0.1)' ],
+--- a/Telegram/gyp/telegram_sources.txt
++++ b/Telegram/gyp/telegram_sources.txt
+@@ -805,14 +805,7 @@
+ <(emoji_suggestions_loc)/emoji_suggestions.cpp
+ <(emoji_suggestions_loc)/emoji_suggestions.h
+
+-platforms: !win
+-<(minizip_loc)/crypt.h
+-<(minizip_loc)/ioapi.c
+-<(minizip_loc)/ioapi.h
+-<(minizip_loc)/zip.c
+-<(minizip_loc)/zip.h
+-<(minizip_loc)/unzip.c
+-<(minizip_loc)/unzip.h
++<(src_loc)/qt_functions.cpp
+
+ platforms: win
+ <(res_loc)/winrc/Telegram.rc
+--- a/Telegram/gyp/tests/tests.gyp
++++ b/Telegram/gyp/tests/tests.gyp
+@@ -9,7 +9,7 @@
+ '../common.gypi',
+ ],
+ 'variables': {
+- 'libs_loc': '../../../../Libraries',
++ 'libs_loc': '../../../Libraries',
+ 'src_loc': '../../SourceFiles',
+ 'submodules_loc': '../../ThirdParty',
+ 'mac_target': '10.10',
+--- a/Telegram/gyp/utils.gyp
++++ b/Telegram/gyp/utils.gyp
+@@ -11,7 +11,7 @@
+ 'targets': [{
+ 'target_name': 'Updater',
+ 'variables': {
+- 'libs_loc': '../../../Libraries',
++ 'libs_loc': '../../Libraries',
+ 'src_loc': '../SourceFiles',
+ 'res_loc': '../Resources',
+ },
+@@ -57,7 +57,7 @@
+ }, {
+ 'target_name': 'Packer',
+ 'variables': {
+- 'libs_loc': '../../../Libraries',
++ 'libs_loc': '../../Libraries',
+ 'src_loc': '../SourceFiles',
+ 'mac_target': '10.10',
+ },
diff --git a/testing/telegram-desktop/xdg.patch b/testing/telegram-desktop/xdg.patch
new file mode 100644
index 0000000000..e26bda0bc7
--- /dev/null
+++ b/testing/telegram-desktop/xdg.patch
@@ -0,0 +1,30 @@
+--- a/lib/xdg/telegramdesktop.desktop
++++ b/lib/xdg/telegramdesktop.desktop
+@@ -1,6 +1,8 @@
+ [Desktop Entry]
+ Version=1.0
+ Name=Telegram Desktop
++GenericName=Telegram Desktop
++Keywords=IM;Chat;
+ Comment=Official desktop version of Telegram messaging app
+ Exec=telegram-desktop -- %u
+ Icon=telegram
+--- a/lib/xdg/telegramdesktop.appdata.xml
++++ b/lib/xdg/telegramdesktop.appdata.xml
+@@ -1,6 +1,6 @@
+ <?xml version="1.0" encoding="utf-8"?>
+ <component type="desktop">
+- <id>org.telegram.desktop</id>
++ <id>telegram-desktop.desktop</id>
+ <metadata_license>CC0-1.0</metadata_license>
+ <project_license>GPL-3.0</project_license>
+ <name>Telegram Desktop</name>
+--- a/lib/xdg/tg.protocol
++++ b/lib/xdg/tg.protocol
+@@ -1,5 +1,5 @@
+ [Protocol]
+-exec=/usr/bin/telegram-desktop -- %u
++exec=telegram-desktop -- %u
+ protocol=tg
+ input=none
+ output=none