diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml new file mode 100644 index 000000000..ebfb141e6 --- /dev/null +++ b/.github/workflows/mac.yml @@ -0,0 +1,432 @@ +name: MacOS. + +on: + push: + paths-ignore: + - 'docs/**' + - '*.md' + pull_request: + paths-ignore: + - 'docs/**' + - '*.md' + +jobs: + + macos: + name: MacOS + runs-on: macos-latest + + strategy: + matrix: + defines: + - "" + env: + MIN_MAC: "-mmacosx-version-min=10.12" + UNGUARDED: "-Werror=unguarded-availability-new" + GIT: "https://github.com" + PREFIX: "/usr/local/macos" + MACOSX_DEPLOYMENT_TARGET: "10.12" + XZ: "xz-5.0.5" + QT: "5_12_5" + OPENSSL_VER: "1_1_1" + QT_PREFIX: "/usr/local/desktop-app/Qt-5.12.5" + LIBICONV_VER: "libiconv-1.15" + UPLOAD_ARTIFACT: "false" + MANUAL_CACHING: "1" + DOC_PATH: "docs/building-xcode.md" + steps: + - name: Get repository name. + run: echo ::set-env name=REPO_NAME::${GITHUB_REPOSITORY##*/} + + - name: Clone. + uses: actions/checkout@v1 + with: + submodules: recursive + + - name: First set up. + run: | + cd .. + mv $REPO_NAME temp + mkdir $REPO_NAME + mv temp $REPO_NAME/$REPO_NAME + cd $REPO_NAME + + brew install automake fdk-aac lame libass libtool libvorbis libvpx \ + ninja opus sdl shtool texi2html theora x264 xvid yasm pkg-config + + sudo xcode-select -s /Applications/Xcode.app/Contents/Developer + + xcodebuild -version > CACHE_KEY.txt + echo $MIN_MAC >> CACHE_KEY.txt + echo $PREFIX >> CACHE_KEY.txt + echo $MANUAL_CACHING >> CACHE_KEY.txt + echo ::set-env name=CACHE_KEY::`md5 -q CACHE_KEY.txt` + + echo ::add-path::$PWD/Libraries/depot_tools + + mkdir -p Libraries/macos + cd Libraries/macos + echo ::set-env name=LibrariesPath::`pwd` + + - name: Range-v3. + run: | + echo "Find necessary branch from doc." + cloneRange=$(grep -A 1 "range-v3" $REPO_NAME/$DOC_PATH | sed -n 1p) + cd $LibrariesPath + echo $cloneRange + eval $cloneRange + + - name: Patches. + run: | + echo "Find necessary commit from doc." + checkoutCommit=$(grep -A 1 "cd patches" $REPO_NAME/$DOC_PATH | sed -n 2p) + cd $LibrariesPath + git clone $GIT/desktop-app/patches.git + cd Patches + eval $checkoutCommit + + - name: XZ. + run: | + cd $LibrariesPath + + wget https://tukaani.org/xz/$XZ.tar.gz + tar -xvzf $XZ.tar.gz + cd $XZ + CFLAGS="$MIN_MAC" LDFLAGS="$MIN_MAC" ./configure --prefix=$PREFIX + make -j$(nproc) + sudo make install + + - name: Zlib. + run: | + cd $LibrariesPath + + git clone $GIT/desktop-app/zlib.git + cd zlib + CFLAGS="$MIN_MAC $UNGUARDED" LDFLAGS="$MIN_MAC" ./configure + make -j$(nproc) + sudo make install + + - name: OpenSSL cache. + id: cache-openssl + uses: actions/cache@v1 + with: + path: ${{ env.LibrariesPath }}/openssl_${{ env.OPENSSL_VER }} + key: ${{ runner.OS }}-${{ env.OPENSSL_VER }}-${{ env.CACHE_KEY }} + - name: OpenSSL. + if: steps.cache-openssl.outputs.cache-hit != 'true' + run: | + cd $LibrariesPath + + git clone $GIT/openssl/openssl openssl_$OPENSSL_VER + cd openssl_$OPENSSL_VER + git checkout OpenSSL_"$OPENSSL_VER"-stable + ./Configure \ + --prefix=$PREFIX \ + darwin64-x86_64-cc \ + -static \ + $MIN_MAC + make build_libs -j$(nproc) + + - name: Opus cache. + id: cache-opus + uses: actions/cache@v1 + with: + path: ${{ env.LibrariesPath }}/opus + key: ${{ runner.OS }}-opus-${{ env.CACHE_KEY }} + - name: Opus. + if: steps.cache-opus.outputs.cache-hit != 'true' + run: | + cd $LibrariesPath + + git clone $GIT/xiph/opus + cd opus + git checkout v1.3 + ./autogen.sh + CFLAGS="$MIN_MAC $UNGUARDED" CPPFLAGS="$MIN_MAC $UNGUARDED" LDFLAGS="$MIN_MAC" ./configure --prefix=$PREFIX + make -j$(nproc) + - name: Opus install. + run: | + cd $LibrariesPath/opus + sudo make install + + - name: Libiconv cache. + id: cache-libiconv + uses: actions/cache@v1 + with: + path: ${{ env.LibrariesPath }}/${{ env.LIBICONV_VER }} + key: ${{ runner.OS }}-${{ env.LIBICONV_VER }}-${{ env.CACHE_KEY }} + - name: Libiconv. + if: steps.cache-libiconv.outputs.cache-hit != 'true' + run: | + cd $LibrariesPath + + wget https://ftp.gnu.org/pub/gnu/libiconv/"$LIBICONV_VER".tar.gz + tar -xvzf "$LIBICONV_VER".tar.gz + cd $LIBICONV_VER + CFLAGS="$MIN_MAC $UNGUARDED" CPPFLAGS="$MIN_MAC $UNGUARDED" LDFLAGS="$MIN_MAC" ./configure --enable-static --prefix=$PREFIX + make -j$(nproc) + - name: Libiconv install. + run: | + cd $LibrariesPath/$LIBICONV_VER + sudo make install + + - name: FFmpeg cache. + id: cache-ffmpeg + uses: actions/cache@v1 + with: + path: ${{ env.LibrariesPath }}/ffmpeg + key: ${{ runner.OS }}-ffmpeg-${{ env.CACHE_KEY }} + - name: FFmpeg. + if: steps.cache-ffmpeg.outputs.cache-hit != 'true' + run: | + cd $LibrariesPath + + git clone $GIT/FFmpeg/FFmpeg.git ffmpeg + cd ffmpeg + git checkout release/3.4 + CFLAGS=`freetype-config --cflags` + LDFLAGS=`freetype-config --libs` + PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/usr/X11/lib/pkgconfig + + ./configure --prefix=/usr/local \ + --extra-cflags="$MIN_MAC $UNGUARDED" \ + --extra-cxxflags="$MIN_MAC $UNGUARDED" \ + --extra-ldflags="$MIN_MAC" \ + --enable-protocol=file --enable-libopus \ + --disable-programs \ + --disable-doc \ + --disable-network \ + --disable-everything \ + --enable-hwaccel=h264_videotoolbox \ + --enable-hwaccel=hevc_videotoolbox \ + --enable-hwaccel=mpeg1_videotoolbox \ + --enable-hwaccel=mpeg2_videotoolbox \ + --enable-hwaccel=mpeg4_videotoolbox \ + --enable-decoder=aac \ + --enable-decoder=aac_at \ + --enable-decoder=aac_fixed \ + --enable-decoder=aac_latm \ + --enable-decoder=aasc \ + --enable-decoder=alac \ + --enable-decoder=alac_at \ + --enable-decoder=flac \ + --enable-decoder=gif \ + --enable-decoder=h264 \ + --enable-decoder=hevc \ + --enable-decoder=mp1 \ + --enable-decoder=mp1float \ + --enable-decoder=mp2 \ + --enable-decoder=mp2float \ + --enable-decoder=mp3 \ + --enable-decoder=mp3adu \ + --enable-decoder=mp3adufloat \ + --enable-decoder=mp3float \ + --enable-decoder=mp3on4 \ + --enable-decoder=mp3on4float \ + --enable-decoder=mpeg4 \ + --enable-decoder=msmpeg4v2 \ + --enable-decoder=msmpeg4v3 \ + --enable-decoder=opus \ + --enable-decoder=pcm_alaw \ + --enable-decoder=pcm_alaw_at \ + --enable-decoder=pcm_f32be \ + --enable-decoder=pcm_f32le \ + --enable-decoder=pcm_f64be \ + --enable-decoder=pcm_f64le \ + --enable-decoder=pcm_lxf \ + --enable-decoder=pcm_mulaw \ + --enable-decoder=pcm_mulaw_at \ + --enable-decoder=pcm_s16be \ + --enable-decoder=pcm_s16be_planar \ + --enable-decoder=pcm_s16le \ + --enable-decoder=pcm_s16le_planar \ + --enable-decoder=pcm_s24be \ + --enable-decoder=pcm_s24daud \ + --enable-decoder=pcm_s24le \ + --enable-decoder=pcm_s24le_planar \ + --enable-decoder=pcm_s32be \ + --enable-decoder=pcm_s32le \ + --enable-decoder=pcm_s32le_planar \ + --enable-decoder=pcm_s64be \ + --enable-decoder=pcm_s64le \ + --enable-decoder=pcm_s8 \ + --enable-decoder=pcm_s8_planar \ + --enable-decoder=pcm_u16be \ + --enable-decoder=pcm_u16le \ + --enable-decoder=pcm_u24be \ + --enable-decoder=pcm_u24le \ + --enable-decoder=pcm_u32be \ + --enable-decoder=pcm_u32le \ + --enable-decoder=pcm_u8 \ + --enable-decoder=pcm_zork \ + --enable-decoder=vorbis \ + --enable-decoder=wavpack \ + --enable-decoder=wmalossless \ + --enable-decoder=wmapro \ + --enable-decoder=wmav1 \ + --enable-decoder=wmav2 \ + --enable-decoder=wmavoice \ + --enable-encoder=libopus \ + --enable-parser=aac \ + --enable-parser=aac_latm \ + --enable-parser=flac \ + --enable-parser=h264 \ + --enable-parser=hevc \ + --enable-parser=mpeg4video \ + --enable-parser=mpegaudio \ + --enable-parser=opus \ + --enable-parser=vorbis \ + --enable-demuxer=aac \ + --enable-demuxer=flac \ + --enable-demuxer=gif \ + --enable-demuxer=h264 \ + --enable-demuxer=hevc \ + --enable-demuxer=m4v \ + --enable-demuxer=mov \ + --enable-demuxer=mp3 \ + --enable-demuxer=ogg \ + --enable-demuxer=wav \ + --enable-muxer=ogg \ + --enable-muxer=opus + + make -j$(nproc) + - name: FFmpeg install. + run: | + cd $LibrariesPath/ffmpeg + sudo make install + + - name: OpenAL Soft. + run: | + cd $LibrariesPath + + git clone $GIT/kcat/openal-soft.git + cd openal-soft + git checkout openal-soft-1.19.1 + cd build + + CFLAGS="$UNGUARDED" CPPFLAGS="$UNGUARDED" cmake \ + -D CMAKE_INSTALL_PREFIX:PATH=$PREFIX \ + -D ALSOFT_EXAMPLES=OFF \ + -D LIBTYPE:STRING=STATIC \ + -D CMAKE_OSX_DEPLOYMENT_TARGET:STRING=$MACOSX_DEPLOYMENT_TARGET .. + + make -j$(nproc) + sudo make install + + - name: Crashpad cache. + id: cache-crashpad + uses: actions/cache@v1 + with: + path: ${{ env.LibrariesPath }}/crashpad + key: ${{ runner.OS }}-crashpad-${{ env.CACHE_KEY }}-${{ hashFiles('**/crashpad.diff') }}-${{ hashFiles('**/mini_chromium.diff') }} + - name: Crashpad. + if: steps.cache-crashpad.outputs.cache-hit != 'true' + run: | + cd Libraries + echo Install GYP for Crashpad. + git clone https://chromium.googlesource.com/external/gyp + git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git + cd gyp + git checkout 9f2a7bb1 + git apply $LibrariesPath/patches/gyp.diff + ./setup.py build + sudo ./setup.py install + + cd $LibrariesPath + + git clone https://chromium.googlesource.com/crashpad/crashpad.git + cd crashpad + git checkout feb3aa3923 + git apply ../patches/crashpad.diff + cd third_party/mini_chromium + git clone https://chromium.googlesource.com/chromium/mini_chromium + cd mini_chromium + git checkout 7c5b0c1ab4 + git apply ../../../../patches/mini_chromium.diff + cd ../../gtest + git clone https://chromium.googlesource.com/external/github.com/google/googletest gtest + cd gtest + git checkout d62d6c6556 + cd ../../.. + + build/gyp_crashpad.py -Dmac_deployment_target=10.10 + ninja -C out/Debug + + - name: Qt 5.12.5 cache. + id: cache-qt + uses: actions/cache@v1 + with: + path: ${{ env.LibrariesPath }}/qt-cache + key: ${{ runner.OS }}-qt-${{ env.CACHE_KEY }}-${{ hashFiles('**/qtbase_5_12_5.diff') }} + - name: Use cached Qt 5.12.5. + if: steps.cache-qt.outputs.cache-hit == 'true' + run: | + cd $LibrariesPath + mv qt-cache Qt-5.12.5 + sudo mkdir -p $QT_PREFIX + sudo mv -f Qt-5.12.5 /usr/local/desktop-app/ + - name: Build Qt 5.12.5. + if: steps.cache-qt.outputs.cache-hit != 'true' + run: | + cd $LibrariesPath + + git clone git://code.qt.io/qt/qt5.git qt$QT + cd qt$QT + perl init-repository --module-subset=qtbase,qtimageformats + git checkout v5.12.5 + git submodule update qtbase + git submodule update qtimageformats + cd qtbase + git apply ../../patches/qtbase_$QT.diff + cd .. + + ./configure \ + -prefix "$QT_PREFIX" \ + -debug \ + -force-debug-info \ + -opensource \ + -confirm-license \ + -static \ + -opengl desktop \ + -no-openssl \ + -securetransport \ + -nomake examples \ + -nomake tests \ + -platform macx-clang + + make -j$(nproc) + sudo make install + + make clean + cp -r $QT_PREFIX $LibrariesPath/qt-cache + + - name: Build Telegram Desktop. + run: | + cd $REPO_NAME/Telegram + + DEFINE="" + if [ -n "${{ matrix.defines }}" ]; then + DEFINE="-D ${{ matrix.defines }}=ON" + echo Define from matrix: $DEFINE + fi + + ./configure.sh -D TDESKTOP_API_TEST=ON -D DESKTOP_APP_USE_PACKAGED=OFF $DEFINE + + cd ../out + + xcoderun='xcodebuild build -project Telegram.xcodeproj -scheme Telegram -destination "platform=macOS,arch=x86_64" -configuration Debug' + bash -c "$xcoderun" || bash -c "$xcoderun" || bash -c "$xcoderun" + + - name: Move artifact. + if: env.UPLOAD_ARTIFACT == 'true' + run: | + cd $REPO_NAME/out/Debug + mkdir artifact + mv Telegram.app artifact/ + mv Updater artifact/ + - uses: actions/upload-artifact@master + if: env.UPLOAD_ARTIFACT == 'true' + name: Upload artifact. + with: + name: Telegram + path: $REPO_NAME\out\Debug\artifact\ \ No newline at end of file diff --git a/.github/workflows/win.yml b/.github/workflows/win.yml new file mode 100644 index 000000000..46b83e924 --- /dev/null +++ b/.github/workflows/win.yml @@ -0,0 +1,342 @@ +name: Windows. + +on: + push: + paths-ignore: + - 'docs/**' + - '*.md' + pull_request: + paths-ignore: + - 'docs/**' + - '*.md' + +jobs: + + windows: + name: Windows + runs-on: windows-latest + + strategy: + matrix: + defines: + - "" + env: + SDK: "10.0.18362.0" + VC: "call vcvars32.bat && cd Libraries" + PY2: 'C:\hostedtoolcache\windows\Python\2.7.16\x64' + GIT: "https://github.com" + QT: "5_12_5" + OPENSSL_VER: "1_1_1" + UPLOAD_ARTIFACT: "false" + MANUAL_CACHING: "1" + DOC_PATH: "docs/building-msvc.md" + steps: + - name: Get repository name. + shell: bash + run: echo ::set-env name=REPO_NAME::${GITHUB_REPOSITORY##*/} + + - name: Clone. + uses: actions/checkout@v1 + with: + submodules: recursive + + - name: Set up environment variables. + shell: cmd + run: | + cd .. + move %REPO_NAME% temp + mkdir %REPO_NAME% + move temp %REPO_NAME%/%REPO_NAME% + cd %REPO_NAME% + + echo ::add-path::C:\Strawberry\perl\bin\ + echo ::add-path::"%programfiles%\NASM" + + C: + cd "%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\" + echo ::add-path::%cd% + + call vcvars32.bat + D: + cd %GITHUB_WORKSPACE% + msbuild -version > CACHE_KEY.txt + echo %MANUAL_CACHING% >> CACHE_KEY.txt + + mkdir Libraries + cd Libraries + echo ::set-env name=LibrariesPath::%cd% + + - name: Generate cache key. + shell: bash + run: | + echo ::set-env name=CACHE_KEY::`md5sum CACHE_KEY.txt | awk '{ print $1 }'` + + - name: Choco installs. + run: | + choco install --no-progress -y nasm yasm jom ninja + + - name: Range-v3. + shell: bash + run: | + echo "Find necessary branch from doc." + cloneRange=$(grep -A 1 "range-v3" $REPO_NAME/$DOC_PATH | sed -n 1p) + cd $LibrariesPath + echo $cloneRange + eval $cloneRange + + - name: Patches. + shell: bash + run: | + echo "Find necessary commit from doc." + checkoutCommit=$(grep -A 1 "cd patches" $REPO_NAME/$DOC_PATH | sed -n 2p) + cd $LibrariesPath + git clone $GIT/desktop-app/patches.git + cd Patches + eval $checkoutCommit + + - name: LZMA. + shell: cmd + run: | + %VC% + + git clone %GIT%/telegramdesktop/lzma.git + cd lzma + cd C\Util\LzmaLib + msbuild -m LzmaLib.sln /property:Configuration=Debug + + - name: OpenSSL cache. + id: cache-openssl + uses: actions/cache@v1 + with: + path: ${{ env.LibrariesPath }}/openssl_${{ env.OPENSSL_VER }} + key: ${{ runner.OS }}-${{ env.CACHE_KEY }}-${{ env.OPENSSL_VER }} + - name: OpenSSL. + if: steps.cache-openssl.outputs.cache-hit != 'true' + shell: cmd + run: | + %VC% + + git clone %GIT%/openssl/openssl.git openssl_%OPENSSL_VER% + cd openssl_%OPENSSL_VER% + git checkout OpenSSL_%OPENSSL_VER%-stable + perl Configure no-shared debug-VC-WIN32 + nmake + mkdir out32.dbg + move libcrypto.lib out32.dbg + move libssl.lib out32.dbg + move ossl_static.pdb out32.dbg\ossl_static + nmake clean + move out32.dbg\ossl_static out32.dbg\ossl_static.pdb + perl Configure no-shared VC-WIN32 + nmake + mkdir out32 + move libcrypto.lib out32 + move libssl.lib out32 + move ossl_static.pdb out32 + + rmdir /S /Q test + + - name: Zlib. + shell: cmd + run: | + %VC% + + git clone %GIT%/telegramdesktop/zlib.git + cd zlib + git checkout tdesktop + cd contrib\vstudio\vc14 + msbuild -m zlibstat.vcxproj /property:Configuration=Debug + + - name: OpenAL Soft cache. + id: cache-openal + uses: actions/cache@v1 + with: + path: ${{ env.LibrariesPath }}/openal-soft + key: ${{ runner.OS }}-openal-soft-${{ env.CACHE_KEY }} + - name: OpenAL Soft. + shell: cmd + if: steps.cache-openal.outputs.cache-hit != 'true' + run: | + %VC% + + git clone %GIT%/telegramdesktop/openal-soft.git + cd openal-soft + git checkout fix_capture + cd build + cmake ^ + -G "Visual Studio 16 2019" ^ + -A Win32 ^ + -D LIBTYPE:STRING=STATIC ^ + -D FORCE_STATIC_VCRT:STRING=ON .. + + msbuild -m OpenAL.vcxproj /property:Configuration=Debug + + - name: Breakpad cache. + id: cache-breakpad + uses: actions/cache@v1 + with: + path: ${{ env.LibrariesPath }}/breakpad + key: ${{ runner.OS }}-breakpad-${{ env.CACHE_KEY }}-${{ hashFiles('**/breakpad.diff') }} + - name: Breakpad. + env: + GYP_MSVS_OVERRIDE_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\' + GYP_MSVS_VERSION: 2019 + shell: cmd + if: steps.cache-breakpad.outputs.cache-hit != 'true' + run: | + cd %LibrariesPath% + + git clone %GIT%/telegramdesktop/gyp.git + cd gyp + SET PATH=%PY2%;%cd%;%PATH% + git checkout tdesktop + + cd %LibrariesPath% + + git clone %GIT%/google/breakpad + cd breakpad + git checkout a1dbcdcb43 + git apply ../patches/breakpad.diff + cd src + git clone %GIT%/google/googletest testing + cd client\windows + call gyp --no-circular-check breakpad_client.gyp --format=ninja + cd ..\.. + ninja -C out/Debug common crash_generation_client exception_handler + ninja -C out/Release common crash_generation_client exception_handler + cd tools\windows\dump_syms + call gyp dump_syms.gyp + + call vcvars32.bat + msbuild -m dump_syms.vcxproj /property:Configuration=Release + + - name: Opus cache. + id: cache-opus + uses: actions/cache@v1 + with: + path: ${{ env.LibrariesPath }}/opus + key: ${{ runner.OS }}-opus-${{ env.CACHE_KEY }} + - name: Opus. + shell: cmd + run: | + %VC% + + git clone %GIT%/telegramdesktop/opus.git + cd opus + git checkout tdesktop + cd win32\VS2015 + msbuild -m opus.sln /property:Configuration=Debug /property:Platform="Win32" + msbuild -m opus.sln /property:Configuration=Release /property:Platform="Win32" + + - name: FFmpeg cache. + id: cache-ffmpeg + uses: actions/cache@v1 + with: + path: ${{ env.LibrariesPath }}/ffmpeg + key: ${{ runner.OS }}-ffmpeg-${{ env.CACHE_KEY }}-${{ hashFiles('**/build_ffmpeg_win.sh') }} + - name: FFmpeg. + if: steps.cache-ffmpeg.outputs.cache-hit != 'true' + shell: cmd + run: | + %VC% + choco install --no-progress -y msys2 + + git clone %GIT%/FFmpeg/FFmpeg.git ffmpeg + cd ffmpeg + git checkout release/3.4 + set CHERE_INVOKING=enabled_from_arguments + set MSYS2_PATH_TYPE=inherit + call c:\tools\msys64\usr\bin\bash --login ../../%REPO_NAME%/Telegram/Patches/build_ffmpeg_win.sh + + - name: Qt 5.12.5 cache. + id: cache-qt + uses: actions/cache@v1 + with: + path: ${{ env.LibrariesPath }}/Qt-5.12.5 + key: ${{ runner.OS }}-qt-${{ env.CACHE_KEY }}-${{ hashFiles('**/qtbase_5_12_5.diff') }} + - name: Configure Qt 5.12.5. + if: steps.cache-qt.outputs.cache-hit != 'true' + shell: cmd + run: | + %VC% + + git clone git://code.qt.io/qt/qt5.git qt_%QT% + cd qt_%QT% + perl init-repository --module-subset=qtbase,qtimageformats + git checkout v5.12.5 + git submodule update qtbase + git submodule update qtimageformats + cd qtbase + git apply ../../patches/qtbase_%QT%.diff + cd .. + + SET SSL=%LibrariesPath%\openssl_1_1_1 + SET LIBS=libcrypto.lib Ws2_32.lib Gdi32.lib Advapi32.lib Crypt32.lib User32.lib + + configure ^ + -prefix "%LibrariesPath%\Qt-5.12.5" ^ + -debug ^ + -force-debug-info ^ + -opensource ^ + -confirm-license ^ + -static ^ + -static-runtime -I "%SSL%\include" ^ + -no-opengl ^ + -openssl-linked ^ + OPENSSL_LIBS_DEBUG="%SSL%\out32.dbg\libssl.lib %SSL%\out32.dbg\%LIBS%" ^ + OPENSSL_LIBS_RELEASE="%SSL%\out32\libssl.lib %SSL%\out32\%LIBS%" ^ + -mp ^ + -nomake examples ^ + -nomake tests ^ + -platform win32-msvc + - name: Build Qt 5.12.5. + if: steps.cache-qt.outputs.cache-hit != 'true' + shell: cmd + run: | + %VC% + cd qt_%QT% + + jom -j%NUMBER_OF_PROCESSORS% + jom -j%NUMBER_OF_PROCESSORS% install + + cd .. + rmdir /S /Q qt_%QT% + + - name: Read defines. + shell: bash + run: | + DEFINE="" + if [ -n "${{ matrix.defines }}" ]; then + DEFINE="-D ${{ matrix.defines }}=ON" + echo Define from matrix: $DEFINE + fi + echo "::set-env name=TDESKTOP_BUILD_DEFINE::$DEFINE" + + - name: Build Telegram Desktop. + shell: cmd + run: | + cd %REPO_NAME%\Telegram + + call configure.bat ^ + -D TDESKTOP_API_TEST=ON ^ + -D DESKTOP_APP_USE_PACKAGED=OFF ^ + %TDESKTOP_BUILD_DEFINE% ^ + -DCMAKE_SYSTEM_VERSION=%SDK% + + call vcvars32.bat + cd ..\out + msbuild -m Telegram.sln /nologo /p:Configuration=Debug,Platform=Win32 + + - name: Move artifact. + if: env.UPLOAD_ARTIFACT == 'true' + run: | + cd %REPO_NAME%\out\Debug + mkdir artifact + move Telegram.exe artifact/ + move Updater.exe artifact/ + - uses: actions/upload-artifact@master + name: Upload artifact. + if: env.UPLOAD_ARTIFACT == 'true' + with: + name: Telegram + path: ${{ env.REPO_NAME }}\out\Debug\artifact\ \ No newline at end of file diff --git a/.gitignore b/.gitignore index baa529015..14f0e1a5d 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,7 @@ stage /snap/plugins/__pycache__ /Telegram/*.user.* +*.txt.user *.pro.user /Linux/ /Telegram/Makefile diff --git a/.gitmodules b/.gitmodules index 1ad23f5b7..f206a48c7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -49,3 +49,18 @@ [submodule "Telegram/lib_spellcheck"] path = Telegram/lib_spellcheck url = https://github.com/desktop-app/lib_spellcheck +[submodule "Telegram/lib_storage"] + path = Telegram/lib_storage + url = https://github.com/desktop-app/lib_storage.git +[submodule "cmake"] + path = cmake + url = https://github.com/desktop-app/cmake_helpers.git +[submodule "Telegram/ThirdParty/expected"] + path = Telegram/ThirdParty/expected + url = https://github.com/TartanLlama/expected +[submodule "Telegram/ThirdParty/QR"] + path = Telegram/ThirdParty/QR + url = https://github.com/nayuki/QR-Code-generator +[submodule "Telegram/lib_qr"] + path = Telegram/lib_qr + url = https://github.com/desktop-app/lib_qr.git diff --git a/.travis.yml b/.travis.yml index 983351096..d5b16eaea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,12 +43,14 @@ addons: - liblzma-dev - libopus-dev - libpulse-dev + - libenchant-dev - libssl-dev - libdee-dev - libva-dev - libvdpau-dev - libxcb-xkb-dev - libxkbcommon-dev + - libatspi2.0-dev - lintian - quilt - valac diff --git a/.travis/build.sh b/.travis/build.sh index 91d9e06b1..6033b51d3 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -17,7 +17,7 @@ XKB_PATH="$BUILD/libxkbcommon" XKB_CACHE_VERSION="3" QT_PATH="$BUILD/qt" -QT_CACHE_VERSION="4" +QT_CACHE_VERSION="5" QT_PATCH="$EXTERNAL/patches/qtbase_${QT_VERSION//\./_}.diff" BREAKPAD_PATH="$BUILD/breakpad" @@ -694,7 +694,6 @@ buildTelegram() { -Dlinux_path_qt=$QT_PATH \ -Dlinux_path_breakpad=$BREAKPAD_PATH \ -Dlinux_path_libexif_lib=/usr/local/lib \ - -Dlinux_path_opus_include=/usr/include/opus \ -Dlinux_lib_ssl=-lssl \ -Dlinux_lib_crypto=-lcrypto \ -Dlinux_lib_icu=-licuuc\ -licutu\ -licui18n \ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..d427ad059 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,37 @@ +# This file is part of Telegram Desktop, +# the official desktop application for the Telegram messaging service. +# +# For license and copyright information please follow this link: +# https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL + +cmake_minimum_required(VERSION 3.16) +cmake_policy(SET CMP0076 NEW) +cmake_policy(SET CMP0091 NEW) + +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + +include(cmake/validate_special_target.cmake) +include(cmake/version.cmake) +desktop_app_parse_version(Telegram/build/version) + +project(Telegram + LANGUAGES C CXX + VERSION ${desktop_app_version_cmake} + DESCRIPTION "Official Telegram Desktop messenger" + HOMEPAGE_URL "https://desktop.telegram.org" +) +set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Telegram) + +include(cmake/variables.cmake) +include(cmake/nice_target_sources.cmake) +include(cmake/target_link_static_libraries.cmake) +include(cmake/target_link_frameworks.cmake) +include(cmake/init_target.cmake) +include(cmake/generate_target.cmake) + +include(cmake/options.cmake) + +include(cmake/external/qt/package.cmake) + +add_subdirectory(cmake) +add_subdirectory(Telegram) diff --git a/LEGAL b/LEGAL index 89d406468..34fe8e674 100644 --- a/LEGAL +++ b/LEGAL @@ -1,7 +1,7 @@ This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. -Copyright (c) 2014-2019 John Preston, https://desktop.telegram.org +Copyright (c) 2014-2020 The Telegram Desktop Authors. Telegram Desktop is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt new file mode 100644 index 000000000..5c89cc19a --- /dev/null +++ b/Telegram/CMakeLists.txt @@ -0,0 +1,1187 @@ +# This file is part of Telegram Desktop, +# the official desktop application for the Telegram messaging service. +# +# For license and copyright information please follow this link: +# https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL + +add_executable(Telegram WIN32 MACOSX_BUNDLE) +init_target(Telegram) + +add_subdirectory(lib_rpl) +add_subdirectory(lib_crl) +add_subdirectory(lib_base) +add_subdirectory(lib_ui) +add_subdirectory(lib_tl) +if (NOT DESKTOP_APP_DISABLE_SPELLCHECK) + add_subdirectory(lib_spellcheck) +endif() +add_subdirectory(lib_storage) +add_subdirectory(lib_lottie) +add_subdirectory(lib_qr) +add_subdirectory(codegen) + +include(lib_ui/cmake/generate_styles.cmake) +include(cmake/generate_lang.cmake) +include(cmake/generate_numbers.cmake) + +get_filename_component(src_loc SourceFiles REALPATH) +get_filename_component(res_loc Resources REALPATH) + +include(cmake/telegram_options.cmake) +include(cmake/lib_export.cmake) +include(cmake/lib_ffmpeg.cmake) +include(cmake/lib_mtproto.cmake) +include(cmake/lib_scheme.cmake) +include(cmake/lib_tgvoip.cmake) + +set(style_files + boxes/boxes.style + calls/calls.style + dialogs/dialogs.style + export/view/export.style + history/history.style + info/info.style + intro/intro.style + media/view/mediaview.style + media/player/media_player.style + overview/overview.style + passport/passport.style + profile/profile.style + settings/settings.style + chat_helpers/chat_helpers.style + window/window.style +) + +set(dependent_style_files + ${submodules_loc}/lib_ui/ui/colors.palette + ${submodules_loc}/lib_ui/ui/basic.style + ${submodules_loc}/lib_ui/ui/layers/layers.style + ${submodules_loc}/lib_ui/ui/widgets/widgets.style +) + +generate_styles(Telegram ${src_loc} "${style_files}" "${dependent_style_files}") +generate_lang(Telegram ${res_loc}/langs/lang.strings) +generate_numbers(Telegram ${res_loc}/numbers.txt) + +set_target_properties(Telegram PROPERTIES AUTOMOC ON AUTORCC ON) + +if (DESKTOP_APP_USE_PACKAGED) + set(CMAKE_THREAD_PREFER_PTHREAD TRUE) + find_package(Threads) + + target_link_libraries(Telegram + PRIVATE + ${CMAKE_DL_LIBS} + Threads::Threads + ) +endif() + +target_link_libraries(Telegram +PRIVATE + tdesktop::lib_mtproto + tdesktop::lib_scheme + tdesktop::lib_export + desktop-app::lib_base + desktop-app::lib_crl + desktop-app::lib_ui + desktop-app::lib_tl + desktop-app::lib_storage + desktop-app::lib_lottie + desktop-app::lib_qr + desktop-app::lib_ffmpeg + desktop-app::external_lz4 + desktop-app::external_rlottie + desktop-app::external_zlib + desktop-app::external_qt + desktop-app::external_qr_code_generator + desktop-app::external_crash_reports + desktop-app::external_auto_updates + tdesktop::lib_tgvoip + desktop-app::external_openssl + desktop-app::external_openal +) + +if (NOT DESKTOP_APP_USE_PACKAGED) + target_link_libraries(Telegram PRIVATE desktop-app::external_opus) +endif() + +target_precompile_headers(Telegram PRIVATE ${src_loc}/stdafx.h) +nice_target_sources(Telegram ${src_loc} +PRIVATE + ${style_files} + + api/api_common.h + api/api_hash.h + api/api_self_destruct.cpp + api/api_self_destruct.h + api/api_sending.cpp + api/api_sending.h + api/api_sensitive_content.cpp + api/api_sensitive_content.h + api/api_single_message_search.cpp + api/api_single_message_search.h + api/api_text_entities.cpp + api/api_text_entities.h + boxes/peers/add_participants_box.cpp + boxes/peers/add_participants_box.h + boxes/peers/edit_contact_box.cpp + boxes/peers/edit_contact_box.h + boxes/peers/edit_linked_chat_box.cpp + boxes/peers/edit_linked_chat_box.h + boxes/peers/edit_participant_box.cpp + boxes/peers/edit_participant_box.h + boxes/peers/edit_participants_box.cpp + boxes/peers/edit_participants_box.h + boxes/peers/edit_peer_info_box.cpp + boxes/peers/edit_peer_info_box.h + boxes/peers/edit_peer_type_box.cpp + boxes/peers/edit_peer_type_box.h + boxes/peers/edit_peer_history_visibility_box.cpp + boxes/peers/edit_peer_history_visibility_box.h + boxes/peers/edit_peer_permissions_box.cpp + boxes/peers/edit_peer_permissions_box.h + boxes/about_box.cpp + boxes/about_box.h + boxes/abstract_box.cpp + boxes/abstract_box.h + boxes/add_contact_box.cpp + boxes/add_contact_box.h + boxes/auto_lock_box.cpp + boxes/auto_lock_box.h + boxes/auto_download_box.cpp + boxes/auto_download_box.h + boxes/background_box.cpp + boxes/background_box.h + boxes/background_preview_box.cpp + boxes/background_preview_box.h + boxes/calendar_box.cpp + boxes/calendar_box.h + boxes/change_phone_box.cpp + boxes/change_phone_box.h + boxes/confirm_box.cpp + boxes/confirm_box.h + boxes/confirm_phone_box.cpp + boxes/confirm_phone_box.h + boxes/connection_box.cpp + boxes/connection_box.h + boxes/create_poll_box.cpp + boxes/create_poll_box.h + boxes/download_path_box.cpp + boxes/download_path_box.h + boxes/edit_caption_box.cpp + boxes/edit_caption_box.h + boxes/edit_color_box.cpp + boxes/edit_color_box.h + boxes/edit_privacy_box.cpp + boxes/edit_privacy_box.h + boxes/language_box.cpp + boxes/language_box.h + boxes/local_storage_box.cpp + boxes/local_storage_box.h + boxes/mute_settings_box.cpp + boxes/mute_settings_box.h + boxes/peer_list_box.cpp + boxes/peer_list_box.h + boxes/peer_list_controllers.cpp + boxes/peer_list_controllers.h + boxes/passcode_box.cpp + boxes/passcode_box.h + boxes/photo_crop_box.cpp + boxes/photo_crop_box.h + boxes/rate_call_box.cpp + boxes/rate_call_box.h + boxes/report_box.cpp + boxes/report_box.h + boxes/self_destruction_box.cpp + boxes/self_destruction_box.h + boxes/send_files_box.cpp + boxes/send_files_box.h + boxes/sessions_box.cpp + boxes/sessions_box.h + boxes/share_box.cpp + boxes/share_box.h + boxes/single_choice_box.cpp + boxes/single_choice_box.h + boxes/sticker_set_box.cpp + boxes/sticker_set_box.h + boxes/stickers_box.cpp + boxes/stickers_box.h + boxes/url_auth_box.cpp + boxes/url_auth_box.h + boxes/username_box.cpp + boxes/username_box.h + calls/calls_box_controller.cpp + calls/calls_box_controller.h + calls/calls_call.cpp + calls/calls_call.h + calls/calls_emoji_fingerprint.cpp + calls/calls_emoji_fingerprint.h + calls/calls_instance.cpp + calls/calls_instance.h + calls/calls_panel.cpp + calls/calls_panel.h + calls/calls_top_bar.cpp + calls/calls_top_bar.h + chat_helpers/bot_keyboard.cpp + chat_helpers/bot_keyboard.h + chat_helpers/emoji_keywords.cpp + chat_helpers/emoji_keywords.h + chat_helpers/emoji_list_widget.cpp + chat_helpers/emoji_list_widget.h + chat_helpers/emoji_sets_manager.cpp + chat_helpers/emoji_sets_manager.h + chat_helpers/emoji_suggestions_widget.cpp + chat_helpers/emoji_suggestions_widget.h + chat_helpers/field_autocomplete.cpp + chat_helpers/field_autocomplete.h + chat_helpers/gifs_list_widget.cpp + chat_helpers/gifs_list_widget.h + chat_helpers/message_field.cpp + chat_helpers/message_field.h + chat_helpers/stickers.cpp + chat_helpers/stickers.h + chat_helpers/stickers_emoji_pack.cpp + chat_helpers/stickers_emoji_pack.h + chat_helpers/stickers_list_widget.cpp + chat_helpers/stickers_list_widget.h + chat_helpers/tabbed_panel.cpp + chat_helpers/tabbed_panel.h + chat_helpers/tabbed_section.cpp + chat_helpers/tabbed_section.h + chat_helpers/tabbed_selector.cpp + chat_helpers/tabbed_selector.h + core/application.cpp + core/application.h + core/base_integration.cpp + core/base_integration.h + core/changelogs.cpp + core/changelogs.h + core/click_handler_types.cpp + core/click_handler_types.h + core/core_cloud_password.cpp + core/core_cloud_password.h + core/core_settings.cpp + core/core_settings.h + core/crash_report_window.cpp + core/crash_report_window.h + core/crash_reports.cpp + core/crash_reports.h + core/file_utilities.cpp + core/file_utilities.h + core/launcher.cpp + core/launcher.h + core/local_url_handlers.cpp + core/local_url_handlers.h + core/media_active_cache.h + core/mime_type.cpp + core/mime_type.h + core/sandbox.cpp + core/sandbox.h + core/shortcuts.cpp + core/shortcuts.h + core/ui_integration.cpp + core/ui_integration.h + core/update_checker.cpp + core/update_checker.h + core/utils.cpp + core/utils.h + core/version.h + data/data_abstract_structure.cpp + data/data_abstract_structure.h + data/data_auto_download.cpp + data/data_auto_download.h + data/data_chat.cpp + data/data_chat.h + data/data_channel.cpp + data/data_channel.h + data/data_channel_admins.cpp + data/data_channel_admins.h + data/data_cloud_themes.cpp + data/data_cloud_themes.h + data/data_countries.cpp + data/data_countries.h + data/data_document.cpp + data/data_document.h + data/data_document_good_thumbnail.cpp + data/data_document_good_thumbnail.h + data/data_drafts.cpp + data/data_drafts.h + data/data_folder.cpp + data/data_folder.h + # data/data_feed_messages.cpp + # data/data_feed_messages.h + data/data_file_origin.cpp + data/data_file_origin.h + data/data_flags.h + data/data_game.h + data/data_groups.cpp + data/data_groups.h + data/data_location.cpp + data/data_location.h + data/data_media_types.cpp + data/data_media_types.h + data/data_messages.cpp + data/data_messages.h + data/data_notify_settings.cpp + data/data_notify_settings.h + data/data_peer.cpp + data/data_peer.h + data/data_peer_values.cpp + data/data_peer_values.h + data/data_photo.cpp + data/data_photo.h + data/data_poll.cpp + data/data_poll.h + data/data_pts_waiter.cpp + data/data_pts_waiter.h + data/data_search_controller.cpp + data/data_search_controller.h + data/data_session.cpp + data/data_session.h + data/data_scheduled_messages.cpp + data/data_scheduled_messages.h + data/data_shared_media.cpp + data/data_shared_media.h + data/data_sparse_ids.cpp + data/data_sparse_ids.h + data/data_streaming.cpp + data/data_streaming.h + data/data_types.cpp + data/data_types.h + data/data_user.cpp + data/data_user.h + data/data_user_photos.cpp + data/data_user_photos.h + data/data_wall_paper.cpp + data/data_wall_paper.h + data/data_web_page.cpp + data/data_web_page.h + dialogs/dialogs_entry.cpp + dialogs/dialogs_entry.h + dialogs/dialogs_indexed_list.cpp + dialogs/dialogs_indexed_list.h + dialogs/dialogs_inner_widget.cpp + dialogs/dialogs_inner_widget.h + dialogs/dialogs_key.cpp + dialogs/dialogs_key.h + dialogs/dialogs_layout.cpp + dialogs/dialogs_layout.h + dialogs/dialogs_list.cpp + dialogs/dialogs_list.h + dialogs/dialogs_main_list.cpp + dialogs/dialogs_main_list.h + dialogs/dialogs_pinned_list.cpp + dialogs/dialogs_pinned_list.h + dialogs/dialogs_row.cpp + dialogs/dialogs_row.h + dialogs/dialogs_search_from_controllers.cpp + dialogs/dialogs_search_from_controllers.h + dialogs/dialogs_widget.cpp + dialogs/dialogs_widget.h + export/view/export_view_content.cpp + export/view/export_view_content.h + export/view/export_view_panel_controller.cpp + export/view/export_view_panel_controller.h + export/view/export_view_progress.cpp + export/view/export_view_progress.h + export/view/export_view_settings.cpp + export/view/export_view_settings.h + export/view/export_view_top_bar.cpp + export/view/export_view_top_bar.h + history/admin_log/history_admin_log_filter.cpp + history/admin_log/history_admin_log_filter.h + history/admin_log/history_admin_log_inner.cpp + history/admin_log/history_admin_log_inner.h + history/admin_log/history_admin_log_item.cpp + history/admin_log/history_admin_log_item.h + history/admin_log/history_admin_log_section.cpp + history/admin_log/history_admin_log_section.h + # history/feed/history_feed_section.cpp + # history/feed/history_feed_section.h + history/view/media/history_view_call.h + history/view/media/history_view_call.cpp + history/view/media/history_view_contact.h + history/view/media/history_view_contact.cpp + history/view/media/history_view_document.h + history/view/media/history_view_document.cpp + history/view/media/history_view_file.h + history/view/media/history_view_file.cpp + history/view/media/history_view_game.h + history/view/media/history_view_game.cpp + history/view/media/history_view_gif.h + history/view/media/history_view_gif.cpp + history/view/media/history_view_invoice.h + history/view/media/history_view_invoice.cpp + history/view/media/history_view_large_emoji.h + history/view/media/history_view_large_emoji.cpp + history/view/media/history_view_location.h + history/view/media/history_view_location.cpp + history/view/media/history_view_media.h + history/view/media/history_view_media.cpp + history/view/media/history_view_media_common.h + history/view/media/history_view_media_common.cpp + history/view/media/history_view_media_grouped.h + history/view/media/history_view_media_grouped.cpp + history/view/media/history_view_media_unwrapped.h + history/view/media/history_view_media_unwrapped.cpp + history/view/media/history_view_photo.h + history/view/media/history_view_photo.cpp + history/view/media/history_view_poll.h + history/view/media/history_view_poll.cpp + history/view/media/history_view_sticker.h + history/view/media/history_view_sticker.cpp + history/view/media/history_view_theme_document.h + history/view/media/history_view_theme_document.cpp + history/view/media/history_view_web_page.h + history/view/media/history_view_web_page.cpp + history/view/history_view_compose_controls.cpp + history/view/history_view_compose_controls.h + history/view/history_view_contact_status.cpp + history/view/history_view_contact_status.h + history/view/history_view_context_menu.cpp + history/view/history_view_context_menu.h + history/view/history_view_cursor_state.cpp + history/view/history_view_cursor_state.h + history/view/history_view_element.cpp + history/view/history_view_element.h + history/view/history_view_list_widget.cpp + history/view/history_view_list_widget.h + history/view/history_view_message.cpp + history/view/history_view_message.h + history/view/history_view_object.h + history/view/history_view_schedule_box.cpp + history/view/history_view_schedule_box.h + history/view/history_view_scheduled_section.cpp + history/view/history_view_scheduled_section.h + history/view/history_view_service_message.cpp + history/view/history_view_service_message.h + history/view/history_view_top_bar_widget.cpp + history/view/history_view_top_bar_widget.h + history/history.cpp + history/history.h + history/history_drag_area.cpp + history/history_drag_area.h + history/history_item.cpp + history/history_item.h + history/history_item_components.cpp + history/history_item_components.h + history/history_item_text.cpp + history/history_item_text.h + history/history_inner_widget.cpp + history/history_inner_widget.h + history/history_location_manager.cpp + history/history_location_manager.h + history/history_message.cpp + history/history_message.h + history/history_service.cpp + history/history_service.h + history/history_widget.cpp + history/history_widget.h + info/info_content_widget.cpp + info/info_content_widget.h + info/info_controller.cpp + info/info_controller.h + info/info_layer_widget.cpp + info/info_layer_widget.h + info/info_memento.cpp + info/info_memento.h + info/info_section_widget.cpp + info/info_section_widget.h + info/info_top_bar.cpp + info/info_top_bar.h + info/info_wrap_widget.cpp + info/info_wrap_widget.h + # info/channels/info_channels_widget.cpp + # info/channels/info_channels_widget.h + info/common_groups/info_common_groups_inner_widget.cpp + info/common_groups/info_common_groups_inner_widget.h + info/common_groups/info_common_groups_widget.cpp + info/common_groups/info_common_groups_widget.h + # info/feed/info_feed_channels.cpp + # info/feed/info_feed_channels.h + # info/feed/info_feed_channels_controllers.cpp + # info/feed/info_feed_channels_controllers.h + # info/feed/info_feed_cover.cpp + # info/feed/info_feed_cover.h + # info/feed/info_feed_profile_inner_widget.cpp + # info/feed/info_feed_profile_inner_widget.h + # info/feed/info_feed_profile_widget.cpp + # info/feed/info_feed_profile_widget.h + info/media/info_media_buttons.h + info/media/info_media_empty_widget.cpp + info/media/info_media_empty_widget.h + info/media/info_media_inner_widget.cpp + info/media/info_media_inner_widget.h + info/media/info_media_list_widget.cpp + info/media/info_media_list_widget.h + info/media/info_media_widget.cpp + info/media/info_media_widget.h + info/members/info_members_widget.cpp + info/members/info_members_widget.h + info/profile/info_profile_actions.cpp + info/profile/info_profile_actions.h + info/profile/info_profile_cover.cpp + info/profile/info_profile_cover.h + info/profile/info_profile_icon.cpp + info/profile/info_profile_icon.h + info/profile/info_profile_inner_widget.cpp + info/profile/info_profile_inner_widget.h + info/profile/info_profile_members.cpp + info/profile/info_profile_members.h + info/profile/info_profile_members_controllers.cpp + info/profile/info_profile_members_controllers.h + info/profile/info_profile_text.cpp + info/profile/info_profile_text.h + info/profile/info_profile_values.cpp + info/profile/info_profile_values.h + info/profile/info_profile_widget.cpp + info/profile/info_profile_widget.h + info/settings/info_settings_widget.cpp + info/settings/info_settings_widget.h + inline_bots/inline_bot_layout_internal.cpp + inline_bots/inline_bot_layout_internal.h + inline_bots/inline_bot_layout_item.cpp + inline_bots/inline_bot_layout_item.h + inline_bots/inline_bot_result.cpp + inline_bots/inline_bot_result.h + inline_bots/inline_bot_send_data.cpp + inline_bots/inline_bot_send_data.h + inline_bots/inline_results_widget.cpp + inline_bots/inline_results_widget.h + intro/intro_code.cpp + intro/intro_code.h + intro/intro_password_check.cpp + intro/intro_password_check.h + intro/intro_phone.cpp + intro/intro_phone.h + intro/intro_qr.cpp + intro/intro_qr.h + intro/intro_signup.cpp + intro/intro_signup.h + intro/intro_start.cpp + intro/intro_start.h + intro/intro_step.cpp + intro/intro_step.h + intro/intro_widget.cpp + intro/intro_widget.h + lang/lang_cloud_manager.cpp + lang/lang_cloud_manager.h + lang/lang_file_parser.cpp + lang/lang_file_parser.h + lang/lang_hardcoded.h + lang/lang_instance.cpp + lang/lang_instance.h + lang/lang_keys.cpp + lang/lang_keys.h + lang/lang_numbers_animation.cpp + lang/lang_numbers_animation.h + lang/lang_tag.cpp + lang/lang_tag.h + lang/lang_text_entity.cpp + lang/lang_text_entity.h + lang/lang_translator.cpp + lang/lang_translator.h + lang/lang_values.cpp + lang/lang_values.h + main/main_account.cpp + main/main_account.h + main/main_app_config.cpp + main/main_app_config.h + main/main_session.cpp + main/main_session.h + main/main_settings.cpp + main/main_settings.h + media/audio/media_audio.cpp + media/audio/media_audio.h + media/audio/media_audio_capture.cpp + media/audio/media_audio_capture.h + media/audio/media_audio_ffmpeg_loader.cpp + media/audio/media_audio_ffmpeg_loader.h + media/audio/media_audio_loader.cpp + media/audio/media_audio_loader.h + media/audio/media_audio_loaders.cpp + media/audio/media_audio_loaders.h + media/audio/media_audio_track.cpp + media/audio/media_audio_track.h + media/audio/media_child_ffmpeg_loader.cpp + media/audio/media_child_ffmpeg_loader.h + media/clip/media_clip_check_streaming.cpp + media/clip/media_clip_check_streaming.h + media/clip/media_clip_ffmpeg.cpp + media/clip/media_clip_ffmpeg.h + media/clip/media_clip_implementation.cpp + media/clip/media_clip_implementation.h + media/clip/media_clip_reader.cpp + media/clip/media_clip_reader.h + media/player/media_player_button.cpp + media/player/media_player_button.h + media/player/media_player_float.cpp + media/player/media_player_float.h + media/player/media_player_instance.cpp + media/player/media_player_instance.h + media/player/media_player_panel.cpp + media/player/media_player_panel.h + media/player/media_player_volume_controller.cpp + media/player/media_player_volume_controller.h + media/player/media_player_widget.cpp + media/player/media_player_widget.h + media/streaming/media_streaming_audio_track.cpp + media/streaming/media_streaming_audio_track.h + media/streaming/media_streaming_common.h + media/streaming/media_streaming_document.cpp + media/streaming/media_streaming_document.h + media/streaming/media_streaming_file.cpp + media/streaming/media_streaming_file.h + media/streaming/media_streaming_file_delegate.h + media/streaming/media_streaming_instance.cpp + media/streaming/media_streaming_instance.h + media/streaming/media_streaming_loader.cpp + media/streaming/media_streaming_loader.h + media/streaming/media_streaming_loader_local.cpp + media/streaming/media_streaming_loader_local.h + media/streaming/media_streaming_loader_mtproto.cpp + media/streaming/media_streaming_loader_mtproto.h + media/streaming/media_streaming_player.cpp + media/streaming/media_streaming_player.h + media/streaming/media_streaming_reader.cpp + media/streaming/media_streaming_reader.h + media/streaming/media_streaming_utility.cpp + media/streaming/media_streaming_utility.h + media/streaming/media_streaming_video_track.cpp + media/streaming/media_streaming_video_track.h + media/view/media_view_playback_controls.cpp + media/view/media_view_playback_controls.h + media/view/media_view_playback_progress.cpp + media/view/media_view_playback_progress.h + media/view/media_view_group_thumbs.cpp + media/view/media_view_group_thumbs.h + media/view/media_view_overlay_widget.cpp + media/view/media_view_overlay_widget.h + mtproto/config_loader.cpp + mtproto/config_loader.h + mtproto/connection_abstract.cpp + mtproto/connection_abstract.h + mtproto/connection_http.cpp + mtproto/connection_http.h + mtproto/connection_resolving.cpp + mtproto/connection_resolving.h + mtproto/connection_tcp.cpp + mtproto/connection_tcp.h + mtproto/core_types.h + mtproto/dc_options.cpp + mtproto/dc_options.h + mtproto/dedicated_file_loader.cpp + mtproto/dedicated_file_loader.h + mtproto/facade.cpp + mtproto/facade.h + mtproto/mtp_instance.cpp + mtproto/mtp_instance.h + mtproto/sender.h + mtproto/session.cpp + mtproto/session.h + mtproto/session_private.cpp + mtproto/session_private.h + mtproto/special_config_request.cpp + mtproto/special_config_request.h + mtproto/type_utils.h + overview/overview_layout.cpp + overview/overview_layout.h + passport/passport_encryption.cpp + passport/passport_encryption.h + passport/passport_form_controller.cpp + passport/passport_form_controller.h + passport/passport_form_view_controller.cpp + passport/passport_form_view_controller.h + passport/passport_panel.cpp + passport/passport_panel.h + passport/passport_panel_controller.cpp + passport/passport_panel_controller.h + passport/passport_panel_details_row.cpp + passport/passport_panel_details_row.h + passport/passport_panel_edit_contact.cpp + passport/passport_panel_edit_contact.h + passport/passport_panel_edit_document.cpp + passport/passport_panel_edit_document.h + passport/passport_panel_edit_scans.cpp + passport/passport_panel_edit_scans.h + passport/passport_panel_form.cpp + passport/passport_panel_form.h + passport/passport_panel_password.cpp + passport/passport_panel_password.h + platform/linux/linux_desktop_environment.cpp + platform/linux/linux_desktop_environment.h + platform/linux/linux_gdk_helper.cpp + platform/linux/linux_gdk_helper.h + platform/linux/linux_libs.cpp + platform/linux/linux_libs.h + platform/linux/file_utilities_linux.cpp + platform/linux/file_utilities_linux.h + platform/linux/launcher_linux.cpp + platform/linux/launcher_linux.h + platform/linux/main_window_linux.cpp + platform/linux/main_window_linux.h + platform/linux/notifications_manager_linux.cpp + platform/linux/notifications_manager_linux.h + platform/linux/specific_linux.cpp + platform/linux/specific_linux.h + platform/mac/file_utilities_mac.mm + platform/mac/file_utilities_mac.h + platform/mac/launcher_mac.mm + platform/mac/launcher_mac.h + platform/mac/mac_iconv_helper.c + platform/mac/main_window_mac.mm + platform/mac/main_window_mac.h + platform/mac/notifications_manager_mac.mm + platform/mac/notifications_manager_mac.h + platform/mac/specific_mac.mm + platform/mac/specific_mac.h + platform/mac/specific_mac_p.mm + platform/mac/specific_mac_p.h + platform/mac/window_title_mac.mm + platform/mac/window_title_mac.h + platform/mac/mac_touchbar.h + platform/mac/mac_touchbar.mm + platform/win/audio_win.cpp + platform/win/audio_win.h + platform/win/file_utilities_win.cpp + platform/win/file_utilities_win.h + platform/win/launcher_win.cpp + platform/win/launcher_win.h + platform/win/main_window_win.cpp + platform/win/main_window_win.h + platform/win/notifications_manager_win.cpp + platform/win/notifications_manager_win.h + platform/win/specific_win.cpp + platform/win/specific_win.h + platform/win/window_title_win.cpp + platform/win/window_title_win.h + platform/win/windows_app_user_model_id.cpp + platform/win/windows_app_user_model_id.h + platform/win/windows_dlls.cpp + platform/win/windows_dlls.h + platform/win/windows_event_filter.cpp + platform/win/windows_event_filter.h + platform/win/wrapper_wrl_implements_h.h + platform/platform_audio.h + platform/platform_file_utilities.h + platform/platform_launcher.h + platform/platform_main_window.h + platform/platform_notifications_manager.h + platform/platform_specific.h + platform/platform_window_title.h + profile/profile_back_button.cpp + profile/profile_back_button.h + profile/profile_block_group_members.cpp + profile/profile_block_group_members.h + profile/profile_block_peer_list.cpp + profile/profile_block_peer_list.h + profile/profile_block_widget.cpp + profile/profile_block_widget.h + profile/profile_cover_drop_area.cpp + profile/profile_cover_drop_area.h + settings/settings_advanced.cpp + settings/settings_advanced.h + settings/settings_chat.cpp + settings/settings_chat.h + settings/settings_calls.cpp + settings/settings_calls.h + settings/settings_codes.cpp + settings/settings_codes.h + settings/settings_common.cpp + settings/settings_common.h + settings/settings_information.cpp + settings/settings_information.h + settings/settings_intro.cpp + settings/settings_intro.h + settings/settings_main.cpp + settings/settings_main.h + settings/settings_notifications.cpp + settings/settings_notifications.h + settings/settings_privacy_controllers.cpp + settings/settings_privacy_controllers.h + settings/settings_privacy_security.cpp + settings/settings_privacy_security.h + storage/download_manager_mtproto.cpp + storage/download_manager_mtproto.h + storage/file_download.cpp + storage/file_download.h + storage/file_download_mtproto.cpp + storage/file_download_mtproto.h + storage/file_download_web.cpp + storage/file_download_web.h + storage/file_upload.cpp + storage/file_upload.h + storage/localimageloader.cpp + storage/localimageloader.h + storage/localstorage.cpp + storage/localstorage.h + storage/serialize_common.cpp + storage/serialize_common.h + storage/serialize_document.cpp + storage/serialize_document.h + storage/storage_facade.cpp + storage/storage_facade.h + # storage/storage_feed_messages.cpp + # storage/storage_feed_messages.h + storage/storage_media_prepare.cpp + storage/storage_media_prepare.h + storage/storage_shared_media.cpp + storage/storage_shared_media.h + storage/storage_sparse_ids_list.cpp + storage/storage_sparse_ids_list.h + storage/storage_user_photos.cpp + storage/storage_user_photos.h + storage/streamed_file_downloader.cpp + storage/streamed_file_downloader.h + support/support_autocomplete.cpp + support/support_autocomplete.h + support/support_common.cpp + support/support_common.h + support/support_helper.cpp + support/support_helper.h + support/support_templates.cpp + support/support_templates.h + ui/effects/round_checkbox.cpp + ui/effects/round_checkbox.h + ui/effects/send_action_animations.cpp + ui/effects/send_action_animations.h + ui/image/image.cpp + ui/image/image.h + ui/image/image_location.cpp + ui/image/image_location.h + ui/image/image_source.cpp + ui/image/image_source.h + ui/widgets/continuous_sliders.cpp + ui/widgets/continuous_sliders.h + ui/widgets/discrete_sliders.cpp + ui/widgets/discrete_sliders.h + ui/widgets/level_meter.cpp + ui/widgets/level_meter.h + ui/widgets/multi_select.cpp + ui/widgets/multi_select.h + ui/widgets/separate_panel.cpp + ui/widgets/separate_panel.h + ui/countryinput.cpp + ui/countryinput.h + ui/empty_userpic.cpp + ui/empty_userpic.h + ui/grouped_layout.cpp + ui/grouped_layout.h + ui/resize_area.h + ui/search_field_controller.cpp + ui/search_field_controller.h + ui/special_buttons.cpp + ui/special_buttons.h + ui/special_fields.cpp + ui/special_fields.h + ui/text_options.cpp + ui/text_options.h + ui/unread_badge.cpp + ui/unread_badge.h + window/main_window.cpp + window/main_window.h + window/notifications_manager.cpp + window/notifications_manager.h + window/notifications_manager_default.cpp + window/notifications_manager_default.h + window/notifications_utilities.cpp + window/notifications_utilities.h + window/section_memento.h + window/section_widget.cpp + window/section_widget.h + window/window_connecting_widget.cpp + window/window_connecting_widget.h + window/window_controller.cpp + window/window_controller.h + window/window_history_hider.cpp + window/window_history_hider.h + window/window_lock_widgets.cpp + window/window_lock_widgets.h + window/window_main_menu.cpp + window/window_main_menu.h + window/window_media_preview.cpp + window/window_media_preview.h + window/window_outdated_bar.cpp + window/window_outdated_bar.h + window/window_peer_menu.cpp + window/window_peer_menu.h + window/window_session_controller.cpp + window/window_session_controller.h + window/window_slide_animation.cpp + window/window_slide_animation.h + window/window_title.h + window/window_top_bar_wrap.h + window/themes/window_theme.cpp + window/themes/window_theme.h + window/themes/window_theme_editor.cpp + window/themes/window_theme_editor.h + window/themes/window_theme_editor_block.cpp + window/themes/window_theme_editor_block.h + window/themes/window_theme_editor_box.cpp + window/themes/window_theme_editor_box.h + window/themes/window_theme_preview.cpp + window/themes/window_theme_preview.h + window/themes/window_theme_warning.cpp + window/themes/window_theme_warning.h + window/themes/window_themes_cloud_list.cpp + window/themes/window_themes_cloud_list.h + window/themes/window_themes_embedded.cpp + window/themes/window_themes_embedded.h + window/themes/window_themes_generate_name.cpp + window/themes/window_themes_generate_name.h + apiwrap.cpp + apiwrap.h + app.cpp + app.h + config.h + facades.cpp + facades.h + layout.cpp + layout.h + logs.cpp + logs.h + main.cpp + mainwidget.cpp + mainwidget.h + mainwindow.cpp + mainwindow.h + observer_peer.cpp + observer_peer.h + settings.cpp + settings.h +) + +if (DESKTOP_APP_USE_PACKAGED) + nice_target_sources(Telegram ${src_loc} PRIVATE qt_functions.cpp) +else() + nice_target_sources(Telegram ${src_loc} PRIVATE qt_static_plugins.cpp) +endif() + +nice_target_sources(Telegram ${res_loc} +PRIVATE + qrc/emoji_1.qrc + qrc/emoji_2.qrc + qrc/emoji_3.qrc + qrc/emoji_4.qrc + qrc/emoji_5.qrc + qrc/emoji_preview.qrc + qrc/telegram/telegram.qrc + qrc/telegram/sounds.qrc + winrc/Telegram.rc + winrc/Telegram.manifest + langs/lang.strings + numbers.txt +) + +if (WIN32) + # message(${CMAKE_GENERATOR}) + # mt.exe -manifest "${res_loc}/winrc/Telegram.manifest" "-inputresource:\"$\";#1" "-outputresource:\"$\";#1" >NUL + # set(hash_symbol "#") + # set(release $) + # add_custom_command( + # TARGET + # Telegram + # POST_BUILD COMMAND + # $ $<${release}:-manifest> $<${release}:"${res_loc}/winrc/Telegram.manifest"> $<${release}:-inputresource:"$"$${hash_symbol}1> $<${release}:-outputresource:"$"$${hash_symbol}1> $<${release}:$NUL> + # COMMENT + # $ + # ) +elseif (APPLE) + target_link_libraries(Telegram + PRIVATE + desktop-app::external_sp_media_key_tap + desktop-app::external_iconv + ) + + set(icons_path ${CMAKE_CURRENT_SOURCE_DIR}/Telegram/Images.xcassets) + set_target_properties(Telegram PROPERTIES RESOURCE ${icons_path}) + target_sources(Telegram PRIVATE ${icons_path}) + + set(lang_packs + en + de + es + it + nl + ko + pt-BR + ) + foreach (lang ${lang_packs}) + set(strings_path ${res_loc}/langs/${lang}.lproj/Localizable.strings) + set_source_files_properties(${strings_path} PROPERTIES + MACOSX_PACKAGE_LOCATION + Resources/${lang}.lproj + ) + target_sources(Telegram PRIVATE ${strings_path}) + source_group(TREE ${res_loc} PREFIX Resources FILES ${strings_path}) + endforeach() + + if (NOT build_macstore) + add_custom_command(TARGET Telegram + PRE_LINK + COMMAND mkdir -p $/../Frameworks + COMMAND cp $ $/../Frameworks/ + ) + if (NOT DESKTOP_APP_DISABLE_CRASH_REPORTS) + add_custom_command(TARGET Telegram + PRE_LINK + COMMAND mkdir -p $/../Helpers + COMMAND cp ${libs_loc}/crashpad/out/$,Debug,Release>/crashpad_handler $/../Helpers/ + ) + endif() + endif() +elseif (LINUX) + if (NOT TDESKTOP_DISABLE_GTK_INTEGRATION) + find_package(PkgConfig REQUIRED) + + pkg_search_module(GTK REQUIRED gtk+-2.0 gtk+-3.0) + target_include_directories(Telegram PRIVATE ${GTK_INCLUDE_DIRS}) + target_compile_options(Telegram PRIVATE -Wno-register) + + if (DESKTOP_APP_USE_PACKAGED) + find_library(X11_LIBRARY X11) + target_link_libraries(Telegram PRIVATE ${X11_LIBRARY}) + endif() + + set(appindicator_packages + ayatana-appindicator3-0.1 + ayatana-appindicator-0.1 + appindicator3-0.1 + appindicator-0.1 + ) + set(appindicator_found 0) + foreach (package ${appindicator_packages}) + pkg_check_modules(APPIND_${package} ${package}) + if (APPIND_${package}_FOUND) + set(appindicator_found 1) + target_include_directories(Telegram PRIVATE "${APPIND_${package}_INCLUDE_DIRS}") + if (${package} MATCHES "ayatana") + target_compile_definitions(Telegram PRIVATE TDESKTOP_USE_AYATANA_INDICATORS) + endif() + break() + endif() + endforeach() + if (NOT ${appindicator_found}) + message(FATAL_ERROR "No libappindicator found by pkg-config.") + endif() + endif() +endif() + +if (build_macstore) + set(bundle_identifier "org.telegram.desktop") + set(bundle_entitlements "Telegram Desktop.entitlements") + set(output_name "Telegram Desktop") + set_target_properties(Telegram PROPERTIES + XCODE_ATTRIBUTE_FRAMEWORK_SEARCH_PATHS ${libs_loc}/breakpad/src/client/mac/build/Release + ) + target_link_frameworks(Telegram PRIVATE Breakpad) + add_custom_command(TARGET Telegram + PRE_LINK + COMMAND rm -rf $/../Frameworks + COMMAND mkdir -p $/../Frameworks + COMMAND cp -a ${libs_loc}/breakpad/src/client/mac/build/Release/Breakpad.framework $/../Frameworks/Breakpad.framework + ) +elseif (build_osx) + set(bundle_identifier "com.tdesktop.Telegram$<$:DebugOsx>") + set(bundle_entitlements "Telegram.entitlements") + set(output_name "Telegram") +else() + set(bundle_identifier "com.tdesktop.Telegram$<$:Debug>") + set(bundle_entitlements "Telegram.entitlements") + set(output_name "Telegram") +endif() + +set_target_properties(Telegram PROPERTIES + OUTPUT_NAME ${output_name} + MACOSX_BUNDLE_GUI_IDENTIFIER ${bundle_identifier} + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Telegram.plist + XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${CMAKE_CURRENT_SOURCE_DIR}/Telegram/${bundle_entitlements}" + XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER ${bundle_identifier} + XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION ${desktop_app_version_string} + XCODE_ATTRIBUTE_PRODUCT_NAME ${output_name} + XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT $<$>:dwarf-with-dsym> + XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME AppIcon + XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES + XCODE_ATTRIBUTE_COMBINE_HIDPI_IMAGES YES + XCODE_ATTRIBUTE_COPY_PHASE_STRIP NO + XCODE_ATTRIBUTE_ALWAYS_SEARCH_USER_PATHS NO + XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY libc++ + XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS --deep +) +set(entitlement_sources + "${CMAKE_CURRENT_SOURCE_DIR}/Telegram/Telegram.entitlements" + "${CMAKE_CURRENT_SOURCE_DIR}/Telegram/Telegram Desktop.entitlements" +) +target_sources(Telegram PRIVATE ${entitlement_sources}) +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/Telegram PREFIX Resources FILES ${entitlement_sources}) + +target_include_directories(Telegram PRIVATE ${src_loc}) + +if (NOT DESKTOP_APP_USE_PACKAGED) + target_include_directories(Telegram PRIVATE ${third_party_loc}/minizip) +endif() + +target_compile_definitions(Telegram +PRIVATE + TDESKTOP_API_ID=${TDESKTOP_API_ID} + TDESKTOP_API_HASH=${TDESKTOP_API_HASH} + AL_ALEXT_PROTOTYPES +) + +if (NOT DESKTOP_APP_USE_PACKAGED) + target_compile_definitions(Telegram PRIVATE AL_LIBTYPE_STATIC) +endif() + +if (${CMAKE_GENERATOR} MATCHES "(Visual Studio|Xcode)") + set(output_folder ${CMAKE_BINARY_DIR}) +elseif (DESKTOP_APP_SPECIAL_TARGET STREQUAL "") + set(output_folder ${CMAKE_BINARY_DIR}/bin) +else() + set(output_folder ${CMAKE_BINARY_DIR}/$,Debug,Release>) +endif() + +set_target_properties(Telegram PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${output_folder}) + +if ((NOT disable_autoupdate OR NOT LINUX) AND NOT build_macstore AND NOT build_winstore) + add_executable(Updater WIN32) + init_target(Updater) + + add_dependencies(Telegram Updater) + + nice_target_sources(Updater ${src_loc} + PRIVATE + _other/updater_win.cpp + _other/updater_linux.cpp + _other/updater_osx.m + _other/updater.h + ) + + set_target_properties(Updater PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${output_folder}) + + if (LINUX) + target_link_options(Updater INTERFACE -static-libstdc++) + endif() + + if (DESKTOP_APP_SPECIAL_TARGET) + add_executable(Packer WIN32) + init_target(Packer) + + add_dependencies(Telegram Packer) + + nice_target_sources(Packer ${src_loc} + PRIVATE + _other/packer.cpp + _other/packer.h + ) + + target_link_libraries(Packer + PRIVATE + desktop-app::external_qt + desktop-app::external_zlib + desktop-app::external_auto_updates + desktop-app::external_openssl + ) + + set_target_properties(Packer PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${output_folder}) + endif() +endif() diff --git a/Telegram/Resources/icons/intro_qr_plane.png b/Telegram/Resources/icons/intro_qr_plane.png new file mode 100644 index 000000000..cdc309f9d Binary files /dev/null and b/Telegram/Resources/icons/intro_qr_plane.png differ diff --git a/Telegram/Resources/icons/intro_qr_plane@2x.png b/Telegram/Resources/icons/intro_qr_plane@2x.png new file mode 100644 index 000000000..3d0c2e9af Binary files /dev/null and b/Telegram/Resources/icons/intro_qr_plane@2x.png differ diff --git a/Telegram/Resources/icons/intro_qr_plane@3x.png b/Telegram/Resources/icons/intro_qr_plane@3x.png new file mode 100644 index 000000000..ae5c5442e Binary files /dev/null and b/Telegram/Resources/icons/intro_qr_plane@3x.png differ diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index ff2b42142..4738da233 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -178,8 +178,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_photo_caption" = "Caption"; "lng_photos_comment" = "Comment"; +"lng_intro_qr_title" = "Scan From Mobile Telegram"; +"lng_intro_qr_step1" = "Open Telegram on your phone"; +"lng_intro_qr_step2" = "Go to Settings > Devices > Scan QR Code"; +"lng_intro_qr_step3" = "Scan this image to Log In"; +"lng_intro_qr_skip" = "Or log in using your phone number"; + "lng_phone_title" = "Your Phone Number"; "lng_phone_desc" = "Please confirm your country code and\nenter your mobile phone number."; +"lng_phone_to_qr" = "Quick log in using QR code"; "lng_country_code" = "Country Code"; "lng_bad_country_code" = "Invalid Country Code"; "lng_country_ph" = "Search"; @@ -408,7 +415,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_settings_system_integration" = "System integration"; "lng_settings_performance" = "Performance"; "lng_settings_enable_animations" = "Enable animations"; -"lng_settings_autoplay_gifs" = "Autoplay GIFs"; +"lng_settings_sensitive_title" = "Sensitive content"; +"lng_settings_sensitive_disable_filtering" = "Disable filtering"; +"lng_settings_sensitive_about" = "Display sensitive media in public channels on all your Telegram devices."; "lng_settings_spellchecker" = "Spell checker"; "lng_settings_system_spellchecker" = "Use system spell checker"; @@ -1143,12 +1152,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_media_auto_in_groups" = "In groups"; "lng_media_auto_in_channels" = "In channels"; "lng_media_auto_title" = "Automatically download"; +"lng_media_auto_play" = "Autoplay"; "lng_media_photo_title" = "Photos"; "lng_media_video_title" = "Video files"; -"lng_media_audio_title" = "Voice messages"; "lng_media_video_messages_title" = "Round video messages"; "lng_media_file_title" = "Files"; -"lng_media_music_title" = "Music"; "lng_media_animation_title" = "Animated GIFs"; "lng_media_size_limit" = "Limit by size"; "lng_media_size_up_to" = "up to {size}"; @@ -2231,6 +2239,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_mac_menu_new_group" = "New Group"; "lng_mac_menu_new_channel" = "New Channel"; "lng_mac_menu_show" = "Show Telegram"; +"lng_mac_menu_emoji_and_symbols" = "Emoji & Symbols"; "lng_mac_touchbar_favorite_stickers" = "Favorite stickers"; diff --git a/Telegram/Resources/tl/api.tl b/Telegram/Resources/tl/api.tl index 5baf29966..982f05af7 100644 --- a/Telegram/Resources/tl/api.tl +++ b/Telegram/Resources/tl/api.tl @@ -89,6 +89,7 @@ inputDocumentFileLocation#bad07584 id:long access_hash:long file_reference:bytes inputSecureFileLocation#cbc7ee28 id:long access_hash:long = InputFileLocation; inputTakeoutFileLocation#29be5899 = InputFileLocation; inputPhotoFileLocation#40181ffe id:long access_hash:long file_reference:bytes thumb_size:string = InputFileLocation; +inputPhotoLegacyFileLocation#d83466f3 id:long access_hash:long file_reference:bytes volume_id:long local_id:int secret:long = InputFileLocation; inputPeerPhotoFileLocation#27d69997 flags:# big:flags.0?true peer:InputPeer volume_id:long local_id:int = InputFileLocation; inputStickerSetThumb#dbaeae9 stickerset:InputStickerSet volume_id:long local_id:int = InputFileLocation; @@ -213,6 +214,7 @@ peerNotifySettings#af509d20 flags:# show_previews:flags.0?Bool silent:flags.1?Bo peerSettings#818426cd flags:# report_spam:flags.0?true add_contact:flags.1?true block_contact:flags.2?true share_contact:flags.3?true need_contacts_exception:flags.4?true report_geo:flags.5?true = PeerSettings; wallPaper#a437c3ed id:long flags:# creator:flags.0?true default:flags.1?true pattern:flags.3?true dark:flags.4?true access_hash:long slug:string document:Document settings:flags.2?WallPaperSettings = WallPaper; +wallPaperNoFile#8af40b25 flags:# default:flags.1?true dark:flags.4?true settings:flags.2?WallPaperSettings = WallPaper; inputReportReasonSpam#58dbcab8 = ReportReason; inputReportReasonViolence#1e22c78d = ReportReason; @@ -347,6 +349,8 @@ updatePeerLocated#b4afcfb0 peers:Vector = Update; updateNewScheduledMessage#39a51dfb message:Message = Update; updateDeleteScheduledMessages#90866cee peer:Peer messages:Vector = Update; updateTheme#8216fba3 theme:Theme = Update; +updateGeoLiveViewed#871fb939 peer:Peer msg_id:int = Update; +updateLoginToken#564fe691 = Update; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; @@ -496,7 +500,7 @@ messages.affectedMessages#84d19185 pts:int pts_count:int = messages.AffectedMess webPageEmpty#eb1477e8 id:long = WebPage; webPagePending#c586da1c id:long date:int = WebPage; -webPage#fa64e172 flags:# id:long url:string display_url:string hash:int type:flags.0?string site_name:flags.1?string title:flags.2?string description:flags.3?string photo:flags.4?Photo embed_url:flags.5?string embed_type:flags.5?string embed_width:flags.6?int embed_height:flags.6?int duration:flags.7?int author:flags.8?string document:flags.9?Document documents:flags.11?Vector cached_page:flags.10?Page = WebPage; +webPage#e89c45b2 flags:# id:long url:string display_url:string hash:int type:flags.0?string site_name:flags.1?string title:flags.2?string description:flags.3?string photo:flags.4?Photo embed_url:flags.5?string embed_type:flags.5?string embed_width:flags.6?int embed_height:flags.6?int duration:flags.7?int author:flags.8?string document:flags.9?Document cached_page:flags.10?Page attributes:flags.12?Vector = WebPage; webPageNotModified#85849473 = WebPage; authorization#ad01d61d flags:# current:flags.0?true official_app:flags.1?true password_pending:flags.2?true hash:long device_model:string platform:string system_version:string api_id:int app_name:string app_version:string date_created:int date_active:int ip:string country:string region:string = Authorization; @@ -1027,15 +1031,16 @@ chatBannedRights#9f120418 flags:# view_messages:flags.0?true send_messages:flags inputWallPaper#e630b979 id:long access_hash:long = InputWallPaper; inputWallPaperSlug#72091c80 slug:string = InputWallPaper; +inputWallPaperNoFile#8427bbac = InputWallPaper; account.wallPapersNotModified#1c199183 = account.WallPapers; account.wallPapers#702b65a9 hash:int wallpapers:Vector = account.WallPapers; codeSettings#debebe83 flags:# allow_flashcall:flags.0?true current_number:flags.1?true allow_app_hash:flags.4?true = CodeSettings; -wallPaperSettings#a12f40b8 flags:# blur:flags.1?true motion:flags.2?true background_color:flags.0?int intensity:flags.3?int = WallPaperSettings; +wallPaperSettings#5086cf8 flags:# blur:flags.1?true motion:flags.2?true background_color:flags.0?int second_background_color:flags.4?int intensity:flags.3?int rotation:flags.4?int = WallPaperSettings; -autoDownloadSettings#d246fd47 flags:# disabled:flags.0?true video_preload_large:flags.1?true audio_preload_next:flags.2?true phonecalls_less_data:flags.3?true photo_size_max:int video_size_max:int file_size_max:int = AutoDownloadSettings; +autoDownloadSettings#e04232f3 flags:# disabled:flags.0?true video_preload_large:flags.1?true audio_preload_next:flags.2?true phonecalls_less_data:flags.3?true photo_size_max:int video_size_max:int file_size_max:int video_upload_maxbitrate:int = AutoDownloadSettings; account.autoDownloadSettings#63cacf26 low:AutoDownloadSettings medium:AutoDownloadSettings high:AutoDownloadSettings = account.AutoDownloadSettings; @@ -1073,7 +1078,7 @@ inputTheme#3c5693e9 id:long access_hash:long = InputTheme; inputThemeSlug#f5890df1 slug:string = InputTheme; themeDocumentNotModified#483d270c = Theme; -theme#f7d90ce0 flags:# creator:flags.0?true default:flags.1?true id:long access_hash:long slug:string title:string document:flags.2?Document installs_count:int = Theme; +theme#28f1114 flags:# creator:flags.0?true default:flags.1?true id:long access_hash:long slug:string title:string document:flags.2?Document settings:flags.3?ThemeSettings installs_count:int = Theme; account.themesNotModified#f41eb622 = account.Themes; account.themes#7f676421 hash:int themes:Vector = account.Themes; @@ -1082,6 +1087,26 @@ wallet.liteResponse#764386d7 response:bytes = wallet.LiteResponse; wallet.secretSalt#dd484d64 salt:bytes = wallet.KeySecretSalt; +auth.loginToken#629f1980 expires:int token:bytes = auth.LoginToken; +auth.loginTokenMigrateTo#68e9916 dc_id:int token:bytes = auth.LoginToken; +auth.loginTokenSuccess#390d5c5e authorization:auth.Authorization = auth.LoginToken; + +account.contentSettings#57e28221 flags:# sensitive_enabled:flags.0?true sensitive_can_change:flags.1?true = account.ContentSettings; + +messages.inactiveChats#a927fec5 dates:Vector chats:Vector users:Vector = messages.InactiveChats; + +baseThemeClassic#c3a12462 = BaseTheme; +baseThemeDay#fbd81688 = BaseTheme; +baseThemeNight#b7b31ea8 = BaseTheme; +baseThemeTinted#6d5f77ee = BaseTheme; +baseThemeArctic#5b11125a = BaseTheme; + +inputThemeSettings#bd507cd1 flags:# base_theme:BaseTheme accent_color:int message_top_color:flags.0?int message_bottom_color:flags.0?int wallpaper:flags.1?InputWallPaper wallpaper_settings:flags.1?WallPaperSettings = InputThemeSettings; + +themeSettings#9c14984a flags:# base_theme:BaseTheme accent_color:int message_top_color:flags.0?int message_bottom_color:flags.0?int wallpaper:flags.1?WallPaper = ThemeSettings; + +webPageAttributeTheme#54b56617 flags:# documents:flags.0?Vector settings:flags.1?ThemeSettings = WebPageAttribute; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1107,6 +1132,9 @@ auth.recoverPassword#4ea56e92 code:string = auth.Authorization; auth.resendCode#3ef1a9bf phone_number:string phone_code_hash:string = auth.SentCode; auth.cancelCode#1f040578 phone_number:string phone_code_hash:string = Bool; auth.dropTempAuthKeys#8e48a188 except_auth_keys:Vector = Bool; +auth.exportLoginToken#b1b41517 api_id:int api_hash:string except_ids:Vector = auth.LoginToken; +auth.importLoginToken#95ac5ce4 token:bytes = auth.LoginToken; +auth.acceptLoginToken#e894ad4d token:bytes = Authorization; account.registerDevice#68976c6f flags:# no_muted:flags.0?true token_type:int token:string app_sandbox:Bool secret:bytes other_uids:Vector = Bool; account.unregisterDevice#3076c4bf token_type:int token:string other_uids:Vector = Bool; @@ -1164,12 +1192,15 @@ account.resetWallPapers#bb3b9804 = Bool; account.getAutoDownloadSettings#56da0b3f = account.AutoDownloadSettings; account.saveAutoDownloadSettings#76f36233 flags:# low:flags.0?true high:flags.1?true settings:AutoDownloadSettings = Bool; account.uploadTheme#1c3db333 flags:# file:InputFile thumb:flags.0?InputFile file_name:string mime_type:string = Document; -account.createTheme#2b7ffd7f slug:string title:string document:InputDocument = Theme; -account.updateTheme#3b8ea202 flags:# format:string theme:InputTheme slug:flags.0?string title:flags.1?string document:flags.2?InputDocument = Theme; +account.createTheme#8432c21f flags:# slug:string title:string document:flags.2?InputDocument settings:flags.3?InputThemeSettings = Theme; +account.updateTheme#5cb367d5 flags:# format:string theme:InputTheme slug:flags.0?string title:flags.1?string document:flags.2?InputDocument settings:flags.3?InputThemeSettings = Theme; account.saveTheme#f257106c theme:InputTheme unsave:Bool = Bool; account.installTheme#7ae43737 flags:# dark:flags.0?true format:flags.1?string theme:flags.1?InputTheme = Bool; account.getTheme#8d9d742b format:string theme:InputTheme document_id:long = Theme; account.getThemes#285946f8 format:string hash:int = account.Themes; +account.setContentSettings#b574b16b flags:# sensitive_enabled:flags.0?true = Bool; +account.getContentSettings#8b9b4dae = account.ContentSettings; +account.getMultiWallPapers#65ad71dc wallpapers:Vector = Vector; users.getUsers#d91a548 id:Vector = Vector; users.getFullUser#ca30a5b1 id:InputUser = UserFull; @@ -1385,6 +1416,7 @@ channels.setDiscussionGroup#40582bb2 broadcast:InputChannel group:InputChannel = channels.editCreator#8f38cd1f channel:InputChannel user_id:InputUser password:InputCheckPasswordSRP = Updates; channels.editLocation#58e63f6d channel:InputChannel geo_point:InputGeoPoint address:string = Bool; channels.toggleSlowMode#edd49ef0 channel:InputChannel seconds:int = Updates; +channels.getInactiveChannels#11e831ee = messages.InactiveChats; bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON; bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool; @@ -1422,4 +1454,4 @@ folders.deleteFolder#1c295881 folder_id:int = Updates; wallet.sendLiteRequest#e2c9d33e body:bytes = wallet.LiteResponse; wallet.getKeySecretSalt#b57f346 revoke:Bool = wallet.KeySecretSalt; -// LAYER 106 +// LAYER 108 diff --git a/Telegram/Resources/tl/mtproto.tl b/Telegram/Resources/tl/mtproto.tl index 83a770292..4b92c3e6e 100644 --- a/Telegram/Resources/tl/mtproto.tl +++ b/Telegram/Resources/tl/mtproto.tl @@ -21,6 +21,8 @@ p_q_inner_data_dc#a9f55f95 pq:string p:string q:string nonce:int128 server_nonce p_q_inner_data_temp#3c6a84d4 pq:string p:string q:string nonce:int128 server_nonce:int128 new_nonce:int256 expires_in:int = P_Q_inner_data; p_q_inner_data_temp_dc#56fddf88 pq:string p:string q:string nonce:int128 server_nonce:int128 new_nonce:int256 dc:int expires_in:int = P_Q_inner_data; +bind_auth_key_inner#75a3f765 nonce:long temp_auth_key_id:long perm_auth_key_id:long temp_session_id:long expires_at:int = BindAuthKeyInner; + server_DH_params_fail#79cb045d nonce:int128 server_nonce:int128 new_nonce_hash:int128 = Server_DH_Params; server_DH_params_ok#d0e8075c nonce:int128 server_nonce:int128 encrypted_answer:string = Server_DH_Params; diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml index 91eed0956..664e29634 100644 --- a/Telegram/Resources/uwp/AppX/AppxManifest.xml +++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml @@ -9,7 +9,7 @@ + Version="1.9.4.0" /> Telegram Desktop Telegram FZ-LLC diff --git a/Telegram/SourceFiles/_other/updater.cpp b/Telegram/SourceFiles/_other/updater_win.cpp similarity index 100% rename from Telegram/SourceFiles/_other/updater.cpp rename to Telegram/SourceFiles/_other/updater_win.cpp diff --git a/Telegram/SourceFiles/api/api_self_destruct.cpp b/Telegram/SourceFiles/api/api_self_destruct.cpp new file mode 100644 index 000000000..80ae25186 --- /dev/null +++ b/Telegram/SourceFiles/api/api_self_destruct.cpp @@ -0,0 +1,51 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#include "api/api_self_destruct.h" + +#include "apiwrap.h" + +namespace Api { + +SelfDestruct::SelfDestruct(not_null api) +: _api(api->instance()) { +} + +void SelfDestruct::reload() { + if (_requestId) { + return; + } + _requestId = _api.request(MTPaccount_GetAccountTTL( + )).done([=](const MTPAccountDaysTTL &result) { + _requestId = 0; + result.match([&](const MTPDaccountDaysTTL &data) { + _days = data.vdays().v; + }); + }).fail([=](const RPCError &error) { + _requestId = 0; + }).send(); +} + +rpl::producer SelfDestruct::days() const { + using namespace rpl::mappers; + + return _days.value() | rpl::filter(_1 != 0); +} + +void SelfDestruct::update(int days) { + _api.request(_requestId).cancel(); + _requestId = _api.request(MTPaccount_SetAccountTTL( + MTP_accountDaysTTL(MTP_int(days)) + )).done([=](const MTPBool &result) { + _requestId = 0; + }).fail([=](const RPCError &result) { + _requestId = 0; + }).send(); + _days = days; +} + +} // namespace Api diff --git a/Telegram/SourceFiles/api/api_self_destruct.h b/Telegram/SourceFiles/api/api_self_destruct.h new file mode 100644 index 000000000..d9534a423 --- /dev/null +++ b/Telegram/SourceFiles/api/api_self_destruct.h @@ -0,0 +1,32 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#pragma once + +#include "mtproto/sender.h" + +class ApiWrap; + +namespace Api { + +class SelfDestruct final { +public: + explicit SelfDestruct(not_null api); + + void reload(); + void update(int days); + + rpl::producer days() const; + +private: + MTP::Sender _api; + mtpRequestId _requestId = 0; + rpl::variable _days = 0; + +}; + +} // namespace Api diff --git a/Telegram/SourceFiles/api/api_sensitive_content.cpp b/Telegram/SourceFiles/api/api_sensitive_content.cpp new file mode 100644 index 000000000..7ff3dd610 --- /dev/null +++ b/Telegram/SourceFiles/api/api_sensitive_content.cpp @@ -0,0 +1,74 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#include "api/api_sensitive_content.h" + +#include "apiwrap.h" +#include "main/main_session.h" +#include "main/main_account.h" +#include "main/main_app_config.h" + +namespace Api { +namespace { + +constexpr auto kRefreshAppConfigTimeout = 3 * crl::time(1000); + +} // namespace + +SensitiveContent::SensitiveContent(not_null api) +: _session(&api->session()) +, _api(api->instance()) +, _appConfigReloadTimer([=] { _session->account().appConfig().refresh(); }) { +} + +void SensitiveContent::reload() { + if (_requestId) { + return; + } + _requestId = _api.request(MTPaccount_GetContentSettings( + )).done([=](const MTPaccount_ContentSettings &result) { + _requestId = 0; + result.match([&](const MTPDaccount_contentSettings &data) { + _enabled = data.is_sensitive_enabled(); + _canChange = data.is_sensitive_can_change(); + }); + }).fail([=](const RPCError &error) { + _requestId = 0; + }).send(); +} + +bool SensitiveContent::enabledCurrent() const { + return _enabled.current(); +} + +rpl::producer SensitiveContent::enabled() const { + return _enabled.value(); +} + +rpl::producer SensitiveContent::canChange() const { + return _canChange.value(); +} + +void SensitiveContent::update(bool enabled) { + if (!_canChange.current()) { + return; + } + using Flag = MTPaccount_SetContentSettings::Flag; + _api.request(_requestId).cancel(); + _requestId = _api.request(MTPaccount_SetContentSettings( + MTP_flags(enabled ? Flag::f_sensitive_enabled : Flag(0)) + )).done([=](const MTPBool &result) { + _requestId = 0; + }).fail([=](const RPCError &error) { + _requestId = 0; + }).send(); + _enabled = enabled; + + _appConfigReloadTimer.callOnce(kRefreshAppConfigTimeout); +} + +} // namespace Api diff --git a/Telegram/SourceFiles/api/api_sensitive_content.h b/Telegram/SourceFiles/api/api_sensitive_content.h new file mode 100644 index 000000000..0a61f9da7 --- /dev/null +++ b/Telegram/SourceFiles/api/api_sensitive_content.h @@ -0,0 +1,42 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#pragma once + +#include "mtproto/sender.h" +#include "base/timer.h" + +class ApiWrap; + +namespace Main { +class Session; +} // namespace Main + +namespace Api { + +class SensitiveContent final { +public: + explicit SensitiveContent(not_null api); + + void reload(); + void update(bool enabled); + + [[nodiscard]] bool enabledCurrent() const; + [[nodiscard]] rpl::producer enabled() const; + [[nodiscard]] rpl::producer canChange() const; + +private: + const not_null _session; + MTP::Sender _api; + mtpRequestId _requestId = 0; + rpl::variable _enabled = false; + rpl::variable _canChange = false; + base::Timer _appConfigReloadTimer; + +}; + +} // namespace Api diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index b33afa76a..64a4432f1 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -8,6 +8,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "apiwrap.h" #include "api/api_text_entities.h" +#include "api/api_self_destruct.h" +#include "api/api_sensitive_content.h" #include "data/data_drafts.h" #include "data/data_photo.h" #include "data/data_web_page.h" @@ -40,6 +42,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL //#include "history/feed/history_feed_section.h" // #feed #include "storage/localstorage.h" #include "main/main_session.h" +#include "main/main_account.h" #include "boxes/confirm_box.h" #include "boxes/stickers_box.h" #include "boxes/sticker_set_box.h" @@ -54,7 +57,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/emoji_config.h" #include "support/support_helper.h" #include "storage/localimageloader.h" -#include "storage/file_download.h" +#include "storage/download_manager_mtproto.h" #include "storage/file_upload.h" #include "storage/storage_facade.h" #include "storage/storage_shared_media.h" @@ -222,7 +225,8 @@ bool ApiWrap::BlockedUsersSlice::operator!=(const BlockedUsersSlice &other) cons } ApiWrap::ApiWrap(not_null session) -: _session(session) +: MTP::Sender(session->account().mtp()) +, _session(session) , _messageDataResolveDelayed([=] { resolveMessageDatas(); }) , _webPagesTimer([=] { resolveWebPages(); }) , _draftsSaveTimer([=] { saveDraftsToCloud(); }) @@ -231,7 +235,9 @@ ApiWrap::ApiWrap(not_null session) , _fileLoader(std::make_unique(kFileLoaderQueueStopTimeout)) //, _feedReadTimer([=] { readFeeds(); }) // #feed , _proxyPromotionTimer([=] { refreshProxyPromotion(); }) -, _updateNotifySettingsTimer([=] { sendNotifySettingsUpdates(); }) { +, _updateNotifySettingsTimer([=] { sendNotifySettingsUpdates(); }) +, _selfDestruct(std::make_unique(this)) +, _sensitiveContent(std::make_unique(this)) { crl::on_main([=] { // You can't use _session->lifetime() in the constructor, // only queued, because it is not constructed yet. @@ -244,6 +250,8 @@ ApiWrap::ApiWrap(not_null session) }); } +ApiWrap::~ApiWrap() = default; + Main::Session &ApiWrap::session() const { return *_session; } @@ -280,11 +288,11 @@ void ApiWrap::refreshProxyPromotion() { return; } const auto key = [&]() -> std::pair { - if (Global::ProxySettings() != ProxyData::Settings::Enabled) { + if (Global::ProxySettings() != MTP::ProxyData::Settings::Enabled) { return {}; } const auto &proxy = Global::SelectedProxy(); - if (proxy.type != ProxyData::Type::Mtproto) { + if (proxy.type != MTP::ProxyData::Type::Mtproto) { return {}; } return { proxy.host, proxy.port }; @@ -2971,12 +2979,12 @@ void ApiWrap::requestFileReference( void ApiWrap::refreshFileReference( Data::FileOrigin origin, - not_null loader, + not_null task, int requestId, const QByteArray ¤t) { - return refreshFileReference(origin, crl::guard(loader, [=]( + return refreshFileReference(origin, crl::guard(task, [=]( const UpdatedFileReferences &data) { - loader->refreshFileReferenceFrom(data, requestId, current); + task->refreshFileReferenceFrom(data, requestId, current); })); } @@ -5798,42 +5806,12 @@ auto ApiWrap::blockedUsersSlice() -> rpl::producer { : (_blockedUsersChanges.events() | rpl::type_erased()); } -void ApiWrap::reloadSelfDestruct() { - if (_selfDestructRequestId) { - return; - } - _selfDestructRequestId = request(MTPaccount_GetAccountTTL( - )).done([=](const MTPAccountDaysTTL &result) { - _selfDestructRequestId = 0; - result.match([&](const MTPDaccountDaysTTL &data) { - setSelfDestructDays(data.vdays().v); - }); - }).fail([=](const RPCError &error) { - _selfDestructRequestId = 0; - }).send(); +Api::SelfDestruct &ApiWrap::selfDestruct() { + return *_selfDestruct; } -rpl::producer ApiWrap::selfDestructValue() const { - return _selfDestructDays - ? _selfDestructChanges.events_starting_with_copy(*_selfDestructDays) - : (_selfDestructChanges.events() | rpl::type_erased()); -} - -void ApiWrap::saveSelfDestruct(int days) { - request(_selfDestructRequestId).cancel(); - _selfDestructRequestId = request(MTPaccount_SetAccountTTL( - MTP_accountDaysTTL(MTP_int(days)) - )).done([=](const MTPBool &result) { - _selfDestructRequestId = 0; - }).fail([=](const RPCError &result) { - _selfDestructRequestId = 0; - }).send(); - setSelfDestructDays(days); -} - -void ApiWrap::setSelfDestructDays(int days) { - _selfDestructDays = days; - _selfDestructChanges.fire_copy(days); +Api::SensitiveContent &ApiWrap::sensitiveContent() { + return *_sensitiveContent; } void ApiWrap::createPoll( @@ -6105,5 +6083,3 @@ void ApiWrap::sendReadRequest(not_null peer, MsgId upTo) { }(); _readRequests.emplace(peer, requestId, upTo); } - -ApiWrap::~ApiWrap() = default; diff --git a/Telegram/SourceFiles/apiwrap.h b/Telegram/SourceFiles/apiwrap.h index 0656d974b..0a57a619b 100644 --- a/Telegram/SourceFiles/apiwrap.h +++ b/Telegram/SourceFiles/apiwrap.h @@ -20,7 +20,6 @@ struct MessageGroupId; struct SendingAlbum; enum class SendMediaType; struct FileLoadTo; -class mtpFileLoader; namespace Main { class Session; @@ -38,6 +37,7 @@ class Result; namespace Storage { enum class SharedMediaType : signed char; struct PreparedList; +class DownloadMtprotoTask; } // namespace Storage namespace Dialogs { @@ -83,6 +83,9 @@ QString RequestKey(Types &&...values) { return result; } +class SelfDestruct; +class SensitiveContent; + } // namespace Api class ApiWrap : public MTP::Sender, private base::Subscriber { @@ -131,6 +134,7 @@ public: }; explicit ApiWrap(not_null session); + ~ApiWrap(); Main::Session &session() const; @@ -201,7 +205,7 @@ public: FileReferencesHandler &&handler); void refreshFileReference( Data::FileOrigin origin, - not_null loader, + not_null task, int requestId, const QByteArray ¤t); @@ -465,9 +469,8 @@ public: void reloadBlockedUsers(); rpl::producer blockedUsersSlice(); - void reloadSelfDestruct(); - rpl::producer selfDestructValue() const; - void saveSelfDestruct(int days); + [[nodiscard]] Api::SelfDestruct &selfDestruct(); + [[nodiscard]] Api::SensitiveContent &sensitiveContent(); void createPoll( const PollData &data, @@ -480,8 +483,6 @@ public: void closePoll(not_null item); void reloadPollResults(not_null item); - ~ApiWrap(); - private: struct MessageDataRequest { using Callbacks = QList; @@ -679,8 +680,6 @@ private: const QVector &rules); void updatePrivacyLastSeens(const QVector &rules); - void setSelfDestructDays(int days); - void migrateDone( not_null peer, not_null channel); @@ -874,9 +873,8 @@ private: std::optional _blockedUsersSlice; rpl::event_stream _blockedUsersChanges; - mtpRequestId _selfDestructRequestId = 0; - std::optional _selfDestructDays; - rpl::event_stream _selfDestructChanges; + const std::unique_ptr _selfDestruct; + const std::unique_ptr _sensitiveContent; base::flat_map _pollVotesRequestIds; base::flat_map _pollCloseRequestIds; diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index e783d4a62..f5b103af8 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -316,12 +316,12 @@ namespace App { } QImage readImage(QByteArray data, QByteArray *format, bool opaque, bool *animated) { - QByteArray tmpFormat; + QByteArray tmpFormat; QImage result; QBuffer buffer(&data); - if (!format) { - format = &tmpFormat; - } + if (!format) { + format = &tmpFormat; + } { QImageReader reader(&buffer, *format); #ifndef OS_MAC_OLD diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index ed831de5f..06e10fc37 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -203,7 +203,7 @@ void ShowAddParticipantsError( Ui::show(Box(text), Ui::LayerOption::KeepOther); } -class RevokePublicLinkBox::Inner : public TWidget, private MTP::Sender { +class RevokePublicLinkBox::Inner : public TWidget { public: Inner( QWidget *parent, @@ -228,6 +228,7 @@ private: void updateSelected(); const not_null _session; + MTP::Sender _api; PeerData *_selected = nullptr; PeerData *_pressed = nullptr; @@ -450,6 +451,7 @@ GroupInfoBox::GroupInfoBox( const QString &title, Fn)> channelDone) : _navigation(navigation) +, _api(_navigation->session().api().instance()) , _type(type) , _initialTitle(title) , _channelDone(std::move(channelDone)) { @@ -569,7 +571,7 @@ void GroupInfoBox::createGroup( if (inputs.empty()) { return; } - _creationRequestId = request(MTPmessages_CreateChat( + _creationRequestId = _api.request(MTPmessages_CreateChat( MTP_vector(inputs), MTP_string(title) )).done([=](const MTPUpdates &result) { @@ -645,7 +647,7 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio const auto flags = (_type == Type::Megagroup) ? MTPchannels_CreateChannel::Flag::f_megagroup : MTPchannels_CreateChannel::Flag::f_broadcast; - _creationRequestId = request(MTPchannels_CreateChannel( + _creationRequestId = _api.request(MTPchannels_CreateChannel( MTP_flags(flags), MTP_string(title), MTP_string(description), @@ -682,7 +684,7 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio std::move(image)); } _createdChannel = channel; - _creationRequestId = request(MTPmessages_ExportChatInvite( + _creationRequestId = _api.request(MTPmessages_ExportChatInvite( _createdChannel->input )).done([=](const MTPExportedChatInvite &result) { _creationRequestId = 0; @@ -1287,6 +1289,7 @@ RevokePublicLinkBox::Inner::Inner( Fn revokeCallback) : TWidget(parent) , _session(session) +, _api(_session->api().instance()) , _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom()) , _revokeWidth(st::normalFont->width(tr::lng_channels_too_much_public_revoke(tr::now))) , _revokeCallback(std::move(revokeCallback)) { @@ -1294,7 +1297,7 @@ RevokePublicLinkBox::Inner::Inner( resize(width(), 5 * _rowHeight); - request(MTPchannels_GetAdminedPublicChannels( + _api.request(MTPchannels_GetAdminedPublicChannels( MTP_flags(0) )).done([=](const MTPmessages_Chats &result) { const auto &chats = result.match([](const auto &data) { @@ -1401,7 +1404,7 @@ void RevokePublicLinkBox::Inner::mouseReleaseEvent(QMouseEvent *e) { auto confirmText = tr::lng_channels_too_much_public_revoke(tr::now); _weakRevokeConfirmBox = Ui::show(Box(text, confirmText, crl::guard(this, [this, pressed]() { if (_revokeRequestId) return; - _revokeRequestId = request(MTPchannels_UpdateUsername( + _revokeRequestId = _api.request(MTPchannels_UpdateUsername( pressed->asChannel()->inputChannel, MTP_string() )).done([=](const MTPBool &result) { diff --git a/Telegram/SourceFiles/boxes/add_contact_box.h b/Telegram/SourceFiles/boxes/add_contact_box.h index e97eff55e..488893da8 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.h +++ b/Telegram/SourceFiles/boxes/add_contact_box.h @@ -94,7 +94,7 @@ private: }; -class GroupInfoBox : public Ui::BoxContent, private MTP::Sender { +class GroupInfoBox : public Ui::BoxContent { public: enum class Type { Group, @@ -124,6 +124,7 @@ private: void updateMaxHeight(); const not_null _navigation; + MTP::Sender _api; Type _type = Type::Group; QString _initialTitle; diff --git a/Telegram/SourceFiles/boxes/auto_download_box.cpp b/Telegram/SourceFiles/boxes/auto_download_box.cpp index 21d44e0c2..6b4ff9d48 100644 --- a/Telegram/SourceFiles/boxes/auto_download_box.cpp +++ b/Telegram/SourceFiles/boxes/auto_download_box.cpp @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "main/main_session.h" #include "data/data_session.h" +#include "data/data_auto_download.h" #include "ui/widgets/continuous_sliders.h" #include "ui/widgets/buttons.h" #include "ui/wrap/vertical_layout.h" @@ -24,8 +25,53 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace { constexpr auto kMegabyte = 1024 * 1024; -constexpr auto kDefaultLimit = 10 * kMegabyte; +constexpr auto kDefaultDownloadLimit = 10 * kMegabyte; +constexpr auto kDefaultAutoPlayLimit = 50 * kMegabyte; +using Type = Data::AutoDownload::Type; + +not_null AddSizeLimitSlider( + not_null container, + const base::flat_map &values, + int defaultValue) { + using namespace Settings; + using Pair = base::flat_map::value_type; + + const auto limits = Ui::CreateChild>( + container.get()); + const auto currentLimit = ranges::max_element( + values, + std::less<>(), + [](Pair pair) { return pair.second; })->second; + const auto initialLimit = currentLimit ? currentLimit : defaultValue; + const auto result = Ui::CreateChild(container.get(), initialLimit); + AddButtonWithLabel( + container, + tr::lng_media_size_limit(), + limits->events_starting_with_copy( + initialLimit + ) | rpl::map([](int value) { + return tr::lng_media_size_up_to( + tr::now, + lt_size, + QString::number(value / kMegabyte) + " MB"); + }), + st::autoDownloadLimitButton + )->setAttribute(Qt::WA_TransparentForMouseEvents); + const auto slider = container->add( + object_ptr(container, st::autoDownloadLimitSlider), + st::autoDownloadLimitPadding); + slider->resize(st::autoDownloadLimitSlider.seekSize); + slider->setPseudoDiscrete( + Export::View::kSizeValueCount, + Export::View::SizeLimitByIndex, + *result, + [=](int value) { + *result = value; + limits->fire_copy(value); + }); + return result; +} } // namespace AutoDownloadBox::AutoDownloadBox( @@ -41,12 +87,13 @@ void AutoDownloadBox::prepare() { } void AutoDownloadBox::setupContent() { + using namespace rpl::mappers; using namespace Settings; using namespace Data::AutoDownload; - using namespace rpl::mappers; using Type = Data::AutoDownload::Type; + using Pair = base::flat_map::value_type; - setTitle(tr::lng_media_auto_title()); + setTitle(tr::lng_profile_settings_section()); const auto settings = &_session->settings().autoDownload(); const auto checked = [=](Source source, Type type) { @@ -59,17 +106,10 @@ void AutoDownloadBox::setupContent() { this, std::move(wrap))); - static const auto kHidden = { - Type::Video, - Type::Music, - Type::VoiceMessage - }; - - const auto values = Ui::CreateChild>(content); - const auto add = [&](Type type, rpl::producer label) { - if (ranges::find(kHidden, type) != end(kHidden)) { - return; - } + const auto add = [&]( + not_null*> values, + Type type, + rpl::producer label) { const auto value = settings->bytesLimit(_source, type); AddButton( content, @@ -83,77 +123,78 @@ void AutoDownloadBox::setupContent() { }, content->lifetime()); values->emplace(type, value); }; - add(Type::Photo, tr::lng_media_photo_title()); - add(Type::VoiceMessage, tr::lng_media_audio_title()); - add(Type::VideoMessage, tr::lng_media_video_messages_title()); - add(Type::Video, tr::lng_media_video_title()); - add(Type::File, tr::lng_media_file_title()); - add(Type::Music, tr::lng_media_music_title()); - add(Type::GIF, tr::lng_media_animation_title()); - const auto limits = Ui::CreateChild>(content); - using Pair = base::flat_map::value_type; - const auto settingsLimit = ranges::max_element( - *values, - std::less<>(), - [](Pair pair) { return pair.second; })->second; - const auto initialLimit = settingsLimit ? settingsLimit : kDefaultLimit; - const auto limit = Ui::CreateChild(content, initialLimit); - AddButtonWithLabel( + AddSubsectionTitle(content, tr::lng_media_auto_title()); + + const auto downloadValues = Ui::CreateChild>( + content); + add(downloadValues, Type::Photo, tr::lng_media_photo_title()); + add(downloadValues, Type::File, tr::lng_media_file_title()); + + const auto downloadLimit = AddSizeLimitSlider( content, - tr::lng_media_size_limit(), - limits->events_starting_with_copy( - initialLimit - ) | rpl::map([](int value) { - return tr::lng_media_size_up_to( - tr::now, - lt_size, - QString::number(value / kMegabyte) + " MB"); - }), - st::autoDownloadLimitButton - )->setAttribute(Qt::WA_TransparentForMouseEvents); - const auto slider = content->add( - object_ptr(content, st::autoDownloadLimitSlider), - st::autoDownloadLimitPadding); - slider->resize(st::autoDownloadLimitSlider.seekSize); - slider->setPseudoDiscrete( - Export::View::kSizeValueCount, - Export::View::SizeLimitByIndex, - *limit, - [=](int value) { - *limit = value; - limits->fire_copy(value); - }); + *downloadValues, + kDefaultDownloadLimit); + + AddSkip(content); + AddSubsectionTitle(content, tr::lng_media_auto_play()); + + const auto autoPlayValues = Ui::CreateChild>( + content); + add( + autoPlayValues, + Type::AutoPlayVideoMessage, + tr::lng_media_video_messages_title()); + add(autoPlayValues, Type::AutoPlayVideo, tr::lng_media_video_title()); + add(autoPlayValues, Type::AutoPlayGIF, tr::lng_media_animation_title()); + + const auto autoPlayLimit = AddSizeLimitSlider( + content, + *autoPlayValues, + kDefaultAutoPlayLimit); + + const auto limitByType = [=](Type type) { + return (ranges::find(kAutoPlayTypes, type) != end(kAutoPlayTypes)) + ? *autoPlayLimit + : *downloadLimit; + }; addButton(tr::lng_connection_save(), [=] { - auto allowMore = ranges::view::all( - *values - ) | ranges::view::filter([&](Pair pair) { + auto &&values = ranges::view::concat( + *downloadValues, + *autoPlayValues); + auto allowMore = values | ranges::view::filter([&](Pair pair) { const auto [type, enabled] = pair; - const auto value = enabled ? *limit : 0; + const auto value = enabled ? limitByType(type) : 0; const auto old = settings->bytesLimit(_source, type); return (old < value); }) | ranges::view::transform([](Pair pair) { return pair.first; }); + const auto less = ranges::find_if(*autoPlayValues, [&](Pair pair) { + const auto [type, enabled] = pair; + const auto value = enabled ? limitByType(type) : 0; + return value < settings->bytesLimit(_source, type); + }) != end(*autoPlayValues); const auto allowMoreTypes = base::flat_set( allowMore.begin(), allowMore.end()); - const auto changed = ranges::find_if(*values, [&](Pair pair) { + const auto changed = ranges::find_if(values, [&](Pair pair) { const auto [type, enabled] = pair; - const auto value = enabled ? *limit : 0; - return settings->bytesLimit(_source, type) != value; - }) != end(*values); + const auto value = enabled ? limitByType(type) : 0; + return value != settings->bytesLimit(_source, type); + }) != end(values); + const auto &kHidden = kStreamedTypes; const auto hiddenChanged = ranges::find_if(kHidden, [&](Type type) { const auto now = settings->bytesLimit(_source, type); - return (now > 0) && (now != *limit); + return (now > 0) && (now != limitByType(type)); }) != end(kHidden); if (changed) { - for (const auto [type, enabled] : *values) { - const auto value = enabled ? *limit : 0; + for (const auto [type, enabled] : values) { + const auto value = enabled ? limitByType(type) : 0; settings->setBytesLimit(_source, type, value); } } @@ -161,7 +202,10 @@ void AutoDownloadBox::setupContent() { for (const auto type : kHidden) { const auto now = settings->bytesLimit(_source, type); if (now > 0) { - settings->setBytesLimit(_source, type, *limit); + settings->setBytesLimit( + _source, + type, + limitByType(type)); } } } @@ -175,6 +219,9 @@ void AutoDownloadBox::setupContent() { != allowMoreTypes.end()) { _session->data().documentLoadSettingsChanged(); } + if (less) { + _session->data().checkPlayingVideoFiles(); + } closeBox(); }); addButton(tr::lng_cancel(), [=] { closeBox(); }); diff --git a/Telegram/SourceFiles/boxes/background_box.cpp b/Telegram/SourceFiles/boxes/background_box.cpp index 9d91c177a..f69aac5db 100644 --- a/Telegram/SourceFiles/boxes/background_box.cpp +++ b/Telegram/SourceFiles/boxes/background_box.cpp @@ -53,10 +53,7 @@ QImage TakeMiddleSample(QImage original, QSize size) { } // namespace -class BackgroundBox::Inner - : public Ui::RpWidget - , private MTP::Sender - , private base::Subscriber { +class BackgroundBox::Inner : public Ui::RpWidget, private base::Subscriber { public: Inner( QWidget *parent, @@ -114,6 +111,7 @@ private: void validatePaperThumbnail(const Paper &paper) const; const not_null _session; + MTP::Sender _api; std::vector _papers; @@ -185,6 +183,7 @@ BackgroundBox::Inner::Inner( not_null session) : RpWidget(parent) , _session(session) +, _api(_session->api().instance()) , _check(std::make_unique(st::overviewCheck, [=] { update(); })) { _check->setChecked(true, Ui::RoundCheckbox::SetStyle::Fast); if (_session->data().wallpapers().empty()) { @@ -209,7 +208,7 @@ BackgroundBox::Inner::Inner( } void BackgroundBox::Inner::requestPapers() { - request(MTPaccount_GetWallPapers( + _api.request(MTPaccount_GetWallPapers( MTP_int(_session->data().wallpapersHash()) )).done([=](const MTPaccount_WallPapers &result) { if (_session->data().updateWallpapers(result)) { diff --git a/Telegram/SourceFiles/boxes/background_preview_box.cpp b/Telegram/SourceFiles/boxes/background_preview_box.cpp index 61c3a1c05..e72908a01 100644 --- a/Telegram/SourceFiles/boxes/background_preview_box.cpp +++ b/Telegram/SourceFiles/boxes/background_preview_box.cpp @@ -716,6 +716,9 @@ void BackgroundPreviewBox::checkLoadedDocument() { return; } const auto generateCallback = [=](QImage &&image) { + if (image.isNull()) { + return; + } crl::async([ this, image = std::move(image), diff --git a/Telegram/SourceFiles/boxes/calendar_box.cpp b/Telegram/SourceFiles/boxes/calendar_box.cpp index 25bbbfe79..48cfdd794 100644 --- a/Telegram/SourceFiles/boxes/calendar_box.cpp +++ b/Telegram/SourceFiles/boxes/calendar_box.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "boxes/calendar_box.h" +#include "mtproto/mtproto_rpc_sender.h" #include "ui/widgets/buttons.h" #include "lang/lang_keys.h" #include "ui/effects/ripple_animation.h" diff --git a/Telegram/SourceFiles/boxes/confirm_box.cpp b/Telegram/SourceFiles/boxes/confirm_box.cpp index 402facdc0..c8b6efcd2 100644 --- a/Telegram/SourceFiles/boxes/confirm_box.cpp +++ b/Telegram/SourceFiles/boxes/confirm_box.cpp @@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_channel.h" #include "data/data_chat.h" #include "data/data_user.h" +#include "data/data_file_origin.h" #include "base/unixtime.h" #include "main/main_session.h" #include "observer_peer.h" diff --git a/Telegram/SourceFiles/boxes/confirm_box.h b/Telegram/SourceFiles/boxes/confirm_box.h index 07c4971c0..d3c53edda 100644 --- a/Telegram/SourceFiles/boxes/confirm_box.h +++ b/Telegram/SourceFiles/boxes/confirm_box.h @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once #include "boxes/abstract_box.h" +#include "mtproto/mtproto_rpc_sender.h" namespace Main { class Session; diff --git a/Telegram/SourceFiles/boxes/confirm_phone_box.cpp b/Telegram/SourceFiles/boxes/confirm_phone_box.cpp index 8e4b8bf48..6cd1a62e2 100644 --- a/Telegram/SourceFiles/boxes/confirm_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/confirm_phone_box.cpp @@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "numbers.h" #include "app.h" #include "lang/lang_keys.h" +#include "mtproto/facade.h" #include "styles/style_layers.h" #include "styles/style_boxes.h" diff --git a/Telegram/SourceFiles/boxes/confirm_phone_box.h b/Telegram/SourceFiles/boxes/confirm_phone_box.h index d2963f960..398b8062f 100644 --- a/Telegram/SourceFiles/boxes/confirm_phone_box.h +++ b/Telegram/SourceFiles/boxes/confirm_phone_box.h @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/abstract_box.h" #include "base/timer.h" #include "ui/widgets/input_fields.h" +#include "mtproto/mtproto_rpc_sender.h" namespace Ui { class InputField; diff --git a/Telegram/SourceFiles/boxes/connection_box.cpp b/Telegram/SourceFiles/boxes/connection_box.cpp index e67b894c3..a96648e17 100644 --- a/Telegram/SourceFiles/boxes/connection_box.cpp +++ b/Telegram/SourceFiles/boxes/connection_box.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/call_delayed.h" #include "core/application.h" #include "main/main_account.h" +#include "mtproto/facade.h" #include "ui/widgets/checkbox.h" #include "ui/widgets/buttons.h" #include "ui/widgets/input_fields.h" @@ -38,6 +39,8 @@ namespace { constexpr auto kSaveSettingsDelayedTimeout = crl::time(1000); +using ProxyData = MTP::ProxyData; + class Base64UrlInput : public Ui::MaskedInputField { public: Base64UrlInput( @@ -1057,7 +1060,7 @@ void ProxiesBoxController::refreshChecker(Item &item) { item.state = ItemState::Checking; const auto setup = [&](Checker &checker, const bytes::vector &secret) { - checker = MTP::internal::AbstractConnection::Create( + checker = MTP::details::AbstractConnection::Create( mtproto, type, QThread::currentThread(), @@ -1105,7 +1108,7 @@ void ProxiesBoxController::refreshChecker(Item &item) { } void ProxiesBoxController::setupChecker(int id, const Checker &checker) { - using Connection = MTP::internal::AbstractConnection; + using Connection = MTP::details::AbstractConnection; const auto pointer = checker.get(); pointer->connect(pointer, &Connection::connected, [=] { const auto item = findById(id); @@ -1148,7 +1151,7 @@ object_ptr ProxiesBoxController::create() { for (const auto &item : _list) { updateView(item); } - return std::move(result); + return result; } auto ProxiesBoxController::findById(int id) -> std::vector::iterator { diff --git a/Telegram/SourceFiles/boxes/connection_box.h b/Telegram/SourceFiles/boxes/connection_box.h index 37e7040f2..fbefdacb5 100644 --- a/Telegram/SourceFiles/boxes/connection_box.h +++ b/Telegram/SourceFiles/boxes/connection_box.h @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/timer.h" #include "base/object_ptr.h" #include "mtproto/connection_abstract.h" +#include "mtproto/mtproto_proxy_data.h" namespace Ui { class BoxContent; @@ -25,6 +26,7 @@ class Radioenum; class ProxiesBoxController : public base::Subscriber { public: + using ProxyData = MTP::ProxyData; using Type = ProxyData::Type; ProxiesBoxController(); @@ -73,7 +75,7 @@ public: ~ProxiesBoxController(); private: - using Checker = MTP::internal::ConnectionPointer; + using Checker = MTP::details::ConnectionPointer; struct Item { int id = 0; ProxyData data; diff --git a/Telegram/SourceFiles/boxes/create_poll_box.cpp b/Telegram/SourceFiles/boxes/create_poll_box.cpp index ad9a1db47..11d44d311 100644 --- a/Telegram/SourceFiles/boxes/create_poll_box.cpp +++ b/Telegram/SourceFiles/boxes/create_poll_box.cpp @@ -768,7 +768,7 @@ object_ptr CreatePollBox::setupContent() { FocusAtEnd(question); }, lifetime()); - return std::move(result); + return result; } void CreatePollBox::prepare() { diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.h b/Telegram/SourceFiles/boxes/edit_caption_box.h index 14e7cd5c3..d5136afb4 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.h +++ b/Telegram/SourceFiles/boxes/edit_caption_box.h @@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/storage_media_prepare.h" #include "ui/wrap/slide_wrap.h" #include "media/clip/media_clip_reader.h" +#include "mtproto/mtproto_rpc_sender.h" namespace ChatHelpers { class TabbedPanel; diff --git a/Telegram/SourceFiles/boxes/edit_privacy_box.h b/Telegram/SourceFiles/boxes/edit_privacy_box.h index 1060157fd..4310d1b51 100644 --- a/Telegram/SourceFiles/boxes/edit_privacy_box.h +++ b/Telegram/SourceFiles/boxes/edit_privacy_box.h @@ -100,7 +100,7 @@ private: }; -class EditPrivacyBox : public Ui::BoxContent, private MTP::Sender { +class EditPrivacyBox : public Ui::BoxContent { public: using Value = ApiWrap::Privacy; using Option = Value::Option; diff --git a/Telegram/SourceFiles/boxes/passcode_box.cpp b/Telegram/SourceFiles/boxes/passcode_box.cpp index 19f3d2f2e..8a9ed9318 100644 --- a/Telegram/SourceFiles/boxes/passcode_box.cpp +++ b/Telegram/SourceFiles/boxes/passcode_box.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/confirm_box.h" #include "boxes/confirm_phone_box.h" #include "mainwindow.h" +#include "apiwrap.h" #include "main/main_session.h" #include "storage/localstorage.h" #include "ui/widgets/buttons.h" @@ -47,6 +48,7 @@ PasscodeBox::PasscodeBox( not_null session, bool turningOff) : _session(session) +, _api(_session->api().instance()) , _turningOff(turningOff) , _about(st::boxWidth - st::boxPadding.left() * 1.5) , _oldPasscode(this, st::defaultInputField, tr::lng_passcode_enter_old()) @@ -62,6 +64,7 @@ PasscodeBox::PasscodeBox( not_null session, const CloudFields &fields) : _session(session) +, _api(_session->api().instance()) , _turningOff(fields.turningOff) , _cloudPwd(true) , _cloudFields(fields) @@ -357,7 +360,7 @@ void PasscodeBox::validateEmail( if (_setRequest) { return; } - _setRequest = request(MTPaccount_ConfirmPasswordEmail( + _setRequest = _api.request(MTPaccount_ConfirmPasswordEmail( MTP_string(code) )).done([=](const MTPBool &result) { *set = true; @@ -387,7 +390,7 @@ void PasscodeBox::validateEmail( if (_setRequest) { return; } - _setRequest = request(MTPaccount_ResendPasswordEmail( + _setRequest = _api.request(MTPaccount_ResendPasswordEmail( )).done([=](const MTPBool &result) { _setRequest = 0; resent->fire(tr::lng_cloud_password_resent(tr::now)); @@ -597,8 +600,8 @@ void PasscodeBox::requestPasswordData() { return serverError(); } - request(base::take(_setRequest)).cancel(); - _setRequest = request( + _api.request(base::take(_setRequest)).cancel(); + _setRequest = _api.request( MTPaccount_GetPassword() ).done([=](const MTPaccount_Password &result) { _setRequest = 0; @@ -636,7 +639,7 @@ void PasscodeBox::sendClearCloudPassword( | MTPDaccount_passwordInputSettings::Flag::f_new_password_hash | MTPDaccount_passwordInputSettings::Flag::f_hint | MTPDaccount_passwordInputSettings::Flag::f_email; - _setRequest = request(MTPaccount_UpdatePasswordSettings( + _setRequest = _api.request(MTPaccount_UpdatePasswordSettings( check.result, MTP_account_passwordInputSettings( MTP_flags(flags), @@ -667,7 +670,7 @@ void PasscodeBox::setNewCloudPassword(const QString &newPassword) { | MTPDaccount_passwordInputSettings::Flag::f_hint | MTPDaccount_passwordInputSettings::Flag::f_email; _checkPasswordCallback = nullptr; - _setRequest = request(MTPaccount_UpdatePasswordSettings( + _setRequest = _api.request(MTPaccount_UpdatePasswordSettings( MTP_inputCheckPasswordEmpty(), MTP_account_passwordInputSettings( MTP_flags(flags), @@ -695,7 +698,7 @@ void PasscodeBox::changeCloudPassword( const QString &oldPassword, const Core::CloudPasswordResult &check, const QString &newPassword) { - _setRequest = request(MTPaccount_GetPasswordSettings( + _setRequest = _api.request(MTPaccount_GetPasswordSettings( check.result )).done([=](const MTPaccount_PasswordSettings &result) { _setRequest = 0; @@ -760,7 +763,7 @@ void PasscodeBox::resetSecret( const QString &newPassword, Fn callback) { using Flag = MTPDaccount_passwordInputSettings::Flag; - _setRequest = request(MTPaccount_UpdatePasswordSettings( + _setRequest = _api.request(MTPaccount_UpdatePasswordSettings( check.result, MTP_account_passwordInputSettings( MTP_flags(Flag::f_new_secure_settings), @@ -814,7 +817,7 @@ void PasscodeBox::sendChangeCloudPassword( _cloudFields.newSecureSecretAlgo, bytes::make_span(newPasswordBytes))); } - _setRequest = request(MTPaccount_UpdatePasswordSettings( + _setRequest = _api.request(MTPaccount_UpdatePasswordSettings( check.result, MTP_account_passwordInputSettings( MTP_flags(flags), @@ -873,7 +876,7 @@ void PasscodeBox::emailChanged() { void PasscodeBox::recoverByEmail() { if (_pattern.isEmpty()) { _pattern = "-"; - request(MTPauth_RequestPasswordRecovery( + _api.request(MTPauth_RequestPasswordRecovery( )).done([=](const MTPauth_PasswordRecovery &result) { recoverStarted(result); }).fail([=](const RPCError &error) { diff --git a/Telegram/SourceFiles/boxes/passcode_box.h b/Telegram/SourceFiles/boxes/passcode_box.h index a8ad5ea8c..03ab68f87 100644 --- a/Telegram/SourceFiles/boxes/passcode_box.h +++ b/Telegram/SourceFiles/boxes/passcode_box.h @@ -25,7 +25,7 @@ namespace Core { struct CloudPasswordState; } // namespace Core -class PasscodeBox : public Ui::BoxContent, private MTP::Sender { +class PasscodeBox : public Ui::BoxContent { public: PasscodeBox(QWidget*, not_null session, bool turningOff); @@ -130,6 +130,7 @@ private: void serverError(); const not_null _session; + MTP::Sender _api; QString _pattern; diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 33721e8e4..2ecddf4bc 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -1313,7 +1313,6 @@ void PeerListContent::loadProfilePhotos() { auto yFrom = _visibleTop; auto yTo = _visibleBottom + (_visibleBottom - _visibleTop) * PreloadHeightsCount; - _controller->session().downloader().clearPriorities(); if (yTo < 0) return; if (yFrom < 0) yFrom = 0; diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp index 190c2f372..606ecc4f4 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp @@ -142,7 +142,8 @@ void PeerListRowWithLink::paintAction( PeerListGlobalSearchController::PeerListGlobalSearchController( not_null navigation) -: _navigation(navigation) { +: _navigation(navigation) +, _api(_navigation->session().api().instance()) { _timer.setCallback([this] { searchOnServer(); }); } @@ -169,7 +170,7 @@ bool PeerListGlobalSearchController::searchInCache() { } void PeerListGlobalSearchController::searchOnServer() { - _requestId = request(MTPcontacts_Search( + _requestId = _api.request(MTPcontacts_Search( MTP_string(_query), MTP_int(SearchPeopleLimit) )).done([=](const MTPcontacts_Found &result, mtpRequestId requestId) { diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.h b/Telegram/SourceFiles/boxes/peer_list_controllers.h index ddc4ba4f8..a1a52e701 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.h +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.h @@ -59,9 +59,7 @@ private: }; -class PeerListGlobalSearchController - : public PeerListSearchController - , private MTP::Sender { +class PeerListGlobalSearchController : public PeerListSearchController { public: PeerListGlobalSearchController( not_null navigation); @@ -78,6 +76,7 @@ private: void searchDone(const MTPcontacts_Found &result, mtpRequestId requestId); const not_null _navigation; + MTP::Sender _api; base::Timer _timer; QString _query; mtpRequestId _requestId = 0; diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp index 08c95bc72..ff7d2c3d1 100644 --- a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp @@ -276,6 +276,7 @@ AddSpecialBoxController::AddSpecialBoxController( peer, &_additional)) , _peer(peer) +, _api(_peer->session().api().instance()) , _role(role) , _additional(peer, Role::Members) , _adminDoneCallback(std::move(adminDoneCallback)) @@ -408,7 +409,7 @@ void AddSpecialBoxController::loadMoreRows() { const auto participantsHash = 0; const auto channel = _peer->asChannel(); - _loadRequestId = request(MTPchannels_GetParticipants( + _loadRequestId = _api.request(MTPchannels_GetParticipants( channel->inputChannel, MTP_channelParticipantsRecent(), MTP_int(_offset), @@ -464,7 +465,7 @@ bool AddSpecialBoxController::checkInfoLoaded( // We don't know what this user status is in the group. const auto channel = _peer->asChannel(); - request(MTPchannels_GetParticipant( + _api.request(MTPchannels_GetParticipant( channel->inputChannel, user->inputUser )).done([=](const MTPchannels_ChannelParticipant &result) { @@ -829,6 +830,7 @@ AddSpecialBoxSearchController::AddSpecialBoxSearchController( not_null additional) : _peer(peer) , _additional(additional) +, _api(_peer->session().api().instance()) , _timer([=] { searchOnServer(); }) { subscribeToMigration(); } @@ -924,7 +926,7 @@ void AddSpecialBoxSearchController::requestParticipants() { const auto participantsHash = 0; const auto channel = _peer->asChannel(); - _requestId = request(MTPchannels_GetParticipants( + _requestId = _api.request(MTPchannels_GetParticipants( channel->inputChannel, MTP_channelParticipantsSearch(MTP_string(_query)), MTP_int(_offset), @@ -1012,7 +1014,7 @@ void AddSpecialBoxSearchController::requestGlobal() { } auto perPage = SearchPeopleLimit; - _requestId = request(MTPcontacts_Search( + _requestId = _api.request(MTPcontacts_Search( MTP_string(_query), MTP_int(perPage) )).done([=](const MTPcontacts_Found &result, mtpRequestId requestId) { diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.h b/Telegram/SourceFiles/boxes/peers/add_participants_box.h index d15f474e8..2761d172d 100644 --- a/Telegram/SourceFiles/boxes/peers/add_participants_box.h +++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.h @@ -69,7 +69,6 @@ private: class AddSpecialBoxController : public PeerListController , private base::Subscriber - , private MTP::Sender , public base::has_weak_ptr { public: using Role = ParticipantsBoxController::Role; @@ -87,12 +86,12 @@ public: AdminDoneCallback adminDoneCallback, BannedDoneCallback bannedDoneCallback); - Main::Session &session() const override; + [[nodiscard]] Main::Session &session() const override; void prepare() override; void rowClicked(not_null row) override; void loadMoreRows() override; - std::unique_ptr createSearchRow( + [[nodiscard]] std::unique_ptr createSearchRow( not_null peer) override; private: @@ -120,6 +119,7 @@ private: void migrate(not_null channel); not_null _peer; + MTP::Sender _api; Role _role = Role::Admins; int _offset = 0; mtpRequestId _loadRequestId = 0; @@ -139,7 +139,6 @@ protected: // Finds chat/channel members, then contacts, then global search results. class AddSpecialBoxSearchController : public PeerListSearchController - , private MTP::Sender , private base::Subscriber { public: using Role = ParticipantsBoxController::Role; @@ -181,6 +180,7 @@ private: not_null _peer; not_null _additional; + MTP::Sender _api; base::Timer _timer; QString _query; diff --git a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp index d490a38f4..cc55265a8 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp @@ -223,7 +223,7 @@ object_ptr SetupAbout( tr::now, Ui::Text::WithEntities); }()); - return std::move(about); + return about; } object_ptr SetupFooter( diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.h b/Telegram/SourceFiles/boxes/peers/edit_participant_box.h index 7ef9e877e..689b08a7b 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.h @@ -10,6 +10,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/abstract_box.h" #include "base/unique_qptr.h" +class RPCError; + namespace Ui { class FlatLabel; class LinkButton; diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index af2cedbfe..afe9af512 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -750,6 +750,7 @@ ParticipantsBoxController::ParticipantsBoxController( : PeerListController(CreateSearchController(peer, role, &_additional)) , _navigation(navigation) , _peer(peer) +, _api(_peer->session().api().instance()) , _role(role) , _additional(peer, _role) { subscribeToMigration(); @@ -1029,7 +1030,7 @@ void ParticipantsBoxController::restoreState( : nullptr; if (const auto my = dynamic_cast(typeErasedState)) { if (const auto requestId = base::take(_loadRequestId)) { - request(requestId).cancel(); + _api.request(requestId).cancel(); } _additional = std::move(my->additional); @@ -1260,7 +1261,7 @@ void ParticipantsBoxController::loadMoreRows() { : kParticipantsFirstPageCount; const auto participantsHash = 0; - _loadRequestId = request(MTPchannels_GetParticipants( + _loadRequestId = _api.request(MTPchannels_GetParticipants( channel->inputChannel, filter, MTP_int(_offset), @@ -1797,7 +1798,7 @@ std::unique_ptr ParticipantsBoxController::createRow( row->setActionLink(tr::lng_profile_kick(tr::now)); } } - return std::move(row); + return row; } auto ParticipantsBoxController::computeType( @@ -1920,7 +1921,8 @@ ParticipantsBoxSearchController::ParticipantsBoxSearchController( not_null additional) : _channel(channel) , _role(role) -, _additional(additional) { +, _additional(additional) +, _api(_channel->session().api().instance()) { _timer.setCallback([=] { searchOnServer(); }); } @@ -1945,14 +1947,14 @@ auto ParticipantsBoxSearchController::saveState() const result->offset = _offset; result->allLoaded = _allLoaded; result->wasLoading = (_requestId != 0); - return std::move(result); + return result; } void ParticipantsBoxSearchController::restoreState( std::unique_ptr state) { if (auto my = dynamic_cast(state.get())) { if (auto requestId = base::take(_requestId)) { - request(requestId).cancel(); + _api.request(requestId).cancel(); } _cache.clear(); _queries.clear(); @@ -2017,7 +2019,7 @@ bool ParticipantsBoxSearchController::loadMoreRows() { auto perPage = kParticipantsPerPage; auto participantsHash = 0; - _requestId = request(MTPchannels_GetParticipants( + _requestId = _api.request(MTPchannels_GetParticipants( _channel->inputChannel, filter, MTP_int(_offset), diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.h b/Telegram/SourceFiles/boxes/peers/edit_participants_box.h index db271a3aa..0e958751f 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.h @@ -135,7 +135,6 @@ private: class ParticipantsBoxController : public PeerListController , private base::Subscriber - , private MTP::Sender , public base::has_weak_ptr { public: using Role = ParticipantsRole; @@ -239,6 +238,7 @@ private: not_null _navigation; not_null _peer; + MTP::Sender _api; Role _role = Role::Admins; int _offset = 0; mtpRequestId _loadRequestId = 0; @@ -252,9 +252,7 @@ private: }; // Members, banned and restricted users server side search. -class ParticipantsBoxSearchController - : public PeerListSearchController - , private MTP::Sender { +class ParticipantsBoxSearchController : public PeerListSearchController { public: using Role = ParticipantsBoxController::Role; @@ -296,6 +294,7 @@ private: not_null _channel; Role _role = Role::Restricted; not_null _additional; + MTP::Sender _api; base::Timer _timer; QString _query; diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index d14fbde3d..5ee2cd89a 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -240,9 +240,7 @@ namespace { constexpr auto kMaxGroupChannelTitle = 128; // See also add_contact_box. constexpr auto kMaxChannelDescription = 255; // See also add_contact_box. -class Controller - : public base::has_weak_ptr - , private MTP::Sender { +class Controller : public base::has_weak_ptr { public: Controller( not_null navigation, @@ -334,6 +332,7 @@ private: const not_null _navigation; const not_null _box; not_null _peer; + MTP::Sender _api; const bool _isGroup = false; base::unique_qptr _wrap; @@ -344,7 +343,6 @@ private: const rpl::event_stream _privacyTypeUpdates; const rpl::event_stream _linkedChatUpdates; - MTP::Sender _linkedChatsRequester; mtpRequestId _linkedChatsRequestId = 0; rpl::lifetime _lifetime; @@ -358,6 +356,7 @@ Controller::Controller( : _navigation(navigation) , _box(box) , _peer(peer) +, _api(_peer->session().api().instance()) , _isGroup(_peer->isChat() || _peer->isMegagroup()) { _box->setTitle(_isGroup ? tr::lng_edit_group() @@ -478,7 +477,7 @@ object_ptr Controller::createTitleEdit() { [=] { submitTitle(); }); _controls.title = result->entity(); - return std::move(result); + return result; } object_ptr Controller::createDescriptionEdit() { @@ -512,7 +511,7 @@ object_ptr Controller::createDescriptionEdit() { [=] { submitDescription(); }); _controls.description = result->entity(); - return std::move(result); + return result; } object_ptr Controller::createManageGroupButtons() { @@ -526,7 +525,7 @@ object_ptr Controller::createManageGroupButtons() { fillManageSection(); - return std::move(result); + return result; } object_ptr Controller::createStickersEdit() { @@ -564,7 +563,7 @@ object_ptr Controller::createStickersEdit() { Ui::show(Box(channel), Ui::LayerOption::KeepOther); }); - return std::move(result); + return result; } bool Controller::canEditInformation() const { @@ -644,7 +643,7 @@ void Controller::showEditLinkedChatBox() { callback(_linkedChatOriginalValue); return; } - _linkedChatsRequestId = _linkedChatsRequester.request( + _linkedChatsRequestId = _api.request( MTPchannels_GetGroupsForDiscussion() ).done([=](const MTPmessages_Chats &result) { _linkedChatsRequestId = 0; @@ -1187,7 +1186,7 @@ void Controller::saveUsername() { return; } - request(MTPchannels_UpdateUsername( + _api.request(MTPchannels_UpdateUsername( channel->inputChannel, MTP_string(*_savingData.username) )).done([=](const MTPBool &result) { @@ -1242,7 +1241,7 @@ void Controller::saveLinkedChat() { const auto input = *_savingData.linkedChat ? (*_savingData.linkedChat)->inputChannel : MTP_inputChannelEmpty(); - request(MTPchannels_SetDiscussionGroup( + _api.request(MTPchannels_SetDiscussionGroup( (channel->isBroadcast() ? channel->inputChannel : input), (channel->isBroadcast() ? input : channel->inputChannel) )).done([=](const MTPBool &result) { @@ -1283,14 +1282,14 @@ void Controller::saveTitle() { }; if (const auto channel = _peer->asChannel()) { - request(MTPchannels_EditTitle( + _api.request(MTPchannels_EditTitle( channel->inputChannel, MTP_string(*_savingData.title) )).done(std::move(onDone) ).fail(std::move(onFail) ).send(); } else if (const auto chat = _peer->asChat()) { - request(MTPmessages_EditChatTitle( + _api.request(MTPmessages_EditChatTitle( chat->inputChat, MTP_string(*_savingData.title) )).done(std::move(onDone) @@ -1311,7 +1310,7 @@ void Controller::saveDescription() { _peer->setAbout(*_savingData.description); continueSave(); }; - request(MTPmessages_EditChatAbout( + _api.request(MTPmessages_EditChatAbout( _peer->input, MTP_string(*_savingData.description) )).done([=](const MTPBool &result) { @@ -1368,7 +1367,7 @@ void Controller::togglePreHistoryHidden( done(); }; - request(MTPchannels_TogglePreHistoryHidden( + _api.request(MTPchannels_TogglePreHistoryHidden( channel->inputChannel, MTP_bool(hidden) )).done([=](const MTPUpdates &result) { @@ -1390,7 +1389,7 @@ void Controller::saveSignatures() { || *_savingData.signatures == channel->addsSignature()) { return continueSave(); } - request(MTPchannels_ToggleSignatures( + _api.request(MTPchannels_ToggleSignatures( channel->inputChannel, MTP_bool(*_savingData.signatures) )).done([=](const MTPUpdates &result) { diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp index 7c67aba61..71ee082ca 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp @@ -51,9 +51,7 @@ namespace { constexpr auto kUsernameCheckTimeout = crl::time(200); constexpr auto kMinUsernameLength = 5; -class Controller - : public base::has_weak_ptr - , private MTP::Sender { +class Controller : public base::has_weak_ptr { public: Controller( not_null container, @@ -144,6 +142,7 @@ private: QString inviteLinkText(); not_null _peer; + MTP::Sender _api; std::optional _privacySavedValue; std::optional _usernameSavedValue; @@ -169,6 +168,7 @@ Controller::Controller( std::optional privacySavedValue, std::optional usernameSavedValue) : _peer(peer) +, _api(_peer->session().api().instance()) , _privacySavedValue(privacySavedValue) , _usernameSavedValue(usernameSavedValue) , _useLocationPhrases(useLocationPhrases) @@ -364,7 +364,7 @@ object_ptr Controller::createUsernameEdit() { const auto shown = (_controls.privacy->value() == Privacy::HasUsername); result->toggle(shown, anim::type::instant); - return std::move(result); + return result; } void Controller::privacyChanged(Privacy value) { @@ -401,7 +401,7 @@ void Controller::privacyChanged(Privacy value) { refreshVisibilities(); _controls.usernameInput->setDisplayFocused(true); } else { - request(base::take(_checkUsernameRequestId)).cancel(); + _api.request(base::take(_checkUsernameRequestId)).cancel(); _checkUsernameTimer.cancel(); refreshVisibilities(); } @@ -420,11 +420,11 @@ void Controller::checkUsernameAvailability() { return; } if (_checkUsernameRequestId) { - request(_checkUsernameRequestId).cancel(); + _api.request(_checkUsernameRequestId).cancel(); } const auto channel = _peer->migrateToOrMe()->asChannel(); const auto username = channel ? channel->username : QString(); - _checkUsernameRequestId = request(MTPchannels_CheckUsername( + _checkUsernameRequestId = _api.request(MTPchannels_CheckUsername( channel ? channel->inputChannel : MTP_inputChannelEmpty(), MTP_string(checking) )).done([=](const MTPBool &result) { @@ -630,7 +630,7 @@ object_ptr Controller::createInviteLinkEdit() { observeInviteLink(); - return std::move(result); + return result; } void Controller::refreshEditInviteLink() { @@ -692,7 +692,7 @@ object_ptr Controller::createInviteLinkCreate() { observeInviteLink(); - return std::move(result); + return result; } void Controller::refreshCreateInviteLink() { diff --git a/Telegram/SourceFiles/boxes/rate_call_box.cpp b/Telegram/SourceFiles/boxes/rate_call_box.cpp index be102184b..85294a3fe 100644 --- a/Telegram/SourceFiles/boxes/rate_call_box.cpp +++ b/Telegram/SourceFiles/boxes/rate_call_box.cpp @@ -31,6 +31,7 @@ RateCallBox::RateCallBox( uint64 callId, uint64 callAccessHash) : _session(session) +, _api(_session->api().instance()) , _callId(callId) , _callAccessHash(callAccessHash) { } @@ -120,7 +121,7 @@ void RateCallBox::send() { return; } auto comment = _comment ? _comment->getLastText().trimmed() : QString(); - _requestId = request(MTPphone_SetCallRating( + _requestId = _api.request(MTPphone_SetCallRating( MTP_flags(0), MTP_inputPhoneCall(MTP_long(_callId), MTP_long(_callAccessHash)), MTP_int(_rating), diff --git a/Telegram/SourceFiles/boxes/rate_call_box.h b/Telegram/SourceFiles/boxes/rate_call_box.h index 9efaa4d53..99ca677d8 100644 --- a/Telegram/SourceFiles/boxes/rate_call_box.h +++ b/Telegram/SourceFiles/boxes/rate_call_box.h @@ -20,7 +20,7 @@ namespace Main { class Session; } // namespace Main -class RateCallBox : public Ui::BoxContent, private MTP::Sender { +class RateCallBox : public Ui::BoxContent { public: RateCallBox( QWidget*, @@ -41,6 +41,7 @@ private: void commentResized(); const not_null _session; + MTP::Sender _api; uint64 _callId = 0; uint64 _callAccessHash = 0; diff --git a/Telegram/SourceFiles/boxes/report_box.cpp b/Telegram/SourceFiles/boxes/report_box.cpp index 5ad271db2..28697df52 100644 --- a/Telegram/SourceFiles/boxes/report_box.cpp +++ b/Telegram/SourceFiles/boxes/report_box.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/buttons.h" #include "ui/widgets/input_fields.h" #include "ui/toast/toast.h" +#include "mtproto/facade.h" #include "mainwindow.h" #include "styles/style_layers.h" #include "styles/style_boxes.h" diff --git a/Telegram/SourceFiles/boxes/report_box.h b/Telegram/SourceFiles/boxes/report_box.h index d7afc3761..05782b8ce 100644 --- a/Telegram/SourceFiles/boxes/report_box.h +++ b/Telegram/SourceFiles/boxes/report_box.h @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once #include "boxes/abstract_box.h" +#include "mtproto/mtproto_rpc_sender.h" namespace Ui { template diff --git a/Telegram/SourceFiles/boxes/self_destruction_box.cpp b/Telegram/SourceFiles/boxes/self_destruction_box.cpp index 79b5cf517..acc9e2427 100644 --- a/Telegram/SourceFiles/boxes/self_destruction_box.cpp +++ b/Telegram/SourceFiles/boxes/self_destruction_box.cpp @@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/checkbox.h" #include "ui/widgets/labels.h" #include "apiwrap.h" +#include "api/api_self_destruct.h" #include "main/main_session.h" #include "styles/style_layers.h" #include "styles/style_boxes.h" @@ -76,7 +77,7 @@ void SelfDestructionBox::showContent() { clearButtons(); addButton(tr::lng_settings_save(), [=] { - _session->api().saveSelfDestruct(_ttlGroup->value()); + _session->api().selfDestruct().update(_ttlGroup->value()); closeBox(); }); addButton(tr::lng_cancel(), [=] { closeBox(); }); diff --git a/Telegram/SourceFiles/boxes/self_destruction_box.h b/Telegram/SourceFiles/boxes/self_destruction_box.h index 475f59749..95f7928c8 100644 --- a/Telegram/SourceFiles/boxes/self_destruction_box.h +++ b/Telegram/SourceFiles/boxes/self_destruction_box.h @@ -20,7 +20,7 @@ namespace Main { class Session; } // namespace Main -class SelfDestructionBox : public Ui::BoxContent, private MTP::Sender { +class SelfDestructionBox : public Ui::BoxContent { public: SelfDestructionBox( QWidget*, diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 0f5a43054..3bbd168da 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -365,6 +365,7 @@ void AlbumThumb::prepareCache(QSize size, int shrink) { ImageRoundRadius::Large, _albumCorners, QRect(QPoint(), size * cIntRetinaFactor())); + _albumCache.setDevicePixelRatio(cRetinaFactor()); } void AlbumThumb::drawSimpleFrame(Painter &p, QRect to, QSize size) const { diff --git a/Telegram/SourceFiles/boxes/sessions_box.cpp b/Telegram/SourceFiles/boxes/sessions_box.cpp index 91247790d..071058b17 100644 --- a/Telegram/SourceFiles/boxes/sessions_box.cpp +++ b/Telegram/SourceFiles/boxes/sessions_box.cpp @@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/localstorage.h" #include "mainwidget.h" #include "mainwindow.h" +#include "apiwrap.h" #include "main/main_session.h" #include "data/data_session.h" #include "base/unixtime.h" @@ -77,6 +78,7 @@ private: SessionsBox::SessionsBox(QWidget*, not_null session) : _session(session) +, _api(_session->api().instance()) , _shortPollTimer([=] { shortPollSessions(); }) { } @@ -280,7 +282,7 @@ void SessionsBox::shortPollSessions() { if (_shortPollRequest) { return; } - _shortPollRequest = request(MTPaccount_GetAuthorizations( + _shortPollRequest = _api.request(MTPaccount_GetAuthorizations( )).done([=](const MTPaccount_Authorizations &result) { got(result); }).send(); @@ -294,7 +296,7 @@ void SessionsBox::terminateOne(uint64 hash) { _terminateBox->closeBox(); _terminateBox = nullptr; } - request(MTPaccount_ResetAuthorization( + _api.request(MTPaccount_ResetAuthorization( MTP_long(hash) )).done([=](const MTPBool &result) { _inner->terminatingOne(hash, false); @@ -330,12 +332,12 @@ void SessionsBox::terminateAll() { _terminateBox->closeBox(); _terminateBox = nullptr; } - request(MTPauth_ResetAuthorizations( + _api.request(MTPauth_ResetAuthorizations( )).done([=](const MTPBool &result) { - request(base::take(_shortPollRequest)).cancel(); + _api.request(base::take(_shortPollRequest)).cancel(); shortPollSessions(); }).fail([=](const RPCError &result) { - request(base::take(_shortPollRequest)).cancel(); + _api.request(base::take(_shortPollRequest)).cancel(); shortPollSessions(); }).send(); setLoading(true); diff --git a/Telegram/SourceFiles/boxes/sessions_box.h b/Telegram/SourceFiles/boxes/sessions_box.h index b27ec5dd4..b2c7953eb 100644 --- a/Telegram/SourceFiles/boxes/sessions_box.h +++ b/Telegram/SourceFiles/boxes/sessions_box.h @@ -22,7 +22,7 @@ namespace Main { class Session; } // namespace Main -class SessionsBox : public Ui::BoxContent, private MTP::Sender { +class SessionsBox : public Ui::BoxContent { public: SessionsBox(QWidget*, not_null session); @@ -60,6 +60,7 @@ private: void terminateAll(); const not_null _session; + MTP::Sender _api; bool _loading = false; Full _data; diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index 0f319b401..49c2b32ee 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -722,7 +722,6 @@ void ShareBox::Inner::loadProfilePhotos(int yFrom) { yFrom *= _columnCount; yTo *= _columnCount; - _navigation->session().downloader().clearPriorities(); if (_filter.isEmpty()) { if (!_chatsIndexed->empty()) { auto i = _chatsIndexed->cfind(yFrom, _rowHeight); diff --git a/Telegram/SourceFiles/boxes/share_box.h b/Telegram/SourceFiles/boxes/share_box.h index 55d223c04..b5d3f5397 100644 --- a/Telegram/SourceFiles/boxes/share_box.h +++ b/Telegram/SourceFiles/boxes/share_box.h @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/timer.h" #include "ui/effects/animations.h" #include "ui/effects/round_checkbox.h" +#include "mtproto/mtproto_rpc_sender.h" enum class SendMenuType; diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 597d71826..ca7130b2b 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_document.h" #include "data/data_session.h" +#include "data/data_file_origin.h" #include "lang/lang_keys.h" #include "chat_helpers/stickers.h" #include "boxes/confirm_box.h" @@ -99,7 +100,7 @@ private: void showPreview(); not_null _controller; - MTP::Sender _mtp; + MTP::Sender _api; std::vector _elements; std::unique_ptr _lottiePlayer; Stickers::Pack _pack; @@ -220,6 +221,7 @@ StickerSetBox::Inner::Inner( const MTPInputStickerSet &set) : RpWidget(parent) , _controller(controller) +, _api(_controller->session().api().instance()) , _input(set) , _previewTimer([=] { showPreview(); }) { set.match([&](const MTPDinputStickerSetID &data) { @@ -231,7 +233,7 @@ StickerSetBox::Inner::Inner( }, [&](const MTPDinputStickerSetAnimatedEmoji &) { }); - _mtp.request(MTPmessages_GetStickerSet( + _api.request(MTPmessages_GetStickerSet( _input )).done([=](const MTPmessages_StickerSet &result) { gotSet(result); @@ -700,7 +702,7 @@ void StickerSetBox::Inner::install() { } else if (_installRequest) { return; } - _installRequest = _mtp.request(MTPmessages_InstallStickerSet( + _installRequest = _api.request(MTPmessages_InstallStickerSet( _input, MTP_bool(false) )).done([=](const MTPmessages_StickerSetInstallResult &result) { diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index c426a2316..5ffdfc131 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_document.h" #include "data/data_session.h" #include "data/data_channel.h" +#include "data/data_file_origin.h" #include "core/application.h" #include "lang/lang_keys.h" #include "mainwidget.h" @@ -410,7 +411,7 @@ void StickersBox::updateTabsGeometry() { auto featuredLeft = width() / 3; auto featuredRight = 2 * width() / 3; - auto featuredTextWidth = st::stickersTabs.labelFont->width(tr::lng_stickers_featured_tab(tr::now).toUpper()); + auto featuredTextWidth = st::stickersTabs.labelStyle.font->width(tr::lng_stickers_featured_tab(tr::now).toUpper()); auto featuredTextRight = featuredLeft + (featuredRight - featuredLeft - featuredTextWidth) / 2 + featuredTextWidth; auto unreadBadgeLeft = featuredTextRight - st::stickersFeaturedBadgeSkip; auto unreadBadgeTop = st::stickersFeaturedBadgeTop; @@ -661,6 +662,7 @@ StickersBox::Inner::Inner( StickersBox::Section section) : RpWidget(parent) , _session(session) +, _api(_session->api().instance()) , _section(section) , _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom()) , _shiftingAnimation([=](crl::time now) { @@ -677,6 +679,7 @@ StickersBox::Inner::Inner( StickersBox::Inner::Inner(QWidget *parent, not_null megagroup) : RpWidget(parent) , _session(&megagroup->session()) +, _api(_session->api().instance()) , _section(StickersBox::Section::Installed) , _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom()) , _shiftingAnimation([=](crl::time now) { @@ -1469,11 +1472,13 @@ void StickersBox::Inner::handleMegagroupSetAddressChange() { } } } else if (!_megagroupSetRequestId) { - _megagroupSetRequestId = request(MTPmessages_GetStickerSet(MTP_inputStickerSetShortName(MTP_string(text)))).done([this](const MTPmessages_StickerSet &result) { + _megagroupSetRequestId = _api.request(MTPmessages_GetStickerSet( + MTP_inputStickerSetShortName(MTP_string(text)) + )).done([=](const MTPmessages_StickerSet &result) { _megagroupSetRequestId = 0; auto set = Stickers::FeedSetFull(result); setMegagroupSelectedSet(MTP_inputStickerSetID(MTP_long(set->id), MTP_long(set->access))); - }).fail([this](const RPCError &error) { + }).fail([=](const RPCError &error) { _megagroupSetRequestId = 0; setMegagroupSelectedSet(MTP_inputStickerSetEmpty()); }).send(); diff --git a/Telegram/SourceFiles/boxes/stickers_box.h b/Telegram/SourceFiles/boxes/stickers_box.h index d5aba39ed..3cdd90a18 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.h +++ b/Telegram/SourceFiles/boxes/stickers_box.h @@ -153,8 +153,7 @@ private: // This class is hold in header because it requires Qt preprocessing. class StickersBox::Inner : public Ui::RpWidget - , private base::Subscriber - , private MTP::Sender { + , private base::Subscriber { Q_OBJECT public: @@ -320,6 +319,7 @@ private: int countMaxNameWidth() const; const not_null _session; + MTP::Sender _api; Section _section; diff --git a/Telegram/SourceFiles/boxes/username_box.h b/Telegram/SourceFiles/boxes/username_box.h index 2cc31dd52..3a78c6596 100644 --- a/Telegram/SourceFiles/boxes/username_box.h +++ b/Telegram/SourceFiles/boxes/username_box.h @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once #include "boxes/abstract_box.h" +#include "mtproto/mtproto_rpc_sender.h" namespace Ui { class UsernameInput; diff --git a/Telegram/SourceFiles/calls/calls_box_controller.cpp b/Telegram/SourceFiles/calls/calls_box_controller.cpp index 937c34a74..7b2000892 100644 --- a/Telegram/SourceFiles/calls/calls_box_controller.cpp +++ b/Telegram/SourceFiles/calls/calls_box_controller.cpp @@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "data/data_media_types.h" #include "data/data_user.h" +#include "apiwrap.h" #include "facades.h" #include "app.h" @@ -216,7 +217,8 @@ void BoxController::Row::stopLastActionRipple() { } BoxController::BoxController(not_null window) -: _window(window) { +: _window(window) +, _api(_window->session().api().instance()) { } Main::Session &BoxController::session() const { @@ -256,7 +258,7 @@ void BoxController::loadMoreRows() { return; } - _loadRequestId = request(MTPmessages_Search( + _loadRequestId = _api.request(MTPmessages_Search( MTP_flags(0), MTP_inputPeerEmpty(), MTP_string(), @@ -404,8 +406,7 @@ BoxController::Row *BoxController::rowForItem(not_null item) std::unique_ptr BoxController::createRow( not_null item) const { - auto row = std::make_unique(item); - return std::move(row); + return std::make_unique(item); } } // namespace Calls diff --git a/Telegram/SourceFiles/calls/calls_box_controller.h b/Telegram/SourceFiles/calls/calls_box_controller.h index 9833469f1..d67e22c04 100644 --- a/Telegram/SourceFiles/calls/calls_box_controller.h +++ b/Telegram/SourceFiles/calls/calls_box_controller.h @@ -15,10 +15,7 @@ class SessionController; namespace Calls { -class BoxController - : public PeerListController - , private base::Subscriber - , private MTP::Sender { +class BoxController : public PeerListController, private base::Subscriber { public: explicit BoxController(not_null window); @@ -44,6 +41,7 @@ private: not_null item) const; const not_null _window; + MTP::Sender _api; MsgId _offsetId = 0; mtpRequestId _loadRequestId = 0; diff --git a/Telegram/SourceFiles/calls/calls_call.cpp b/Telegram/SourceFiles/calls/calls_call.cpp index 428ebf94f..bf57bdca4 100644 --- a/Telegram/SourceFiles/calls/calls_call.cpp +++ b/Telegram/SourceFiles/calls/calls_call.cpp @@ -14,7 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/rate_call_box.h" #include "calls/calls_instance.h" #include "base/openssl_help.h" -#include "mtproto/connection.h" +#include "mtproto/mtproto_dh_utils.h" #include "media/audio/media_audio_track.h" #include "base/platform/base_platform_info.h" #include "calls/calls_panel.h" @@ -130,6 +130,7 @@ Call::Call( Type type) : _delegate(delegate) , _user(user) +, _api(_user->session().api().instance()) , _type(type) { _discardByTimeoutTimer.setCallback([this] { hangup(); }); @@ -189,7 +190,7 @@ void Call::startOutgoing() { Expects(_state == State::Requesting); Expects(_gaHash.size() == kSha256Size); - request(MTPphone_RequestCall( + _api.request(MTPphone_RequestCall( MTP_flags(0), _user->inputUser, MTP_int(rand_value()), @@ -236,11 +237,13 @@ void Call::startIncoming() { Expects(_type == Type::Incoming); Expects(_state == State::Starting); - request(MTPphone_ReceivedCall(MTP_inputPhoneCall(MTP_long(_id), MTP_long(_accessHash)))).done([this](const MTPBool &result) { + _api.request(MTPphone_ReceivedCall( + MTP_inputPhoneCall(MTP_long(_id), MTP_long(_accessHash)) + )).done([=](const MTPBool &result) { if (_state == State::Starting) { setState(State::WaitingIncoming); } - }).fail([this](const RPCError &error) { + }).fail([=](const RPCError &error) { handleRequestError(error); }).send(); } @@ -267,7 +270,7 @@ void Call::actuallyAnswer() { } else { _answerAfterDhConfigReceived = false; } - request(MTPphone_AcceptCall( + _api.request(MTPphone_AcceptCall( MTP_inputPhoneCall(MTP_long(_id), MTP_long(_accessHash)), MTP_bytes(_gb), MTP_phoneCallProtocol( @@ -504,7 +507,7 @@ void Call::confirmAcceptedCall(const MTPDphoneCallAccepted &call) { _keyFingerprint = ComputeFingerprint(_authKey); setState(State::ExchangingKeys); - request(MTPphone_ConfirmCall( + _api.request(MTPphone_ConfirmCall( MTP_inputPhoneCall(MTP_long(_id), MTP_long(_accessHash)), MTP_bytes(_ga), MTP_long(_keyFingerprint), @@ -623,10 +626,10 @@ void Call::createAndStartController(const MTPDphoneCall &call) { _controller->SetEncryptionKey(reinterpret_cast(_authKey.data()), (_type == Type::Outgoing)); _controller->SetCallbacks(callbacks); if (Global::UseProxyForCalls() - && (Global::ProxySettings() == ProxyData::Settings::Enabled)) { + && (Global::ProxySettings() == MTP::ProxyData::Settings::Enabled)) { const auto &proxy = Global::SelectedProxy(); if (proxy.supportsCalls()) { - Assert(proxy.type == ProxyData::Type::Socks5); + Assert(proxy.type == MTP::ProxyData::Type::Socks5); _controller->SetProxy( tgvoip::PROXY_SOCKS5, proxy.host.toStdString(), @@ -840,7 +843,7 @@ void Call::finish(FinishType type, const MTPPhoneCallDiscardReason &reason) { auto duration = getDurationMs() / 1000; auto connectionId = _controller ? _controller->GetPreferredRelayID() : 0; _finishByTimeoutTimer.call(kHangupTimeoutMs, [this, finalState] { setState(finalState); }); - request(MTPphone_DiscardCall( + _api.request(MTPphone_DiscardCall( MTP_flags(0), MTP_inputPhoneCall( MTP_long(_id), diff --git a/Telegram/SourceFiles/calls/calls_call.h b/Telegram/SourceFiles/calls/calls_call.h index 04ade9804..98bc6b5a6 100644 --- a/Telegram/SourceFiles/calls/calls_call.h +++ b/Telegram/SourceFiles/calls/calls_call.h @@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/timer.h" #include "base/bytes.h" #include "mtproto/sender.h" -#include "mtproto/auth_key.h" +#include "mtproto/mtproto_auth_key.h" namespace Media { namespace Audio { @@ -31,7 +31,7 @@ struct DhConfig { bytes::vector p; }; -class Call : public base::has_weak_ptr, private MTP::Sender { +class Call : public base::has_weak_ptr { public: class Delegate { public: @@ -183,6 +183,7 @@ private: not_null _delegate; not_null _user; + MTP::Sender _api; Type _type = Type::Outgoing; State _state = State::Starting; FinishType _finishAfterRequestingCall = FinishType::None; diff --git a/Telegram/SourceFiles/calls/calls_instance.cpp b/Telegram/SourceFiles/calls/calls_instance.cpp index b8d6a0a9c..ff4c90f62 100644 --- a/Telegram/SourceFiles/calls/calls_instance.cpp +++ b/Telegram/SourceFiles/calls/calls_instance.cpp @@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "calls/calls_instance.h" -#include "mtproto/connection.h" +#include "mtproto/mtproto_dh_utils.h" #include "core/application.h" #include "main/main_session.h" #include "apiwrap.h" @@ -32,7 +32,9 @@ constexpr auto kServerConfigUpdateTimeoutMs = 24 * 3600 * crl::time(1000); } // namespace -Instance::Instance(not_null session) : _session(session) { +Instance::Instance(not_null session) +: _session(session) +, _api(_session->api().instance()) { } void Instance::startOutgoingCall(not_null user) { @@ -139,7 +141,7 @@ void Instance::refreshDhConfig() { Expects(_currentCall != nullptr); const auto weak = base::make_weak(_currentCall); - request(MTPmessages_GetDhConfig( + _api.request(MTPmessages_GetDhConfig( MTP_int(_dhConfig.version), MTP_int(MTP::ModExpFirst::kRandomPowerSize) )).done([=](const MTPmessages_DhConfig &result) { @@ -203,13 +205,14 @@ void Instance::refreshServerConfig() { if (_lastServerConfigUpdateTime && (crl::now() - _lastServerConfigUpdateTime) < kServerConfigUpdateTimeoutMs) { return; } - _serverConfigRequestId = request(MTPphone_GetCallConfig()).done([this](const MTPDataJSON &result) { + _serverConfigRequestId = _api.request(MTPphone_GetCallConfig( + )).done([=](const MTPDataJSON &result) { _serverConfigRequestId = 0; _lastServerConfigUpdateTime = crl::now(); const auto &json = result.c_dataJSON().vdata().v; UpdateConfig(std::string(json.data(), json.size())); - }).fail([this](const RPCError &error) { + }).fail([=](const RPCError &error) { _serverConfigRequestId = 0; }).send(); } @@ -246,7 +249,7 @@ void Instance::handleCallUpdate(const MTPPhoneCall &call) { LOG(("API Error: Self found in phoneCallRequested.")); } if (alreadyInCall() || !user || user->isSelf()) { - request(MTPphone_DiscardCall( + _api.request(MTPphone_DiscardCall( MTP_flags(0), MTP_inputPhoneCall(phoneCall.vid(), phoneCall.vaccess_hash()), MTP_int(0), diff --git a/Telegram/SourceFiles/calls/calls_instance.h b/Telegram/SourceFiles/calls/calls_instance.h index f5d30fa9b..d8987f458 100644 --- a/Telegram/SourceFiles/calls/calls_instance.h +++ b/Telegram/SourceFiles/calls/calls_instance.h @@ -25,8 +25,7 @@ namespace Calls { class Panel; class Instance - : private MTP::Sender - , private Call::Delegate + : private Call::Delegate , private base::Subscriber , public base::has_weak_ptr { public: @@ -74,6 +73,7 @@ private: void handleCallUpdate(const MTPPhoneCall &call); const not_null _session; + MTP::Sender _api; DhConfig _dhConfig; diff --git a/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp b/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp index 2668efcc6..39d0b8d2f 100644 --- a/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp +++ b/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp @@ -271,7 +271,7 @@ QPoint BotKeyboard::tooltipPos() const { } bool BotKeyboard::tooltipWindowActive() const { - return Ui::InFocusChain(window()); + return Ui::AppInFocus() && Ui::InFocusChain(window()); } QString BotKeyboard::tooltipText() const { diff --git a/Telegram/SourceFiles/chat_helpers/emoji_keywords.cpp b/Telegram/SourceFiles/chat_helpers/emoji_keywords.cpp index 16803d6fb..d83638615 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_keywords.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_keywords.cpp @@ -72,6 +72,12 @@ struct LangPackData { return false; } +[[nodiscard]] EmojiPtr FindExact(const QString &text) { + auto length = 0; + const auto result = Find(text, &length); + return (length < text.size()) ? nullptr : result; +} + void CreateCacheFilePath() { QDir().mkpath(internal::CacheFileFolder() + qstr("/keywords")); } @@ -120,7 +126,7 @@ void CreateCacheFilePath() { const auto emoji = MustAddPostfix(text) ? (text + QChar(Ui::Emoji::kPostfix)) : text; - const auto entry = LangPackEmoji{ Find(emoji), text }; + const auto entry = LangPackEmoji{ FindExact(emoji), text }; if (!entry.emoji) { return {}; } @@ -251,7 +257,7 @@ void ApplyDifference( const auto emoji = MustAddPostfix(text) ? (text + QChar(Ui::Emoji::kPostfix)) : text; - return LangPackEmoji{ Find(emoji), text }; + return LangPackEmoji{ FindExact(emoji), text }; }) | ranges::view::filter([&](const LangPackEmoji &entry) { if (!entry.emoji) { LOG(("API Warning: emoji %1 is not supported, word: %2." diff --git a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp index a9b4129f0..e4b8c8ac6 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp @@ -427,7 +427,7 @@ object_ptr EmojiListWidget::createFooter() { Expects(_footer == nullptr); auto result = object_ptr