Compare commits
170 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
887b6629f6 | ||
|
|
b6a66bbf1b | ||
|
|
a0eb073728 | ||
|
|
34840766b2 | ||
|
|
1aaf7df54a | ||
|
|
1b60829da8 | ||
|
|
fbe02dbb8d | ||
|
|
cb18c9a9b3 | ||
|
|
a106d80a41 | ||
|
|
465c661c45 | ||
|
|
8af40c22a4 | ||
|
|
f1b6d1fdae | ||
|
|
476b9c44c1 | ||
|
|
377ff2f421 | ||
|
|
cdc87086f3 | ||
|
|
99f3173ae6 | ||
|
|
7de5cabd79 | ||
|
|
925f6df06a | ||
|
|
c93d3ae924 | ||
|
|
537645c282 | ||
|
|
38b9111bf5 | ||
|
|
79feb0c6d9 | ||
|
|
97fe05c7ed | ||
|
|
e01bf8e1cd | ||
|
|
369ec46064 | ||
|
|
13f2ceaf47 | ||
|
|
eda22b925f | ||
|
|
bd16708781 | ||
|
|
38546c701a | ||
|
|
4971e281fa | ||
|
|
d4b8fa70a7 | ||
|
|
95de762529 | ||
|
|
a89634b767 | ||
|
|
4bf6550e24 | ||
|
|
83759adb5f | ||
|
|
6f90e57523 | ||
|
|
aba8f72c36 | ||
|
|
35dfb9fab3 | ||
|
|
b692242012 | ||
|
|
c1f727bde9 | ||
|
|
f3808bdc24 | ||
|
|
16177eae2b | ||
|
|
da3bbba497 | ||
|
|
a4ee90e8c6 | ||
|
|
7fec49a752 | ||
|
|
78c9c1e7f8 | ||
|
|
662424319c | ||
|
|
5c55f31972 | ||
|
|
29d42a6936 | ||
|
|
46550381a4 | ||
|
|
6c272e38ad | ||
|
|
0a019411ee | ||
|
|
815300bffc | ||
|
|
12e0399cf4 | ||
|
|
b703f4e555 | ||
|
|
71040464c5 | ||
|
|
6d36176a8d | ||
|
|
438a560a79 | ||
|
|
145ace2fa0 | ||
|
|
4ba7de8df1 | ||
|
|
b6c70572a9 | ||
|
|
b12256f1ee | ||
|
|
14cda49db2 | ||
|
|
af9440db38 | ||
|
|
1eea07d88a | ||
|
|
cf56658664 | ||
|
|
2ac425f350 | ||
|
|
edceed28d7 | ||
|
|
1fee7d1a41 | ||
|
|
d1d153e886 | ||
|
|
5b95585725 | ||
|
|
43056107fd | ||
|
|
7db9843543 | ||
|
|
a95a324401 | ||
|
|
759e802eba | ||
|
|
b71062561a | ||
|
|
2576312cd4 | ||
|
|
972bbbce6a | ||
|
|
65e2bbee3e | ||
|
|
bbe2adc44f | ||
|
|
449fa0ef2c | ||
|
|
dc9d0aae54 | ||
|
|
08b67e383e | ||
|
|
4e5e30a8dd | ||
|
|
cbeaee24c9 | ||
|
|
26bedd95d7 | ||
|
|
252bdd2353 | ||
|
|
361b99b0c9 | ||
|
|
e293a26029 | ||
|
|
4f3f1e18a2 | ||
|
|
188b98b4d8 | ||
|
|
fe639078a6 | ||
|
|
e5434ea491 | ||
|
|
ce4338fae4 | ||
|
|
5a1a8af222 | ||
|
|
152b49c65c | ||
|
|
5c5414b680 | ||
|
|
f99960e1f6 | ||
|
|
e363b254f6 | ||
|
|
3aea9cb3ca | ||
|
|
060fe6a928 | ||
|
|
8c45b5e0f8 | ||
|
|
0126578dbd | ||
|
|
1a9c241b96 | ||
|
|
638d4d63c5 | ||
|
|
9370e87c54 | ||
|
|
59c38df5cc | ||
|
|
5655ad25b0 | ||
|
|
c86ced8a1e | ||
|
|
511067981d | ||
|
|
9a186cd8ce | ||
|
|
385aa3eef7 | ||
|
|
e065d32d28 | ||
|
|
d4feb16378 | ||
|
|
79e6369e27 | ||
|
|
e4bd89d33e | ||
|
|
2b89700f66 | ||
|
|
ab95751a66 | ||
|
|
841908fe31 | ||
|
|
9e0b046213 | ||
|
|
d46b9d024e | ||
|
|
52cd9f8cbf | ||
|
|
25d69434ec | ||
|
|
8c4e8212cd | ||
|
|
c24da4c3df | ||
|
|
47a237c924 | ||
|
|
fc3a9d98c0 | ||
|
|
acce671eb0 | ||
|
|
67b6023b32 | ||
|
|
5a46bb1770 | ||
|
|
01fd8aded1 | ||
|
|
e0750f7b87 | ||
|
|
4eaba39a7c | ||
|
|
6ac9ef34eb | ||
|
|
42a2286230 | ||
|
|
24d02d5461 | ||
|
|
9bf2940375 | ||
|
|
d98212e8b3 | ||
|
|
3fe9c36d90 | ||
|
|
22f16caa89 | ||
|
|
46cce57f6b | ||
|
|
456244cdec | ||
|
|
69b2030c71 | ||
|
|
11018d76f1 | ||
|
|
e862215efb | ||
|
|
129de6d87f | ||
|
|
3c3ce24675 | ||
|
|
d98ac33425 | ||
|
|
76842792b8 | ||
|
|
4b01043b27 | ||
|
|
0a4f3f310c | ||
|
|
8320feea10 | ||
|
|
58281023bc | ||
|
|
0b655450bb | ||
|
|
61292557bf | ||
|
|
12ad1190ff | ||
|
|
42e0994581 | ||
|
|
69bc595e31 | ||
|
|
5c097887ef | ||
|
|
b02b690747 | ||
|
|
c52da743fd | ||
|
|
63dff9ff91 | ||
|
|
1c41808042 | ||
|
|
2ebf44c166 | ||
|
|
c46b96f252 | ||
|
|
6c89f60679 | ||
|
|
bb73687fc5 | ||
|
|
31fa2d9355 | ||
|
|
c350e33dd8 | ||
|
|
7dd9adb934 |
5
.github/workflows/linux.yml
vendored
@@ -423,8 +423,8 @@ jobs:
|
||||
|
||||
git clone -b v5.12.8 --depth=1 git://code.qt.io/qt/qt5.git qt_${QT}
|
||||
cd qt_${QT}
|
||||
perl init-repository --module-subset=qtbase,qtwayland,qtimageformats,qtsvg,qtx11extras
|
||||
git submodule update qtbase qtwayland qtimageformats qtsvg qtx11extras
|
||||
perl init-repository --module-subset=qtbase,qtwayland,qtimageformats,qtsvg
|
||||
git submodule update qtbase qtwayland qtimageformats qtsvg
|
||||
cd qtbase
|
||||
find ../../patches/qtbase_${QT} -type f -print0 | sort -z | xargs -r0 git apply
|
||||
cd ..
|
||||
@@ -530,6 +530,7 @@ jobs:
|
||||
-D CMAKE_CXX_FLAGS="-s" \
|
||||
-D TDESKTOP_API_TEST=ON \
|
||||
-D DESKTOP_APP_USE_PACKAGED=OFF \
|
||||
-D DESKTOP_APP_DISABLE_CRASH_REPORTS=OFF \
|
||||
$DEFINE
|
||||
|
||||
cd ../out/Debug
|
||||
|
||||
7
.github/workflows/mac.yml
vendored
@@ -79,6 +79,7 @@ jobs:
|
||||
|
||||
- name: First set up.
|
||||
run: |
|
||||
sudo chown -R `whoami`:admin /usr/local/share
|
||||
brew install automake fdk-aac lame libass libtool libvorbis libvpx \
|
||||
ninja opus sdl shtool texi2html theora x264 xvid yasm pkg-config
|
||||
|
||||
@@ -462,7 +463,11 @@ jobs:
|
||||
echo ::set-env name=ARTIFACT_NAME::Telegram
|
||||
fi
|
||||
|
||||
./configure.sh -D TDESKTOP_API_TEST=ON -D DESKTOP_APP_USE_PACKAGED=OFF $DEFINE
|
||||
./configure.sh \
|
||||
-D TDESKTOP_API_TEST=ON \
|
||||
-D DESKTOP_APP_USE_PACKAGED=OFF \
|
||||
-D DESKTOP_APP_DISABLE_CRASH_REPORTS=OFF \
|
||||
$DEFINE
|
||||
|
||||
cd ../out
|
||||
|
||||
|
||||
1
.github/workflows/win.yml
vendored
@@ -365,6 +365,7 @@ jobs:
|
||||
call configure.bat ^
|
||||
-D TDESKTOP_API_TEST=ON ^
|
||||
-D DESKTOP_APP_USE_PACKAGED=OFF ^
|
||||
-D DESKTOP_APP_DISABLE_CRASH_REPORTS=OFF ^
|
||||
%TDESKTOP_BUILD_DEFINE% ^
|
||||
-DCMAKE_SYSTEM_VERSION=%SDK%
|
||||
|
||||
|
||||
6
.gitmodules
vendored
@@ -94,3 +94,9 @@
|
||||
[submodule "Telegram/ThirdParty/fcitx5-qt"]
|
||||
path = Telegram/ThirdParty/fcitx5-qt
|
||||
url = https://github.com/fcitx/fcitx5-qt.git
|
||||
[submodule "Telegram/lib_webrtc"]
|
||||
path = Telegram/lib_webrtc
|
||||
url = https://github.com/desktop-app/lib_webrtc.git
|
||||
[submodule "Telegram/ThirdParty/tgcalls"]
|
||||
path = Telegram/ThirdParty/tgcalls
|
||||
url = https://github.com/TelegramMessenger/tgcalls.git
|
||||
|
||||
@@ -18,6 +18,7 @@ endif()
|
||||
add_subdirectory(lib_storage)
|
||||
add_subdirectory(lib_lottie)
|
||||
add_subdirectory(lib_qr)
|
||||
add_subdirectory(lib_webrtc)
|
||||
add_subdirectory(codegen)
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
@@ -34,6 +35,7 @@ include(cmake/lib_ffmpeg.cmake)
|
||||
include(cmake/lib_mtproto.cmake)
|
||||
include(cmake/lib_scheme.cmake)
|
||||
include(cmake/lib_tgvoip.cmake)
|
||||
include(cmake/lib_tgcalls.cmake)
|
||||
|
||||
set(style_files
|
||||
boxes/boxes.style
|
||||
@@ -72,9 +74,7 @@ if (LINUX)
|
||||
PRIVATE
|
||||
desktop-app::external_materialdecoration
|
||||
desktop-app::external_nimf_qt5
|
||||
desktop-app::external_qt5ct
|
||||
desktop-app::external_qt5ct_style
|
||||
desktop-app::external_qt5ct_qtplugin
|
||||
desktop-app::external_qt5ct_support
|
||||
)
|
||||
|
||||
if (NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION)
|
||||
@@ -103,9 +103,13 @@ endif()
|
||||
|
||||
target_link_libraries(Telegram
|
||||
PRIVATE
|
||||
tdesktop::lib_tgcalls_legacy
|
||||
tdesktop::lib_tgcalls
|
||||
tdesktop::lib_tgvoip
|
||||
tdesktop::lib_mtproto
|
||||
tdesktop::lib_scheme
|
||||
tdesktop::lib_export
|
||||
desktop-app::lib_webrtc
|
||||
desktop-app::lib_base
|
||||
desktop-app::lib_crl
|
||||
desktop-app::lib_ui
|
||||
@@ -122,12 +126,11 @@ PRIVATE
|
||||
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 (LINUX AND DESKTOP_APP_USE_PACKAGED)
|
||||
if (LINUX AND DESKTOP_APP_USE_PACKAGED AND Qt5WaylandClient_VERSION VERSION_LESS 5.13.0)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(WAYLAND_CLIENT REQUIRED wayland-client)
|
||||
|
||||
@@ -183,26 +186,6 @@ if (LINUX AND NOT TDESKTOP_DISABLE_GTK_INTEGRATION)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Telegram uses long atomic types, so on some architectures libatomic is needed.
|
||||
check_cxx_source_compiles("
|
||||
#include <atomic>
|
||||
std::atomic_int64_t foo;
|
||||
int main() {return foo;}
|
||||
" HAVE_LONG_ATOMIC_WITHOUT_LIB)
|
||||
if (NOT HAVE_LONG_ATOMIC_WITHOUT_LIB)
|
||||
target_link_libraries(Telegram PRIVATE atomic)
|
||||
endif()
|
||||
|
||||
if (DESKTOP_APP_USE_PACKAGED)
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
target_link_libraries(Telegram
|
||||
PRIVATE
|
||||
Threads::Threads
|
||||
)
|
||||
endif()
|
||||
|
||||
target_precompile_headers(Telegram PRIVATE ${src_loc}/stdafx.h)
|
||||
nice_target_sources(Telegram ${src_loc}
|
||||
PRIVATE
|
||||
@@ -212,9 +195,17 @@ PRIVATE
|
||||
api/api_bot.h
|
||||
api/api_chat_filters.cpp
|
||||
api/api_chat_filters.h
|
||||
api/api_chat_invite.cpp
|
||||
api/api_chat_invite.h
|
||||
api/api_common.h
|
||||
api/api_editing.cpp
|
||||
api/api_editing.h
|
||||
api/api_global_privacy.cpp
|
||||
api/api_global_privacy.h
|
||||
api/api_hash.cpp
|
||||
api/api_hash.h
|
||||
api/api_media.cpp
|
||||
api/api_media.h
|
||||
api/api_self_destruct.cpp
|
||||
api/api_self_destruct.h
|
||||
api/api_send_progress.cpp
|
||||
@@ -327,17 +318,20 @@ PRIVATE
|
||||
calls/calls_box_controller.h
|
||||
calls/calls_call.cpp
|
||||
calls/calls_call.h
|
||||
calls/calls_controller.cpp
|
||||
calls/calls_controller.h
|
||||
calls/calls_controller_tgvoip.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_signal_bars.cpp
|
||||
calls/calls_signal_bars.h
|
||||
calls/calls_top_bar.cpp
|
||||
calls/calls_top_bar.h
|
||||
calls/calls_userpic.cpp
|
||||
calls/calls_userpic.h
|
||||
calls/calls_video_bubble.cpp
|
||||
calls/calls_video_bubble.h
|
||||
chat_helpers/bot_keyboard.cpp
|
||||
chat_helpers/bot_keyboard.h
|
||||
chat_helpers/emoji_keywords.cpp
|
||||
@@ -354,6 +348,8 @@ PRIVATE
|
||||
chat_helpers/gifs_list_widget.h
|
||||
chat_helpers/message_field.cpp
|
||||
chat_helpers/message_field.h
|
||||
chat_helpers/send_context_menu.cpp
|
||||
chat_helpers/send_context_menu.h
|
||||
chat_helpers/spellchecker_common.cpp
|
||||
chat_helpers/spellchecker_common.h
|
||||
chat_helpers/stickers_emoji_image_loader.cpp
|
||||
@@ -600,6 +596,8 @@ PRIVATE
|
||||
history/view/history_view_service_message.h
|
||||
history/view/history_view_top_bar_widget.cpp
|
||||
history/view/history_view_top_bar_widget.h
|
||||
history/view/history_view_webpage_preview.cpp
|
||||
history/view/history_view_webpage_preview.h
|
||||
history/history.cpp
|
||||
history/history.h
|
||||
history/history_drag_area.cpp
|
||||
@@ -1083,6 +1081,7 @@ PRIVATE
|
||||
window/window_connecting_widget.h
|
||||
window/window_controller.cpp
|
||||
window/window_controller.h
|
||||
window/window_controls_layout.h
|
||||
window/window_filters_menu.cpp
|
||||
window/window_filters_menu.h
|
||||
window/window_history_hider.cpp
|
||||
@@ -1231,6 +1230,18 @@ elseif (APPLE)
|
||||
)
|
||||
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})
|
||||
|
||||
if (DESKTOP_APP_USE_PACKAGED)
|
||||
find_library(X11_LIBRARY X11)
|
||||
target_link_libraries(Telegram PRIVATE ${X11_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (build_macstore)
|
||||
|
||||
@@ -13,6 +13,8 @@ pacman --noconfirm -S pkg-config
|
||||
PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||
|
||||
./configure --toolchain=msvc \
|
||||
--extra-cflags="-DCONFIG_SAFE_BITSTREAM_READER=1" \
|
||||
--extra-cxxflags="-DCONFIG_SAFE_BITSTREAM_READER=1" \
|
||||
--extra-ldflags="-libpath:$FullExecPath/../opus/win32/VS2015/Win32/Release" \
|
||||
--disable-programs \
|
||||
--disable-doc \
|
||||
|
||||
|
Before Width: | Height: | Size: 456 B After Width: | Height: | Size: 595 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.7 KiB |
BIN
Telegram/Resources/icons/call_camera_active.png
Normal file
|
After Width: | Height: | Size: 377 B |
BIN
Telegram/Resources/icons/call_camera_active@2x.png
Normal file
|
After Width: | Height: | Size: 733 B |
BIN
Telegram/Resources/icons/call_camera_active@3x.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
Telegram/Resources/icons/call_camera_muted.png
Normal file
|
After Width: | Height: | Size: 727 B |
BIN
Telegram/Resources/icons/call_camera_muted@2x.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Telegram/Resources/icons/call_camera_muted@3x.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
Telegram/Resources/icons/call_cancel.png
Normal file
|
After Width: | Height: | Size: 214 B |
BIN
Telegram/Resources/icons/call_cancel@2x.png
Normal file
|
After Width: | Height: | Size: 426 B |
BIN
Telegram/Resources/icons/call_cancel@3x.png
Normal file
|
After Width: | Height: | Size: 912 B |
|
Before Width: | Height: | Size: 405 B After Width: | Height: | Size: 460 B |
|
Before Width: | Height: | Size: 736 B After Width: | Height: | Size: 970 B |
|
Before Width: | Height: | Size: 886 B After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 412 B After Width: | Height: | Size: 489 B |
|
Before Width: | Height: | Size: 800 B After Width: | Height: | Size: 1002 B |
|
Before Width: | Height: | Size: 945 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 459 B After Width: | Height: | Size: 744 B |
|
Before Width: | Height: | Size: 843 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 2.4 KiB |
BIN
Telegram/Resources/icons/calls_close_main.png
Normal file
|
After Width: | Height: | Size: 305 B |
BIN
Telegram/Resources/icons/calls_close_main@2x.png
Normal file
|
After Width: | Height: | Size: 524 B |
BIN
Telegram/Resources/icons/calls_close_main@3x.png
Normal file
|
After Width: | Height: | Size: 820 B |
BIN
Telegram/Resources/icons/calls_close_shadow.png
Normal file
|
After Width: | Height: | Size: 385 B |
BIN
Telegram/Resources/icons/calls_close_shadow@2x.png
Normal file
|
After Width: | Height: | Size: 873 B |
BIN
Telegram/Resources/icons/calls_close_shadow@3x.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
Telegram/Resources/icons/calls_maximize_main.png
Normal file
|
After Width: | Height: | Size: 230 B |
BIN
Telegram/Resources/icons/calls_maximize_main@2x.png
Normal file
|
After Width: | Height: | Size: 393 B |
BIN
Telegram/Resources/icons/calls_maximize_main@3x.png
Normal file
|
After Width: | Height: | Size: 616 B |
BIN
Telegram/Resources/icons/calls_maximize_shadow.png
Normal file
|
After Width: | Height: | Size: 333 B |
BIN
Telegram/Resources/icons/calls_maximize_shadow@2x.png
Normal file
|
After Width: | Height: | Size: 552 B |
BIN
Telegram/Resources/icons/calls_maximize_shadow@3x.png
Normal file
|
After Width: | Height: | Size: 889 B |
BIN
Telegram/Resources/icons/calls_minimize_main.png
Normal file
|
After Width: | Height: | Size: 173 B |
BIN
Telegram/Resources/icons/calls_minimize_main@2x.png
Normal file
|
After Width: | Height: | Size: 304 B |
BIN
Telegram/Resources/icons/calls_minimize_main@3x.png
Normal file
|
After Width: | Height: | Size: 545 B |
BIN
Telegram/Resources/icons/calls_minimize_shadow.png
Normal file
|
After Width: | Height: | Size: 228 B |
BIN
Telegram/Resources/icons/calls_minimize_shadow@2x.png
Normal file
|
After Width: | Height: | Size: 420 B |
BIN
Telegram/Resources/icons/calls_minimize_shadow@3x.png
Normal file
|
After Width: | Height: | Size: 661 B |
BIN
Telegram/Resources/icons/calls_mute_tooltip.png
Normal file
|
After Width: | Height: | Size: 637 B |
BIN
Telegram/Resources/icons/calls_mute_tooltip@2x.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Telegram/Resources/icons/calls_mute_tooltip@3x.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
Telegram/Resources/icons/calls_mute_userpic.png
Normal file
|
After Width: | Height: | Size: 545 B |
BIN
Telegram/Resources/icons/calls_mute_userpic@2x.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
Telegram/Resources/icons/calls_mute_userpic@3x.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
Telegram/Resources/icons/calls_restore_main.png
Normal file
|
After Width: | Height: | Size: 290 B |
BIN
Telegram/Resources/icons/calls_restore_main@2x.png
Normal file
|
After Width: | Height: | Size: 499 B |
BIN
Telegram/Resources/icons/calls_restore_main@3x.png
Normal file
|
After Width: | Height: | Size: 846 B |
BIN
Telegram/Resources/icons/calls_restore_shadow.png
Normal file
|
After Width: | Height: | Size: 420 B |
BIN
Telegram/Resources/icons/calls_restore_shadow@2x.png
Normal file
|
After Width: | Height: | Size: 715 B |
BIN
Telegram/Resources/icons/calls_restore_shadow@3x.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
Telegram/Resources/icons/calls_shadow_controls.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
Telegram/Resources/icons/calls_shadow_controls@2x.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
Telegram/Resources/icons/calls_shadow_controls@3x.png
Normal file
|
After Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 128 B |
|
Before Width: | Height: | Size: 148 B After Width: | Height: | Size: 247 B |
|
Before Width: | Height: | Size: 190 B After Width: | Height: | Size: 350 B |
BIN
Telegram/Resources/icons/dialogs_menu_unread.png
Normal file
|
After Width: | Height: | Size: 146 B |
BIN
Telegram/Resources/icons/dialogs_menu_unread@2x.png
Normal file
|
After Width: | Height: | Size: 289 B |
BIN
Telegram/Resources/icons/dialogs_menu_unread@3x.png
Normal file
|
After Width: | Height: | Size: 386 B |
BIN
Telegram/Resources/icons/dialogs_menu_unread_dot.png
Normal file
|
After Width: | Height: | Size: 170 B |
BIN
Telegram/Resources/icons/dialogs_menu_unread_dot@2x.png
Normal file
|
After Width: | Height: | Size: 362 B |
BIN
Telegram/Resources/icons/dialogs_menu_unread_dot@3x.png
Normal file
|
After Width: | Height: | Size: 488 B |
@@ -424,6 +424,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_settings_passcode_title" = "Local passcode";
|
||||
"lng_settings_password_title" = "Two-step verification";
|
||||
"lng_settings_sessions_title" = "Active sessions";
|
||||
"lng_settings_new_unknown" = "New chats from unknown users";
|
||||
"lng_settings_auto_archive" = "Archive and Mute";
|
||||
"lng_settings_auto_archive_about" = "Automatically archive and mute new chats, groups and channels from non-contacts.";
|
||||
"lng_settings_destroy_title" = "Delete my account";
|
||||
"lng_settings_network_proxy" = "Network and proxy";
|
||||
"lng_settings_version_info" = "Version and updates";
|
||||
@@ -434,6 +437,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_settings_sensitive_disable_filtering" = "Disable filtering";
|
||||
"lng_settings_sensitive_about" = "Display sensitive media in public channels on all your Telegram devices.";
|
||||
|
||||
"lng_settings_auto_night_mode" = "Auto-Night mode";
|
||||
"lng_settings_auto_night_enabled" = "Match the system settings";
|
||||
"lng_settings_auto_night_warning" = "You have enabled auto-night mode. If you want to change the dark mode settings, you'll need to disable it first.";
|
||||
"lng_settings_auto_night_disable" = "Disable";
|
||||
|
||||
"lng_suggest_hide_new_title" = "Hide new chats?";
|
||||
"lng_suggest_hide_new_about" = "You are receiving lots of new chats from users who are not in your Contact List.\n\nDo you want to have such chats **automatically muted** and **archived**?";
|
||||
"lng_suggest_hide_new_to_settings" = "Go to Settings";
|
||||
|
||||
"lng_settings_spellchecker" = "Spell checker";
|
||||
"lng_settings_system_spellchecker" = "Use system spell checker";
|
||||
"lng_settings_custom_spellchecker" = "Use spell checker";
|
||||
@@ -1127,6 +1139,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
"lng_group_invite_members#one" = "{count} member, among them:";
|
||||
"lng_group_invite_members#other" = "{count} members, among them:";
|
||||
"lng_channel_invite_private" = "This channel is private.\nPlease join it to continue viewing its content.";
|
||||
|
||||
"lng_group_invite_create" = "Create an invite link";
|
||||
"lng_group_invite_about" = "Telegram users will be able to join\nyour group by following this link.";
|
||||
@@ -1281,6 +1294,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_new_contact_share_done" = "{user} can now see your phone number.";
|
||||
"lng_new_contact_add_name" = "Add {user} to contacts";
|
||||
"lng_new_contact_add_done" = "{user} is now in your contact list.";
|
||||
"lng_new_contact_unarchive" = "Unarchive";
|
||||
"lng_cant_send_to_not_contact" = "Sorry, you can only send messages to\nmutual contacts at the moment.\n{more_info}";
|
||||
"lng_cant_invite_not_contact" = "Sorry, you can only add mutual contacts\nto groups at the moment.\n{more_info}";
|
||||
"lng_cant_more_info" = "More info »";
|
||||
@@ -1454,6 +1468,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_context_copy_text" = "Copy Text";
|
||||
"lng_context_open_gif" = "Open GIF";
|
||||
"lng_context_save_gif" = "Save GIF";
|
||||
"lng_context_delete_gif" = "Delete GIF";
|
||||
"lng_context_attached_stickers" = "Attached Stickers";
|
||||
"lng_context_to_msg" = "Go To Message";
|
||||
"lng_context_reply_msg" = "Reply";
|
||||
@@ -1721,16 +1736,33 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_call_box_status_group" = "({amount}) {status}";
|
||||
|
||||
"lng_call_outgoing" = "Outgoing call";
|
||||
"lng_call_video_outgoing" = "Outgoing video call";
|
||||
"lng_call_incoming" = "Incoming call";
|
||||
"lng_call_video_incoming" = "Incoming video call";
|
||||
"lng_call_missed" = "Missed call";
|
||||
"lng_call_video_missed" = "Missed video call";
|
||||
"lng_call_cancelled" = "Cancelled call";
|
||||
"lng_call_video_cancelled" = "Cancelled video call";
|
||||
"lng_call_declined" = "Declined call";
|
||||
"lng_call_video_declined" = "Declined video call";
|
||||
"lng_call_duration_info" = "{time}, {duration}";
|
||||
"lng_call_type_and_duration" = "{type} ({duration})";
|
||||
|
||||
"lng_call_rate_label" = "Please rate the quality of your call";
|
||||
"lng_call_rate_comment" = "Comment (optional)";
|
||||
|
||||
"lng_call_start_video" = "Start Video";
|
||||
"lng_call_stop_video" = "Stop Video";
|
||||
"lng_call_end_call" = "End Call";
|
||||
"lng_call_mute_audio" = "Mute";
|
||||
"lng_call_unmute_audio" = "Unmute";
|
||||
"lng_call_accept" = "Accept";
|
||||
"lng_call_decline" = "Decline";
|
||||
"lng_call_redial" = "Redial";
|
||||
"lng_call_cancel" = "Cancel";
|
||||
|
||||
"lng_call_microphone_off" = "{user}'s microphone is off";
|
||||
|
||||
"lng_no_mic_permission" = "Telegram needs access to your microphone so that you can make calls and record voice messages.";
|
||||
|
||||
"lng_player_message_today" = "Today at {time}";
|
||||
|
||||
@@ -62,10 +62,9 @@ inputMediaUploadedPhoto#1e287d04 flags:# file:InputFile stickers:flags.0?Vector<
|
||||
inputMediaPhoto#b3ba0635 flags:# id:InputPhoto ttl_seconds:flags.0?int = InputMedia;
|
||||
inputMediaGeoPoint#f9c44144 geo_point:InputGeoPoint = InputMedia;
|
||||
inputMediaContact#f8ab7dfb phone_number:string first_name:string last_name:string vcard:string = InputMedia;
|
||||
inputMediaUploadedDocument#5b38c6c1 flags:# nosound_video:flags.3?true file:InputFile thumb:flags.2?InputFile mime_type:string attributes:Vector<DocumentAttribute> stickers:flags.0?Vector<InputDocument> ttl_seconds:flags.1?int = InputMedia;
|
||||
inputMediaUploadedDocument#5b38c6c1 flags:# nosound_video:flags.3?true force_file:flags.4?true file:InputFile thumb:flags.2?InputFile mime_type:string attributes:Vector<DocumentAttribute> stickers:flags.0?Vector<InputDocument> ttl_seconds:flags.1?int = InputMedia;
|
||||
inputMediaDocument#23ab23d2 flags:# id:InputDocument ttl_seconds:flags.0?int = InputMedia;
|
||||
inputMediaVenue#c13d1c11 geo_point:InputGeoPoint title:string address:string provider:string venue_id:string venue_type:string = InputMedia;
|
||||
inputMediaGifExternal#4843b0fd url:string q:string = InputMedia;
|
||||
inputMediaPhotoExternal#e5bbfe1a flags:# url:string ttl_seconds:flags.0?int = InputMedia;
|
||||
inputMediaDocumentExternal#fb52dc99 flags:# url:string ttl_seconds:flags.0?int = InputMedia;
|
||||
inputMediaGame#d33f43f3 id:InputGame = InputMedia;
|
||||
@@ -75,7 +74,7 @@ inputMediaPoll#f94e5f1 flags:# poll:Poll correct_answers:flags.0?Vector<bytes> s
|
||||
inputMediaDice#e66fbf7b emoticon:string = InputMedia;
|
||||
|
||||
inputChatPhotoEmpty#1ca48f57 = InputChatPhoto;
|
||||
inputChatUploadedPhoto#927c55b4 file:InputFile = InputChatPhoto;
|
||||
inputChatUploadedPhoto#c642724e flags:# file:flags.0?InputFile video:flags.1?InputFile video_start_ts:flags.2?double = InputChatPhoto;
|
||||
inputChatPhoto#8953ad37 id:InputPhoto = InputChatPhoto;
|
||||
|
||||
inputGeoPointEmpty#e4c123d6 = InputGeoPoint;
|
||||
@@ -110,10 +109,10 @@ storage.fileMp4#b3cea0e4 = storage.FileType;
|
||||
storage.fileWebp#1081464c = storage.FileType;
|
||||
|
||||
userEmpty#200250ba id:int = User;
|
||||
user#938458c1 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true id:int access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector<RestrictionReason> bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User;
|
||||
user#938458c1 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true id:int access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector<RestrictionReason> bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User;
|
||||
|
||||
userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto;
|
||||
userProfilePhoto#ecd75d8c photo_id:long photo_small:FileLocation photo_big:FileLocation dc_id:int = UserProfilePhoto;
|
||||
userProfilePhoto#69d3ab26 flags:# has_video:flags.0?true photo_id:long photo_small:FileLocation photo_big:FileLocation dc_id:int = UserProfilePhoto;
|
||||
|
||||
userStatusEmpty#9d05049 = UserStatus;
|
||||
userStatusOnline#edb93949 expires:int = UserStatus;
|
||||
@@ -129,7 +128,7 @@ channel#d31a961e flags:# creator:flags.0?true left:flags.2?true broadcast:flags.
|
||||
channelForbidden#289da732 flags:# broadcast:flags.5?true megagroup:flags.8?true id:int access_hash:long title:string until_date:flags.16?int = Chat;
|
||||
|
||||
chatFull#1b7c9db3 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true id:int about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:flags.3?Vector<BotInfo> pinned_msg_id:flags.6?int folder_id:flags.11?int = ChatFull;
|
||||
channelFull#f0e6672a flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_view_stats:flags.12?true can_set_location:flags.16?true has_scheduled:flags.19?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector<BotInfo> migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?int location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int = ChatFull;
|
||||
channelFull#f0e6672a flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector<BotInfo> migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?int location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int = ChatFull;
|
||||
|
||||
chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant;
|
||||
chatParticipantCreator#da13538a user_id:int = ChatParticipant;
|
||||
@@ -139,7 +138,7 @@ chatParticipantsForbidden#fc900c2b flags:# chat_id:int self_participant:flags.0?
|
||||
chatParticipants#3f460fed chat_id:int participants:Vector<ChatParticipant> version:int = ChatParticipants;
|
||||
|
||||
chatPhotoEmpty#37c1011c = ChatPhoto;
|
||||
chatPhoto#475cdbd5 photo_small:FileLocation photo_big:FileLocation dc_id:int = ChatPhoto;
|
||||
chatPhoto#d20b9f3c flags:# has_video:flags.0?true photo_small:FileLocation photo_big:FileLocation dc_id:int = ChatPhoto;
|
||||
|
||||
messageEmpty#83e5de54 id:int = Message;
|
||||
message#452c0e65 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true id:int from_id:flags.8?int to_id:Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?int reply_to_msg_id:flags.3?int date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector<MessageEntity> views:flags.10?int edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long restriction_reason:flags.22?Vector<RestrictionReason> = Message;
|
||||
@@ -187,7 +186,7 @@ dialog#2c171f72 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer t
|
||||
dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog;
|
||||
|
||||
photoEmpty#2331b22d id:long = Photo;
|
||||
photo#d07504a5 flags:# has_stickers:flags.0?true id:long access_hash:long file_reference:bytes date:int sizes:Vector<PhotoSize> dc_id:int = Photo;
|
||||
photo#fb197a65 flags:# has_stickers:flags.0?true id:long access_hash:long file_reference:bytes date:int sizes:Vector<PhotoSize> video_sizes:flags.1?Vector<VideoSize> dc_id:int = Photo;
|
||||
|
||||
photoSizeEmpty#e17e23c type:string = PhotoSize;
|
||||
photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = PhotoSize;
|
||||
@@ -213,7 +212,7 @@ inputPeerNotifySettings#9c3d198e flags:# show_previews:flags.0?Bool silent:flags
|
||||
|
||||
peerNotifySettings#af509d20 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?string = PeerNotifySettings;
|
||||
|
||||
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;
|
||||
peerSettings#733f2961 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 autoarchived:flags.7?true geo_distance:flags.6?int = 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;
|
||||
@@ -226,7 +225,7 @@ inputReportReasonOther#e1746d0a text:string = ReportReason;
|
||||
inputReportReasonCopyright#9b89f93a = ReportReason;
|
||||
inputReportReasonGeoIrrelevant#dbd4feed = ReportReason;
|
||||
|
||||
userFull#edf17c12 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true user:User about:flags.1?string settings:PeerSettings profile_photo:flags.2?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int = UserFull;
|
||||
userFull#edf17c12 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true user:User about:flags.1?string settings:PeerSettings profile_photo:flags.2?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int = UserFull;
|
||||
|
||||
contact#f911c994 user_id:int mutual:Bool = Contact;
|
||||
|
||||
@@ -358,6 +357,7 @@ updateDialogFilter#26ffde7d flags:# id:int filter:flags.0?DialogFilter = Update;
|
||||
updateDialogFilterOrder#a5d72105 order:Vector<int> = Update;
|
||||
updateDialogFilters#3504914f = Update;
|
||||
updatePhoneCallSignalingData#2661bf09 phone_call_id:long data:bytes = Update;
|
||||
updateChannelParticipant#65d2b464 flags:# channel_id:int date:int user_id:int prev_participant:flags.0?ChannelParticipant new_participant:flags.1?ChannelParticipant qts:int = Update;
|
||||
|
||||
updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State;
|
||||
|
||||
@@ -395,7 +395,7 @@ help.inviteText#18cb9f78 message:string = help.InviteText;
|
||||
|
||||
encryptedChatEmpty#ab7ec0a0 id:int = EncryptedChat;
|
||||
encryptedChatWaiting#3bf703dc id:int access_hash:long date:int admin_id:int participant_id:int = EncryptedChat;
|
||||
encryptedChatRequested#c878527e id:int access_hash:long date:int admin_id:int participant_id:int g_a:bytes = EncryptedChat;
|
||||
encryptedChatRequested#62718a82 flags:# folder_id:flags.0?int id:int access_hash:long date:int admin_id:int participant_id:int g_a:bytes = EncryptedChat;
|
||||
encryptedChat#fa56ce36 id:int access_hash:long date:int admin_id:int participant_id:int g_a_or_b:bytes key_fingerprint:long = EncryptedChat;
|
||||
encryptedChatDiscarded#13d6dd27 id:int = EncryptedChat;
|
||||
|
||||
@@ -529,6 +529,7 @@ chatInviteExported#fc2e05bc link:string = ExportedChatInvite;
|
||||
|
||||
chatInviteAlready#5a686d7c chat:Chat = ChatInvite;
|
||||
chatInvite#dfc2f58e flags:# channel:flags.0?true broadcast:flags.1?true public:flags.2?true megagroup:flags.3?true title:string photo:Photo participants_count:int participants:flags.4?Vector<User> = ChatInvite;
|
||||
chatInvitePeek#61695cb0 chat:Chat expires:int = ChatInvite;
|
||||
|
||||
inputStickerSetEmpty#ffb62b95 = InputStickerSet;
|
||||
inputStickerSetID#9de7a269 id:long access_hash:long = InputStickerSet;
|
||||
@@ -619,11 +620,6 @@ channels.channelParticipant#d0d9b163 participant:ChannelParticipant users:Vector
|
||||
|
||||
help.termsOfService#780a0310 flags:# popup:flags.0?true id:DataJSON text:string entities:Vector<MessageEntity> min_age_confirm:flags.1?int = help.TermsOfService;
|
||||
|
||||
foundGif#162ecc1f url:string thumb_url:string content_url:string content_type:string w:int h:int = FoundGif;
|
||||
foundGifCached#9c750409 url:string photo:Photo document:Document = FoundGif;
|
||||
|
||||
messages.foundGifs#450a1c0a next_offset:int results:Vector<FoundGif> = messages.FoundGifs;
|
||||
|
||||
messages.savedGifsNotModified#e8025ca2 = messages.SavedGifs;
|
||||
messages.savedGifs#2e0709a5 hash:int gifs:Vector<Document> = messages.SavedGifs;
|
||||
|
||||
@@ -822,13 +818,14 @@ inputStickerSetItem#ffa0a496 flags:# document:InputDocument emoji:string mask_co
|
||||
inputPhoneCall#1e36fded id:long access_hash:long = InputPhoneCall;
|
||||
|
||||
phoneCallEmpty#5366c915 id:long = PhoneCall;
|
||||
phoneCallWaiting#1b8f4ad1 flags:# video:flags.5?true id:long access_hash:long date:int admin_id:int participant_id:int protocol:PhoneCallProtocol receive_date:flags.0?int = PhoneCall;
|
||||
phoneCallRequested#87eabb53 flags:# video:flags.5?true id:long access_hash:long date:int admin_id:int participant_id:int g_a_hash:bytes protocol:PhoneCallProtocol = PhoneCall;
|
||||
phoneCallAccepted#997c454a flags:# video:flags.5?true id:long access_hash:long date:int admin_id:int participant_id:int g_b:bytes protocol:PhoneCallProtocol = PhoneCall;
|
||||
phoneCall#8742ae7f flags:# p2p_allowed:flags.5?true id:long access_hash:long date:int admin_id:int participant_id:int g_a_or_b:bytes key_fingerprint:long protocol:PhoneCallProtocol connections:Vector<PhoneConnection> start_date:int = PhoneCall;
|
||||
phoneCallDiscarded#50ca4de1 flags:# need_rating:flags.2?true need_debug:flags.3?true video:flags.5?true id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = PhoneCall;
|
||||
phoneCallWaiting#1b8f4ad1 flags:# video:flags.6?true id:long access_hash:long date:int admin_id:int participant_id:int protocol:PhoneCallProtocol receive_date:flags.0?int = PhoneCall;
|
||||
phoneCallRequested#87eabb53 flags:# video:flags.6?true id:long access_hash:long date:int admin_id:int participant_id:int g_a_hash:bytes protocol:PhoneCallProtocol = PhoneCall;
|
||||
phoneCallAccepted#997c454a flags:# video:flags.6?true id:long access_hash:long date:int admin_id:int participant_id:int g_b:bytes protocol:PhoneCallProtocol = PhoneCall;
|
||||
phoneCall#8742ae7f flags:# p2p_allowed:flags.5?true video:flags.6?true id:long access_hash:long date:int admin_id:int participant_id:int g_a_or_b:bytes key_fingerprint:long protocol:PhoneCallProtocol connections:Vector<PhoneConnection> start_date:int = PhoneCall;
|
||||
phoneCallDiscarded#50ca4de1 flags:# need_rating:flags.2?true need_debug:flags.3?true video:flags.6?true id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = PhoneCall;
|
||||
|
||||
phoneConnection#9d4c17c0 id:long ip:string ipv6:string port:int peer_tag:bytes = PhoneConnection;
|
||||
phoneConnectionWebrtc#635fe375 flags:# turn:flags.0?true stun:flags.1?true id:long ip:string ipv6:string port:int username:string password:string = PhoneConnection;
|
||||
|
||||
phoneCallProtocol#fc878fc8 flags:# udp_p2p:flags.0?true udp_reflector:flags.1?true min_layer:int max_layer:int library_versions:Vector<string> = PhoneCallProtocol;
|
||||
|
||||
@@ -1141,7 +1138,17 @@ stats.broadcastStats#bdf78394 period:StatsDateRangeDays followers:StatsAbsValueA
|
||||
help.promoDataEmpty#98f6ac75 expires:int = help.PromoData;
|
||||
help.promoData#8c39793f flags:# proxy:flags.0?true expires:int peer:Peer chats:Vector<Chat> users:Vector<User> psa_type:flags.1?string psa_message:flags.2?string = help.PromoData;
|
||||
|
||||
videoSize#435bb987 type:string location:FileLocation w:int h:int size:int = VideoSize;
|
||||
videoSize#e831c556 flags:# type:string location:FileLocation w:int h:int size:int video_start_ts:flags.0?double = VideoSize;
|
||||
|
||||
statsGroupTopPoster#18f3d0f7 user_id:int messages:int avg_chars:int = StatsGroupTopPoster;
|
||||
|
||||
statsGroupTopAdmin#6014f412 user_id:int deleted:int kicked:int banned:int = StatsGroupTopAdmin;
|
||||
|
||||
statsGroupTopInviter#31962a4c user_id:int invitations:int = StatsGroupTopInviter;
|
||||
|
||||
stats.megagroupStats#ef7ff916 period:StatsDateRangeDays members:StatsAbsValueAndPrev messages:StatsAbsValueAndPrev viewers:StatsAbsValueAndPrev posters:StatsAbsValueAndPrev growth_graph:StatsGraph members_graph:StatsGraph new_members_by_source_graph:StatsGraph languages_graph:StatsGraph messages_graph:StatsGraph actions_graph:StatsGraph top_hours_graph:StatsGraph weekdays_graph:StatsGraph top_posters:Vector<StatsGroupTopPoster> top_admins:Vector<StatsGroupTopAdmin> top_inviters:Vector<StatsGroupTopInviter> users:Vector<User> = stats.MegagroupStats;
|
||||
|
||||
globalPrivacySettings#bea2f424 flags:# archive_and_mute_new_noncontact_peers:flags.0?Bool = GlobalPrivacySettings;
|
||||
|
||||
---functions---
|
||||
|
||||
@@ -1237,6 +1244,8 @@ 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<InputWallPaper> = Vector<WallPaper>;
|
||||
account.getGlobalPrivacySettings#eb2b4cf6 = GlobalPrivacySettings;
|
||||
account.setGlobalPrivacySettings#1edaaac2 settings:GlobalPrivacySettings = GlobalPrivacySettings;
|
||||
|
||||
users.getUsers#d91a548 id:Vector<InputUser> = Vector<User>;
|
||||
users.getFullUser#ca30a5b1 id:InputUser = UserFull;
|
||||
@@ -1312,7 +1321,6 @@ messages.migrateChat#15a3b8e3 chat_id:int = Updates;
|
||||
messages.searchGlobal#bf7225a4 flags:# folder_id:flags.0?int q:string offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;
|
||||
messages.reorderStickerSets#78337739 flags:# masks:flags.0?true order:Vector<long> = Bool;
|
||||
messages.getDocumentByHash#338e2464 sha256:bytes size:int mime_type:string = Document;
|
||||
messages.searchGifs#bf9a776b q:string offset:int = messages.FoundGifs;
|
||||
messages.getSavedGifs#83bf3d52 hash:int = messages.SavedGifs;
|
||||
messages.saveGif#327a30cb id:InputDocument unsave:Bool = Bool;
|
||||
messages.getInlineBotResults#514e999d flags:# bot:InputUser peer:InputPeer geo_point:flags.0?InputGeoPoint query:string offset:string = messages.BotResults;
|
||||
@@ -1391,8 +1399,8 @@ updates.getState#edd4882a = updates.State;
|
||||
updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference;
|
||||
updates.getChannelDifference#3173d78 flags:# force:flags.0?true channel:InputChannel filter:ChannelMessagesFilter pts:int limit:int = updates.ChannelDifference;
|
||||
|
||||
photos.updateProfilePhoto#f0bb5152 id:InputPhoto = UserProfilePhoto;
|
||||
photos.uploadProfilePhoto#4f32c098 file:InputFile = photos.Photo;
|
||||
photos.updateProfilePhoto#72d4742c id:InputPhoto = photos.Photo;
|
||||
photos.uploadProfilePhoto#89f30f69 flags:# file:flags.0?InputFile video:flags.1?InputFile video_start_ts:flags.2?double = photos.Photo;
|
||||
photos.deletePhotos#87cf7f2f id:Vector<InputPhoto> = Vector<long>;
|
||||
photos.getUserPhotos#91cd32a8 user_id:InputUser offset:int max_id:long limit:int = photos.Photos;
|
||||
|
||||
@@ -1425,6 +1433,7 @@ help.getUserInfo#38a08d3 user_id:InputUser = help.UserInfo;
|
||||
help.editUserInfo#66b91b70 user_id:InputUser message:string entities:Vector<MessageEntity> = help.UserInfo;
|
||||
help.getPromoData#c0977421 = help.PromoData;
|
||||
help.hidePromoData#1e251c95 peer:InputPeer = Bool;
|
||||
help.dismissSuggestion#77fa99f suggestion:string = Bool;
|
||||
|
||||
channels.readHistory#cc104937 channel:InputChannel max_id:int = Bool;
|
||||
channels.deleteMessages#84c1fd4e channel:InputChannel id:Vector<int> = messages.AffectedMessages;
|
||||
@@ -1501,5 +1510,6 @@ folders.deleteFolder#1c295881 folder_id:int = Updates;
|
||||
|
||||
stats.getBroadcastStats#ab42441a flags:# dark:flags.0?true channel:InputChannel = stats.BroadcastStats;
|
||||
stats.loadAsyncGraph#621d5fa0 flags:# token:string x:flags.0?long = StatsGraph;
|
||||
stats.getMegagroupStats#dcdf8607 flags:# dark:flags.0?true channel:InputChannel = stats.MegagroupStats;
|
||||
|
||||
// LAYER 114
|
||||
// LAYER 117
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<Identity Name="TelegramMessengerLLP.TelegramDesktop"
|
||||
ProcessorArchitecture="ARCHITECTURE"
|
||||
Publisher="CN=536BC709-8EE1-4478-AF22-F0F0F26FF64A"
|
||||
Version="2.1.20.0" />
|
||||
Version="2.3.0.0" />
|
||||
<Properties>
|
||||
<DisplayName>Telegram Desktop</DisplayName>
|
||||
<PublisherDisplayName>Telegram FZ-LLC</PublisherDisplayName>
|
||||
|
||||
@@ -44,8 +44,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2,1,20,0
|
||||
PRODUCTVERSION 2,1,20,0
|
||||
FILEVERSION 2,3,0,0
|
||||
PRODUCTVERSION 2,3,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -62,10 +62,10 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Telegram FZ-LLC"
|
||||
VALUE "FileDescription", "Telegram Desktop"
|
||||
VALUE "FileVersion", "2.1.20.0"
|
||||
VALUE "FileVersion", "2.3.0.0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2014-2020"
|
||||
VALUE "ProductName", "Telegram Desktop"
|
||||
VALUE "ProductVersion", "2.1.20.0"
|
||||
VALUE "ProductVersion", "2.3.0.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
@@ -35,8 +35,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2,1,20,0
|
||||
PRODUCTVERSION 2,1,20,0
|
||||
FILEVERSION 2,3,0,0
|
||||
PRODUCTVERSION 2,3,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -53,10 +53,10 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Telegram FZ-LLC"
|
||||
VALUE "FileDescription", "Telegram Desktop Updater"
|
||||
VALUE "FileVersion", "2.1.20.0"
|
||||
VALUE "FileVersion", "2.3.0.0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2014-2020"
|
||||
VALUE "ProductName", "Telegram Desktop"
|
||||
VALUE "ProductVersion", "2.1.20.0"
|
||||
VALUE "ProductVersion", "2.3.0.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
@@ -298,6 +298,28 @@ bool update() {
|
||||
|
||||
for (size_t i = 0; i < from.size(); ++i) {
|
||||
string fname = from[i], tofname = to[i];
|
||||
|
||||
// it is necessary to remove the old file to not to get an error if appimage file is used by fuse
|
||||
struct stat statbuf;
|
||||
writeLog("Trying to get stat() for '%s'", tofname.c_str());
|
||||
if (!stat(tofname.c_str(), &statbuf)) {
|
||||
if (S_ISDIR(statbuf.st_mode)) {
|
||||
writeLog("Fully clearing path '%s'..", tofname.c_str());
|
||||
if (!remove_directory(tofname.c_str())) {
|
||||
writeLog("Error: failed to clear path '%s'", tofname.c_str());
|
||||
delFolder();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
writeLog("Unlinking file '%s'", tofname.c_str());
|
||||
if (unlink(tofname.c_str())) {
|
||||
writeLog("Error: failed to unlink '%s'", tofname.c_str());
|
||||
delFolder();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writeLog("Copying file '%s' to '%s'..", fname.c_str(), tofname.c_str());
|
||||
int copyTries = 0, triesLimit = 30;
|
||||
do {
|
||||
|
||||
230
Telegram/SourceFiles/api/api_chat_invite.cpp
Normal file
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
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_chat_invite.h"
|
||||
|
||||
#include "apiwrap.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "main/main_session.h"
|
||||
#include "ui/empty_userpic.h"
|
||||
#include "core/application.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_photo_media.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_layers.h"
|
||||
|
||||
namespace Api {
|
||||
|
||||
void CheckChatInvite(
|
||||
not_null<Window::SessionController*> controller,
|
||||
const QString &hash,
|
||||
ChannelData *invitePeekChannel) {
|
||||
const auto session = &controller->session();
|
||||
const auto weak = base::make_weak(controller.get());
|
||||
session->api().checkChatInvite(hash, [=](const MTPChatInvite &result) {
|
||||
Core::App().hideMediaView();
|
||||
result.match([=](const MTPDchatInvite &data) {
|
||||
const auto box = Ui::show(Box<ConfirmInviteBox>(
|
||||
session,
|
||||
data,
|
||||
invitePeekChannel,
|
||||
[=] { session->api().importChatInvite(hash); }));
|
||||
if (invitePeekChannel) {
|
||||
box->boxClosing(
|
||||
) | rpl::filter([=] {
|
||||
return !invitePeekChannel->amIn();
|
||||
}) | rpl::start_with_next([=] {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->clearSectionStack(Window::SectionShow(
|
||||
Window::SectionShow::Way::ClearStack,
|
||||
anim::type::normal,
|
||||
anim::activation::background));
|
||||
}
|
||||
}, box->lifetime());
|
||||
}
|
||||
}, [=](const MTPDchatInviteAlready &data) {
|
||||
if (const auto chat = session->data().processChat(data.vchat())) {
|
||||
if (const auto channel = chat->asChannel()) {
|
||||
channel->clearInvitePeek();
|
||||
}
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->showPeerHistory(
|
||||
chat,
|
||||
Window::SectionShow::Way::Forward);
|
||||
}
|
||||
}
|
||||
}, [=](const MTPDchatInvitePeek &data) {
|
||||
if (const auto chat = session->data().processChat(data.vchat())) {
|
||||
if (const auto channel = chat->asChannel()) {
|
||||
channel->setInvitePeek(hash, data.vexpires().v);
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->showPeerHistory(
|
||||
chat,
|
||||
Window::SectionShow::Way::Forward);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}, [=](const RPCError &error) {
|
||||
if (error.code() != 400) {
|
||||
return;
|
||||
}
|
||||
Core::App().hideMediaView();
|
||||
Ui::show(Box<InformBox>(tr::lng_group_invite_bad_link(tr::now)));
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Api
|
||||
|
||||
ConfirmInviteBox::ConfirmInviteBox(
|
||||
QWidget*,
|
||||
not_null<Main::Session*> session,
|
||||
const MTPDchatInvite &data,
|
||||
ChannelData *invitePeekChannel,
|
||||
Fn<void()> submit)
|
||||
: _session(session)
|
||||
, _submit(std::move(submit))
|
||||
, _title(this, st::confirmInviteTitle)
|
||||
, _status(this, st::confirmInviteStatus)
|
||||
, _participants(GetParticipants(_session, data))
|
||||
, _isChannel(data.is_channel() && !data.is_megagroup()) {
|
||||
const auto title = qs(data.vtitle());
|
||||
const auto count = data.vparticipants_count().v;
|
||||
const auto status = [&] {
|
||||
return invitePeekChannel
|
||||
? tr::lng_channel_invite_private(tr::now)
|
||||
: (!_participants.empty() && _participants.size() < count)
|
||||
? tr::lng_group_invite_members(tr::now, lt_count, count)
|
||||
: (count > 0)
|
||||
? tr::lng_chat_status_members(tr::now, lt_count_decimal, count)
|
||||
: _isChannel
|
||||
? tr::lng_channel_status(tr::now)
|
||||
: tr::lng_group_status(tr::now);
|
||||
}();
|
||||
_title->setText(title);
|
||||
_status->setText(status);
|
||||
|
||||
const auto photo = _session->data().processPhoto(data.vphoto());
|
||||
if (!photo->isNull()) {
|
||||
_photo = photo->createMediaView();
|
||||
_photo->wanted(Data::PhotoSize::Small, Data::FileOrigin());
|
||||
if (!_photo->image(Data::PhotoSize::Small)) {
|
||||
_session->downloaderTaskFinished(
|
||||
) | rpl::start_with_next([=] {
|
||||
update();
|
||||
}, lifetime());
|
||||
}
|
||||
} else {
|
||||
_photoEmpty = std::make_unique<Ui::EmptyUserpic>(
|
||||
Data::PeerUserpicColor(0),
|
||||
title);
|
||||
}
|
||||
}
|
||||
|
||||
ConfirmInviteBox::~ConfirmInviteBox() = default;
|
||||
|
||||
auto ConfirmInviteBox::GetParticipants(
|
||||
not_null<Main::Session*> session,
|
||||
const MTPDchatInvite &data)
|
||||
-> std::vector<Participant> {
|
||||
const auto participants = data.vparticipants();
|
||||
if (!participants) {
|
||||
return {};
|
||||
}
|
||||
const auto &v = participants->v;
|
||||
auto result = std::vector<Participant>();
|
||||
result.reserve(v.size());
|
||||
for (const auto &participant : v) {
|
||||
if (const auto user = session->data().processUser(participant)) {
|
||||
result.push_back(Participant{ user });
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void ConfirmInviteBox::prepare() {
|
||||
addButton(
|
||||
(_isChannel
|
||||
? tr::lng_profile_join_channel()
|
||||
: tr::lng_profile_join_group()),
|
||||
_submit);
|
||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||
|
||||
while (_participants.size() > 4) {
|
||||
_participants.pop_back();
|
||||
}
|
||||
|
||||
auto newHeight = st::confirmInviteStatusTop + _status->height() + st::boxPadding.bottom();
|
||||
if (!_participants.empty()) {
|
||||
int skip = (st::boxWideWidth - 4 * st::confirmInviteUserPhotoSize) / 5;
|
||||
int padding = skip / 2;
|
||||
_userWidth = (st::confirmInviteUserPhotoSize + 2 * padding);
|
||||
int sumWidth = _participants.size() * _userWidth;
|
||||
int left = (st::boxWideWidth - sumWidth) / 2;
|
||||
for (const auto &participant : _participants) {
|
||||
auto name = new Ui::FlatLabel(this, st::confirmInviteUserName);
|
||||
name->resizeToWidth(st::confirmInviteUserPhotoSize + padding);
|
||||
name->setText(participant.user->firstName.isEmpty()
|
||||
? participant.user->name
|
||||
: participant.user->firstName);
|
||||
name->moveToLeft(left + (padding / 2), st::confirmInviteUserNameTop);
|
||||
left += _userWidth;
|
||||
}
|
||||
|
||||
newHeight += st::confirmInviteUserHeight;
|
||||
}
|
||||
setDimensions(st::boxWideWidth, newHeight);
|
||||
}
|
||||
|
||||
void ConfirmInviteBox::resizeEvent(QResizeEvent *e) {
|
||||
BoxContent::resizeEvent(e);
|
||||
_title->move((width() - _title->width()) / 2, st::confirmInviteTitleTop);
|
||||
_status->move((width() - _status->width()) / 2, st::confirmInviteStatusTop);
|
||||
}
|
||||
|
||||
void ConfirmInviteBox::paintEvent(QPaintEvent *e) {
|
||||
BoxContent::paintEvent(e);
|
||||
|
||||
Painter p(this);
|
||||
|
||||
if (_photo) {
|
||||
if (const auto image = _photo->image(Data::PhotoSize::Small)) {
|
||||
p.drawPixmap(
|
||||
(width() - st::confirmInvitePhotoSize) / 2,
|
||||
st::confirmInvitePhotoTop,
|
||||
image->pixCircled(
|
||||
st::confirmInvitePhotoSize,
|
||||
st::confirmInvitePhotoSize));
|
||||
}
|
||||
} else if (_photoEmpty) {
|
||||
_photoEmpty->paint(
|
||||
p,
|
||||
(width() - st::confirmInvitePhotoSize) / 2,
|
||||
st::confirmInvitePhotoTop,
|
||||
width(),
|
||||
st::confirmInvitePhotoSize);
|
||||
}
|
||||
|
||||
int sumWidth = _participants.size() * _userWidth;
|
||||
int left = (width() - sumWidth) / 2;
|
||||
for (auto &participant : _participants) {
|
||||
participant.user->paintUserpicLeft(
|
||||
p,
|
||||
participant.userpic,
|
||||
left + (_userWidth - st::confirmInviteUserPhotoSize) / 2,
|
||||
st::confirmInviteUserPhotoTop,
|
||||
width(),
|
||||
st::confirmInviteUserPhotoSize);
|
||||
left += _userWidth;
|
||||
}
|
||||
}
|
||||
74
Telegram/SourceFiles/api/api_chat_invite.h
Normal file
@@ -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
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "ui/layers/box_content.h"
|
||||
|
||||
class UserData;
|
||||
class ChannelData;
|
||||
|
||||
namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace Data {
|
||||
class CloudImageView;
|
||||
class PhotoMedia;
|
||||
} // namespace Data
|
||||
|
||||
namespace Ui {
|
||||
class EmptyUserpic;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Api {
|
||||
|
||||
void CheckChatInvite(
|
||||
not_null<Window::SessionController*> controller,
|
||||
const QString &hash,
|
||||
ChannelData *invitePeekChannel = nullptr);
|
||||
|
||||
} // namespace Api
|
||||
|
||||
class ConfirmInviteBox final : public Ui::BoxContent {
|
||||
public:
|
||||
ConfirmInviteBox(
|
||||
QWidget*,
|
||||
not_null<Main::Session*> session,
|
||||
const MTPDchatInvite &data,
|
||||
ChannelData *invitePeekChannel,
|
||||
Fn<void()> submit);
|
||||
~ConfirmInviteBox();
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
private:
|
||||
struct Participant {
|
||||
not_null<UserData*> user;
|
||||
std::shared_ptr<Data::CloudImageView> userpic;
|
||||
};
|
||||
static std::vector<Participant> GetParticipants(
|
||||
not_null<Main::Session*> session,
|
||||
const MTPDchatInvite &data);
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
|
||||
Fn<void()> _submit;
|
||||
object_ptr<Ui::FlatLabel> _title;
|
||||
object_ptr<Ui::FlatLabel> _status;
|
||||
std::shared_ptr<Data::PhotoMedia> _photo;
|
||||
std::unique_ptr<Ui::EmptyUserpic> _photoEmpty;
|
||||
std::vector<Participant> _participants;
|
||||
bool _isChannel = false;
|
||||
|
||||
int _userWidth = 0;
|
||||
|
||||
};
|
||||
213
Telegram/SourceFiles/api/api_editing.cpp
Normal file
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
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_editing.h"
|
||||
|
||||
#include "apiwrap.h"
|
||||
#include "api/api_media.h"
|
||||
#include "api/api_text_entities.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "data/data_scheduled_messages.h"
|
||||
#include "data/data_session.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "mtproto/mtproto_rpc_sender.h"
|
||||
|
||||
namespace Api {
|
||||
namespace {
|
||||
|
||||
using namespace rpl::details;
|
||||
|
||||
template <typename T>
|
||||
constexpr auto WithId =
|
||||
is_callable_plain_v<T, const MTPUpdates &, Fn<void()>, mtpRequestId>;
|
||||
template <typename T>
|
||||
constexpr auto WithoutId =
|
||||
is_callable_plain_v<T, const MTPUpdates &, Fn<void()>>;
|
||||
template <typename T>
|
||||
constexpr auto WithoutCallback =
|
||||
is_callable_plain_v<T, const MTPUpdates &>;
|
||||
|
||||
template <typename DoneCallback, typename FailCallback>
|
||||
mtpRequestId EditMessage(
|
||||
not_null<HistoryItem*> item,
|
||||
const TextWithEntities &textWithEntities,
|
||||
SendOptions options,
|
||||
DoneCallback &&done,
|
||||
FailCallback &&fail,
|
||||
std::optional<MTPInputMedia> inputMedia = std::nullopt) {
|
||||
const auto session = &item->history()->session();
|
||||
const auto api = &session->api();
|
||||
|
||||
const auto text = textWithEntities.text;
|
||||
const auto sentEntities = EntitiesToMTP(
|
||||
session,
|
||||
textWithEntities.entities,
|
||||
ConvertOption::SkipLocal);
|
||||
const auto media = item->media();
|
||||
|
||||
const auto emptyFlag = MTPmessages_EditMessage::Flag(0);
|
||||
const auto flags = emptyFlag
|
||||
| (!text.isEmpty() || media
|
||||
? MTPmessages_EditMessage::Flag::f_message
|
||||
: emptyFlag)
|
||||
| ((media && inputMedia.has_value())
|
||||
? MTPmessages_EditMessage::Flag::f_media
|
||||
: emptyFlag)
|
||||
| (options.removeWebPageId
|
||||
? MTPmessages_EditMessage::Flag::f_no_webpage
|
||||
: emptyFlag)
|
||||
| (!sentEntities.v.isEmpty()
|
||||
? MTPmessages_EditMessage::Flag::f_entities
|
||||
: emptyFlag)
|
||||
| (options.scheduled
|
||||
? MTPmessages_EditMessage::Flag::f_schedule_date
|
||||
: emptyFlag);
|
||||
|
||||
const auto id = item->isScheduled()
|
||||
? session->data().scheduledMessages().lookupId(item)
|
||||
: item->id;
|
||||
return api->request(MTPmessages_EditMessage(
|
||||
MTP_flags(flags),
|
||||
item->history()->peer->input,
|
||||
MTP_int(id),
|
||||
MTP_string(text),
|
||||
inputMedia.value_or(MTPInputMedia()),
|
||||
MTPReplyMarkup(),
|
||||
sentEntities,
|
||||
MTP_int(options.scheduled)
|
||||
)).done([=](
|
||||
const MTPUpdates &result,
|
||||
[[maybe_unused]] mtpRequestId requestId) {
|
||||
const auto apply = [=] { api->applyUpdates(result); };
|
||||
|
||||
if constexpr (WithId<DoneCallback>) {
|
||||
done(result, apply, requestId);
|
||||
} else if constexpr (WithoutId<DoneCallback>) {
|
||||
done(result, apply);
|
||||
} else if constexpr (WithoutCallback<DoneCallback>) {
|
||||
done(result);
|
||||
apply();
|
||||
} else {
|
||||
apply();
|
||||
}
|
||||
}).fail(
|
||||
fail
|
||||
).send();
|
||||
}
|
||||
|
||||
template <typename DoneCallback, typename FailCallback>
|
||||
mtpRequestId EditMessage(
|
||||
not_null<HistoryItem*> item,
|
||||
SendOptions options,
|
||||
DoneCallback &&done,
|
||||
FailCallback &&fail,
|
||||
std::optional<MTPInputMedia> inputMedia = std::nullopt) {
|
||||
const auto &text = item->originalText();
|
||||
return EditMessage(
|
||||
item,
|
||||
text,
|
||||
options,
|
||||
std::forward<DoneCallback>(done),
|
||||
std::forward<FailCallback>(fail),
|
||||
inputMedia);
|
||||
}
|
||||
|
||||
void EditMessageWithUploadedMedia(
|
||||
not_null<HistoryItem*> item,
|
||||
SendOptions options,
|
||||
MTPInputMedia media) {
|
||||
const auto done = [=](const auto &result, Fn<void()> applyUpdates) {
|
||||
if (item) {
|
||||
item->clearSavedMedia();
|
||||
item->setIsLocalUpdateMedia(true);
|
||||
applyUpdates();
|
||||
item->setIsLocalUpdateMedia(false);
|
||||
}
|
||||
};
|
||||
const auto fail = [=](const RPCError &error) {
|
||||
const auto err = error.type();
|
||||
const auto session = &item->history()->session();
|
||||
const auto notModified = (err == u"MESSAGE_NOT_MODIFIED"_q);
|
||||
const auto mediaInvalid = (err == u"MEDIA_NEW_INVALID"_q);
|
||||
if (notModified || mediaInvalid) {
|
||||
item->returnSavedMedia();
|
||||
session->data().sendHistoryChangeNotifications();
|
||||
if (mediaInvalid) {
|
||||
Ui::show(
|
||||
Box<InformBox>(tr::lng_edit_media_invalid_file(tr::now)),
|
||||
Ui::LayerOption::KeepOther);
|
||||
}
|
||||
} else {
|
||||
session->api().sendMessageFail(error, item->history()->peer);
|
||||
}
|
||||
};
|
||||
|
||||
EditMessage(item, options, done, fail, media);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void RescheduleMessage(
|
||||
not_null<HistoryItem*> item,
|
||||
SendOptions options) {
|
||||
const auto empty = [](const auto &r) {};
|
||||
EditMessage(item, options, empty, empty);
|
||||
}
|
||||
|
||||
void EditMessageWithUploadedDocument(
|
||||
HistoryItem *item,
|
||||
const MTPInputFile &file,
|
||||
const std::optional<MTPInputFile> &thumb,
|
||||
SendOptions options) {
|
||||
if (!item || !item->media() || !item->media()->document()) {
|
||||
return;
|
||||
}
|
||||
const auto media = PrepareUploadedDocument(item, file, thumb);
|
||||
EditMessageWithUploadedMedia(item, options, media);
|
||||
}
|
||||
|
||||
void EditMessageWithUploadedPhoto(
|
||||
HistoryItem *item,
|
||||
const MTPInputFile &file,
|
||||
SendOptions options) {
|
||||
if (!item || !item->media() || !item->media()->photo()) {
|
||||
return;
|
||||
}
|
||||
const auto media = PrepareUploadedPhoto(file);
|
||||
EditMessageWithUploadedMedia(item, options, media);
|
||||
}
|
||||
|
||||
mtpRequestId EditCaption(
|
||||
not_null<HistoryItem*> item,
|
||||
const TextWithEntities &caption,
|
||||
SendOptions options,
|
||||
Fn<void(const MTPUpdates &)> done,
|
||||
Fn<void(const RPCError &)> fail) {
|
||||
return EditMessage(item, caption, options, done, fail);
|
||||
}
|
||||
|
||||
mtpRequestId EditTextMessage(
|
||||
not_null<HistoryItem*> item,
|
||||
const TextWithEntities &caption,
|
||||
SendOptions options,
|
||||
Fn<void(const MTPUpdates &, mtpRequestId requestId)> done,
|
||||
Fn<void(const RPCError &, mtpRequestId requestId)> fail) {
|
||||
const auto callback = [=](
|
||||
const auto &result,
|
||||
Fn<void()> applyUpdates,
|
||||
auto id) {
|
||||
applyUpdates();
|
||||
done(result, id);
|
||||
};
|
||||
return EditMessage(item, caption, options, callback, fail);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Api
|
||||
52
Telegram/SourceFiles/api/api_editing.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
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
|
||||
|
||||
class HistoryItem;
|
||||
class RPCError;
|
||||
|
||||
namespace Api {
|
||||
|
||||
struct SendOptions;
|
||||
|
||||
const auto kDefaultEditMessagesErrors = {
|
||||
u"MESSAGE_ID_INVALID"_q,
|
||||
u"CHAT_ADMIN_REQUIRED"_q,
|
||||
u"MESSAGE_EDIT_TIME_EXPIRED"_q,
|
||||
};
|
||||
|
||||
void RescheduleMessage(
|
||||
not_null<HistoryItem*> item,
|
||||
SendOptions options);
|
||||
|
||||
void EditMessageWithUploadedDocument(
|
||||
HistoryItem *item,
|
||||
const MTPInputFile &file,
|
||||
const std::optional<MTPInputFile> &thumb,
|
||||
SendOptions options);
|
||||
|
||||
void EditMessageWithUploadedPhoto(
|
||||
HistoryItem *item,
|
||||
const MTPInputFile &file,
|
||||
SendOptions options);
|
||||
|
||||
mtpRequestId EditCaption(
|
||||
not_null<HistoryItem*> item,
|
||||
const TextWithEntities &caption,
|
||||
SendOptions options,
|
||||
Fn<void(const MTPUpdates &)> done,
|
||||
Fn<void(const RPCError &)> fail);
|
||||
|
||||
mtpRequestId EditTextMessage(
|
||||
not_null<HistoryItem*> item,
|
||||
const TextWithEntities &caption,
|
||||
SendOptions options,
|
||||
Fn<void(const MTPUpdates &, mtpRequestId requestId)> done,
|
||||
Fn<void(const RPCError &, mtpRequestId requestId)> fail);
|
||||
|
||||
} // namespace Api
|
||||
103
Telegram/SourceFiles/api/api_global_privacy.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
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_global_privacy.h"
|
||||
|
||||
#include "apiwrap.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_account.h"
|
||||
#include "main/main_app_config.h"
|
||||
|
||||
namespace Api {
|
||||
|
||||
GlobalPrivacy::GlobalPrivacy(not_null<ApiWrap*> api)
|
||||
: _session(&api->session())
|
||||
, _api(&api->instance()) {
|
||||
}
|
||||
|
||||
void GlobalPrivacy::reload(Fn<void()> callback) {
|
||||
if (callback) {
|
||||
_callbacks.push_back(std::move(callback));
|
||||
}
|
||||
if (_requestId) {
|
||||
return;
|
||||
}
|
||||
_requestId = _api.request(MTPaccount_GetGlobalPrivacySettings(
|
||||
)).done([=](const MTPGlobalPrivacySettings &result) {
|
||||
_requestId = 0;
|
||||
apply(result);
|
||||
for (const auto &callback : base::take(_callbacks)) {
|
||||
callback();
|
||||
}
|
||||
}).fail([=](const RPCError &error) {
|
||||
_requestId = 0;
|
||||
for (const auto &callback : base::take(_callbacks)) {
|
||||
callback();
|
||||
}
|
||||
}).send();
|
||||
|
||||
_session->account().appConfig().value(
|
||||
) | rpl::start_with_next([=] {
|
||||
_showArchiveAndMute = _session->account().appConfig().get<bool>(
|
||||
u"autoarchive_setting_available"_q,
|
||||
false);
|
||||
}, _session->lifetime());
|
||||
}
|
||||
|
||||
bool GlobalPrivacy::archiveAndMuteCurrent() const {
|
||||
return _archiveAndMute.current();
|
||||
}
|
||||
|
||||
rpl::producer<bool> GlobalPrivacy::archiveAndMute() const {
|
||||
return _archiveAndMute.value();
|
||||
}
|
||||
|
||||
rpl::producer<bool> GlobalPrivacy::showArchiveAndMute() const {
|
||||
using namespace rpl::mappers;
|
||||
|
||||
return rpl::combine(
|
||||
archiveAndMute(),
|
||||
_showArchiveAndMute.value(),
|
||||
_1 || _2);
|
||||
}
|
||||
|
||||
rpl::producer<> GlobalPrivacy::suggestArchiveAndMute() const {
|
||||
return _session->account().appConfig().suggestionRequested(
|
||||
u"AUTOARCHIVE_POPULAR"_q);
|
||||
}
|
||||
|
||||
void GlobalPrivacy::dismissArchiveAndMuteSuggestion() {
|
||||
_session->account().appConfig().dismissSuggestion(
|
||||
u"AUTOARCHIVE_POPULAR"_q);
|
||||
}
|
||||
|
||||
void GlobalPrivacy::update(bool archiveAndMute) {
|
||||
using Flag = MTPDglobalPrivacySettings::Flag;
|
||||
|
||||
_api.request(_requestId).cancel();
|
||||
_requestId = _api.request(MTPaccount_SetGlobalPrivacySettings(
|
||||
MTP_globalPrivacySettings(
|
||||
MTP_flags(Flag::f_archive_and_mute_new_noncontact_peers),
|
||||
MTP_bool(archiveAndMute))
|
||||
)).done([=](const MTPGlobalPrivacySettings &result) {
|
||||
_requestId = 0;
|
||||
apply(result);
|
||||
}).fail([=](const RPCError &error) {
|
||||
_requestId = 0;
|
||||
}).send();
|
||||
_archiveAndMute = archiveAndMute;
|
||||
}
|
||||
|
||||
void GlobalPrivacy::apply(const MTPGlobalPrivacySettings &data) {
|
||||
data.match([&](const MTPDglobalPrivacySettings &data) {
|
||||
_archiveAndMute = data.varchive_and_mute_new_noncontact_peers()
|
||||
? mtpIsTrue(*data.varchive_and_mute_new_noncontact_peers())
|
||||
: false;
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Api
|
||||
45
Telegram/SourceFiles/api/api_global_privacy.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
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 Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Api {
|
||||
|
||||
class GlobalPrivacy final {
|
||||
public:
|
||||
explicit GlobalPrivacy(not_null<ApiWrap*> api);
|
||||
|
||||
void reload(Fn<void()> callback = nullptr);
|
||||
void update(bool archiveAndMute);
|
||||
|
||||
[[nodiscard]] bool archiveAndMuteCurrent() const;
|
||||
[[nodiscard]] rpl::producer<bool> archiveAndMute() const;
|
||||
[[nodiscard]] rpl::producer<bool> showArchiveAndMute() const;
|
||||
[[nodiscard]] rpl::producer<> suggestArchiveAndMute() const;
|
||||
void dismissArchiveAndMuteSuggestion();
|
||||
|
||||
private:
|
||||
void apply(const MTPGlobalPrivacySettings &data);
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
MTP::Sender _api;
|
||||
mtpRequestId _requestId = 0;
|
||||
rpl::variable<bool> _archiveAndMute = false;
|
||||
rpl::variable<bool> _showArchiveAndMute = false;
|
||||
std::vector<Fn<void()>> _callbacks;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Api
|
||||
107
Telegram/SourceFiles/api/api_media.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
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_media.h"
|
||||
|
||||
#include "data/data_document.h"
|
||||
#include "history/history_item.h"
|
||||
|
||||
namespace Api {
|
||||
namespace {
|
||||
|
||||
MTPVector<MTPDocumentAttribute> ComposeSendingDocumentAttributes(
|
||||
not_null<DocumentData*> document) {
|
||||
const auto filenameAttribute = MTP_documentAttributeFilename(
|
||||
MTP_string(document->filename()));
|
||||
const auto dimensions = document->dimensions;
|
||||
auto attributes = QVector<MTPDocumentAttribute>(1, filenameAttribute);
|
||||
if (dimensions.width() > 0 && dimensions.height() > 0) {
|
||||
const auto duration = document->getDuration();
|
||||
if (duration >= 0 && !document->hasMimeType(qstr("image/gif"))) {
|
||||
auto flags = MTPDdocumentAttributeVideo::Flags(0);
|
||||
using VideoFlag = MTPDdocumentAttributeVideo::Flag;
|
||||
if (document->isVideoMessage()) {
|
||||
flags |= VideoFlag::f_round_message;
|
||||
}
|
||||
if (document->supportsStreaming()) {
|
||||
flags |= VideoFlag::f_supports_streaming;
|
||||
}
|
||||
attributes.push_back(MTP_documentAttributeVideo(
|
||||
MTP_flags(flags),
|
||||
MTP_int(duration),
|
||||
MTP_int(dimensions.width()),
|
||||
MTP_int(dimensions.height())));
|
||||
} else {
|
||||
attributes.push_back(MTP_documentAttributeImageSize(
|
||||
MTP_int(dimensions.width()),
|
||||
MTP_int(dimensions.height())));
|
||||
}
|
||||
}
|
||||
if (document->type == AnimatedDocument) {
|
||||
attributes.push_back(MTP_documentAttributeAnimated());
|
||||
} else if (document->type == StickerDocument && document->sticker()) {
|
||||
attributes.push_back(MTP_documentAttributeSticker(
|
||||
MTP_flags(0),
|
||||
MTP_string(document->sticker()->alt),
|
||||
document->sticker()->set,
|
||||
MTPMaskCoords()));
|
||||
} else if (const auto song = document->song()) {
|
||||
const auto flags = MTPDdocumentAttributeAudio::Flag::f_title
|
||||
| MTPDdocumentAttributeAudio::Flag::f_performer;
|
||||
attributes.push_back(MTP_documentAttributeAudio(
|
||||
MTP_flags(flags),
|
||||
MTP_int(song->duration),
|
||||
MTP_string(song->title),
|
||||
MTP_string(song->performer),
|
||||
MTPstring()));
|
||||
} else if (const auto voice = document->voice()) {
|
||||
const auto flags = MTPDdocumentAttributeAudio::Flag::f_voice
|
||||
| MTPDdocumentAttributeAudio::Flag::f_waveform;
|
||||
attributes.push_back(MTP_documentAttributeAudio(
|
||||
MTP_flags(flags),
|
||||
MTP_int(voice->duration),
|
||||
MTPstring(),
|
||||
MTPstring(),
|
||||
MTP_bytes(documentWaveformEncode5bit(voice->waveform))));
|
||||
}
|
||||
return MTP_vector<MTPDocumentAttribute>(attributes);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
MTPInputMedia PrepareUploadedPhoto(const MTPInputFile &file) {
|
||||
return MTP_inputMediaUploadedPhoto(
|
||||
MTP_flags(0),
|
||||
file,
|
||||
MTPVector<MTPInputDocument>(),
|
||||
MTP_int(0));
|
||||
}
|
||||
|
||||
MTPInputMedia PrepareUploadedDocument(
|
||||
not_null<HistoryItem*> item,
|
||||
const MTPInputFile &file,
|
||||
const std::optional<MTPInputFile> &thumb) {
|
||||
if (!item || !item->media() || !item->media()->document()) {
|
||||
return MTP_inputMediaEmpty();
|
||||
}
|
||||
const auto emptyFlag = MTPDinputMediaUploadedDocument::Flags(0);
|
||||
using DocFlags = MTPDinputMediaUploadedDocument::Flag;
|
||||
const auto flags = emptyFlag
|
||||
| (thumb ? DocFlags::f_thumb : emptyFlag)
|
||||
| (item->groupId() ? DocFlags::f_nosound_video : emptyFlag);
|
||||
const auto document = item->media()->document();
|
||||
return MTP_inputMediaUploadedDocument(
|
||||
MTP_flags(flags),
|
||||
file,
|
||||
thumb.value_or(MTPInputFile()),
|
||||
MTP_string(document->mimeString()),
|
||||
ComposeSendingDocumentAttributes(document),
|
||||
MTPVector<MTPInputDocument>(),
|
||||
MTP_int(0));
|
||||
}
|
||||
|
||||
} // namespace Api
|
||||
21
Telegram/SourceFiles/api/api_media.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
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
|
||||
|
||||
class HistoryItem;
|
||||
|
||||
namespace Api {
|
||||
|
||||
MTPInputMedia PrepareUploadedPhoto(const MTPInputFile &file);
|
||||
|
||||
MTPInputMedia PrepareUploadedDocument(
|
||||
not_null<HistoryItem*> item,
|
||||
const MTPInputFile &file,
|
||||
const std::optional<MTPInputFile> &thumb);
|
||||
|
||||
} // namespace Api
|
||||
@@ -400,6 +400,8 @@ void SendConfirmedFile(
|
||||
}
|
||||
if (file->to.options.scheduled) {
|
||||
flags |= MTPDmessage::Flag::f_from_scheduled;
|
||||
// Scheduled messages have no the 'edited' badge.
|
||||
flags |= MTPDmessage::Flag::f_edit_hide;
|
||||
} else {
|
||||
clientFlags |= MTPDmessage_ClientFlag::f_local_history_entry;
|
||||
}
|
||||
@@ -523,9 +525,13 @@ void SendConfirmedFile(
|
||||
}
|
||||
|
||||
session->data().sendHistoryChangeNotifications();
|
||||
session->changes().historyUpdated(
|
||||
history,
|
||||
Data::HistoryUpdate::Flag::MessageSent);
|
||||
if (!itemToEdit) {
|
||||
session->changes().historyUpdated(
|
||||
history,
|
||||
(action.options.scheduled
|
||||
? Data::HistoryUpdate::Flag::ScheduledSent
|
||||
: Data::HistoryUpdate::Flag::MessageSent));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Api
|
||||
|
||||
@@ -1642,15 +1642,21 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||
if (auto user = session().data().userLoaded(d.vuser_id().v)) {
|
||||
user->setPhoto(d.vphoto());
|
||||
user->loadUserpic();
|
||||
if (mtpIsTrue(d.vprevious()) || !user->userpicPhotoId()) {
|
||||
// After that update we don't have enough information to
|
||||
// create a 'photo' with all necessary fields. So if
|
||||
// we receive second such update we end up with a 'photo_id'
|
||||
// in user_photos list without a loaded 'photo'.
|
||||
// It fails to show in media overview if you try to open it.
|
||||
//
|
||||
//if (mtpIsTrue(d.vprevious()) || !user->userpicPhotoId()) {
|
||||
session().storage().remove(Storage::UserPhotosRemoveAfter(
|
||||
user->bareId(),
|
||||
user->userpicPhotoId()));
|
||||
} else {
|
||||
session().storage().add(Storage::UserPhotosAddNew(
|
||||
user->bareId(),
|
||||
user->userpicPhotoId()));
|
||||
}
|
||||
//} else {
|
||||
// session().storage().add(Storage::UserPhotosAddNew(
|
||||
// user->bareId(),
|
||||
// user->userpicPhotoId()));
|
||||
//}
|
||||
}
|
||||
} break;
|
||||
|
||||
@@ -1720,8 +1726,9 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||
auto &d = update.c_updateEncryptedMessagesRead();
|
||||
} break;
|
||||
|
||||
case mtpc_updatePhoneCall: {
|
||||
Core::App().calls().handleUpdate(&session(), update.c_updatePhoneCall());
|
||||
case mtpc_updatePhoneCall:
|
||||
case mtpc_updatePhoneCallSignalingData: {
|
||||
Core::App().calls().handleUpdate(&session(), update);
|
||||
} break;
|
||||
|
||||
case mtpc_updateUserBlocked: {
|
||||
|
||||
@@ -8,10 +8,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "apiwrap.h"
|
||||
|
||||
#include "api/api_hash.h"
|
||||
#include "api/api_media.h"
|
||||
#include "api/api_sending.h"
|
||||
#include "api/api_text_entities.h"
|
||||
#include "api/api_self_destruct.h"
|
||||
#include "api/api_sensitive_content.h"
|
||||
#include "api/api_global_privacy.h"
|
||||
#include "api/api_updates.h"
|
||||
#include "data/stickers/data_stickers.h"
|
||||
#include "data/data_drafts.h"
|
||||
@@ -111,63 +113,6 @@ using PhotoFileLocationId = Data::PhotoFileLocationId;
|
||||
using DocumentFileLocationId = Data::DocumentFileLocationId;
|
||||
using UpdatedFileReferences = Data::UpdatedFileReferences;
|
||||
|
||||
MTPVector<MTPDocumentAttribute> ComposeSendingDocumentAttributes(
|
||||
not_null<DocumentData*> document) {
|
||||
const auto filenameAttribute = MTP_documentAttributeFilename(
|
||||
MTP_string(document->filename()));
|
||||
const auto dimensions = document->dimensions;
|
||||
auto attributes = QVector<MTPDocumentAttribute>(1, filenameAttribute);
|
||||
if (dimensions.width() > 0 && dimensions.height() > 0) {
|
||||
const auto duration = document->getDuration();
|
||||
if (duration >= 0 && !document->hasMimeType(qstr("image/gif"))) {
|
||||
auto flags = MTPDdocumentAttributeVideo::Flags(0);
|
||||
if (document->isVideoMessage()) {
|
||||
flags |= MTPDdocumentAttributeVideo::Flag::f_round_message;
|
||||
}
|
||||
if (document->supportsStreaming()) {
|
||||
flags |= MTPDdocumentAttributeVideo::Flag::f_supports_streaming;
|
||||
}
|
||||
attributes.push_back(MTP_documentAttributeVideo(
|
||||
MTP_flags(flags),
|
||||
MTP_int(duration),
|
||||
MTP_int(dimensions.width()),
|
||||
MTP_int(dimensions.height())));
|
||||
} else {
|
||||
attributes.push_back(MTP_documentAttributeImageSize(
|
||||
MTP_int(dimensions.width()),
|
||||
MTP_int(dimensions.height())));
|
||||
}
|
||||
}
|
||||
if (document->type == AnimatedDocument) {
|
||||
attributes.push_back(MTP_documentAttributeAnimated());
|
||||
} else if (document->type == StickerDocument && document->sticker()) {
|
||||
attributes.push_back(MTP_documentAttributeSticker(
|
||||
MTP_flags(0),
|
||||
MTP_string(document->sticker()->alt),
|
||||
document->sticker()->set,
|
||||
MTPMaskCoords()));
|
||||
} else if (const auto song = document->song()) {
|
||||
const auto flags = MTPDdocumentAttributeAudio::Flag::f_title
|
||||
| MTPDdocumentAttributeAudio::Flag::f_performer;
|
||||
attributes.push_back(MTP_documentAttributeAudio(
|
||||
MTP_flags(flags),
|
||||
MTP_int(song->duration),
|
||||
MTP_string(song->title),
|
||||
MTP_string(song->performer),
|
||||
MTPstring()));
|
||||
} else if (const auto voice = document->voice()) {
|
||||
const auto flags = MTPDdocumentAttributeAudio::Flag::f_voice
|
||||
| MTPDdocumentAttributeAudio::Flag::f_waveform;
|
||||
attributes.push_back(MTP_documentAttributeAudio(
|
||||
MTP_flags(flags),
|
||||
MTP_int(voice->duration),
|
||||
MTPstring(),
|
||||
MTPstring(),
|
||||
MTP_bytes(documentWaveformEncode5bit(voice->waveform))));
|
||||
}
|
||||
return MTP_vector<MTPDocumentAttribute>(attributes);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
MTPInputPrivacyKey ApiWrap::Privacy::Input(Key key) {
|
||||
@@ -242,7 +187,8 @@ ApiWrap::ApiWrap(not_null<Main::Session*> session)
|
||||
, _topPromotionTimer([=] { refreshTopPromotion(); })
|
||||
, _updateNotifySettingsTimer([=] { sendNotifySettingsUpdates(); })
|
||||
, _selfDestruct(std::make_unique<Api::SelfDestruct>(this))
|
||||
, _sensitiveContent(std::make_unique<Api::SensitiveContent>(this)) {
|
||||
, _sensitiveContent(std::make_unique<Api::SensitiveContent>(this))
|
||||
, _globalPrivacy(std::make_unique<Api::GlobalPrivacy>(this)) {
|
||||
crl::on_main(session, [=] {
|
||||
// You can't use _session->lifetime() in the constructor,
|
||||
// only queued, because it is not constructed yet.
|
||||
@@ -1701,7 +1647,7 @@ void ApiWrap::requestSelfParticipant(not_null<ChannelData*> channel) {
|
||||
}).fail([=](const RPCError &error) {
|
||||
_selfParticipantRequests.erase(channel);
|
||||
if (error.type() == qstr("CHANNEL_PRIVATE")) {
|
||||
channel->markForbidden();
|
||||
channel->privateErrorReceived();
|
||||
}
|
||||
finalize(-1, 0);
|
||||
}).afterDelay(kSmallDelayMs).send();
|
||||
@@ -2018,6 +1964,9 @@ void ApiWrap::joinChannel(not_null<ChannelData*> channel) {
|
||||
applyUpdates(result);
|
||||
}).fail([=](const RPCError &error) {
|
||||
if (error.type() == qstr("CHANNEL_PRIVATE")
|
||||
&& channel->invitePeekExpires()) {
|
||||
channel->privateErrorReceived();
|
||||
} else if (error.type() == qstr("CHANNEL_PRIVATE")
|
||||
|| error.type() == qstr("CHANNEL_PUBLIC_GROUP_NA")
|
||||
|| error.type() == qstr("USER_BANNED_IN_CHANNEL")) {
|
||||
Ui::show(Box<InformBox>(channel->isMegagroup()
|
||||
@@ -3959,8 +3908,10 @@ void ApiWrap::userPhotosDone(
|
||||
//}
|
||||
|
||||
void ApiWrap::sendAction(const SendAction &action) {
|
||||
_session->data().histories().readInbox(action.history);
|
||||
action.history->getReadyFor(ShowAtTheEndMsgId);
|
||||
if (!action.options.scheduled) {
|
||||
_session->data().histories().readInbox(action.history);
|
||||
action.history->getReadyFor(ShowAtTheEndMsgId);
|
||||
}
|
||||
_sendActions.fire_copy(action);
|
||||
}
|
||||
|
||||
@@ -3980,7 +3931,9 @@ void ApiWrap::finishForwarding(const SendAction &action) {
|
||||
_session->data().sendHistoryChangeNotifications();
|
||||
_session->changes().historyUpdated(
|
||||
history,
|
||||
Data::HistoryUpdate::Flag::MessageSent);
|
||||
(action.options.scheduled
|
||||
? Data::HistoryUpdate::Flag::ScheduledSent
|
||||
: Data::HistoryUpdate::Flag::MessageSent));
|
||||
}
|
||||
|
||||
void ApiWrap::forwardMessages(
|
||||
@@ -4220,7 +4173,9 @@ void ApiWrap::sendSharedContact(
|
||||
_session->data().sendHistoryChangeNotifications();
|
||||
_session->changes().historyUpdated(
|
||||
history,
|
||||
Data::HistoryUpdate::Flag::MessageSent);
|
||||
(action.options.scheduled
|
||||
? Data::HistoryUpdate::Flag::ScheduledSent
|
||||
: Data::HistoryUpdate::Flag::MessageSent));
|
||||
}
|
||||
|
||||
void ApiWrap::sendVoiceMessage(
|
||||
@@ -4339,11 +4294,7 @@ void ApiWrap::sendUploadedPhoto(
|
||||
const MTPInputFile &file,
|
||||
Api::SendOptions options) {
|
||||
if (const auto item = _session->data().message(localId)) {
|
||||
const auto media = MTP_inputMediaUploadedPhoto(
|
||||
MTP_flags(0),
|
||||
file,
|
||||
MTPVector<MTPInputDocument>(),
|
||||
MTP_int(0));
|
||||
const auto media = Api::PrepareUploadedPhoto(file);
|
||||
if (const auto groupId = item->groupId()) {
|
||||
uploadAlbumMedia(item, groupId, media);
|
||||
} else {
|
||||
@@ -4358,125 +4309,17 @@ void ApiWrap::sendUploadedDocument(
|
||||
const std::optional<MTPInputFile> &thumb,
|
||||
Api::SendOptions options) {
|
||||
if (const auto item = _session->data().message(localId)) {
|
||||
auto media = item->media();
|
||||
if (auto document = media ? media->document() : nullptr) {
|
||||
const auto groupId = item->groupId();
|
||||
const auto flags = MTPDinputMediaUploadedDocument::Flags(0)
|
||||
| (thumb
|
||||
? MTPDinputMediaUploadedDocument::Flag::f_thumb
|
||||
: MTPDinputMediaUploadedDocument::Flag(0))
|
||||
| (groupId
|
||||
? MTPDinputMediaUploadedDocument::Flag::f_nosound_video
|
||||
: MTPDinputMediaUploadedDocument::Flag(0));
|
||||
const auto media = MTP_inputMediaUploadedDocument(
|
||||
MTP_flags(flags),
|
||||
file,
|
||||
thumb ? *thumb : MTPInputFile(),
|
||||
MTP_string(document->mimeString()),
|
||||
ComposeSendingDocumentAttributes(document),
|
||||
MTPVector<MTPInputDocument>(),
|
||||
MTP_int(0));
|
||||
if (groupId) {
|
||||
uploadAlbumMedia(item, groupId, media);
|
||||
} else {
|
||||
sendMedia(item, media, options);
|
||||
}
|
||||
if (!item->media() || !item->media()->document()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ApiWrap::editUploadedFile(
|
||||
FullMsgId localId,
|
||||
const MTPInputFile &file,
|
||||
const std::optional<MTPInputFile> &thumb,
|
||||
Api::SendOptions options,
|
||||
bool isDocument) {
|
||||
const auto item = _session->data().message(localId);
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
if (!item->media()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto sentEntities = Api::EntitiesToMTP(
|
||||
_session,
|
||||
item->originalText().entities,
|
||||
Api::ConvertOption::SkipLocal);
|
||||
|
||||
auto flagsEditMsg = MTPmessages_EditMessage::Flag::f_message | 0;
|
||||
flagsEditMsg |= MTPmessages_EditMessage::Flag::f_no_webpage;
|
||||
flagsEditMsg |= MTPmessages_EditMessage::Flag::f_entities;
|
||||
flagsEditMsg |= MTPmessages_EditMessage::Flag::f_media;
|
||||
|
||||
const auto media = [&]() -> std::optional<MTPInputMedia> {
|
||||
if (!isDocument) {
|
||||
if (!item->media()->photo()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return MTP_inputMediaUploadedPhoto(
|
||||
MTP_flags(0),
|
||||
file,
|
||||
MTPVector<MTPInputDocument>(),
|
||||
MTP_int(0));
|
||||
}
|
||||
|
||||
const auto document = item->media()->document();
|
||||
if (!document) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const auto flags = MTPDinputMediaUploadedDocument::Flags(0)
|
||||
| (thumb
|
||||
? MTPDinputMediaUploadedDocument::Flag::f_thumb
|
||||
: MTPDinputMediaUploadedDocument::Flag(0))
|
||||
| (item->groupId()
|
||||
? MTPDinputMediaUploadedDocument::Flag::f_nosound_video
|
||||
: MTPDinputMediaUploadedDocument::Flag(0));
|
||||
return MTP_inputMediaUploadedDocument(
|
||||
MTP_flags(flags),
|
||||
file,
|
||||
thumb ? *thumb : MTPInputFile(),
|
||||
MTP_string(document->mimeString()),
|
||||
ComposeSendingDocumentAttributes(document),
|
||||
MTPVector<MTPInputDocument>(),
|
||||
MTP_int(0));
|
||||
}();
|
||||
|
||||
if (!media) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto peer = item->history()->peer;
|
||||
request(MTPmessages_EditMessage(
|
||||
MTP_flags(flagsEditMsg),
|
||||
peer->input,
|
||||
MTP_int(item->id),
|
||||
MTP_string(item->originalText().text),
|
||||
*media,
|
||||
MTPReplyMarkup(),
|
||||
sentEntities,
|
||||
MTP_int(0) // schedule_date
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
item->clearSavedMedia();
|
||||
item->setIsLocalUpdateMedia(true);
|
||||
applyUpdates(result);
|
||||
item->setIsLocalUpdateMedia(false);
|
||||
}).fail([=](const RPCError &error) {
|
||||
QString err = error.type();
|
||||
if (err == qstr("MESSAGE_NOT_MODIFIED")) {
|
||||
item->returnSavedMedia();
|
||||
_session->data().sendHistoryChangeNotifications();
|
||||
} else if (err == qstr("MEDIA_NEW_INVALID")) {
|
||||
item->returnSavedMedia();
|
||||
_session->data().sendHistoryChangeNotifications();
|
||||
Ui::show(
|
||||
Box<InformBox>(tr::lng_edit_media_invalid_file(tr::now)),
|
||||
Ui::LayerOption::KeepOther);
|
||||
const auto media = Api::PrepareUploadedDocument(item, file, thumb);
|
||||
const auto groupId = item->groupId();
|
||||
if (groupId) {
|
||||
uploadAlbumMedia(item, groupId, media);
|
||||
} else {
|
||||
sendMessageFail(error, peer);
|
||||
sendMedia(item, media, options);
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
}
|
||||
|
||||
void ApiWrap::cancelLocalItem(not_null<HistoryItem*> item) {
|
||||
@@ -5036,7 +4879,10 @@ void ApiWrap::photoUploadReady(
|
||||
};
|
||||
if (peer->isSelf()) {
|
||||
request(MTPphotos_UploadProfilePhoto(
|
||||
file
|
||||
MTP_flags(MTPphotos_UploadProfilePhoto::Flag::f_file),
|
||||
file,
|
||||
MTPInputFile(), // video
|
||||
MTPdouble() // video_start_ts
|
||||
)).done([=](const MTPphotos_Photo &result) {
|
||||
result.match([&](const MTPDphotos_photo &data) {
|
||||
_session->data().processPhoto(data.vphoto());
|
||||
@@ -5047,13 +4893,21 @@ void ApiWrap::photoUploadReady(
|
||||
const auto history = _session->data().history(chat);
|
||||
history->sendRequestId = request(MTPmessages_EditChatPhoto(
|
||||
chat->inputChat,
|
||||
MTP_inputChatUploadedPhoto(file)
|
||||
MTP_inputChatUploadedPhoto(
|
||||
MTP_flags(MTPDinputChatUploadedPhoto::Flag::f_file),
|
||||
file,
|
||||
MTPInputFile(), // video
|
||||
MTPdouble()) // video_start_ts
|
||||
)).done(applier).afterRequest(history->sendRequestId).send();
|
||||
} else if (const auto channel = peer->asChannel()) {
|
||||
const auto history = _session->data().history(channel);
|
||||
history->sendRequestId = request(MTPchannels_EditPhoto(
|
||||
channel->inputChannel,
|
||||
MTP_inputChatUploadedPhoto(file)
|
||||
MTP_inputChatUploadedPhoto(
|
||||
MTP_flags(MTPDinputChatUploadedPhoto::Flag::f_file),
|
||||
file,
|
||||
MTPInputFile(), // video
|
||||
MTPdouble()) // video_start_ts
|
||||
)).done(applier).afterRequest(history->sendRequestId).send();
|
||||
}
|
||||
}
|
||||
@@ -5064,8 +4918,8 @@ void ApiWrap::clearPeerPhoto(not_null<PhotoData*> photo) {
|
||||
if (self->userpicPhotoId() == photo->id) {
|
||||
request(MTPphotos_UpdateProfilePhoto(
|
||||
MTP_inputPhotoEmpty()
|
||||
)).done([=](const MTPUserProfilePhoto &result) {
|
||||
self->setPhoto(result);
|
||||
)).done([=](const MTPphotos_Photo &result) {
|
||||
self->setPhoto(MTP_userProfilePhotoEmpty());
|
||||
}).send();
|
||||
} else if (photo->peer && photo->peer->userpicPhotoId() == photo->id) {
|
||||
const auto applier = [=](const MTPUpdates &result) {
|
||||
@@ -5389,6 +5243,10 @@ Api::SensitiveContent &ApiWrap::sensitiveContent() {
|
||||
return *_sensitiveContent;
|
||||
}
|
||||
|
||||
Api::GlobalPrivacy &ApiWrap::globalPrivacy() {
|
||||
return *_globalPrivacy;
|
||||
}
|
||||
|
||||
void ApiWrap::createPoll(
|
||||
const PollData &data,
|
||||
const SendAction &action,
|
||||
@@ -5519,44 +5377,6 @@ void ApiWrap::closePoll(not_null<HistoryItem*> item) {
|
||||
_pollCloseRequestIds.emplace(itemId, requestId);
|
||||
}
|
||||
|
||||
void ApiWrap::rescheduleMessage(
|
||||
not_null<HistoryItem*> item,
|
||||
Api::SendOptions options) {
|
||||
const auto text = item->originalText().text;
|
||||
const auto sentEntities = Api::EntitiesToMTP(
|
||||
_session,
|
||||
item->originalText().entities,
|
||||
Api::ConvertOption::SkipLocal);
|
||||
const auto media = item->media();
|
||||
|
||||
const auto emptyFlag = MTPmessages_EditMessage::Flag(0);
|
||||
const auto flags = MTPmessages_EditMessage::Flag::f_schedule_date
|
||||
| (!text.isEmpty()
|
||||
? MTPmessages_EditMessage::Flag::f_message
|
||||
: emptyFlag)
|
||||
| ((!media || !media->webpage())
|
||||
? MTPmessages_EditMessage::Flag::f_no_webpage
|
||||
: emptyFlag)
|
||||
| (!sentEntities.v.isEmpty()
|
||||
? MTPmessages_EditMessage::Flag::f_entities
|
||||
: emptyFlag);
|
||||
|
||||
const auto id = _session->data().scheduledMessages().lookupId(item);
|
||||
request(MTPmessages_EditMessage(
|
||||
MTP_flags(flags),
|
||||
item->history()->peer->input,
|
||||
MTP_int(id),
|
||||
MTP_string(text),
|
||||
MTPInputMedia(),
|
||||
MTPReplyMarkup(),
|
||||
sentEntities,
|
||||
MTP_int(options.scheduled)
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
applyUpdates(result);
|
||||
}).fail([](const RPCError &error) {
|
||||
}).send();
|
||||
}
|
||||
|
||||
void ApiWrap::reloadPollResults(not_null<HistoryItem*> item) {
|
||||
const auto itemId = item->fullId();
|
||||
if (!IsServerMsgId(item->id)
|
||||
|
||||
@@ -50,6 +50,12 @@ struct CloudPasswordState;
|
||||
} // namespace Core
|
||||
|
||||
namespace Api {
|
||||
|
||||
class Updates;
|
||||
class SelfDestruct;
|
||||
class SensitiveContent;
|
||||
class GlobalPrivacy;
|
||||
|
||||
namespace details {
|
||||
|
||||
inline QString ToString(const QString &value) {
|
||||
@@ -66,8 +72,6 @@ inline QString ToString(uint64 value) {
|
||||
|
||||
} // namespace details
|
||||
|
||||
class Updates;
|
||||
|
||||
template <
|
||||
typename ...Types,
|
||||
typename = std::enable_if_t<(sizeof...(Types) > 0)>>
|
||||
@@ -86,9 +90,6 @@ QString RequestKey(Types &&...values) {
|
||||
return result;
|
||||
}
|
||||
|
||||
class SelfDestruct;
|
||||
class SensitiveContent;
|
||||
|
||||
} // namespace Api
|
||||
|
||||
class ApiWrap : public MTP::Sender, private base::Subscriber {
|
||||
@@ -422,12 +423,6 @@ public:
|
||||
const MTPInputFile &file,
|
||||
const std::optional<MTPInputFile> &thumb,
|
||||
Api::SendOptions options);
|
||||
void editUploadedFile(
|
||||
FullMsgId localId,
|
||||
const MTPInputFile &file,
|
||||
const std::optional<MTPInputFile> &thumb,
|
||||
Api::SendOptions options,
|
||||
bool isDocument);
|
||||
|
||||
void cancelLocalItem(not_null<HistoryItem*> item);
|
||||
|
||||
@@ -466,6 +461,7 @@ public:
|
||||
|
||||
[[nodiscard]] Api::SelfDestruct &selfDestruct();
|
||||
[[nodiscard]] Api::SensitiveContent &sensitiveContent();
|
||||
[[nodiscard]] Api::GlobalPrivacy &globalPrivacy();
|
||||
|
||||
void createPoll(
|
||||
const PollData &data,
|
||||
@@ -478,10 +474,6 @@ public:
|
||||
void closePoll(not_null<HistoryItem*> item);
|
||||
void reloadPollResults(not_null<HistoryItem*> item);
|
||||
|
||||
void rescheduleMessage(
|
||||
not_null<HistoryItem*> item,
|
||||
Api::SendOptions options);
|
||||
|
||||
private:
|
||||
struct MessageDataRequest {
|
||||
using Callbacks = QList<RequestMessageDataCallback>;
|
||||
@@ -831,6 +823,7 @@ private:
|
||||
|
||||
const std::unique_ptr<Api::SelfDestruct> _selfDestruct;
|
||||
const std::unique_ptr<Api::SensitiveContent> _sensitiveContent;
|
||||
const std::unique_ptr<Api::GlobalPrivacy> _globalPrivacy;
|
||||
|
||||
base::flat_map<FullMsgId, mtpRequestId> _pollVotesRequestIds;
|
||||
base::flat_map<FullMsgId, mtpRequestId> _pollCloseRequestIds;
|
||||
|
||||
@@ -94,7 +94,6 @@ confirmInviteTitle: FlatLabel(defaultFlatLabel) {
|
||||
confirmInviteStatus: FlatLabel(boxLabel) {
|
||||
align: align(center);
|
||||
minWidth: 320px;
|
||||
maxHeight: 20px;
|
||||
textFg: windowSubTextFg;
|
||||
}
|
||||
confirmInviteTitleTop: 106px;
|
||||
|
||||
@@ -861,146 +861,6 @@ void DeleteMessagesBox::deleteAndClear() {
|
||||
session->data().sendHistoryChangeNotifications();
|
||||
}
|
||||
|
||||
ConfirmInviteBox::ConfirmInviteBox(
|
||||
QWidget*,
|
||||
not_null<Main::Session*> session,
|
||||
const MTPDchatInvite &data,
|
||||
Fn<void()> submit)
|
||||
: _session(session)
|
||||
, _submit(std::move(submit))
|
||||
, _title(this, st::confirmInviteTitle)
|
||||
, _status(this, st::confirmInviteStatus)
|
||||
, _participants(GetParticipants(_session, data))
|
||||
, _isChannel(data.is_channel() && !data.is_megagroup()) {
|
||||
const auto title = qs(data.vtitle());
|
||||
const auto count = data.vparticipants_count().v;
|
||||
const auto status = [&] {
|
||||
return (!_participants.empty() && _participants.size() < count)
|
||||
? tr::lng_group_invite_members(tr::now, lt_count, count)
|
||||
: (count > 0)
|
||||
? tr::lng_chat_status_members(tr::now, lt_count_decimal, count)
|
||||
: _isChannel
|
||||
? tr::lng_channel_status(tr::now)
|
||||
: tr::lng_group_status(tr::now);
|
||||
}();
|
||||
_title->setText(title);
|
||||
_status->setText(status);
|
||||
|
||||
const auto photo = _session->data().processPhoto(data.vphoto());
|
||||
if (!photo->isNull()) {
|
||||
_photo = photo->createMediaView();
|
||||
_photo->wanted(Data::PhotoSize::Small, Data::FileOrigin());
|
||||
if (!_photo->image(Data::PhotoSize::Small)) {
|
||||
_session->downloaderTaskFinished(
|
||||
) | rpl::start_with_next([=] {
|
||||
update();
|
||||
}, lifetime());
|
||||
}
|
||||
} else {
|
||||
_photoEmpty = std::make_unique<Ui::EmptyUserpic>(
|
||||
Data::PeerUserpicColor(0),
|
||||
title);
|
||||
}
|
||||
}
|
||||
|
||||
auto ConfirmInviteBox::GetParticipants(
|
||||
not_null<Main::Session*> session,
|
||||
const MTPDchatInvite &data)
|
||||
-> std::vector<Participant> {
|
||||
const auto participants = data.vparticipants();
|
||||
if (!participants) {
|
||||
return {};
|
||||
}
|
||||
const auto &v = participants->v;
|
||||
auto result = std::vector<Participant>();
|
||||
result.reserve(v.size());
|
||||
for (const auto &participant : v) {
|
||||
if (const auto user = session->data().processUser(participant)) {
|
||||
result.push_back(Participant{ user });
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void ConfirmInviteBox::prepare() {
|
||||
addButton(
|
||||
(_isChannel
|
||||
? tr::lng_profile_join_channel()
|
||||
: tr::lng_profile_join_group()),
|
||||
_submit);
|
||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||
|
||||
while (_participants.size() > 4) {
|
||||
_participants.pop_back();
|
||||
}
|
||||
|
||||
auto newHeight = st::confirmInviteStatusTop + _status->height() + st::boxPadding.bottom();
|
||||
if (!_participants.empty()) {
|
||||
int skip = (st::boxWideWidth - 4 * st::confirmInviteUserPhotoSize) / 5;
|
||||
int padding = skip / 2;
|
||||
_userWidth = (st::confirmInviteUserPhotoSize + 2 * padding);
|
||||
int sumWidth = _participants.size() * _userWidth;
|
||||
int left = (st::boxWideWidth - sumWidth) / 2;
|
||||
for (const auto &participant : _participants) {
|
||||
auto name = new Ui::FlatLabel(this, st::confirmInviteUserName);
|
||||
name->resizeToWidth(st::confirmInviteUserPhotoSize + padding);
|
||||
name->setText(participant.user->firstName.isEmpty()
|
||||
? participant.user->name
|
||||
: participant.user->firstName);
|
||||
name->moveToLeft(left + (padding / 2), st::confirmInviteUserNameTop);
|
||||
left += _userWidth;
|
||||
}
|
||||
|
||||
newHeight += st::confirmInviteUserHeight;
|
||||
}
|
||||
setDimensions(st::boxWideWidth, newHeight);
|
||||
}
|
||||
|
||||
void ConfirmInviteBox::resizeEvent(QResizeEvent *e) {
|
||||
BoxContent::resizeEvent(e);
|
||||
_title->move((width() - _title->width()) / 2, st::confirmInviteTitleTop);
|
||||
_status->move((width() - _status->width()) / 2, st::confirmInviteStatusTop);
|
||||
}
|
||||
|
||||
void ConfirmInviteBox::paintEvent(QPaintEvent *e) {
|
||||
BoxContent::paintEvent(e);
|
||||
|
||||
Painter p(this);
|
||||
|
||||
if (_photo) {
|
||||
if (const auto image = _photo->image(Data::PhotoSize::Small)) {
|
||||
p.drawPixmap(
|
||||
(width() - st::confirmInvitePhotoSize) / 2,
|
||||
st::confirmInvitePhotoTop,
|
||||
image->pixCircled(
|
||||
st::confirmInvitePhotoSize,
|
||||
st::confirmInvitePhotoSize));
|
||||
}
|
||||
} else if (_photoEmpty) {
|
||||
_photoEmpty->paint(
|
||||
p,
|
||||
(width() - st::confirmInvitePhotoSize) / 2,
|
||||
st::confirmInvitePhotoTop,
|
||||
width(),
|
||||
st::confirmInvitePhotoSize);
|
||||
}
|
||||
|
||||
int sumWidth = _participants.size() * _userWidth;
|
||||
int left = (width() - sumWidth) / 2;
|
||||
for (auto &participant : _participants) {
|
||||
participant.user->paintUserpicLeft(
|
||||
p,
|
||||
participant.userpic,
|
||||
left + (_userWidth - st::confirmInviteUserPhotoSize) / 2,
|
||||
st::confirmInviteUserPhotoTop,
|
||||
width(),
|
||||
st::confirmInviteUserPhotoSize);
|
||||
left += _userWidth;
|
||||
}
|
||||
}
|
||||
|
||||
ConfirmInviteBox::~ConfirmInviteBox() = default;
|
||||
|
||||
ConfirmDontWarnBox::ConfirmDontWarnBox(
|
||||
QWidget*,
|
||||
rpl::producer<TextWithEntities> text,
|
||||
|
||||
@@ -206,46 +206,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class ConfirmInviteBox final
|
||||
: public Ui::BoxContent
|
||||
, private base::Subscriber {
|
||||
public:
|
||||
ConfirmInviteBox(
|
||||
QWidget*,
|
||||
not_null<Main::Session*> session,
|
||||
const MTPDchatInvite &data,
|
||||
Fn<void()> submit);
|
||||
~ConfirmInviteBox();
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
private:
|
||||
struct Participant {
|
||||
not_null<UserData*> user;
|
||||
std::shared_ptr<Data::CloudImageView> userpic;
|
||||
};
|
||||
static std::vector<Participant> GetParticipants(
|
||||
not_null<Main::Session*> session,
|
||||
const MTPDchatInvite &data);
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
|
||||
Fn<void()> _submit;
|
||||
object_ptr<Ui::FlatLabel> _title;
|
||||
object_ptr<Ui::FlatLabel> _status;
|
||||
std::shared_ptr<Data::PhotoMedia> _photo;
|
||||
std::unique_ptr<Ui::EmptyUserpic> _photoEmpty;
|
||||
std::vector<Participant> _participants;
|
||||
bool _isChannel = false;
|
||||
|
||||
int _userWidth = 0;
|
||||
|
||||
};
|
||||
|
||||
class ConfirmDontWarnBox : public Ui::BoxContent {
|
||||
public:
|
||||
ConfirmDontWarnBox(
|
||||
|
||||
@@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "core/core_settings.h"
|
||||
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||
#include "chat_helpers/message_field.h"
|
||||
#include "chat_helpers/send_context_menu.h"
|
||||
#include "history/view/history_view_schedule_box.h"
|
||||
#include "settings/settings_common.h"
|
||||
#include "base/unique_qptr.h"
|
||||
@@ -1058,19 +1059,19 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
||||
*error &= ~Error::Solution;
|
||||
}
|
||||
};
|
||||
const auto showError = [=](const QString &text) {
|
||||
Ui::Toast::Show(text);
|
||||
const auto showError = [](tr::phrase<> text) {
|
||||
Ui::Toast::Show(text(tr::now));
|
||||
};
|
||||
const auto send = [=](Api::SendOptions sendOptions) {
|
||||
collectError();
|
||||
if (*error & Error::Question) {
|
||||
showError(tr::lng_polls_choose_question(tr::now));
|
||||
showError(tr::lng_polls_choose_question);
|
||||
question->setFocus();
|
||||
} else if (*error & Error::Options) {
|
||||
showError(tr::lng_polls_choose_answers(tr::now));
|
||||
showError(tr::lng_polls_choose_answers);
|
||||
options->focusFirst();
|
||||
} else if (*error & Error::Correct) {
|
||||
showError(tr::lng_polls_choose_correct(tr::now));
|
||||
showError(tr::lng_polls_choose_correct);
|
||||
} else if (*error & Error::Solution) {
|
||||
solution->showError();
|
||||
} else if (!*error) {
|
||||
@@ -1078,15 +1079,13 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
||||
}
|
||||
};
|
||||
const auto sendSilent = [=] {
|
||||
auto options = Api::SendOptions();
|
||||
options.silent = true;
|
||||
send(options);
|
||||
send({ .silent = true });
|
||||
};
|
||||
const auto sendScheduled = [=] {
|
||||
Ui::show(
|
||||
HistoryView::PrepareScheduleBox(
|
||||
this,
|
||||
SendMenuType::Scheduled,
|
||||
SendMenu::Type::Scheduled,
|
||||
send),
|
||||
Ui::LayerOption::KeepOther);
|
||||
};
|
||||
@@ -1101,15 +1100,22 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
||||
FocusAtEnd(question);
|
||||
}, lifetime());
|
||||
|
||||
const auto isNormal = (_sendType == Api::SendType::Normal);
|
||||
const auto isScheduled = (_sendType == Api::SendType::Scheduled);
|
||||
|
||||
const auto submit = addButton(
|
||||
tr::lng_polls_create_button(),
|
||||
[=] { send({}); });
|
||||
if (_sendType == Api::SendType::Normal) {
|
||||
isNormal
|
||||
? tr::lng_polls_create_button()
|
||||
: tr::lng_schedule_button(),
|
||||
[=] { isNormal ? send({}) : sendScheduled(); });
|
||||
if (isNormal || isScheduled) {
|
||||
const auto sendMenuType = [=] {
|
||||
collectError();
|
||||
return *error ? SendMenuType::Disabled : SendMenuType::Scheduled;
|
||||
return (*error || isScheduled)
|
||||
? SendMenu::Type::Disabled
|
||||
: SendMenu::Type::Scheduled;
|
||||
};
|
||||
SetupSendMenuAndShortcuts(
|
||||
SendMenu::SetupMenuAndShortcuts(
|
||||
submit.data(),
|
||||
sendMenuType,
|
||||
sendSilent,
|
||||
|
||||
@@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "boxes/edit_caption_box.h"
|
||||
|
||||
#include "apiwrap.h"
|
||||
#include "api/api_editing.h"
|
||||
#include "api/api_text_entities.h"
|
||||
#include "main/main_session.h"
|
||||
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||
@@ -29,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_photo_media.h"
|
||||
#include "data/data_document_media.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_drag_area.h"
|
||||
#include "history/history_item.h"
|
||||
#include "platform/platform_specific.h"
|
||||
#include "lang/lang_keys.h"
|
||||
@@ -37,6 +39,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "media/streaming/media_streaming_player.h"
|
||||
#include "media/streaming/media_streaming_document.h"
|
||||
#include "media/streaming/media_streaming_loader_local.h"
|
||||
#include "platform/platform_file_utilities.h"
|
||||
#include "storage/localimageloader.h"
|
||||
#include "storage/storage_media_prepare.h"
|
||||
#include "mtproto/mtproto_config.h"
|
||||
@@ -63,6 +66,31 @@ namespace {
|
||||
using namespace ::Media::Streaming;
|
||||
using Data::PhotoSize;
|
||||
|
||||
auto ListFromMimeData(not_null<const QMimeData*> data) {
|
||||
using Error = Storage::PreparedList::Error;
|
||||
auto result = data->hasUrls()
|
||||
? Storage::PrepareMediaList(
|
||||
// When we edit media, we need only 1 file.
|
||||
data->urls().mid(0, 1),
|
||||
st::sendMediaPreviewSize)
|
||||
: Storage::PreparedList(Error::EmptyFile, QString());
|
||||
if (result.error == Error::None) {
|
||||
return result;
|
||||
} else if (data->hasImage()) {
|
||||
auto image = Platform::GetImageFromClipboard();
|
||||
if (image.isNull()) {
|
||||
image = qvariant_cast<QImage>(data->imageData());
|
||||
}
|
||||
if (!image.isNull()) {
|
||||
return Storage::PrepareMediaFromImage(
|
||||
std::move(image),
|
||||
QByteArray(),
|
||||
st::sendMediaPreviewSize);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
EditCaptionBox::EditCaptionBox(
|
||||
@@ -70,7 +98,6 @@ EditCaptionBox::EditCaptionBox(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<HistoryItem*> item)
|
||||
: _controller(controller)
|
||||
, _api(&controller->session().mtp())
|
||||
, _msgId(item->fullId()) {
|
||||
Expects(item->media() != nullptr);
|
||||
Expects(item->media()->allowsEditCaption());
|
||||
@@ -617,12 +644,8 @@ void EditCaptionBox::prepare() {
|
||||
if (action == Ui::InputField::MimeAction::Check) {
|
||||
if (!data->hasText() && !_isAllowedEditMedia) {
|
||||
return false;
|
||||
} else if (data->hasImage()) {
|
||||
} else if (Storage::ValidateDragData(data, _isAlbum)) {
|
||||
return true;
|
||||
} else if (const auto urls = data->urls(); !urls.empty()) {
|
||||
if (ranges::all_of(urls, &QUrl::isLocalFile)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return data->hasText();
|
||||
} else if (action == Ui::InputField::MimeAction::Insert) {
|
||||
@@ -640,6 +663,8 @@ void EditCaptionBox::prepare() {
|
||||
auto cursor = _field->textCursor();
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
_field->setTextCursor(cursor);
|
||||
|
||||
setupDragArea();
|
||||
}
|
||||
|
||||
bool EditCaptionBox::fileFromClipboard(not_null<const QMimeData*> data) {
|
||||
@@ -647,50 +672,34 @@ bool EditCaptionBox::fileFromClipboard(not_null<const QMimeData*> data) {
|
||||
return false;
|
||||
}
|
||||
using Error = Storage::PreparedList::Error;
|
||||
using AlbumType = Storage::PreparedFile::AlbumType;
|
||||
auto list = ListFromMimeData(data);
|
||||
|
||||
auto list = [&] {
|
||||
auto url = QList<QUrl>();
|
||||
auto canAddUrl = false;
|
||||
// When we edit media, we need only 1 file.
|
||||
if (data->hasUrls()) {
|
||||
const auto first = data->urls().front();
|
||||
url.push_front(first);
|
||||
canAddUrl = first.isLocalFile();
|
||||
}
|
||||
auto result = canAddUrl
|
||||
? Storage::PrepareMediaList(url, st::sendMediaPreviewSize)
|
||||
: Storage::PreparedList(
|
||||
Error::EmptyFile,
|
||||
QString());
|
||||
if (result.error == Error::None) {
|
||||
return result;
|
||||
} else if (data->hasImage()) {
|
||||
auto image = Platform::GetImageFromClipboard();
|
||||
if (image.isNull()) {
|
||||
image = qvariant_cast<QImage>(data->imageData());
|
||||
}
|
||||
if (!image.isNull()) {
|
||||
_isImage = true;
|
||||
_photo = true;
|
||||
return Storage::PrepareMediaFromImage(
|
||||
std::move(image),
|
||||
QByteArray(),
|
||||
st::sendMediaPreviewSize);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}();
|
||||
if (list.error != Error::None || list.files.empty()) {
|
||||
return false;
|
||||
}
|
||||
if (list.files.front().type == Storage::PreparedFile::AlbumType::None
|
||||
&& _isAlbum) {
|
||||
Ui::show(
|
||||
Box<InformBox>(tr::lng_edit_media_album_error(tr::now)),
|
||||
Ui::LayerOption::KeepOther);
|
||||
|
||||
const auto file = &list.files.front();
|
||||
if (_isAlbum && (file->type == AlbumType::None)) {
|
||||
const auto imageAsDoc = [&] {
|
||||
using Info = FileMediaInformation;
|
||||
const auto fileMedia = &file->information->media;
|
||||
if (const auto image = base::get_if<Info::Image>(fileMedia)) {
|
||||
return !Storage::ValidateThumbDimensions(
|
||||
image->data.width(),
|
||||
image->data.height());
|
||||
}
|
||||
return false;
|
||||
}();
|
||||
|
||||
if (!data->hasText() || imageAsDoc) {
|
||||
Ui::show(
|
||||
Box<InformBox>(tr::lng_edit_media_album_error(tr::now)),
|
||||
Ui::LayerOption::KeepOther);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
_photo = _isImage = (file->type == AlbumType::Photo);
|
||||
_preparedList = std::move(list);
|
||||
updateEditPreview();
|
||||
return true;
|
||||
@@ -735,6 +744,37 @@ void EditCaptionBox::setupEmojiPanel() {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void EditCaptionBox::setupDragArea() {
|
||||
auto enterFilter = [=](not_null<const QMimeData*> data) {
|
||||
return !_isAllowedEditMedia
|
||||
? false
|
||||
: Storage::ValidateDragData(data, _isAlbum);
|
||||
};
|
||||
// Avoid both drag areas appearing at one time.
|
||||
auto computeState = [=](const QMimeData *data) {
|
||||
const auto state = Storage::ComputeMimeDataState(data);
|
||||
return (state == Storage::MimeDataState::PhotoFiles)
|
||||
? Storage::MimeDataState::Image
|
||||
: state;
|
||||
};
|
||||
const auto areas = DragArea::SetupDragAreaToContainer(
|
||||
this,
|
||||
std::move(enterFilter),
|
||||
[=](bool f) { _field->setAcceptDrops(f); },
|
||||
nullptr,
|
||||
std::move(computeState));
|
||||
|
||||
const auto droppedCallback = [=](bool compress) {
|
||||
return [=](const QMimeData *data) {
|
||||
fileFromClipboard(data);
|
||||
Window::ActivateWindow(_controller);
|
||||
};
|
||||
};
|
||||
areas.document->setDroppedCallback(droppedCallback(false));
|
||||
areas.photo->setDroppedCallback(droppedCallback(true));
|
||||
}
|
||||
|
||||
void EditCaptionBox::updateBoxSize() {
|
||||
auto newHeight = st::boxPhotoPadding.top() + st::boxPhotoCaptionSkip + _field->height() + errorTopSkip() + st::normalFont->height;
|
||||
if (_photo) {
|
||||
@@ -759,8 +799,7 @@ int EditCaptionBox::errorTopSkip() const {
|
||||
void EditCaptionBox::checkStreamedIsStarted() {
|
||||
if (!_streamed) {
|
||||
return;
|
||||
}
|
||||
if (_streamed->paused()) {
|
||||
} else if (_streamed->paused()) {
|
||||
_streamed->resume();
|
||||
}
|
||||
if (!_streamed->active() && !_streamed->failed()) {
|
||||
@@ -930,88 +969,60 @@ void EditCaptionBox::save() {
|
||||
return;
|
||||
}
|
||||
|
||||
auto flags = MTPmessages_EditMessage::Flag::f_message | 0;
|
||||
if (_previewCancelled) {
|
||||
flags |= MTPmessages_EditMessage::Flag::f_no_webpage;
|
||||
}
|
||||
const auto textWithTags = _field->getTextWithAppliedMarkdown();
|
||||
auto sending = TextWithEntities{
|
||||
const auto sending = TextWithEntities{
|
||||
textWithTags.text,
|
||||
TextUtilities::ConvertTextTagsToEntities(textWithTags.tags)
|
||||
};
|
||||
const auto prepareFlags = Ui::ItemTextOptions(
|
||||
item->history(),
|
||||
_controller->session().user()).flags;
|
||||
TextUtilities::PrepareForSending(sending, prepareFlags);
|
||||
TextUtilities::Trim(sending);
|
||||
|
||||
const auto sentEntities = Api::EntitiesToMTP(
|
||||
&item->history()->session(),
|
||||
sending.entities,
|
||||
Api::ConvertOption::SkipLocal);
|
||||
if (!sentEntities.v.isEmpty()) {
|
||||
flags |= MTPmessages_EditMessage::Flag::f_entities;
|
||||
}
|
||||
auto options = Api::SendOptions();
|
||||
options.scheduled = item->isScheduled() ? item->date() : 0;
|
||||
|
||||
if (!_preparedList.files.empty()) {
|
||||
const auto textWithTags = _field->getTextWithAppliedMarkdown();
|
||||
auto sending = TextWithEntities{
|
||||
textWithTags.text,
|
||||
TextUtilities::ConvertTextTagsToEntities(textWithTags.tags)
|
||||
};
|
||||
item->setText(sending);
|
||||
auto action = Api::SendAction(item->history());
|
||||
action.options = options;
|
||||
|
||||
_controller->session().api().editMedia(
|
||||
std::move(_preparedList),
|
||||
(!_asFile && _photo) ? SendMediaType::Photo : SendMediaType::File,
|
||||
_field->getTextWithAppliedMarkdown(),
|
||||
Api::SendAction(item->history()),
|
||||
action,
|
||||
item->fullId().msg);
|
||||
closeBox();
|
||||
return;
|
||||
}
|
||||
|
||||
_saveRequestId = _api.request(MTPmessages_EditMessage(
|
||||
MTP_flags(flags),
|
||||
item->history()->peer->input,
|
||||
MTP_int(item->id),
|
||||
MTP_string(sending.text),
|
||||
MTPInputMedia(),
|
||||
MTPReplyMarkup(),
|
||||
sentEntities,
|
||||
MTP_int(0)
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
saveDone(result);
|
||||
}).fail([=](const RPCError &error) {
|
||||
saveFail(error);
|
||||
}).send();
|
||||
}
|
||||
|
||||
void EditCaptionBox::saveDone(const MTPUpdates &updates) {
|
||||
_saveRequestId = 0;
|
||||
const auto controller = _controller;
|
||||
closeBox();
|
||||
controller->session().api().applyUpdates(updates);
|
||||
}
|
||||
|
||||
void EditCaptionBox::saveFail(const RPCError &error) {
|
||||
_saveRequestId = 0;
|
||||
const auto &type = error.type();
|
||||
if (type == qstr("MESSAGE_ID_INVALID")
|
||||
|| type == qstr("CHAT_ADMIN_REQUIRED")
|
||||
|| type == qstr("MESSAGE_EDIT_TIME_EXPIRED")) {
|
||||
_error = tr::lng_edit_error(tr::now);
|
||||
update();
|
||||
} else if (type == qstr("MESSAGE_NOT_MODIFIED")) {
|
||||
const auto done = crl::guard(this, [=](const MTPUpdates &updates) {
|
||||
_saveRequestId = 0;
|
||||
closeBox();
|
||||
} else if (type == qstr("MESSAGE_EMPTY")) {
|
||||
_field->setFocus();
|
||||
_field->showError();
|
||||
update();
|
||||
} else {
|
||||
_error = tr::lng_edit_error(tr::now);
|
||||
update();
|
||||
}
|
||||
});
|
||||
|
||||
const auto fail = crl::guard(this, [=](const RPCError &error) {
|
||||
_saveRequestId = 0;
|
||||
const auto &type = error.type();
|
||||
if (ranges::contains(Api::kDefaultEditMessagesErrors, type)) {
|
||||
_error = tr::lng_edit_error(tr::now);
|
||||
update();
|
||||
} else if (type == u"MESSAGE_NOT_MODIFIED"_q) {
|
||||
closeBox();
|
||||
} else if (type == u"MESSAGE_EMPTY"_q) {
|
||||
_field->setFocus();
|
||||
_field->showError();
|
||||
update();
|
||||
} else {
|
||||
_error = tr::lng_edit_error(tr::now);
|
||||
update();
|
||||
}
|
||||
});
|
||||
|
||||
lifetime().add([=] {
|
||||
if (_saveRequestId) {
|
||||
auto &session = _controller->session();
|
||||
session.api().request(base::take(_saveRequestId)).cancel();
|
||||
}
|
||||
});
|
||||
|
||||
_saveRequestId = Api::EditCaption(item, sending, options, done, fail);
|
||||
}
|
||||
|
||||
void EditCaptionBox::setName(QString nameString, qint64 size) {
|
||||
|
||||
@@ -10,7 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "storage/storage_media_prepare.h"
|
||||
#include "ui/wrap/slide_wrap.h"
|
||||
#include "mtproto/sender.h"
|
||||
|
||||
class Image;
|
||||
|
||||
@@ -80,12 +79,11 @@ private:
|
||||
void updateEmojiPanelGeometry();
|
||||
void emojiFilterForGeometry(not_null<QEvent*> event);
|
||||
|
||||
void setupDragArea();
|
||||
|
||||
void save();
|
||||
void captionResized();
|
||||
|
||||
void saveDone(const MTPUpdates &updates);
|
||||
void saveFail(const RPCError &error);
|
||||
|
||||
void setName(QString nameString, qint64 size);
|
||||
bool fileFromClipboard(not_null<const QMimeData*> data);
|
||||
void updateEditPreview();
|
||||
@@ -102,7 +100,6 @@ private:
|
||||
}
|
||||
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
MTP::Sender _api;
|
||||
|
||||
FullMsgId _msgId;
|
||||
std::shared_ptr<Data::PhotoMedia> _photoMedia;
|
||||
@@ -135,7 +132,6 @@ private:
|
||||
|
||||
Storage::PreparedList _preparedList;
|
||||
|
||||
bool _previewCancelled = false;
|
||||
mtpRequestId _saveRequestId = 0;
|
||||
|
||||
object_ptr<Ui::IconButton> _editMedia = nullptr;
|
||||
|
||||
@@ -15,10 +15,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "main/main_session.h"
|
||||
#include "mtproto/mtproto_config.h"
|
||||
#include "chat_helpers/message_field.h"
|
||||
#include "chat_helpers/send_context_menu.h"
|
||||
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||
#include "chat_helpers/tabbed_panel.h"
|
||||
#include "chat_helpers/tabbed_selector.h"
|
||||
#include "confirm_box.h"
|
||||
#include "history/history_drag_area.h"
|
||||
#include "history/view/history_view_schedule_box.h"
|
||||
#include "core/file_utilities.h"
|
||||
#include "core/mime_type.h"
|
||||
@@ -333,7 +335,7 @@ AlbumThumb::AlbumThumb(
|
||||
- st::sendMediaFileThumbSize
|
||||
// Right buttons.
|
||||
- st::sendBoxAlbumGroupButtonFile.width * 2
|
||||
- st::sendBoxAlbumGroupEditInternalSkip
|
||||
- st::sendBoxAlbumGroupEditInternalSkip * 2
|
||||
- st::sendBoxAlbumGroupSkipRight;
|
||||
const auto filepath = file.path;
|
||||
if (filepath.isEmpty()) {
|
||||
@@ -1665,7 +1667,7 @@ SendFilesBox::SendFilesBox(
|
||||
CompressConfirm compressed,
|
||||
SendLimit limit,
|
||||
Api::SendType sendType,
|
||||
SendMenuType sendMenuType)
|
||||
SendMenu::Type sendMenuType)
|
||||
: _controller(controller)
|
||||
, _sendType(sendType)
|
||||
, _list(std::move(list))
|
||||
@@ -1835,7 +1837,7 @@ void SendFilesBox::setupShadows(
|
||||
void SendFilesBox::prepare() {
|
||||
_send = addButton(tr::lng_send_button(), [=] { send({}); });
|
||||
if (_sendType == Api::SendType::Normal) {
|
||||
SetupSendMenuAndShortcuts(
|
||||
SendMenu::SetupMenuAndShortcuts(
|
||||
_send,
|
||||
[=] { return _sendMenuType; },
|
||||
[=] { sendSilent(); },
|
||||
@@ -1858,6 +1860,41 @@ void SendFilesBox::prepare() {
|
||||
}));
|
||||
|
||||
updateLeftButtonVisibility();
|
||||
setupDragArea();
|
||||
}
|
||||
|
||||
void SendFilesBox::setupDragArea() {
|
||||
// Avoid both drag areas appearing at one time.
|
||||
auto computeState = [=](const QMimeData *data) {
|
||||
using DragState = Storage::MimeDataState;
|
||||
const auto state = Storage::ComputeMimeDataState(data);
|
||||
return (state == DragState::PhotoFiles)
|
||||
? DragState::Image
|
||||
: (state == DragState::Files
|
||||
&& !Storage::ValidateDragData(data, true))
|
||||
? DragState::None
|
||||
: state;
|
||||
};
|
||||
const auto areas = DragArea::SetupDragAreaToContainer(
|
||||
this,
|
||||
[=](not_null<const QMimeData*> d) { return canAddFiles(d); },
|
||||
[=](bool f) { _caption->setAcceptDrops(f); },
|
||||
[=] { updateControlsGeometry(); },
|
||||
std::move(computeState));
|
||||
|
||||
const auto droppedCallback = [=](bool compress) {
|
||||
return [=](const QMimeData *data) {
|
||||
addFiles(data);
|
||||
Window::ActivateWindow(_controller);
|
||||
};
|
||||
};
|
||||
areas.document->setDroppedCallback(droppedCallback(false));
|
||||
areas.photo->setDroppedCallback(droppedCallback(true));
|
||||
_albumChanged.events(
|
||||
) | rpl::start_with_next([=] {
|
||||
areas.document->raise();
|
||||
areas.photo->raise();
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
void SendFilesBox::updateLeftButtonVisibility() {
|
||||
@@ -1875,6 +1912,7 @@ void SendFilesBox::refreshAllAfterAlbumChanges() {
|
||||
preparePreview();
|
||||
captionResized();
|
||||
updateLeftButtonVisibility();
|
||||
_albumChanged.fire({});
|
||||
}
|
||||
|
||||
void SendFilesBox::openDialogToAddFileToAlbum() {
|
||||
@@ -2380,7 +2418,7 @@ void SendFilesBox::sendSilent() {
|
||||
|
||||
void SendFilesBox::sendScheduled() {
|
||||
const auto type = (_sendType == Api::SendType::ScheduledToUser)
|
||||
? SendMenuType::ScheduledToUser
|
||||
? SendMenu::Type::ScheduledToUser
|
||||
: _sendMenuType;
|
||||
const auto callback = [=](Api::SendOptions options) { send(options); };
|
||||
Ui::show(
|
||||
|
||||
@@ -40,7 +40,9 @@ namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
enum class SendMenuType;
|
||||
namespace SendMenu {
|
||||
enum class Type;
|
||||
} // namespace SendMenu
|
||||
|
||||
enum class SendFilesWay {
|
||||
Album,
|
||||
@@ -62,7 +64,7 @@ public:
|
||||
CompressConfirm compressed,
|
||||
SendLimit limit,
|
||||
Api::SendType sendType,
|
||||
SendMenuType sendMenuType);
|
||||
SendMenu::Type sendMenuType);
|
||||
|
||||
void setConfirmedCallback(
|
||||
Fn<void(
|
||||
@@ -115,6 +117,7 @@ private:
|
||||
void sendScheduled();
|
||||
void captionResized();
|
||||
|
||||
void setupDragArea();
|
||||
void setupTitleText();
|
||||
void updateBoxSize();
|
||||
void updateControlsGeometry();
|
||||
@@ -141,7 +144,7 @@ private:
|
||||
CompressConfirm _compressConfirmInitial = CompressConfirm::None;
|
||||
CompressConfirm _compressConfirm = CompressConfirm::None;
|
||||
SendLimit _sendLimit = SendLimit::Many;
|
||||
SendMenuType _sendMenuType = SendMenuType();
|
||||
SendMenu::Type _sendMenuType = SendMenu::Type();
|
||||
|
||||
Fn<void(
|
||||
Storage::PreparedList &&list,
|
||||
@@ -163,6 +166,7 @@ private:
|
||||
std::shared_ptr<Ui::RadioenumGroup<SendFilesWay>> _sendWay;
|
||||
|
||||
rpl::variable<int> _footerHeight = 0;
|
||||
rpl::event_stream<> _albumChanged;
|
||||
|
||||
QWidget *_preview = nullptr;
|
||||
AlbumPreview *_albumPreview = nullptr;
|
||||
|
||||
@@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/wrap/slide_wrap.h"
|
||||
#include "ui/text_options.h"
|
||||
#include "chat_helpers/message_field.h"
|
||||
#include "chat_helpers/send_context_menu.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_message.h"
|
||||
#include "history/view/history_view_schedule_box.h"
|
||||
@@ -408,13 +409,13 @@ void ShareBox::keyPressEvent(QKeyEvent *e) {
|
||||
}
|
||||
}
|
||||
|
||||
SendMenuType ShareBox::sendMenuType() const {
|
||||
SendMenu::Type ShareBox::sendMenuType() const {
|
||||
const auto selected = _inner->selected();
|
||||
return ranges::all_of(selected, HistoryView::CanScheduleUntilOnline)
|
||||
? SendMenuType::ScheduledToUser
|
||||
? SendMenu::Type::ScheduledToUser
|
||||
: (selected.size() == 1 && selected.front()->isSelf())
|
||||
? SendMenuType::Reminder
|
||||
: SendMenuType::Scheduled;
|
||||
? SendMenu::Type::Reminder
|
||||
: SendMenu::Type::Scheduled;
|
||||
}
|
||||
|
||||
void ShareBox::createButtons() {
|
||||
@@ -423,7 +424,7 @@ void ShareBox::createButtons() {
|
||||
const auto send = addButton(tr::lng_share_confirm(), [=] {
|
||||
submit({});
|
||||
});
|
||||
SetupSendMenuAndShortcuts(
|
||||
SendMenu::SetupMenuAndShortcuts(
|
||||
send,
|
||||
[=] { return sendMenuType(); },
|
||||
[=] { submitSilent(); },
|
||||
|
||||
@@ -14,7 +14,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/effects/round_checkbox.h"
|
||||
#include "mtproto/sender.h"
|
||||
|
||||
enum class SendMenuType;
|
||||
namespace SendMenu {
|
||||
enum class Type;
|
||||
} // namespace SendMenu
|
||||
|
||||
namespace Window {
|
||||
class SessionNavigation;
|
||||
@@ -82,7 +84,7 @@ private:
|
||||
void copyLink();
|
||||
bool searchByUsername(bool useCache = false);
|
||||
|
||||
SendMenuType sendMenuType() const;
|
||||
SendMenu::Type sendMenuType() const;
|
||||
|
||||
void scrollTo(Ui::ScrollToRequest request);
|
||||
void needSearchByUsername();
|
||||
|
||||
@@ -14,12 +14,12 @@ CallSignalBars {
|
||||
width: pixels;
|
||||
radius: pixels;
|
||||
skip: pixels;
|
||||
min: pixels;
|
||||
max: pixels;
|
||||
color: color;
|
||||
inactiveOpacity: double;
|
||||
}
|
||||
|
||||
callWidth: 300px;
|
||||
callHeight: 470px;
|
||||
callRadius: 6px;
|
||||
callShadow: Shadow {
|
||||
left: icon {{ "call_shadow_left", windowShadowFg }};
|
||||
@@ -34,16 +34,83 @@ callShadow: Shadow {
|
||||
fallback: windowShadowFgFallback;
|
||||
}
|
||||
|
||||
callButton: IconButton {
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
callWidthMin: 300px;
|
||||
callHeightMin: 440px;
|
||||
callWidth: 720px;
|
||||
callHeight: 540px;
|
||||
|
||||
iconPosition: point(-1px, -1px);
|
||||
callBottomControlsHeight: 87px;
|
||||
|
||||
CallBodyLayout {
|
||||
height: pixels;
|
||||
photoTop: pixels;
|
||||
photoSize: pixels;
|
||||
nameTop: pixels;
|
||||
statusTop: pixels;
|
||||
muteStroke: pixels;
|
||||
muteSize: pixels;
|
||||
mutePosition: point;
|
||||
}
|
||||
|
||||
callBodyLayout: CallBodyLayout {
|
||||
height: 284px;
|
||||
photoTop: 21px;
|
||||
photoSize: 160px;
|
||||
nameTop: 221px;
|
||||
statusTop: 254px;
|
||||
muteStroke: 3px;
|
||||
muteSize: 36px;
|
||||
mutePosition: point(142px, 135px);
|
||||
}
|
||||
callBodyWithPreview: CallBodyLayout {
|
||||
height: 185px;
|
||||
photoTop: 21px;
|
||||
photoSize: 100px;
|
||||
nameTop: 132px;
|
||||
statusTop: 163px;
|
||||
muteStroke: 3px;
|
||||
muteSize: 0px;
|
||||
mutePosition: point(90px, 84px);
|
||||
}
|
||||
callMutedPeerIcon: icon {{ "calls_mute_userpic", callIconFg }};
|
||||
|
||||
callOutgoingPreviewMin: size(360px, 120px);
|
||||
callOutgoingPreview: size(540px, 180px); // default, for height == callHeight.
|
||||
callOutgoingPreviewMax: size(1620px, 540px);
|
||||
callOutgoingDefaultSize: size(160px, 110px);
|
||||
|
||||
callInnerPadding: 12px;
|
||||
|
||||
callFingerprintPadding: margins(10px, 4px, 8px, 5px);
|
||||
callFingerprintSkip: 4px;
|
||||
callFingerprintSignalBarsSkip: 2px;
|
||||
callSignalBarsPadding: margins(8px, 9px, 11px, 5px);
|
||||
|
||||
callFingerprintTop: 8px;
|
||||
callFingerprintBottom: -16px;
|
||||
|
||||
callTooltipMutedIcon: icon{{ "calls_mute_tooltip", videoPlayIconFg }};
|
||||
callTooltipMutedIconPosition: point(10px, 5px);
|
||||
callTooltipPadding: margins(41px, 7px, 15px, 8px);
|
||||
|
||||
callButton: IconButton {
|
||||
width: 68px;
|
||||
height: 79px;
|
||||
|
||||
iconPosition: point(-1px, 16px);
|
||||
|
||||
rippleAreaPosition: point(12px, 12px);
|
||||
rippleAreaSize: 48px;
|
||||
rippleAreaSize: 44px;
|
||||
ripple: defaultRippleAnimation;
|
||||
}
|
||||
callButtonLabel: FlatLabel(defaultFlatLabel) {
|
||||
textFg: callNameFg;
|
||||
style: TextStyle(defaultTextStyle) {
|
||||
font: font(11px);
|
||||
linkFont: font(11px);
|
||||
linkFontOver: font(11px underline);
|
||||
}
|
||||
}
|
||||
|
||||
callAnswer: CallButton {
|
||||
button: IconButton(callButton) {
|
||||
@@ -56,6 +123,7 @@ callAnswer: CallButton {
|
||||
angle: 135.;
|
||||
outerRadius: 12px;
|
||||
outerBg: callAnswerBgOuter;
|
||||
label: callButtonLabel;
|
||||
}
|
||||
callHangup: CallButton {
|
||||
button: IconButton(callButton) {
|
||||
@@ -66,30 +134,57 @@ callHangup: CallButton {
|
||||
}
|
||||
bg: callHangupBg;
|
||||
outerBg: callHangupBg;
|
||||
label: callButtonLabel;
|
||||
}
|
||||
callCancel: CallButton {
|
||||
button: IconButton(callButton) {
|
||||
icon: icon {{ "box_button_close", callCancelFg }};
|
||||
icon: icon {{ "call_cancel", callIconFgActive }};
|
||||
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||
color: callCancelRipple;
|
||||
color: callIconActiveRipple;
|
||||
}
|
||||
}
|
||||
bg: callCancelBg;
|
||||
outerBg: callCancelBg;
|
||||
bg: callIconBgActive;
|
||||
outerBg: callIconBgActive;
|
||||
label: callButtonLabel;
|
||||
}
|
||||
callMuteToggle: IconButton(callButton) {
|
||||
icon: icon {{ "call_record_active", callIconFg }};
|
||||
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||
color: callMuteRipple;
|
||||
callMicrophoneMute: CallButton {
|
||||
button: IconButton(callButton) {
|
||||
icon: icon {{ "call_record_active", callIconFg }};
|
||||
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||
color: callMuteRipple;
|
||||
}
|
||||
}
|
||||
bg: callIconBg;
|
||||
outerBg: callMuteRipple;
|
||||
label: callButtonLabel;
|
||||
}
|
||||
callMicrophoneUnmute: CallButton(callMicrophoneMute) {
|
||||
button: IconButton(callButton) {
|
||||
icon: icon {{ "call_record_muted", callIconFgActive }};
|
||||
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||
color: callIconActiveRipple;
|
||||
}
|
||||
}
|
||||
bg: callIconBgActive;
|
||||
}
|
||||
callCameraMute: CallButton(callMicrophoneMute) {
|
||||
button: IconButton(callButton) {
|
||||
icon: icon {{ "call_camera_active", callIconFg }};
|
||||
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||
color: callMuteRipple;
|
||||
}
|
||||
}
|
||||
}
|
||||
callUnmuteIcon: icon {{ "call_record_muted", callIconFg }};
|
||||
callCameraUnmute: CallButton(callMicrophoneUnmute) {
|
||||
button: IconButton(callButton) {
|
||||
icon: icon {{ "call_camera_muted", callIconFgActive }};
|
||||
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||
color: callIconActiveRipple;
|
||||
}
|
||||
}
|
||||
}
|
||||
callBottomShadowSize: 124px;
|
||||
|
||||
callControlsTop: 80px;
|
||||
callControlsSkip: 0px;
|
||||
callMuteRight: 8px;
|
||||
|
||||
callNameTop: 15px;
|
||||
callName: FlatLabel(defaultFlatLabel) {
|
||||
minWidth: 260px;
|
||||
maxHeight: 30px;
|
||||
@@ -101,7 +196,6 @@ callName: FlatLabel(defaultFlatLabel) {
|
||||
linkFontOver: font(21px semibold underline);
|
||||
}
|
||||
}
|
||||
callStatusTop: 46px;
|
||||
callStatus: FlatLabel(defaultFlatLabel) {
|
||||
minWidth: 260px;
|
||||
maxHeight: 20px;
|
||||
@@ -113,10 +207,16 @@ callStatus: FlatLabel(defaultFlatLabel) {
|
||||
linkFontOver: font(14px underline);
|
||||
}
|
||||
}
|
||||
|
||||
callFingerprintPadding: margins(9px, 4px, 9px, 5px);
|
||||
callFingerprintSkip: 3px;
|
||||
callFingerprintBottom: 8px;
|
||||
callRemoteAudioMute: FlatLabel(callStatus) {
|
||||
minWidth: 0px;
|
||||
textFg: videoPlayIconFg;
|
||||
style: TextStyle(defaultTextStyle) {
|
||||
font: font(12px);
|
||||
linkFont: font(12px);
|
||||
linkFontOver: font(12px underline);
|
||||
}
|
||||
}
|
||||
callRemoteAudioMuteSkip: 12px;
|
||||
|
||||
callBarHeight: 38px;
|
||||
callBarMuteToggle: IconButton {
|
||||
@@ -124,7 +224,7 @@ callBarMuteToggle: IconButton {
|
||||
height: 38px;
|
||||
|
||||
icon: icon {{ "call_record_active", callBarFg }};
|
||||
iconPosition: point(9px, 8px);
|
||||
iconPosition: point(3px, 2px);
|
||||
|
||||
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||
color: callBarMuteRipple;
|
||||
@@ -137,7 +237,7 @@ callBarRightSkip: 12px;
|
||||
callBarSkip: 10px;
|
||||
callBarHangup: IconButton(callBarMuteToggle) {
|
||||
icon: icon {{ "call_discard", callBarFg }};
|
||||
iconPosition: point(9px, 11px);
|
||||
iconPosition: point(3px, 1px);
|
||||
}
|
||||
callBarLabel: LabelSimple(defaultLabelSimple) {
|
||||
font: semiboldFont;
|
||||
@@ -200,14 +300,93 @@ callDebugLabel: FlatLabel(defaultFlatLabel) {
|
||||
callPanelDuration: 150;
|
||||
|
||||
callPanelSignalBars: CallSignalBars {
|
||||
width: 3px;
|
||||
width: 2px;
|
||||
radius: 1px;
|
||||
skip: 1px;
|
||||
skip: 2px;
|
||||
min: 4px;
|
||||
max: 10px;
|
||||
color: callNameFg;
|
||||
inactiveOpacity: 0.5;
|
||||
}
|
||||
callBarSignalBars: CallSignalBars(callPanelSignalBars) {
|
||||
width: 3px;
|
||||
skip: 1px;
|
||||
min: 3px;
|
||||
max: 12px;
|
||||
color: callBarFg;
|
||||
}
|
||||
callSignalMargin: 8px;
|
||||
callSignalPadding: 4px;
|
||||
|
||||
callTitleButton: IconButton {
|
||||
width: 34px;
|
||||
height: 30px;
|
||||
iconPosition: point(0px, 0px);
|
||||
}
|
||||
callTitleMinimizeIcon: icon {
|
||||
{ "calls_minimize_shadow", windowShadowFg },
|
||||
{ "calls_minimize_main", callNameFg },
|
||||
};
|
||||
callTitleMinimizeIconOver: icon {
|
||||
{ size(34px, 30px), callBgButton },
|
||||
{ size(34px, 30px), callMuteRipple },
|
||||
{ "calls_minimize_shadow", windowShadowFg },
|
||||
{ "calls_minimize_main", callNameFg },
|
||||
};
|
||||
callTitleMaximizeIcon: icon {
|
||||
{ "calls_maximize_shadow", windowShadowFg },
|
||||
{ "calls_maximize_main", callNameFg },
|
||||
};
|
||||
callTitleMaximizeIconOver: icon {
|
||||
{ size(34px, 30px), callBgButton },
|
||||
{ size(34px, 30px), callMuteRipple },
|
||||
{ "calls_maximize_shadow", windowShadowFg },
|
||||
{ "calls_maximize_main", callNameFg },
|
||||
};
|
||||
callTitleRestoreIcon: icon {
|
||||
{ "calls_restore_shadow", windowShadowFg },
|
||||
{ "calls_restore_main", callNameFg },
|
||||
};
|
||||
callTitleRestoreIconOver: icon {
|
||||
{ size(34px, 30px), callBgButton },
|
||||
{ size(34px, 30px), callMuteRipple },
|
||||
{ "calls_restore_shadow", windowShadowFg },
|
||||
{ "calls_restore_main", callNameFg },
|
||||
};
|
||||
callTitleCloseIcon: icon {
|
||||
{ "calls_close_shadow", windowShadowFg },
|
||||
{ "calls_close_main", callNameFg },
|
||||
};
|
||||
callTitleCloseIconOver: icon {
|
||||
{ size(34px, 30px), titleButtonCloseBgOver },
|
||||
{ "calls_close_shadow", windowShadowFg },
|
||||
{ "calls_close_main", titleButtonCloseFgOver },
|
||||
};
|
||||
callTitle: WindowTitle(defaultWindowTitle) {
|
||||
height: 0px;
|
||||
bg: callBgOpaque;
|
||||
bgActive: callBgOpaque;
|
||||
fg: transparent;
|
||||
fgActive: transparent;
|
||||
minimize: IconButton(callTitleButton) {
|
||||
icon: callTitleMinimizeIcon;
|
||||
iconOver: callTitleMinimizeIconOver;
|
||||
}
|
||||
minimizeIconActive: callTitleMinimizeIcon;
|
||||
minimizeIconActiveOver: callTitleMinimizeIconOver;
|
||||
maximize: IconButton(callTitleButton) {
|
||||
icon: callTitleMaximizeIcon;
|
||||
iconOver: callTitleMaximizeIconOver;
|
||||
}
|
||||
maximizeIconActive: callTitleMaximizeIcon;
|
||||
maximizeIconActiveOver: callTitleMaximizeIconOver;
|
||||
restoreIcon: callTitleRestoreIcon;
|
||||
restoreIconOver: callTitleRestoreIconOver;
|
||||
restoreIconActive: callTitleRestoreIcon;
|
||||
restoreIconActiveOver: callTitleRestoreIconOver;
|
||||
close: IconButton(callTitleButton) {
|
||||
icon: callTitleCloseIcon;
|
||||
iconOver: callTitleCloseIconOver;
|
||||
}
|
||||
closeIconActive: callTitleCloseIcon;
|
||||
closeIconActiveOver: callTitleCloseIconOver;
|
||||
}
|
||||
callTitleShadow: icon {{ "calls_shadow_controls", windowShadowFg }};
|
||||
|
||||
@@ -317,7 +317,7 @@ void BoxController::rowActionClicked(not_null<PeerListRow*> row) {
|
||||
auto user = row->peer()->asUser();
|
||||
Assert(user != nullptr);
|
||||
|
||||
Core::App().calls().startOutgoingCall(user);
|
||||
Core::App().calls().startOutgoingCall(user, false);
|
||||
}
|
||||
|
||||
void BoxController::receivedCalls(const QVector<MTPMessage> &result) {
|
||||
|
||||
@@ -8,6 +8,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "calls/calls_call.h"
|
||||
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_account.h"
|
||||
#include "main/main_app_config.h"
|
||||
#include "apiwrap.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
@@ -21,38 +23,96 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "media/audio/media_audio_track.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "calls/calls_panel.h"
|
||||
#include "calls/calls_controller.h"
|
||||
#include "webrtc/webrtc_video_track.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_session.h"
|
||||
#include "facades.h"
|
||||
|
||||
#include <tgcalls/Instance.h>
|
||||
#include <tgcalls/VideoCaptureInterface.h>
|
||||
|
||||
namespace tgcalls {
|
||||
class InstanceImpl;
|
||||
class InstanceImplLegacy;
|
||||
class InstanceImplReference;
|
||||
void SetLegacyGlobalServerConfig(const std::string &serverConfig);
|
||||
} // namespace tgcalls
|
||||
|
||||
namespace Calls {
|
||||
namespace {
|
||||
|
||||
constexpr auto kMinLayer = 65;
|
||||
constexpr auto kHangupTimeoutMs = 5000;
|
||||
constexpr auto kSha256Size = 32;
|
||||
const auto kDefaultVersion = "2.4.4"_q;
|
||||
|
||||
#ifndef DESKTOP_APP_DISABLE_WEBRTC_INTEGRATION
|
||||
const auto RegisterTag = tgcalls::Register<tgcalls::InstanceImpl>();
|
||||
//const auto RegisterTagReference = tgcalls::Register<tgcalls::InstanceImplReference>();
|
||||
#endif // DESKTOP_APP_DISABLE_WEBRTC_INTEGRATION
|
||||
const auto RegisterTagLegacy = tgcalls::Register<tgcalls::InstanceImplLegacy>();
|
||||
|
||||
void AppendEndpoint(
|
||||
std::vector<TgVoipEndpoint> &list,
|
||||
std::vector<tgcalls::Endpoint> &list,
|
||||
const MTPPhoneConnection &connection) {
|
||||
connection.match([&](const MTPDphoneConnection &data) {
|
||||
if (data.vpeer_tag().v.length() != 16) {
|
||||
return;
|
||||
}
|
||||
auto endpoint = TgVoipEndpoint{
|
||||
tgcalls::Endpoint endpoint = {
|
||||
.endpointId = (int64_t)data.vid().v,
|
||||
.host = TgVoipEdpointHost{
|
||||
.host = tgcalls::EndpointHost{
|
||||
.ipv4 = data.vip().v.toStdString(),
|
||||
.ipv6 = data.vipv6().v.toStdString() },
|
||||
.port = (uint16_t)data.vport().v,
|
||||
.type = TgVoipEndpointType::UdpRelay
|
||||
.type = tgcalls::EndpointType::UdpRelay,
|
||||
};
|
||||
const auto tag = data.vpeer_tag().v;
|
||||
if (tag.size() >= 16) {
|
||||
memcpy(endpoint.peerTag, tag.data(), 16);
|
||||
}
|
||||
list.push_back(std::move(endpoint));
|
||||
}, [&](const MTPDphoneConnectionWebrtc &data) {
|
||||
});
|
||||
}
|
||||
|
||||
void AppendServer(
|
||||
std::vector<tgcalls::RtcServer> &list,
|
||||
const MTPPhoneConnection &connection) {
|
||||
connection.match([&](const MTPDphoneConnection &data) {
|
||||
}, [&](const MTPDphoneConnectionWebrtc &data) {
|
||||
const auto host = qs(data.vip());
|
||||
const auto hostv6 = qs(data.vipv6());
|
||||
const auto port = uint16_t(data.vport().v);
|
||||
if (data.is_stun()) {
|
||||
const auto pushStun = [&](const QString &host) {
|
||||
if (host.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
list.push_back(tgcalls::RtcServer{
|
||||
.host = host.toStdString(),
|
||||
.port = port,
|
||||
.isTurn = false
|
||||
});
|
||||
};
|
||||
pushStun(host);
|
||||
pushStun(hostv6);
|
||||
}
|
||||
const auto username = qs(data.vusername());
|
||||
const auto password = qs(data.vpassword());
|
||||
if (data.is_turn() && !username.isEmpty() && !password.isEmpty()) {
|
||||
const auto pushTurn = [&](const QString &host) {
|
||||
list.push_back(tgcalls::RtcServer{
|
||||
.host = host.toStdString(),
|
||||
.port = port,
|
||||
.login = username.toStdString(),
|
||||
.password = password.toStdString(),
|
||||
.isTurn = true,
|
||||
});
|
||||
};
|
||||
pushTurn(host);
|
||||
pushTurn(hostv6);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -71,10 +131,6 @@ uint64 ComputeFingerprint(bytes::const_span authKey) {
|
||||
| (gsl::to_integer<uint64>(hash[12]));
|
||||
}
|
||||
|
||||
[[nodiscard]] std::vector<std::string> CollectVersions() {
|
||||
return { TgVoip::getVersion() };
|
||||
}
|
||||
|
||||
[[nodiscard]] QVector<MTPstring> WrapVersions(
|
||||
const std::vector<std::string> &data) {
|
||||
auto result = QVector<MTPstring>();
|
||||
@@ -86,28 +142,35 @@ uint64 ComputeFingerprint(bytes::const_span authKey) {
|
||||
}
|
||||
|
||||
[[nodiscard]] QVector<MTPstring> CollectVersionsForApi() {
|
||||
return WrapVersions(CollectVersions());
|
||||
return WrapVersions(tgcalls::Meta::Versions() | ranges::action::reverse);
|
||||
}
|
||||
|
||||
[[nodiscard]] Webrtc::VideoState StartVideoState(bool enabled) {
|
||||
using State = Webrtc::VideoState;
|
||||
return enabled ? State::Active : State::Inactive;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Call::Delegate::~Delegate() = default;
|
||||
|
||||
Call::Call(
|
||||
not_null<Delegate*> delegate,
|
||||
not_null<UserData*> user,
|
||||
Type type)
|
||||
Type type,
|
||||
bool video)
|
||||
: _delegate(delegate)
|
||||
, _user(user)
|
||||
, _api(&_user->session().mtp())
|
||||
, _type(type) {
|
||||
_discardByTimeoutTimer.setCallback([this] { hangup(); });
|
||||
, _type(type)
|
||||
, _videoIncoming(std::make_unique<Webrtc::VideoTrack>(StartVideoState(video)))
|
||||
, _videoOutgoing(std::make_unique<Webrtc::VideoTrack>(StartVideoState(video))) {
|
||||
_discardByTimeoutTimer.setCallback([=] { hangup(); });
|
||||
|
||||
if (_type == Type::Outgoing) {
|
||||
setState(State::Requesting);
|
||||
} else {
|
||||
startWaitingTrack();
|
||||
}
|
||||
setupOutgoingVideo();
|
||||
}
|
||||
|
||||
void Call::generateModExpFirst(bytes::const_span randomSeed) {
|
||||
@@ -161,8 +224,11 @@ void Call::startOutgoing() {
|
||||
Expects(_state.current() == State::Requesting);
|
||||
Expects(_gaHash.size() == kSha256Size);
|
||||
|
||||
const auto flags = _videoCapture
|
||||
? MTPphone_RequestCall::Flag::f_video
|
||||
: MTPphone_RequestCall::Flag(0);
|
||||
_api.request(MTPphone_RequestCall(
|
||||
MTP_flags(0),
|
||||
MTP_flags(flags),
|
||||
_user->inputUser,
|
||||
MTP_int(rand_value<int32>()),
|
||||
MTP_bytes(_gaHash),
|
||||
@@ -170,7 +236,7 @@ void Call::startOutgoing() {
|
||||
MTP_flags(MTPDphoneCallProtocol::Flag::f_udp_p2p
|
||||
| MTPDphoneCallProtocol::Flag::f_udp_reflector),
|
||||
MTP_int(kMinLayer),
|
||||
MTP_int(TgVoip::getConnectionMaxLayer()),
|
||||
MTP_int(tgcalls::Meta::MaxLayer()),
|
||||
MTP_vector(CollectVersionsForApi()))
|
||||
)).done([=](const MTPphone_PhoneCall &result) {
|
||||
Expects(result.type() == mtpc_phone_phoneCall);
|
||||
@@ -222,7 +288,7 @@ void Call::startIncoming() {
|
||||
}
|
||||
|
||||
void Call::answer() {
|
||||
_delegate->requestMicrophonePermissionOrFail(crl::guard(this, [=] {
|
||||
_delegate->requestPermissionsOrFail(crl::guard(this, [=] {
|
||||
actuallyAnswer();
|
||||
}));
|
||||
}
|
||||
@@ -251,10 +317,11 @@ void Call::actuallyAnswer() {
|
||||
MTP_flags(MTPDphoneCallProtocol::Flag::f_udp_p2p
|
||||
| MTPDphoneCallProtocol::Flag::f_udp_reflector),
|
||||
MTP_int(kMinLayer),
|
||||
MTP_int(TgVoip::getConnectionMaxLayer()),
|
||||
MTP_int(tgcalls::Meta::MaxLayer()),
|
||||
MTP_vector(CollectVersionsForApi()))
|
||||
)).done([=](const MTPphone_PhoneCall &result) {
|
||||
Expects(result.type() == mtpc_phone_phoneCall);
|
||||
|
||||
auto &call = result.c_phone_phoneCall();
|
||||
_user->session().data().processUsers(call.vusers());
|
||||
if (call.vphone_call().type() != mtpc_phoneCallWaiting) {
|
||||
@@ -270,12 +337,46 @@ void Call::actuallyAnswer() {
|
||||
}).send();
|
||||
}
|
||||
|
||||
void Call::setMute(bool mute) {
|
||||
_mute = mute;
|
||||
if (_controller) {
|
||||
_controller->setMuteMicrophone(_mute);
|
||||
void Call::setMuted(bool mute) {
|
||||
_muted = mute;
|
||||
if (_instance) {
|
||||
_instance->setMuteMicrophone(mute);
|
||||
}
|
||||
_muteChanged.notify(_mute);
|
||||
}
|
||||
|
||||
void Call::setupOutgoingVideo() {
|
||||
const auto started = _videoOutgoing->state();
|
||||
_videoOutgoing->stateValue(
|
||||
) | rpl::start_with_next([=](Webrtc::VideoState state) {
|
||||
if (_state.current() != State::Established
|
||||
&& state != started
|
||||
&& !_videoCapture) {
|
||||
_videoOutgoing->setState(started);
|
||||
} else if (state != Webrtc::VideoState::Inactive) {
|
||||
// Paused not supported right now.
|
||||
#ifndef DESKTOP_APP_DISABLE_WEBRTC_INTEGRATION
|
||||
Assert(state == Webrtc::VideoState::Active);
|
||||
if (!_videoCapture) {
|
||||
_videoCapture = tgcalls::VideoCaptureInterface::Create();
|
||||
_videoCapture->setOutput(_videoOutgoing->sink());
|
||||
}
|
||||
if (_instance) {
|
||||
_instance->setVideoCapture(_videoCapture);
|
||||
}
|
||||
_videoCapture->setState(tgcalls::VideoState::Active);
|
||||
#endif // DESKTOP_APP_DISABLE_WEBRTC_INTEGRATION
|
||||
} else if (_videoCapture) {
|
||||
_videoCapture->setState(tgcalls::VideoState::Inactive);
|
||||
}
|
||||
}, _lifetime);
|
||||
}
|
||||
|
||||
not_null<Webrtc::VideoTrack*> Call::videoIncoming() const {
|
||||
return _videoIncoming.get();
|
||||
}
|
||||
|
||||
not_null<Webrtc::VideoTrack*> Call::videoOutgoing() const {
|
||||
return _videoOutgoing.get();
|
||||
}
|
||||
|
||||
crl::time Call::getDurationMs() const {
|
||||
@@ -299,7 +400,7 @@ void Call::redial() {
|
||||
if (_state.current() != State::Busy) {
|
||||
return;
|
||||
}
|
||||
Assert(_controller == nullptr);
|
||||
Assert(_instance == nullptr);
|
||||
_type = Type::Outgoing;
|
||||
setState(State::Requesting);
|
||||
_answerAfterDhConfigReceived = false;
|
||||
@@ -308,7 +409,7 @@ void Call::redial() {
|
||||
}
|
||||
|
||||
QString Call::getDebugLog() const {
|
||||
return QString::fromStdString(_controller->getDebugInfo());
|
||||
return QString::fromStdString(_instance->getDebugInfo());
|
||||
}
|
||||
|
||||
void Call::startWaitingTrack() {
|
||||
@@ -322,6 +423,21 @@ void Call::startWaitingTrack() {
|
||||
_waitingTrack->playInLoop();
|
||||
}
|
||||
|
||||
void Call::sendSignalingData(const QByteArray &data) {
|
||||
_api.request(MTPphone_SendSignalingData(
|
||||
MTP_inputPhoneCall(
|
||||
MTP_long(_id),
|
||||
MTP_long(_accessHash)),
|
||||
MTP_bytes(data)
|
||||
)).done([=](const MTPBool &result) {
|
||||
if (!mtpIsTrue(result)) {
|
||||
finish(FinishType::Failed);
|
||||
}
|
||||
}).fail([=](const RPCError &error) {
|
||||
handleRequestError(error);
|
||||
}).send();
|
||||
}
|
||||
|
||||
float64 Call::getWaitingSoundPeakValue() const {
|
||||
if (_waitingTrack) {
|
||||
auto when = crl::now() + kSoundSampleMs / 4;
|
||||
@@ -360,6 +476,7 @@ bool Call::handleUpdate(const MTPPhoneCall &call) {
|
||||
finish(FinishType::Failed);
|
||||
return true;
|
||||
}
|
||||
|
||||
_id = data.vid().v;
|
||||
_accessHash = data.vaccess_hash().v;
|
||||
auto gaHashBytes = bytes::make_span(data.vg_a_hash().v);
|
||||
@@ -404,7 +521,7 @@ bool Call::handleUpdate(const MTPPhoneCall &call) {
|
||||
}
|
||||
if (_type == Type::Incoming
|
||||
&& _state.current() == State::ExchangingKeys
|
||||
&& !_controller) {
|
||||
&& !_instance) {
|
||||
startConfirmedCall(data);
|
||||
}
|
||||
} return true;
|
||||
@@ -415,8 +532,8 @@ bool Call::handleUpdate(const MTPPhoneCall &call) {
|
||||
return false;
|
||||
}
|
||||
if (data.is_need_debug()) {
|
||||
auto debugLog = _controller
|
||||
? _controller->getDebugInfo()
|
||||
auto debugLog = _instance
|
||||
? _instance->getDebugInfo()
|
||||
: std::string();
|
||||
if (!debugLog.empty()) {
|
||||
user()->session().api().request(MTPphone_SaveCallDebug(
|
||||
@@ -462,11 +579,49 @@ bool Call::handleUpdate(const MTPPhoneCall &call) {
|
||||
Unexpected("phoneCall type inside an existing call handleUpdate()");
|
||||
}
|
||||
|
||||
void Call::updateRemoteMediaState(
|
||||
tgcalls::AudioState audio,
|
||||
tgcalls::VideoState video) {
|
||||
_remoteAudioState = [&] {
|
||||
using From = tgcalls::AudioState;
|
||||
using To = RemoteAudioState;
|
||||
switch (audio) {
|
||||
case From::Active: return To::Active;
|
||||
case From::Muted: return To::Muted;
|
||||
}
|
||||
Unexpected("Audio state in remoteMediaStateUpdated.");
|
||||
}();
|
||||
_videoIncoming->setState([&] {
|
||||
using From = tgcalls::VideoState;
|
||||
using To = Webrtc::VideoState;
|
||||
switch (video) {
|
||||
case From::Inactive: return To::Inactive;
|
||||
case From::Paused: return To::Paused;
|
||||
case From::Active: return To::Active;
|
||||
}
|
||||
Unexpected("Video state in remoteMediaStateUpdated.");
|
||||
}());
|
||||
}
|
||||
|
||||
bool Call::handleSignalingData(
|
||||
const MTPDupdatePhoneCallSignalingData &data) {
|
||||
if (data.vphone_call_id().v != _id || !_instance) {
|
||||
return false;
|
||||
}
|
||||
auto prepared = ranges::view::all(
|
||||
data.vdata().v
|
||||
) | ranges::view::transform([](char byte) {
|
||||
return static_cast<uint8_t>(byte);
|
||||
}) | ranges::to_vector;
|
||||
_instance->receiveSignalingData(std::move(prepared));
|
||||
return true;
|
||||
}
|
||||
|
||||
void Call::confirmAcceptedCall(const MTPDphoneCallAccepted &call) {
|
||||
Expects(_type == Type::Outgoing);
|
||||
|
||||
if (_state.current() == State::ExchangingKeys
|
||||
|| _controller) {
|
||||
|| _instance) {
|
||||
LOG(("Call Warning: Unexpected confirmAcceptedCall."));
|
||||
return;
|
||||
}
|
||||
@@ -494,9 +649,9 @@ void Call::confirmAcceptedCall(const MTPDphoneCallAccepted &call) {
|
||||
MTP_flags(MTPDphoneCallProtocol::Flag::f_udp_p2p
|
||||
| MTPDphoneCallProtocol::Flag::f_udp_reflector),
|
||||
MTP_int(kMinLayer),
|
||||
MTP_int(TgVoip::getConnectionMaxLayer()),
|
||||
MTP_int(tgcalls::Meta::MaxLayer()),
|
||||
MTP_vector(CollectVersionsForApi()))
|
||||
)).done([this](const MTPphone_PhoneCall &result) {
|
||||
)).done([=](const MTPphone_PhoneCall &result) {
|
||||
Expects(result.type() == mtpc_phone_phoneCall);
|
||||
|
||||
auto &call = result.c_phone_phoneCall();
|
||||
@@ -508,7 +663,7 @@ void Call::confirmAcceptedCall(const MTPDphoneCallAccepted &call) {
|
||||
}
|
||||
|
||||
createAndStartController(call.vphone_call().c_phoneCall());
|
||||
}).fail([this](const RPCError &error) {
|
||||
}).fail([=](const RPCError &error) {
|
||||
handleRequestError(error);
|
||||
}).send();
|
||||
}
|
||||
@@ -539,83 +694,117 @@ void Call::startConfirmedCall(const MTPDphoneCall &call) {
|
||||
|
||||
void Call::createAndStartController(const MTPDphoneCall &call) {
|
||||
_discardByTimeoutTimer.cancel();
|
||||
if (!checkCallFields(call)) {
|
||||
if (!checkCallFields(call) || _authKey.size() != 256) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto &protocol = call.vprotocol().c_phoneCallProtocol();
|
||||
const auto &serverConfig = _user->session().serverConfig();
|
||||
|
||||
TgVoipConfig config;
|
||||
config.dataSaving = TgVoipDataSaving::Never;
|
||||
config.enableAEC = !Platform::IsMac10_7OrGreater();
|
||||
config.enableNS = true;
|
||||
config.enableAGC = true;
|
||||
config.enableVolumeControl = true;
|
||||
config.initializationTimeout = serverConfig.callConnectTimeoutMs / 1000.;
|
||||
config.receiveTimeout = serverConfig.callPacketTimeoutMs / 1000.;
|
||||
config.enableP2P = call.is_p2p_allowed();
|
||||
config.maxApiLayer = protocol.vmax_layer().v;
|
||||
auto encryptionKeyValue = std::make_shared<std::array<uint8_t, 256>>();
|
||||
memcpy(encryptionKeyValue->data(), _authKey.data(), 256);
|
||||
|
||||
const auto weak = base::make_weak(this);
|
||||
tgcalls::Descriptor descriptor = {
|
||||
.config = tgcalls::Config{
|
||||
.initializationTimeout = serverConfig.callConnectTimeoutMs / 1000.,
|
||||
.receiveTimeout = serverConfig.callPacketTimeoutMs / 1000.,
|
||||
.dataSaving = tgcalls::DataSaving::Never,
|
||||
.enableP2P = call.is_p2p_allowed(),
|
||||
.enableAEC = !Platform::IsMac10_7OrGreater(),
|
||||
.enableNS = true,
|
||||
.enableAGC = true,
|
||||
.enableVolumeControl = true,
|
||||
.maxApiLayer = protocol.vmax_layer().v,
|
||||
},
|
||||
.encryptionKey = tgcalls::EncryptionKey(
|
||||
std::move(encryptionKeyValue),
|
||||
(_type == Type::Outgoing)),
|
||||
.videoCapture = _videoCapture,
|
||||
.stateUpdated = [=](tgcalls::State state) {
|
||||
crl::on_main(weak, [=] {
|
||||
handleControllerStateChange(state);
|
||||
});
|
||||
},
|
||||
.signalBarsUpdated = [=](int count) {
|
||||
crl::on_main(weak, [=] {
|
||||
handleControllerBarCountChange(count);
|
||||
});
|
||||
},
|
||||
.remoteMediaStateUpdated = [=](tgcalls::AudioState audio, tgcalls::VideoState video) {
|
||||
crl::on_main(weak, [=] {
|
||||
updateRemoteMediaState(audio, video);
|
||||
});
|
||||
},
|
||||
.signalingDataEmitted = [=](const std::vector<uint8_t> &data) {
|
||||
const auto bytes = QByteArray(
|
||||
reinterpret_cast<const char*>(data.data()),
|
||||
data.size());
|
||||
crl::on_main(weak, [=] {
|
||||
sendSignalingData(bytes);
|
||||
});
|
||||
},
|
||||
};
|
||||
if (Logs::DebugEnabled()) {
|
||||
auto callLogFolder = cWorkingDir() + qsl("DebugLogs");
|
||||
auto callLogPath = callLogFolder + qsl("/last_call_log.txt");
|
||||
auto callLogNative = QDir::toNativeSeparators(callLogPath);
|
||||
#ifdef Q_OS_WIN
|
||||
config.logPath = callLogNative.toStdWString();
|
||||
descriptor.config.logPath = callLogNative.toStdWString();
|
||||
#else // Q_OS_WIN
|
||||
const auto callLogUtf = QFile::encodeName(callLogNative);
|
||||
config.logPath.resize(callLogUtf.size());
|
||||
ranges::copy(callLogUtf, config.logPath.begin());
|
||||
descriptor.config.logPath.resize(callLogUtf.size());
|
||||
ranges::copy(callLogUtf, descriptor.config.logPath.begin());
|
||||
#endif // Q_OS_WIN
|
||||
QFile(callLogPath).remove();
|
||||
QDir().mkpath(callLogFolder);
|
||||
}
|
||||
|
||||
auto endpoints = std::vector<TgVoipEndpoint>();
|
||||
for (const auto &connection : call.vconnections().v) {
|
||||
AppendEndpoint(endpoints, connection);
|
||||
AppendEndpoint(descriptor.endpoints, connection);
|
||||
}
|
||||
for (const auto &connection : call.vconnections().v) {
|
||||
AppendServer(descriptor.rtcServers, connection);
|
||||
}
|
||||
|
||||
auto proxy = TgVoipProxy();
|
||||
if (Global::UseProxyForCalls()
|
||||
&& (Global::ProxySettings() == MTP::ProxyData::Settings::Enabled)) {
|
||||
const auto &selected = Global::SelectedProxy();
|
||||
if (selected.supportsCalls()) {
|
||||
if (selected.supportsCalls() && !selected.host.isEmpty()) {
|
||||
Assert(selected.type == MTP::ProxyData::Type::Socks5);
|
||||
proxy.host = selected.host.toStdString();
|
||||
proxy.port = selected.port;
|
||||
proxy.login = selected.user.toStdString();
|
||||
proxy.password = selected.password.toStdString();
|
||||
descriptor.proxy = std::make_unique<tgcalls::Proxy>();
|
||||
descriptor.proxy->host = selected.host.toStdString();
|
||||
descriptor.proxy->port = selected.port;
|
||||
descriptor.proxy->login = selected.user.toStdString();
|
||||
descriptor.proxy->password = selected.password.toStdString();
|
||||
}
|
||||
}
|
||||
|
||||
auto encryptionKey = TgVoipEncryptionKey();
|
||||
encryptionKey.isOutgoing = (_type == Type::Outgoing);
|
||||
encryptionKey.value = ranges::view::all(
|
||||
_authKey
|
||||
) | ranges::view::transform([](bytes::type byte) {
|
||||
return static_cast<uint8_t>(byte);
|
||||
}) | ranges::to_vector;
|
||||
const auto version = call.vprotocol().match([&](
|
||||
const MTPDphoneCallProtocol &data) {
|
||||
return data.vlibrary_versions().v;
|
||||
}).value(0, MTP_bytes(kDefaultVersion)).v;
|
||||
|
||||
_controller = MakeController(
|
||||
"2.4.4",
|
||||
config,
|
||||
TgVoipPersistentState(),
|
||||
endpoints,
|
||||
proxy.host.empty() ? nullptr : &proxy,
|
||||
TgVoipNetworkType::Unknown,
|
||||
encryptionKey);
|
||||
|
||||
const auto raw = _controller.get();
|
||||
raw->setOnStateUpdated([=](TgVoipState state) {
|
||||
handleControllerStateChange(raw, state);
|
||||
});
|
||||
raw->setOnSignalBarsUpdated([=](int count) {
|
||||
handleControllerBarCountChange(count);
|
||||
});
|
||||
if (_mute) {
|
||||
raw->setMuteMicrophone(_mute);
|
||||
LOG(("Call Info: Creating instance with version '%1', allowP2P: %2"
|
||||
).arg(QString::fromUtf8(version)
|
||||
).arg(Logs::b(descriptor.config.enableP2P)));
|
||||
_instance = tgcalls::Meta::Create(
|
||||
version.toStdString(),
|
||||
std::move(descriptor));
|
||||
if (!_instance) {
|
||||
LOG(("Call Error: Wrong library version: %1."
|
||||
).arg(QString::fromUtf8(version)));
|
||||
finish(FinishType::Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto raw = _instance.get();
|
||||
if (_muted.current()) {
|
||||
raw->setMuteMicrophone(_muted.current());
|
||||
}
|
||||
|
||||
raw->setIncomingVideoOutput(_videoIncoming->sink());
|
||||
|
||||
const auto &settings = Core::App().settings();
|
||||
raw->setAudioOutputDevice(
|
||||
settings.callOutputDeviceID().toStdString());
|
||||
@@ -626,32 +815,27 @@ void Call::createAndStartController(const MTPDphoneCall &call) {
|
||||
raw->setAudioOutputDuckingEnabled(settings.callAudioDuckingEnabled());
|
||||
}
|
||||
|
||||
void Call::handleControllerStateChange(
|
||||
not_null<Controller*> controller,
|
||||
TgVoipState state) {
|
||||
// NB! Can be called from an arbitrary thread!
|
||||
// This can be called from ~VoIPController()!
|
||||
|
||||
void Call::handleControllerStateChange(tgcalls::State state) {
|
||||
switch (state) {
|
||||
case TgVoipState::WaitInit: {
|
||||
case tgcalls::State::WaitInit: {
|
||||
DEBUG_LOG(("Call Info: State changed to WaitingInit."));
|
||||
setStateQueued(State::WaitingInit);
|
||||
setState(State::WaitingInit);
|
||||
} break;
|
||||
|
||||
case TgVoipState::WaitInitAck: {
|
||||
case tgcalls::State::WaitInitAck: {
|
||||
DEBUG_LOG(("Call Info: State changed to WaitingInitAck."));
|
||||
setStateQueued(State::WaitingInitAck);
|
||||
setState(State::WaitingInitAck);
|
||||
} break;
|
||||
|
||||
case TgVoipState::Established: {
|
||||
case tgcalls::State::Established: {
|
||||
DEBUG_LOG(("Call Info: State changed to Established."));
|
||||
setStateQueued(State::Established);
|
||||
setState(State::Established);
|
||||
} break;
|
||||
|
||||
case TgVoipState::Failed: {
|
||||
auto error = QString::fromStdString(controller->getLastError());
|
||||
case tgcalls::State::Failed: {
|
||||
auto error = QString::fromStdString(_instance->getLastError());
|
||||
LOG(("Call Info: State changed to Failed, error: %1.").arg(error));
|
||||
setFailedQueued(error);
|
||||
handleControllerError(error);
|
||||
} break;
|
||||
|
||||
default: LOG(("Call Error: Unexpected state in handleStateChange: %1"
|
||||
@@ -660,19 +844,11 @@ void Call::handleControllerStateChange(
|
||||
}
|
||||
|
||||
void Call::handleControllerBarCountChange(int count) {
|
||||
// NB! Can be called from an arbitrary thread!
|
||||
// This can be called from ~VoIPController()!
|
||||
|
||||
crl::on_main(this, [=] {
|
||||
setSignalBarCount(count);
|
||||
});
|
||||
setSignalBarCount(count);
|
||||
}
|
||||
|
||||
void Call::setSignalBarCount(int count) {
|
||||
if (_signalBarCount != count) {
|
||||
_signalBarCount = count;
|
||||
_signalBarCountChanged.notify(count);
|
||||
}
|
||||
_signalBarCount = count;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -766,28 +942,28 @@ void Call::setState(State state) {
|
||||
}
|
||||
|
||||
void Call::setCurrentAudioDevice(bool input, std::string deviceID) {
|
||||
if (_controller) {
|
||||
if (_instance) {
|
||||
if (input) {
|
||||
_controller->setAudioInputDevice(deviceID);
|
||||
_instance->setAudioInputDevice(deviceID);
|
||||
} else {
|
||||
_controller->setAudioOutputDevice(deviceID);
|
||||
_instance->setAudioOutputDevice(deviceID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Call::setAudioVolume(bool input, float level) {
|
||||
if (_controller) {
|
||||
if (_instance) {
|
||||
if (input) {
|
||||
_controller->setInputVolume(level);
|
||||
_instance->setInputVolume(level);
|
||||
} else {
|
||||
_controller->setOutputVolume(level);
|
||||
_instance->setOutputVolume(level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Call::setAudioDuckingEnabled(bool enabled) {
|
||||
if (_controller) {
|
||||
_controller->setAudioOutputDuckingEnabled(enabled);
|
||||
if (_instance) {
|
||||
_instance->setAudioOutputDuckingEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -818,10 +994,14 @@ void Call::finish(FinishType type, const MTPPhoneCallDiscardReason &reason) {
|
||||
|
||||
setState(hangupState);
|
||||
auto duration = getDurationMs() / 1000;
|
||||
auto connectionId = _controller ? _controller->getPreferredRelayId() : 0;
|
||||
auto connectionId = _instance ? _instance->getPreferredRelayId() : 0;
|
||||
_finishByTimeoutTimer.call(kHangupTimeoutMs, [this, finalState] { setState(finalState); });
|
||||
const auto flags = ((_videoIncoming->state() != Webrtc::VideoState::Inactive)
|
||||
|| (_videoOutgoing->state() != Webrtc::VideoState::Inactive))
|
||||
? MTPphone_DiscardCall::Flag::f_video
|
||||
: MTPphone_DiscardCall::Flag(0);
|
||||
_api.request(MTPphone_DiscardCall(
|
||||
MTP_flags(0),
|
||||
MTP_flags(flags),
|
||||
MTP_inputPhoneCall(
|
||||
MTP_long(_id),
|
||||
MTP_long(_accessHash)),
|
||||
@@ -874,9 +1054,11 @@ void Call::handleControllerError(const QString &error) {
|
||||
}
|
||||
|
||||
void Call::destroyController() {
|
||||
if (_controller) {
|
||||
if (_instance) {
|
||||
const auto state = _instance->stop();
|
||||
|
||||
DEBUG_LOG(("Call Info: Destroying call controller.."));
|
||||
_controller.reset();
|
||||
_instance.reset();
|
||||
DEBUG_LOG(("Call Info: Call controller destroyed."));
|
||||
}
|
||||
setSignalBarCount(kSignalBarFinished);
|
||||
@@ -887,7 +1069,7 @@ Call::~Call() {
|
||||
}
|
||||
|
||||
void UpdateConfig(const std::string &data) {
|
||||
TgVoip::setGlobalServerConfig(data);
|
||||
tgcalls::SetLegacyGlobalServerConfig(data);
|
||||
}
|
||||
|
||||
} // namespace Calls
|
||||
|
||||