From ddc22c8f0394841d72343b8a54285cb06f1eeab0 Mon Sep 17 00:00:00 2001
From: John <johnz@posteo.net>
Date: Thu, 6 Jun 2019 17:48:25 +0200
Subject: [PATCH] telegram-desktop: update to 1.7.7.

---
 srcpkgs/telegram-desktop/files/Telegram.cmake |  5 +++
 .../files/ThirdParty-qtlottie.cmake           | 44 +++++++++++++++++++
 .../patches/PrecompiledHeader-cmake.patch     | 24 +++-------
 srcpkgs/telegram-desktop/template             | 25 +++++++----
 4 files changed, 70 insertions(+), 28 deletions(-)
 create mode 100644 srcpkgs/telegram-desktop/files/ThirdParty-qtlottie.cmake

diff --git a/srcpkgs/telegram-desktop/files/Telegram.cmake b/srcpkgs/telegram-desktop/files/Telegram.cmake
index e6317a2af83..8a252bc4d7f 100644
--- a/srcpkgs/telegram-desktop/files/Telegram.cmake
+++ b/srcpkgs/telegram-desktop/files/Telegram.cmake
@@ -27,6 +27,7 @@ find_package(OpenSSL REQUIRED)
 find_package(Threads REQUIRED)
 find_package(X11 REQUIRED)
 find_package(ZLIB REQUIRED)
+find_package(RapidJSON REQUIRED)
 
 find_package(Qt5 REQUIRED COMPONENTS Core DBus Gui Widgets Network)
 get_target_property(QTCORE_INCLUDE_DIRS Qt5::Core INTERFACE_INCLUDE_DIRECTORIES)
