From f676d32f96e70874d9d8e78788c37b82b1e3324a Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Fri, 2 May 2025 17:19:01 +0400 Subject: [PATCH 001/131] Fix tde2e include the way tdlib itself uses it --- Telegram/SourceFiles/tde2e/tde2e_api.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/tde2e/tde2e_api.cpp b/Telegram/SourceFiles/tde2e/tde2e_api.cpp index c3cc45d89a..fb7cbbb986 100644 --- a/Telegram/SourceFiles/tde2e/tde2e_api.cpp +++ b/Telegram/SourceFiles/tde2e/tde2e_api.cpp @@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/assertion.h" #include "base/debug_log.h" -#include +#include #define LOG_ERROR(error) \ LOG(("TdE2E Error %1: %2").arg(int(error.code)).arg(error.message.c_str())) From cf414cb9cbf1ef01009889be4302de8421381ed1 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 3 May 2025 13:19:48 +0400 Subject: [PATCH 002/131] Update cmake_helpers --- cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake b/cmake index b1bd565af8..e76dce0783 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit b1bd565af81c41a908d87148505179cef803d813 +Subproject commit e76dce0783ac7927f77d046f6ad757df442653cd From 9fd1f95ab88a90e8acde6d26b2f1d715961f5c24 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 1 May 2025 13:04:09 +0400 Subject: [PATCH 003/131] Cherry-pick mozjpeg cmake 4 compatibility --- Telegram/build/prepare/prepare.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index e26c85c2d4..6362765444 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -577,6 +577,7 @@ mac: stage('mozjpeg', """ git clone -b v4.1.5 https://github.com/mozilla/mozjpeg.git cd mozjpeg + git cherry-pick 1644bdb win: cmake . ^ -A %WIN32X64% ^ From 932bd92b951dfa770834995389ba29e02342d175 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 1 May 2025 15:08:53 +0400 Subject: [PATCH 004/131] Cherry-pick libde265 cmake 4 compatibility --- Telegram/build/prepare/prepare.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index 6362765444..f96cf65bd0 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -905,6 +905,7 @@ mac: stage('libde265', """ git clone -b v1.0.15 https://github.com/strukturag/libde265.git cd libde265 + git cherry-pick 5c5af1e win: cmake . ^ -A %WIN32X64% ^ From d62b488459a563fd79cec7059b118aae1c6f7cf6 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Fri, 2 May 2025 15:15:22 +0400 Subject: [PATCH 005/131] Ensure ffmpeg can find static pkg-config deps --- Telegram/build/docker/centos_env/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index 8bf42a9281..b5640d7cb2 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -30,6 +30,7 @@ RUN dnf -y install epel-release \ && dnf clean all RUN python3 -m pip install meson ninja +RUN sed -i '/Requires.private: valgrind/d' /usr/lib64/pkgconfig/libdrm.pc RUN echo set debuginfod enabled on > /opt/rh/{{ TOOLSET }}/root/etc/gdbinit.d/00-debuginfod.gdb RUN adduser user @@ -482,6 +483,7 @@ RUN git clone -b n6.1.1 --depth=1 {{ GIT }}/FFmpeg/FFmpeg.git \ && ./configure \ --extra-cflags="-fno-lto -DCONFIG_SAFE_BITSTREAM_READER=1" \ --extra-cxxflags="-fno-lto -DCONFIG_SAFE_BITSTREAM_READER=1" \ + --pkg-config-flags=--static \ --disable-debug \ --disable-programs \ --disable-doc \ From e81a2a50115e4986523f78199f1d049e395ba3e5 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 1 May 2025 14:13:04 +0400 Subject: [PATCH 006/131] Update Opus to 1.5.2 This fixes compatibility with cmake 4 --- Telegram/build/docker/centos_env/Dockerfile | 9 ++++----- Telegram/build/prepare/prepare.py | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index b5640d7cb2..3f04007a22 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -121,12 +121,11 @@ RUN git clone -b 1.0.7 --depth=1 {{ GIT }}/google/highway.git \ && rm -rf highway FROM builder AS opus -RUN git clone -b v1.4 --depth=1 {{ GIT }}/xiph/opus.git \ +RUN git clone -b v1.5.2 --depth=1 {{ GIT }}/xiph/opus.git \ && cd opus \ - && ./autogen.sh \ - && ./configure \ - && make -j$(nproc) \ - && make DESTDIR="{{ LibrariesPath }}/opus-cache" install \ + && cmake -GNinja -B build . -DCMAKE_BUILD_TYPE=None \ + && cmake --build build --parallel \ + && DESTDIR="{{ LibrariesPath }}/opus-cache" cmake --install build \ && cd .. \ && rm -rf opus diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index f96cf65bd0..290b3ae8ae 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -660,9 +660,8 @@ mac: """) stage('opus', """ - git clone -b v1.3.1 https://github.com/xiph/opus.git + git clone -b v1.5.2 https://github.com/xiph/opus.git cd opus - git cherry-pick 927de8453c win: cmake -B out . ^ -A %WIN32X64% ^ From cfefb8b2e01f6b2ff4bd0c0a5be53bbd94087e30 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 1 May 2025 14:16:34 +0400 Subject: [PATCH 007/131] Update zlib to 1.3.1 --- Telegram/build/docker/centos_env/Dockerfile | 13 ++++++------- Telegram/build/prepare/prepare.py | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index 3f04007a22..6337858562 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -50,14 +50,13 @@ RUN git init patches \ && rm -rf .git FROM builder AS zlib -RUN git init zlib \ +RUN git clone -b v1.3.1 --depth=1 {{ GIT }}/madler/zlib.git \ && cd zlib \ - && git remote add origin {{ GIT }}/madler/zlib.git \ - && git fetch --depth=1 origin 643e17b7498d12ab8d15565662880579692f769d \ - && git reset --hard FETCH_HEAD \ - && ./configure \ - && make -j$(nproc) \ - && make DESTDIR="{{ LibrariesPath }}/zlib-cache" install \ + && cmake -GNinja -B build . \ + -DCMAKE_BUILD_TYPE=None \ + -DZLIB_BUILD_EXAMPLES=OFF \ + && cmake --build build --parallel \ + && DESTDIR="{{ LibrariesPath }}/zlib-cache" cmake --install build \ && cd .. \ && rm -rf zlib diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index 290b3ae8ae..8098a4f9f4 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -552,16 +552,16 @@ stage('xz', """ """) stage('zlib', """ - git clone https://github.com/madler/zlib.git + git clone -b v1.3.1 https://github.com/madler/zlib.git cd zlib - git checkout 643e17b749 win: cmake . ^ -A %WIN32X64% ^ -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" ^ -DCMAKE_C_FLAGS_DEBUG="/MTd /Zi /Ob0 /Od /RTC1" ^ -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" ^ - -DCMAKE_C_FLAGS="/DZLIB_WINAPI" + -DCMAKE_C_FLAGS="/DZLIB_WINAPI" ^ + -DZLIB_BUILD_EXAMPLES=OFF cmake --build . --config Debug --parallel release: cmake --build . --config Release --parallel From fcec85881f69d1c76431b55822e217b590423862 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 1 May 2025 15:00:34 +0400 Subject: [PATCH 008/131] Update xz to 5.8.1 in Docker --- Telegram/build/docker/centos_env/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index 6337858562..40b596bfb8 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -61,10 +61,10 @@ RUN git clone -b v1.3.1 --depth=1 {{ GIT }}/madler/zlib.git \ && rm -rf zlib FROM builder AS xz -RUN git clone -b v5.4.4 --depth=1 {{ GIT }}/tukaani-project/xz.git \ +RUN git clone -b v5.8.1 --depth=1 {{ GIT }}/tukaani-project/xz.git \ && cd xz \ - && cmake -B build . -DCMAKE_BUILD_TYPE=None \ - && cmake --build build -j$(nproc) \ + && cmake -GNinja -B build . -DCMAKE_BUILD_TYPE=None \ + && cmake --build build --parallel \ && DESTDIR="{{ LibrariesPath }}/xz-cache" cmake --install build \ && cd .. \ && rm -rf xz From e3a5a4239b11fb553d7bae7a6077461a8f5f0245 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 1 May 2025 14:21:43 +0400 Subject: [PATCH 009/131] Don't override C(XX)FLAGS for static MSVC library in prepare.py Rely solely on CMAKE_MSVC_RUNTIME_LIBRARY --- Telegram/build/prepare/prepare.py | 39 +++++++++++-------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index 8098a4f9f4..98929c364f 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -558,8 +558,7 @@ win: cmake . ^ -A %WIN32X64% ^ -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" ^ - -DCMAKE_C_FLAGS_DEBUG="/MTd /Zi /Ob0 /Od /RTC1" ^ - -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" ^ + -DCMAKE_POLICY_DEFAULT_CMP0091=NEW ^ -DCMAKE_C_FLAGS="/DZLIB_WINAPI" ^ -DZLIB_BUILD_EXAMPLES=OFF cmake --build . --config Debug --parallel @@ -666,9 +665,7 @@ win: cmake -B out . ^ -A %WIN32X64% ^ -DCMAKE_INSTALL_PREFIX=%LIBS_DIR%/local ^ - -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" ^ - -DCMAKE_C_FLAGS_DEBUG="/MTd /Zi /Ob0 /Od /RTC1" ^ - -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" + -DOPUS_STATIC_RUNTIME=ON cmake --build out --config Debug --parallel cmake --build out --config Release --parallel cmake --install out --config Release @@ -878,8 +875,7 @@ win: -A %WIN32X64% ^ -DCMAKE_INSTALL_PREFIX=%LIBS_DIR%/local ^ -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" ^ - -DCMAKE_C_FLAGS_DEBUG="/MTd /Zi /Ob0 /Od /RTC1" ^ - -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" ^ + -DCMAKE_POLICY_DEFAULT_CMP0091=NEW ^ -DBUILD_SHARED_LIBS=OFF ^ -DAVIF_ENABLE_WERROR=OFF ^ -DAVIF_CODEC_DAV1D=ON @@ -910,12 +906,9 @@ win: -A %WIN32X64% ^ -DCMAKE_INSTALL_PREFIX=%LIBS_DIR%/local ^ -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" ^ + -DCMAKE_POLICY_DEFAULT_CMP0091=NEW ^ -DCMAKE_C_FLAGS="/DLIBDE265_STATIC_BUILD" ^ -DCMAKE_CXX_FLAGS="/DLIBDE265_STATIC_BUILD" ^ - -DCMAKE_C_FLAGS_DEBUG="/MTd /Zi /Ob0 /Od /RTC1" ^ - -DCMAKE_CXX_FLAGS_DEBUG="/MTd /Zi /Ob0 /Od /RTC1" ^ - -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" ^ - -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" ^ -DENABLE_SDL=OFF ^ -DBUILD_SHARED_LIBS=OFF ^ -DENABLE_DECODER=OFF ^ @@ -989,10 +982,6 @@ win: -A %WIN32X64% ^ -DCMAKE_INSTALL_PREFIX=%LIBS_DIR%/local ^ -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" ^ - -DCMAKE_C_FLAGS_DEBUG="/MTd /Zi /Ob0 /Od /RTC1" ^ - -DCMAKE_CXX_FLAGS_DEBUG="/MTd /Zi /Ob0 /Od /RTC1" ^ - -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" ^ - -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" ^ -DBUILD_SHARED_LIBS=OFF ^ -DBUILD_TESTING=OFF ^ -DENABLE_PLUGIN_LOADING=OFF ^ @@ -1061,10 +1050,6 @@ win: -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" ^ -DCMAKE_C_FLAGS="/DJXL_STATIC_DEFINE /DJXL_THREADS_STATIC_DEFINE /DJXL_CMS_STATIC_DEFINE" ^ -DCMAKE_CXX_FLAGS="/DJXL_STATIC_DEFINE /DJXL_THREADS_STATIC_DEFINE /DJXL_CMS_STATIC_DEFINE" ^ - -DCMAKE_C_FLAGS_DEBUG="/MTd /Zi /Ob0 /Od /RTC1" ^ - -DCMAKE_CXX_FLAGS_DEBUG="/MTd /Zi /Ob0 /Od /RTC1" ^ - -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" ^ - -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" ^ %cmake_defines% cmake --build . --config Debug --parallel cmake --install . --config Debug @@ -1873,9 +1858,7 @@ win: -D ADA_TESTING=OFF ^ -D ADA_TOOLS=OFF ^ -D ADA_INCLUDE_URL_PATTERN=OFF ^ - -D CMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" ^ - -D CMAKE_C_FLAGS_DEBUG="/MTd /Zi /Ob0 /Od /RTC1" ^ - -D CMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" + -D CMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" cmake --build out --config Debug --parallel cmake --build out --config Release --parallel mac: @@ -1946,8 +1929,10 @@ win: -DZLIB_FOUND=1 ^ -DZLIB_INCLUDE_DIR=%ZLIB_LIBS_DIR% ^ -DZLIB_LIBRARIES="%ZLIB_LIBS_DIR%\\Debug\\zlibstaticd.lib" ^ - -DCMAKE_CXX_FLAGS_DEBUG="/DZLIB_WINAPI /DNDEBUG /MTd /Zi /Od /Ob0" ^ - -DCMAKE_C_FLAGS_DEBUG="/DNDEBUG /MTd /Zi /Od /Ob0" ^ + -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" ^ + -DCMAKE_POLICY_DEFAULT_CMP0091=NEW ^ + -DCMAKE_C_FLAGS="/DZLIB_WINAPI" ^ + -DCMAKE_CXX_FLAGS="/DZLIB_WINAPI" ^ -DCMAKE_EXE_LINKER_FLAGS="/SAFESEH:NO Ws2_32.lib Gdi32.lib Advapi32.lib Crypt32.lib User32.lib %OPENSSL_LIBS_DIR%.dbg\\libssl.lib" ^ -DCMAKE_SHARED_LINKER_FLAGS="/SAFESEH:NO Ws2_32.lib Gdi32.lib Advapi32.lib Crypt32.lib User32.lib %OPENSSL_LIBS_DIR%.dbg\\libssl.lib" ^ -DTD_ENABLE_MULTI_PROCESSOR_COMPILATION=ON ^ @@ -1965,8 +1950,10 @@ release: -DZLIB_FOUND=1 ^ -DZLIB_INCLUDE_DIR=%ZLIB_LIBS_DIR% ^ -DZLIB_LIBRARIES="%ZLIB_LIBS_DIR%\\Release\\zlibstatic.lib" ^ - -DCMAKE_CXX_FLAGS_RELEASE="/DZLIB_WINAPI /MT /Ob2" ^ - -DCMAKE_C_FLAGS_RELEASE="/MT /Ob2" ^ + -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" ^ + -DCMAKE_POLICY_DEFAULT_CMP0091=NEW ^ + -DCMAKE_C_FLAGS="/DZLIB_WINAPI" ^ + -DCMAKE_CXX_FLAGS="/DZLIB_WINAPI" ^ -DCMAKE_EXE_LINKER_FLAGS="/SAFESEH:NO Ws2_32.lib Gdi32.lib Advapi32.lib Crypt32.lib User32.lib %OPENSSL_LIBS_DIR%\\libssl.lib" ^ -DCMAKE_SHARED_LINKER_FLAGS="/SAFESEH:NO Ws2_32.lib Gdi32.lib Advapi32.lib Crypt32.lib User32.lib %OPENSSL_LIBS_DIR%\\libssl.lib" ^ -DTD_ENABLE_MULTI_PROCESSOR_COMPILATION=ON ^ From 81c1f6bd8ea822ca5342d791ceedd1f55c018c23 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 1 May 2025 14:33:31 +0400 Subject: [PATCH 010/131] Update rnnoise --- Telegram/build/docker/centos_env/Dockerfile | 5 +---- Telegram/build/prepare/prepare.py | 6 ++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index 40b596bfb8..0995ff7036 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -278,10 +278,7 @@ RUN git clone -b master --depth=1 {{ GIT }}/desktop-app/rnnoise.git \ && cd rnnoise \ && cmake -GNinja -B build . -DCMAKE_BUILD_TYPE=None \ && cmake --build build --parallel \ - && mkdir -p "{{ LibrariesPath }}/rnnoise-cache/usr/local/include" \ - && cp "include/rnnoise.h" "{{ LibrariesPath }}/rnnoise-cache/usr/local/include/" \ - && mkdir -p "{{ LibrariesPath }}/rnnoise-cache/usr/local/lib" \ - && cp "build/librnnoise.a" "{{ LibrariesPath }}/rnnoise-cache/usr/local/lib/" \ + && DESTDIR="{{ LibrariesPath }}/rnnoise-cache" cmake --install build \ && cd .. \ && rm -rf rnnoise diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index 98929c364f..6640650b55 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -681,11 +681,11 @@ mac: stage('rnnoise', """ git clone https://github.com/desktop-app/rnnoise.git cd rnnoise - git checkout fe37e57d09 + git checkout d8ea2b0 mkdir out cd out win: - cmake -A %WIN32X64% .. + cmake -A %WIN32X64% .. -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" cmake --build . --config Debug --parallel release: cmake --build . --config Release --parallel @@ -694,6 +694,7 @@ release: cd Debug cmake -G Ninja ../.. \\ -D CMAKE_BUILD_TYPE=Debug \\ + -D CMAKE_OSX_DEPLOYMENT_TARGET:STRING=$MACOSX_DEPLOYMENT_TARGET \\ -D CMAKE_OSX_ARCHITECTURES="x86_64;arm64" ninja release: @@ -702,6 +703,7 @@ release: cd Release cmake -G Ninja ../.. \\ -D CMAKE_BUILD_TYPE=Release \\ + -D CMAKE_OSX_DEPLOYMENT_TARGET:STRING=$MACOSX_DEPLOYMENT_TARGET \\ -D CMAKE_OSX_ARCHITECTURES="x86_64;arm64" ninja """) From f97d7513437eb2c1dc01793b72a9514d04bb07a3 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 1 May 2025 14:33:50 +0400 Subject: [PATCH 011/131] Update tg_owt --- Telegram/build/docker/centos_env/Dockerfile | 2 +- Telegram/build/prepare/prepare.py | 11 ++++++++--- snap/snapcraft.yaml | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index 0995ff7036..64820246ea 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -765,7 +765,7 @@ COPY --link --from=pipewire {{ LibrariesPath }}/pipewire-cache / RUN git init tg_owt \ && cd tg_owt \ && git remote add origin {{ GIT }}/desktop-app/tg_owt.git \ - && git fetch --depth=1 origin 8198c4d8b91e22d68eb5c7327fd408e3b6abcc79 \ + && git fetch --depth=1 origin c4192e8e2e10ccb72704daa79fa108becfa57b01 \ && git reset --hard FETCH_HEAD \ && git submodule update --init --recursive --depth=1 \ && rm -rf .git \ diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index 6640650b55..9eb72b7fce 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -1738,9 +1738,8 @@ win: stage('tg_owt', """ git clone https://github.com/desktop-app/tg_owt.git cd tg_owt - git checkout 4a60ce1ab9 - git submodule init - git submodule update + git checkout c4192e8 + git submodule update --init --recursive win: SET MOZJPEG_PATH=$LIBS_DIR/mozjpeg SET OPUS_PATH=$USED_PREFIX/include/opus @@ -1754,6 +1753,7 @@ win: cd Debug cmake -G Ninja \ -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" \ -DTG_OWT_BUILD_AUDIO_BACKENDS=OFF \ -DTG_OWT_SPECIAL_TARGET=$SPECIAL_TARGET \ -DTG_OWT_LIBJPEG_INCLUDE_PATH=$MOZJPEG_PATH \ @@ -1769,6 +1769,7 @@ release: cd Release cmake -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" \ -DTG_OWT_BUILD_AUDIO_BACKENDS=OFF \ -DTG_OWT_SPECIAL_TARGET=$SPECIAL_TARGET \ -DTG_OWT_LIBJPEG_INCLUDE_PATH=$MOZJPEG_PATH \ @@ -1790,6 +1791,7 @@ mac: cd Debug.x86_64 cmake -G Ninja \ -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=$MACOSX_DEPLOYMENT_TARGET \ -DCMAKE_OSX_ARCHITECTURES=x86_64 \ -DTG_OWT_BUILD_AUDIO_BACKENDS=OFF \ -DTG_OWT_SPECIAL_TARGET=$SPECIAL_TARGET \ @@ -1805,6 +1807,7 @@ mac: cd Debug.arm64 cmake -G Ninja \ -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=$MACOSX_DEPLOYMENT_TARGET \ -DCMAKE_OSX_ARCHITECTURES=arm64 \ -DTG_OWT_BUILD_AUDIO_BACKENDS=OFF \ -DTG_OWT_SPECIAL_TARGET=$SPECIAL_TARGET \ @@ -1823,6 +1826,7 @@ release: cd Release.x86_64 cmake -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=$MACOSX_DEPLOYMENT_TARGET \ -DCMAKE_OSX_ARCHITECTURES=x86_64 \ -DTG_OWT_SPECIAL_TARGET=$SPECIAL_TARGET \ -DTG_OWT_LIBJPEG_INCLUDE_PATH=$MOZJPEG_PATH \ @@ -1837,6 +1841,7 @@ release: cd Release.arm64 cmake -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=$MACOSX_DEPLOYMENT_TARGET \ -DCMAKE_OSX_ARCHITECTURES=arm64 \ -DTG_OWT_SPECIAL_TARGET=$SPECIAL_TARGET \ -DTG_OWT_LIBJPEG_INCLUDE_PATH=$MOZJPEG_PATH \ diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 8c86d17fa6..7fe128fb78 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -452,7 +452,7 @@ parts: webrtc: source: https://github.com/desktop-app/tg_owt.git source-depth: 1 - source-commit: 8198c4d8b91e22d68eb5c7327fd408e3b6abcc79 + source-commit: c4192e8e2e10ccb72704daa79fa108becfa57b01 plugin: cmake build-environment: - LDFLAGS: ${LDFLAGS:+$LDFLAGS} -s From 9790e37154595515ad4d33308ee3af0a3a6387f4 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 1 May 2025 19:14:38 +0400 Subject: [PATCH 012/131] Remove unused ThirdParty\cmake\bin from prepare.py --- Telegram/build/prepare/prepare.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index 9eb72b7fce..cfaec6772f 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -84,7 +84,6 @@ if not os.path.isdir(os.path.join(thirdPartyDir, keysLoc)): pathPrefixes = [ 'ThirdParty\\msys64\\mingw64\\bin', 'ThirdParty\\jom', - 'ThirdParty\\cmake\\bin', 'ThirdParty\\gyp', ] if win else [ 'ThirdParty/gyp', From 2327d661b94fd286548a6d496e762702b098ea5b Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 1 May 2025 19:14:52 +0400 Subject: [PATCH 013/131] Update msys2 --- Telegram/build/prepare/prepare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index cfaec6772f..3fab1059a5 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -467,7 +467,7 @@ win: SET CHERE_INVOKING=enabled_from_arguments SET MSYS2_PATH_TYPE=inherit - powershell -Command "iwr -OutFile ./msys64.exe https://github.com/msys2/msys2-installer/releases/download/2024-05-07/msys2-base-x86_64-20240507.sfx.exe" + powershell -Command "iwr -OutFile ./msys64.exe https://github.com/msys2/msys2-installer/releases/download/2025-02-21/msys2-base-x86_64-20250221.sfx.exe" msys64.exe del msys64.exe From 4a6ae3b46c7c5d7a6376a4f616700a2569a7a0ba Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 1 May 2025 19:17:07 +0400 Subject: [PATCH 014/131] Use ninja from Windows SDK --- Telegram/build/prepare/prepare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index 3fab1059a5..33a7559377 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -472,7 +472,7 @@ win: del msys64.exe bash -c "pacman-key --init; pacman-key --populate; pacman -Syu --noconfirm" - pacman -Syu --noconfirm mingw-w64-x86_64-perl mingw-w64-x86_64-nasm mingw-w64-x86_64-yasm mingw-w64-x86_64-ninja msys/make diffutils pkg-config + pacman -Syu --noconfirm mingw-w64-x86_64-perl mingw-w64-x86_64-nasm mingw-w64-x86_64-yasm msys/make diffutils pkg-config SET PATH=%PATH_BACKUP_% """, 'ThirdParty') From 5938e0f82196c36ab0098d1cff8343e201d807cd Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 1 May 2025 19:18:20 +0400 Subject: [PATCH 015/131] Use native versions of diffutils and pkg-config on Windows --- Telegram/build/prepare/prepare.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index 33a7559377..b14c72ee44 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -472,7 +472,13 @@ win: del msys64.exe bash -c "pacman-key --init; pacman-key --populate; pacman -Syu --noconfirm" - pacman -Syu --noconfirm mingw-w64-x86_64-perl mingw-w64-x86_64-nasm mingw-w64-x86_64-yasm msys/make diffutils pkg-config + pacman -Syu --noconfirm ^ + make ^ + mingw-w64-x86_64-diffutils ^ + mingw-w64-x86_64-nasm ^ + mingw-w64-x86_64-perl ^ + mingw-w64-x86_64-pkgconf ^ + mingw-w64-x86_64-yasm SET PATH=%PATH_BACKUP_% """, 'ThirdParty') From 78a3e329f5ee62853345c497110c25fcef799e05 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 1 May 2025 19:18:45 +0400 Subject: [PATCH 016/131] Use gperf from msys2 --- Telegram/build/prepare/prepare.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index b14c72ee44..28cebccd34 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -475,6 +475,7 @@ win: pacman -Syu --noconfirm ^ make ^ mingw-w64-x86_64-diffutils ^ + mingw-w64-x86_64-gperf ^ mingw-w64-x86_64-nasm ^ mingw-w64-x86_64-perl ^ mingw-w64-x86_64-pkgconf ^ @@ -1937,7 +1938,6 @@ win: -DOPENSSL_FOUND=1 ^ -DOPENSSL_INCLUDE_DIR=%OPENSSL_DIR%\\include ^ -DOPENSSL_CRYPTO_LIBRARY="%OPENSSL_LIBS_DIR%.dbg\\libcrypto.lib" ^ - -DGPERF_EXECUTABLE=%ROOT_DIR%\\ThirdParty\\gperf\\bin\\gperf ^ -DZLIB_FOUND=1 ^ -DZLIB_INCLUDE_DIR=%ZLIB_LIBS_DIR% ^ -DZLIB_LIBRARIES="%ZLIB_LIBS_DIR%\\Debug\\zlibstaticd.lib" ^ @@ -1958,7 +1958,6 @@ release: -DOPENSSL_FOUND=1 ^ -DOPENSSL_INCLUDE_DIR=%OPENSSL_DIR%\\include ^ -DOPENSSL_CRYPTO_LIBRARY="%OPENSSL_LIBS_DIR%\\libcrypto.lib" ^ - -DGPERF_EXECUTABLE=%ROOT_DIR%\\ThirdParty\\gperf\\bin\\gperf ^ -DZLIB_FOUND=1 ^ -DZLIB_INCLUDE_DIR=%ZLIB_LIBS_DIR% ^ -DZLIB_LIBRARIES="%ZLIB_LIBS_DIR%\\Release\\zlibstatic.lib" ^ From ca2f2adc905ab500d5950a89f915b4e6e107c7ae Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 5 May 2025 10:58:35 +0400 Subject: [PATCH 017/131] Use correct paths for the rules files. --- .cursor/{api_usage.md => rules/api_usage.mdc} | 0 .cursor/{localization.md => rules/localization.mdc} | 0 .cursor/{rpl_guide.md => rules/rpl_guide.mdc} | 0 .cursor/{styling.md => rules/styling.mdc} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename .cursor/{api_usage.md => rules/api_usage.mdc} (100%) rename .cursor/{localization.md => rules/localization.mdc} (100%) rename .cursor/{rpl_guide.md => rules/rpl_guide.mdc} (100%) rename .cursor/{styling.md => rules/styling.mdc} (100%) diff --git a/.cursor/api_usage.md b/.cursor/rules/api_usage.mdc similarity index 100% rename from .cursor/api_usage.md rename to .cursor/rules/api_usage.mdc diff --git a/.cursor/localization.md b/.cursor/rules/localization.mdc similarity index 100% rename from .cursor/localization.md rename to .cursor/rules/localization.mdc diff --git a/.cursor/rpl_guide.md b/.cursor/rules/rpl_guide.mdc similarity index 100% rename from .cursor/rpl_guide.md rename to .cursor/rules/rpl_guide.mdc diff --git a/.cursor/styling.md b/.cursor/rules/styling.mdc similarity index 100% rename from .cursor/styling.md rename to .cursor/rules/styling.mdc From 904e531113fa909ae5a26735d732c7d2d31c2007 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 16 Apr 2025 09:54:50 +0400 Subject: [PATCH 018/131] Show resell info in gifts choose box. --- Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/api/api_premium.cpp | 3 +++ Telegram/SourceFiles/boxes/star_gift_box.cpp | 8 ++++++- Telegram/SourceFiles/data/data_star_gift.h | 2 ++ .../peer_gifts/info_peer_gifts_common.cpp | 21 ++++++++++++++----- .../info/peer_gifts/info_peer_gifts_common.h | 1 + Telegram/SourceFiles/mtproto/scheme/api.tl | 21 ++++++++++++++----- 7 files changed, 46 insertions(+), 11 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 983e6da4a1..0176d9484e 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -3421,6 +3421,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_gift_stars_link" = "What are Stars >"; "lng_gift_stars_limited" = "limited"; "lng_gift_stars_sold_out" = "sold out"; +"lng_gift_stars_resale" = "resale"; "lng_gift_stars_tabs_all" = "All Gifts"; "lng_gift_stars_tabs_my" = "My Gifts"; "lng_gift_stars_tabs_limited" = "Limited"; diff --git a/Telegram/SourceFiles/api/api_premium.cpp b/Telegram/SourceFiles/api/api_premium.cpp index be3ead5afc..63b9323c6f 100644 --- a/Telegram/SourceFiles/api/api_premium.cpp +++ b/Telegram/SourceFiles/api/api_premium.cpp @@ -799,6 +799,7 @@ std::optional FromTL( return gift.match([&](const MTPDstarGift &data) { const auto document = session->data().processDocument( data.vsticker()); + const auto resellPrice = data.vresell_min_stars().value_or_empty(); const auto remaining = data.vavailability_remains(); const auto total = data.vavailability_total(); if (!document->sticker()) { @@ -809,7 +810,9 @@ std::optional FromTL( .stars = int64(data.vstars().v), .starsConverted = int64(data.vconvert_stars().v), .starsToUpgrade = int64(data.vupgrade_stars().value_or_empty()), + .starsResellMin = int64(resellPrice), .document = document, + .resellCount = int(data.vavailability_resale().value_or_empty()), .limitedLeft = remaining.value_or_empty(), .limitedCount = total.value_or_empty(), .firstSaleDate = data.vfirst_sale_date().value_or_empty(), diff --git a/Telegram/SourceFiles/boxes/star_gift_box.cpp b/Telegram/SourceFiles/boxes/star_gift_box.cpp index 4247e936c3..bda9b868e5 100644 --- a/Telegram/SourceFiles/boxes/star_gift_box.cpp +++ b/Telegram/SourceFiles/boxes/star_gift_box.cpp @@ -859,9 +859,15 @@ void PreviewWrap::paintEvent(QPaintEvent *e) { list.reserve(gifts.size()); for (auto &gift : gifts) { list.push_back({ .info = gift }); + if (gift.resellCount > 0) { + list.push_back({ .info = gift, .resale = true }); + } } ranges::stable_sort(list, [](const auto &a, const auto &b) { - return a.info.soldOut < b.info.soldOut; + const auto soldOut = [](const auto &gift) { + return gift.info.soldOut && !gift.resale; + }; + return soldOut(a) < soldOut(b); }); auto &map = Map[session]; diff --git a/Telegram/SourceFiles/data/data_star_gift.h b/Telegram/SourceFiles/data/data_star_gift.h index c529be692e..fd2f6bb5e1 100644 --- a/Telegram/SourceFiles/data/data_star_gift.h +++ b/Telegram/SourceFiles/data/data_star_gift.h @@ -62,7 +62,9 @@ struct StarGift { int64 stars = 0; int64 starsConverted = 0; int64 starsToUpgrade = 0; + int64 starsResellMin = 0; not_null document; + int resellCount = 0; int limitedLeft = 0; int limitedCount = 0; TimeId firstSaleDate = 0; diff --git a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp index fb014da15a..b143d03975 100644 --- a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp +++ b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp @@ -141,7 +141,11 @@ void GiftButton::setDescriptor(const GiftDescriptor &descriptor, Mode mode) { } _price.setMarkedText( st::semiboldTextStyle, - (unique + (data.resale + ? _delegate->star().append(' ').append( + Lang::FormatCountDecimal(data.info.starsResellMin) + ).append(data.info.resellCount > 0 ? "+" : "") + : unique ? tr::lng_gift_transfer_button( tr::now, Ui::Text::WithEntities) @@ -152,7 +156,10 @@ void GiftButton::setDescriptor(const GiftDescriptor &descriptor, Mode mode) { if (!_stars) { _stars.emplace(this, true, starsType); } - if (unique) { + if (data.resale) { + _stars->setColorOverride( + Ui::Premium::CreditsIconGradientStops()); + } else if (unique) { const auto white = QColor(255, 255, 255); _stars->setColorOverride(QGradientStops{ { 0., anim::with_alpha(white, .3) }, @@ -491,10 +498,12 @@ void GiftButton::paintEvent(QPaintEvent *e) { && !data.userpic && !data.info.limitedLeft; return GiftBadge{ - .text = (soldOut - ? tr::lng_gift_stars_sold_out(tr::now) + .text = (data.resale + ? tr::lng_gift_stars_resale(tr::now) : (unique && pinned) ? ('#' + QString::number(unique->number)) + : soldOut + ? tr::lng_gift_stars_sold_out(tr::now) : (!data.userpic && !data.info.unique) ? tr::lng_gift_stars_limited(tr::now) : (count == 1) @@ -505,7 +514,9 @@ void GiftButton::paintEvent(QPaintEvent *e) { (((count % 1000) && (count < 10'000)) ? Lang::FormatCountDecimal(count) : Lang::FormatCountToShort(count).string))), - .bg1 = (unique + .bg1 = (data.resale + ? st::boxTextFgGood->c + : unique ? unique->backdrop.edgeColor : soldOut ? st::attentionButtonFg->c diff --git a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h index aa852493a1..16658c6beb 100644 --- a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h +++ b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h @@ -68,6 +68,7 @@ struct GiftTypeStars { bool userpic : 1 = false; bool pinned : 1 = false; bool hidden : 1 = false; + bool resale : 1 = false; bool mine : 1 = false; [[nodiscard]] friend inline bool operator==( diff --git a/Telegram/SourceFiles/mtproto/scheme/api.tl b/Telegram/SourceFiles/mtproto/scheme/api.tl index af06c44507..48e7697aa4 100644 --- a/Telegram/SourceFiles/mtproto/scheme/api.tl +++ b/Telegram/SourceFiles/mtproto/scheme/api.tl @@ -184,7 +184,7 @@ messageActionPaymentRefunded#41b3e202 flags:# peer:Peer currency:string total_am messageActionGiftStars#45d5b021 flags:# currency:string amount:long stars:long crypto_currency:flags.0?string crypto_amount:flags.0?long transaction_id:flags.1?string = MessageAction; messageActionPrizeStars#b00c47a2 flags:# unclaimed:flags.0?true stars:long transaction_id:string boost_peer:Peer giveaway_msg_id:int = MessageAction; messageActionStarGift#4717e8a4 flags:# name_hidden:flags.0?true saved:flags.2?true converted:flags.3?true upgraded:flags.5?true refunded:flags.9?true can_upgrade:flags.10?true gift:StarGift message:flags.1?TextWithEntities convert_stars:flags.4?long upgrade_msg_id:flags.5?int upgrade_stars:flags.8?long from_id:flags.11?Peer peer:flags.12?Peer saved_id:flags.12?long = MessageAction; -messageActionStarGiftUnique#acdfcb81 flags:# upgrade:flags.0?true transferred:flags.1?true saved:flags.2?true refunded:flags.5?true gift:StarGift can_export_at:flags.3?int transfer_stars:flags.4?long from_id:flags.6?Peer peer:flags.7?Peer saved_id:flags.7?long = MessageAction; +messageActionStarGiftUnique#5f6b75c9 flags:# upgrade:flags.0?true transferred:flags.1?true saved:flags.2?true refunded:flags.5?true gift:StarGift can_export_at:flags.3?int transfer_stars:flags.4?long from_id:flags.6?Peer peer:flags.7?Peer saved_id:flags.7?long resale_stars:flags.8?long = MessageAction; messageActionPaidMessagesRefunded#ac1f1fcd count:int stars:long = MessageAction; messageActionPaidMessagesPrice#bcd71419 stars:long = MessageAction; messageActionConferenceCall#2ffe2f7a flags:# missed:flags.0?true active:flags.1?true video:flags.4?true call_id:long duration:flags.2?int other_participants:flags.3?Vector = MessageAction; @@ -1490,6 +1490,7 @@ inputInvoiceStarGiftUpgrade#4d818d5d flags:# keep_original_details:flags.0?true inputInvoiceStarGiftTransfer#4a5f5bd9 stargift:InputSavedStarGift to_id:InputPeer = InputInvoice; inputInvoicePremiumGiftStars#dabab2ef flags:# user_id:InputUser months:int message:flags.0?TextWithEntities = InputInvoice; inputInvoiceBusinessBotTransferStars#f4997e42 bot:InputUser stars:long = InputInvoice; +inputInvoiceStarGiftResale#63cbc38c slug:string to_id:InputPeer = InputInvoice; payments.exportedInvoice#aed0cbd9 url:string = payments.ExportedInvoice; @@ -1887,8 +1888,8 @@ starsGiveawayOption#94ce852a flags:# extended:flags.0?true default:flags.1?true starsGiveawayWinnersOption#54236209 flags:# default:flags.0?true users:int per_user_stars:long = StarsGiveawayWinnersOption; -starGift#2cc73c8 flags:# limited:flags.0?true sold_out:flags.1?true birthday:flags.2?true id:long sticker:Document stars:long availability_remains:flags.0?int availability_total:flags.0?int convert_stars:long first_sale_date:flags.1?int last_sale_date:flags.1?int upgrade_stars:flags.3?long = StarGift; -starGiftUnique#5c62d151 flags:# id:long title:string slug:string num:int owner_id:flags.0?Peer owner_name:flags.1?string owner_address:flags.2?string attributes:Vector availability_issued:int availability_total:int gift_address:flags.3?string = StarGift; +starGift#c62aca28 flags:# limited:flags.0?true sold_out:flags.1?true birthday:flags.2?true id:long sticker:Document stars:long availability_remains:flags.0?int availability_total:flags.0?int availability_resale:flags.4?long convert_stars:long first_sale_date:flags.1?int last_sale_date:flags.1?int upgrade_stars:flags.3?long resell_min_stars:flags.4?long title:flags.5?string = StarGift; +starGiftUnique#6411db89 flags:# id:long title:string slug:string num:int owner_id:flags.0?Peer owner_name:flags.1?string owner_address:flags.2?string attributes:Vector availability_issued:int availability_total:int gift_address:flags.3?string resell_stars:flags.4?long = StarGift; payments.starGiftsNotModified#a388a368 = payments.StarGifts; payments.starGifts#901689ea hash:int gifts:Vector = payments.StarGifts; @@ -1924,7 +1925,7 @@ botVerification#f93cd45c bot_id:long icon:long description:string = BotVerificat starGiftAttributeModel#39d99013 name:string document:Document rarity_permille:int = StarGiftAttribute; starGiftAttributePattern#13acff19 name:string document:Document rarity_permille:int = StarGiftAttribute; -starGiftAttributeBackdrop#94271762 name:string center_color:int edge_color:int pattern_color:int text_color:int rarity_permille:int = StarGiftAttribute; +starGiftAttributeBackdrop#d93d859c name:string backdrop_id:int center_color:int edge_color:int pattern_color:int text_color:int rarity_permille:int = StarGiftAttribute; starGiftAttributeOriginalDetails#e0bff26c flags:# sender_id:flags.0?Peer recipient_id:Peer date:int message:flags.1?TextWithEntities = StarGiftAttribute; payments.starGiftUpgradePreview#167bd90b sample_attributes:Vector = payments.StarGiftUpgradePreview; @@ -1964,6 +1965,14 @@ sponsoredPeer#c69708d3 flags:# random_id:bytes peer:Peer sponsor_info:flags.0?st contacts.sponsoredPeersEmpty#ea32b4b1 = contacts.SponsoredPeers; contacts.sponsoredPeers#eb032884 peers:Vector chats:Vector users:Vector = contacts.SponsoredPeers; +starGiftAttributeIdModel#48aaae3c document_id:long = StarGiftAttributeId; +starGiftAttributeIdPattern#4a162433 document_id:long = StarGiftAttributeId; +starGiftAttributeIdBackdrop#1f01c757 backdrop_id:int = StarGiftAttributeId; + +starGiftAttributeCounter#2eb1b658 attribute:StarGiftAttributeId count:int = StarGiftAttributeCounter; + +payments.resaleStarGifts#947a12df flags:# count:int gifts:Vector next_offset:flags.0?string attributes:flags.1?Vector attributes_hash:flags.1?long chats:Vector counters:flags.2?Vector users:Vector = payments.ResaleStarGifts; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -2564,6 +2573,8 @@ payments.getStarGiftWithdrawalUrl#d06e93a8 stargift:InputSavedStarGift password: payments.toggleChatStarGiftNotifications#60eaefa1 flags:# enabled:flags.0?true peer:InputPeer = Bool; payments.toggleStarGiftsPinnedToTop#1513e7b0 peer:InputPeer stargift:Vector = Bool; payments.canPurchaseStore#4fdc5ea7 purpose:InputStorePaymentPurpose = Bool; +payments.getResaleStarGifts#7a5fa236 flags:# sort_by_price:flags.1?true sort_by_num:flags.2?true attributes_hash:flags.0?long gift_id:long attributes:flags.3?Vector offset:string limit:int = payments.ResaleStarGifts; +payments.updateStarGiftPrice#e2d4f33a slug:string resell_stars:long = Updates; stickers.createStickerSet#9021ab67 flags:# masks:flags.0?true emojis:flags.5?true text_color:flags.6?true user_id:InputUser title:string short_name:string thumb:flags.2?InputDocument stickers:Vector software:flags.3?string = messages.StickerSet; stickers.removeStickerFromSet#f7760f51 sticker:InputDocument = messages.StickerSet; @@ -2689,4 +2700,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool; fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo; -// LAYER 202 +// LAYER 203 From e629460942abd97bd31684b97826136d3971d492 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 18 Apr 2025 14:56:08 +0400 Subject: [PATCH 019/131] Implement filtering of resale gifts. --- Telegram/Resources/langs/lang.strings | 16 + Telegram/SourceFiles/api/api_premium.cpp | 3 +- Telegram/SourceFiles/boxes/star_gift_box.cpp | 725 ++++++++++++++++++ Telegram/SourceFiles/data/data_star_gift.h | 2 + .../SourceFiles/menu/gift_resale_filter.cpp | 147 ++++ .../SourceFiles/menu/gift_resale_filter.h | 55 ++ Telegram/SourceFiles/ui/effects/credits.style | 15 + Telegram/cmake/td_ui.cmake | 2 + 8 files changed, 964 insertions(+), 1 deletion(-) create mode 100644 Telegram/SourceFiles/menu/gift_resale_filter.cpp create mode 100644 Telegram/SourceFiles/menu/gift_resale_filter.h diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 0176d9484e..816b61c8e9 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -3590,6 +3590,22 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_gift_wear_end_toast" = "You took off {name}"; "lng_gift_many_pinned_title" = "Too Many Pinned Gifts"; "lng_gift_many_pinned_choose" = "Select a gift to unpin below"; +"lng_gift_resale_price" = "Price"; +"lng_gift_resale_number" = "Number"; +"lng_gift_resale_date" = "Date"; +"lng_gift_resale_sort_price" = "Sort by Price"; +"lng_gift_resale_sort_date" = "Sort by Date"; +"lng_gift_resale_sort_number" = "Sort by Number"; +"lng_gift_resale_filter_all" = "Select All"; +"lng_gift_resale_model" = "Model"; +"lng_gift_resale_models#one" = "{count} Model"; +"lng_gift_resale_models#other" = "{count} Models"; +"lng_gift_resale_backdrop" = "Backdrop"; +"lng_gift_resale_backdrops#one" = "{count} Backdrop"; +"lng_gift_resale_backdrops#other" = "{count} Backdrops"; +"lng_gift_resale_symbol" = "Symbol"; +"lng_gift_resale_symbols#one" = "{count} Symbol"; +"lng_gift_resale_symbols#other" = "{count} Symbols"; "lng_accounts_limit_title" = "Limit Reached"; "lng_accounts_limit1#one" = "You have reached the limit of **{count}** connected account."; diff --git a/Telegram/SourceFiles/api/api_premium.cpp b/Telegram/SourceFiles/api/api_premium.cpp index 63b9323c6f..7be23befea 100644 --- a/Telegram/SourceFiles/api/api_premium.cpp +++ b/Telegram/SourceFiles/api/api_premium.cpp @@ -812,6 +812,7 @@ std::optional FromTL( .starsToUpgrade = int64(data.vupgrade_stars().value_or_empty()), .starsResellMin = int64(resellPrice), .document = document, + .resellTitle = qs(data.vtitle().value_or_empty()), .resellCount = int(data.vavailability_resale().value_or_empty()), .limitedLeft = remaining.value_or_empty(), .limitedCount = total.value_or_empty(), @@ -939,7 +940,7 @@ Data::UniqueGiftPattern FromTL( } Data::UniqueGiftBackdrop FromTL(const MTPDstarGiftAttributeBackdrop &data) { - auto result = Data::UniqueGiftBackdrop(); + auto result = Data::UniqueGiftBackdrop{ .id = data.vbackdrop_id().v }; result.name = qs(data.vname()); result.rarityPermille = data.vrarity_permille().v; result.centerColor = Ui::ColorFromSerialized( diff --git a/Telegram/SourceFiles/boxes/star_gift_box.cpp b/Telegram/SourceFiles/boxes/star_gift_box.cpp index bda9b868e5..63749d168d 100644 --- a/Telegram/SourceFiles/boxes/star_gift_box.cpp +++ b/Telegram/SourceFiles/boxes/star_gift_box.cpp @@ -57,6 +57,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lottie/lottie_single_player.h" #include "main/main_app_config.h" #include "main/main_session.h" +#include "menu/gift_resale_filter.h" #include "payments/payments_form.h" #include "payments/payments_checkout_process.h" #include "payments/payments_non_panel_process.h" @@ -117,6 +118,8 @@ constexpr auto kSwitchUpgradeCoverInterval = 3 * crl::time(1000); constexpr auto kCrossfadeDuration = crl::time(400); constexpr auto kUpgradeDoneToastDuration = 4 * crl::time(1000); constexpr auto kGiftsPreloadTimeout = 3 * crl::time(1000); +constexpr auto kResaleGiftsPerPage = 50; +constexpr auto kFiltersCount = 4; using namespace HistoryView; using namespace Info::PeerGifts; @@ -128,6 +131,20 @@ enum class PickType { }; using PickCallback = Fn, PickType)>; +enum class AttributeIdType { + Model, + Pattern, + Backdrop, +}; + +struct AttributeId { + uint64 value = 0; + AttributeIdType type = AttributeIdType::Model; + + friend inline auto operator<=>(AttributeId, AttributeId) = default; + friend inline bool operator==(AttributeId, AttributeId) = default; +}; + struct PremiumGiftsDescriptor { std::vector list; std::shared_ptr api; @@ -138,6 +155,53 @@ struct MyGiftsDescriptor { QString offset; }; +struct ModelCount { + Data::UniqueGiftModel model; + int count = 0; +}; + +struct BackdropCount { + Data::UniqueGiftBackdrop backdrop; + int count = 0; +}; + +struct PatternCount { + Data::UniqueGiftPattern pattern; + int count = 0; +}; + +enum class ResaleSort { + Date, + Price, + Number, +}; + +struct ResaleGiftsDescriptor { + uint64 giftId = 0; + QString title; + QString offset; + std::vector list; + std::vector models; + std::vector backdrops; + std::vector patterns; + uint64 attributesHash = 0; + int count = 0; + ResaleSort sort = ResaleSort::Date; +}; + +struct ResaleFilter { + uint64 attributesHash = 0; + base::flat_set attributes; + ResaleSort sort = ResaleSort::Date; + + friend inline auto operator<=>( + const ResaleFilter &, + const ResaleFilter &) = default; + friend inline bool operator==( + const ResaleFilter &, + const ResaleFilter &) = default; +}; + struct GiftsDescriptor { std::vector list; std::shared_ptr api; @@ -267,6 +331,53 @@ private: }; +[[nodiscard]] AttributeId FromTL(const MTPStarGiftAttributeId &id) { + return id.match([&](const MTPDstarGiftAttributeIdBackdrop &data) { + return AttributeId{ + .value = uint64(uint32(data.vbackdrop_id().v)), + .type = AttributeIdType::Backdrop, + }; + }, [&](const MTPDstarGiftAttributeIdModel &data) { + return AttributeId{ + .value = data.vdocument_id().v, + .type = AttributeIdType::Model, + }; + }, [&](const MTPDstarGiftAttributeIdPattern &data) { + return AttributeId{ + .value = data.vdocument_id().v, + .type = AttributeIdType::Pattern, + }; + }); +} + +[[nodiscard]] MTPStarGiftAttributeId AttributeToTL(AttributeId id) { + switch (id.type) { + case AttributeIdType::Backdrop: + return MTP_starGiftAttributeIdBackdrop( + MTP_int(int32(uint32(id.value)))); + case AttributeIdType::Model: + return MTP_starGiftAttributeIdModel(MTP_long(id.value)); + case AttributeIdType::Pattern: + return MTP_starGiftAttributeIdPattern(MTP_long(id.value)); + } + Unexpected("Invalid attribute id type"); +} + +[[nodiscard]] AttributeId IdFor(const Data::UniqueGiftBackdrop &value) { + return { + .value = uint64(uint32(value.id)), + .type = AttributeIdType::Backdrop, + }; +} + +[[nodiscard]] AttributeId IdFor(const Data::UniqueGiftModel &value) { + return { .value = value.document->id, .type = AttributeIdType::Model }; +} + +[[nodiscard]] AttributeId IdFor(const Data::UniqueGiftPattern &value) { + return { .value = value.document->id, .type = AttributeIdType::Pattern }; +} + [[nodiscard]] bool SortForBirthday(not_null peer) { const auto user = peer->asUser(); if (!user) { @@ -948,6 +1059,405 @@ void PreviewWrap::paintEvent(QPaintEvent *e) { return result; } +[[nodiscard]] Text::String ResaleTabText(QString text) { + auto result = Text::String(); + result.setMarkedText( + st::semiboldTextStyle, + TextWithEntities{ text }.append( + Ui::Text::IconEmoji(&st::giftBoxResaleTabsDropdown)), + kMarkupTextOptions); + return result; +} + +[[nodiscard]] Text::String SortModeText(ResaleSort mode) { + if (mode == ResaleSort::Number) { + return ResaleTabText(tr::lng_gift_resale_number(tr::now)); + } else if (mode == ResaleSort::Price) { + return ResaleTabText(tr::lng_gift_resale_price(tr::now)); + } + return ResaleTabText(tr::lng_gift_resale_date(tr::now)); +} + +struct ResaleTabs { + rpl::producer filter; + object_ptr widget; +}; +[[nodiscard]] ResaleTabs MakeResaleTabs( + not_null window, + not_null peer, + const ResaleGiftsDescriptor &info, + rpl::producer filter) { + auto widget = object_ptr((QWidget*)nullptr); + const auto raw = widget.data(); + + struct Button { + QRect geometry; + Text::String text; + }; + struct State { + rpl::variable filter; + rpl::variable fullWidth; + std::vector