@@ -57,6 +58,7 @@ list(APPEND THIRD_PARTY_INCLUDE_DIRS
 
 add_subdirectory(${THIRD_PARTY_DIR}/crl)
 add_subdirectory(${THIRD_PARTY_DIR}/libtgvoip)
+add_subdirectory(${THIRD_PARTY_DIR}/qtlottie)
 
 set(TELEGRAM_SOURCES_DIR ${CMAKE_SOURCE_DIR}/SourceFiles)
 set(TELEGRAM_RESOURCES_DIR ${CMAKE_SOURCE_DIR}/Resources)
@@ -93,6 +95,7 @@ file(GLOB FLAT_SOURCE_FILES
 	SourceFiles/inline_bots/*.cpp
 	SourceFiles/intro/*.cpp
 	SourceFiles/lang/*.cpp
+	SourceFiles/main/*.cpp
 	SourceFiles/mtproto/*.cpp
 	SourceFiles/overview/*.cpp
 	SourceFiles/passport/*.cpp
@@ -153,6 +156,7 @@ set(TELEGRAM_INCLUDE_DIRS
 	${MINIZIP_INCLUDE_DIRS}
 	${OPENAL_INCLUDE_DIR}
 	${QT_PRIVATE_INCLUDE_DIRS}
+	${RAPIDJSON_INCLUDE_DIRS}
 	${THIRD_PARTY_INCLUDE_DIRS}
 	${ZLIB_INCLUDE_DIR}
 )
@@ -160,6 +164,7 @@ set(TELEGRAM_INCLUDE_DIRS
 set(TELEGRAM_LINK_LIBRARIES
 	xxhash
 	crl
+	qtlottie
 	tgvoip
 	OpenSSL::Crypto
 	OpenSSL::SSL
diff --git a/srcpkgs/telegram-desktop/files/ThirdParty-qtlottie.cmake b/srcpkgs/telegram-desktop/files/ThirdParty-qtlottie.cmake
new file mode 100644
index 00000000000..52bc3011c0b
--- /dev/null
+++ b/srcpkgs/telegram-desktop/files/ThirdParty-qtlottie.cmake
@@ -0,0 +1,44 @@
+project(qtlottie)
+
+set(CMAKE_CXX_STANDARD 17)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+
+list(APPEND CMAKE_MODULE_PATH
+	${CMAKE_SOURCE_DIR}/gyp
+)
+
+find_package(Qt5 REQUIRED COMPONENTS Core Gui)
+
+foreach(__qt_module IN ITEMS QtCore QtGui)
+	list(APPEND QT_PRIVATE_INCLUDE_DIRS
+		${QT_INCLUDE_DIR}/${__qt_module}/${Qt5_VERSION}
+		${QT_INCLUDE_DIR}/${__qt_module}/${Qt5_VERSION}/${__qt_module}
+	)
+endforeach()
+
+file(GLOB QTLOTTIE_SOURCE_FILES
+	src/bodymovin/*.cpp
+	src/imports/rasterrenderer/rasterrenderer.cpp
+	../../SourceFiles/lottie/*.cpp
+)
+
+add_library(${PROJECT_NAME} STATIC ${QTLOTTIE_SOURCE_FILES})
+
+include(PrecompiledHeader)
+add_precompiled_header(${PROJECT_NAME} ../../SourceFiles/lottie/lottie_pch.h)
+
+target_include_directories(${PROJECT_NAME} PUBLIC
+	src
+	src/bodymovin
+	src/imports
+	${CMAKE_SOURCE_DIR}/SourceFiles
+	${CMAKE_SOURCE_DIR}/ThirdParty/GSL/include
+	${CMAKE_SOURCE_DIR}/ThirdParty/variant/include
+	${QT_PRIVATE_INCLUDE_DIRS}
+)
+set_target_properties(${PROJECT_NAME} PROPERTIES AUTOMOC_MOC_OPTIONS -bqtlottie_pch/lottie_pch.h)
+target_compile_definitions(${PROJECT_NAME} PUBLIC BODYMOVIN_LIBRARY)
+target_link_libraries(${PROJECT_NAME} crl Qt5::Core Qt5::Widgets)
diff --git a/srcpkgs/telegram-desktop/patches/PrecompiledHeader-cmake.patch b/srcpkgs/telegram-desktop/patches/PrecompiledHeader-cmake.patch
index 37f7b312148..2977f2d6110 100644
--- a/srcpkgs/telegram-desktop/patches/PrecompiledHeader-cmake.patch
+++ b/srcpkgs/telegram-desktop/patches/PrecompiledHeader-cmake.patch
@@ -1,14 +1,6 @@
---- Telegram/gyp/PrecompiledHeader.cmake
-+++ Telegram/gyp/PrecompiledHeader.cmake
-@@ -79,7 +79,6 @@ function(export_all_flags _filename _source_name_for_flags)
- endfunction()
- 
- function(add_precompiled_header _target _input)
--  if(CMAKE_COMPILER_IS_GNUCXX)
-     get_filename_component(_name ${_input} NAME)
-     set(_pch_header "${CMAKE_CURRENT_SOURCE_DIR}/${_input}")
-     set(_pch_binary_dir "${CMAKE_CURRENT_BINARY_DIR}/${_target}_pch")
-@@ -112,7 +111,7 @@ function(add_precompiled_header _target _input)
+--- Telegram/gyp/PrecompiledHeader.cmake	2019-06-06 18:14:46.443138055 +0200
++++ -	2019-06-06 18:15:45.874739539 +0200
+@@ -114,7 +114,7 @@
        set(_compiler_FLAGS "@${_pch_c_flags_file}")
        add_custom_command(
          OUTPUT "${_output_c}"
@@ -17,7 +9,7 @@
          DEPENDS "${_pchfile}" "${_pch_c_flags_file}"
          IMPLICIT_DEPENDS C "${_pch_header}"
          COMMENT "Precompiling ${_name} for ${_target} (C)")
-@@ -123,7 +122,7 @@ function(add_precompiled_header _target _input)
+@@ -125,7 +125,7 @@
        set(_compiler_FLAGS "@${_pch_cpp_flags_file}")
        add_custom_command(
          OUTPUT "${_output_cxx}"
@@ -25,10 +17,4 @@
 +        COMMAND "${CMAKE_CXX_COMPILER}" ${_compiler_FLAGS} "$(CXX_FLAGS)" -x c++-header -o "${_output_cxx}" -c "${_pchfile}"
          DEPENDS "${_pchfile}" "${_pch_cpp_flags_file}"
          IMPLICIT_DEPENDS CXX "${_pch_header}"
-         COMMENT "Precompiling ${_name} for ${_target} (C++)")
-@@ -161,5 +160,4 @@ function(add_precompiled_header _target _input)
-           OBJECT_DEPENDS "${_object_depends}")
-       endif()
-     endforeach()
--  endif(CMAKE_COMPILER_IS_GNUCXX)
- endfunction()
+         COMMENT "Precompiling header ${_name} for ${_target} (C++)")
diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 78b629d169f..27791505a10 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,12 +1,13 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
-version=1.7.0
+version=1.7.7
 revision=1
-_libtgvoip_commit=e7010506210fbb3a6704d7ac1276b3334f9ab6c9
+_libtgvoip_commit=a19a0aff644127d8089f6a4ac18119ec5247dbd0
 _GSL_commit=d846fe50a3f0bb7767c7e087a05f4be95f4da0ec
 _variant_commit=550ac2f159ca883d360c196149b466955c77a573
-_crl_commit=84072fba75f14620935e5e91788ce603daeb1988
+_crl_commit=d259aebc11df52cb6ff8c738580dc4d8f245d681
 _Catch_commit=5ca44b68721833ae3731802ed99af67c6f38a53a
+_qtlottie_commit=a3fac9db920b167a5f91d678ee7968f100f6fe51
 wrksrc="tdesktop-${version}"
 build_wrksrc="Telegram"
 build_style=cmake
@@ -16,7 +17,8 @@ configure_args="-DENABLE_CRASH_REPORTS=OFF -DENABLE_GTK_INTEGRATION=ON
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools python"
 makedepends="alsa-lib-devel ffmpeg-devel gtk+3-devel libappindicator-devel
  libdbusmenu-glib-devel libopenal-devel minizip-devel opus-devel xxHash-devel
- $(vopt_if pulseaudio 'pulseaudio-devel') qt5-devel range-v3 libva-devel"
+ $(vopt_if pulseaudio 'pulseaudio-devel') qt5-devel range-v3 libva-devel
+ rapidjson"
 depends="qt5-imageformats qt5>=5.11.3<5.11.4"
 short_desc="Telegram Desktop messaging app"
 maintainer="John <johnz@posteo.net>"
@@ -28,13 +30,15 @@ distfiles="https://github.com/telegramdesktop/tdesktop/archive/v${version}.tar.g
  https://github.com/Microsoft/GSL/archive/${_GSL_commit}.tar.gz
  https://github.com/mapbox/variant/archive/${_variant_commit}.tar.gz
  https://github.com/telegramdesktop/crl/archive/${_crl_commit}.tar.gz
- https://github.com/catchorg/Catch2/archive/${_Catch_commit}.tar.gz"
-checksum="3be1f6979da9dd0061f27ad5082f96633a4dfde078b1406554b13d5e9674a8bb
- 9c250f24c0f1775daefb2967c2a25be1d10ea35e72928256aec3f469e576bac4
+ https://github.com/catchorg/Catch2/archive/${_Catch_commit}.tar.gz
+ https://github.com/telegramdesktop/qtlottie/archive/${_qtlottie_commit}.tar.gz"
+checksum="b3ca072eb4c6e30fd17d34daa129d6211de427fa3953f4020b27a02e65400ef1
+ d839ab5a3358e171116b322e0053f441e023c9ced9aec3f0388969c2fce7ac43
  be81db4ab1b57102a0fa1cd0c4a6469294eb9daf24294347592245b754f65ff6
  aa794dfefe0a90501587e36d977b958d0df888503117a8d9aa43dc14f8526d9d
- 0f4143814b17d61d09c6a7fb6764ce74756ec14c0aab94cd65758f7b5a6d2928
- d24e6d9df2b8aa5739d3b9077c6b0ff0ef4d5ef8acc52c3a57e32893854d8d18"
+ f5ea3aeeda0290a44ac49b6300b033d171e67a5b27039fea2f8ae0cb3fc71253
+ d24e6d9df2b8aa5739d3b9077c6b0ff0ef4d5ef8acc52c3a57e32893854d8d18
+ 16d4cda12e340b89007c610070c67130e87f60a85fd1206339ac92b2c71ce848"
 
 build_options="clang pulseaudio"
 build_options_default="pulseaudio"
@@ -94,12 +98,15 @@ post_extract() {
 	mv ../crl-${_crl_commit} ${wrksrc}/${build_wrksrc}/ThirdParty/crl
 	rmdir ${wrksrc}/${build_wrksrc}/ThirdParty/Catch
 	mv ../Catch2-${_Catch_commit} ${wrksrc}/${build_wrksrc}/ThirdParty/Catch
+	rmdir ${wrksrc}/${build_wrksrc}/ThirdParty/qtlottie
+	mv ../qtlottie-${_qtlottie_commit} ${wrksrc}/${build_wrksrc}/ThirdParty/qtlottie
 
 	cp ${FILESDIR}/Telegram.cmake ${build_wrksrc}/CMakeLists.txt
 	cp ${FILESDIR}/ThirdParty-crl.cmake ${build_wrksrc}/ThirdParty/crl/CMakeLists.txt
 	cp ${FILESDIR}/ThirdParty-libtgvoip.cmake ${build_wrksrc}/ThirdParty/libtgvoip/CMakeLists.txt
 	cp ${FILESDIR}/ThirdParty-libtgvoip-webrtc.cmake \
 		${build_wrksrc}/ThirdParty/libtgvoip/webrtc_dsp/CMakeLists.txt
+	cp ${FILESDIR}/ThirdParty-qtlottie.cmake ${build_wrksrc}/ThirdParty/qtlottie/CMakeLists.txt
 
 	mkdir -p ${build_wrksrc}/cmake
 	cp ${FILESDIR}/FindBreakpad.cmake ${build_wrksrc}/cmake
