Compare commits

...

496 Commits

Author SHA1 Message Date
John Preston
5655ad25b0 Beta version 2.1.21.
- Edit your scheduled messages.
- See the unread messages indicator for your additional accounts
on the main menu button.
- Use Auto-Night Mode to make Telegram night mode match
the system Dark Mode settings.
- Enjoy dark native window frame for Telegram night mode on Windows.
2020-07-24 17:07:54 +04:00
John Preston
c86ced8a1e Use dark Windows title bar for night mode. 2020-07-24 16:15:58 +04:00
John Preston
511067981d Forbid auto-night mode with theme editor. 2020-07-24 10:01:37 +04:00
John Preston
9a186cd8ce Indicate other accounts unread messages. 2020-07-24 09:41:51 +04:00
Ilya Fedin
385aa3eef7 Remove redudant library order hacks 2020-07-24 09:40:20 +04:00
John Preston
e065d32d28 Don't try building profile photos list by updates. 2020-07-23 17:47:04 +04:00
John Preston
d4feb16378 Don't mark as read when scheduling messages. 2020-07-23 17:46:52 +04:00
Ilya Fedin
79e6369e27 Move libatomic link to common_options 2020-07-23 14:29:56 +04:00
Ilya Fedin
e4bd89d33e Remove redudant hacks for missed dependencies
27f6c8ce62 and 3194d883d2 added missed pthread dependencies that allows to remove Threads::Threads dependency
2020-07-23 14:29:56 +04:00
Ilya Fedin
2b89700f66 libwayland headers are needed only with Qt < 5.13 2020-07-23 14:29:56 +04:00
Ilya Fedin
ab95751a66 Make gdk backend limit more permissive 2020-07-23 14:29:56 +04:00
Ilya Fedin
841908fe31 Read decoration layout property from gtk 2020-07-23 14:29:56 +04:00
23rd
9e0b046213 Fixed handling of language switch for connection type in intro settings. 2020-07-23 13:00:55 +03:00
23rd
d46b9d024e Fixed handling of language switch for theme names in intro settings. 2020-07-23 13:00:55 +03:00
23rd
52cd9f8cbf Fixed handling of language switch for checkboxes in intro settings. 2020-07-23 13:00:55 +03:00
John Preston
25d69434ec Support auto-night mode on macOS. 2020-07-23 12:30:20 +04:00
John Preston
8c4e8212cd Add 'respect system dark mode' checkbox. 2020-07-22 17:18:17 +04:00
Ilya Fedin
c24da4c3df Don't generate 64px tray icon since badge counter generator doesn't support it 2020-07-22 10:33:12 +04:00
Ilya Fedin
47a237c924 Implement system-based dark mode for Windows and Linux 2020-07-22 10:32:56 +04:00
23rd
fc3a9d98c0 Fixed phrase translate of option for native window frame. 2020-07-22 10:31:32 +04:00
23rd
acce671eb0 Added ability to jump to bottom in HistoryWidget with Ctrl key.
Fixed #7868.
2020-07-22 10:26:00 +04:00
John Preston
67b6023b32 Fix build on Windows. 2020-07-22 10:25:55 +04:00
23rd
5a46bb1770 Fixed stuck of FieldHeader when invalid link was provided. 2020-07-20 21:44:07 +03:00
23rd
01fd8aded1 Slightly refactored DragArea. 2020-07-20 21:44:07 +03:00
23rd
e0750f7b87 Added drag'n'drop area to SendFilesBox for images. 2020-07-20 21:44:07 +03:00
23rd
4eaba39a7c Added drag'n'drop area to EditCaptionBox. 2020-07-20 21:44:07 +03:00
23rd
6ac9ef34eb Moved ActivateWindow from HistoryWidget to single place. 2020-07-20 21:44:07 +03:00
23rd
42a2286230 Added implementation of drag'n'drop in section of scheduled messages. 2020-07-20 21:44:07 +03:00
23rd
24d02d5461 Replaced creating of drag'n'drop area in HistoryWidget with new way. 2020-07-20 21:44:07 +03:00
23rd
9bf2940375 Simplified setup of drag'n'drop area. 2020-07-20 21:44:07 +03:00
23rd
d98212e8b3 Fixed incorrect text in context menu item to cancel scheduled uploading. 2020-07-20 21:44:07 +03:00
23rd
3fe9c36d90 Added Esc shortcut to cancel edit in section of scheduled messages. 2020-07-20 21:44:07 +03:00
23rd
22f16caa89 Fixed multiple attempts to send request to edit message. 2020-07-20 21:44:07 +03:00
23rd
46cce57f6b Removed display post views for sent forwarded scheduled messages. 2020-07-20 21:44:07 +03:00
23rd
456244cdec Fixed blurred display of scheduled photos that were downloaded too fast. 2020-07-20 21:44:07 +03:00
23rd
69b2030c71 Added updating of WebPage preview image on download finish. 2020-07-20 21:44:07 +03:00
23rd
11018d76f1 Added Up arrow shortcut to edit scheduled messages. 2020-07-20 21:44:07 +03:00
23rd
e862215efb Added handling of group rights changes to scheduled WebPage preview.
Slightly refactored code.
2020-07-20 21:44:06 +03:00
23rd
129de6d87f Added ability to scroll to scheduled text message on edit header click. 2020-07-20 21:43:33 +03:00
23rd
3c3ce24675 Added ability to remove WebPage preview from scheduled messages section. 2020-07-20 21:43:33 +03:00
23rd
d98ac33425 Improved WebPage preview support in scheduled text messages. 2020-07-20 21:43:33 +03:00
23rd
76842792b8 Added initial support for WebPage cancelling of scheduled text messages. 2020-07-19 19:56:18 +03:00
23rd
4b01043b27 Added handling of deleting currently edited scheduled text messages. 2020-07-19 19:56:18 +03:00
23rd
0a4f3f310c Added initial implementation of editing of scheduled text messages. 2020-07-19 19:56:18 +03:00
23rd
8320feea10 Added saving local text before editing scheduled message. 2020-07-19 19:56:18 +03:00
23rd
58281023bc Moved drawing preview image from HistoryWidget to WebPageData. 2020-07-19 19:56:18 +03:00
23rd
0b655450bb Added text preview in edit header of scheduled messages section. 2020-07-19 19:56:18 +03:00
23rd
61292557bf Fixed top scroll of compose controls on change of height. 2020-07-19 19:56:18 +03:00
23rd
12ad1190ff Added initial edit message header to scheduled section. 2020-07-19 19:56:18 +03:00
23rd
42e0994581 Moved generating preview text from HistoryWidget to WebPageData. 2020-07-19 19:56:18 +03:00
23rd
69bc595e31 Fixed text loss when editing media content is canceled. 2020-07-17 18:22:38 +03:00
23rd
5c097887ef Added ability to edit media in scheduled messages. 2020-07-17 18:22:38 +03:00
23rd
b02b690747 Moved HistoryWidget::saveEditMsgDone/Fail to lambdas. 2020-07-17 18:22:38 +03:00
23rd
c52da743fd Fixed WebPageId removing from api_editing. 2020-07-17 18:22:38 +03:00
23rd
63dff9ff91 Moved edit text messages from HistoryWidget to api_editing. 2020-07-17 18:22:38 +03:00
23rd
1c41808042 Set Api::EditMessage as generic function. 2020-07-17 18:22:38 +03:00
23rd
2ebf44c166 Removed unused code from apiwrap. 2020-07-17 18:22:38 +03:00
23rd
c46b96f252 Moved edit captions from EditCaptionBox to api_editing. 2020-07-17 18:22:38 +03:00
23rd
6c89f60679 Added edit messages with uploaded file to api_editing. 2020-07-17 18:22:38 +03:00
23rd
bb73687fc5 Added api_editing as separate file of API code for edit messages. 2020-07-17 18:22:38 +03:00
23rd
31fa2d9355 Added ScheduledMessages::lookupItem for FullMsgId. 2020-07-17 18:22:37 +03:00
23rd
c350e33dd8 Moved preparing MTPInputMedia to separate file. 2020-07-17 18:22:37 +03:00
23rd
7dd9adb934 Added handling of updates for edited media in scheduled messages. 2020-07-17 18:22:37 +03:00
John Preston
01dc3b9382 Beta version 2.1.20.
- Fix animated emoji.
- Fix crash in bot callback sending.
2020-07-17 09:23:42 +04:00
John Preston
c62b39e287 Fix possible crash in call top bar hiding. 2020-07-17 08:32:51 +04:00
John Preston
04f95e905e Fix crash in bot callback sending. 2020-07-17 08:13:53 +04:00
John Preston
9463bbd266 Fix animated stickers with wrong dimensions. 2020-07-17 08:13:45 +04:00
John Preston
f64f1ea62e Build xz from git on macOS. 2020-07-16 12:52:05 +04:00
John Preston
55bd469b2d Beta version 2.1.19.
- File uploading in an inactive account correctly finishes.
- Stickers panel works correctly after switching between accounts.
- Large .webp files are not shown as stickers.
- MacBook TouchBar support was fully rewritten with fixes for multiple accounts.
- Custom window title bar works in all Linux versions.
- Passcode doesn't auto-lock while you're active in other apps on Linux X11.
2020-07-16 11:49:10 +04:00
Ilya Fedin
ba50393e86 Update icon theme on the fly 2020-07-16 07:07:33 +04:00
23rd
df155f6cb5 Added rotate button for doc images to touchbar for media view overlay. 2020-07-15 22:04:00 +03:00
John Preston
8aafe6ba0e Show only box(512,512) .webp as stickers. 2020-07-15 22:31:42 +04:00
23rd
9cf15da2b1 Fixed display of rotate button in media view overlay for theme previews. 2020-07-15 22:10:06 +04:00
23rd
d9c566ac44 Added touchbar to media view overlay.
Fixed #7795.
2020-07-15 22:10:06 +04:00
23rd
780b5555d7 Added missed OSX checking to touchbar's files. 2020-07-15 22:10:06 +04:00
23rd
87aa8a249f Reimplemented track position item for audio touchbar. 2020-07-15 22:10:06 +04:00
23rd
8de6d0b63b Moved creation of touchbar buttons and sliders to separate file. 2020-07-15 22:10:06 +04:00
23rd
8dceec5a9f Fixed memory leak in obtaining doNotDisturb value on macOS. 2020-07-15 22:10:06 +04:00
23rd
da690d2741 Removed source code of old touchbar. 2020-07-15 22:10:06 +04:00
23rd
b95f5071a4 Added new touchbar to MainWindow. 2020-07-15 22:10:06 +04:00
23rd
7cc55e24c0 Added touchbar manager. 2020-07-15 22:10:06 +04:00
23rd
199c746216 Added main touchbar. 2020-07-15 22:10:06 +04:00
23rd
2b9cce2f23 Moved touchbar item for text formatting to separate file. 2020-07-15 22:10:06 +04:00
23rd
ed4b90717a Added new rpl events to Media::Player::Instance for stop/start.
Removed unused playerWidgetToggled event.
2020-07-15 22:10:06 +04:00
23rd
c50df6a6bc Moved touchbar scrubber item for stickers and emoji to separate file. 2020-07-15 22:10:06 +04:00
23rd
54149fb156 Moved panel of pinned dialogs for touchbar to separate file. 2020-07-15 22:10:06 +04:00
23rd
2f964d0415 Refactored and moved to separate file audio player in touchbar. 2020-07-15 22:10:06 +04:00
23rd
0970728273 Added common touchbar utils. 2020-07-15 22:10:06 +04:00
23rd
b02dd889e0 Removed old touchbar from MainWindow. 2020-07-15 22:10:06 +04:00
23rd
f68e4d9d59 Fixed sending of PlayGame user action. 2020-07-14 19:24:36 +03:00
23rd
9445ce4b09 Moved sending of bot's CallbackData and CallbackGame to separate file. 2020-07-14 19:03:41 +04:00
John Preston
515d8e78da Show 'Open With' for files without extension. 2020-07-14 19:03:36 +04:00
John Preston
f316d951ae Fix stickers list display after account switch. 2020-07-14 19:03:27 +04:00
John Preston
52e780b065 Fix a memory leak using a recursive lambda. 2020-07-14 19:03:14 +04:00
John Preston
900f7e1304 Try recursive lambda without make_shared. 2020-07-14 19:02:45 +04:00
John Preston
2f5cb33bf2 Fix finalizing media in non-active account. 2020-07-14 19:02:27 +04:00
Ilya Fedin
000a7ae28b Choose output folder based on executable name and extension instead of generator name 2020-07-13 09:47:18 +04:00
Neurotoxin001
00460506b2 Update building-msvc.md 2020-07-13 09:46:41 +04:00
Neurotoxin001
0852e717c3 Update building-msvc.md
Add some more requirements because without them users will get errors
2020-07-13 09:46:41 +04:00
Ilya Fedin
a7f9b260de Update patches commit and cmake submodule 2020-07-13 09:46:15 +04:00
Ilya Fedin
7d81159ccf Move QTextItemInt symbols to lib_ui 2020-07-13 09:46:15 +04:00
Sean Wei
556aa28df6 Remove unused variable
The following are commits related to removed variables.

apiwrap.cpp
e050e27: kSaveDraftBeforeQuitTimeout

app.cpp
113f665: serviceImageCacheSize

boxes/auto_download_box.cpp
a0c6104: checked(Source source, Type type)

boxes/background_preview_box.cpp
b6edf45: resultBytesPerPixel
fe21b5a: ms

boxes/calendar_box.cpp
ae97704: yearIndex, monthIndex
99bb093: ms

boxes/connection_box.cpp
f794d8d: ping

boxes/dictionaries_manager.cpp
8353867: session

boxes/peer_list_box.cpp
2ce2a14: grayedWidth

boxes/peers/add_participants_box.cpp
07e010d: chat, channel

boxes/self_destruction_box.cpp
fe9f02e: count

chat_helpers/emoji_suggestions_widget.cpp
a12bc60: is(QLatin1String string)

chat_helpers/field_autocomplete.cpp
8c7a35c: atwidth, hashwidth

chat_helpers/gifs_list_widget.cpp
ff65734: inlineItems
3d846fc: newSelected
d1687ab: kSaveDraftBeforeQuitTimeout

chat_helpers/stickers_dice_pack.cpp
c83e297: kZeroDiceDocumentId

chat_helpers/stickers_emoji_pack.cpp
d298953: length

chat_helpers/stickers_list_widget.cpp
eb75859: index, x

core/crash_reports.cpp
5940ae6: LaunchedDateTimeStr, LaunchedBinaryName

data/data_changes.cpp
3c4e959:clearRealtime

data/data_cloud_file.cpp
4b354b0: fromCloud, cacheTag

data/data_document_media.cpp
7db5359: kMaxVideoFrameArea

data/data_messages.cpp
794e315: wasCount

data/data_photo_media.cpp
e27d2bc: index

data/data_wall_paper.cpp
b6edf45: resultBytesPerPixel

data/data_types.cpp
aa8f62d: kWebDocumentCacheTag, kStorageCacheMask

history/admin_log/history_admin_log_inner.cpp
794e315: canDelete, canForward

history/history_location_manager.cpp
60f45ab: kCoordPrecision
9f90d3a: kMaxHttpRedirects

history/history_message.cpp
cedf8a6: kPinnedMessageTextLimit

history/history_widget.cpp
b305924: serviceColor
efa5fc4: hasForward
5e7aa4f: kTabbedSelectorToggleTooltipTimeoutMs, kTabbedSelectorToggleTooltipCount

history/view/history_view_context_menu.cpp
fe1a90b: isVideoLink, isVoiceLink, isAudioLink

settings.cpp
e2f54eb: defaultRecent

settings/settings_folders.cpp
e8bf5bb: kRefreshSuggestedTimeout

ui/filter_icon_panel.cpp
c4a0bc1: kDelayedHideTimeoutMs

window/themes/window_theme_preview.cpp
ef927c8: mutedCounter

-----

Modified variables

boxes/stickers_box.cpp
554eb3a: _rows[pressedIndex] -> set

data/data_notify_settings.cpp
734c410: muteForSeconds -> muteUntil

history/view/history_view_list_widget.cpp
07528be: _items[index] -> view
e5f3bed: fromState, tillState

history/history.cpp
cd3c1c6: kStatusShowClientsideRecordVideo -> kStatusShowClientsideRecordVoice

storage/download_manager_mtproto.cpp
ae8fb14: _queues[dcId] -> queue

storage/localstorage.cpp
357caf8: MTP::Environment::Production -> production
2020-07-13 09:33:55 +04:00
Ilya Fedin
c61cabb075 Make qt_make_filter_list a part of file_utilities_linux.cpp 2020-07-13 06:53:45 +04:00
Ilya Fedin
a6fe5c08ad Add a method to get flatpak ID 2020-07-13 06:53:45 +04:00
Ilya Fedin
256e976167 Hide ProcessNameByPID and RealExecutablePath into a private namespace 2020-07-13 06:53:45 +04:00
Ilya Fedin
e081ed4b4a Follow device pixel ratio in TrayIconFile 2020-07-13 06:53:45 +04:00
Ilya Fedin
4623804123 Don't build OpenSSL tests
To decrease actions run time and fails
2020-07-13 06:50:55 +04:00
Ilya Fedin
93e78f1565 Make export window and PiP window movable on Wayland with Qt < 5.15 2020-07-12 23:19:05 +04:00
Ilya Fedin
b587328fed Add support for custom titlebar on Linux with Qt < 5.15 2020-07-12 23:19:05 +04:00
Ilya Fedin
2fd5771c3d Add support for org.gnome.Mutter.IdleMonitor 2020-07-12 22:19:44 +04:00
Ilya Fedin
59b521d666 Implement xcb-based LastUserInputTime method 2020-07-12 22:19:44 +04:00
John Preston
c3f5de30be Beta version 2.1.18: Update changelog. 2020-07-08 10:08:45 +04:00
John Preston
2df5972f68 Raise file size limit to 2000 MB. 2020-07-08 10:07:01 +04:00
John Preston
c9ebe28fc1 Beta version 2.1.18.
- Fix a possible crash in Picture-in-Picture video player.
- Fix copying links from message texts.
- Allow using system window frame in Windows and Linux.
2020-07-08 09:41:20 +04:00
John Preston
9997af1e8b Fix copying links in some cases. 2020-07-08 09:33:53 +04:00
John Preston
b13b4a6b5c Fix system window frame toggle on Linux. 2020-07-07 21:34:25 +04:00
John Preston
f10b2194e6 Add option for a native window frame.
Fixes #2958.
2020-07-07 21:34:25 +04:00
John Preston
d1050e6041 Use window shadow from lib_ui. 2020-07-07 21:34:25 +04:00
John Preston
326574ab7e Fix possible crash in PiP drag. 2020-07-03 07:45:08 +04:00
John Preston
3822845f86 Fix build for OS X 10.10-10.11. 2020-07-02 23:02:59 +04:00
John Preston
f887bf3b6a Beta version 2.1.17.
- Fix messages editing in a non-active account.
- Fix large animated emoji messages editing.
- Fix high definition GIF animations opening in media viewer.
- Multiple crash fixes.
2020-07-02 22:11:53 +04:00
John Preston
dfa4a9990d Show accounts in main menu when added. 2020-07-02 22:11:45 +04:00
John Preston
7f55fd2cad Use a safer way to load system libraries. 2020-07-02 21:01:25 +04:00
John Preston
822c0434e8 Fix editing animated emoji messages. 2020-07-02 14:44:12 +04:00
John Preston
76596f42c7 Open too large GIFs in fullscreen viewer. 2020-07-02 13:43:39 +04:00
John Preston
f2577265ee Refresh main message view for inactive accounts. 2020-07-02 13:35:07 +04:00
John Preston
895c65d518 Fix visual glitch on profile opening. 2020-07-02 12:15:21 +04:00
Ilya Fedin
d8cc7a9b50 Pass Qt::Edges to updateCursor and startResize 2020-07-02 11:33:58 +04:00
Sean Wei
212944d89c Fix format 2020-07-02 11:32:17 +04:00
Ilya Fedin
2b5df331bd Install Qt log handler 2020-07-02 11:31:51 +04:00
Ilya Fedin
7ebebc2bc3 Detect OpenAL effects at runtime 2020-07-02 11:30:13 +04:00
John Preston
120ce27894 Fix possible crash in global search requests. 2020-07-02 11:13:50 +04:00
John Preston
17312a1eec Fix possible crash in intro widget. 2020-07-02 10:42:09 +04:00
John Preston
f1b4a82015 Fix crash in password submit. 2020-07-02 10:25:12 +04:00
John Preston
a6c76382e3 Fix possible crash in top bar widget init. 2020-07-02 10:10:09 +04:00
John Preston
370ad0aa44 Fix critical memory leak on macOS. 2020-07-01 22:34:42 +04:00
John Preston
b1554782fb Add one more moderate hotkey. 2020-07-01 22:33:19 +04:00
John Preston
90c6ff3e41 Fix Settings layout. 2020-07-01 22:33:13 +04:00
John Preston
432ce4caa4 Fix crash in migration with corrupted settings. 2020-07-01 14:16:36 +04:00
John Preston
eb1845e33b Fix crash in session destruction.
Also use rpl::event_stream for downloaderTaskFinished.
2020-07-01 12:26:29 +04:00
John Preston
0981335ca7 Beta version 2.1.16.
- Crash fix.
2020-07-01 00:42:21 +04:00
John Preston
1a69627102 Fix crash in reading saved peers. 2020-07-01 00:41:21 +04:00
Nicholas Guriev
3c0694280f Fix -Wredundant-move 2020-07-01 00:17:05 +04:00
John Preston
e050055c1e Beta version 2.1.15.
- Receive notifications only from the active account
in Settings > Notifications.
- Fix saving chats list width between application relaunches.
- Multiple crash fixes.
2020-06-30 22:17:36 +04:00
Ilya Fedin
e7c598e533 Reset cursor on window leave 2020-06-30 22:14:15 +04:00
Ilya Fedin
dd76d54aeb Fix build with TDESKTOP_DISABLE_GTK_INTEGRATION 2020-06-30 22:13:36 +04:00
John Preston
1dc31c7f2f Allow turning off inactive accounts notifications. 2020-06-30 22:11:54 +04:00
John Preston
5cc7c2b6c6 Add account from settings three-dot menu. 2020-06-30 21:16:05 +04:00
John Preston
dd0e0a10cd Add Activate/Logout context menu in accounts list. 2020-06-30 21:15:35 +04:00
John Preston
9fb12b6093 Set correct username to crash annotations. 2020-06-30 20:41:25 +04:00
John Preston
5ea5d3c60d Fix empty web page preview removing. 2020-06-30 20:22:47 +04:00
John Preston
20ea3af2f0 Fix crash in edited and replied message destruction. 2020-06-30 20:01:17 +04:00
John Preston
41f2cc6d81 Fix crash in notifications clearing. 2020-06-30 19:33:22 +04:00
John Preston
d529c60081 Fix crash in MainMenu hiding on external logout. 2020-06-30 19:13:57 +04:00
John Preston
7d0eb3ba8e Fix crash in MainWidget setup with audio player. 2020-06-30 19:05:12 +04:00
John Preston
3c028590b1 Fix crash in StickersListWidget. 2020-06-30 19:04:52 +04:00
John Preston
47c8b852b8 Fix possible crash in Dialogs::Widget. 2020-06-30 18:34:38 +04:00
John Preston
c15019dee6 Fix crashes in MainWidget and ApiWrap. 2020-06-30 18:26:44 +04:00
John Preston
09aff23ac9 Fix crashes in HistoryWidget. 2020-06-30 18:14:05 +04:00
John Preston
b7707a8a89 Fix event loop tracking crash. 2020-06-30 17:41:58 +04:00
John Preston
10ced19841 Fix crash in redundant checkStartUrl call. 2020-06-30 17:23:21 +04:00
John Preston
2ef47222f4 Fix crash in update online on logout. 2020-06-30 17:17:07 +04:00
John Preston
a95b756111 Fix settings saving.
Regression was introduced in 5d6a494934.

Fixes #8168.
2020-06-30 13:49:22 +04:00
23rd
d2615dda63 Updated Github Actions Cache version. 2020-06-30 12:28:13 +03:00
John Preston
e6f3cd1d56 Refresh appconfig after login. 2020-06-30 13:01:59 +04:00
John Preston
5d32ba5867 Accept IPv4:port in proxy host input field. 2020-06-30 12:56:06 +04:00
John Preston
4b1e9e3b9d Fix proxies list box. 2020-06-30 12:25:06 +04:00
John Preston
06c9e55c26 Fix notification receiver name. 2020-06-30 12:03:42 +04:00
John Preston
613a2f358a Fix clearing session notifications. 2020-06-30 11:52:59 +04:00
John Preston
c3fa300b5c Create notifications manager after reading settings. 2020-06-30 11:44:32 +04:00
John Preston
0db6fc4ffb Toggle accounts by userpic in Main Menu. 2020-06-30 11:34:02 +04:00
John Preston
9211b4d421 Remove duplicate accounts toggle subscription. 2020-06-30 11:31:52 +04:00
John Preston
ab33af3f73 Save preloaded filters info. 2020-06-30 11:18:35 +04:00
John Preston
dfc1712043 Fix loading locally stored self data. 2020-06-30 11:16:47 +04:00
John Preston
87eaab15b5 Load filters before creating session on log in. 2020-06-30 11:02:44 +04:00
Ilya Fedin
90af3d295b Always fallback to gtk icon theme
To inherit icon theme even on WM-based environments
2020-06-30 10:23:07 +04:00
John Preston
107dea085c Fix build for OS X 10.10-10.11. 2020-06-30 00:05:27 +04:00
John Preston
a9eedf0024 Beta version 2.1.14: Fix nearest dc resolve. 2020-06-29 22:25:36 +04:00
John Preston
db435aa9b1 Fix language switch in not-authed window. 2020-06-29 22:25:35 +04:00
John Preston
711fcc2e11 Remove change language link for secondary account. 2020-06-29 22:25:35 +04:00
John Preston
90f7f482ee Take main DC and phone prefix from active account. 2020-06-29 22:14:24 +04:00
John Preston
eff340deaf Fix touchbar destruction with Window. 2020-06-29 22:12:40 +04:00
John Preston
a8d0b80baa Beta version 2.1.14.
- Support for multiple accounts.
2020-06-29 21:51:06 +04:00
John Preston
c777f51427 Fix new settings saving. 2020-06-29 21:49:58 +04:00
John Preston
1a07a388d0 Build window_title_qt only on Linux. 2020-06-29 21:37:56 +04:00
John Preston
cbad993bba Fix app start without data. 2020-06-29 21:37:56 +04:00
John Preston
40971d6da6 Fix quit-by-closing non-authed window. 2020-06-29 21:37:56 +04:00
John Preston
52eef22273 Fix build. 2020-06-29 21:37:55 +04:00
John Preston
44e81269a3 Fix assertion violation in event loop tracking. 2020-06-29 21:29:20 +04:00
Ilya Fedin
0ede4bba72 Unity doesn't support _NET_WM_MOVERESIZE 2020-06-29 19:17:06 +04:00
Ilya Fedin
5e8e654324 Add cross-platform TitleWidget implementation based on startSystemMove/startSystemResize 2020-06-29 17:04:05 +04:00
Ilya Fedin
916601a52c Don't request IsStatusNotifierHostRegistered when SNI become available
To avoid situations when StatusNotifierItem registers icon, but tdesktop assumes that there are still no SNI
2020-06-29 16:58:00 +04:00
Ilya Fedin
a726c6411b Don't use custom notificaions on Wayland even with TDESKTOP_DISABLE_DBUS_INTEGRATION 2020-06-29 16:53:50 +04:00
John Preston
a33c9479a5 Revert pausing in processQueuedPackets. 2020-06-29 16:44:48 +04:00
Ilya Fedin
73b0153a66 Use startSystemMove in export window 2020-06-29 16:44:02 +04:00
Ilya Fedin
bb8f9a1b7f Link to gtk3 without QLibrary if DESKTOP_APP_USE_PACKAGED is defined 2020-06-29 16:27:45 +04:00
Ilya Fedin
4922768086 Don't use QLibrary for glib 2020-06-29 16:27:45 +04:00
Ilya Fedin
806f2e0b50 Check for all needed gtk functions for gtk clipboard 2020-06-29 16:27:45 +04:00
Ilya Fedin
d319c85c57 Don't load another gtk version if gtk_init_check was called 2020-06-29 16:27:45 +04:00
Magnus Groß
f697abe9a1 Do not open non-images as image
QImageReader might report PDF as a viable image type, if Qt is
dynamically linked and QtWebEngine is installed.

Fixed by additionally checking the mime type.

Fixes #8102
2020-06-29 16:22:15 +04:00
RadRussianRus
ae31bdcd1b Fix patches revision 2020-06-29 16:20:01 +04:00
Ilya Fedin
aaf71b34b5 Find alsa and pulse for libtgvoip 2020-06-29 16:18:47 +04:00
John Preston
5f9dae1b72 Run main menu hide animation on account switch. 2020-06-29 16:11:38 +04:00
John Preston
1757dd856b Fix 125% scale active account check. 2020-06-29 15:07:42 +04:00
John Preston
5689154ec5 Clear MessageUpdate changes on item destruction. 2020-06-29 13:23:51 +04:00
John Preston
57249c6ea0 Fix a case of huge memory consumption in streaming. 2020-06-29 12:42:56 +04:00
John Preston
1bd0b03e8e Return Saved Messages button to the main menu. 2020-06-29 09:55:19 +04:00
23rd
0227b5f2fa Removed Notify::inlineKeyboardMoved as completely unused code. 2020-06-29 06:26:09 +04:00
23rd
b629e0c43a Replaced Notify::replyMarkupUpdated with Data::MessageUpdate. 2020-06-29 06:26:02 +04:00
23rd
6507007086 Added fade animation for total unread count badge in main menu. 2020-06-29 06:25:36 +04:00
John Preston
a389a1e468 Fix couple of crashes in main window. 2020-06-29 06:25:20 +04:00
John Preston
4e57ce8dbb Fix crash in filters update. 2020-06-26 21:50:36 +04:00
John Preston
b6ac4a0233 Closed alpha version 2.1.13.1: Multiaccount. 2020-06-26 17:09:39 +04:00
23rd
f8dca0ae88 Fixed couple of issues with passcode lock support in touchbar. 2020-06-26 15:57:09 +03:00
23rd
ef6fab7f2a Improved unread badges in touchbar. 2020-06-26 15:05:08 +03:00
23rd
c8c7497d75 Removed from touchbar unused code of old panel of pinned dialogs. 2020-06-26 15:05:08 +03:00
23rd
4f062788d2 Wrapped Pins in touchbar to shared_ptr. 2020-06-26 15:05:08 +03:00
23rd
25ab88d87a Added animated online dots to panel of pinned dialogs in touchbar. 2020-06-26 15:05:08 +03:00
23rd
e5732cba97 Added ability to reorder pins in new panel in touchbar. 2020-06-26 15:05:08 +03:00
23rd
0e794d53cd Reimplemented panel of pinned dialogs for touchbar. 2020-06-26 15:05:08 +03:00
23rd
68badc6682 Slightly optimized drawing stickers in touchbar. 2020-06-26 15:05:08 +03:00
23rd
27c799ce3d Fixed size ratios of stickers in touchbar. 2020-06-26 15:05:08 +03:00
John Preston
044c281cf7 Fix closing float player over Intro. 2020-06-26 16:01:37 +04:00
John Preston
3f0078cfbf Fix crash in float player over Intro. 2020-06-26 15:48:38 +04:00
John Preston
6068dc418d More auto-switching between accounts. 2020-06-26 15:48:28 +04:00
John Preston
6960e4808a Don't change dc after qr request / phone submit. 2020-06-26 15:28:06 +04:00
John Preston
793e8c102e Fix adjustable colors in default theme. 2020-06-26 14:37:07 +04:00
John Preston
31c745cb07 Destroy non-authed account on deactivate. 2020-06-26 14:36:52 +04:00
John Preston
c8efb77520 Fix local storage clearing on logout. 2020-06-26 14:36:22 +04:00
John Preston
76593b0f3d Fix migrating background image. 2020-06-26 13:23:10 +04:00
John Preston
9703f7460a Fix build on Linux. 2020-06-26 12:27:54 +04:00
John Preston
325840703e Fix launching with a passcode on macOS. 2020-06-26 11:51:05 +04:00
John Preston
70fdc4eb39 Improve quit prevent management. 2020-06-26 11:22:53 +04:00
John Preston
79a361ba43 Move call management to Core::App. 2020-06-25 21:57:36 +04:00
John Preston
8c4d3a86e7 Fix notifications on macOS. 2020-06-25 19:13:02 +04:00
John Preston
2b5d3b022d Fix player closing on logout. 2020-06-25 19:01:10 +04:00
John Preston
bf7aae5fc6 Allow float video player across accounts. 2020-06-25 18:17:37 +04:00
23rd
8171ed6c12 Fixed online status stuck when switching between accounts. 2020-06-25 16:06:02 +03:00
John Preston
5d6a494934 Move some more settings to Core::App. 2020-06-25 16:25:53 +04:00
John Preston
90a9cb4f8d Fix playing music from a different account. 2020-06-25 15:12:50 +04:00
John Preston
c60b9cfa4d Allow PiP from another account. 2020-06-25 14:28:02 +04:00
John Preston
8fec04ba7a Track session better in media viewer. 2020-06-25 13:42:30 +04:00
John Preston
c19c0afe60 Fix export bar in accounts toggle. 2020-06-25 13:02:02 +04:00
John Preston
8ad1e8aed9 Fix saving of main menu accounts state. 2020-06-25 13:01:17 +04:00
John Preston
65050bf9dd Move export management to Core::App. 2020-06-25 11:14:05 +04:00
John Preston
28cafb129e Load local stickers / gifs in Session(). 2020-06-24 16:52:06 +04:00
John Preston
0bc2bfe630 Don't allow two same accounts being logged in. 2020-06-24 13:32:07 +04:00
John Preston
d8a2b391a3 Use Main::Session::uniqueId in notifications. 2020-06-24 13:05:56 +04:00
John Preston
e38d39656d Activate account before showing a peer. 2020-06-24 12:28:46 +04:00
John Preston
99bf61ac8c Pass correct context to setMarkedText. 2020-06-24 12:22:27 +04:00
John Preston
e7b8a52278 Move terms lock from Core::App to Session. 2020-06-24 11:56:16 +04:00
John Preston
30c82bb2e0 Remove some MainWindow::sessionController() calls. 2020-06-23 21:53:44 +04:00
John Preston
4d65df6ca2 Remove legacy temp download folder. 2020-06-23 21:53:44 +04:00
John Preston
4add6234b6 Fix reading background before style init. 2020-06-23 21:53:44 +04:00
John Preston
55ec4ebf86 Allow returning from new account setup. 2020-06-23 21:53:44 +04:00
John Preston
c92c15883d Improve badges in accounts list. 2020-06-23 21:53:44 +04:00
John Preston
7b0a32b607 Add unread unmuted counter to main menu cover. 2020-06-23 21:53:44 +04:00
John Preston
34ef54e40b Display check on the active account. 2020-06-23 21:53:43 +04:00
John Preston
51c2bc7349 Create only one EmojiImageLoader to fix a crash. 2020-06-23 21:53:43 +04:00
23rd
2e7a89d9c4 Added support of switching accounts to touchbar. 2020-06-23 21:53:43 +04:00
John Preston
1248cef86b Add an arrow to the expand accounts button. 2020-06-23 21:53:43 +04:00
23rd
0696a2d5c0 Replaced mapping to rpl::empty_value with rpl::to_empty. 2020-06-23 21:53:43 +04:00
23rd
e318a7d65f Simplified ranges::find_if with ranges::any_of and ranges::none_of. 2020-06-23 21:53:43 +04:00
John Preston
5f238a71f9 Allow switching accounts from the main menu. 2020-06-23 21:53:43 +04:00
John Preston
f129b6b90d Fix invalid cache settings being read. 2020-06-23 21:53:43 +04:00
John Preston
bc3719038f Fix crash in session destruction. 2020-06-23 21:53:43 +04:00
John Preston
1705a1aa4a Fix filters in non-active accounts. 2020-06-23 21:53:43 +04:00
John Preston
a45d088ee4 Fix create group box. 2020-06-23 21:53:43 +04:00
John Preston
28570b45e3 Fix working with settings before Domain::started. 2020-06-23 21:53:43 +04:00
John Preston
4a8d297df3 Use username in notifications if available. 2020-06-23 21:53:43 +04:00
John Preston
3bb352e0e5 Fix build and working on macOS. 2020-06-23 21:53:42 +04:00
23rd
b49a8e6dc1 Fixed crash on pinning dialog from context menu.
Regression was introduced in 3a147305b7.
2020-06-23 21:53:42 +04:00
John Preston
0824d2da20 Reset some settings on full logout. 2020-06-23 21:53:42 +04:00
John Preston
2635ca33f8 Move background to global settings. 2020-06-23 21:53:42 +04:00
John Preston
5433c16244 Add target account name to notifications. 2020-06-23 21:53:42 +04:00
John Preston
997913be25 One Window::Notifications system for all sessions. 2020-06-23 21:53:42 +04:00
John Preston
83538675ce Move a lot of settings to Core::Settings. 2020-06-23 21:53:42 +04:00
John Preston
4d6cc58f0d Move session settings to main_session_settings. 2020-06-23 21:53:42 +04:00
John Preston
3a5ede534e Count all accounts in Core::App().unreadBadge. 2020-06-23 21:53:41 +04:00
John Preston
357caf8007 Keep separate MTP::Config's for separate accounts. 2020-06-23 21:53:41 +04:00
John Preston
63cdda2df7 Fix launching with autoupdates disabled. 2020-06-23 21:53:41 +04:00
23rd
3ef45f5431 Fixed starting with touchbar. 2020-06-23 21:53:41 +04:00
John Preston
c83659f0c7 Fix logouting from the passcode. 2020-06-23 21:53:41 +04:00
John Preston
ba103fdd40 Fix starting with a passcode. 2020-06-23 21:53:41 +04:00
John Preston
bc144377c0 Support logout of a secondary account. 2020-06-23 21:53:41 +04:00
John Preston
5e045ec02c Fix first main window appearance. 2020-06-23 21:53:41 +04:00
John Preston
ab5796c117 Several working accounts together. 2020-06-23 21:53:40 +04:00
John Preston
6fc5e22882 Allow several accounts in Core::App. 2020-06-23 21:53:40 +04:00
23rd
815e26eea5 Added missed handler for MTPupdates_GetState. 2020-06-23 21:53:40 +04:00
23rd
9faf15943a Fixed build for macOS. 2020-06-23 21:53:40 +04:00
John Preston
dddd355f6c Fix language and theme writing / reading. 2020-06-23 21:53:40 +04:00
John Preston
f450f81215 Remove non-UI calls to App::main. 2020-06-23 21:53:40 +04:00
John Preston
3c4e959468 Replace observer_peer with rpl interface. 2020-06-23 21:53:40 +04:00
John Preston
b0f9ad71dd Check some more App::main()s. 2020-06-23 21:53:40 +04:00
John Preston
0ad7dcaef9 Remove MTP::MainInstance() global access point. 2020-06-23 21:53:40 +04:00
John Preston
7f09da9e32 Use MTP::Sender in Intro. 2020-06-23 21:53:39 +04:00
John Preston
0b028b959b Move updates handling MainWidget -> Api::Updates. 2020-06-23 21:53:39 +04:00
John Preston
ee43027bea Remove some usages of App::main(). 2020-06-23 21:53:39 +04:00
John Preston
ea86433be5 Remove some activeAccount() calls. 2020-06-23 21:53:39 +04:00
John Preston
598fb67cdf Remove Session::Exists() global access point. 2020-06-23 21:53:39 +04:00
John Preston
5f8d22f1f2 Remove Auth() global access point. 2020-06-23 21:53:39 +04:00
John Preston
7892ba97e6 Fix clearing storage_account files on logout. 2020-06-23 21:53:39 +04:00
John Preston
ad4afe9293 Move session data localstorage -> storage_account. 2020-06-23 21:53:39 +04:00
23rd
739a3ebe97 Removed all Auth() calls from touchbar. 2020-06-23 21:53:39 +04:00
John Preston
03dec15e8e Pass Main::Session to click handler creators. 2020-06-23 21:53:38 +04:00
John Preston
fc174f742a Move stickers code to Data::Stickers class. 2020-06-23 21:53:38 +04:00
John Preston
27af83267e Move autolock checking to Core::Application. 2020-06-23 21:53:38 +04:00
John Preston
4b354b0928 Use Main::Session in download/upload. 2020-06-23 21:53:38 +04:00
John Preston
3878a1b212 Remove some more Auth() calls. 2020-06-23 21:53:38 +04:00
John Preston
bede709f6b Fix file origin in media viewer photo preloading.
It never worked correctly, but before somehow it got worked around.

Fixes #8043.
2020-06-23 21:53:38 +04:00
John Preston
f6150d4d3e Version 2.1.13.
- Fix photos loading.
- Fix Picture-in-Picture window movement on Wayland in Linux.
2020-06-23 21:52:59 +04:00
John Preston
7624e74c8b Be sure to set correct PiP maximum size. 2020-06-23 21:50:20 +04:00
Ilya Fedin
5ac628ee4d Use startSystemMove/startSystemResize in PiP window on Wayland
Since startSystemMove is the only way to move a window on Wayland

And since custom resize works bad due to the lack of moving (resize with left and top corners works just like resize with right and bottom corners)
2020-06-23 21:45:39 +04:00
23rd
beb2e7dc19 Fixed ability to open more than one calendar in schedule box. 2020-06-23 21:39:33 +04:00
23rd
50ab655af9 Added ability to change date in schedule box with wheel. 2020-06-23 21:39:33 +04:00
23rd
425423e113 Added ability to change time in schedule box with wheel. 2020-06-23 21:39:33 +04:00
Ilya Fedin
2743aee614 Disable restart on session start explicitly 2020-06-23 21:30:44 +04:00
Ilya Fedin
06a4480520 Drop unneeded GTK methods 2020-06-23 21:29:18 +04:00
Ilya Fedin
384a71930d Don't try to focus the window when clicking on tray icon on Wayland 2020-06-23 21:28:46 +04:00
Ilya Fedin
68fde210c6 Platform::IsWayland could be used on any platform now 2020-06-23 21:24:44 +04:00
Ilya Fedin
9a65481e9d Unset QT_STYLE_OVERRIDE instead of forcing Fusion
To don't break styling on KDE
2020-06-23 21:23:47 +04:00
Ilya Fedin
0b939e72c1 Fix CI 2020-06-19 06:28:01 +04:00
Ilya Fedin
1beada6e4a Hide notification position in settings on Wayland 2020-06-19 06:28:01 +04:00
Ilya Fedin
a416debc2f core20 doesn't support i386 2020-06-18 06:46:11 +04:00
Ilya Fedin
6c52b4630c Update ffmpeg to 4.3 in snap 2020-06-18 06:46:11 +04:00
John Preston
a56ecfebeb Version 2.1.12: Fix build on macOS. 2020-06-17 22:36:53 +04:00
John Preston
3681a5559e Version 2.1.12: Update submodule. 2020-06-17 21:21:02 +04:00
John Preston
f07e4a8e5e Version 2.1.12.
- Fix sticker and video results in inline bots.
- Fix clipboard issues in Linux.
- Fix several crashes.
2020-06-17 20:38:41 +04:00
Ilya Fedin
3a91003eea Use gtk clipboard when available to avoid https://bugreports.qt.io/browse/QTBUG-56595 2020-06-17 20:34:47 +04:00
Ilya Fedin
a70cc9b956 Fix patches cache on windows and macos actions 2020-06-17 20:33:46 +04:00
Ilya Fedin
fde51018ca Update libwayland 2020-06-17 20:33:46 +04:00
Ilya Fedin
70acebc1ef Windows build can be built without updater too 2020-06-17 20:33:23 +04:00
Ilya Fedin
dbad9fa73a Use Q_OS_UNIX instead of Q_OS_LINUX since linux-specific code can be used also on *BSD/Haiku 2020-06-17 20:33:23 +04:00
Ilya Fedin
56de3194ef Never use custom notifications on Wayland since there are no positioning API 2020-06-17 20:32:50 +04:00
23rd
2559a3590d Fixed wrong Z-order of drag areas that were under schedule button. 2020-06-16 20:06:37 +03:00
John Preston
099482574e Fix sending stickers from inline bots.
Fixes #8020.
2020-06-16 20:53:44 +04:00
John Preston
1024f38944 Fix inline bot video results without documents.
Fixes #8060.
2020-06-16 19:54:23 +04:00
John Preston
99704e973b Always keep current self-userpic loaded. 2020-06-16 19:40:43 +04:00
John Preston
571a15bf92 Fix sending image from clipboard as file. 2020-06-16 19:31:50 +04:00
John Preston
cdc295c1d7 Fix build with updated submodules. 2020-06-16 19:10:39 +04:00
Zhiming Deng
b412b2141e update 2020-06-14 11:07:48 +04:00
Zhiming Deng
c18edf2f30 doc 2020-06-14 11:07:48 +04:00
Ilya Fedin
e009ac026d Update snap to core20 2020-06-09 19:01:35 +04:00
John Preston
ef08b52597 Version 2.1.11 (Linux only).
- Fix launch on old Linux systems.

Degrade OpenAL back to 1.19.1 so that it will still work on old systems.

Fixes #8005.
2020-06-08 12:23:27 +04:00
John Preston
9f6fc3a4c8 Ignore observables notification after ~Application. 2020-06-08 12:20:51 +04:00
John Preston
7757cad839 Fix crash in media viewer refresh in showPhoto. 2020-06-08 12:09:07 +04:00
John Preston
bdbcd8e540 Use Main::Session in entities parsing. 2020-06-08 12:05:17 +04:00
John Preston
7a5f4e8a01 Fix crashes in EditCaptionBox and dropdown. 2020-06-08 12:02:43 +04:00
23rd
cf40f92cd5 Fixed crash in rescheduling of scheduled until online messages.
Fixed #8016.
2020-06-08 09:56:09 +03:00
Ilya Fedin
ccce5f081d Fix running snap with XEmbed trays 2020-06-08 10:33:45 +04:00
John Preston
f50fdd0236 Version 2.1.10.
- Improve memory usage.
- Add support for full group message history export.
- Allow export of a single chat message history in JSON format.
2020-06-05 20:04:22 +04:00
23rd
d4f2b8dd0e Fixed ability to edit media with sticker.
Regression was introduced in efa4deef6a.
2020-06-05 19:46:34 +04:00
23rd
f4042d5ad5 Fixed ability to see empty header in HistoryWidget.
The problem occurs by pressing the left side of the header
when there is no second layer.
2020-06-05 19:46:33 +04:00
23rd
1c77b9c16f Changed button names in SendFilesBox.
Fixed #7988.
2020-06-05 19:46:32 +04:00
John Preston
06629ad171 Fix crash in PiP with bad video files. 2020-06-05 14:26:42 +04:00
John Preston
05df4f832b Fix crash in theme editor closing. 2020-06-05 14:00:06 +04:00
John Preston
6c2a29b83f Fix possible crash in EditCaptionBox. 2020-06-05 13:17:53 +04:00
John Preston
a586b18dfb Fix pending web pages applying.
Fixes #7091.
2020-06-05 13:03:45 +04:00
John Preston
d0994019ca Beta version 2.1.9: Fix 'edited' field export.
Export 'edited' only if the message was edited.
2020-06-04 18:17:50 +04:00
John Preston
23f94c61a4 Beta version 2.1.9.
- Several crash fixes.
2020-06-04 17:32:10 +04:00
John Preston
2b9e4a8ddf Simplify playing video tracking (and fix a crash). 2020-06-04 17:26:11 +04:00
John Preston
e1d36cfd50 Fix crash in the EditCaptionBox. 2020-06-04 17:26:11 +04:00
John Preston
fbb2bae99f Fix crash in OS X 10.10 / 10.11. 2020-06-04 13:24:38 +04:00
John Preston
6bc7fa9ef4 Fix crash in saving of a document. 2020-06-04 12:22:37 +04:00
John Preston
bf06d4d545 Fix crash in stickers box. 2020-06-04 12:16:56 +04:00
John Preston
bfafdd5b38 Fix crash in streaming+loading of a document. 2020-06-04 12:16:44 +04:00
John Preston
f581a15b6e Fix crash in PiP window. 2020-06-04 11:00:59 +04:00
John Preston
c868cd6036 Update lib_ui. 2020-06-04 10:53:59 +04:00
John Preston
9d1a4cdbfe Beta version 2.1.8: Fix build on 64 bit systems. 2020-06-03 16:18:03 +04:00
John Preston
383e6dec43 Beta version 2.1.8.
- Add support for full group message history export.
- Allow export of a single chat message history in JSON format.
2020-06-03 15:51:27 +04:00
John Preston
85904e3022 Update submodules. 2020-06-03 15:51:15 +04:00
John Preston
f88b97553e Fix crash in destructor of Data::CloudFile. 2020-06-03 13:48:11 +04:00
John Preston
63c6a1db82 Allow removing users invited by me. 2020-06-03 12:57:36 +04:00
John Preston
ca97e3c375 Add more warnings for suspicious urls. 2020-06-03 12:44:46 +04:00
John Preston
ef30c776bf Fix visual glitch in filter change from archived chat. 2020-06-03 12:31:15 +04:00
Ilya Fedin
d45e74619d Use Platform::IsWayland from lib_base 2020-06-03 11:43:55 +04:00
Ilya Fedin
d92b5eebcc Restore X error handler just like qgtk3 2020-06-03 11:31:34 +04:00
Ilya Fedin
5c6b4d95b0 Suppress warning about transient parent when opening gtk file dialog 2020-06-03 11:31:34 +04:00
Ilya Fedin
0fbec5eba1 Use QVersionNumber to compare version in native notifications 2020-06-03 11:31:34 +04:00
Ilya Fedin
ab13d9bdaf Skip empty parts in QT_QPA_PLATFORMTHEME 2020-06-03 11:31:34 +04:00
Ilya Fedin
0165e31ca7 Never use custom code for portal detecting in flatpak 2020-06-03 11:31:34 +04:00
Ilya Fedin
f1e75d809a Separate patches 2020-06-03 11:31:34 +04:00
Ilya Fedin
c776f81dc7 Add support for choosing directories via xdg-desktop-portal 2020-06-03 11:31:34 +04:00
John Preston
9fd62d3892 Add more deprecated system versions. 2020-06-02 22:26:59 +04:00
John Preston
793906ca9a Fix build on Windows. 2020-06-02 12:26:58 +04:00
23rd
35e575c2d7 Fixed build for macOS. 2020-06-01 19:28:19 +03:00
23rd
f5e84220eb Fixed crash in context menu for uploading scheduled messages. 2020-06-01 17:55:22 +03:00
Ilya Fedin
1d622fb3c0 Add patches with the fix for https://github.com/telegramdesktop/tdesktop/issues/6645 2020-06-01 18:43:42 +04:00
Nicholas Guriev
d8d3dda2f3 Fix little typo in theme names generator 2020-06-01 18:26:16 +04:00
Ilya Fedin
e098922a4b Add Platform::AutostartSupported 2020-06-01 18:25:21 +04:00
Ilya Fedin
413ddf285e Fix crash in gtk file dialog on Wayland 2020-06-01 18:22:53 +04:00
Ilya Fedin
7ac78be984 Load gtk2 even on Wayland 2020-06-01 18:22:53 +04:00
Ilya Fedin
4c546156da Remove duplicate log line 2020-06-01 18:22:53 +04:00
Ilya Fedin
db528b39e1 Fix macOS cache validating
macOS action has runner version in the workdir path, it should be a part of the cache key
2020-06-01 18:21:52 +04:00
Ilya Fedin
586744c112 Apply sway fixes to the PiP and export windows too 2020-06-01 18:21:30 +04:00
Ilya Fedin
7b106761be Remove cache from snap action since it works not so good 2020-06-01 18:19:34 +04:00
Ilya Fedin
8fb7f0fc73 Use TDESKTOP_USE_GTK_FILE_DIALOG in snap 2020-06-01 18:19:34 +04:00
Ilya Fedin
10b169f9f6 Make not supported errors static 2020-06-01 18:19:34 +04:00
Ilya Fedin
c83b8d4043 Fix naming of static variables 2020-06-01 18:19:34 +04:00
Ilya Fedin
1fc2b19c94 Add Cinnamon sound settings command 2020-06-01 18:19:34 +04:00
Ilya Fedin
fb97940cac Rename SandboxAutostart to PortalAutostart 2020-06-01 18:19:34 +04:00
Ilya Fedin
16c38b54e2 Rename InSandbox to InFlatpak 2020-06-01 18:19:34 +04:00
Ilya Fedin
7f29f57c3d Use custom gtk file dialog only on gtk-based DEs 2020-06-01 18:19:34 +04:00
Ilya Fedin
1fb1d57a27 Get system icon theme on gtk-based DEs 2020-06-01 18:19:34 +04:00
Ilya Fedin
47d7bd95ae Add a method to check if gtk integration is forced 2020-06-01 18:19:34 +04:00
John Preston
368eeaf754 Improve single chat export progress display. 2020-06-01 18:09:34 +04:00
John Preston
1686eb394d Add support for JSON single-chat export. 2020-06-01 18:09:34 +04:00
John Preston
02586ebe4b Allow export of just-converted supergroup. 2020-06-01 18:09:34 +04:00
John Preston
8f80c19ae1 Merge old group with supergroup history in export. 2020-06-01 18:09:34 +04:00
John Preston
1598165e2b Closed alpha version 2.1.7.4. 2020-06-01 18:09:34 +04:00
John Preston
f4cd84c313 Fix crash in stickers. 2020-06-01 18:09:34 +04:00
John Preston
9b574e497d Closed alpha version 2.1.7.3. 2020-06-01 18:09:34 +04:00
John Preston
6660338ccc Fix crash in sticker sets without a thumbnail. 2020-06-01 18:09:34 +04:00
John Preston
423ea5b499 Fix crash on invalid image data. 2020-06-01 18:09:34 +04:00
John Preston
4695ebae6e Fix crash in sticker set parsing. 2020-06-01 18:09:34 +04:00
John Preston
aaa4db7b27 Fix a crash in custom notifications. 2020-06-01 18:09:34 +04:00
John Preston
0965b06fa3 Closed alpha version 2.1.7.2. 2020-06-01 18:09:34 +04:00
Ilya Fedin
be96bf2812 Set parent for dialogs only on Wayland 2020-06-01 18:09:34 +04:00
John Preston
b7aa60bedf Fix build for Linux. 2020-06-01 18:09:34 +04:00
John Preston
d5b3fa017b Fix build for macOS. 2020-06-01 18:09:34 +04:00
John Preston
36fbdfb380 Simplify Image, remove ImageSource. 2020-06-01 18:09:33 +04:00
John Preston
d0c78eaddd Leave only one image source type. 2020-06-01 18:09:33 +04:00
John Preston
6513422e40 Remove legacy image-related code. 2020-06-01 18:09:33 +04:00
John Preston
f066e0f05a Use Data::CloudImage for userpics. 2020-06-01 18:09:33 +04:00
John Preston
249f7813c1 Don't hold session pointer in Data::CloudImage. 2020-06-01 18:09:33 +04:00
John Preston
29a498b959 Use Data::CloudImage for location thumbnails. 2020-06-01 18:09:33 +04:00
John Preston
ae9ed820ee Fix sticker set icons display. 2020-06-01 18:09:33 +04:00
John Preston
803593cd8d Change Stickers::Set from value to object type. 2020-06-01 18:09:33 +04:00
John Preston
897e432f40 Use CloudImageView in the inline bot thumbnails. 2020-06-01 18:09:33 +04:00
John Preston
50e0c3ee4d Fix preloading in media viewer. 2020-06-01 18:09:33 +04:00
John Preston
056945d9f5 Remove legacy image creation methods. 2020-06-01 18:09:32 +04:00
John Preston
a9b70a7d63 Closed alpha 2.1.7.1: Fix build for Xcode. 2020-06-01 18:09:32 +04:00
John Preston
6dabd87df3 Closed alpha version 2.1.7.1. 2020-06-01 18:09:32 +04:00
John Preston
b35b6c4449 Fix saving cache from InMemoryLocation. 2020-06-01 18:09:32 +04:00
John Preston
74ef8104a7 Fix photo edit caption box, remove 's' size. 2020-06-01 18:09:32 +04:00
John Preston
af0eebb6f1 Remove debug inline bot results marks. 2020-06-01 18:09:32 +04:00
John Preston
dbb46ce9b0 Let [Photo|Document]Media outlive message view. 2020-06-01 18:09:32 +04:00
John Preston
700d3db4cc Correctly unload heavy parts on quit. 2020-06-01 18:09:32 +04:00
John Preston
64cf0e1a44 Fix caching of sent photos and document previews. 2020-06-01 18:09:32 +04:00
John Preston
7ad660a0e7 Allow photos not have some of the thumbnails. 2020-06-01 18:09:32 +04:00
John Preston
e27d2bc2d5 Move photo data to Data::PhotoMedia. 2020-06-01 18:09:32 +04:00
John Preston
24fed8105c Fix stickers panel on Retina screens. 2020-06-01 18:09:32 +04:00
John Preston
9ce59730ff Collect local DocumentMedia data. 2020-06-01 18:09:32 +04:00
John Preston
3f26fc9f55 Allow WebDocument video thumbnails. 2020-06-01 18:09:32 +04:00
John Preston
0834920db8 Fix sending of video-thumbed GIFs from panel. 2020-06-01 18:09:32 +04:00
John Preston
f4ed2c26ba Save video thumbnail location to local storage. 2020-06-01 18:09:32 +04:00
John Preston
c63e2c01ac Use video thumbnail in media preview. 2020-06-01 18:09:31 +04:00
John Preston
c61f3a0aba Fix sending of thumbnailed inline result GIFs. 2020-06-01 18:09:31 +04:00
John Preston
3c9ca2eb94 Load and show video thumbnails in the panel. 2020-06-01 18:09:31 +04:00
John Preston
33c1c48ad9 Update API scheme to layer 114. 2020-06-01 18:09:31 +04:00
John Preston
a27aea3887 Allow retrying of updates build preparing. 2020-06-01 18:09:31 +04:00
John Preston
ea4044e38c Use TgVoip interface instead of VoIPController. 2020-06-01 18:09:31 +04:00
John Preston
c967a72dcb Save frame in GIFs panel. 2020-06-01 18:09:31 +04:00
John Preston
7d386b164b Save a frame in stickers panel. 2020-06-01 18:09:31 +04:00
John Preston
ccbbf6f5f3 Always download GIFs in the panel.
Fixes #6981.
2020-06-01 18:09:31 +04:00
John Preston
9725d4272e Clear DocumentMedia in sticker panel. 2020-06-01 18:09:31 +04:00
John Preston
eb75859dc0 Cache last frame of stickers panel footer icons. 2020-06-01 18:09:31 +04:00
John Preston
ad5507f2c8 Clear DocumentMedia in media overview. 2020-06-01 18:09:31 +04:00
John Preston
58f82620e0 Simplify media overview layouts. 2020-06-01 18:09:31 +04:00
John Preston
053eace154 Prepare overview layouts for media clearing. 2020-06-01 18:09:31 +04:00
John Preston
d64014c995 Clear DocumentMedia in ReplyPreview. 2020-06-01 18:09:31 +04:00
John Preston
44ec55b6a8 Clear DocumentMedia in links overview. 2020-06-01 18:09:31 +04:00
John Preston
9dba723643 Better DocumentMedia management in BackgroundBox. 2020-06-01 18:09:31 +04:00
John Preston
97a82762ef Fix build with MSVC 16.6.0. 2020-06-01 18:09:31 +04:00
John Preston
1542311d89 Preload documents in media viewer. 2020-06-01 18:09:31 +04:00
John Preston
fb322b5fc5 Use empty Storage::Cache::Key as nullopt. 2020-06-01 18:09:31 +04:00
John Preston
581a21dbd9 Use Media::Streaming in EditCaptionBox. 2020-06-01 18:09:31 +04:00
John Preston
3d431a27cb Improve inline thumbnail usage in PiP player. 2020-06-01 18:09:31 +04:00
John Preston
cbb9657044 Fix download task finalizing. 2020-06-01 18:09:30 +04:00
John Preston
3797753d16 Support different location types for thumbnails. 2020-06-01 18:09:30 +04:00
John Preston
37aabc0da9 Add generic DownloadLocation and ImageLocation. 2020-06-01 18:09:30 +04:00
John Preston
956c3af0ae Start DocumentData::thumbnail move to DocumentMedia. 2020-06-01 18:09:30 +04:00
John Preston
1329870c8e Fix build on macOS. 2020-06-01 18:09:30 +04:00
John Preston
ff6365ec72 Fix crash in still downloaded ~DocumentData. 2020-06-01 18:09:30 +04:00
John Preston
1e9c79ca85 Move automaticLoad() to DocumentMedia. 2020-06-01 18:09:30 +04:00
John Preston
40f12a2584 Keep document byte data only in DocumentMedia. 2020-06-01 18:09:30 +04:00
John Preston
97bab388ea Use rpl for file download progress notifications. 2020-06-01 18:09:30 +04:00
John Preston
bf616036b3 Check loaded status through DocumentMedia if possible. 2020-06-01 18:09:30 +04:00
John Preston
669b79588e Remove FilePathResolve::SaveFromData. 2020-06-01 18:09:30 +04:00
John Preston
33f4946242 Start using document bytes from DocumentMedia. 2020-06-01 18:09:30 +04:00
John Preston
888e42df34 Remove data_document_good_thumbnail module. 2020-06-01 18:09:30 +04:00
John Preston
70c79eb6bd Move sticker image to DocumentMedia. 2020-06-01 18:09:30 +04:00
John Preston
bdd3c51ab8 Move inline thumbnail image to DocumentMedia. 2020-06-01 18:09:30 +04:00
John Preston
6ca43153bb Improve clearing of DocumentMedia. 2020-06-01 18:09:29 +04:00
John Preston
7db53599e8 Use Data::DocumentMedia to store good thumbnails. 2020-06-01 18:09:29 +04:00
John Preston
61647275e8 Optimize image destruction.
No need to call _source->unload(), it leads to saving to PNG.
2020-06-01 18:09:29 +04:00
Ilya Fedin
a37138aa52 Fix signature key errors in snap action 2020-06-01 15:24:35 +04:00
Ilya Fedin
1504136828 Don't spam logs if there are no dbus 2020-05-26 07:24:18 +04:00
Ilya Fedin
c12356a032 Disable unneeded alsa dependency in ffmpeg 2020-05-25 10:34:12 +04:00
Ilya Fedin
126ed6e6e3 Fix path to compose file 2020-05-25 10:34:12 +04:00
Ilya Fedin
fa4236e9ea Add support for DESKTOP_APP_USE_PACKAGED on macOS 2020-05-25 10:29:40 +04:00
Ilya Fedin
b19dcf0653 Add possibility to control external upater flag with a config in /etc 2020-05-25 10:27:48 +04:00
Ilya Fedin
77d1f64e0e Disable fallback session management 2020-05-25 09:31:52 +04:00
Ilya Fedin
3479a4ec59 Add parent, minimum and maximum size to notifications 2020-05-25 09:29:15 +04:00
Ilya Fedin
bdf28370f9 Fix call window size on Sway 2020-05-25 09:29:15 +04:00
Ilya Fedin
cd81fc6727 Don't lose -freetype argument on restart 2020-05-25 09:26:49 +04:00
718 changed files with 43532 additions and 31238 deletions

View File

@@ -95,7 +95,7 @@ jobs:
libgtk2.0-dev libice-dev libsm-dev libicu-dev libdrm-dev dh-autoreconf \
autoconf automake build-essential libxml2-dev libass-dev libfreetype6-dev \
libgpac-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev \
libvorbis-dev libxcb1-dev libxcb-image0-dev libxcb-shm0-dev \
libvorbis-dev libxcb1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-screensaver0-dev \
libxcb-xfixes0-dev libxcb-keysyms1-dev libxcb-icccm4-dev libatspi2.0-dev \
libxcb-render-util0-dev libxcb-util0-dev libxcb-xkb-dev libxrender-dev \
libasound-dev libpulse-dev libxcb-sync0-dev libxcb-randr0-dev libegl1-mesa-dev \
@@ -157,7 +157,7 @@ jobs:
- name: Opus cache.
id: cache-opus
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/opus
key: ${{ runner.OS }}-opus-${{ env.CACHE_KEY }}
@@ -202,7 +202,7 @@ jobs:
- name: FFmpeg cache.
id: cache-ffmpeg
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/ffmpeg-cache
key: ${{ runner.OS }}-ffmpeg-${{ env.CACHE_KEY }}
@@ -221,6 +221,7 @@ jobs:
--disable-autodetect \
--disable-everything \
--disable-neon \
--disable-alsa \
--disable-iconv \
--enable-libopus \
--enable-vaapi \
@@ -355,7 +356,7 @@ jobs:
- name: OpenSSL cache.
id: cache-openssl
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/openssl-cache
key: ${{ runner.OS }}-${{ env.OPENSSL_VER }}-${{ env.CACHE_KEY }}
@@ -368,7 +369,7 @@ jobs:
git clone -b OpenSSL_${OPENSSL_VER}-stable --depth=1 \
$GIT/openssl/openssl $opensslDir
cd $opensslDir
./config --prefix="$OPENSSL_PREFIX"
./config --prefix="$OPENSSL_PREFIX" no-tests
make -j$(nproc)
sudo make DESTDIR="$LibrariesPath/openssl-cache" install_sw
cd ..
@@ -378,36 +379,43 @@ jobs:
cd $LibrariesPath
sudo cp -R openssl-cache/. /
- name: Libwayland.
run: |
cd $LibrariesPath
git clone -b 1.18.0 https://gitlab.freedesktop.org/wayland/wayland
cd wayland
./autogen.sh \
--enable-static \
--disable-documentation \
--disable-dtd-validation
make -j$(nproc)
sudo make install
cd ..
rm -rf wayland
- name: Libxkbcommon.
run: |
cd $LibrariesPath
git clone -b xkbcommon-0.8.4 --depth=1 $GIT/xkbcommon/libxkbcommon.git
cd libxkbcommon
./autogen.sh
./autogen.sh \
--disable-docs \
--disable-wayland \
--with-xkb-config-root=/usr/share/X11/xkb \
--with-x-locale-root=/usr/share/X11/locale
make -j$(nproc)
sudo make install
cd ..
rm -rf libxkbcommon
- name: Libwayland.
run: |
cd $LibrariesPath
git clone -b 1.16 https://gitlab.freedesktop.org/wayland/wayland
cd wayland
./autogen.sh --enable-static --disable-documentation --disable-dtd-validation
make -j$(nproc)
sudo make install
cd ..
rm -rf wayland
- name: Qt 5.12.8 cache.
id: cache-qt
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/qt-cache
key: ${{ runner.OS }}-qt-${{ env.CACHE_KEY }}-${{ hashFiles('**/qtbase_5_12_8.diff') }}
key: ${{ runner.OS }}-qt-${{ env.CACHE_KEY }}-${{ hashFiles('**/qt*_5_12_8/*') }}
- name: Qt 5.12.8 build.
if: steps.cache-qt.outputs.cache-hit != 'true'
run: |
@@ -418,8 +426,11 @@ jobs:
perl init-repository --module-subset=qtbase,qtwayland,qtimageformats,qtsvg,qtx11extras
git submodule update qtbase qtwayland qtimageformats qtsvg qtx11extras
cd qtbase
git apply ../../patches/qtbase_${QT}.diff
cd ../
find ../../patches/qtbase_${QT} -type f -print0 | sort -z | xargs -r0 git apply
cd ..
cd qtwayland
find ../../patches/qtwayland_${QT} -type f -print0 | sort -z | xargs -r0 git apply
cd ..
./configure -prefix "$QT_PREFIX" \
-release \
@@ -450,7 +461,7 @@ jobs:
- name: Breakpad cache.
id: cache-breakpad
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/breakpad-cache
key: ${{ runner.OS }}-breakpad-${{ env.CACHE_KEY }}

View File

@@ -88,6 +88,7 @@ jobs:
echo $MIN_MAC >> CACHE_KEY.txt
echo $PREFIX >> CACHE_KEY.txt
echo $MANUAL_CACHING >> CACHE_KEY.txt
echo "$GITHUB_WORKSPACE" >> CACHE_KEY.txt
if [ "$AUTO_CACHING" == "1" ]; then
thisFile=$REPO_NAME/.github/workflows/mac.yml
echo `md5 -q $thisFile` >> CACHE_KEY.txt
@@ -132,7 +133,7 @@ jobs:
- name: OpenSSL cache.
id: cache-openssl
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/openssl_${{ env.OPENSSL_VER }}
key: ${{ runner.OS }}-${{ env.OPENSSL_VER }}-${{ env.CACHE_KEY }}
@@ -146,6 +147,7 @@ jobs:
git checkout OpenSSL_"$OPENSSL_VER"-stable
./Configure \
--prefix=$PREFIX \
no-tests \
darwin64-x86_64-cc \
-static \
$MIN_MAC
@@ -162,7 +164,7 @@ jobs:
- name: Opus cache.
id: cache-opus
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/opus
key: ${{ runner.OS }}-opus-${{ env.CACHE_KEY }}
@@ -184,7 +186,7 @@ jobs:
- name: Libiconv cache.
id: cache-libiconv
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/${{ env.LIBICONV_VER }}
key: ${{ runner.OS }}-${{ env.LIBICONV_VER }}-${{ env.CACHE_KEY }}
@@ -205,7 +207,7 @@ jobs:
- name: FFmpeg cache.
id: cache-ffmpeg
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/ffmpeg-cache
key: ${{ runner.OS }}-ffmpeg-${{ env.CACHE_KEY }}
@@ -361,7 +363,7 @@ jobs:
- name: Crashpad cache.
id: cache-crashpad
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/crashpad
key: ${{ runner.OS }}-crashpad-${{ env.CACHE_KEY }}-${{ hashFiles('**/crashpad.diff') }}-${{ hashFiles('**/mini_chromium.diff') }}
@@ -400,10 +402,10 @@ jobs:
- name: Qt 5.12.8 cache.
id: cache-qt
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/qt-cache
key: ${{ runner.OS }}-qt-${{ env.CACHE_KEY }}-${{ hashFiles('**/qtbase_5_12_8.diff') }}
key: ${{ runner.OS }}-qt-${{ env.CACHE_KEY }}-${{ hashFiles('**/qtbase_5_12_8/*') }}
- name: Use cached Qt 5.12.8.
if: steps.cache-qt.outputs.cache-hit == 'true'
run: |
@@ -423,7 +425,7 @@ jobs:
git submodule update qtbase
git submodule update qtimageformats
cd qtbase
git apply ../../patches/qtbase_$QT.diff
find ../../patches/qtbase_$QT -type f -print0 | sort -z | xargs -0 git apply
cd ..
./configure \

View File

@@ -12,7 +12,6 @@ on:
- '!.github/workflows/snap.yml'
- 'Telegram/build/**'
- 'Telegram/Patches/**'
- '!Telegram/Patches/ffmpeg.diff'
- 'Telegram/Resources/uwp/**'
- 'Telegram/Resources/winrc/**'
- 'Telegram/SourceFiles/platform/win/**'
@@ -31,7 +30,6 @@ on:
- '!.github/workflows/snap.yml'
- 'Telegram/build/**'
- 'Telegram/Patches/**'
- '!Telegram/Patches/ffmpeg.diff'
- 'Telegram/Resources/uwp/**'
- 'Telegram/Resources/winrc/**'
- 'Telegram/SourceFiles/platform/win/**'
@@ -43,13 +41,11 @@ on:
jobs:
linux:
name: Ubuntu 18.04
runs-on: ubuntu-18.04
name: Ubuntu 20.04
runs-on: ubuntu-20.04
env:
UPLOAD_ARTIFACT: "false"
ONLY_CACHE: "false"
MANUAL_CACHING: "5"
steps:
- name: Clone.
@@ -59,56 +55,17 @@ jobs:
- name: First set up.
run: |
# Workaround for permanent problems with third-party repository keys
sudo rm -rf /etc/apt/sources.list.d/*
sudo apt-get update
sudo apt-get install gcc-8 g++-8 -y
sudo snap install --classic snapcraft
# Workaround for snapcraft
# See https://forum.snapcraft.io/t/13258
sudo chown root:root /
md5() {
md5cache=$(md5sum $1.txt | cut -c -32)
echo ::set-env name=$1::$md5cache
}
keyFor() {
keyName="${1^^}_CACHE_KEY"
awk -v RS="" -v ORS="\n\n" '/^ '"$1"':/' snap/snapcraft.yaml > $keyName.txt
md5 $keyName
}
snap run snapcraft --version > CACHE_KEY.txt
gcc-8 --version >> CACHE_KEY.txt
echo $MANUAL_CACHING >> CACHE_KEY.txt
md5 CACHE_KEY
keyFor cmake
keyFor ffmpeg
- name: CMake cache.
id: cache-cmake
uses: actions/cache@v1
with:
path: parts/cmake
key: ${{ runner.OS }}-cmake-${{ env.CACHE_KEY }}-${{ env.CMAKE_CACHE_KEY }}
- name: CMake build.
if: steps.cache-cmake.outputs.cache-hit != 'true'
run: sudo snap run snapcraft build --destructive-mode cmake
- name: FFmpeg cache.
id: cache-ffmpeg
uses: actions/cache@v1
with:
path: parts/ffmpeg
key: ${{ runner.OS }}-ffmpeg-${{ env.CACHE_KEY }}-${{ env.FFMPEG_CACHE_KEY }}
- name: FFmpeg build.
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
run: sudo snap run snapcraft build --destructive-mode ffmpeg
- name: Telegram Desktop snap build.
if: env.ONLY_CACHE == 'false'
run: sudo snap run snapcraft --destructive-mode
- name: Move artifact.
@@ -126,8 +83,3 @@ jobs:
with:
name: ${{ env.ARTIFACT_NAME }}
path: artifact
- name: Remove unneeded directories for cache.
run: |
sudo rm -rf parts/*/{build,src,ubuntu}
sudo rm -rf parts/*/state/{stage,prime}

View File

@@ -133,7 +133,7 @@ jobs:
- name: OpenSSL cache.
id: cache-openssl
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/openssl_${{ env.OPENSSL_VER }}
key: ${{ runner.OS }}-${{ env.CACHE_KEY }}-${{ env.OPENSSL_VER }}
@@ -146,7 +146,7 @@ jobs:
git clone %GIT%/openssl/openssl.git openssl_%OPENSSL_VER%
cd openssl_%OPENSSL_VER%
git checkout OpenSSL_%OPENSSL_VER%-stable
perl Configure no-shared debug-VC-WIN32
perl Configure no-shared no-tests debug-VC-WIN32
nmake
mkdir out32.dbg
move libcrypto.lib out32.dbg
@@ -177,7 +177,7 @@ jobs:
- name: OpenAL Soft cache.
id: cache-openal
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/openal-soft
key: ${{ runner.OS }}-openal-soft-${{ env.CACHE_KEY }}
@@ -201,7 +201,7 @@ jobs:
- name: Breakpad cache.
id: cache-breakpad
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/breakpad
key: ${{ runner.OS }}-breakpad-${{ env.CACHE_KEY }}-${{ hashFiles('**/breakpad.diff') }}
@@ -250,7 +250,7 @@ jobs:
- name: Opus cache.
id: cache-opus
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/opus
key: ${{ runner.OS }}-opus-${{ env.CACHE_KEY }}
@@ -269,7 +269,7 @@ jobs:
- name: FFmpeg cache.
id: cache-ffmpeg
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/ffmpeg
key: ${{ runner.OS }}-ffmpeg-${{ env.CACHE_KEY }}-2-${{ hashFiles('**/build_ffmpeg_win.sh') }}
@@ -291,10 +291,10 @@ jobs:
- name: Qt 5.12.8 cache.
id: cache-qt
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/Qt-5.12.8
key: ${{ runner.OS }}-qt-${{ env.CACHE_KEY }}-${{ hashFiles('**/qtbase_5_12_8.diff') }}
key: ${{ runner.OS }}-qt-${{ env.CACHE_KEY }}-${{ hashFiles('**/qtbase_5_12_8/*') }}
- name: Configure Qt 5.12.8.
if: steps.cache-qt.outputs.cache-hit != 'true'
shell: cmd
@@ -308,7 +308,7 @@ jobs:
git submodule update qtbase
git submodule update qtimageformats
cd qtbase
git apply ../../patches/qtbase_%QT%.diff
for /r %%i in (..\..\patches\qtbase_%QT%\*) do git apply %%i
cd ..
SET SSL=%LibrariesPath%\openssl_1_1_1
@@ -379,7 +379,6 @@ jobs:
cd %REPO_NAME%\out\Debug
mkdir artifact
move Telegram.exe artifact/
move Updater.exe artifact/
- uses: actions/upload-artifact@master
name: Upload artifact.
if: env.UPLOAD_ARTIFACT == 'true'

2
.gitmodules vendored
View File

@@ -3,7 +3,7 @@
url = https://github.com/telegramdesktop/libtgvoip
[submodule "Telegram/ThirdParty/variant"]
path = Telegram/ThirdParty/variant
url = https://github.com/mapbox/variant
url = https://github.com/desktop-app/variant.git
[submodule "Telegram/ThirdParty/GSL"]
path = Telegram/ThirdParty/GSL
url = https://github.com/Microsoft/GSL.git

View File

@@ -72,9 +72,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)
@@ -106,6 +104,7 @@ PRIVATE
tdesktop::lib_mtproto
tdesktop::lib_scheme
tdesktop::lib_export
tdesktop::lib_tgvoip
desktop-app::lib_base
desktop-app::lib_crl
desktop-app::lib_ui
@@ -122,29 +121,64 @@ 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
)
# 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)
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)
target_include_directories(Telegram
PRIVATE
${WAYLAND_CLIENT_INCLUDE_DIRS}
)
endif()
if (DESKTOP_APP_USE_PACKAGED)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
if (LINUX)
if (DESKTOP_APP_USE_PACKAGED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(XCB_SCREENSAVER REQUIRED IMPORTED_TARGET xcb-screensaver)
pkg_check_modules(XCB REQUIRED IMPORTED_TARGET xcb)
target_link_libraries(Telegram
PRIVATE
Threads::Threads
)
target_link_libraries(Telegram
PRIVATE
PkgConfig::XCB_SCREENSAVER
PkgConfig::XCB
)
else()
target_link_static_libraries(Telegram PRIVATE xcb-screensaver)
target_link_libraries(Telegram PRIVATE xcb)
endif()
endif()
if (LINUX AND NOT TDESKTOP_DISABLE_GTK_INTEGRATION)
find_package(PkgConfig REQUIRED)
target_compile_options(Telegram PRIVATE -Wno-register)
if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY)
pkg_check_modules(X11 REQUIRED IMPORTED_TARGET x11)
pkg_check_modules(GOBJECT2 REQUIRED IMPORTED_TARGET gobject-2.0)
pkg_check_modules(GLIB2 REQUIRED IMPORTED_TARGET glib-2.0)
pkg_check_modules(GTK3 REQUIRED IMPORTED_TARGET gtk+-3.0)
target_link_libraries(Telegram
PRIVATE
PkgConfig::X11
PkgConfig::GOBJECT2
PkgConfig::GLIB2
PkgConfig::GTK3
)
else()
pkg_search_module(GTK REQUIRED gtk+-2.0 gtk+-3.0)
target_link_libraries(Telegram
PRIVATE
X11
gobject-2.0
glib-2.0
)
target_include_directories(Telegram PRIVATE ${GTK_INCLUDE_DIRS})
endif()
endif()
target_precompile_headers(Telegram PRIVATE ${src_loc}/stdafx.h)
@@ -152,12 +186,21 @@ nice_target_sources(Telegram ${src_loc}
PRIVATE
${style_files}
api/api_bot.cpp
api/api_bot.h
api/api_chat_filters.cpp
api/api_chat_filters.h
api/api_common.h
api/api_editing.cpp
api/api_editing.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
api/api_send_progress.h
api/api_sending.cpp
api/api_sending.h
api/api_sensitive_content.cpp
@@ -166,6 +209,8 @@ PRIVATE
api/api_single_message_search.h
api/api_text_entities.cpp
api/api_text_entities.h
api/api_updates.cpp
api/api_updates.h
boxes/filters/edit_filter_box.cpp
boxes/filters/edit_filter_box.h
boxes/filters/edit_filter_chats_list.cpp
@@ -264,6 +309,9 @@ 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
@@ -290,14 +338,16 @@ PRIVATE
chat_helpers/message_field.h
chat_helpers/spellchecker_common.cpp
chat_helpers/spellchecker_common.h
chat_helpers/stickers.cpp
chat_helpers/stickers.h
chat_helpers/stickers_emoji_image_loader.cpp
chat_helpers/stickers_emoji_image_loader.h
chat_helpers/stickers_emoji_pack.cpp
chat_helpers/stickers_emoji_pack.h
chat_helpers/stickers_dice_pack.cpp
chat_helpers/stickers_dice_pack.h
chat_helpers/stickers_list_widget.cpp
chat_helpers/stickers_list_widget.h
chat_helpers/stickers_lottie.cpp
chat_helpers/stickers_lottie.h
chat_helpers/tabbed_panel.cpp
chat_helpers/tabbed_panel.h
chat_helpers/tabbed_section.cpp
@@ -326,7 +376,6 @@ PRIVATE
core/launcher.h
core/local_url_handlers.cpp
core/local_url_handlers.h
core/media_active_cache.h
core/mime_type.cpp
core/mime_type.h
core/sandbox.cpp
@@ -340,6 +389,10 @@ PRIVATE
core/utils.cpp
core/utils.h
core/version.h
data/stickers/data_stickers_set.cpp
data/stickers/data_stickers_set.h
data/stickers/data_stickers.cpp
data/stickers/data_stickers.h
data/data_abstract_structure.cpp
data/data_abstract_structure.h
data/data_auto_download.cpp
@@ -348,18 +401,22 @@ PRIVATE
data/data_chat.h
data/data_chat_filters.cpp
data/data_chat_filters.h
data/data_changes.cpp
data/data_changes.h
data/data_channel.cpp
data/data_channel.h
data/data_channel_admins.cpp
data/data_channel_admins.h
data/data_cloud_file.cpp
data/data_cloud_file.h
data/data_cloud_themes.cpp
data/data_cloud_themes.h
data/data_countries.cpp
data/data_countries.h
data/data_document.cpp
data/data_document.h
data/data_document_good_thumbnail.cpp
data/data_document_good_thumbnail.h
data/data_document_media.cpp
data/data_document_media.h
data/data_drafts.cpp
data/data_drafts.h
data/data_folder.cpp
@@ -390,10 +447,14 @@ PRIVATE
data/data_peer_values.h
data/data_photo.cpp
data/data_photo.h
data/data_photo_media.cpp
data/data_photo_media.h
data/data_poll.cpp
data/data_poll.h
data/data_pts_waiter.cpp
data/data_pts_waiter.h
data/data_reply_preview.cpp
data/data_reply_preview.h
data/data_search_controller.cpp
data/data_search_controller.h
data/data_session.cpp
@@ -438,6 +499,8 @@ PRIVATE
dialogs/dialogs_search_from_controllers.h
dialogs/dialogs_widget.cpp
dialogs/dialogs_widget.h
export/export_manager.cpp
export/export_manager.h
export/view/export_view_content.cpp
export/view/export_view_content.h
export/view/export_view_panel_controller.cpp
@@ -519,6 +582,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
@@ -653,10 +718,12 @@ PRIVATE
main/main_account.h
main/main_app_config.cpp
main/main_app_config.h
main/main_domain.cpp
main/main_domain.h
main/main_session.cpp
main/main_session.h
main/main_settings.cpp
main/main_settings.h
main/main_session_settings.cpp
main/main_session_settings.h
media/audio/media_audio.cpp
media/audio/media_audio.h
media/audio/media_audio_capture.cpp
@@ -671,6 +738,8 @@ PRIVATE
media/audio/media_audio_track.h
media/audio/media_child_ffmpeg_loader.cpp
media/audio/media_child_ffmpeg_loader.h
media/audio/media_openal_functions.cpp
media/audio/media_openal_functions.h
media/clip/media_clip_check_streaming.cpp
media/clip/media_clip_check_streaming.h
media/clip/media_clip_ffmpeg.cpp
@@ -736,8 +805,6 @@ PRIVATE
mtproto/connection_tcp.cpp
mtproto/connection_tcp.h
mtproto/core_types.h
mtproto/dc_options.cpp
mtproto/dc_options.h
mtproto/dedicated_file_loader.cpp
mtproto/dedicated_file_loader.h
mtproto/facade.cpp
@@ -754,6 +821,7 @@ PRIVATE
mtproto/type_utils.h
overview/overview_layout.cpp
overview/overview_layout.h
overview/overview_layout_delegate.h
passport/passport_encryption.cpp
passport/passport_encryption.h
passport/passport_form_controller.cpp
@@ -782,6 +850,8 @@ PRIVATE
platform/linux/linux_gdk_helper.h
platform/linux/linux_libs.cpp
platform/linux/linux_libs.h
platform/linux/linux_xlib_helper.cpp
platform/linux/linux_xlib_helper.h
platform/linux/file_utilities_linux.cpp
platform/linux/file_utilities_linux.h
platform/linux/launcher_linux.cpp
@@ -792,11 +862,11 @@ PRIVATE
platform/linux/notifications_manager_linux.h
platform/linux/specific_linux.cpp
platform/linux/specific_linux.h
platform/linux/window_title_linux.h
platform/mac/file_utilities_mac.mm
platform/mac/file_utilities_mac.h
platform/mac/launcher_mac.mm
platform/mac/launcher_mac.h
platform/mac/mac_iconv_helper.c
platform/mac/main_window_mac.mm
platform/mac/main_window_mac.h
platform/mac/notifications_manager_mac.mm
@@ -807,8 +877,24 @@ PRIVATE
platform/mac/specific_mac_p.h
platform/mac/window_title_mac.mm
platform/mac/window_title_mac.h
platform/mac/mac_touchbar.h
platform/mac/mac_touchbar.mm
platform/mac/touchbar/items/mac_formatter_item.h
platform/mac/touchbar/items/mac_formatter_item.mm
platform/mac/touchbar/items/mac_pinned_chats_item.h
platform/mac/touchbar/items/mac_pinned_chats_item.mm
platform/mac/touchbar/items/mac_scrubber_item.h
platform/mac/touchbar/items/mac_scrubber_item.mm
platform/mac/touchbar/mac_touchbar_audio.h
platform/mac/touchbar/mac_touchbar_audio.mm
platform/mac/touchbar/mac_touchbar_common.h
platform/mac/touchbar/mac_touchbar_common.mm
platform/mac/touchbar/mac_touchbar_controls.h
platform/mac/touchbar/mac_touchbar_controls.mm
platform/mac/touchbar/mac_touchbar_main.h
platform/mac/touchbar/mac_touchbar_main.mm
platform/mac/touchbar/mac_touchbar_manager.h
platform/mac/touchbar/mac_touchbar_manager.mm
platform/mac/touchbar/mac_touchbar_media_view.h
platform/mac/touchbar/mac_touchbar_media_view.mm
platform/win/audio_win.cpp
platform/win/audio_win.h
platform/win/file_utilities_win.cpp
@@ -871,6 +957,10 @@ PRIVATE
settings/settings_privacy_controllers.h
settings/settings_privacy_security.cpp
settings/settings_privacy_security.h
storage/details/storage_file_utilities.cpp
storage/details/storage_file_utilities.h
storage/details/storage_settings_scheme.cpp
storage/details/storage_settings_scheme.h
storage/download_manager_mtproto.cpp
storage/download_manager_mtproto.h
storage/file_download.cpp
@@ -889,8 +979,14 @@ PRIVATE
storage/serialize_common.h
storage/serialize_document.cpp
storage/serialize_document.h
storage/serialize_peer.cpp
storage/serialize_peer.h
storage/storage_account.cpp
storage/storage_account.h
storage/storage_cloud_blob.cpp
storage/storage_cloud_blob.h
storage/storage_domain.cpp
storage/storage_domain.h
storage/storage_facade.cpp
storage/storage_facade.h
# storage/storage_feed_messages.cpp
@@ -923,8 +1019,8 @@ PRIVATE
ui/image/image.h
ui/image/image_location.cpp
ui/image/image_location.h
ui/image/image_source.cpp
ui/image/image_source.h
ui/image/image_location_factory.cpp
ui/image/image_location_factory.h
ui/widgets/continuous_sliders.cpp
ui/widgets/continuous_sliders.h
ui/widgets/discrete_sliders.cpp
@@ -971,6 +1067,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
@@ -989,6 +1086,8 @@ PRIVATE
window/window_session_controller.h
window/window_slide_animation.cpp
window/window_slide_animation.h
window/window_title_qt.cpp
window/window_title_qt.h
window/window_title.h
window/window_top_bar_wrap.h
window/themes/window_theme.cpp
@@ -1025,15 +1124,20 @@ PRIVATE
mainwidget.h
mainwindow.cpp
mainwindow.h
observer_peer.cpp
observer_peer.h
qt_static_plugins.cpp
settings.cpp
settings.h
)
if (DESKTOP_APP_USE_PACKAGED)
nice_target_sources(Telegram ${src_loc} PRIVATE qt_functions.cpp)
if (NOT LINUX)
remove_target_sources(Telegram ${src_loc}
window/window_title_qt.cpp
window/window_title_qt.h
)
endif()
if (NOT DESKTOP_APP_USE_PACKAGED)
nice_target_sources(Telegram ${src_loc} PRIVATE platform/mac/mac_iconv_helper.c)
endif()
nice_target_sources(Telegram ${res_loc}
@@ -1069,11 +1173,11 @@ if (WIN32)
# $<IF:${release},"Appending compatibility manifest.","Finalizing build.">
# )
elseif (APPLE)
target_link_libraries(Telegram
PRIVATE
desktop-app::external_sp_media_key_tap
desktop-app::external_iconv
)
target_link_libraries(Telegram PRIVATE desktop-app::external_sp_media_key_tap)
if (NOT DESKTOP_APP_USE_PACKAGED)
target_link_libraries(Telegram PRIVATE desktop-app::external_iconv)
endif()
set(icons_path ${CMAKE_CURRENT_SOURCE_DIR}/Telegram/Images.xcassets)
set_target_properties(Telegram PROPERTIES RESOURCE ${icons_path})
@@ -1112,19 +1216,6 @@ 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})
target_compile_options(Telegram PRIVATE -Wno-register)
if (DESKTOP_APP_USE_PACKAGED)
find_library(X11_LIBRARY X11)
target_link_libraries(Telegram PRIVATE ${X11_LIBRARY})
endif()
endif()
endif()
if (build_macstore)
@@ -1187,7 +1278,7 @@ PRIVATE
TDESKTOP_API_HASH=${TDESKTOP_API_HASH}
)
if (${CMAKE_GENERATOR} MATCHES "(Visual Studio|Xcode)")
if (APPLE OR NOT CMAKE_EXECUTABLE_SUFFIX STREQUAL "" OR NOT "${output_name}" STREQUAL "Telegram")
set(output_folder ${CMAKE_BINARY_DIR})
elseif (DESKTOP_APP_SPECIAL_TARGET STREQUAL "")
set(output_folder ${CMAKE_BINARY_DIR}/bin)
@@ -1197,7 +1288,7 @@ endif()
set_target_properties(Telegram PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${output_folder})
if ((NOT DESKTOP_APP_DISABLE_AUTOUPDATE OR NOT LINUX) AND NOT build_macstore AND NOT build_winstore)
if ((NOT DESKTOP_APP_DISABLE_AUTOUPDATE OR APPLE) AND NOT build_macstore AND NOT build_winstore)
add_executable(Updater WIN32)
init_target(Updater)

View File

@@ -1,225 +0,0 @@
diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile
index 00f93bf59f..52da7036f3 100644
--- a/libavcodec/aarch64/Makefile
+++ b/libavcodec/aarch64/Makefile
@@ -6,6 +6,7 @@ OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_init_aarch64.o
OBJS-$(CONFIG_H264PRED) += aarch64/h264pred_init.o
OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_init_aarch64.o
OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_init_aarch64.o
+OBJS-$(CONFIG_IDCTDSP) += aarch64/idctdsp_init_aarch64.o
OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_init.o
OBJS-$(CONFIG_NEON_CLOBBER_TEST) += aarch64/neontest.o
OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp_init.o
@@ -21,6 +22,7 @@ OBJS-$(CONFIG_VC1DSP) += aarch64/vc1dsp_init_aarch64.o
OBJS-$(CONFIG_VORBIS_DECODER) += aarch64/vorbisdsp_init.o
OBJS-$(CONFIG_VP9_DECODER) += aarch64/vp9dsp_init_10bpp_aarch64.o \
aarch64/vp9dsp_init_12bpp_aarch64.o \
+ aarch64/vp9mc_aarch64.o \
aarch64/vp9dsp_init_aarch64.o
# ARMv8 optimizations
@@ -41,8 +43,7 @@ NEON-OBJS-$(CONFIG_H264PRED) += aarch64/h264pred_neon.o
NEON-OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_neon.o \
aarch64/hpeldsp_neon.o
NEON-OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_neon.o
-NEON-OBJS-$(CONFIG_IDCTDSP) += aarch64/idctdsp_init_aarch64.o \
- aarch64/simple_idct_neon.o
+NEON-OBJS-$(CONFIG_IDCTDSP) += aarch64/simple_idct_neon.o
NEON-OBJS-$(CONFIG_MDCT) += aarch64/mdct_neon.o
NEON-OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_neon.o
NEON-OBJS-$(CONFIG_VP8DSP) += aarch64/vp8dsp_neon.o
diff --git a/libavcodec/aarch64/idctdsp_init_aarch64.c b/libavcodec/aarch64/idctdsp_init_aarch64.c
index 0406e60830..742a3372e3 100644
--- a/libavcodec/aarch64/idctdsp_init_aarch64.c
+++ b/libavcodec/aarch64/idctdsp_init_aarch64.c
@@ -21,6 +21,8 @@
*/
#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/arm/cpu.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/idctdsp.h"
#include "idct.h"
@@ -28,7 +30,9 @@
av_cold void ff_idctdsp_init_aarch64(IDCTDSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth)
{
- if (!avctx->lowres && !high_bit_depth) {
+ int cpu_flags = av_get_cpu_flags();
+
+ if (have_neon(cpu_flags) && !avctx->lowres && !high_bit_depth) {
if (avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
avctx->idct_algo == FF_IDCT_SIMPLENEON) {
diff --git a/libavcodec/aarch64/vp9mc_16bpp_neon.S b/libavcodec/aarch64/vp9mc_16bpp_neon.S
index cac6428709..53b372c262 100644
--- a/libavcodec/aarch64/vp9mc_16bpp_neon.S
+++ b/libavcodec/aarch64/vp9mc_16bpp_neon.S
@@ -25,31 +25,6 @@
// const uint8_t *ref, ptrdiff_t ref_stride,
// int h, int mx, int my);
-function ff_vp9_copy128_aarch64, export=1
-1:
- ldp x5, x6, [x2]
- ldp x7, x8, [x2, #16]
- stp x5, x6, [x0]
- ldp x9, x10, [x2, #32]
- stp x7, x8, [x0, #16]
- subs w4, w4, #1
- ldp x11, x12, [x2, #48]
- stp x9, x10, [x0, #32]
- stp x11, x12, [x0, #48]
- ldp x5, x6, [x2, #64]
- ldp x7, x8, [x2, #80]
- stp x5, x6, [x0, #64]
- ldp x9, x10, [x2, #96]
- stp x7, x8, [x0, #80]
- ldp x11, x12, [x2, #112]
- stp x9, x10, [x0, #96]
- stp x11, x12, [x0, #112]
- add x2, x2, x3
- add x0, x0, x1
- b.ne 1b
- ret
-endfunc
-
function ff_vp9_avg64_16_neon, export=1
mov x5, x0
sub x1, x1, #64
diff --git a/libavcodec/aarch64/vp9mc_aarch64.S b/libavcodec/aarch64/vp9mc_aarch64.S
new file mode 100644
index 0000000000..f17a8cf04a
--- /dev/null
+++ b/libavcodec/aarch64/vp9mc_aarch64.S
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2016 Google Inc.
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/asm.S"
+
+// All public functions in this file have the following signature:
+// typedef void (*vp9_mc_func)(uint8_t *dst, ptrdiff_t dst_stride,
+// const uint8_t *ref, ptrdiff_t ref_stride,
+// int h, int mx, int my);
+
+function ff_vp9_copy128_aarch64, export=1
+1:
+ ldp x5, x6, [x2]
+ ldp x7, x8, [x2, #16]
+ stp x5, x6, [x0]
+ ldp x9, x10, [x2, #32]
+ stp x7, x8, [x0, #16]
+ subs w4, w4, #1
+ ldp x11, x12, [x2, #48]
+ stp x9, x10, [x0, #32]
+ stp x11, x12, [x0, #48]
+ ldp x5, x6, [x2, #64]
+ ldp x7, x8, [x2, #80]
+ stp x5, x6, [x0, #64]
+ ldp x9, x10, [x2, #96]
+ stp x7, x8, [x0, #80]
+ ldp x11, x12, [x2, #112]
+ stp x9, x10, [x0, #96]
+ stp x11, x12, [x0, #112]
+ add x2, x2, x3
+ add x0, x0, x1
+ b.ne 1b
+ ret
+endfunc
+
+function ff_vp9_copy64_aarch64, export=1
+1:
+ ldp x5, x6, [x2]
+ ldp x7, x8, [x2, #16]
+ stp x5, x6, [x0]
+ ldp x9, x10, [x2, #32]
+ stp x7, x8, [x0, #16]
+ subs w4, w4, #1
+ ldp x11, x12, [x2, #48]
+ stp x9, x10, [x0, #32]
+ stp x11, x12, [x0, #48]
+ add x2, x2, x3
+ add x0, x0, x1
+ b.ne 1b
+ ret
+endfunc
+
+function ff_vp9_copy32_aarch64, export=1
+1:
+ ldp x5, x6, [x2]
+ ldp x7, x8, [x2, #16]
+ stp x5, x6, [x0]
+ subs w4, w4, #1
+ stp x7, x8, [x0, #16]
+ add x2, x2, x3
+ add x0, x0, x1
+ b.ne 1b
+ ret
+endfunc
diff --git a/libavcodec/aarch64/vp9mc_neon.S b/libavcodec/aarch64/vp9mc_neon.S
index f67624ca04..abf2bae9db 100644
--- a/libavcodec/aarch64/vp9mc_neon.S
+++ b/libavcodec/aarch64/vp9mc_neon.S
@@ -25,23 +25,6 @@
// const uint8_t *ref, ptrdiff_t ref_stride,
// int h, int mx, int my);
-function ff_vp9_copy64_aarch64, export=1
-1:
- ldp x5, x6, [x2]
- ldp x7, x8, [x2, #16]
- stp x5, x6, [x0]
- ldp x9, x10, [x2, #32]
- stp x7, x8, [x0, #16]
- subs w4, w4, #1
- ldp x11, x12, [x2, #48]
- stp x9, x10, [x0, #32]
- stp x11, x12, [x0, #48]
- add x2, x2, x3
- add x0, x0, x1
- b.ne 1b
- ret
-endfunc
-
function ff_vp9_avg64_neon, export=1
mov x5, x0
1:
@@ -64,19 +47,6 @@ function ff_vp9_avg64_neon, export=1
ret
endfunc
-function ff_vp9_copy32_aarch64, export=1
-1:
- ldp x5, x6, [x2]
- ldp x7, x8, [x2, #16]
- stp x5, x6, [x0]
- subs w4, w4, #1
- stp x7, x8, [x0, #16]
- add x2, x2, x3
- add x0, x0, x1
- b.ne 1b
- ret
-endfunc
-
function ff_vp9_avg32_neon, export=1
1:
ld1 {v2.16b, v3.16b}, [x2], x3

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 B

After

Width:  |  Height:  |  Size: 128 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 B

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 B

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -15,6 +15,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_menu_update" = "Update";
"lng_menu_back" = "Back";
"lng_menu_night_mode" = "Night Mode";
"lng_menu_add_account" = "Add Account";
"lng_menu_activate" = "Activate";
"lng_disable_notifications_from_tray" = "Disable notifications";
"lng_enable_notifications_from_tray" = "Enable notifications";
@@ -290,6 +292,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_settings_empty_bio" = "None";
"lng_settings_section_notify" = "Notifications";
"lng_settings_show_from" = "Show notifications from";
"lng_settings_notify_all" = "All accounts";
"lng_settings_notify_all_about" = "Turn this off if you want to receive notifications only from the account you are currently using.";
"lng_settings_notify_title" = "Notifications for chats";
"lng_settings_desktop_notify" = "Desktop notifications";
"lng_settings_show_name" = "Show sender's name";
@@ -333,6 +338,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_settings_update_fail" = "Update check failed :(";
"lng_settings_workmode_tray" = "Show tray icon";
"lng_settings_workmode_window" = "Show taskbar icon";
"lng_settings_native_frame" = "Use system window frame";
"lng_settings_auto_start" = "Launch Telegram when system starts";
"lng_settings_start_min" = "Launch minimized";
"lng_settings_add_sendto" = "Place Telegram in \"Send to\" menu";
@@ -428,6 +434,11 @@ 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_settings_spellchecker" = "Spell checker";
"lng_settings_system_spellchecker" = "Use system spell checker";
"lng_settings_custom_spellchecker" = "Use spell checker";
@@ -2150,6 +2161,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_export_option_size_limit" = "Size limit: {size}";
"lng_export_header_format" = "Location and format";
"lng_export_option_location" = "Download path: {path}";
"lng_export_option_format_location" = "Format: {format}, Path: {path}";
"lng_export_option_choose_format" = "Choose export format";
"lng_export_option_html" = "Human-readable HTML";
"lng_export_option_json" = "Machine-readable JSON";
"lng_export_limits" = "From: {from}, to: {till}";
@@ -2249,6 +2262,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_polls_votes_collapse" = "Collapse";
"lng_outdated_title" = "PLEASE UPDATE YOUR OPERATING SYSTEM.";
"lng_outdated_title_bits" = "PLEASE SWITCH TO 64 BIT OPERATING SYSTEM.";
"lng_outdated_soon" = "Otherwise, Telegram Desktop will stop updating on {date}.";
"lng_outdated_now" = "So that Telegram Desktop can update to newer versions.";

View File

@@ -357,6 +357,7 @@ updateMessagePollVote#42f88f2c poll_id:long user_id:int options:Vector<bytes> =
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;
updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State;
@@ -421,7 +422,7 @@ inputDocumentEmpty#72f0eaae = InputDocument;
inputDocument#1abfb575 id:long access_hash:long file_reference:bytes = InputDocument;
documentEmpty#36f8c871 id:long = Document;
document#9ba29cc1 flags:# id:long access_hash:long file_reference:bytes date:int mime_type:string size:int thumbs:flags.0?Vector<PhotoSize> dc_id:int attributes:Vector<DocumentAttribute> = Document;
document#1e87342b flags:# id:long access_hash:long file_reference:bytes date:int mime_type:string size:int thumbs:flags.0?Vector<PhotoSize> video_thumbs:flags.1?Vector<VideoSize> dc_id:int attributes:Vector<DocumentAttribute> = Document;
help.support#17c6b5f6 phone_number:string user:User = help.Support;
@@ -1140,6 +1141,8 @@ 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;
---functions---
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
@@ -1485,6 +1488,7 @@ phone.receivedCall#17d54f61 peer:InputPhoneCall = Bool;
phone.discardCall#b2cbc1c0 flags:# video:flags.0?true peer:InputPhoneCall duration:int reason:PhoneCallDiscardReason connection_id:long = Updates;
phone.setCallRating#59ead627 flags:# user_initiative:flags.0?true peer:InputPhoneCall rating:int comment:string = Updates;
phone.saveCallDebug#277add7e peer:InputPhoneCall debug:DataJSON = Bool;
phone.sendSignalingData#ff7a9383 peer:InputPhoneCall data:bytes = Bool;
langpack.getLangPack#f2f2330a lang_pack:string lang_code:string = LangPackDifference;
langpack.getStrings#efea3803 lang_pack:string lang_code:string keys:Vector<string> = Vector<LangPackString>;
@@ -1498,4 +1502,4 @@ 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;
// LAYER 113
// LAYER 114

View File

@@ -9,7 +9,7 @@
<Identity Name="TelegramMessengerLLP.TelegramDesktop"
ProcessorArchitecture="ARCHITECTURE"
Publisher="CN=536BC709-8EE1-4478-AF22-F0F0F26FF64A"
Version="2.1.7.0" />
Version="2.1.21.0" />
<Properties>
<DisplayName>Telegram Desktop</DisplayName>
<PublisherDisplayName>Telegram FZ-LLC</PublisherDisplayName>

View File

@@ -44,8 +44,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,1,7,0
PRODUCTVERSION 2,1,7,0
FILEVERSION 2,1,21,0
PRODUCTVERSION 2,1,21,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.7.0"
VALUE "FileVersion", "2.1.21.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2020"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "2.1.7.0"
VALUE "ProductVersion", "2.1.21.0"
END
END
BLOCK "VarFileInfo"

View File

@@ -35,8 +35,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,1,7,0
PRODUCTVERSION 2,1,7,0
FILEVERSION 2,1,21,0
PRODUCTVERSION 2,1,21,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.7.0"
VALUE "FileVersion", "2.1.21.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2020"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "2.1.7.0"
VALUE "ProductVersion", "2.1.21.0"
END
END
BLOCK "VarFileInfo"

View File

@@ -254,7 +254,7 @@ int main(int argc, char *argv[])
}
QByteArray inner = f.readAll();
stream << name << quint32(inner.size()) << inner;
#if defined Q_OS_MAC || defined Q_OS_LINUX
#ifdef Q_OS_UNIX
stream << (QFileInfo(fullName).isExecutable() ? true : false);
#endif
}
@@ -467,10 +467,12 @@ int main(int argc, char *argv[])
QString outName(QString("tupdate%1").arg(AlphaVersion ? AlphaVersion : version));
#elif defined Q_OS_MAC
QString outName((targetosx ? QString("tosxupd%1") : QString("tmacupd%1")).arg(AlphaVersion ? AlphaVersion : version));
#elif defined Q_OS_LINUX32
#elif defined Q_OS_UNIX
#ifndef _LP64
QString outName(QString("tlinux32upd%1").arg(AlphaVersion ? AlphaVersion : version));
#elif defined Q_OS_LINUX64
#else
QString outName(QString("tlinuxupd%1").arg(AlphaVersion ? AlphaVersion : version));
#endif
#else
#error Unknown platform!
#endif

View File

@@ -90,7 +90,7 @@ int main(int argc, const char * argv[]) {
openLog();
pid_t procId = 0;
BOOL update = YES, toSettings = NO, autoStart = NO, startInTray = NO, testMode = NO, externalUpdater = NO;
BOOL update = YES, toSettings = NO, autoStart = NO, startInTray = NO, testMode = NO, freeType = NO, externalUpdater = NO;
BOOL customWorkingDir = NO;
NSString *key = nil;
for (int i = 0; i < argc; ++i) {
@@ -116,6 +116,8 @@ int main(int argc, const char * argv[]) {
startInTray = YES;
} else if ([@"-testmode" isEqualToString:[NSString stringWithUTF8String:argv[i]]]) {
testMode = YES;
} else if ([@"-freetype" isEqualToString:[NSString stringWithUTF8String:argv[i]]]) {
freeType = YES;
} else if ([@"-externalupdater" isEqualToString:[NSString stringWithUTF8String:argv[i]]]) {
externalUpdater = YES;
} else if ([@"-workdir_custom" isEqualToString:[NSString stringWithUTF8String:argv[i]]]) {
@@ -255,6 +257,7 @@ int main(int argc, const char * argv[]) {
if (_debug) [args addObject:@"-debug"];
if (startInTray) [args addObject:@"-startintray"];
if (testMode) [args addObject:@"-testmode"];
if (freeType) [args addObject:@"-freetype"];
if (externalUpdater) [args addObject:@"-externalupdater"];
if (autoStart) [args addObject:@"-autostart"];
if (key) {

View File

@@ -339,7 +339,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdPara
LPWSTR *args;
int argsCount;
bool needupdate = false, autostart = false, debug = false, writeprotected = false, startintray = false, testmode = false, externalupdater = false;
bool needupdate = false, autostart = false, debug = false, writeprotected = false, startintray = false, testmode = false, freetype = false, externalupdater = false;
args = CommandLineToArgvW(GetCommandLine(), &argsCount);
if (args) {
for (int i = 1; i < argsCount; ++i) {
@@ -355,6 +355,8 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdPara
startintray = true;
} else if (equal(args[i], L"-testmode")) {
testmode = true;
} else if (equal(args[i], L"-freetype")) {
freetype = true;
} else if (equal(args[i], L"-externalupdater")) {
externalupdater = true;
} else if (equal(args[i], L"-writeprotected") && ++i < argsCount) {
@@ -427,6 +429,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdPara
if (debug) targs += L" -debug";
if (startintray) targs += L" -startintray";
if (testmode) targs += L" -testmode";
if (freetype) targs += L" -freetype";
if (externalupdater) targs += L" -externalupdater";
if (!customWorkingDir.empty()) {
targs += L" -workdir \"" + customWorkingDir + L"\"";

View File

@@ -0,0 +1,117 @@
/*
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_bot.h"
#include "apiwrap.h"
#include "api/api_send_progress.h"
#include "boxes/confirm_box.h"
#include "boxes/share_box.h"
#include "core/click_handler_types.h"
#include "data/data_changes.h"
#include "data/data_peer.h"
#include "data/data_session.h"
#include "history/history.h"
#include "history/history_item.h"
#include "history/history_item_components.h"
#include "main/main_session.h"
#include "ui/toast/toast.h"
namespace Api {
void SendBotCallbackData(
not_null<HistoryItem*> item,
int row,
int column) {
if (!IsServerMsgId(item->id)) {
return;
}
const auto history = item->history();
const auto session = &history->session();
const auto owner = &history->owner();
const auto api = &session->api();
const auto bot = item->getMessageBot();
const auto fullId = item->fullId();
const auto getButton = [=] {
return HistoryMessageMarkupButton::Get(
owner,
fullId,
row,
column);
};
const auto button = getButton();
if (!button) {
return;
}
using ButtonType = HistoryMessageMarkupButton::Type;
const auto isGame = (button->type == ButtonType::Game);
auto flags = MTPmessages_GetBotCallbackAnswer::Flags(0);
QByteArray sendData;
if (isGame) {
flags |= MTPmessages_GetBotCallbackAnswer::Flag::f_game;
} else if (button->type == ButtonType::Callback) {
flags |= MTPmessages_GetBotCallbackAnswer::Flag::f_data;
sendData = button->data;
}
button->requestId = api->request(MTPmessages_GetBotCallbackAnswer(
MTP_flags(flags),
history->peer->input,
MTP_int(item->id),
MTP_bytes(sendData)
)).done([=](const MTPmessages_BotCallbackAnswer &result) {
const auto item = owner->message(fullId);
if (!item) {
return;
}
if (const auto button = getButton()) {
button->requestId = 0;
owner->requestItemRepaint(item);
}
result.match([&](const MTPDmessages_botCallbackAnswer &data) {
if (const auto message = data.vmessage()) {
if (data.is_alert()) {
Ui::show(Box<InformBox>(qs(*message)));
} else {
Ui::Toast::Show(qs(*message));
}
} else if (const auto url = data.vurl()) {
const auto link = qs(*url);
if (!isGame) {
UrlClickHandler::Open(link);
return;
}
const auto scoreLink = AppendShareGameScoreUrl(
session,
link,
item->fullId());
BotGameUrlClickHandler(bot, scoreLink).onClick({});
session->sendProgressManager().update(
history,
Api::SendProgressType::PlayGame);
}
});
}).fail([=](const RPCError &error) {
const auto item = owner->message(fullId);
if (!item) {
return;
}
// Show error?
if (const auto button = getButton()) {
button->requestId = 0;
owner->requestItemRepaint(item);
}
}).send();
session->changes().messageUpdated(
item,
Data::MessageUpdate::Flag::BotCallbackSent
);
}
} // namespace Api

View File

@@ -0,0 +1,19 @@
/*
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 {
void SendBotCallbackData(
not_null<HistoryItem*> item,
int row,
int column);
} // namespace Api

View 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

View 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

View File

@@ -0,0 +1,94 @@
/*
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_hash.h"
#include "data/data_document.h"
#include "data/data_session.h"
#include "data/stickers/data_stickers.h"
#include "main/main_session.h"
namespace Api {
namespace {
[[nodiscard]] int32 CountDocumentVectorHash(
const QVector<DocumentData*> vector) {
auto result = HashInit();
for (const auto document : vector) {
HashUpdate(result, document->id);
}
return HashFinalize(result);
}
[[nodiscard]] int32 CountSpecialStickerSetHash(
not_null<Main::Session*> session,
uint64 setId) {
const auto &sets = session->data().stickers().sets();
const auto it = sets.find(setId);
if (it != sets.cend()) {
return CountDocumentVectorHash(it->second->stickers);
}
return 0;
}
} // namespace
int32 CountStickersHash(
not_null<Main::Session*> session,
bool checkOutdatedInfo) {
auto result = HashInit();
bool foundOutdated = false;
const auto &sets = session->data().stickers().sets();
const auto &order = session->data().stickers().setsOrder();
for (auto i = order.cbegin(), e = order.cend(); i != e; ++i) {
auto it = sets.find(*i);
if (it != sets.cend()) {
const auto set = it->second.get();
if (set->id == Data::Stickers::DefaultSetId) {
foundOutdated = true;
} else if (!(set->flags & MTPDstickerSet_ClientFlag::f_special)
&& !(set->flags & MTPDstickerSet::Flag::f_archived)) {
HashUpdate(result, set->hash);
}
}
}
return (!checkOutdatedInfo || !foundOutdated)
? HashFinalize(result)
: 0;
}
int32 CountRecentStickersHash(not_null<Main::Session*> session) {
return CountSpecialStickerSetHash(
session,
Data::Stickers::CloudRecentSetId);
}
int32 CountFavedStickersHash(not_null<Main::Session*> session) {
return CountSpecialStickerSetHash(session, Data::Stickers::FavedSetId);
}
int32 CountFeaturedStickersHash(not_null<Main::Session*> session) {
auto result = HashInit();
const auto &sets = session->data().stickers().sets();
const auto &featured = session->data().stickers().featuredSetsOrder();
for (const auto setId : featured) {
HashUpdate(result, setId);
const auto it = sets.find(setId);
if (it != sets.cend()
&& (it->second->flags & MTPDstickerSet_ClientFlag::f_unread)) {
HashUpdate(result, 1);
}
}
return HashFinalize(result);
}
int32 CountSavedGifsHash(not_null<Main::Session*> session) {
return CountDocumentVectorHash(session->data().stickers().savedGifs());
}
} // namespace Api

View File

@@ -7,8 +7,22 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
namespace Main {
class Session;
} // namespace Main
namespace Api {
[[nodiscard]] int32 CountStickersHash(
not_null<Main::Session*> session,
bool checkOutdatedInfo = false);
[[nodiscard]] int32 CountRecentStickersHash(
not_null<Main::Session*> session);
[[nodiscard]] int32 CountFavedStickersHash(not_null<Main::Session*> session);
[[nodiscard]] int32 CountFeaturedStickersHash(
not_null<Main::Session*> session);
[[nodiscard]] int32 CountSavedGifsHash(not_null<Main::Session*> session);
[[nodiscard]] inline uint32 HashInit() {
return 0;
}

View 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

View 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

View File

@@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Api {
SelfDestruct::SelfDestruct(not_null<ApiWrap*> api)
: _api(api->instance()) {
: _api(&api->instance()) {
}
void SelfDestruct::reload() {

View File

@@ -0,0 +1,108 @@
/*
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_send_progress.h"
#include "main/main_session.h"
#include "history/history.h"
#include "data/data_peer.h"
#include "apiwrap.h"
namespace Api {
namespace {
constexpr auto kCancelTypingActionTimeout = crl::time(5000);
} // namespace
SendProgressManager::SendProgressManager(not_null<Main::Session*> session)
: _session(session)
, _stopTypingTimer([=] { cancelTyping(base::take(_stopTypingHistory)); }) {
}
void SendProgressManager::cancel(
not_null<History*> history,
SendProgressType type) {
const auto i = _requests.find({ history, type });
if (i != _requests.end()) {
_session->api().request(i->second).cancel();
_requests.erase(i);
}
}
void SendProgressManager::cancelTyping(not_null<History*> history) {
_stopTypingTimer.cancel();
cancel(history, SendProgressType::Typing);
}
void SendProgressManager::update(
not_null<History*> history,
SendProgressType type,
int32 progress) {
const auto peer = history->peer;
if (peer->isSelf() || (peer->isChannel() && !peer->isMegagroup())) {
return;
}
const auto doing = (progress >= 0);
if (history->mySendActionUpdated(type, doing)) {
cancel(history, type);
if (doing) {
send(history, type, progress);
}
}
}
void SendProgressManager::send(
not_null<History*> history,
SendProgressType type,
int32 progress) {
using Type = SendProgressType;
const auto action = [&]() -> MTPsendMessageAction {
const auto p = MTP_int(progress);
switch (type) {
case Type::Typing: return MTP_sendMessageTypingAction();
case Type::RecordVideo: return MTP_sendMessageRecordVideoAction();
case Type::UploadVideo: return MTP_sendMessageUploadVideoAction(p);
case Type::RecordVoice: return MTP_sendMessageRecordAudioAction();
case Type::UploadVoice: return MTP_sendMessageUploadAudioAction(p);
case Type::RecordRound: return MTP_sendMessageRecordRoundAction();
case Type::UploadRound: return MTP_sendMessageUploadRoundAction(p);
case Type::UploadPhoto: return MTP_sendMessageUploadPhotoAction(p);
case Type::UploadFile: return MTP_sendMessageUploadDocumentAction(p);
case Type::ChooseLocation: return MTP_sendMessageGeoLocationAction();
case Type::ChooseContact: return MTP_sendMessageChooseContactAction();
case Type::PlayGame: return MTP_sendMessageGamePlayAction();
default: return MTP_sendMessageTypingAction();
}
}();
const auto requestId = _session->api().request(MTPmessages_SetTyping(
history->peer->input,
action
)).done([=](const MTPBool &result, mtpRequestId requestId) {
done(result, requestId);
}).send();
_requests.emplace(Key{ history, type }, requestId);
if (type == Type::Typing) {
_stopTypingHistory = history;
_stopTypingTimer.callOnce(kCancelTypingActionTimeout);
}
}
void SendProgressManager::done(
const MTPBool &result,
mtpRequestId requestId) {
for (auto i = _requests.begin(), e = _requests.end(); i != e; ++i) {
if (i->second == requestId) {
_requests.erase(i);
break;
}
}
}
} // namespace Api

View File

@@ -0,0 +1,88 @@
/*
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 "api/api_common.h"
#include "base/timer.h"
class History;
namespace Main {
class Session;
} // namespace Main
namespace Api {
enum class SendProgressType {
Typing,
RecordVideo,
UploadVideo,
RecordVoice,
UploadVoice,
RecordRound,
UploadRound,
UploadPhoto,
UploadFile,
ChooseLocation,
ChooseContact,
PlayGame,
};
struct SendProgress {
SendProgress(
SendProgressType type,
crl::time until,
int progress = 0)
: type(type)
, until(until)
, progress(progress) {
}
SendProgressType type = SendProgressType::Typing;
crl::time until = 0;
int progress = 0;
};
class SendProgressManager final {
public:
SendProgressManager(not_null<Main::Session*> session);
void update(
not_null<History*> history,
SendProgressType type,
int32 progress = 0);
void cancel(
not_null<History*> history,
SendProgressType type);
void cancelTyping(not_null<History*> history);
private:
struct Key {
not_null<History*> history;
SendProgressType type = SendProgressType();
inline bool operator<(const Key &other) const {
return (history < other.history)
|| (history == other.history && type < other.type);
}
};
void send(
not_null<History*> history,
SendProgressType type,
int32 progress);
void done(const MTPBool &result, mtpRequestId requestId);
const not_null<Main::Session*> _session;
base::flat_map<Key, mtpRequestId> _requests;
base::Timer _stopTypingTimer;
History *_stopTypingHistory = nullptr;
};
} // namespace Api

View File

@@ -16,13 +16,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h"
#include "data/data_file_origin.h"
#include "data/data_histories.h"
#include "data/data_changes.h"
#include "data/stickers/data_stickers.h"
#include "history/history.h"
#include "history/history_message.h" // NewMessageFlags.
#include "chat_helpers/message_field.h" // ConvertTextTagsToEntities.
#include "ui/text/text_entity.h" // TextWithEntities.
#include "ui/text_options.h" // Ui::ItemTextOptions.
#include "main/main_session.h"
#include "main/main_account.h"
#include "main/main_app_config.h"
#include "storage/localimageloader.h"
#include "storage/file_upload.h"
#include "mainwidget.h"
#include "apiwrap.h"
#include "app.h"
@@ -93,6 +98,7 @@ void SendExistingMedia(
};
TextUtilities::Trim(caption);
auto sentEntities = EntitiesToMTP(
session,
caption.entities,
ConvertOption::SkipLocal);
if (!sentEntities.v.isEmpty()) {
@@ -123,8 +129,7 @@ void SendExistingMedia(
caption,
MTPReplyMarkup());
auto failHandler = std::make_shared<Fn<void(const RPCError&, QByteArray)>>();
auto performRequest = [=] {
auto performRequest = [=](const auto &repeatRequest) -> void {
auto &histories = history->owner().histories();
const auto requestType = Data::Histories::RequestType::Send;
histories.sendRequest(history, requestType, [=](Fn<void()> finish) {
@@ -143,32 +148,27 @@ void SendExistingMedia(
api->applyUpdates(result, randomId);
finish();
}).fail([=](const RPCError &error) {
(*failHandler)(error, usedFileReference);
if (error.code() == 400
&& error.type().startsWith(qstr("FILE_REFERENCE_"))) {
api->refreshFileReference(origin, [=](const auto &result) {
if (media->fileReference() != usedFileReference) {
repeatRequest(repeatRequest);
} else {
api->sendMessageFail(error, peer, randomId, newId);
}
});
} else {
api->sendMessageFail(error, peer, randomId, newId);
}
finish();
}).afterRequest(history->sendRequestId
).send();
return history->sendRequestId;
});
};
*failHandler = [=](const RPCError &error, QByteArray usedFileReference) {
if (error.code() == 400
&& error.type().startsWith(qstr("FILE_REFERENCE_"))) {
api->refreshFileReference(origin, [=](const auto &result) {
if (media->fileReference() != usedFileReference) {
performRequest();
} else {
api->sendMessageFail(error, peer, randomId, newId);
}
});
} else {
api->sendMessageFail(error, peer, randomId, newId);
}
};
performRequest();
performRequest(performRequest);
if (const auto main = App::main()) {
main->finishForwarding(message.action);
}
api->finishForwarding(message.action);
}
} // namespace
@@ -189,10 +189,7 @@ void SendExistingDocument(
document->stickerOrGifOrigin());
if (document->sticker()) {
if (const auto main = App::main()) {
main->incrementSticker(document);
document->owner().notifyRecentStickersUpdated();
}
document->owner().stickers().incrementSticker(document);
}
}
@@ -321,6 +318,7 @@ bool SendDice(Api::MessageToSend &message) {
).send();
return history->sendRequestId;
});
api->finishForwarding(message.action);
return true;
}
@@ -331,4 +329,209 @@ void FillMessagePostFlags(
InnerFillMessagePostFlags(action.options, peer, flags);
}
void SendConfirmedFile(
not_null<Main::Session*> session,
const std::shared_ptr<FileLoadResult> &file,
const std::optional<FullMsgId> &oldId) {
const auto isEditing = oldId.has_value();
const auto channelId = peerToChannel(file->to.peer);
const auto newId = oldId.value_or(
FullMsgId(channelId, session->data().nextLocalMessageId()));
auto groupId = file->album ? file->album->groupId : uint64(0);
if (file->album) {
const auto proj = [](const SendingAlbum::Item &item) {
return item.taskId;
};
const auto it = ranges::find(file->album->items, file->taskId, proj);
Assert(it != file->album->items.end());
it->msgId = newId;
}
file->edit = isEditing;
session->uploader().upload(newId, file);
const auto itemToEdit = isEditing
? session->data().message(newId)
: nullptr;
const auto history = session->data().history(file->to.peer);
const auto peer = history->peer;
auto action = Api::SendAction(history);
action.options = file->to.options;
action.clearDraft = false;
action.replyTo = file->to.replyTo;
action.generateLocal = true;
session->api().sendAction(action);
auto caption = TextWithEntities{
file->caption.text,
TextUtilities::ConvertTextTagsToEntities(file->caption.tags)
};
const auto prepareFlags = Ui::ItemTextOptions(
history,
session->user()).flags;
TextUtilities::PrepareForSending(caption, prepareFlags);
TextUtilities::Trim(caption);
auto localEntities = Api::EntitiesToMTP(session, caption.entities);
if (itemToEdit) {
if (const auto id = itemToEdit->groupId()) {
groupId = id.value;
}
}
auto flags = (isEditing ? MTPDmessage::Flags() : NewMessageFlags(peer))
| MTPDmessage::Flag::f_entities
| MTPDmessage::Flag::f_media;
auto clientFlags = NewMessageClientFlags();
if (file->to.replyTo) {
flags |= MTPDmessage::Flag::f_reply_to_msg_id;
}
const auto channelPost = peer->isChannel() && !peer->isMegagroup();
const auto silentPost = file->to.options.silent;
Api::FillMessagePostFlags(action, peer, flags);
if (silentPost) {
flags |= MTPDmessage::Flag::f_silent;
}
if (groupId) {
flags |= MTPDmessage::Flag::f_grouped_id;
}
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;
}
const auto messageFromId = channelPost ? 0 : session->userId();
const auto messagePostAuthor = channelPost
? session->user()->name
: QString();
if (file->type == SendMediaType::Photo) {
const auto photoFlags = MTPDmessageMediaPhoto::Flag::f_photo | 0;
const auto photo = MTP_messageMediaPhoto(
MTP_flags(photoFlags),
file->photo,
MTPint());
const auto mtpMessage = MTP_message(
MTP_flags(flags),
MTP_int(newId.msg),
MTP_int(messageFromId),
peerToMTP(file->to.peer),
MTPMessageFwdHeader(),
MTPint(),
MTP_int(file->to.replyTo),
MTP_int(HistoryItem::NewMessageDate(file->to.options.scheduled)),
MTP_string(caption.text),
photo,
MTPReplyMarkup(),
localEntities,
MTP_int(1),
MTPint(),
MTP_string(messagePostAuthor),
MTP_long(groupId),
//MTPMessageReactions(),
MTPVector<MTPRestrictionReason>());
if (itemToEdit) {
itemToEdit->savePreviousMedia();
itemToEdit->applyEdition(mtpMessage.c_message());
} else {
history->addNewMessage(
mtpMessage,
clientFlags,
NewMessageType::Unread);
}
} else if (file->type == SendMediaType::File) {
const auto documentFlags = MTPDmessageMediaDocument::Flag::f_document | 0;
const auto document = MTP_messageMediaDocument(
MTP_flags(documentFlags),
file->document,
MTPint());
const auto mtpMessage = MTP_message(
MTP_flags(flags),
MTP_int(newId.msg),
MTP_int(messageFromId),
peerToMTP(file->to.peer),
MTPMessageFwdHeader(),
MTPint(),
MTP_int(file->to.replyTo),
MTP_int(HistoryItem::NewMessageDate(file->to.options.scheduled)),
MTP_string(caption.text),
document,
MTPReplyMarkup(),
localEntities,
MTP_int(1),
MTPint(),
MTP_string(messagePostAuthor),
MTP_long(groupId),
//MTPMessageReactions(),
MTPVector<MTPRestrictionReason>());
if (itemToEdit) {
itemToEdit->savePreviousMedia();
itemToEdit->applyEdition(mtpMessage.c_message());
} else {
history->addNewMessage(
mtpMessage,
clientFlags,
NewMessageType::Unread);
}
} else if (file->type == SendMediaType::Audio) {
if (!peer->isChannel() || peer->isMegagroup()) {
flags |= MTPDmessage::Flag::f_media_unread;
}
const auto documentFlags = MTPDmessageMediaDocument::Flag::f_document | 0;
const auto document = MTP_messageMediaDocument(
MTP_flags(documentFlags),
file->document,
MTPint());
history->addNewMessage(
MTP_message(
MTP_flags(flags),
MTP_int(newId.msg),
MTP_int(messageFromId),
peerToMTP(file->to.peer),
MTPMessageFwdHeader(),
MTPint(),
MTP_int(file->to.replyTo),
MTP_int(
HistoryItem::NewMessageDate(file->to.options.scheduled)),
MTP_string(caption.text),
document,
MTPReplyMarkup(),
localEntities,
MTP_int(1),
MTPint(),
MTP_string(messagePostAuthor),
MTP_long(groupId),
//MTPMessageReactions(),
MTPVector<MTPRestrictionReason>()),
clientFlags,
NewMessageType::Unread);
// Voices can't be edited.
} else {
Unexpected("Type in sendFilesConfirmed.");
}
if (isEditing) {
return;
}
session->data().sendHistoryChangeNotifications();
if (!itemToEdit) {
session->changes().historyUpdated(
history,
(action.options.scheduled
? Data::HistoryUpdate::Flag::ScheduledSent
: Data::HistoryUpdate::Flag::MessageSent));
}
}
} // namespace Api

View File

@@ -10,10 +10,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
class History;
class PhotoData;
class DocumentData;
struct FileLoadResult;
namespace Api {
struct MessageToSend;
struct SendAction;
void SendExistingDocument(
Api::MessageToSend &&message,
@@ -30,4 +32,9 @@ void FillMessagePostFlags(
not_null<PeerData*> peer,
MTPDmessage::Flags &flags);
void SendConfirmedFile(
not_null<Main::Session*> session,
const std::shared_ptr<FileLoadResult> &file,
const std::optional<FullMsgId> &oldId);
} // namespace Api

View File

@@ -21,7 +21,7 @@ constexpr auto kRefreshAppConfigTimeout = 3 * crl::time(1000);
SensitiveContent::SensitiveContent(not_null<ApiWrap*> api)
: _session(&api->session())
, _api(api->instance())
, _api(&api->instance())
, _appConfigReloadTimer([=] { _session->account().appConfig().refresh(); }) {
}

View File

@@ -18,11 +18,13 @@ using namespace TextUtilities;
} // namespace
EntitiesInText EntitiesFromMTP(const QVector<MTPMessageEntity> &entities) {
EntitiesInText EntitiesFromMTP(
Main::Session *session,
const QVector<MTPMessageEntity> &entities) {
auto result = EntitiesInText();
if (!entities.isEmpty()) {
result.reserve(entities.size());
for_const (auto &entity, entities) {
for (const auto &entity : entities) {
switch (entity.type()) {
case mtpc_messageEntityUrl: { auto &d = entity.c_messageEntityUrl(); result.push_back({ EntityType::Url, d.voffset().v, d.vlength().v }); } break;
case mtpc_messageEntityTextUrl: { auto &d = entity.c_messageEntityTextUrl(); result.push_back({ EntityType::CustomUrl, d.voffset().v, d.vlength().v, Clean(qs(d.vurl())) }); } break;
@@ -32,28 +34,30 @@ EntitiesInText EntitiesFromMTP(const QVector<MTPMessageEntity> &entities) {
case mtpc_messageEntityPhone: break; // Skipping phones.
case mtpc_messageEntityMention: { auto &d = entity.c_messageEntityMention(); result.push_back({ EntityType::Mention, d.voffset().v, d.vlength().v }); } break;
case mtpc_messageEntityMentionName: {
auto &d = entity.c_messageEntityMentionName();
auto data = [&d] {
if (auto user = Auth().data().userLoaded(d.vuser_id().v)) {
return MentionNameDataFromFields({
d.vuser_id().v,
user->accessHash() });
const auto &d = entity.c_messageEntityMentionName();
const auto data = [&] {
if (session) {
if (const auto user = session->data().userLoaded(d.vuser_id().v)) {
return MentionNameDataFromFields({
d.vuser_id().v,
user->accessHash() });
}
}
return MentionNameDataFromFields(d.vuser_id().v);
};
result.push_back({ EntityType::MentionName, d.voffset().v, d.vlength().v, data() });
}();
result.push_back({ EntityType::MentionName, d.voffset().v, d.vlength().v, data });
} break;
case mtpc_inputMessageEntityMentionName: {
auto &d = entity.c_inputMessageEntityMentionName();
auto data = ([&d]() -> QString {
if (d.vuser_id().type() == mtpc_inputUserSelf) {
return MentionNameDataFromFields(Auth().userId());
const auto &d = entity.c_inputMessageEntityMentionName();
const auto data = [&] {
if (session && d.vuser_id().type() == mtpc_inputUserSelf) {
return MentionNameDataFromFields(session->userId());
} else if (d.vuser_id().type() == mtpc_inputUser) {
auto &user = d.vuser_id().c_inputUser();
return MentionNameDataFromFields({ user.vuser_id().v, user.vaccess_hash().v });
}
return QString();
})();
}();
if (!data.isEmpty()) {
result.push_back({ EntityType::MentionName, d.voffset().v, d.vlength().v, data });
}
@@ -74,11 +78,12 @@ EntitiesInText EntitiesFromMTP(const QVector<MTPMessageEntity> &entities) {
}
MTPVector<MTPMessageEntity> EntitiesToMTP(
not_null<Main::Session*> session,
const EntitiesInText &entities,
ConvertOption option) {
auto v = QVector<MTPMessageEntity>();
v.reserve(entities.size());
for_const (auto &entity, entities) {
for (const auto &entity : entities) {
if (entity.length() <= 0) continue;
if (option == ConvertOption::SkipLocal
&& entity.type() != EntityType::Bold
@@ -103,15 +108,15 @@ MTPVector<MTPMessageEntity> EntitiesToMTP(
case EntityType::Cashtag: v.push_back(MTP_messageEntityCashtag(offset, length)); break;
case EntityType::Mention: v.push_back(MTP_messageEntityMention(offset, length)); break;
case EntityType::MentionName: {
auto inputUser = ([](const QString &data) -> MTPInputUser {
auto inputUser = [&](const QString &data) -> MTPInputUser {
auto fields = MentionNameDataToFields(data);
if (fields.userId == Auth().userId()) {
if (session && fields.userId == session->userId()) {
return MTP_inputUserSelf();
} else if (fields.userId) {
return MTP_inputUser(MTP_int(fields.userId), MTP_long(fields.accessHash));
}
return MTP_inputUserEmpty();
})(entity.data());
}(entity.data());
if (inputUser.type() != mtpc_inputUserEmpty) {
v.push_back(MTP_inputMessageEntityMentionName(offset, length, inputUser));
}

View File

@@ -9,14 +9,23 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_entity.h"
namespace Main {
class Session;
} // namespace Main
namespace Api {
EntitiesInText EntitiesFromMTP(const QVector<MTPMessageEntity> &entities);
enum class ConvertOption {
WithLocal,
SkipLocal,
};
MTPVector<MTPMessageEntity> EntitiesToMTP(
[[nodiscard]] EntitiesInText EntitiesFromMTP(
Main::Session *session,
const QVector<MTPMessageEntity> &entities);
[[nodiscard]] MTPVector<MTPMessageEntity> EntitiesToMTP(
not_null<Main::Session*> session,
const EntitiesInText &entities,
ConvertOption option = ConvertOption::WithLocal);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,172 @@
/*
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 "data/data_pts_waiter.h"
#include "base/timer.h"
class RPCError;
class ApiWrap;
class History;
namespace Main {
class Session;
} // namespace Main
namespace Api {
class Updates final {
public:
explicit Updates(not_null<Main::Session*> session);
[[nodiscard]] Main::Session &session() const;
[[nodiscard]] ApiWrap &api() const;
void applyUpdates(
const MTPUpdates &updates,
uint64 sentMessageRandomId = 0);
void applyUpdatesNoPtsCheck(const MTPUpdates &updates);
void applyUpdateNoPtsCheck(const MTPUpdate &update);
void updateOnline();
[[nodiscard]] bool isIdle() const;
void checkIdleFinish();
bool lastWasOnline() const;
crl::time lastSetOnline() const;
bool isQuitPrevent();
bool updateAndApply(int32 pts, int32 ptsCount, const MTPUpdates &updates);
bool updateAndApply(int32 pts, int32 ptsCount, const MTPUpdate &update);
bool updateAndApply(int32 pts, int32 ptsCount);
void checkLastUpdate(bool afterSleep);
// ms <= 0 - stop timer
void ptsWaiterStartTimerFor(ChannelData *channel, crl::time ms);
void getDifference();
void requestChannelRangeDifference(not_null<History*> history);
void addActiveChat(rpl::producer<PeerData*> chat);
private:
enum class ChannelDifferenceRequest {
Unknown,
PtsGapOrShortPoll,
AfterFail,
};
struct ActiveChatTracker {
PeerData *peer = nullptr;
rpl::lifetime lifetime;
};
void channelRangeDifferenceSend(
not_null<ChannelData*> channel,
MsgRange range,
int32 pts);
void channelRangeDifferenceDone(
not_null<ChannelData*> channel,
MsgRange range,
const MTPupdates_ChannelDifference &result);
void updateOnline(bool gotOtherOffline);
void sendPing();
void getDifferenceByPts();
void getDifferenceAfterFail();
[[nodiscard]] bool requestingDifference() const {
return _ptsWaiter.requesting();
}
void getChannelDifference(
not_null<ChannelData*> channel,
ChannelDifferenceRequest from = ChannelDifferenceRequest::Unknown);
void differenceDone(const MTPupdates_Difference &result);
void differenceFail(const RPCError &error);
void feedDifference(
const MTPVector<MTPUser> &users,
const MTPVector<MTPChat> &chats,
const MTPVector<MTPMessage> &msgs,
const MTPVector<MTPUpdate> &other);
void stateDone(const MTPupdates_State &state);
void setState(int32 pts, int32 date, int32 qts, int32 seq);
void channelDifferenceDone(
not_null<ChannelData*> channel,
const MTPupdates_ChannelDifference &diff);
void channelDifferenceFail(
not_null<ChannelData*> channel,
const RPCError &error);
void failDifferenceStartTimerFor(ChannelData *channel);
void feedChannelDifference(const MTPDupdates_channelDifference &data);
void mtpUpdateReceived(const MTPUpdates &updates);
void mtpNewSessionCreated();
void feedUpdateVector(
const MTPVector<MTPUpdate> &updates,
bool skipMessageIds = false);
// Doesn't call sendHistoryChangeNotifications itself.
void feedMessageIds(const MTPVector<MTPUpdate> &updates);
// Doesn't call sendHistoryChangeNotifications itself.
void feedUpdate(const MTPUpdate &update);
bool whenGetDiffChanged(
ChannelData *channel,
int32 ms,
base::flat_map<not_null<ChannelData*>, crl::time> &whenMap,
crl::time &curTime);
const not_null<Main::Session*> _session;
int32 _updatesDate = 0;
int32 _updatesQts = -1;
int32 _updatesSeq = 0;
base::Timer _noUpdatesTimer;
base::Timer _onlineTimer;
PtsWaiter _ptsWaiter;
base::flat_map<not_null<ChannelData*>, crl::time> _whenGetDiffByPts;
base::flat_map<not_null<ChannelData*>, crl::time> _whenGetDiffAfterFail;
crl::time _getDifferenceTimeByPts = 0;
crl::time _getDifferenceTimeAfterFail = 0;
base::Timer _byPtsTimer;
base::flat_map<int32, MTPUpdates> _bySeqUpdates;
base::Timer _bySeqTimer;
base::Timer _byMinChannelTimer;
// growing timeout for getDifference calls, if it fails
crl::time _failDifferenceTimeout = 1;
// growing timeout for getChannelDifference calls, if it fails
base::flat_map<
not_null<ChannelData*>,
crl::time> _channelFailDifferenceTimeout;
base::Timer _failDifferenceTimer;
base::flat_map<
not_null<ChannelData*>,
mtpRequestId> _rangeDifferenceRequests;
crl::time _lastUpdateTime = 0;
bool _handlingChannelDifference = false;
base::flat_map<int, ActiveChatTracker> _activeChats;
mtpRequestId _onlineRequest = 0;
base::Timer _idleFinishTimer;
crl::time _lastSetOnline = 0;
bool _lastWasOnline = false;
bool _isIdle = false;
rpl::lifetime _lifetime;
};
} // namespace Api

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/flat_map.h"
#include "base/flat_set.h"
#include "mtproto/sender.h"
#include "chat_helpers/stickers.h"
#include "data/stickers/data_stickers_set.h"
#include "data/data_messages.h"
class TaskQueue;
@@ -38,6 +38,7 @@ namespace Storage {
enum class SharedMediaType : signed char;
struct PreparedList;
class DownloadMtprotoTask;
class Account;
} // namespace Storage
namespace Dialogs {
@@ -65,6 +66,8 @@ inline QString ToString(uint64 value) {
} // namespace details
class Updates;
template <
typename ...Types,
typename = std::enable_if_t<(sizeof...(Types) > 0)>>
@@ -136,7 +139,9 @@ public:
explicit ApiWrap(not_null<Main::Session*> session);
~ApiWrap();
Main::Session &session() const;
[[nodiscard]] Main::Session &session() const;
[[nodiscard]] Storage::Account &local() const;
[[nodiscard]] Api::Updates &updates() const;
void applyUpdates(
const MTPUpdates &updates,
@@ -152,6 +157,8 @@ public:
MTPInputNotifyPeer peer,
const MTPPeerNotifySettings &settings);
void saveCurrentDraftToCloud();
void savePinnedOrder(Data::Folder *folder);
void toggleHistoryArchived(
not_null<History*> history,
@@ -192,7 +199,6 @@ public:
void requestBots(not_null<ChannelData*> channel);
void requestAdmins(not_null<ChannelData*> channel);
void requestParticipantsCountDelayed(not_null<ChannelData*> channel);
void requestChannelRangeDifference(not_null<History*> history);
using UpdatedFileReferences = Data::UpdatedFileReferences;
using FileReferencesHandler = FnMut<void(const UpdatedFileReferences&)>;
@@ -256,12 +262,11 @@ public:
void clearWebPageRequest(WebPageData *page);
void clearWebPageRequests();
void requestAttachedStickerSets(not_null<PhotoData*> photo);
void scheduleStickerSetRequest(uint64 setId, uint64 access);
void requestStickerSets();
void saveStickerSets(
const Stickers::Order &localOrder,
const Stickers::Order &localRemoved);
const Data::StickersSetsOrder &localOrder,
const Data::StickersSetsOrder &localRemoved);
void updateStickers();
void requestRecentStickersForce();
void setGroupStickerSet(
@@ -308,9 +313,6 @@ public:
bool isQuitPrevent();
void applyUpdatesNoPtsCheck(const MTPUpdates &updates);
void applyUpdateNoPtsCheck(const MTPUpdate &update);
void jumpToDate(Dialogs::Key chat, const QDate &date);
void preloadEnoughUnreadMentions(not_null<History*> history);
@@ -366,11 +368,11 @@ public:
not_null<PeerData*> peer,
const std::vector<not_null<UserData*>> &users);
rpl::producer<SendAction> sendActions() const {
return _sendActions.events();
}
void sendAction(const SendAction &action);
void finishForwarding(const SendAction &action);
void forwardMessages(
HistoryItemsList &&items,
const SendAction &action,
@@ -420,12 +422,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);
@@ -476,10 +472,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>;
@@ -552,15 +544,6 @@ private:
mtpRequestId req);
void gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result);
void channelRangeDifferenceSend(
not_null<ChannelData*> channel,
MsgRange range,
int32 pts);
void channelRangeDifferenceDone(
not_null<ChannelData*> channel,
MsgRange range,
const MTPupdates_ChannelDifference &result);
void stickerSetDisenabled(mtpRequestId requestId);
void stickersSaveOrder();
@@ -707,10 +690,6 @@ private:
base::flat_set<not_null<ChannelData*>> _selfParticipantRequests;
base::flat_map<
not_null<ChannelData*>,
mtpRequestId> _rangeDifferenceRequests;
QMap<WebPageData*, mtpRequestId> _webPagesPending;
base::Timer _webPagesTimer;
@@ -724,7 +703,7 @@ private:
base::Timer _draftsSaveTimer;
base::flat_set<mtpRequestId> _stickerSetDisenableRequests;
Stickers::Order _stickersOrder;
Data::StickersSetsOrder _stickersOrder;
mtpRequestId _stickersReorderRequestId = 0;
mtpRequestId _stickersClearRecentRequestId = 0;
@@ -856,8 +835,6 @@ private:
std::optional<bool> _contactSignupSilent;
rpl::event_stream<bool> _contactSignupSilentChanges;
mtpRequestId _attachedStickerSetsRequestId = 0;
base::flat_map<FullMsgId, QString> _unlikelyMessageLinks;
};

View File

@@ -39,7 +39,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwidget.h"
#include "apiwrap.h"
#include "numbers.h"
#include "observer_peer.h"
#include "main/main_session.h"
#include "styles/style_boxes.h"
#include "styles/style_overview.h"
@@ -75,8 +74,6 @@ using CornersMap = QMap<uint32, CornersPixmaps>;
CornersMap cornersMap;
QImage cornersMaskLarge[4], cornersMaskSmall[4];
int32 serviceImageCacheSize = 0;
} // namespace
namespace App {
@@ -207,16 +204,16 @@ namespace App {
if (update.paletteChanged()) {
createPaletteCorners();
if (App::main()) {
App::main()->updateScrollColors();
if (const auto m = App::main()) { // multi good
m->updateScrollColors();
}
HistoryView::serviceColorsUpdated();
} else if (update.type == Update::Type::New) {
prepareCorners(StickerCorners, st::dateRadius, st::msgServiceBg);
prepareCorners(StickerSelectedCorners, st::dateRadius, st::msgServiceBgSelected);
if (App::main()) {
App::main()->updateScrollColors();
if (const auto m = App::main()) { // multi good
m->updateScrollColors();
}
HistoryView::serviceColorsUpdated();
}
@@ -227,8 +224,6 @@ namespace App {
clearCorners();
Data::clearGlobalStructures();
Images::ClearAll();
}
void hoveredItem(HistoryView::Element *item) {
@@ -322,6 +317,9 @@ namespace App {
}
QImage readImage(QByteArray data, QByteArray *format, bool opaque, bool *animated) {
if (data.isEmpty()) {
return QImage();
}
QByteArray tmpFormat;
QImage result;
QBuffer buffer(&data);

View File

@@ -11,23 +11,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/rect_part.h"
enum class ImageRoundRadius;
class MainWindow;
class MainWidget;
class HistoryItem;
class History;
namespace HistoryView {
class Element;
} // namespace HistoryView
namespace Media {
namespace Clip {
class Reader;
} // namespace Clip
} // namespace Media
using HistoryItemsMap = base::flat_set<not_null<HistoryItem*>>;
using GifItems = QHash<Media::Clip::Reader*, HistoryItem*>;
enum RoundCorners : int {
SmallMaskCorners = 0x00, // for images
LargeMaskCorners,
@@ -97,7 +85,6 @@ namespace App {
void setLaunchState(LaunchState state);
void restart();
constexpr auto kFileSizeLimit = 1500 * 1024 * 1024; // Load files up to 1500mb
constexpr auto kImageSizeLimit = 64 * 1024 * 1024; // Open images up to 64mb jpg/png/gif
QImage readImage(QByteArray data, QByteArray *format = nullptr, bool opaque = true, bool *animated = nullptr);
QImage readImage(const QString &file, QByteArray *format = nullptr, bool opaque = true, bool *animated = nullptr, QByteArray *content = 0);

View File

@@ -34,10 +34,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_chat.h"
#include "data/data_user.h"
#include "data/data_session.h"
#include "data/data_changes.h"
#include "data/data_cloud_file.h"
#include "mainwidget.h"
#include "mainwindow.h"
#include "apiwrap.h"
#include "observer_peer.h"
#include "main/main_session.h"
#include "facades.h"
#include "styles/style_layers.h"
@@ -117,9 +118,11 @@ style::InputField CreateBioFieldStyle() {
return result;
}
QString PeerFloodErrorText(PeerFloodType type) {
auto link = textcmdLink(
Core::App().createInternalLinkFull(qsl("spambot")),
QString PeerFloodErrorText(
not_null<Main::Session*> session,
PeerFloodType type) {
const auto link = textcmdLink(
session->createInternalLinkFull(qsl("spambot")),
tr::lng_cant_more_info(tr::now));
if (type == PeerFloodType::InviteGroup) {
return tr::lng_cant_invite_not_contact(tr::now, lt_more_info, link);
@@ -169,8 +172,7 @@ void ShowAddParticipantsError(
return;
}
}
const auto bot = ranges::find_if(users, &UserData::isBot);
const auto hasBot = (bot != end(users));
const auto hasBot = ranges::any_of(users, &UserData::isBot);
const auto text = [&] {
if (error == qstr("USER_BOT")) {
return tr::lng_cant_invite_bot_to_channel(tr::now);
@@ -189,10 +191,10 @@ void ShowAddParticipantsError(
} else if (error == qstr("BOT_GROUPS_BLOCKED")) {
return tr::lng_error_cant_add_bot(tr::now);
} else if (error == qstr("PEER_FLOOD")) {
const auto isGroup = (chat->isChat() || chat->isMegagroup());
return PeerFloodErrorText(isGroup
const auto type = (chat->isChat() || chat->isMegagroup())
? PeerFloodType::InviteGroup
: PeerFloodType::InviteChannel);
: PeerFloodType::InviteChannel;
return PeerFloodErrorText(&chat->session(), type);
} else if (error == qstr("ADMINS_TOO_MUCH")) {
return ((chat->isChat() || chat->isMegagroup())
? tr::lng_error_admin_limit
@@ -222,6 +224,7 @@ private:
}
not_null<PeerData*> peer;
mutable std::shared_ptr<Data::CloudImageView> userpic;
Ui::Text::String name, status;
};
void paintChat(Painter &p, const ChatRow &row, bool selected) const;
@@ -451,7 +454,7 @@ GroupInfoBox::GroupInfoBox(
const QString &title,
Fn<void(not_null<ChannelData*>)> channelDone)
: _navigation(navigation)
, _api(_navigation->session().api().instance())
, _api(&_navigation->session().mtp())
, _type(type)
, _initialTitle(title)
, _channelDone(std::move(channelDone)) {
@@ -477,7 +480,7 @@ void GroupInfoBox::prepare() {
_title->setMaxLength(kMaxGroupChannelTitle);
_title->setInstantReplaces(Ui::InstantReplaces::Default());
_title->setInstantReplacesEnabled(
_navigation->session().settings().replaceEmojiValue());
Core::App().settings().replaceEmojiValue());
Ui::Emoji::SuggestionsController::Init(
getDelegate()->outerContainer(),
_title,
@@ -493,8 +496,9 @@ void GroupInfoBox::prepare() {
_description->setMaxLength(kMaxChannelDescription);
_description->setInstantReplaces(Ui::InstantReplaces::Default());
_description->setInstantReplacesEnabled(
_navigation->session().settings().replaceEmojiValue());
_description->setSubmitSettings(_navigation->session().settings().sendSubmitWay());
Core::App().settings().replaceEmojiValue());
_description->setSubmitSettings(
Core::App().settings().sendSubmitWay());
connect(_description, &Ui::InputField::resized, [=] { descriptionResized(); });
connect(_description, &Ui::InputField::submitted, [=] { submit(); });
@@ -596,7 +600,9 @@ void GroupInfoBox::createGroup(
} else if (error.type() == qstr("PEER_FLOOD")) {
Ui::show(
Box<InformBox>(
PeerFloodErrorText(PeerFloodType::InviteGroup)),
PeerFloodErrorText(
&_navigation->session(),
PeerFloodType::InviteGroup)),
Ui::LayerOption::KeepOther);
} else if (error.type() == qstr("USER_RESTRICTED")) {
Ui::show(
@@ -748,6 +754,7 @@ SetupChannelBox::SetupChannelBox(
bool existing)
: _navigation(navigation)
, _channel(channel)
, _api(&_channel->session().mtp())
, _existing(existing)
, _privacyGroup(
std::make_shared<Ui::RadioenumGroup<Privacy>>(Privacy::Public))
@@ -787,7 +794,12 @@ SetupChannelBox::SetupChannelBox(
: tr::lng_create_private_channel_about)(tr::now),
_defaultOptions,
_aboutPublicWidth)
, _link(this, st::setupChannelLink, nullptr, channel->username, true) {
, _link(
this,
st::setupChannelLink,
nullptr,
channel->username,
channel->session().createInternalLink(QString())) {
}
void SetupChannelBox::prepare() {
@@ -795,12 +807,12 @@ void SetupChannelBox::prepare() {
setMouseTracking(true);
_checkRequestId = MTP::send(
MTPchannels_CheckUsername(
_channel->inputChannel,
MTP_string("preston")),
RPCDoneHandlerPtr(),
rpcFail(&SetupChannelBox::onFirstCheckFail));
_checkRequestId = _api.request(MTPchannels_CheckUsername(
_channel->inputChannel,
MTP_string("preston")
)).fail([=](const RPCError &error) {
firstCheckFail(error);
}).send();
addButton(tr::lng_settings_save(), [=] { save(); });
addButton(
@@ -814,11 +826,13 @@ void SetupChannelBox::prepare() {
connect(&_checkTimer, &QTimer::timeout, [=] { check(); });
_privacyGroup->setChangedCallback([this](Privacy value) { privacyChanged(value); });
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::InviteLinkChanged, [this](const Notify::PeerUpdate &update) {
if (update.peer == _channel) {
rtlupdate(_invitationLink);
}
}));
_channel->session().changes().peerUpdates(
_channel,
Data::PeerUpdate::Flag::InviteLink
) | rpl::start_with_next([=] {
rtlupdate(_invitationLink);
}, lifetime());
boxClosing() | rpl::start_with_next([=] {
if (!_existing) {
@@ -948,12 +962,22 @@ void SetupChannelBox::updateSelected(const QPoint &cursorGlobalPosition) {
}
void SetupChannelBox::save() {
const auto saveUsername = [&](const QString &link) {
_sentUsername = link;
_saveRequestId = _api.request(MTPchannels_UpdateUsername(
_channel->inputChannel,
MTP_string(_sentUsername)
)).done([=](const MTPBool &result) {
updateDone(result);
}).fail([=](const RPCError &error) {
updateFail(error);
}).send();
};
if (_saveRequestId) {
return;
} else if (_privacyGroup->value() == Privacy::Private) {
if (_existing) {
_sentUsername = QString();
_saveRequestId = MTP::send(MTPchannels_UpdateUsername(_channel->inputChannel, MTP_string(_sentUsername)), rpcDone(&SetupChannelBox::onUpdateDone), rpcFail(&SetupChannelBox::onUpdateFail));
saveUsername(QString());
} else {
closeBox();
}
@@ -964,8 +988,7 @@ void SetupChannelBox::save() {
_link->showError();
return;
}
_sentUsername = link;
_saveRequestId = MTP::send(MTPchannels_UpdateUsername(_channel->inputChannel, MTP_string(_sentUsername)), rpcDone(&SetupChannelBox::onUpdateDone), rpcFail(&SetupChannelBox::onUpdateFail));
saveUsername(link);
}
}
@@ -1008,17 +1031,19 @@ void SetupChannelBox::handleChange() {
void SetupChannelBox::check() {
if (_checkRequestId) {
MTP::cancel(_checkRequestId);
_channel->session().api().request(_checkRequestId).cancel();
}
QString link = _link->text().trimmed();
if (link.size() >= kMinUsernameLength) {
_checkUsername = link;
_checkRequestId = MTP::send(
MTPchannels_CheckUsername(
_channel->inputChannel,
MTP_string(link)),
rpcDone(&SetupChannelBox::onCheckDone),
rpcFail(&SetupChannelBox::onCheckFail));
_checkRequestId = _api.request(MTPchannels_CheckUsername(
_channel->inputChannel,
MTP_string(link)
)).done([=](const MTPBool &result) {
checkDone(result);
}).fail([=](const RPCError &error) {
checkFail(error);
}).send();
}
}
@@ -1051,38 +1076,36 @@ void SetupChannelBox::privacyChanged(Privacy value) {
update();
}
void SetupChannelBox::onUpdateDone(const MTPBool &result) {
void SetupChannelBox::updateDone(const MTPBool &result) {
_channel->setName(TextUtilities::SingleLine(_channel->name), _sentUsername);
closeBox();
}
bool SetupChannelBox::onUpdateFail(const RPCError &error) {
if (MTP::isDefaultHandledError(error)) return false;
void SetupChannelBox::updateFail(const RPCError &error) {
_saveRequestId = 0;
QString err(error.type());
if (err == "USERNAME_NOT_MODIFIED" || _sentUsername == _channel->username) {
_channel->setName(TextUtilities::SingleLine(_channel->name), TextUtilities::SingleLine(_sentUsername));
if (err == "USERNAME_NOT_MODIFIED"
|| _sentUsername == _channel->username) {
_channel->setName(
TextUtilities::SingleLine(_channel->name),
TextUtilities::SingleLine(_sentUsername));
closeBox();
return true;
} else if (err == "USERNAME_INVALID") {
_link->setFocus();
_link->showError();
_errorText = tr::lng_create_channel_link_invalid(tr::now);
update();
return true;
} else if (err == "USERNAME_OCCUPIED" || err == "USERNAMES_UNAVAILABLE") {
_link->setFocus();
_link->showError();
_errorText = tr::lng_create_channel_link_occupied(tr::now);
update();
return true;
} else {
_link->setFocus();
}
_link->setFocus();
return true;
}
void SetupChannelBox::onCheckDone(const MTPBool &result) {
void SetupChannelBox::checkDone(const MTPBool &result) {
_checkRequestId = 0;
QString newError = (mtpIsTrue(result) || _checkUsername == _channel->username) ? QString() : tr::lng_create_channel_link_occupied(tr::now);
QString newGood = newError.isEmpty() ? tr::lng_create_channel_link_available(tr::now) : QString();
@@ -1093,14 +1116,11 @@ void SetupChannelBox::onCheckDone(const MTPBool &result) {
}
}
bool SetupChannelBox::onCheckFail(const RPCError &error) {
if (MTP::isDefaultHandledError(error)) return false;
void SetupChannelBox::checkFail(const RPCError &error) {
_checkRequestId = 0;
QString err(error.type());
if (err == qstr("CHANNEL_PUBLIC_GROUP_NA")) {
Ui::hideLayer();
return true;
} else if (err == qstr("CHANNELS_ADMIN_PUBLIC_TOO_MUCH")) {
if (_existing) {
showRevokePublicLinkBoxForEdit();
@@ -1108,19 +1128,16 @@ bool SetupChannelBox::onCheckFail(const RPCError &error) {
_tooMuchUsernames = true;
_privacyGroup->setValue(Privacy::Private);
}
return true;
} else if (err == qstr("USERNAME_INVALID")) {
_errorText = tr::lng_create_channel_link_invalid(tr::now);
update();
return true;
} else if (err == qstr("USERNAME_OCCUPIED") && _checkUsername != _channel->username) {
_errorText = tr::lng_create_channel_link_occupied(tr::now);
update();
return true;
} else {
_goodText = QString();
_link->setFocus();
}
_goodText = QString();
_link->setFocus();
return true;
}
void SetupChannelBox::showRevokePublicLinkBoxForEdit() {
@@ -1140,14 +1157,11 @@ void SetupChannelBox::showRevokePublicLinkBoxForEdit() {
Ui::LayerOption::KeepOther);
}
bool SetupChannelBox::onFirstCheckFail(const RPCError &error) {
if (MTP::isDefaultHandledError(error)) return false;
void SetupChannelBox::firstCheckFail(const RPCError &error) {
_checkRequestId = 0;
const auto &type = error.type();
if (type == qstr("CHANNEL_PUBLIC_GROUP_NA")) {
Ui::hideLayer();
return true;
} else if (type == qstr("CHANNELS_ADMIN_PUBLIC_TOO_MUCH")) {
if (_existing) {
showRevokePublicLinkBoxForEdit();
@@ -1155,15 +1169,15 @@ bool SetupChannelBox::onFirstCheckFail(const RPCError &error) {
_tooMuchUsernames = true;
_privacyGroup->setValue(Privacy::Private);
}
return true;
} else {
_goodText = QString();
_link->setFocus();
}
_goodText = QString();
_link->setFocus();
return true;
}
EditNameBox::EditNameBox(QWidget*, not_null<UserData*> user)
: _user(user)
, _api(&_user->session().mtp())
, _first(this, st::defaultInputField, tr::lng_signup_firstname(), _user->firstName)
, _last(this, st::defaultInputField, tr::lng_signup_lastname(), _user->lastName)
, _invertOrder(langFirstNameGoesSecond()) {
@@ -1246,14 +1260,16 @@ void EditNameBox::save() {
_sentName = first;
auto flags = MTPaccount_UpdateProfile::Flag::f_first_name
| MTPaccount_UpdateProfile::Flag::f_last_name;
_requestId = MTP::send(
MTPaccount_UpdateProfile(
MTP_flags(flags),
MTP_string(first),
MTP_string(last),
MTPstring()),
rpcDone(&EditNameBox::saveSelfDone),
rpcFail(&EditNameBox::saveSelfFail));
_requestId = _api.request(MTPaccount_UpdateProfile(
MTP_flags(flags),
MTP_string(first),
MTP_string(last),
MTPstring()
)).done([=](const MTPUser &result) {
saveSelfDone(result);
}).fail([=](const RPCError &error) {
saveSelfFail(error);
}).send();
}
void EditNameBox::saveSelfDone(const MTPUser &user) {
@@ -1261,27 +1277,22 @@ void EditNameBox::saveSelfDone(const MTPUser &user) {
closeBox();
}
bool EditNameBox::saveSelfFail(const RPCError &error) {
if (MTP::isDefaultHandledError(error)) return false;
void EditNameBox::saveSelfFail(const RPCError &error) {
auto err = error.type();
auto first = TextUtilities::SingleLine(_first->getLastText().trimmed());
auto last = TextUtilities::SingleLine(_last->getLastText().trimmed());
if (err == "NAME_NOT_MODIFIED") {
_user->setName(first, last, QString(), TextUtilities::SingleLine(_user->username));
closeBox();
return true;
} else if (err == "FIRSTNAME_INVALID") {
_first->setFocus();
_first->showError();
return true;
} else if (err == "LASTNAME_INVALID") {
_last->setFocus();
_last->showError();
return true;
} else {
_first->setFocus();
}
_first->setFocus();
return true;
}
RevokePublicLinkBox::Inner::Inner(
@@ -1290,7 +1301,7 @@ RevokePublicLinkBox::Inner::Inner(
Fn<void()> revokeCallback)
: TWidget(parent)
, _session(session)
, _api(_session->api().instance())
, _api(&_session->mtp())
, _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
, _revokeWidth(st::normalFont->width(tr::lng_channels_too_much_public_revoke(tr::now)))
, _revokeCallback(std::move(revokeCallback)) {
@@ -1318,7 +1329,7 @@ RevokePublicLinkBox::Inner::Inner(
Ui::NameTextOptions());
row.status.setText(
st::defaultTextStyle,
Core::App().createInternalLink(
_session->createInternalLink(
textcmdLink(1, peer->userName())),
Ui::DialogTextOptions());
_rows.push_back(std::move(row));
@@ -1353,7 +1364,10 @@ void RevokePublicLinkBox::prepare() {
addButton(tr::lng_cancel(), [=] { closeBox(); });
subscribe(_session->downloaderTaskFinished(), [=] { update(); });
_session->downloaderTaskFinished(
) | rpl::start_with_next([=] {
update();
}, lifetime());
_inner->resizeToWidth(st::boxWideWidth);
setDimensions(st::boxWideWidth, _innerTop + _inner->height());
@@ -1399,7 +1413,7 @@ void RevokePublicLinkBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
auto text = text_method(
tr::now,
lt_link,
Core::App().createInternalLink(pressed->userName()),
_session->createInternalLink(pressed->userName()),
lt_group,
pressed->name);
auto confirmText = tr::lng_channels_too_much_public_revoke(tr::now);
@@ -1438,7 +1452,7 @@ void RevokePublicLinkBox::resizeEvent(QResizeEvent *e) {
void RevokePublicLinkBox::Inner::paintChat(Painter &p, const ChatRow &row, bool selected) const {
auto peer = row.peer;
peer->paintUserpicLeft(p, st::contactsPadding.left(), st::contactsPadding.top(), width(), st::contactsPhotoSize);
peer->paintUserpicLeft(p, row.userpic, st::contactsPadding.left(), st::contactsPadding.top(), width(), st::contactsPhotoSize);
p.setPen(st::contactsNameFg);

View File

@@ -46,9 +46,11 @@ enum class PeerFloodType {
InviteChannel,
};
style::InputField CreateBioFieldStyle();
[[nodiscard]] style::InputField CreateBioFieldStyle();
QString PeerFloodErrorText(PeerFloodType type);
[[nodiscard]] QString PeerFloodErrorText(
not_null<Main::Session*> session,
PeerFloodType type);
void ShowAddParticipantsError(
const QString &error,
not_null<PeerData*> chat,
@@ -140,9 +142,8 @@ private:
};
class SetupChannelBox
class SetupChannelBox final
: public Ui::BoxContent
, public RPCSender
, private base::Subscriber {
public:
SetupChannelBox(
@@ -174,12 +175,12 @@ private:
void check();
void save();
void onUpdateDone(const MTPBool &result);
bool onUpdateFail(const RPCError &error);
void updateDone(const MTPBool &result);
void updateFail(const RPCError &error);
void onCheckDone(const MTPBool &result);
bool onCheckFail(const RPCError &error);
bool onFirstCheckFail(const RPCError &error);
void checkDone(const MTPBool &result);
void checkFail(const RPCError &error);
void firstCheckFail(const RPCError &error);
void updateMaxHeight();
@@ -187,6 +188,7 @@ private:
const not_null<Window::SessionNavigation*> _navigation;
const not_null<ChannelData*> _channel;
MTP::Sender _api;
bool _existing = false;
@@ -210,7 +212,7 @@ private:
};
class EditNameBox : public Ui::BoxContent, public RPCSender {
class EditNameBox : public Ui::BoxContent {
public:
EditNameBox(QWidget*, not_null<UserData*> user);
@@ -224,9 +226,10 @@ private:
void submit();
void save();
void saveSelfDone(const MTPUser &user);
bool saveSelfFail(const RPCError &error);
void saveSelfFail(const RPCError &error);
not_null<UserData*> _user;
const not_null<UserData*> _user;
MTP::Sender _api;
object_ptr<Ui::InputField> _first;
object_ptr<Ui::InputField> _last;
@@ -238,9 +241,8 @@ private:
};
class RevokePublicLinkBox
class RevokePublicLinkBox final
: public Ui::BoxContent
, public RPCSender
, private base::Subscriber {
public:
RevokePublicLinkBox(

View File

@@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "main/main_session.h"
#include "main/main_session_settings.h"
#include "data/data_session.h"
#include "data/data_auto_download.h"
#include "ui/widgets/continuous_sliders.h"
@@ -96,9 +97,6 @@ void AutoDownloadBox::setupContent() {
setTitle(tr::lng_profile_settings_section());
const auto settings = &_session->settings().autoDownload();
const auto checked = [=](Source source, Type type) {
return (settings->bytesLimit(source, type) > 0);
};
auto wrap = object_ptr<Ui::VerticalLayout>(this);
const auto content = wrap.data();
@@ -171,26 +169,26 @@ void AutoDownloadBox::setupContent() {
}) | ranges::view::transform([](Pair pair) {
return pair.first;
});
const auto less = ranges::find_if(*autoPlayValues, [&](Pair pair) {
const auto less = ranges::any_of(*autoPlayValues, [&](Pair pair) {
const auto [type, enabled] = pair;
const auto value = enabled ? limitByType(type) : 0;
return value < settings->bytesLimit(_source, type);
}) != end(*autoPlayValues);
});
const auto allowMoreTypes = base::flat_set<Type>(
allowMore.begin(),
allowMore.end());
const auto changed = ranges::find_if(values, [&](Pair pair) {
const auto changed = ranges::any_of(values, [&](Pair pair) {
const auto [type, enabled] = pair;
const auto value = enabled ? limitByType(type) : 0;
return value != settings->bytesLimit(_source, type);
}) != end(values);
});
const auto &kHidden = kStreamedTypes;
const auto hiddenChanged = ranges::find_if(kHidden, [&](Type type) {
const auto hiddenChanged = ranges::any_of(kHidden, [&](Type type) {
const auto now = settings->bytesLimit(_source, type);
return (now > 0) && (now != limitByType(type));
}) != end(kHidden);
});
if (changed) {
for (const auto [type, enabled] : values) {
@@ -210,17 +208,16 @@ void AutoDownloadBox::setupContent() {
}
}
if (changed || hiddenChanged) {
Local::writeUserSettings();
_session->saveSettingsDelayed();
}
if (allowMoreTypes.contains(Type::Photo)) {
_session->data().photoLoadSettingsChanged();
}
if (ranges::find_if(allowMoreTypes, _1 != Type::Photo)
!= allowMoreTypes.end()) {
if (ranges::any_of(allowMoreTypes, _1 != Type::Photo)) {
_session->data().documentLoadSettingsChanged();
}
if (less) {
_session->data().checkPlayingVideoFiles();
_session->data().checkPlayingAnimations();
}
closeBox();
});

View File

@@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "storage/localstorage.h"
#include "core/application.h"
#include "mainwindow.h"
#include "ui/widgets/checkbox.h"
#include "facades.h"
@@ -26,7 +27,8 @@ void AutoLockBox::prepare() {
auto options = { 60, 300, 3600, 18000 };
auto group = std::make_shared<Ui::RadiobuttonGroup>(Global::AutoLock());
auto group = std::make_shared<Ui::RadiobuttonGroup>(
Core::App().settings().autoLock());
auto y = st::boxOptionListPadding.top() + st::autolockButton.margin.top();
auto count = int(options.size());
_options.reserve(count);
@@ -41,10 +43,10 @@ void AutoLockBox::prepare() {
}
void AutoLockBox::durationChanged(int seconds) {
Global::SetAutoLock(seconds);
Local::writeUserSettings();
Core::App().settings().setAutoLock(seconds);
Core::App().saveSettingsDelayed();
Global::RefLocalPasscodeChanged().notify();
_session->checkAutoLock();
Core::App().checkAutoLock();
closeBox();
}

View File

@@ -16,8 +16,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mtproto/sender.h"
#include "data/data_session.h"
#include "data/data_file_origin.h"
#include "data/data_document.h"
#include "data/data_document_media.h"
#include "boxes/background_preview_box.h"
#include "boxes/confirm_box.h"
#include "window/window_session_controller.h"
#include "app.h"
#include "styles/style_overview.h"
#include "styles/style_layers.h"
@@ -53,28 +56,33 @@ QImage TakeMiddleSample(QImage original, QSize size) {
} // namespace
class BackgroundBox::Inner : public Ui::RpWidget, private base::Subscriber {
class BackgroundBox::Inner final
: public Ui::RpWidget
, private base::Subscriber {
public:
Inner(
QWidget *parent,
not_null<Main::Session*> session);
~Inner();
rpl::producer<Data::WallPaper> chooseEvents() const;
rpl::producer<Data::WallPaper> removeRequests() const;
void removePaper(const Data::WallPaper &data);
~Inner();
protected:
private:
void paintEvent(QPaintEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
private:
void visibleTopBottomUpdated(
int visibleTop,
int visibleBottom) override;
struct Paper {
Data::WallPaper data;
mutable std::shared_ptr<Data::DocumentMedia> dataMedia;
mutable QPixmap thumbnail;
};
struct Selected {
@@ -124,8 +132,10 @@ private:
};
BackgroundBox::BackgroundBox(QWidget*, not_null<Main::Session*> session)
: _session(session) {
BackgroundBox::BackgroundBox(
QWidget*,
not_null<Window::SessionController*> controller)
: _controller(controller) {
}
void BackgroundBox::prepare() {
@@ -136,13 +146,13 @@ void BackgroundBox::prepare() {
setDimensions(st::boxWideWidth, st::boxMaxListHeight);
_inner = setInnerWidget(
object_ptr<Inner>(this, _session),
object_ptr<Inner>(this, &_controller->session()),
st::backgroundScroll);
_inner->chooseEvents(
) | rpl::start_with_next([=](const Data::WallPaper &paper) {
Ui::show(
Box<BackgroundPreviewBox>(_session, paper),
Box<BackgroundPreviewBox>(_controller, paper),
Ui::LayerOption::KeepOther);
}, _inner->lifetime());
@@ -154,7 +164,7 @@ void BackgroundBox::prepare() {
void BackgroundBox::removePaper(const Data::WallPaper &paper) {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>();
const auto session = _session;
const auto session = &_controller->session();
const auto remove = [=, weak = Ui::MakeWeak(this)]{
if (*box) {
(*box)->closeBox();
@@ -164,7 +174,7 @@ void BackgroundBox::removePaper(const Data::WallPaper &paper) {
}
session->data().removeWallpaper(paper);
session->api().request(MTPaccount_SaveWallPaper(
paper.mtpInput(),
paper.mtpInput(session),
MTP_bool(true),
paper.mtpSettings()
)).send();
@@ -183,7 +193,7 @@ BackgroundBox::Inner::Inner(
not_null<Main::Session*> session)
: RpWidget(parent)
, _session(session)
, _api(_session->api().instance())
, _api(&_session->mtp())
, _check(std::make_unique<Ui::RoundCheckbox>(st::overviewCheck, [=] { update(); })) {
_check->setChecked(true, anim::type::instant);
if (_session->data().wallpapers().empty()) {
@@ -193,7 +203,10 @@ BackgroundBox::Inner::Inner(
}
requestPapers();
subscribe(_session->downloaderTaskFinished(), [=] { update(); });
_session->downloaderTaskFinished(
) | rpl::start_with_next([=] {
update();
}, lifetime());
using Update = Window::Theme::BackgroundUpdate;
subscribe(Window::Theme::Background(), [=](const Update &update) {
if (update.paletteChanged()) {
@@ -252,11 +265,19 @@ void BackgroundBox::Inner::resizeToContentAndPreload() {
const auto rows = (count / kBackgroundsInRow)
+ (count % kBackgroundsInRow ? 1 : 0);
resize(st::boxWideWidth, rows * (st::backgroundSize.height() + st::backgroundPadding) + st::backgroundPadding);
resize(
st::boxWideWidth,
(rows * (st::backgroundSize.height() + st::backgroundPadding)
+ st::backgroundPadding));
const auto preload = kBackgroundsInRow * 3;
for (const auto &paper : _papers | ranges::view::take(preload)) {
paper.data.loadThumbnail();
if (!paper.data.localThumbnail() && !paper.dataMedia) {
if (const auto document = paper.data.document()) {
paper.dataMedia = document->createMediaView();
paper.dataMedia->thumbnailWanted(paper.data.fileOrigin());
}
}
}
update();
}
@@ -292,15 +313,24 @@ void BackgroundBox::Inner::paintEvent(QPaintEvent *e) {
void BackgroundBox::Inner::validatePaperThumbnail(
const Paper &paper) const {
Expects(paper.data.thumbnail() != nullptr);
const auto thumbnail = paper.data.thumbnail();
if (!paper.thumbnail.isNull()) {
return;
} else if (!thumbnail->loaded()) {
thumbnail->load(paper.data.fileOrigin());
return;
}
const auto localThumbnail = paper.data.localThumbnail();
if (!localThumbnail) {
if (const auto document = paper.data.document()) {
if (!paper.dataMedia) {
paper.dataMedia = document->createMediaView();
paper.dataMedia->thumbnailWanted(paper.data.fileOrigin());
}
}
if (!paper.dataMedia || !paper.dataMedia->thumbnail()) {
return;
}
}
const auto thumbnail = localThumbnail
? localThumbnail
: paper.dataMedia->thumbnail();
auto original = thumbnail->original();
if (paper.data.isPattern()) {
const auto color = *paper.data.backgroundColor();
@@ -428,7 +458,14 @@ void BackgroundBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
if (base::get_if<DeleteSelected>(&_over)) {
_backgroundRemove.fire_copy(_papers[index].data);
} else if (base::get_if<Selected>(&_over)) {
_backgroundChosen.fire_copy(_papers[index].data);
auto &paper = _papers[index];
if (!paper.dataMedia) {
if (const auto document = paper.data.document()) {
// Keep it alive while it is on the screen.
paper.dataMedia = document->createMediaView();
}
}
_backgroundChosen.fire_copy(paper.data);
}
}
} else if (!_over.has_value()) {
@@ -436,6 +473,22 @@ void BackgroundBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
}
}
void BackgroundBox::Inner::visibleTopBottomUpdated(
int visibleTop,
int visibleBottom) {
for (auto i = 0, count = int(_papers.size()); i != count; ++i) {
const auto row = (i / kBackgroundsInRow);
const auto height = st::backgroundSize.height();
const auto skip = st::backgroundPadding;
const auto top = skip + row * (height + skip);
const auto bottom = top + height;
if ((bottom <= visibleTop || top >= visibleBottom)
&& !_papers[i].thumbnail.isNull()) {
_papers[i].dataMedia = nullptr;
}
}
}
rpl::producer<Data::WallPaper> BackgroundBox::Inner::chooseEvents() const {
return _backgroundChosen.events();
}

View File

@@ -9,9 +9,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/abstract_box.h"
namespace Main {
class Session;
} // namespace Main
namespace Window {
class SessionController;
} // namespace Window
namespace Data {
class WallPaper;
@@ -19,7 +19,7 @@ class WallPaper;
class BackgroundBox : public Ui::BoxContent {
public:
BackgroundBox(QWidget*, not_null<Main::Session*> session);
BackgroundBox(QWidget*, not_null<Window::SessionController*> controller);
protected:
void prepare() override;
@@ -29,7 +29,7 @@ private:
void removePaper(const Data::WallPaper &paper);
const not_null<Main::Session*> _session;
const not_null<Window::SessionController*> _controller;
QPointer<Inner> _inner;

View File

@@ -22,9 +22,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h"
#include "data/data_user.h"
#include "data/data_document.h"
#include "data/data_document_media.h"
#include "data/data_file_origin.h"
#include "base/unixtime.h"
#include "boxes/confirm_box.h"
#include "boxes/background_preview_box.h"
#include "window/window_session_controller.h"
#include "app.h"
#include "styles/style_history.h"
#include "styles/style_layers.h"
@@ -268,14 +271,14 @@ bool ServiceCheck::checkRippleStartPosition(QPoint position) const {
if (slug.isEmpty() || slug.size() > kMaxWallPaperSlugLength) {
return false;
}
return ranges::find_if(slug, [](QChar ch) {
return ranges::none_of(slug, [](QChar ch) {
return (ch != '.')
&& (ch != '_')
&& (ch != '-')
&& (ch < '0' || ch > '9')
&& (ch < 'a' || ch > 'z')
&& (ch < 'A' || ch > 'Z');
}) == slug.end();
});
}
AdminLog::OwnedItem GenerateTextItem(
@@ -345,7 +348,6 @@ QImage ColorizePattern(QImage image, QColor color) {
const auto height = image.height();
const auto pattern = anim::shifted(color);
const auto resultBytesPerPixel = (image.depth() >> 3);
constexpr auto resultIntsPerPixel = 1;
const auto resultIntsPerLine = (image.bytesPerLine() >> 2);
const auto resultIntsAdded = resultIntsPerLine - width * resultIntsPerPixel;
@@ -394,24 +396,32 @@ QImage PrepareScaledFromFull(
BackgroundPreviewBox::BackgroundPreviewBox(
QWidget*,
not_null<Main::Session*> session,
not_null<Window::SessionController*> controller,
const Data::WallPaper &paper)
: _session(session)
: SimpleElementDelegate(controller)
, _controller(controller)
, _text1(GenerateTextItem(
delegate(),
_session->data().history(
_controller->session().data().history(
peerFromUser(PeerData::kServiceNotificationsId)),
tr::lng_background_text1(tr::now),
false))
, _text2(GenerateTextItem(
delegate(),
_session->data().history(
_controller->session().data().history(
peerFromUser(PeerData::kServiceNotificationsId)),
tr::lng_background_text2(tr::now),
true))
, _paper(paper)
, _media(_paper.document() ? _paper.document()->createMediaView() : nullptr)
, _radial([=](crl::time now) { radialAnimationCallback(now); }) {
subscribe(_session->downloaderTaskFinished(), [=] { update(); });
if (_media) {
_media->thumbnailWanted(_paper.fileOrigin());
}
_controller->session().downloaderTaskFinished(
) | rpl::start_with_next([=] {
update();
}, lifetime());
}
not_null<HistoryView::ElementDelegate*> BackgroundPreviewBox::delegate() {
@@ -428,12 +438,14 @@ void BackgroundPreviewBox::prepare() {
}
updateServiceBg(_paper.backgroundColor());
_paper.loadThumbnail();
_paper.loadDocument();
if (_paper.document() && _paper.document()->loading()) {
_radial.start(_paper.document()->progress());
const auto document = _paper.document();
if (document && document->loading()) {
_radial.start(_media->progress());
}
if (_paper.thumbnail() && !_paper.isPattern()) {
if (!_paper.isPattern()
&& (_paper.localThumbnail()
|| (document && document->hasThumbnail()))) {
createBlurCheckbox();
}
setScaledFromThumb();
@@ -492,10 +504,10 @@ void BackgroundPreviewBox::createBlurCheckbox() {
void BackgroundPreviewBox::apply() {
const auto install = (_paper.id() != Window::Theme::Background()->id())
&& Data::IsCloudWallPaper(_paper);
App::main()->setChatBackground(_paper, std::move(_full));
_controller->content()->setChatBackground(_paper, std::move(_full));
if (install) {
_session->api().request(MTPaccount_InstallWallPaper(
_paper.mtpInput(),
_controller->session().api().request(MTPaccount_InstallWallPaper(
_paper.mtpInput(&_controller->session()),
_paper.mtpSettings()
)).send();
}
@@ -503,7 +515,8 @@ void BackgroundPreviewBox::apply() {
}
void BackgroundPreviewBox::share() {
QGuiApplication::clipboard()->setText(_paper.shareUrl());
QGuiApplication::clipboard()->setText(
_paper.shareUrl(&_controller->session()));
Ui::Toast::Show(tr::lng_background_link_copied(tr::now));
}
@@ -634,7 +647,7 @@ void BackgroundPreviewBox::radialAnimationCallback(crl::time now) {
const auto document = _paper.document();
const auto wasAnimating = _radial.animating();
const auto updated = _radial.update(
document->progress(),
_media->progress(),
!document->loading(),
now);
if ((wasAnimating || _radial.animating())
@@ -645,8 +658,13 @@ void BackgroundPreviewBox::radialAnimationCallback(crl::time now) {
}
bool BackgroundPreviewBox::setScaledFromThumb() {
const auto thumbnail = _paper.thumbnail();
if (!thumbnail || !thumbnail->loaded()) {
const auto localThumbnail = _paper.localThumbnail();
const auto thumbnail = localThumbnail
? localThumbnail
: _media
? _media->thumbnail()
: nullptr;
if (!thumbnail) {
return false;
} else if (_paper.isPattern() && _paper.document() != nullptr) {
return false;
@@ -710,7 +728,7 @@ void BackgroundPreviewBox::checkLoadedDocument() {
const auto document = _paper.document();
if (!_full.isNull()
|| !document
|| !document->loaded(DocumentData::FilePathResolve::Checked)
|| !_media->loaded(true)
|| _generating) {
return;
}
@@ -725,7 +743,6 @@ void BackgroundPreviewBox::checkLoadedDocument() {
guard = _generating.make_guard()
]() mutable {
auto scaled = PrepareScaledFromFull(image, patternBackground);
const auto ms = crl::now();
auto blurred = patternBackground
? QImage()
: PrepareScaledNonPattern(
@@ -744,18 +761,18 @@ void BackgroundPreviewBox::checkLoadedDocument() {
});
};
_generating = Data::ReadImageAsync(
document,
_media.get(),
Window::Theme::ProcessBackgroundImage,
generateCallback);
}
bool BackgroundPreviewBox::Start(
not_null<Main::Session*> session,
not_null<Window::SessionController*> controller,
const QString &slug,
const QMap<QString, QString> &params) {
if (const auto paper = Data::WallPaper::FromColorSlug(slug)) {
Ui::show(Box<BackgroundPreviewBox>(
session,
controller,
paper->withUrlParams(params)));
return true;
}
@@ -763,11 +780,12 @@ bool BackgroundPreviewBox::Start(
Ui::show(Box<InformBox>(tr::lng_background_bad_link(tr::now)));
return false;
}
session->api().requestWallPaper(slug, [=](const Data::WallPaper &result) {
controller->session().api().requestWallPaper(slug, crl::guard(controller, [=](
const Data::WallPaper &result) {
Ui::show(Box<BackgroundPreviewBox>(
session,
controller,
result.withUrlParams(params)));
}, [](const RPCError &error) {
}), [](const RPCError &error) {
Ui::show(Box<InformBox>(tr::lng_background_bad_link(tr::now)));
});
return true;

View File

@@ -15,9 +15,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/animations.h"
#include "ui/effects/radial_animation.h"
namespace Main {
class Session;
} // namespace Main
namespace Data {
class DocumentMedia;
} // namespace Data
namespace Window {
class SessionController;
} // namespace Window
namespace Ui {
class Checkbox;
@@ -30,11 +34,11 @@ class BackgroundPreviewBox
public:
BackgroundPreviewBox(
QWidget*,
not_null<Main::Session*> session,
not_null<Window::SessionController*> controller,
const Data::WallPaper &paper);
static bool Start(
not_null<Main::Session*> session,
not_null<Window::SessionController*> controller,
const QString &slug,
const QMap<QString, QString> &params);
@@ -67,10 +71,11 @@ private:
void startFadeInFrom(QPixmap previous);
void checkBlurAnimationStart();
const not_null<Main::Session*> _session;
const not_null<Window::SessionController*> _controller;
AdminLog::OwnedItem _text1;
AdminLog::OwnedItem _text2;
Data::WallPaper _paper;
std::shared_ptr<Data::DocumentMedia> _media;
QImage _full;
QPixmap _scaled, _blurred, _fadeOutThumbnail;
Ui::Animations::Simple _fadeIn;

View File

@@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "boxes/calendar_box.h"
#include "mtproto/mtproto_rpc_sender.h"
#include "ui/widgets/buttons.h"
#include "lang/lang_keys.h"
#include "ui/effects/ripple_animation.h"
@@ -123,8 +122,6 @@ void CalendarBox::Context::applyMonth(const QDate &month, bool forced) {
_daysCount = month.daysInMonth();
_daysShift = daysShiftForMonth(month);
_rowsCount = rowsCountForMonth(month);
auto yearIndex = month.year();
auto monthIndex = month.month();
_highlightedIndex = month.daysTo(_highlighted);
_minDayIndex = _min.isNull() ? INT_MIN : month.daysTo(_min);
_maxDayIndex = _max.isNull() ? INT_MAX : month.daysTo(_max);
@@ -199,7 +196,7 @@ QString CalendarBox::Context::labelFromIndex(int index) const {
return QString::number(day());
}
class CalendarBox::Inner : public TWidget, public RPCSender, private base::Subscriber {
class CalendarBox::Inner : public TWidget, private base::Subscriber {
public:
Inner(
QWidget *parent,
@@ -303,7 +300,6 @@ int CalendarBox::Inner::rowsTop() const {
void CalendarBox::Inner::paintRows(Painter &p, QRect clip) {
p.setFont(st::calendarDaysFont);
auto ms = crl::now();
auto y = rowsTop();
auto index = -_context->daysShift();
auto highlightedIndex = _context->highlightedIndex();

View File

@@ -19,6 +19,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "data/data_session.h"
#include "data/data_user.h"
#include "mtproto/sender.h"
#include "apiwrap.h"
#include "app.h"
#include "styles/style_layers.h"
#include "styles/style_boxes.h"
@@ -75,14 +77,15 @@ protected:
private:
void submit();
void sendPhoneDone(const QString &phoneNumber, const MTPauth_SentCode &result);
bool sendPhoneFail(const QString &phoneNumber, const RPCError &error);
void sendPhoneDone(const MTPauth_SentCode &result, const QString &phoneNumber);
void sendPhoneFail(const RPCError &error, const QString &phoneNumber);
void showError(const QString &text);
void hideError() {
showError(QString());
}
const not_null<Main::Session*> _session;
MTP::Sender _api;
object_ptr<Ui::PhoneInput> _phone = { nullptr };
object_ptr<Ui::FadeWrap<Ui::FlatLabel>> _error = { nullptr };
@@ -111,7 +114,7 @@ private:
void submit();
void sendCall();
void updateCall();
bool sendCodeFail(const RPCError &error);
void sendCodeFail(const RPCError &error);
void showError(const QString &text);
void hideError() {
showError(QString());
@@ -119,6 +122,7 @@ private:
int countHeight();
const not_null<Main::Session*> _session;
MTP::Sender _api;
QString _phone;
QString _hash;
@@ -135,7 +139,8 @@ private:
ChangePhoneBox::EnterPhone::EnterPhone(
QWidget*,
not_null<Main::Session*> session)
: _session(session) {
: _session(session)
, _api(&session->mtp()) {
}
void ChangePhoneBox::EnterPhone::prepare() {
@@ -170,20 +175,19 @@ void ChangePhoneBox::EnterPhone::submit() {
hideError();
auto phoneNumber = _phone->getLastText().trimmed();
_requestId = MTP::send(
MTPaccount_SendChangePhoneCode(
MTP_string(phoneNumber),
MTP_codeSettings(MTP_flags(0))),
rpcDone(crl::guard(this, [=](
const MTPauth_SentCode &result) {
return sendPhoneDone(phoneNumber, result);
})), rpcFail(crl::guard(this, [=](
const RPCError &error) {
return sendPhoneFail(phoneNumber, error);
})));
_requestId = _api.request(MTPaccount_SendChangePhoneCode(
MTP_string(phoneNumber),
MTP_codeSettings(MTP_flags(0))
)).done([=](const MTPauth_SentCode &result) {
sendPhoneDone(result, phoneNumber);
}).fail([=](const RPCError &error) {
sendPhoneFail(error, phoneNumber);
}).handleFloodErrors().send();
}
void ChangePhoneBox::EnterPhone::sendPhoneDone(const QString &phoneNumber, const MTPauth_SentCode &result) {
void ChangePhoneBox::EnterPhone::sendPhoneDone(
const MTPauth_SentCode &result,
const QString &phoneNumber) {
Expects(result.type() == mtpc_auth_sentCode);
_requestId = 0;
@@ -218,18 +222,14 @@ void ChangePhoneBox::EnterPhone::sendPhoneDone(const QString &phoneNumber, const
Ui::LayerOption::KeepOther);
}
bool ChangePhoneBox::EnterPhone::sendPhoneFail(const QString &phoneNumber, const RPCError &error) {
auto errorText = Lang::Hard::ServerError();
void ChangePhoneBox::EnterPhone::sendPhoneFail(const RPCError &error, const QString &phoneNumber) {
_requestId = 0;
if (MTP::isFloodError(error)) {
errorText = tr::lng_flood_error(tr::now);
} else if (MTP::isDefaultHandledError(error)) {
return false;
showError(tr::lng_flood_error(tr::now));
} else if (error.type() == qstr("PHONE_NUMBER_INVALID")) {
errorText = tr::lng_bad_phone(tr::now);
showError(tr::lng_bad_phone(tr::now));
} else if (error.type() == qstr("PHONE_NUMBER_BANNED")) {
ShowPhoneBannedError(phoneNumber);
_requestId = 0;
return true;
} else if (error.type() == qstr("PHONE_NUMBER_OCCUPIED")) {
Ui::show(Box<InformBox>(
tr::lng_change_phone_occupied(
@@ -237,12 +237,9 @@ bool ChangePhoneBox::EnterPhone::sendPhoneFail(const QString &phoneNumber, const
lt_phone,
App::formatPhone(phoneNumber)),
tr::lng_box_ok(tr::now)));
_requestId = 0;
return true;
} else {
showError(Lang::Hard::ServerError());
}
showError(errorText);
_requestId = 0;
return true;
}
void ChangePhoneBox::EnterPhone::showError(const QString &text) {
@@ -260,6 +257,7 @@ ChangePhoneBox::EnterCode::EnterCode(
int codeLength,
int callTimeout)
: _session(session)
, _api(&session->mtp())
, _phone(phone)
, _hash(hash)
, _codeLength(codeLength)
@@ -312,25 +310,28 @@ void ChangePhoneBox::EnterCode::submit() {
const auto session = _session;
const auto code = _code->getDigitsOnly();
const auto weak = Ui::MakeWeak(this);
_requestId = MTP::send(MTPaccount_ChangePhone(
_requestId = session->api().request(MTPaccount_ChangePhone(
MTP_string(_phone),
MTP_string(_hash),
MTP_string(code)
), rpcDone([=](const MTPUser &result) {
)).done([=](const MTPUser &result) {
session->data().processUser(result);
if (weak) {
Ui::hideLayer();
}
Ui::Toast::Show(tr::lng_change_phone_success(tr::now));
}), rpcFail(crl::guard(this, [this](const RPCError &error) {
return sendCodeFail(error);
})));
}).fail(crl::guard(this, [=](const RPCError &error) {
sendCodeFail(error);
})).handleFloodErrors().send();
}
void ChangePhoneBox::EnterCode::sendCall() {
MTP::send(MTPauth_ResendCode(MTP_string(_phone), MTP_string(_hash)), rpcDone(crl::guard(this, [this] {
_api.request(MTPauth_ResendCode(
MTP_string(_phone),
MTP_string(_hash)
)).done([=](const MTPauth_SentCode &result) {
_call.callDone();
})));
}).send();
}
void ChangePhoneBox::EnterCode::updateCall() {
@@ -353,25 +354,20 @@ void ChangePhoneBox::EnterCode::showError(const QString &text) {
}
}
bool ChangePhoneBox::EnterCode::sendCodeFail(const RPCError &error) {
auto errorText = Lang::Hard::ServerError();
void ChangePhoneBox::EnterCode::sendCodeFail(const RPCError &error) {
_requestId = 0;
if (MTP::isFloodError(error)) {
errorText = tr::lng_flood_error(tr::now);
} else if (MTP::isDefaultHandledError(error)) {
return false;
showError(tr::lng_flood_error(tr::now));
} else if (error.type() == qstr("PHONE_CODE_EMPTY") || error.type() == qstr("PHONE_CODE_INVALID")) {
errorText = tr::lng_bad_code(tr::now);
showError(tr::lng_bad_code(tr::now));
} else if (error.type() == qstr("PHONE_CODE_EXPIRED")
|| error.type() == qstr("PHONE_NUMBER_BANNED")) {
closeBox(); // Go back to phone input.
_requestId = 0;
return true;
} else if (error.type() == qstr("PHONE_NUMBER_INVALID")) {
errorText = tr::lng_bad_phone(tr::now);
showError(tr::lng_bad_phone(tr::now));
} else {
showError(Lang::Hard::ServerError());
}
_requestId = 0;
showError(errorText);
return true;
}
ChangePhoneBox::ChangePhoneBox(QWidget*, not_null<Main::Session*> session)

View File

@@ -32,10 +32,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_user.h"
#include "data/data_file_origin.h"
#include "data/data_histories.h"
#include "data/data_photo_media.h"
#include "data/data_changes.h"
#include "base/unixtime.h"
#include "main/main_session.h"
#include "observer_peer.h"
#include "facades.h"
#include "mtproto/mtproto_config.h"
#include "facades.h" // Ui::showChatsList
#include "app.h"
#include "styles/style_layers.h"
#include "styles/style_boxes.h"
@@ -350,7 +352,7 @@ MaxInviteBox::MaxInviteBox(QWidget*, not_null<ChannelData*> channel) : BoxConten
tr::lng_participant_invite_sorry(
tr::now,
lt_count,
Global::ChatSizeMax()),
channel->session().serverConfig().chatSizeMax),
kInformBoxTextOptions,
(st::boxWidth
- st::boxPadding.left()
@@ -366,11 +368,12 @@ void MaxInviteBox::prepare() {
_textHeight = qMin(_text.countHeight(_textWidth), 16 * st::boxLabelStyle.lineHeight);
setDimensions(st::boxWidth, st::boxPadding.top() + _textHeight + st::boxTextFont->height + st::boxTextFont->height * 2 + st::newGroupLinkPadding.bottom());
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::InviteLinkChanged, [this](const Notify::PeerUpdate &update) {
if (update.peer == _channel) {
rtlupdate(_invitationLink);
}
}));
_channel->session().changes().peerUpdates(
_channel,
Data::PeerUpdate::Flag::InviteLink
) | rpl::start_with_next([=] {
rtlupdate(_invitationLink);
}, lifetime());
}
void MaxInviteBox::mouseMoveEvent(QMouseEvent *e) {
@@ -431,6 +434,7 @@ PinMessageBox::PinMessageBox(
not_null<PeerData*> peer,
MsgId msgId)
: _peer(peer)
, _api(&peer->session().mtp())
, _msgId(msgId)
, _text(this, tr::lng_pinned_pin_sure(tr::now), st::boxLabel) {
}
@@ -473,24 +477,16 @@ void PinMessageBox::pinMessage() {
if (_notify && !_notify->checked()) {
flags |= MTPmessages_UpdatePinnedMessage::Flag::f_silent;
}
_requestId = MTP::send(
MTPmessages_UpdatePinnedMessage(
MTP_flags(flags),
_peer->input,
MTP_int(_msgId)),
rpcDone(&PinMessageBox::pinDone),
rpcFail(&PinMessageBox::pinFail));
}
void PinMessageBox::pinDone(const MTPUpdates &updates) {
_peer->session().api().applyUpdates(updates);
Ui::hideLayer();
}
bool PinMessageBox::pinFail(const RPCError &error) {
if (MTP::isDefaultHandledError(error)) return false;
Ui::hideLayer();
return true;
_requestId = _api.request(MTPmessages_UpdatePinnedMessage(
MTP_flags(flags),
_peer->input,
MTP_int(_msgId)
)).done([=](const MTPUpdates &result) {
_peer->session().api().applyUpdates(result);
Ui::hideLayer();
}).fail([=](const RPCError &error) {
Ui::hideLayer();
}).send();
}
DeleteMessagesBox::DeleteMessagesBox(
@@ -682,10 +678,7 @@ auto DeleteMessagesBox::revokeText(not_null<PeerData*> peer) const
const auto cannotRevoke = [&](HistoryItem *item) {
return !item->canDeleteForEveryone(now);
};
const auto canRevokeAll = ranges::find_if(
items,
cannotRevoke
) == end(items);
const auto canRevokeAll = ranges::none_of(items, cannotRevoke);
auto outgoing = items | ranges::view::filter(&HistoryItem::out);
const auto canRevokeOutgoingCount = canRevokeAll
? -1
@@ -774,9 +767,10 @@ void DeleteMessagesBox::deleteAndClear() {
if (justClear) {
peer->session().api().clearHistory(peer, revoke);
} else {
const auto controller = App::wnd()->sessionController();
if (controller->activeChatCurrent().peer() == peer) {
Ui::showChatsList();
for (const auto controller : peer->session().windows()) {
if (controller->activeChatCurrent().peer() == peer) {
Ui::showChatsList(&peer->session());
}
}
// Don't delete old history by default,
// because Android app doesn't.
@@ -846,8 +840,8 @@ void DeleteMessagesBox::deleteAndClear() {
peer->session().api().request(MTPmessages_DeleteScheduledMessages(
peer->input,
MTP_vector<MTPint>(ids)
)).done([=, peer=peer](const MTPUpdates &updates) {
peer->session().api().applyUpdates(updates);
)).done([peer=peer](const MTPUpdates &result) {
peer->session().api().applyUpdates(result);
}).send();
}
@@ -894,12 +888,13 @@ ConfirmInviteBox::ConfirmInviteBox(
const auto photo = _session->data().processPhoto(data.vphoto());
if (!photo->isNull()) {
_photo = photo->thumbnail();
if (!_photo->loaded()) {
subscribe(_session->downloaderTaskFinished(), [=] {
_photo = photo->createMediaView();
_photo->wanted(Data::PhotoSize::Small, Data::FileOrigin());
if (!_photo->image(Data::PhotoSize::Small)) {
_session->downloaderTaskFinished(
) | rpl::start_with_next([=] {
update();
});
_photo->load(Data::FileOrigin());
}, lifetime());
}
} else {
_photoEmpty = std::make_unique<Ui::EmptyUserpic>(
@@ -908,19 +903,20 @@ ConfirmInviteBox::ConfirmInviteBox(
}
}
std::vector<not_null<UserData*>> ConfirmInviteBox::GetParticipants(
not_null<Main::Session*> session,
const MTPDchatInvite &data) {
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<not_null<UserData*>>();
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(user);
result.push_back(Participant{ user });
}
}
return result;
@@ -945,12 +941,12 @@ void ConfirmInviteBox::prepare() {
_userWidth = (st::confirmInviteUserPhotoSize + 2 * padding);
int sumWidth = _participants.size() * _userWidth;
int left = (st::boxWideWidth - sumWidth) / 2;
for (const auto user : _participants) {
for (const auto &participant : _participants) {
auto name = new Ui::FlatLabel(this, st::confirmInviteUserName);
name->resizeToWidth(st::confirmInviteUserPhotoSize + padding);
name->setText(user->firstName.isEmpty()
? user->name
: user->firstName);
name->setText(participant.user->firstName.isEmpty()
? participant.user->name
: participant.user->firstName);
name->moveToLeft(left + (padding / 2), st::confirmInviteUserNameTop);
left += _userWidth;
}
@@ -972,14 +968,15 @@ void ConfirmInviteBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (_photo) {
p.drawPixmap(
(width() - st::confirmInvitePhotoSize) / 2,
st::confirmInvitePhotoTop,
_photo->pixCircled(
Data::FileOrigin(),
st::confirmInvitePhotoSize,
st::confirmInvitePhotoSize));
} else {
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,
@@ -990,9 +987,10 @@ void ConfirmInviteBox::paintEvent(QPaintEvent *e) {
int sumWidth = _participants.size() * _userWidth;
int left = (width() - sumWidth) / 2;
for_const (auto user, _participants) {
user->paintUserpicLeft(
for (auto &participant : _participants) {
participant.user->paintUserpicLeft(
p,
participant.userpic,
left + (_userWidth - st::confirmInviteUserPhotoSize) / 2,
st::confirmInviteUserPhotoTop,
width(),

View File

@@ -8,7 +8,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "boxes/abstract_box.h"
#include "mtproto/mtproto_rpc_sender.h"
#include "mtproto/sender.h"
namespace Data {
class PhotoMedia;
class CloudImageView;
} // namespace Data
namespace Main {
class Session;
@@ -124,7 +129,7 @@ private:
};
class PinMessageBox : public Ui::BoxContent, public RPCSender {
class PinMessageBox final : public Ui::BoxContent {
public:
PinMessageBox(QWidget*, not_null<PeerData*> peer, MsgId msgId);
@@ -136,10 +141,9 @@ protected:
private:
void pinMessage();
void pinDone(const MTPUpdates &updates);
bool pinFail(const RPCError &error);
not_null<PeerData*> _peer;
const not_null<PeerData*> _peer;
MTP::Sender _api;
MsgId _msgId;
object_ptr<Ui::FlatLabel> _text;
@@ -149,7 +153,7 @@ private:
};
class DeleteMessagesBox : public Ui::BoxContent, public RPCSender {
class DeleteMessagesBox final : public Ui::BoxContent {
public:
DeleteMessagesBox(
QWidget*,
@@ -202,9 +206,8 @@ private:
};
class ConfirmInviteBox
class ConfirmInviteBox final
: public Ui::BoxContent
, public RPCSender
, private base::Subscriber {
public:
ConfirmInviteBox(
@@ -221,7 +224,11 @@ protected:
void paintEvent(QPaintEvent *e) override;
private:
static std::vector<not_null<UserData*>> GetParticipants(
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);
@@ -230,9 +237,9 @@ private:
Fn<void()> _submit;
object_ptr<Ui::FlatLabel> _title;
object_ptr<Ui::FlatLabel> _status;
Image *_photo = nullptr;
std::shared_ptr<Data::PhotoMedia> _photo;
std::unique_ptr<Ui::EmptyUserpic> _photoEmpty;
std::vector<not_null<UserData*>> _participants;
std::vector<Participant> _participants;
bool _isChannel = false;
int _userWidth = 0;

View File

@@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/click_handler_types.h" // UrlClickHandler
#include "base/qthelp_url.h" // qthelp::url_encode
#include "base/platform/base_platform_info.h"
#include "main/main_session.h"
#include "mainwidget.h"
#include "numbers.h"
#include "app.h"
@@ -203,36 +204,54 @@ QString SentCodeCall::getText() const {
return QString();
}
void ConfirmPhoneBox::start(const QString &phone, const QString &hash) {
if (CurrentConfirmPhoneBox && CurrentConfirmPhoneBox->getPhone() != phone) {
void ConfirmPhoneBox::Start(
not_null<Main::Session*> session,
const QString &phone,
const QString &hash) {
if (CurrentConfirmPhoneBox
&& (CurrentConfirmPhoneBox->getPhone() != phone
|| &CurrentConfirmPhoneBox->session() != session)) {
CurrentConfirmPhoneBox.destroyDelayed();
}
if (!CurrentConfirmPhoneBox) {
CurrentConfirmPhoneBox = Box<ConfirmPhoneBox>(phone, hash);
CurrentConfirmPhoneBox = Box<ConfirmPhoneBox>(session, phone, hash);
}
CurrentConfirmPhoneBox->checkPhoneAndHash();
}
ConfirmPhoneBox::ConfirmPhoneBox(QWidget*, const QString &phone, const QString &hash)
: _phone(phone)
ConfirmPhoneBox::ConfirmPhoneBox(
QWidget*,
not_null<Main::Session*> session,
const QString &phone,
const QString &hash)
: _session(session)
, _api(&session->mtp())
, _phone(phone)
, _hash(hash)
, _call([this] { sendCall(); }, [this] { update(); }) {
}
void ConfirmPhoneBox::sendCall() {
MTP::send(MTPauth_ResendCode(MTP_string(_phone), MTP_string(_phoneHash)), rpcDone(&ConfirmPhoneBox::callDone));
_api.request(MTPauth_ResendCode(
MTP_string(_phone),
MTP_string(_phoneHash)
)).done([=](const MTPauth_SentCode &result) {
callDone(result);
}).send();
}
void ConfirmPhoneBox::checkPhoneAndHash() {
if (_sendCodeRequestId) {
return;
}
_sendCodeRequestId = MTP::send(
MTPaccount_SendConfirmPhoneCode(
MTP_string(_hash),
MTP_codeSettings(MTP_flags(0))),
rpcDone(&ConfirmPhoneBox::sendCodeDone),
rpcFail(&ConfirmPhoneBox::sendCodeFail));
_sendCodeRequestId = _api.request(MTPaccount_SendConfirmPhoneCode(
MTP_string(_hash),
MTP_codeSettings(MTP_flags(0))
)).done([=](const MTPauth_SentCode &result) {
sendCodeDone(result);
}).fail([=](const RPCError &error) {
sendCodeFail(error);
}).handleFloodErrors().send();
}
void ConfirmPhoneBox::sendCodeDone(const MTPauth_SentCode &result) {
@@ -259,12 +278,10 @@ void ConfirmPhoneBox::sendCodeDone(const MTPauth_SentCode &result) {
});
}
bool ConfirmPhoneBox::sendCodeFail(const RPCError &error) {
void ConfirmPhoneBox::sendCodeFail(const RPCError &error) {
auto errorText = Lang::Hard::ServerError();
if (MTP::isFloodError(error)) {
errorText = tr::lng_flood_error(tr::now);
} else if (MTP::isDefaultHandledError(error)) {
return false;
} else if (error.code() == 400) {
errorText = tr::lng_confirm_phone_link_invalid(tr::now);
}
@@ -275,7 +292,6 @@ bool ConfirmPhoneBox::sendCodeFail(const RPCError &error) {
} else {
deleteLater();
}
return true;
}
void ConfirmPhoneBox::launch() {
@@ -327,10 +343,14 @@ void ConfirmPhoneBox::sendCode() {
showError(QString());
_sendCodeRequestId = MTP::send(
MTPaccount_ConfirmPhone(MTP_string(_phoneHash), MTP_string(code)),
rpcDone(&ConfirmPhoneBox::confirmDone),
rpcFail(&ConfirmPhoneBox::confirmFail));
_sendCodeRequestId = _api.request(MTPaccount_ConfirmPhone(
MTP_string(_phoneHash),
MTP_string(code)
)).done([=](const MTPBool &result) {
confirmDone(result);
}).fail([=](const RPCError &error) {
confirmFail(error);
}).handleFloodErrors().send();
}
void ConfirmPhoneBox::confirmDone(const MTPBool &result) {
@@ -338,12 +358,10 @@ void ConfirmPhoneBox::confirmDone(const MTPBool &result) {
Ui::show(Box<InformBox>(tr::lng_confirm_phone_success(tr::now, lt_phone, App::formatPhone(_phone))));
}
bool ConfirmPhoneBox::confirmFail(const RPCError &error) {
void ConfirmPhoneBox::confirmFail(const RPCError &error) {
auto errorText = Lang::Hard::ServerError();
if (MTP::isFloodError(error)) {
errorText = tr::lng_flood_error(tr::now);
} else if (MTP::isDefaultHandledError(error)) {
return false;
} else {
auto &errorType = error.type();
if (errorType == qstr("PHONE_CODE_EMPTY") || errorType == qstr("PHONE_CODE_INVALID")) {
@@ -354,7 +372,6 @@ bool ConfirmPhoneBox::confirmFail(const RPCError &error) {
_code->setDisabled(false);
_code->setFocus();
showError(errorText);
return true;
}
void ConfirmPhoneBox::showError(const QString &error) {
@@ -406,9 +423,3 @@ void ConfirmPhoneBox::resizeEvent(QResizeEvent *e) {
void ConfirmPhoneBox::setInnerFocus() {
_code->setFocusFast();
}
ConfirmPhoneBox::~ConfirmPhoneBox() {
if (_sendCodeRequestId) {
MTP::cancel(_sendCodeRequestId);
}
}

View File

@@ -10,13 +10,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/abstract_box.h"
#include "base/timer.h"
#include "ui/widgets/input_fields.h"
#include "mtproto/mtproto_rpc_sender.h"
#include "mtproto/sender.h"
namespace Ui {
class InputField;
class FlatLabel;
} // namespace Ui
namespace Main {
class Session;
} // namespace Main
void ShowPhoneBannedError(const QString &phone);
[[nodiscard]] QString ExtractPhonePrefix(const QString &phone);
@@ -86,11 +90,16 @@ private:
};
class ConfirmPhoneBox : public Ui::BoxContent, public RPCSender {
class ConfirmPhoneBox final : public Ui::BoxContent {
public:
static void start(const QString &phone, const QString &hash);
static void Start(
not_null<Main::Session*> session,
const QString &phone,
const QString &hash);
~ConfirmPhoneBox();
[[nodiscard]] Main::Session &session() const {
return *_session;
}
protected:
void prepare() override;
@@ -100,7 +109,11 @@ protected:
void resizeEvent(QResizeEvent *e) override;
private:
ConfirmPhoneBox(QWidget*, const QString &phone, const QString &hash);
ConfirmPhoneBox(
QWidget*,
not_null<Main::Session*> session,
const QString &phone,
const QString &hash);
friend class object_ptr<ConfirmPhoneBox>;
void sendCode();
@@ -108,12 +121,12 @@ private:
void checkPhoneAndHash();
void sendCodeDone(const MTPauth_SentCode &result);
bool sendCodeFail(const RPCError &error);
void sendCodeFail(const RPCError &error);
void callDone(const MTPauth_SentCode &result);
void confirmDone(const MTPBool &result);
bool confirmFail(const RPCError &error);
void confirmFail(const RPCError &error);
QString getPhone() const {
return _phone;
@@ -122,6 +135,8 @@ private:
void showError(const QString &error);
const not_null<Main::Session*> _session;
MTP::Sender _api;
mtpRequestId _sendCodeRequestId = 0;
// _hash from the link for account.sendConfirmPhoneCode call.

View File

@@ -171,7 +171,7 @@ private:
};
class ProxyBox : public Ui::BoxContent {
class ProxyBox final : public Ui::BoxContent {
public:
ProxyBox(
QWidget*,
@@ -179,12 +179,14 @@ public:
Fn<void(ProxyData)> callback,
Fn<void(ProxyData)> shareCallback);
protected:
void prepare() override;
private:
using Type = ProxyData::Type;
void prepare() override;
void setInnerFocus() override {
_host->setFocusFast();
}
void refreshButtons();
ProxyData collectData();
void save();
@@ -693,8 +695,8 @@ void ProxiesBox::applyView(View &&view) {
setupButtons(id, i->second.get());
if (_noRows) {
_noRows.reset();
wrap->resizeToWidth(width());
}
wrap->resizeToWidth(width());
} else if (view.host.isEmpty()) {
_rows.erase(i);
} else {
@@ -765,6 +767,31 @@ ProxyBox::ProxyBox(
void ProxyBox::prepare() {
setTitle(tr::lng_proxy_edit());
connect(_host.data(), &Ui::InputField::changed, [=] {
Ui::PostponeCall(_host, [=] {
const auto host = _host->getLastText().trimmed();
static const auto mask = u"^\\d+\\.\\d+\\.\\d+\\.\\d+:(\\d*)$"_q;
const auto match = QRegularExpression(mask).match(host);
if (_host->textCursor().position() == host.size()
&& match.hasMatch()) {
const auto port = match.captured(1);
_port->setText(port);
_port->setCursorPosition(port.size());
_port->setFocus();
_host->setText(host.mid(0, host.size() - port.size() - 1));
}
});
});
_port.data()->events(
) | rpl::start_with_next([=](not_null<QEvent*> e) {
if (e->type() == QEvent::KeyPress
&& (static_cast<QKeyEvent*>(e.get())->key() == Qt::Key_Backspace)
&& _port->cursorPosition() == 0) {
_host->setCursorPosition(_host->getLastText().size());
_host->setFocus();
}
}, _port->lifetime());
refreshButtons();
setDimensionsToContent(st::boxWideWidth, _content);
}
@@ -978,8 +1005,9 @@ void ProxyBox::addLabel(
} // namespace
ProxiesBoxController::ProxiesBoxController()
: _saveTimer([] { Local::writeSettings(); }) {
ProxiesBoxController::ProxiesBoxController(not_null<Main::Account*> account)
: _account(account)
, _saveTimer([] { Local::writeSettings(); }) {
_list = ranges::view::all(
Global::ProxiesList()
) | ranges::view::transform([&](const ProxyData &proxy) {
@@ -1027,7 +1055,7 @@ void ProxiesBoxController::ShowApplyConfirmation(
: QString());
*box = Ui::show(Box<ConfirmBox>(text, tr::lng_sure_enable(tr::now), [=] {
auto &proxies = Global::RefProxiesList();
if (ranges::find(proxies, proxy) == end(proxies)) {
if (!ranges::contains(proxies, proxy)) {
proxies.push_back(proxy);
}
Core::App().setCurrentProxy(
@@ -1058,7 +1086,7 @@ void ProxiesBoxController::refreshChecker(Item &item) {
const auto type = (item.data.type == Type::Http)
? Variants::Http
: Variants::Tcp;
const auto mtproto = Core::App().activeAccount().mtp();
const auto mtproto = &_account->mtp();
const auto dcId = mtproto->mainDcId();
item.state = ItemState::Checking;
@@ -1081,7 +1109,7 @@ void ProxiesBoxController::refreshChecker(Item &item) {
dcId);
item.checkerv6 = nullptr;
} else {
const auto options = mtproto->dcOptions()->lookup(
const auto options = mtproto->dcOptions().lookup(
dcId,
MTP::DcType::Regular,
true);
@@ -1142,8 +1170,9 @@ void ProxiesBoxController::setupChecker(int id, const Checker &checker) {
pointer->connect(pointer, &Connection::error, failed);
}
object_ptr<Ui::BoxContent> ProxiesBoxController::CreateOwningBox() {
auto controller = std::make_unique<ProxiesBoxController>();
object_ptr<Ui::BoxContent> ProxiesBoxController::CreateOwningBox(
not_null<Main::Account*> account) {
auto controller = std::make_unique<ProxiesBoxController>(account);
auto box = controller->create();
Ui::AttachAsChild(box, std::move(controller));
return box;
@@ -1372,7 +1401,7 @@ void ProxiesBoxController::setTryIPv6(bool enabled) {
return;
}
Global::SetTryIPv6(enabled);
MTP::restart();
_account->mtp().restart();
Global::RefConnectionTypeChanged().notify();
saveDelayed();
}
@@ -1386,7 +1415,6 @@ auto ProxiesBoxController::views() const -> rpl::producer<ItemView> {
}
void ProxiesBoxController::updateView(const Item &item) {
const auto ping = 0;
const auto selected = (Global::SelectedProxy() == item.data);
const auto deleted = item.deleted;
const auto type = [&] {
@@ -1404,7 +1432,7 @@ void ProxiesBoxController::updateView(const Item &item) {
if (!selected
|| (Global::ProxySettings() != ProxyData::Settings::Enabled)) {
return item.state;
} else if (MTP::dcstate() == MTP::ConnectedState) {
} else if (_account->mtp().dcstate() == MTP::ConnectedState) {
return ItemState::Online;
}
return ItemState::Connecting;

View File

@@ -24,18 +24,23 @@ template <typename Enum>
class Radioenum;
} // namespace Ui
namespace Main {
class Account;
} // namespace Main
class ProxiesBoxController : public base::Subscriber {
public:
using ProxyData = MTP::ProxyData;
using Type = ProxyData::Type;
ProxiesBoxController();
explicit ProxiesBoxController(not_null<Main::Account*> account);
static void ShowApplyConfirmation(
Type type,
const QMap<QString, QString> &fields);
static object_ptr<Ui::BoxContent> CreateOwningBox();
static object_ptr<Ui::BoxContent> CreateOwningBox(
not_null<Main::Account*> account);
object_ptr<Ui::BoxContent> create();
enum class ItemState {
@@ -104,6 +109,7 @@ private:
const ProxyData &proxy);
void addNewItem(const ProxyData &proxy);
const not_null<Main::Account*> _account;
int _idCounter = 0;
std::vector<Item> _list;
rpl::event_stream<ItemView> _views;

View File

@@ -20,6 +20,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/checkbox.h"
#include "ui/toast/toast.h"
#include "main/main_session.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "chat_helpers/emoji_suggestions_widget.h"
#include "chat_helpers/message_field.h"
#include "history/view/history_view_schedule_box.h"
@@ -27,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/unique_qptr.h"
#include "base/event_filter.h"
#include "base/call_delayed.h"
#include "window/window_session_controller.h"
#include "styles/style_layers.h"
#include "styles/style_boxes.h"
#include "styles/style_settings.h"
@@ -159,7 +162,7 @@ void InitField(
not_null<Main::Session*> session) {
field->setInstantReplaces(Ui::InstantReplaces::Default());
field->setInstantReplacesEnabled(
session->settings().replaceEmojiValue());
Core::App().settings().replaceEmojiValue());
auto options = Ui::Emoji::SuggestionsController::Options();
options.suggestExactFirstWord = false;
Ui::Emoji::SuggestionsController::Init(
@@ -721,9 +724,8 @@ void Options::removeDestroyed(not_null<Option*> option) {
void Options::validateState() {
checkLastOption();
_hasOptions = (ranges::count_if(_list, &Option::isGood) > 1);
_isValid = _hasOptions
&& (ranges::find_if(_list, &Option::isTooLong) == end(_list));
_hasCorrect = ranges::find_if(_list, &Option::isCorrect) != end(_list);
_isValid = _hasOptions && ranges::none_of(_list, &Option::isTooLong);
_hasCorrect = ranges::any_of(_list, &Option::isCorrect);
const auto lastEmpty = !_list.empty() && _list.back()->isEmpty();
_usedCount = _list.size() - (lastEmpty ? 1 : 0);
@@ -748,11 +750,11 @@ void Options::checkLastOption() {
CreatePollBox::CreatePollBox(
QWidget*,
not_null<Main::Session*> session,
not_null<Window::SessionController*> controller,
PollData::Flags chosen,
PollData::Flags disabled,
Api::SendType sendType)
: _session(session)
: _controller(controller)
, _chosen(chosen)
, _disabled(disabled)
, _sendType(sendType) {
@@ -774,6 +776,7 @@ not_null<Ui::InputField*> CreatePollBox::setupQuestion(
not_null<Ui::VerticalLayout*> container) {
using namespace Settings;
const auto session = &_controller->session();
AddSubsectionTitle(container, tr::lng_polls_create_question());
const auto question = container->add(
object_ptr<Ui::InputField>(
@@ -782,7 +785,7 @@ not_null<Ui::InputField*> CreatePollBox::setupQuestion(
Ui::InputField::Mode::MultiLine,
tr::lng_polls_create_question_placeholder()),
st::createPollFieldPadding);
InitField(getDelegate()->outerContainer(), question, _session);
InitField(getDelegate()->outerContainer(), question, session);
question->setMaxLength(kQuestionLimit + kErrorLimit);
question->setSubmitSettings(Ui::InputField::SubmitSettings::Both);
question->customTab(true);
@@ -824,6 +827,7 @@ not_null<Ui::InputField*> CreatePollBox::setupSolution(
)->setDuration(0)->toggleOn(std::move(shown));
const auto inner = outer->entity();
const auto session = &_controller->session();
AddSkip(inner);
AddSubsectionTitle(inner, tr::lng_polls_solution_title());
const auto solution = inner->add(
@@ -833,14 +837,14 @@ not_null<Ui::InputField*> CreatePollBox::setupSolution(
Ui::InputField::Mode::MultiLine,
tr::lng_polls_solution_placeholder()),
st::createPollFieldPadding);
InitField(getDelegate()->outerContainer(), solution, _session);
InitField(getDelegate()->outerContainer(), solution, session);
solution->setMaxLength(kSolutionLimit + kErrorLimit);
solution->setInstantReplaces(Ui::InstantReplaces::Default());
solution->setInstantReplacesEnabled(
_session->settings().replaceEmojiValue());
Core::App().settings().replaceEmojiValue());
solution->setMarkdownReplacesEnabled(rpl::single(true));
solution->setEditLinkCallback(
DefaultEditLinkCallback(_session, solution));
DefaultEditLinkCallback(_controller, solution));
solution->customTab(true);
const auto warning = CreateWarningLabel(
@@ -896,7 +900,7 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
const auto options = lifetime().make_state<Options>(
getDelegate()->outerContainer(),
container,
_session,
&_controller->session(),
(_chosen & PollData::Flag::Quiz));
auto limit = options->usedCount() | rpl::after_next([=](int count) {
setCloseByEscape(!count);
@@ -1011,7 +1015,7 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
const auto collectResult = [=] {
using Flag = PollData::Flag;
auto result = PollData(&_session->data(), id);
auto result = PollData(&_controller->session().data(), id);
result.question = question->getLastText().trimmed();
result.answers = options->toPollAnswers();
const auto solutionWithTags = quiz->checked()

View File

@@ -18,9 +18,9 @@ namespace Ui {
class VerticalLayout;
} // namespace Ui
namespace Main {
class Session;
} // namespace Main
namespace Window {
class SessionController;
} // namespace Window
class CreatePollBox : public Ui::BoxContent {
public:
@@ -31,7 +31,7 @@ public:
CreatePollBox(
QWidget*,
not_null<Main::Session*> session,
not_null<Window::SessionController*> controller,
PollData::Flags chosen,
PollData::Flags disabled,
Api::SendType sendType);
@@ -62,7 +62,7 @@ private:
not_null<Ui::VerticalLayout*> container,
rpl::producer<bool> shown);
const not_null<Main::Session*> _session;
const not_null<Window::SessionController*> _controller;
const PollData::Flags _chosen = PollData::Flags();
const PollData::Flags _disabled = PollData::Flags();
const Api::SendType _sendType = Api::SendType();

View File

@@ -13,7 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "chat_helpers/spellchecker_common.h"
#include "core/application.h"
#include "main/main_account.h"
#include "main/main_session.h"
#include "mainwidget.h"
#include "mtproto/dedicated_file_loader.h"
#include "spellcheck/spellcheck_utils.h"
@@ -27,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/popup_menu.h"
#include "ui/wrap/slide_wrap.h"
#include "ui/effects/animations.h"
#include "window/window_session_controller.h"
namespace Ui {
namespace {
@@ -46,13 +46,18 @@ using QStringView = QString;
class Inner : public Ui::RpWidget {
public:
Inner(QWidget *parent, Dictionaries enabledDictionaries);
Inner(
QWidget *parent,
not_null<Window::SessionController*> controller,
Dictionaries enabledDictionaries);
Dictionaries enabledRows() const;
QueryCallback queryCallback() const;
private:
void setupContent(Dictionaries enabledDictionaries);
void setupContent(
not_null<Window::SessionController*> controller,
Dictionaries enabledDictionaries);
Dictionaries _enabledRows;
QueryCallback _queryCallback;
@@ -96,8 +101,10 @@ auto CreateMultiSelect(QWidget *parent) {
Inner::Inner(
QWidget *parent,
Dictionaries enabledDictionaries) : RpWidget(parent) {
setupContent(std::move(enabledDictionaries));
not_null<Window::SessionController*> controller,
Dictionaries enabledDictionaries)
: RpWidget(parent) {
setupContent(controller, std::move(enabledDictionaries));
}
QueryCallback Inner::queryCallback() const {
@@ -110,6 +117,7 @@ Dictionaries Inner::enabledRows() const {
auto AddButtonWithLoader(
not_null<Ui::VerticalLayout*> content,
not_null<Window::SessionController*> controller,
const Spellchecker::Dict &dict,
bool buttonEnabled,
rpl::producer<QStringView> query) {
@@ -238,39 +246,29 @@ auto AddButtonWithLoader(
) | rpl::then(
rpl::merge(
// Events to toggle on.
dictionaryFromGlobalLoader->events(
) | rpl::map([] {
return true;
}),
dictionaryFromGlobalLoader->events() | rpl::map_to(true),
// Events to toggle off.
rpl::merge(
dictionaryRemoved->events(),
buttonState->value(
) | rpl::filter([](const DictState &state) {
return state.is<Failed>();
}) | rpl::map([] {
return rpl::empty_value();
})
) | rpl::map([] {
return false;
})
}) | rpl::to_empty
) | rpl::map_to(false)
)
)
);
*buttonState = localLoaderValues->events_starting_with(
rawGlobalLoaderPtr() ? rawGlobalLoaderPtr() : localLoader->get()
) | rpl::map([=](Loader *loader) {
*buttonState = localLoaderValues->events_starting_with(
rawGlobalLoaderPtr() ? rawGlobalLoaderPtr() : localLoader->get()
) | rpl::map([=](Loader *loader) {
return (loader && loader->id() == id)
? loader->state()
: rpl::single(
buttonEnabled
) | rpl::then(
rpl::merge(
dictionaryRemoved->events(
) | rpl::map([] {
return false;
}),
dictionaryRemoved->events() | rpl::map_to(false),
button->toggledValue()
)
) | rpl::map([=](auto enabled) {
@@ -287,7 +285,8 @@ auto AddButtonWithLoader(
if (toggled && (state.is<Available>() || state.is<Failed>())) {
const auto weak = Ui::MakeWeak(button);
setLocalLoader(base::make_unique_q<Loader>(
App::main(),
QCoreApplication::instance(),
&controller->session(),
id,
Spellchecker::GetDownloadLocation(id),
Spellchecker::DictPathByLangId(id),
@@ -336,7 +335,9 @@ auto AddButtonWithLoader(
return button;
}
void Inner::setupContent(Dictionaries enabledDictionaries) {
void Inner::setupContent(
not_null<Window::SessionController*> controller,
Dictionaries enabledDictionaries) {
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
const auto queryStream = content->lifetime()
@@ -346,6 +347,7 @@ void Inner::setupContent(Dictionaries enabledDictionaries) {
const auto id = dict.id;
const auto row = AddButtonWithLoader(
content,
controller,
dict,
ranges::contains(enabledDictionaries, id),
queryStream->events());
@@ -375,8 +377,8 @@ void Inner::setupContent(Dictionaries enabledDictionaries) {
ManageDictionariesBox::ManageDictionariesBox(
QWidget*,
not_null<Main::Session*> session)
: _session(session) {
not_null<Window::SessionController*> controller)
: _controller(controller) {
}
void ManageDictionariesBox::setInnerFocus() {
@@ -389,7 +391,8 @@ void ManageDictionariesBox::prepare() {
const auto inner = setInnerWidget(
object_ptr<Inner>(
this,
_session->settings().dictionariesEnabled()),
_controller,
Core::App().settings().dictionariesEnabled()),
st::boxScroll,
multiSelect->height()
);
@@ -407,9 +410,9 @@ void ManageDictionariesBox::prepare() {
setTitle(tr::lng_settings_manage_dictionaries());
addButton(tr::lng_settings_save(), [=] {
_session->settings().setDictionariesEnabled(
Core::App().settings().setDictionariesEnabled(
FilterEnabledDict(inner->enabledRows()));
_session->saveSettingsDelayed();
Core::App().saveSettingsDelayed();
// Ignore boxClosing() when the Save button was pressed.
lifetime().destroy();
closeBox();
@@ -417,9 +420,9 @@ void ManageDictionariesBox::prepare() {
addButton(tr::lng_close(), [=] { closeBox(); });
boxClosing() | rpl::start_with_next([=] {
_session->settings().setDictionariesEnabled(
Core::App().settings().setDictionariesEnabled(
FilterEnabledDict(initialEnabledRows));
_session->saveSettingsDelayed();
Core::App().saveSettingsDelayed();
}, lifetime());
setDimensionsToContent(st::boxWidth, inner);

View File

@@ -11,9 +11,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/abstract_box.h"
namespace Main {
class Session;
} // namespace Main
namespace Window {
class SessionController;
} // namespace Window
namespace Ui {
@@ -21,14 +21,14 @@ class ManageDictionariesBox : public Ui::BoxContent {
public:
ManageDictionariesBox(
QWidget*,
not_null<Main::Session*> session);
not_null<Window::SessionController*> controller);
protected:
void prepare() override;
void setInnerFocus() override;
private:
const not_null<Main::Session*> _session;
const not_null<Window::SessionController*> _controller;
Fn<void()> _setInnerFocus;
};

View File

@@ -8,18 +8,22 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/download_path_box.h"
#include "lang/lang_keys.h"
#include "storage/localstorage.h"
#include "core/file_utilities.h"
#include "ui/widgets/checkbox.h"
#include "ui/widgets/buttons.h"
#include "platform/platform_specific.h"
#include "facades.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "storage/storage_account.h"
#include "styles/style_layers.h"
#include "styles/style_boxes.h"
DownloadPathBox::DownloadPathBox(QWidget *parent)
: _path(Global::DownloadPath())
, _pathBookmark(Global::DownloadPathBookmark())
DownloadPathBox::DownloadPathBox(
QWidget *parent,
not_null<Window::SessionController*> controller)
: _controller(controller)
, _path(Core::App().settings().downloadPath())
, _pathBookmark(Core::App().settings().downloadPathBookmark())
, _group(std::make_shared<Ui::RadioenumGroup<Directory>>(typeFromPath(_path)))
, _default(this, _group, Directory::Downloads, tr::lng_download_path_default_radio(tr::now), st::defaultBoxCheckbox)
, _temp(this, _group, Directory::Temp, tr::lng_download_path_temp_radio(tr::now), st::defaultBoxCheckbox)
@@ -86,8 +90,9 @@ void DownloadPathBox::radioChanged(Directory value) {
void DownloadPathBox::editPath() {
const auto initialPath = [] {
if (!Global::DownloadPath().isEmpty() && Global::DownloadPath() != qstr("tmp")) {
return Global::DownloadPath().left(Global::DownloadPath().size() - (Global::DownloadPath().endsWith('/') ? 1 : 0));
const auto path = Core::App().settings().downloadPath();
if (!path.isEmpty() && path != qstr("tmp")) {
return path.left(path.size() - (path.endsWith('/') ? 1 : 0));
}
return QString();
}();
@@ -117,10 +122,10 @@ void DownloadPathBox::save() {
}
return QString();
};
Global::SetDownloadPath(computePath());
Global::SetDownloadPathBookmark((value == Directory::Custom) ? _pathBookmark : QByteArray());
Local::writeUserSettings();
Global::RefDownloadPathChanged().notify();
Core::App().settings().setDownloadPathBookmark(
(value == Directory::Custom) ? _pathBookmark : QByteArray());
Core::App().settings().setDownloadPath(computePath());
Core::App().saveSettings();
closeBox();
#endif // OS_WIN_STORE
}

View File

@@ -18,9 +18,15 @@ class Radioenum;
class LinkButton;
} // namespace Ui
namespace Window {
class SessionController;
} // namespace Window
class DownloadPathBox : public Ui::BoxContent {
public:
DownloadPathBox(QWidget *parent);
DownloadPathBox(
QWidget *parent,
not_null<Window::SessionController*> controller);
protected:
void prepare() override;
@@ -48,6 +54,7 @@ private:
void setPathText(const QString &text);
void editPath();
const not_null<Window::SessionController*> _controller;
QString _path;
QByteArray _pathBookmark;

View File

@@ -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"
@@ -15,6 +16,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "chat_helpers/tabbed_panel.h"
#include "chat_helpers/tabbed_selector.h"
#include "base/event_filter.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "core/file_utilities.h"
#include "core/mime_type.h"
#include "data/data_document.h"
@@ -22,13 +25,24 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_photo.h"
#include "data/data_user.h"
#include "data/data_session.h"
#include "data/data_streaming.h"
#include "data/data_file_origin.h"
#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"
#include "layout.h"
#include "media/clip/media_clip_reader.h"
#include "media/streaming/media_streaming_instance.h"
#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"
#include "ui/image/image.h"
#include "ui/widgets/input_fields.h"
#include "ui/widgets/checkbox.h"
@@ -37,7 +51,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text_options.h"
#include "window/window_session_controller.h"
#include "confirm_box.h"
#include "facades.h"
#include "apiwrap.h"
#include "facades.h" // App::LambdaDelayed.
#include "app.h"
#include "styles/style_layers.h"
#include "styles/style_boxes.h"
@@ -46,6 +61,57 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtCore/QMimeData>
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;
}
auto CheckMimeData(not_null<const QMimeData*> data, bool isAlbum) {
if (data->urls().size() > 1) {
return false;
} else if (data->hasImage()) {
return true;
}
if (isAlbum && data->hasUrls()) {
const auto url = data->urls().front();
if (url.isLocalFile()) {
using namespace Core;
const auto info = QFileInfo(Platform::File::UrlToLocal(url));
return IsMimeAcceptedForAlbum(MimeTypeForFile(info).name());
}
}
return true;
}
} // namespace
EditCaptionBox::EditCaptionBox(
QWidget*,
not_null<Window::SessionController*> controller,
@@ -58,45 +124,67 @@ EditCaptionBox::EditCaptionBox(
_isAllowedEditMedia = item->media()->allowsEditMedia();
_isAlbum = !item->groupId().empty();
QSize dimensions;
auto image = (Image*)nullptr;
DocumentData *doc = nullptr;
auto dimensions = QSize();
const auto media = item->media();
if (const auto photo = media->photo()) {
_photoMedia = photo->createMediaView();
_photoMedia->wanted(PhotoSize::Large, _msgId);
dimensions = _photoMedia->size(PhotoSize::Large);
if (dimensions.isEmpty()) {
dimensions = QSize(1, 1);
}
_photo = true;
dimensions = QSize(photo->width(), photo->height());
image = photo->large();
} else if (const auto document = media->document()) {
image = document->thumbnail();
dimensions = image
? image->size()
_documentMedia = document->createMediaView();
_documentMedia->thumbnailWanted(_msgId);
dimensions = _documentMedia->thumbnail()
? _documentMedia->thumbnail()->size()
: document->dimensions;
if (document->isAnimation()) {
_gifw = document->dimensions.width();
_gifh = document->dimensions.height();
_gifw = style::ConvertScale(document->dimensions.width());
_gifh = style::ConvertScale(document->dimensions.height());
_animated = true;
} else if (document->isVideoFile()) {
_animated = true;
} else {
_doc = true;
}
doc = document;
} else {
Unexpected("Photo or document should be set.");
}
const auto editData = PrepareEditText(item);
if (!_animated && (dimensions.isEmpty() || doc || !image)) {
if (!image) {
_thumbw = 0;
const auto computeImage = [=] {
if (_documentMedia) {
return _documentMedia->thumbnail();
} else if (const auto large = _photoMedia->image(PhotoSize::Large)) {
return large;
} else if (const auto thumbnail = _photoMedia->image(
PhotoSize::Thumbnail)) {
return thumbnail;
} else if (const auto small = _photoMedia->image(PhotoSize::Small)) {
return small;
} else {
const auto tw = image->width(), th = image->height();
return _photoMedia->thumbnailInline();
}
};
if (!_animated && _documentMedia) {
if (dimensions.isEmpty()) {
_thumbw = 0;
_thumbnailImageLoaded = true;
} else {
const auto tw = dimensions.width(), th = dimensions.height();
if (tw > th) {
_thumbw = (tw * st::msgFileThumbSize) / th;
} else {
_thumbw = st::msgFileThumbSize;
}
_thumbnailImage = image;
_refreshThumbnail = [=] {
const auto image = computeImage();
if (!image) {
return;
}
const auto options = Images::Option::Smooth
| Images::Option::RoundedSmall
| Images::Option::RoundedTopLeft
@@ -104,30 +192,28 @@ EditCaptionBox::EditCaptionBox(
| Images::Option::RoundedBottomLeft
| Images::Option::RoundedBottomRight;
_thumb = App::pixmapFromImageInPlace(Images::prepare(
image->pix(_msgId).toImage(),
image->original(),
_thumbw * cIntRetinaFactor(),
0,
options,
st::msgFileThumbSize,
st::msgFileThumbSize));
_thumbnailImageLoaded = true;
};
}
if (doc) {
const auto nameString = doc->isVoiceMessage()
? tr::lng_media_audio(tr::now)
: doc->composeNameString();
setName(nameString, doc->size);
_isImage = doc->isImage();
_isAudio = (doc->isVoiceMessage() || doc->isAudioFile());
}
if (_refreshThumbnail) {
_refreshThumbnail();
}
} else {
if (!image) {
image = Image::BlankMedia();
if (_documentMedia) {
const auto document = _documentMedia->owner();
const auto nameString = document->isVoiceMessage()
? tr::lng_media_audio(tr::now)
: document->composeNameString();
setName(nameString, document->size);
_isImage = document->isImage();
_isAudio = document->isVoiceMessage()
|| document->isAudioFile();
}
} else {
auto maxW = 0, maxH = 0;
const auto limitW = st::sendMediaPreviewSize;
auto limitH = std::min(st::confirmMaxHeight, _gifh ? _gifh : INT_MAX);
@@ -145,29 +231,41 @@ EditCaptionBox::EditCaptionBox(
maxH = limitH;
}
}
_thumbnailImage = image;
_refreshThumbnail = [=] {
const auto image = computeImage();
const auto use = image ? image : Image::BlankMedia().get();
const auto options = Images::Option::Smooth
| Images::Option::Blurred;
_thumb = image->pixNoCache(
_msgId,
_thumb = use->pixNoCache(
maxW * cIntRetinaFactor(),
maxH * cIntRetinaFactor(),
options,
maxW,
maxH);
_thumbnailImageLoaded = true;
};
prepareGifPreview(doc);
} else {
Assert(_photoMedia != nullptr);
maxW = dimensions.width();
maxH = dimensions.height();
_thumbnailImage = image;
_refreshThumbnail = [=] {
_thumb = image->pixNoCache(
_msgId,
const auto image = computeImage();
const auto photo = _photoMedia->image(Data::PhotoSize::Large);
const auto use = photo
? photo
: image
? image
: Image::BlankMedia().get();
const auto options = Images::Option::Smooth
| (photo
? Images::Option(0)
: Images::Option::Blurred);
_thumbnailImageLoaded = (photo != nullptr);
_thumb = use->pixNoCache(
maxW * cIntRetinaFactor(),
maxH * cIntRetinaFactor(),
Images::Option::Smooth,
options,
maxW,
maxH);
};
@@ -205,7 +303,7 @@ EditCaptionBox::EditCaptionBox(
thumbX = (st::boxWideWidth - thumbWidth) / 2;
};
if (doc && doc->isAnimation()) {
if (_documentMedia && _documentMedia->owner()->isAnimation()) {
resizeDimensions(_gifw, _gifh, _gifx);
}
limitH = std::min(st::confirmMaxHeight, _gifh ? _gifh : INT_MAX);
@@ -236,39 +334,38 @@ EditCaptionBox::EditCaptionBox(
scaleThumbDown();
}
Assert(_animated || _photo || _doc);
Assert(_thumbnailImageLoaded || _refreshThumbnail);
_thumbnailImageLoaded = _thumbnailImage
? _thumbnailImage->loaded()
: true;
subscribe(_controller->session().downloaderTaskFinished(), [=] {
if (!_thumbnailImageLoaded
&& _thumbnailImage
&& _thumbnailImage->loaded()) {
_thumbnailImageLoaded = true;
if (!_thumbnailImageLoaded) {
_controller->session().downloaderTaskFinished(
) | rpl::start_with_next([=] {
if (_thumbnailImageLoaded
|| (_photoMedia && !_photoMedia->image(PhotoSize::Large))
|| (_documentMedia && !_documentMedia->thumbnail())) {
return;
}
_refreshThumbnail();
update();
}
if (doc && doc->isAnimation() && doc->loaded() && !_gifPreview) {
prepareGifPreview(doc);
}
});
}, lifetime());
}
_field.create(
this,
st::confirmCaptionArea,
Ui::InputField::Mode::MultiLine,
tr::lng_photo_caption(),
editData);
_field->setMaxLength(Global::CaptionLengthMax());
_field->setSubmitSettings(_controller->session().settings().sendSubmitWay());
_field->setMaxLength(
_controller->session().serverConfig().captionLengthMax);
_field->setSubmitSettings(
Core::App().settings().sendSubmitWay());
_field->setInstantReplaces(Ui::InstantReplaces::Default());
_field->setInstantReplacesEnabled(
_controller->session().settings().replaceEmojiValue());
Core::App().settings().replaceEmojiValue());
_field->setMarkdownReplacesEnabled(rpl::single(true));
_field->setEditLinkCallback(
DefaultEditLinkCallback(&_controller->session(), _field));
DefaultEditLinkCallback(_controller, _field));
InitSpellchecker(&_controller->session(), _field);
InitSpellchecker(_controller, _field);
auto r = object_ptr<Ui::SlideWrap<Ui::Checkbox>>(
this,
@@ -287,6 +384,8 @@ EditCaptionBox::EditCaptionBox(
}, _wayWrap->lifetime());
}
EditCaptionBox::~EditCaptionBox() = default;
void EditCaptionBox::emojiFilterForGeometry(not_null<QEvent*> event) {
const auto type = event->type();
if (type == QEvent::Move || type == QEvent::Resize) {
@@ -305,74 +404,86 @@ void EditCaptionBox::updateEmojiPanelGeometry() {
local.x() + _emojiToggle->width() * 3);
}
void EditCaptionBox::prepareGifPreview(DocumentData* document) {
void EditCaptionBox::prepareStreamedPreview() {
const auto isListEmpty = _preparedList.files.empty();
if (_gifPreview) {
if (_streamed) {
return;
} else if (!document && isListEmpty) {
} else if (!_documentMedia && isListEmpty) {
return;
}
const auto callback = [=](Media::Clip::Notification notification) {
clipCallback(notification);
};
if (document && document->isAnimation() && document->loaded()) {
_gifPreview = Media::Clip::MakeReader(
document,
_msgId,
callback);
const auto document = _documentMedia
? _documentMedia->owner().get()
: nullptr;
if (document && document->isAnimation()) {
setupStreamedPreview(
document->owner().streaming().sharedDocument(
document,
_msgId));
} else if (!isListEmpty) {
const auto file = &_preparedList.files.front();
if (file->path.isEmpty()) {
_gifPreview = Media::Clip::MakeReader(
file->content,
callback);
} else {
_gifPreview = Media::Clip::MakeReader(
file->path,
callback);
}
auto loader = file->path.isEmpty()
? MakeBytesLoader(file->content)
: MakeFileLoader(file->path);
setupStreamedPreview(std::make_shared<Document>(std::move(loader)));
}
if (_gifPreview) _gifPreview->setAutoplay();
}
void EditCaptionBox::clipCallback(Media::Clip::Notification notification) {
using namespace Media::Clip;
switch (notification) {
case NotificationReinit: {
if (_gifPreview && _gifPreview->state() == State::Error) {
_gifPreview.setBad();
}
void EditCaptionBox::setupStreamedPreview(std::shared_ptr<Document> shared) {
if (!shared) {
return;
}
_streamed = std::make_unique<Instance>(
std::move(shared),
[=] { update(); });
_streamed->lockPlayer();
_streamed->player().updates(
) | rpl::start_with_next_error([=](Update &&update) {
handleStreamingUpdate(std::move(update));
}, [=](Error &&error) {
handleStreamingError(std::move(error));
}, _streamed->lifetime());
if (_gifPreview && _gifPreview->ready() && !_gifPreview->started()) {
const auto calculateGifDimensions = [&]() {
const auto scaled = QSize(
_gifPreview->width(),
_gifPreview->height()).scaled(
st::sendMediaPreviewSize * cIntRetinaFactor(),
st::confirmMaxHeight * cIntRetinaFactor(),
Qt::KeepAspectRatio);
_thumbw = _gifw = scaled.width();
_thumbh = _gifh = scaled.height();
_thumbx = _gifx = (st::boxWideWidth - _gifw) / 2;
updateBoxSize();
};
// If gif file is not mp4,
// Its dimension values will be known only after reading.
if (_gifw <= 0 || _gifh <= 0) {
calculateGifDimensions();
}
const auto s = QSize(_gifw, _gifh);
_gifPreview->start(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, RectPart::None);
}
if (_streamed->ready()) {
streamingReady(base::duplicate(_streamed->info()));
}
checkStreamedIsStarted();
}
update();
} break;
void EditCaptionBox::handleStreamingUpdate(Update &&update) {
update.data.match([&](Information &update) {
streamingReady(std::move(update));
}, [&](const PreloadedVideo &update) {
}, [&](const UpdateVideo &update) {
this->update();
}, [&](const PreloadedAudio &update) {
}, [&](const UpdateAudio &update) {
}, [&](const WaitingForData &update) {
}, [&](MutedByOther) {
}, [&](Finished) {
});
}
case NotificationRepaint: {
if (_gifPreview && !_gifPreview->currentDisplayed()) {
update();
}
} break;
void EditCaptionBox::handleStreamingError(Error &&error) {
}
void EditCaptionBox::streamingReady(Information &&info) {
const auto calculateGifDimensions = [&]() {
const auto scaled = QSize(
info.video.size.width(),
info.video.size.height()
).scaled(
st::sendMediaPreviewSize * cIntRetinaFactor(),
st::confirmMaxHeight * cIntRetinaFactor(),
Qt::KeepAspectRatio);
_thumbw = _gifw = scaled.width();
_thumbh = _gifh = scaled.height();
_thumbx = _gifx = (st::boxWideWidth - _gifw) / 2;
updateBoxSize();
};
// If gif file is not mp4,
// Its dimension values will be known only after reading.
if (_gifw <= 0 || _gifh <= 0) {
calculateGifDimensions();
}
}
@@ -390,7 +501,7 @@ void EditCaptionBox::updateEditPreview() {
_animated = false;
_photo = false;
_doc = false;
_gifPreview = nullptr;
_streamed = nullptr;
_thumbw = _thumbh = _thumbx = 0;
_gifw = _gifh = _gifx = 0;
@@ -469,7 +580,7 @@ void EditCaptionBox::updateEditPreview() {
_gifw = _thumbw;
_gifh = _thumbh;
_gifx = _thumbx;
prepareGifPreview();
prepareStreamedPreview();
}
}
updateEditMediaButton();
@@ -530,6 +641,10 @@ void EditCaptionBox::createEditMediaButton() {
}
void EditCaptionBox::prepare() {
if (_animated) {
prepareStreamedPreview();
}
addButton(tr::lng_settings_save(), [this] { save(); });
if (_isAllowedEditMedia) {
createEditMediaButton();
@@ -548,12 +663,8 @@ void EditCaptionBox::prepare() {
if (action == Ui::InputField::MimeAction::Check) {
if (!data->hasText() && !_isAllowedEditMedia) {
return false;
} else if (data->hasImage()) {
} else if (CheckMimeData(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) {
@@ -571,6 +682,8 @@ void EditCaptionBox::prepare() {
auto cursor = _field->textCursor();
cursor.movePosition(QTextCursor::End);
_field->setTextCursor(cursor);
setupDragArea();
}
bool EditCaptionBox::fileFromClipboard(not_null<const QMimeData*> data) {
@@ -578,47 +691,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 = 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;
@@ -663,6 +763,35 @@ void EditCaptionBox::setupEmojiPanel() {
});
}
void EditCaptionBox::setupDragArea() {
auto enterFilter = [=](not_null<const QMimeData*> data) {
return !_isAllowedEditMedia ? false : CheckMimeData(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) {
@@ -684,6 +813,31 @@ int EditCaptionBox::errorTopSkip() const {
return (st::defaultBox.buttonPadding.top() / 2);
}
void EditCaptionBox::checkStreamedIsStarted() {
if (!_streamed) {
return;
}
if (_streamed->paused()) {
_streamed->resume();
}
if (!_streamed->active() && !_streamed->failed()) {
startStreamedPlayer();
}
}
void EditCaptionBox::startStreamedPlayer() {
auto options = ::Media::Streaming::PlaybackOptions();
options.audioId = _documentMedia
? AudioMsgId(_documentMedia->owner(), _msgId)
: AudioMsgId();
options.waitForMarkAsShown = true;
//if (!_streamed->withSound) {
options.mode = ::Media::Streaming::Mode::Video;
options.loop = true;
//}
_streamed->play(options);
}
void EditCaptionBox::paintEvent(QPaintEvent *e) {
BoxContent::paintEvent(e);
@@ -697,16 +851,27 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) {
if (_thumbx + _thumbw < width() - st::boxPhotoPadding.right()) {
p.fillRect(_thumbx + _thumbw, st::boxPhotoPadding.top(), width() - st::boxPhotoPadding.right() - _thumbx - _thumbw, th, st::confirmBg);
}
if (_gifPreview && _gifPreview->started()) {
checkStreamedIsStarted();
if (_streamed
&& _streamed->player().ready()
&& !_streamed->player().videoSize().isEmpty()) {
const auto s = QSize(_gifw, _gifh);
const auto paused = _controller->isGifPausedAtLeastFor(Window::GifPauseReason::Layer);
const auto frame = _gifPreview->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, RectPart::None, paused ? 0 : crl::now());
p.drawPixmap(_gifx, st::boxPhotoPadding.top(), frame);
auto request = ::Media::Streaming::FrameRequest();
request.outer = s * cIntRetinaFactor();
request.resize = s * cIntRetinaFactor();
p.drawImage(
QRect(_gifx, st::boxPhotoPadding.top(), _gifw, _gifh),
_streamed->frame(request));
if (!paused) {
_streamed->markFrameShown();
}
} else {
const auto offset = _gifh ? ((_gifh - _thumbh) / 2) : 0;
p.drawPixmap(_thumbx, st::boxPhotoPadding.top() + offset, _thumb);
}
if (_animated && !_gifPreview) {
if (_animated && !_streamed) {
QRect inner(_thumbx + (_thumbw - st::msgFileSize) / 2, st::boxPhotoPadding.top() + (th - st::msgFileSize) / 2, st::msgFileSize, st::msgFileSize);
p.setPen(Qt::NoPen);
p.setBrush(st::msgDateImgBg);
@@ -822,87 +987,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(
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 = MTP::send(
MTPmessages_EditMessage(
MTP_flags(flags),
item->history()->peer->input,
MTP_int(item->id),
MTP_string(sending.text),
MTPInputMedia(),
MTPReplyMarkup(),
sentEntities,
MTP_int(0)), // schedule_date
rpcDone(&EditCaptionBox::saveDone),
rpcFail(&EditCaptionBox::saveFail));
}
void EditCaptionBox::saveDone(const MTPUpdates &updates) {
_saveRequestId = 0;
const auto controller = _controller;
closeBox();
controller->session().api().applyUpdates(updates);
}
bool EditCaptionBox::saveFail(const RPCError &error) {
if (MTP::isDefaultHandledError(error)) return false;
_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);
} else if (type == qstr("MESSAGE_NOT_MODIFIED")) {
const auto done = crl::guard(this, [=](const MTPUpdates &updates) {
_saveRequestId = 0;
closeBox();
return true;
} else if (type == qstr("MESSAGE_EMPTY")) {
_field->setFocus();
_field->showError();
} else {
_error = tr::lng_edit_error(tr::now);
}
update();
return true;
});
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) {

View File

@@ -10,8 +10,8 @@ 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 "media/clip/media_clip_reader.h"
#include "mtproto/mtproto_rpc_sender.h"
class Image;
namespace ChatHelpers {
class TabbedPanel;
@@ -23,6 +23,8 @@ class SessionController;
namespace Data {
class Media;
class PhotoMedia;
class DocumentMedia;
} // namespace Data
namespace Ui {
@@ -36,15 +38,23 @@ namespace Window {
class SessionController;
} // namespace Window
class EditCaptionBox
: public Ui::BoxContent
, public RPCSender
, private base::Subscriber {
namespace Media {
namespace Streaming {
class Instance;
class Document;
struct Update;
enum class Error;
struct Information;
} // namespace Streaming
} // namespace Media
class EditCaptionBox final : public Ui::BoxContent, private base::Subscriber {
public:
EditCaptionBox(
QWidget*,
not_null<Window::SessionController*> controller,
not_null<HistoryItem*> item);
~EditCaptionBox();
protected:
void prepare() override;
@@ -56,19 +66,24 @@ protected:
private:
void updateBoxSize();
void prepareGifPreview(DocumentData* document = nullptr);
void clipCallback(Media::Clip::Notification notification);
void prepareStreamedPreview();
void checkStreamedIsStarted();
void setupStreamedPreview(
std::shared_ptr<::Media::Streaming::Document> shared);
void handleStreamingUpdate(::Media::Streaming::Update &&update);
void handleStreamingError(::Media::Streaming::Error &&error);
void streamingReady(::Media::Streaming::Information &&info);
void startStreamedPlayer();
void setupEmojiPanel();
void updateEmojiPanelGeometry();
void emojiFilterForGeometry(not_null<QEvent*> event);
void setupDragArea();
void save();
void captionResized();
void saveDone(const MTPUpdates &updates);
bool saveFail(const RPCError &error);
void setName(QString nameString, qint64 size);
bool fileFromClipboard(not_null<const QMimeData*> data);
void updateEditPreview();
@@ -84,9 +99,11 @@ private:
: _preparedList.files.front().path;
}
not_null<Window::SessionController*> _controller;
const not_null<Window::SessionController*> _controller;
FullMsgId _msgId;
Image *_thumbnailImage = nullptr;
std::shared_ptr<Data::PhotoMedia> _photoMedia;
std::shared_ptr<Data::DocumentMedia> _documentMedia;
bool _thumbnailImageLoaded = false;
Fn<void()> _refreshThumbnail;
bool _animated = false;
@@ -94,7 +111,7 @@ private:
bool _doc = false;
QPixmap _thumb;
Media::Clip::ReaderPointer _gifPreview;
std::unique_ptr<::Media::Streaming::Instance> _streamed;
object_ptr<Ui::InputField> _field = { nullptr };
object_ptr<Ui::EmojiButton> _emojiToggle = { nullptr };
@@ -115,7 +132,6 @@ private:
Storage::PreparedList _preparedList;
bool _previewCancelled = false;
mtpRequestId _saveRequestId = 0;
object_ptr<Ui::IconButton> _editMedia = nullptr;

View File

@@ -19,6 +19,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_chat_filters.h"
#include "data/data_peer.h"
#include "data/data_session.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "settings/settings_common.h"
#include "base/event_filter.h"
#include "lang/lang_keys.h"
@@ -78,6 +80,7 @@ private:
};
struct PeerButton {
not_null<History*> history;
std::shared_ptr<Data::CloudImageView> userpic;
Button button;
};
@@ -184,9 +187,10 @@ void FilterChatsPreview::updateData(
}
}
for (const auto history : peers) {
_removePeer.push_back({
history,
makeButton([=] { removePeer(history); }) });
_removePeer.push_back(PeerButton{
.history = history,
.button = makeButton([=] { removePeer(history); })
});
}
refresh();
}
@@ -203,7 +207,7 @@ int FilterChatsPreview::resizeGetHeight(int newWidth) {
for (const auto &[flag, button] : _removeFlag) {
moveNextButton(button.get());
}
for (const auto &[history, button] : _removePeer) {
for (const auto &[history, userpic, button] : _removePeer) {
moveNextButton(button.get());
}
return top;
@@ -235,7 +239,7 @@ void FilterChatsPreview::paintEvent(QPaintEvent *e) {
FilterChatsTypeName(flag));
top += st.height;
}
for (const auto &[history, button] : _removePeer) {
for (auto &[history, userpic, button] : _removePeer) {
const auto savedMessages = history->peer->isSelf();
if (savedMessages) {
Ui::EmptyUserpic::PaintSavedMessages(
@@ -253,6 +257,7 @@ void FilterChatsPreview::paintEvent(QPaintEvent *e) {
} else {
history->peer->paintUserpicLeft(
p,
userpic,
iconLeft,
top + iconTop,
width(),
@@ -497,7 +502,7 @@ void EditFilterBox(
name->setMaxLength(kMaxFilterTitleLength);
name->setInstantReplaces(Ui::InstantReplaces::Default());
name->setInstantReplacesEnabled(
window->session().settings().replaceEmojiValue());
Core::App().settings().replaceEmojiValue());
Ui::Emoji::SuggestionsController::Init(
box->getDelegate()->outerContainer(),
name,

View File

@@ -180,11 +180,12 @@ QString ExceptionRow::generateShortName() {
PaintRoundImageCallback ExceptionRow::generatePaintUserpicCallback() {
const auto peer = this->peer();
const auto saved = peer->isSelf();
return [=](Painter &p, int x, int y, int outerWidth, int size) {
auto userpic = saved ? nullptr : ensureUserpicView();
return [=](Painter &p, int x, int y, int outerWidth, int size) mutable {
if (saved) {
Ui::EmptyUserpic::PaintSavedMessages(p, x, y, outerWidth, size);
} else {
peer->paintUserpicLeft(p, x, y, outerWidth, size);
peer->paintUserpicLeft(p, userpic, x, y, outerWidth, size);
}
};
}

View File

@@ -1100,10 +1100,13 @@ void LanguageBox::prepare() {
) | rpl::start_with_next([=](const Language &language) {
// "#custom" is applied each time it's passed to switchToLanguage().
// So we check that the language really has changed.
if (language.id != Lang::Current().id()) {
const auto currentId = [] {
return Lang::LanguageIdOrDefault(Lang::Current().id());
};
if (language.id != currentId()) {
Lang::CurrentCloudManager().switchToLanguage(language);
if (inner) {
inner->changeChosen(Lang::Current().id());
inner->changeChosen(currentId());
}
}
}, inner->lifetime());

View File

@@ -15,7 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/continuous_sliders.h"
#include "ui/effects/radial_animation.h"
#include "ui/emoji_config.h"
#include "storage/localstorage.h"
#include "storage/storage_account.h"
#include "storage/cache/storage_cache_database.h"
#include "data/data_session.h"
#include "lang/lang_keys.h"
@@ -206,7 +206,7 @@ void LocalStorageBox::Row::radialAnimationCallback() {
}
rpl::producer<> LocalStorageBox::Row::clearRequests() const {
return _clear->clicks() | rpl::map([] { return rpl::empty_value(); });
return _clear->clicks() | rpl::to_empty;
}
int LocalStorageBox::Row::resizeGetHeight(int newWidth) {
@@ -271,8 +271,8 @@ LocalStorageBox::LocalStorageBox(
: _session(session)
, _db(&session->data().cache())
, _dbBig(&session->data().cacheBigFile()) {
const auto &settings = Local::cacheSettings();
const auto &settingsBig = Local::cacheBigFileSettings();
const auto &settings = session->local().cacheSettings();
const auto &settingsBig = session->local().cacheBigFileSettings();
_totalSizeLimit = settings.totalSizeLimit + settingsBig.totalSizeLimit;
_mediaSizeLimit = settingsBig.totalSizeLimit;
_timeLimit = settings.totalTimeLimit;
@@ -560,8 +560,8 @@ void LocalStorageBox::setupLimits(not_null<Ui::VerticalLayout*> container) {
}
void LocalStorageBox::limitsChanged() {
const auto &settings = Local::cacheSettings();
const auto &settingsBig = Local::cacheBigFileSettings();
const auto &settings = _session->local().cacheSettings();
const auto &settingsBig = _session->local().cacheBigFileSettings();
const auto sizeLimit = _totalSizeLimit - _mediaSizeLimit;
const auto changed = (settings.totalSizeLimit != sizeLimit)
|| (settingsBig.totalSizeLimit != _mediaSizeLimit)
@@ -590,7 +590,7 @@ void LocalStorageBox::save() {
auto updateBig = Storage::Cache::Database::SettingsUpdate();
updateBig.totalSizeLimit = _mediaSizeLimit;
updateBig.totalTimeLimit = _timeLimit;
Local::updateCacheSettings(update, updateBig);
_session->local().updateCacheSettings(update, updateBig);
_session->data().cache().updateSettings(update);
closeBox();
}

View File

@@ -14,7 +14,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwindow.h"
#include "apiwrap.h"
#include "main/main_session.h"
#include "storage/localstorage.h"
#include "main/main_domain.h"
#include "core/application.h"
#include "storage/storage_domain.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h"
#include "ui/widgets/labels.h"
@@ -48,7 +50,7 @@ PasscodeBox::PasscodeBox(
not_null<Main::Session*> session,
bool turningOff)
: _session(session)
, _api(_session->api().instance())
, _api(&_session->mtp())
, _turningOff(turningOff)
, _about(st::boxWidth - st::boxPadding.left() * 1.5)
, _oldPasscode(this, st::defaultInputField, tr::lng_passcode_enter_old())
@@ -64,7 +66,7 @@ PasscodeBox::PasscodeBox(
not_null<Main::Session*> session,
const CloudFields &fields)
: _session(session)
, _api(_session->api().instance())
, _api(&_session->mtp())
, _turningOff(fields.turningOff)
, _cloudPwd(true)
, _cloudFields(fields)
@@ -450,7 +452,7 @@ void PasscodeBox::save(bool force) {
return;
}
if (Local::checkPasscode(old.toUtf8())) {
if (Core::App().domain().local().checkPasscode(old.toUtf8())) {
cSetPasscodeBadTries(0);
if (_turningOff) pwd = conf = QString();
} else {
@@ -518,8 +520,8 @@ void PasscodeBox::save(bool force) {
closeReplacedBy();
const auto weak = Ui::MakeWeak(this);
cSetPasscodeBadTries(0);
Local::setPasscode(pwd.toUtf8());
_session->localPasscodeChanged();
Core::App().domain().local().setPasscode(pwd.toUtf8());
Core::App().localPasscodeChanged();
if (weak) {
closeBox();
}
@@ -683,7 +685,7 @@ void PasscodeBox::setNewCloudPassword(const QString &newPassword) {
setPasswordDone(newPasswordBytes);
}).fail([=](const RPCError &error) {
setPasswordFail(newPasswordBytes, email, error);
}).send();
}).handleFloodErrors().send();
}
void PasscodeBox::changeCloudPassword(
@@ -736,9 +738,9 @@ void PasscodeBox::changeCloudPassword(
sendChangeCloudPassword(check, newPassword, secureSecret);
});
}
}).handleFloodErrors().fail([=](const RPCError &error) {
}).fail([=](const RPCError &error) {
setPasswordFail(error);
}).send();
}).handleFloodErrors().send();
}
void PasscodeBox::suggestSecretReset(const QString &newPassword) {
@@ -831,9 +833,9 @@ void PasscodeBox::sendChangeCloudPassword(
MTP_long(newSecureSecretId)))
)).done([=](const MTPBool &result) {
setPasswordDone(newPasswordBytes);
}).handleFloodErrors().fail([=](const RPCError &error) {
}).fail([=](const RPCError &error) {
setPasswordFail(newPasswordBytes, QString(), error);
}).send();
}).handleFloodErrors().send();
}
void PasscodeBox::badOldPasscode() {
@@ -895,13 +897,14 @@ void PasscodeBox::recover() {
if (_pattern == "-") return;
const auto box = getDelegate()->show(Box<RecoverBox>(
_session,
_pattern,
_cloudFields.notEmptyPassport));
box->passwordCleared(
) | rpl::map([] {
return QByteArray();
}) | rpl::start_to_stream(_newPasswordSet, lifetime());
) | rpl::map_to(
QByteArray()
) | rpl::start_to_stream(_newPasswordSet, lifetime());
box->recoveryExpired(
) | rpl::start_with_next([=] {
@@ -923,9 +926,11 @@ void PasscodeBox::recoverStartFail(const RPCError &error) {
RecoverBox::RecoverBox(
QWidget*,
not_null<Main::Session*> session,
const QString &pattern,
bool notEmptyPassport)
: _pattern(st::normalFont->elided(tr::lng_signin_recover_hint(tr::now, lt_recover_email, pattern), st::boxWidth - st::boxPadding.left() * 1.5))
: _api(&session->mtp())
, _pattern(st::normalFont->elided(tr::lng_signin_recover_hint(tr::now, lt_recover_email, pattern), st::boxWidth - st::boxPadding.left() * 1.5))
, _notEmptyPassport(notEmptyPassport)
, _recoverCode(this, st::defaultInputField, tr::lng_signin_code()) {
}
@@ -988,10 +993,13 @@ void RecoverBox::submit() {
}
const auto send = crl::guard(this, [=] {
_submitRequest = MTP::send(
MTPauth_RecoverPassword(MTP_string(code)),
rpcDone(&RecoverBox::codeSubmitDone, true),
rpcFail(&RecoverBox::codeSubmitFail));
_submitRequest = _api.request(MTPauth_RecoverPassword(
MTP_string(code)
)).done([=](const MTPauth_Authorization &result) {
codeSubmitDone(result);
}).fail([=](const RPCError &error) {
codeSubmitFail(error);
}).handleFloodErrors().send();
});
if (_notEmptyPassport) {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>();
@@ -1015,9 +1023,7 @@ void RecoverBox::codeChanged() {
update();
}
void RecoverBox::codeSubmitDone(
bool recover,
const MTPauth_Authorization &result) {
void RecoverBox::codeSubmitDone(const MTPauth_Authorization &result) {
_submitRequest = 0;
_passwordCleared.fire({});
@@ -1026,16 +1032,14 @@ void RecoverBox::codeSubmitDone(
Ui::LayerOption::CloseOther);
}
bool RecoverBox::codeSubmitFail(const RPCError &error) {
void RecoverBox::codeSubmitFail(const RPCError &error) {
if (MTP::isFloodError(error)) {
_submitRequest = 0;
_error = tr::lng_flood_error(tr::now);
update();
_recoverCode->showError();
return true;
return;
}
if (MTP::isDefaultHandledError(error)) return false;
_submitRequest = 0;
const QString &err = error.type();
@@ -1044,33 +1048,31 @@ bool RecoverBox::codeSubmitFail(const RPCError &error) {
getDelegate()->show(
Box<InformBox>(tr::lng_cloud_password_removed(tr::now)),
Ui::LayerOption::CloseOther);
return true;
} else if (err == qstr("PASSWORD_RECOVERY_NA")) {
closeBox();
return true;
} else if (err == qstr("PASSWORD_RECOVERY_EXPIRED")) {
_recoveryExpired.fire({});
closeBox();
return true;
} else if (err == qstr("CODE_INVALID")) {
_error = tr::lng_signin_wrong_code(tr::now);
update();
_recoverCode->selectAll();
_recoverCode->setFocus();
_recoverCode->showError();
return true;
}
if (Logs::DebugEnabled()) { // internal server error
_error = err + ": " + error.description();
} else {
_error = Lang::Hard::ServerError();
if (Logs::DebugEnabled()) { // internal server error
_error = err + ": " + error.description();
} else {
_error = Lang::Hard::ServerError();
}
update();
_recoverCode->setFocus();
}
update();
_recoverCode->setFocus();
return false;
}
RecoveryEmailValidation ConfirmRecoveryEmail(const QString &pattern) {
RecoveryEmailValidation ConfirmRecoveryEmail(
not_null<Main::Session*> session,
const QString &pattern) {
const auto errors = std::make_shared<rpl::event_stream<QString>>();
const auto resent = std::make_shared<rpl::event_stream<QString>>();
const auto requestId = std::make_shared<mtpRequestId>(0);
@@ -1082,7 +1084,9 @@ RecoveryEmailValidation ConfirmRecoveryEmail(const QString &pattern) {
if (*requestId) {
return;
}
const auto done = [=](const MTPBool &result) {
*requestId = session->api().request(MTPaccount_ConfirmPasswordEmail(
MTP_string(code)
)).done([=](const MTPBool &result) {
*requestId = 0;
reloads->fire({});
if (*weak) {
@@ -1090,13 +1094,7 @@ RecoveryEmailValidation ConfirmRecoveryEmail(const QString &pattern) {
Box<InformBox>(tr::lng_cloud_password_was_set(tr::now)),
Ui::LayerOption::CloseOther);
}
};
const auto fail = [=](const RPCError &error) {
const auto skip = MTP::isDefaultHandledError(error)
&& !MTP::isFloodError(error);
if (skip) {
return false;
}
}).fail([=](const RPCError &error) {
*requestId = 0;
if (MTP::isFloodError(error)) {
errors->fire(tr::lng_flood_error(tr::now));
@@ -1114,26 +1112,20 @@ RecoveryEmailValidation ConfirmRecoveryEmail(const QString &pattern) {
} else {
errors->fire(Lang::Hard::ServerError());
}
return true;
};
*requestId = MTP::send(
MTPaccount_ConfirmPasswordEmail(MTP_string(code)),
rpcDone(done),
rpcFail(fail));
}).handleFloodErrors().send();
};
const auto resend = [=] {
if (*requestId) {
return;
}
*requestId = MTP::send(MTPaccount_ResendPasswordEmail(
), rpcDone([=](const MTPBool &result) {
*requestId = session->api().request(MTPaccount_ResendPasswordEmail(
)).done([=](const MTPBool &result) {
*requestId = 0;
resent->fire(tr::lng_cloud_password_resent(tr::now));
}), rpcFail([=](const RPCError &error) {
}).fail([=](const RPCError &error) {
*requestId = 0;
errors->fire(Lang::Hard::ServerError());
return true;
}));
}).send();
};
auto box = Passport::VerifyEmailBox(

View File

@@ -164,9 +164,13 @@ private:
};
class RecoverBox : public Ui::BoxContent, public RPCSender {
class RecoverBox final : public Ui::BoxContent {
public:
RecoverBox(QWidget*, const QString &pattern, bool notEmptyPassport);
RecoverBox(
QWidget*,
not_null<Main::Session*> session,
const QString &pattern,
bool notEmptyPassport);
rpl::producer<> passwordCleared() const;
rpl::producer<> recoveryExpired() const;
@@ -184,9 +188,10 @@ protected:
private:
void submit();
void codeChanged();
void codeSubmitDone(bool recover, const MTPauth_Authorization &result);
bool codeSubmitFail(const RPCError &error);
void codeSubmitDone(const MTPauth_Authorization &result);
void codeSubmitFail(const RPCError &error);
MTP::Sender _api;
mtpRequestId _submitRequest = 0;
QString _pattern;
@@ -206,4 +211,6 @@ struct RecoveryEmailValidation {
rpl::producer<> reloadRequests;
rpl::producer<> cancelRequests;
};
RecoveryEmailValidation ConfirmRecoveryEmail(const QString &pattern);
[[nodiscard]] RecoveryEmailValidation ConfirmRecoveryEmail(
not_null<Main::Session*> session,
const QString &pattern);

View File

@@ -19,11 +19,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/wrap/slide_wrap.h"
#include "ui/text_options.h"
#include "lang/lang_keys.h"
#include "observer_peer.h"
#include "storage/file_download.h"
#include "data/data_peer_values.h"
#include "data/data_chat.h"
#include "data/data_session.h"
#include "data/data_changes.h"
#include "base/unixtime.h"
#include "window/themes/window_theme.h"
#include "styles/style_layers.h"
@@ -41,8 +41,9 @@ PaintRoundImageCallback PaintUserpicCallback(
Ui::EmptyUserpic::PaintSavedMessages(p, x, y, outerWidth, size);
};
}
return [=](Painter &p, int x, int y, int outerWidth, int size) {
peer->paintUserpicLeft(p, x, y, outerWidth, size);
auto userpic = std::shared_ptr<Data::CloudImageView>();
return [=](Painter &p, int x, int y, int outerWidth, int size) mutable {
peer->paintUserpicLeft(p, userpic, x, y, outerWidth, size);
};
}
@@ -483,14 +484,22 @@ QString PeerListRow::generateShortName() {
: peer()->shortName();
}
std::shared_ptr<Data::CloudImageView> PeerListRow::ensureUserpicView() {
if (!_userpic) {
_userpic = peer()->createUserpicView();
}
return _userpic;
}
PaintRoundImageCallback PeerListRow::generatePaintUserpicCallback() {
const auto saved = _isSavedMessagesChat;
const auto peer = this->peer();
return [=](Painter &p, int x, int y, int outerWidth, int size) {
auto userpic = saved ? nullptr : ensureUserpicView();
return [=](Painter &p, int x, int y, int outerWidth, int size) mutable {
if (saved) {
Ui::EmptyUserpic::PaintSavedMessages(p, x, y, outerWidth, size);
} else {
peer->paintUserpicLeft(p, x, y, outerWidth, size);
peer->paintUserpicLeft(p, userpic, x, y, outerWidth, size);
}
};
}
@@ -595,7 +604,7 @@ void PeerListRow::paintDisabledCheckUserpic(
if (_isSavedMessagesChat) {
Ui::EmptyUserpic::PaintSavedMessages(p, userpicLeft, userpicTop, outerWidth, userpicRadius * 2);
} else {
peer()->paintUserpicLeft(p, userpicLeft, userpicTop, outerWidth, userpicRadius * 2);
peer()->paintUserpicLeft(p, _userpic, userpicLeft, userpicTop, outerWidth, userpicRadius * 2);
}
{
@@ -653,19 +662,23 @@ PeerListContent::PeerListContent(
, _st(st)
, _controller(controller)
, _rowHeight(_st.item.height) {
subscribe(_controller->session().downloaderTaskFinished(), [=] {
_controller->session().downloaderTaskFinished(
) | rpl::start_with_next([=] {
update();
});
}, lifetime());
using UpdateFlag = Notify::PeerUpdate::Flag;
auto changes = UpdateFlag::NameChanged | UpdateFlag::PhotoChanged;
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(changes, [this](const Notify::PeerUpdate &update) {
if (update.flags & UpdateFlag::PhotoChanged) {
this->update();
} else if (update.flags & UpdateFlag::NameChanged) {
handleNameChanged(update);
using UpdateFlag = Data::PeerUpdate::Flag;
_controller->session().changes().peerUpdates(
UpdateFlag::Name | UpdateFlag::Photo
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
if (update.flags & UpdateFlag::Name) {
handleNameChanged(update.peer);
}
}));
if (update.flags & UpdateFlag::Photo) {
this->update();
}
}, lifetime());
subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &update) {
if (update.paletteChanged()) {
invalidatePixmapsCache();
@@ -1286,7 +1299,6 @@ crl::time PeerListContent::paintRow(
p.drawTextLeft(_st.item.statusPosition.x(), _st.item.statusPosition.y(), width(), highlightedPart);
} else {
grayedPart = st::contactsStatusFont->elided(grayedPart, availableWidth - highlightedWidth);
auto grayedWidth = st::contactsStatusFont->width(grayedPart);
p.setPen(_st.item.statusFgActive);
p.drawTextLeft(_st.item.statusPosition.x(), _st.item.statusPosition.y(), width(), highlightedPart);
p.setPen(selected ? _st.item.statusFgOver : _st.item.statusFg);
@@ -1708,8 +1720,8 @@ PeerListContent::RowIndex PeerListContent::findRowIndex(
return result;
}
void PeerListContent::handleNameChanged(const Notify::PeerUpdate &update) {
auto byPeer = _rowsByPeer.find(update.peer);
void PeerListContent::handleNameChanged(not_null<PeerData*> peer) {
auto byPeer = _rowsByPeer.find(peer);
if (byPeer != _rowsByPeer.cend()) {
for (auto row : byPeer->second) {
if (addingToSearchIndex()) {

View File

@@ -7,11 +7,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include <rpl/event_stream.h>
#include "ui/rp_widget.h"
#include "ui/empty_userpic.h"
#include "boxes/abstract_box.h"
#include "mtproto/sender.h"
#include "data/data_cloud_file.h"
#include "base/timer.h"
namespace style {
@@ -34,10 +34,6 @@ struct ScrollToRequest;
class PopupMenu;
} // namespace Ui
namespace Notify {
struct PeerUpdate;
} // namespace Notify
using PaintRoundImageCallback = Fn<void(
Painter &p,
int x,
@@ -85,6 +81,8 @@ public:
return _id;
}
[[nodiscard]] std::shared_ptr<Data::CloudImageView> ensureUserpicView();
[[nodiscard]] virtual QString generateName();
[[nodiscard]] virtual QString generateShortName();
[[nodiscard]] virtual auto generatePaintUserpicCallback()
@@ -223,6 +221,7 @@ private:
PeerListRowId _id = 0;
PeerData *_peer = nullptr;
mutable std::shared_ptr<Data::CloudImageView> _userpic;
std::unique_ptr<Ui::RippleAnimation> _ripple;
std::unique_ptr<Ui::RoundImageCheckbox> _checkbox;
Ui::Text::String _name;
@@ -548,7 +547,7 @@ protected:
private:
void refreshIndices();
void removeRowAtIndex(std::vector<std::unique_ptr<PeerListRow>> &from, int index);
void handleNameChanged(const Notify::PeerUpdate &update);
void handleNameChanged(not_null<PeerData*> peer);
void invalidatePixmapsCache();

View File

@@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/peer_list_controllers.h"
#include "boxes/confirm_box.h"
#include "observer_peer.h"
#include "ui/widgets/checkbox.h"
#include "ui/ui_utility.h"
#include "main/main_session.h"
@@ -147,7 +146,7 @@ void PeerListRowWithLink::paintAction(
PeerListGlobalSearchController::PeerListGlobalSearchController(
not_null<Window::SessionNavigation*> navigation)
: _navigation(navigation)
, _api(_navigation->session().api().instance()) {
, _api(&_navigation->session().mtp()) {
_timer.setCallback([this] { searchOnServer(); });
}

View File

@@ -15,16 +15,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_user.h"
#include "data/data_session.h"
#include "data/data_folder.h"
#include "data/data_changes.h"
#include "history/history.h"
#include "dialogs/dialogs_indexed_list.h"
#include "base/unixtime.h"
#include "main/main_session.h"
#include "mtproto/mtproto_config.h"
#include "mainwidget.h"
#include "mainwindow.h"
#include "window/window_session_controller.h"
#include "apiwrap.h"
#include "observer_peer.h"
#include "facades.h"
#include "facades.h" // Ui::showPeerHistory
#include "app.h"
namespace {
@@ -87,10 +88,11 @@ void AddParticipantsBoxController::subscribeToMigration() {
}
void AddParticipantsBoxController::rowClicked(not_null<PeerListRow*> row) {
const auto &serverConfig = session().serverConfig();
auto count = fullCount();
auto limit = _peer && (_peer->isChat() || _peer->isMegagroup())
? Global::MegagroupSizeMax()
: Global::ChatSizeMax();
? serverConfig.megagroupSizeMax
: serverConfig.chatSizeMax;
if (count < limit || row->checked()) {
delegate()->peerListSetRowChecked(row, !row->checked());
updateTitle();
@@ -100,8 +102,8 @@ void AddParticipantsBoxController::rowClicked(not_null<PeerListRow*> row) {
Box<MaxInviteBox>(_peer->asChannel()),
Ui::LayerOption::KeepOther);
}
} else if (count >= Global::ChatSizeMax()
&& count < Global::MegagroupSizeMax()) {
} else if (count >= serverConfig.chatSizeMax
&& count < serverConfig.megagroupSizeMax) {
Ui::show(
Box<InformBox>(tr::lng_profile_add_more_after_create(tr::now)),
Ui::LayerOption::KeepOther);
@@ -166,7 +168,9 @@ void AddParticipantsBoxController::updateTitle() {
&& _peer->isChannel()
&& !_peer->isMegagroup())
? QString()
: qsl("%1 / %2").arg(fullCount()).arg(Global::MegagroupSizeMax());
: qsl("%1 / %2"
).arg(fullCount()
).arg(session().serverConfig().megagroupSizeMax);
delegate()->peerListSetTitle(tr::lng_profile_add_participant());
delegate()->peerListSetAdditionalTitle(rpl::single(additional));
}
@@ -240,7 +244,7 @@ void AddParticipantsBoxController::Start(
box->boxClosing() | rpl::start_with_next([=] {
auto params = Window::SectionShow();
params.activation = anim::activation::background;
App::wnd()->sessionController()->showPeerHistory(
navigation->parentController()->showPeerHistory(
channel,
params,
ShowAtTheEndMsgId);
@@ -276,7 +280,7 @@ AddSpecialBoxController::AddSpecialBoxController(
peer,
&_additional))
, _peer(peer)
, _api(_peer->session().api().instance())
, _api(&_peer->session().mtp())
, _role(role)
, _additional(peer, Role::Members)
, _adminDoneCallback(std::move(adminDoneCallback))
@@ -348,17 +352,16 @@ void AddSpecialBoxController::prepareChatRows(not_null<ChatData*> chat) {
chat->updateFullForced();
}
using UpdateFlag = Notify::PeerUpdate::Flag;
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(
UpdateFlag::MembersChanged | UpdateFlag::AdminsChanged,
[=](const Notify::PeerUpdate &update) {
if (update.peer == chat) {
_additional.fillFromPeer();
if (update.flags & UpdateFlag::MembersChanged) {
rebuildChatRows(chat);
}
}
}));
using UpdateFlag = Data::PeerUpdate::Flag;
chat->session().changes().peerUpdates(
chat,
UpdateFlag::Members | UpdateFlag::Admins
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
_additional.fillFromPeer();
if (update.flags & UpdateFlag::Members) {
rebuildChatRows(chat);
}
}, lifetime());
}
void AddSpecialBoxController::rebuildChatRows(not_null<ChatData*> chat) {
@@ -651,8 +654,6 @@ void AddSpecialBoxController::showRestricted(
_editParticipantBox->closeBox();
}
const auto chat = _peer->asChat();
const auto channel = _peer->asChannel();
const auto showRestrictedSure = crl::guard(this, [=] {
showRestricted(user, true);
});
@@ -830,7 +831,7 @@ AddSpecialBoxSearchController::AddSpecialBoxSearchController(
not_null<ParticipantsAdditionalData*> additional)
: _peer(peer)
, _additional(additional)
, _api(_peer->session().api().instance())
, _api(&_peer->session().mtp())
, _timer([=] { searchOnServer(); }) {
subscribeToMigration();
}

View File

@@ -83,7 +83,7 @@ class Controller {
public:
Controller(
not_null<Ui::GenericBox*> box,
not_null<Window::Controller*> window,
not_null<Window::SessionController*> window,
not_null<UserData*> user);
void prepare();
@@ -100,7 +100,7 @@ private:
bool inverted);
not_null<Ui::GenericBox*> _box;
not_null<Window::Controller*> _window;
not_null<Window::SessionController*> _window;
not_null<UserData*> _user;
Ui::Checkbox *_sharePhone = nullptr;
QString _phone;
@@ -111,7 +111,7 @@ private:
Controller::Controller(
not_null<Ui::GenericBox*> box,
not_null<Window::Controller*> window,
not_null<Window::SessionController*> window,
not_null<UserData*> user)
: _box(box)
, _window(window)
@@ -143,7 +143,7 @@ void Controller::setupCover() {
object_ptr<Info::Profile::Cover>(
_box,
_user,
_window->sessionController(),
_window,
(_phone.isEmpty()
? tr::lng_contact_mobile_hidden()
: rpl::single(App::formatPhone(_phone)))),
@@ -266,7 +266,7 @@ void Controller::setupSharePhoneNumber() {
void EditContactBox(
not_null<Ui::GenericBox*> box,
not_null<Window::Controller*> window,
not_null<Window::SessionController*> window,
not_null<UserData*> user) {
box->lifetime().make_state<Controller>(box, window, user)->prepare();
}

View File

@@ -12,10 +12,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
class UserData;
namespace Window {
class Controller;
class SessionController;
} // namespace Window
void EditContactBox(
not_null<Ui::GenericBox*> box,
not_null<Window::Controller*> window,
not_null<Window::SessionController*> window,
not_null<UserData*> user);

View File

@@ -35,7 +35,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/core_cloud_password.h"
#include "base/unixtime.h"
#include "apiwrap.h"
#include "facades.h"
#include "main/main_session.h"
#include "styles/style_layers.h"
#include "styles/style_boxes.h"

View File

@@ -13,22 +13,22 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/confirm_box.h"
#include "boxes/add_contact_box.h"
#include "main/main_session.h"
#include "mtproto/mtproto_config.h"
#include "apiwrap.h"
#include "lang/lang_keys.h"
#include "mainwidget.h"
#include "observer_peer.h"
#include "dialogs/dialogs_indexed_list.h"
#include "data/data_peer_values.h"
#include "data/data_session.h"
#include "data/data_channel.h"
#include "data/data_chat.h"
#include "data/data_user.h"
#include "data/data_changes.h"
#include "base/unixtime.h"
#include "ui/widgets/popup_menu.h"
#include "ui/ui_utility.h"
#include "window/window_session_controller.h"
#include "history/history.h"
#include "facades.h"
namespace {
@@ -286,20 +286,19 @@ void SubscribeToMigration(
if (const auto channel = peer->migrateTo()) {
migrate(channel);
} else if (!chat->isDeactivated()) {
const auto alive = lifetime.make_state<base::Subscription>();
const auto handler = [=](const Notify::PeerUpdate &update) {
if (update.peer == peer) {
if (const auto channel = peer->migrateTo()) {
const auto onstack = base::duplicate(migrate);
*alive = base::Subscription();
onstack(channel);
}
}
};
*alive = Notify::PeerUpdated().add_subscription(
Notify::PeerUpdatedHandler(
Notify::PeerUpdate::Flag::MigrationChanged,
handler));
chat->session().changes().peerUpdates(
peer,
Data::PeerUpdate::Flag::Migration
) | rpl::map([](const Data::PeerUpdate &update) {
return update.peer->migrateTo();
}) | rpl::filter([](ChannelData *channel) {
return (channel != nullptr);
}) | rpl::take(
1
) | rpl::start_with_next([=](not_null<ChannelData*> channel) {
const auto onstack = base::duplicate(migrate);
onstack(channel);
}, lifetime);
}
}
}
@@ -354,6 +353,16 @@ bool ParticipantsAdditionalData::canRestrictUser(
Unexpected("Peer in ParticipantsAdditionalData::canRestrictUser.");
}
bool ParticipantsAdditionalData::canRemoveUser(
not_null<UserData*> user) const {
if (canRestrictUser(user)) {
return true;
} else if (const auto chat = _peer->asChat()) {
return chat->invitedByMe.contains(user);
}
return false;
}
auto ParticipantsAdditionalData::adminRights(
not_null<UserData*> user) const
-> std::optional<MTPChatAdminRights> {
@@ -676,17 +685,15 @@ ParticipantsOnlineSorter::ParticipantsOnlineSorter(
: _peer(peer)
, _delegate(delegate)
, _sortByOnlineTimer([=] { sort(); }) {
const auto handleUpdate = [=](const Notify::PeerUpdate &update) {
peer->session().changes().peerUpdates(
Data::PeerUpdate::Flag::OnlineStatus
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
const auto peerId = update.peer->id;
if (const auto row = _delegate->peerListFindRow(peerId)) {
row->refreshStatus();
sortDelayed();
}
};
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(
Notify::PeerUpdate::Flag::UserOnlineChanged,
handleUpdate));
}, _lifetime);
sort();
}
@@ -700,7 +707,8 @@ void ParticipantsOnlineSorter::sort() {
const auto channel = _peer->asChannel();
if (channel
&& (!channel->isMegagroup()
|| channel->membersCount() > Global::ChatSizeMax())) {
|| (channel->membersCount()
> channel->session().serverConfig().chatSizeMax))) {
_onlineCount = 0;
return;
}
@@ -745,7 +753,7 @@ ParticipantsBoxController::ParticipantsBoxController(
: PeerListController(CreateSearchController(peer, role, &_additional))
, _navigation(navigation)
, _peer(peer)
, _api(_peer->session().api().instance())
, _api(&_peer->session().mtp())
, _role(role)
, _additional(peer, _role) {
subscribeToMigration();
@@ -837,8 +845,9 @@ void ParticipantsBoxController::Start(
return chat
? chat->canAddMembers()
: (channel->canAddMembers()
&& (channel->membersCount() < Global::ChatSizeMax()
|| channel->isMegagroup()));
&& (channel->isMegagroup()
|| (channel->membersCount()
< channel->session().serverConfig().chatSizeMax)));
case Role::Admins:
return chat
? chat->canAddAdmins()
@@ -917,7 +926,8 @@ void ParticipantsBoxController::addNewParticipants() {
if (chat) {
AddParticipantsBoxController::Start(_navigation, chat);
} else if (channel->isMegagroup()
|| channel->membersCount() < Global::ChatSizeMax()) {
|| (channel->membersCount()
< channel->session().serverConfig().chatSizeMax)) {
const auto count = delegate()->peerListFullRowsCount();
auto already = std::vector<not_null<UserData*>>();
already.reserve(count);
@@ -975,10 +985,10 @@ auto ParticipantsBoxController::saveState() const
const auto weak = result.get();
if (const auto chat = _peer->asChat()) {
Notify::PeerUpdateViewer(
chat->session().changes().peerUpdates(
chat,
Notify::PeerUpdate::Flag::MembersChanged
) | rpl::start_with_next([=](const Notify::PeerUpdate &) {
Data::PeerUpdate::Flag::Members
) | rpl::start_with_next([=] {
weak->controllerState = nullptr;
}, my->lifetime);
} else if (const auto channel = _peer->asMegagroup()) {
@@ -1094,23 +1104,20 @@ void ParticipantsBoxController::prepareChatRows(not_null<ChatData*> chat) {
chat->updateFullForced();
}
using UpdateFlag = Notify::PeerUpdate::Flag;
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(
UpdateFlag::MembersChanged
| UpdateFlag::AdminsChanged,
[=](const Notify::PeerUpdate &update) {
if (update.peer != chat) {
return;
}
_additional.fillFromPeer();
if ((update.flags & UpdateFlag::MembersChanged)
|| (_role == Role::Admins)) {
rebuildChatRows(chat);
}
if (update.flags & UpdateFlag::AdminsChanged) {
rebuildRowTypes();
}
}));
using UpdateFlag = Data::PeerUpdate::Flag;
chat->session().changes().peerUpdates(
chat,
UpdateFlag::Members | UpdateFlag::Admins
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
_additional.fillFromPeer();
if ((update.flags & UpdateFlag::Members)
|| (_role == Role::Admins)) {
rebuildChatRows(chat);
}
if (update.flags & UpdateFlag::Admins) {
rebuildRowTypes();
}
}, lifetime());
}
void ParticipantsBoxController::rebuildChatRows(not_null<ChatData*> chat) {
@@ -1436,6 +1443,8 @@ base::unique_qptr<Ui::PopupMenu> ParticipantsBoxController::rowContextMenu(
tr::lng_context_restrict_user(tr::now),
crl::guard(this, [=] { showRestricted(user); }));
}
}
if (_additional.canRemoveUser(user)) {
if (!_additional.isKicked(user)) {
const auto isGroup = _peer->isChat() || _peer->isMegagroup();
result->addAction(
@@ -1806,7 +1815,7 @@ auto ParticipantsBoxController::computeType(
: _additional.adminRights(user).has_value()
? Rights::Admin
: Rights::Normal;
result.canRemove = _additional.canRestrictUser(user);
result.canRemove = _additional.canRemoveUser(user);
return result;
}
@@ -1881,7 +1890,7 @@ void ParticipantsBoxController::subscribeToCreatorChange(
channel->inputChannel,
MTP_channelParticipantsRecent(),
MTP_int(0),
MTP_int(Global::ChatSizeMax()),
MTP_int(channel->session().serverConfig().chatSizeMax),
MTP_int(0)
)).done([=](const MTPchannels_ChannelParticipants &result) {
if (channel->amCreator()) {
@@ -1916,7 +1925,7 @@ ParticipantsBoxSearchController::ParticipantsBoxSearchController(
: _channel(channel)
, _role(role)
, _additional(additional)
, _api(_channel->session().api().instance()) {
, _api(&_channel->session().mtp()) {
_timer.setCallback([=] { searchOnServer(); });
}

View File

@@ -50,7 +50,7 @@ enum class ParticipantsRole {
Kicked,
};
class ParticipantsOnlineSorter : private base::Subscriber {
class ParticipantsOnlineSorter {
public:
ParticipantsOnlineSorter(
not_null<PeerData*> peer,
@@ -63,10 +63,11 @@ private:
void sortDelayed();
void refreshOnlineCount();
not_null<PeerData*> _peer;
not_null<PeerListDelegate*> _delegate;
const not_null<PeerData*> _peer;
const not_null<PeerListDelegate*> _delegate;
base::Timer _sortByOnlineTimer;
rpl::variable<int> _onlineCount = 0;
rpl::lifetime _lifetime;
};
@@ -88,6 +89,7 @@ public:
[[nodiscard]] bool canEditAdmin(not_null<UserData*> user) const;
[[nodiscard]] bool canAddOrEditAdmin(not_null<UserData*> user) const;
[[nodiscard]] bool canRestrictUser(not_null<UserData*> user) const;
[[nodiscard]] bool canRemoveUser(not_null<UserData*> user) const;
[[nodiscard]] std::optional<MTPChatAdminRights> adminRights(
not_null<UserData*> user) const;
QString adminRank(not_null<UserData*> user) const;

View File

@@ -19,6 +19,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/peers/edit_linked_chat_box.h"
#include "boxes/stickers_box.h"
#include "chat_helpers/emoji_suggestions_widget.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "data/data_channel.h"
#include "data/data_chat.h"
#include "data/data_peer.h"
@@ -29,7 +31,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwidget.h"
#include "mainwindow.h"
#include "mtproto/sender.h"
#include "observer_peer.h"
#include "ui/rp_widget.h"
#include "ui/special_buttons.h"
#include "ui/toast/toast.h"
@@ -192,9 +193,11 @@ void SaveSlowmodeSeconds(
api->registerModifyRequest(key, requestId);
}
void ShowEditPermissions(not_null<PeerData*> peer) {
void ShowEditPermissions(
not_null<Window::SessionNavigation*> navigation,
not_null<PeerData*> peer) {
const auto box = Ui::show(
Box<EditPeerPermissionsBox>(peer),
Box<EditPeerPermissionsBox>(navigation, peer),
Ui::LayerOption::KeepOther);
const auto saving = box->lifetime().make_state<int>(0);
const auto save = [=](
@@ -356,7 +359,7 @@ Controller::Controller(
: _navigation(navigation)
, _box(box)
, _peer(peer)
, _api(_peer->session().api().instance())
, _api(&_peer->session().mtp())
, _isGroup(_peer->isChat() || _peer->isMegagroup()) {
_box->setTitle(_isGroup
? tr::lng_edit_group()
@@ -465,7 +468,7 @@ object_ptr<Ui::RpWidget> Controller::createTitleEdit() {
result->entity()->setMaxLength(kMaxGroupChannelTitle);
result->entity()->setInstantReplaces(Ui::InstantReplaces::Default());
result->entity()->setInstantReplacesEnabled(
_peer->session().settings().replaceEmojiValue());
Core::App().settings().replaceEmojiValue());
Ui::Emoji::SuggestionsController::Init(
_wrap->window(),
result->entity(),
@@ -499,8 +502,8 @@ object_ptr<Ui::RpWidget> Controller::createDescriptionEdit() {
result->entity()->setMaxLength(kMaxChannelDescription);
result->entity()->setInstantReplaces(Ui::InstantReplaces::Default());
result->entity()->setInstantReplacesEnabled(
_peer->session().settings().replaceEmojiValue());
result->entity()->setSubmitSettings(_peer->session().settings().sendSubmitWay());
Core::App().settings().replaceEmojiValue());
result->entity()->setSubmitSettings(Core::App().settings().sendSubmitWay());
Ui::Emoji::SuggestionsController::Init(
_wrap->window(),
result->entity(),
@@ -561,7 +564,9 @@ object_ptr<Ui::RpWidget> Controller::createStickersEdit() {
tr::lng_group_stickers_add(tr::now),
st::editPeerInviteLinkButton)
)->addClickHandler([=] {
Ui::show(Box<StickersBox>(channel), Ui::LayerOption::KeepOther);
Ui::show(
Box<StickersBox>(_navigation->parentController(), channel),
Ui::LayerOption::KeepOther);
});
return result;
@@ -830,8 +835,6 @@ void Controller::fillHistoryVisibilityButton() {
void Controller::fillManageSection() {
Expects(_controls.buttonsLayout != nullptr);
const auto navigation = App::wnd()->sessionController();
const auto chat = _peer->asChat();
const auto channel = _peer->asChannel();
const auto isChannel = (!chat);
@@ -943,7 +946,7 @@ void Controller::fillManageSection() {
Info::Profile::RestrictionsCountValue
) | rpl::flatten_latest(
) | ToPositiveNumberStringRestrictions(),
[=] { ShowEditPermissions(_peer); },
[=] { ShowEditPermissions(_navigation, _peer); },
st::infoIconPermissions);
}
if (canViewAdmins) {
@@ -958,7 +961,7 @@ void Controller::fillManageSection() {
) | ToPositiveNumberString(),
[=] {
ParticipantsBoxController::Start(
navigation,
_navigation,
_peer,
ParticipantsBoxController::Role::Admins);
},
@@ -976,7 +979,7 @@ void Controller::fillManageSection() {
) | ToPositiveNumberString(),
[=] {
ParticipantsBoxController::Start(
navigation,
_navigation,
_peer,
ParticipantsBoxController::Role::Members);
},
@@ -990,7 +993,7 @@ void Controller::fillManageSection() {
| ToPositiveNumberString(),
[=] {
ParticipantsBoxController::Start(
navigation,
_navigation,
_peer,
ParticipantsBoxController::Role::Kicked);
},
@@ -1002,7 +1005,7 @@ void Controller::fillManageSection() {
tr::lng_manage_peer_recent_actions(),
rpl::single(QString()), //Empty count.
[=] {
navigation->showSection(AdminLog::SectionMemento(channel));
_navigation->showSection(AdminLog::SectionMemento(channel));
},
st::infoIconRecentActions);
}
@@ -1440,15 +1443,22 @@ void Controller::deleteChannel() {
const auto channel = _peer->asChannel();
const auto chat = channel->migrateFrom();
const auto session = &_peer->session();
Ui::hideLayer();
Ui::showChatsList();
Ui::showChatsList(session);
if (chat) {
chat->session().api().deleteConversation(chat, false);
session->api().deleteConversation(chat, false);
}
MTP::send(
MTPchannels_DeleteChannel(channel->inputChannel),
App::main()->rpcDone(&MainWidget::sentUpdatesReceived),
App::main()->rpcFail(&MainWidget::deleteChannelFailed));
session->api().request(MTPchannels_DeleteChannel(
channel->inputChannel
)).done([=](const MTPUpdates &result) {
session->api().applyUpdates(result);
//}).fail([=](const RPCError &error) {
// if (error.type() == qstr("CHANNEL_TOO_LARGE")) {
// Ui::show(Box<InformBox>(tr::lng_cant_delete_channel(tr::now)));
// }
}).send();
}
} // namespace

View File

@@ -307,8 +307,10 @@ ChatAdminRights FullAdminRights(bool isGroup) {
EditPeerPermissionsBox::EditPeerPermissionsBox(
QWidget*,
not_null<Window::SessionNavigation*> navigation,
not_null<PeerData*> peer)
: _peer(peer->migrateToOrMe()) {
: _navigation(navigation)
, _peer(peer->migrateToOrMe()) {
}
auto EditPeerPermissionsBox::saveEvents() const -> rpl::producer<Result> {
@@ -522,8 +524,6 @@ void EditPeerPermissionsBox::addBannedButtons(
}
}
const auto channel = _peer->asChannel();
const auto navigation = App::wnd()->sessionController();
container->add(EditPeerInfoBox::CreateButton(
container,
tr::lng_manage_peer_exceptions(),
@@ -532,7 +532,7 @@ void EditPeerPermissionsBox::addBannedButtons(
: rpl::single(0)) | ToPositiveNumberString(),
[=] {
ParticipantsBoxController::Start(
navigation,
_navigation,
_peer,
ParticipantsBoxController::Role::Restricted);
},
@@ -545,7 +545,7 @@ void EditPeerPermissionsBox::addBannedButtons(
| ToPositiveNumberString(),
[=] {
ParticipantsBoxController::Start(
navigation,
_navigation,
_peer,
ParticipantsBoxController::Role::Kicked);
},

View File

@@ -15,9 +15,16 @@ class RoundButton;
class VerticalLayout;
} // namespace Ui
namespace Window {
class SessionNavigation;
} // namespace Window
class EditPeerPermissionsBox : public Ui::BoxContent {
public:
EditPeerPermissionsBox(QWidget*, not_null<PeerData*> peer);
EditPeerPermissionsBox(
QWidget*,
not_null<Window::SessionNavigation*> navigation,
not_null<PeerData*> peer);
struct Result {
MTPDchatBannedRights::Flags rights;
@@ -34,7 +41,8 @@ private:
void addSlowmodeLabels(not_null<Ui::VerticalLayout*> container);
void addBannedButtons(not_null<Ui::VerticalLayout*> container);
not_null<PeerData*> _peer;
const not_null<Window::SessionNavigation*> _navigation;
const not_null<PeerData*> _peer;
Ui::RoundButton *_save = nullptr;
Fn<Result()> _value;

View File

@@ -19,11 +19,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_chat.h"
#include "data/data_peer.h"
#include "data/data_session.h"
#include "data/data_changes.h"
#include "info/profile/info_profile_values.h"
#include "lang/lang_keys.h"
#include "mainwindow.h"
#include "mtproto/sender.h"
#include "observer_peer.h"
#include "ui/rp_widget.h"
#include "ui/special_buttons.h"
#include "ui/toast/toast.h"
@@ -168,7 +168,7 @@ Controller::Controller(
std::optional<Privacy> privacySavedValue,
std::optional<QString> usernameSavedValue)
: _peer(peer)
, _api(_peer->session().api().instance())
, _api(&_peer->session().mtp())
, _privacySavedValue(privacySavedValue)
, _usernameSavedValue(usernameSavedValue)
, _useLocationPhrases(useLocationPhrases)
@@ -335,7 +335,7 @@ object_ptr<Ui::RpWidget> Controller::createUsernameEdit() {
st::setupChannelLink,
nullptr,
username,
true));
_peer->session().createInternalLink(QString())));
_controls.usernameInput->heightValue(
) | rpl::start_with_next([placeholder](int height) {
placeholder->resize(placeholder->width(), height);
@@ -485,12 +485,12 @@ void Controller::usernameChanged() {
_checkUsernameTimer.cancel();
return;
}
const auto bad = ranges::find_if(username, [](QChar ch) {
const auto bad = ranges::any_of(username, [](QChar ch) {
return (ch < 'A' || ch > 'Z')
&& (ch < 'a' || ch > 'z')
&& (ch < '0' || ch > '9')
&& (ch != '_');
}) != username.end();
});
if (bad) {
showUsernameError(tr::lng_create_channel_link_bad_symbols());
} else if (username.size() < kMinUsernameLength) {
@@ -574,9 +574,9 @@ void Controller::observeInviteLink() {
if (!_controls.editInviteLinkWrap) {
return;
}
Notify::PeerUpdateValue(
_peer->session().changes().peerFlagsValue(
_peer,
Notify::PeerUpdate::Flag::InviteLinkChanged
Data::PeerUpdate::Flag::InviteLink
) | rpl::start_with_next([=] {
refreshCreateInviteLink();
refreshEditInviteLink();

View File

@@ -14,6 +14,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/input_fields.h"
#include "mainwindow.h"
#include "main/main_session.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "apiwrap.h"
#include "styles/style_layers.h"
#include "styles/style_calls.h"
@@ -31,7 +33,7 @@ RateCallBox::RateCallBox(
uint64 callId,
uint64 callAccessHash)
: _session(session)
, _api(_session->api().instance())
, _api(&_session->mtp())
, _callId(callId)
, _callAccessHash(callAccessHash) {
}
@@ -85,7 +87,7 @@ void RateCallBox::ratingChanged(int value) {
Ui::InputField::Mode::MultiLine,
tr::lng_call_rate_comment());
_comment->show();
_comment->setSubmitSettings(_session->settings().sendSubmitWay());
_comment->setSubmitSettings(Core::App().settings().sendSubmitWay());
_comment->setMaxLength(kRateCallCommentLengthMax);
_comment->resize(width() - (st::callRatingPadding.left() + st::callRatingPadding.right()), _comment->height());

View File

@@ -15,8 +15,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h"
#include "ui/toast/toast.h"
#include "mtproto/facade.h"
#include "mainwindow.h"
#include "core/core_settings.h"
#include "core/application.h"
#include "styles/style_layers.h"
#include "styles/style_boxes.h"
#include "styles/style_profile.h"
@@ -28,11 +29,13 @@ constexpr auto kReportReasonLengthMax = 200;
} // namespace
ReportBox::ReportBox(QWidget*, not_null<PeerData*> peer)
: _peer(peer) {
: _peer(peer)
, _api(&_peer->session().mtp()) {
}
ReportBox::ReportBox(QWidget*, not_null<PeerData*> peer, MessageIdsList ids)
: _peer(peer)
, _api(&_peer->session().mtp())
, _ids(std::move(ids)) {
}
@@ -107,7 +110,7 @@ void ReportBox::reasonChanged(Reason reason) {
Ui::InputField::Mode::MultiLine,
tr::lng_report_reason_description());
_reasonOtherText->show();
_reasonOtherText->setSubmitSettings(_peer->session().settings().sendSubmitWay());
_reasonOtherText->setSubmitSettings(Core::App().settings().sendSubmitWay());
_reasonOtherText->setMaxLength(kReportReasonLengthMax);
_reasonOtherText->resize(width() - (st::boxPadding.left() + st::boxOptionListPadding.left() + st::boxPadding.right()), _reasonOtherText->height());
@@ -137,7 +140,9 @@ void ReportBox::reasonResized() {
}
void ReportBox::report() {
if (_requestId) return;
if (_requestId) {
return;
}
if (_reasonOtherText && _reasonOtherText->getLastText().trimmed().isEmpty()) {
_reasonOtherText->showError();
@@ -159,18 +164,24 @@ void ReportBox::report() {
for (const auto &fullId : *_ids) {
ids.push_back(MTP_int(fullId.msg));
}
_requestId = MTP::send(
MTPmessages_Report(
_peer->input,
MTP_vector<MTPint>(ids),
reason),
rpcDone(&ReportBox::reportDone),
rpcFail(&ReportBox::reportFail));
_requestId = _api.request(MTPmessages_Report(
_peer->input,
MTP_vector<MTPint>(ids),
reason
)).done([=](const MTPBool &result) {
reportDone(result);
}).fail([=](const RPCError &error) {
reportFail(error);
}).send();
} else {
_requestId = MTP::send(
MTPaccount_ReportPeer(_peer->input, reason),
rpcDone(&ReportBox::reportDone),
rpcFail(&ReportBox::reportFail));
_requestId = _api.request(MTPaccount_ReportPeer(
_peer->input,
reason
)).done([=](const MTPBool &result) {
reportDone(result);
}).fail([=](const RPCError &error) {
reportFail(error);
}).send();
}
}
@@ -180,16 +191,11 @@ void ReportBox::reportDone(const MTPBool &result) {
closeBox();
}
bool ReportBox::reportFail(const RPCError &error) {
if (MTP::isDefaultHandledError(error)) {
return false;
}
void ReportBox::reportFail(const RPCError &error) {
_requestId = 0;
if (_reasonOtherText) {
_reasonOtherText->showError();
}
return true;
}
void ReportBox::updateMaxHeight() {

View File

@@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "boxes/abstract_box.h"
#include "mtproto/mtproto_rpc_sender.h"
#include "mtproto/sender.h"
namespace Ui {
template <typename Enum>
@@ -18,7 +18,7 @@ class Radioenum;
class InputField;
} // namespace Ui
class ReportBox : public Ui::BoxContent, public RPCSender {
class ReportBox final : public Ui::BoxContent {
public:
ReportBox(QWidget*, not_null<PeerData*> peer);
ReportBox(QWidget*, not_null<PeerData*> peer, MessageIdsList ids);
@@ -43,9 +43,10 @@ private:
void report();
void reportDone(const MTPBool &result);
bool reportFail(const RPCError &error);
void reportFail(const RPCError &error);
not_null<PeerData*> _peer;
const not_null<PeerData*> _peer;
MTP::Sender _api;
std::optional<MessageIdsList> _ids;
std::shared_ptr<Ui::RadioenumGroup<Reason>> _reasonGroup;

View File

@@ -62,7 +62,6 @@ void SelfDestructionBox::showContent() {
_description->moveToLeft(st::boxPadding.left(), y);
y += _description->height() + st::boxMediumSkip;
const auto count = int(_ttlValues.size());
for (const auto value : _ttlValues) {
const auto button = Ui::CreateChild<Ui::Radiobutton>(
this,

View File

@@ -7,15 +7,19 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "boxes/send_files_box.h"
#include "platform/platform_specific.h"
#include "lang/lang_keys.h"
#include "storage/localstorage.h"
#include "storage/storage_media_prepare.h"
#include "mainwidget.h"
#include "main/main_session.h"
#include "mtproto/mtproto_config.h"
#include "chat_helpers/message_field.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"
@@ -34,8 +38,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "media/clip/media_clip_reader.h"
#include "api/api_common.h"
#include "window/window_session_controller.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "layout.h"
#include "facades.h"
#include "facades.h" // App::LambdaDelayed.
#include "app.h"
#include "styles/style_history.h"
#include "styles/style_layers.h"
@@ -57,10 +63,7 @@ enum class ButtonType {
};
inline bool CanAddUrls(const QList<QUrl> &urls) {
return !urls.isEmpty() && ranges::find_if(
urls,
[](const QUrl &url) { return !url.isLocalFile(); }
) == urls.end();
return !urls.isEmpty() && ranges::all_of(urls, &QUrl::isLocalFile);
}
inline bool IsFirstAlbumItem(const Storage::PreparedList &list) {
@@ -331,7 +334,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()) {
@@ -888,7 +891,6 @@ void SingleMediaPreview::prepareAnimatedPreview(
_gifPreview = Media::Clip::MakeReader(
animatedPreviewPath,
std::move(callback));
if (_gifPreview) _gifPreview->setAutoplay();
}
}
@@ -1832,11 +1834,7 @@ void SendFilesBox::setupShadows(
}
void SendFilesBox::prepare() {
_send = addButton(
(_sendType == Api::SendType::Normal
? tr::lng_send_button()
: tr::lng_schedule_button()),
[=] { send({}); });
_send = addButton(tr::lng_send_button(), [=] { send({}); });
if (_sendType == Api::SendType::Normal) {
SetupSendMenuAndShortcuts(
_send,
@@ -1854,14 +1852,47 @@ void SendFilesBox::prepare() {
}
}, lifetime());
const auto title = tr::lng_stickers_featured_add(tr::now) + qsl("...");
_addFileToAlbum = addLeftButton(
rpl::single(title),
tr::lng_stickers_featured_add(),
App::LambdaDelayed(st::historyAttach.ripple.hideDuration, this, [=] {
openDialogToAddFileToAlbum();
}));
updateLeftButtonVisibility();
setupDragArea();
}
void SendFilesBox::setupDragArea() {
// 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 == Storage::MimeDataState::Files)
// Temporary enable drag'n'drop only for images. TODO.
? Storage::MimeDataState::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() {
@@ -1879,6 +1910,7 @@ void SendFilesBox::refreshAllAfterAlbumChanges() {
preparePreview();
captionResized();
updateLeftButtonVisibility();
_albumChanged.fire({});
}
void SendFilesBox::openDialogToAddFileToAlbum() {
@@ -1915,7 +1947,7 @@ void SendFilesBox::initSendWay() {
? SendFilesWay::Album
: SendFilesWay::Photos;
}
const auto way = _controller->session().settings().sendFilesWay();
const auto way = Core::App().settings().sendFilesWay();
if (way == SendFilesWay::Files) {
return way;
} else if (way == SendFilesWay::Album) {
@@ -2046,8 +2078,10 @@ void SendFilesBox::applyAlbumOrder() {
}
void SendFilesBox::setupCaption() {
_caption->setMaxLength(Global::CaptionLengthMax());
_caption->setSubmitSettings(_controller->session().settings().sendSubmitWay());
_caption->setMaxLength(
_controller->session().serverConfig().captionLengthMax);
_caption->setSubmitSettings(
Core::App().settings().sendSubmitWay());
connect(_caption, &Ui::InputField::resized, [=] {
captionResized();
});
@@ -2071,16 +2105,16 @@ void SendFilesBox::setupCaption() {
});
_caption->setInstantReplaces(Ui::InstantReplaces::Default());
_caption->setInstantReplacesEnabled(
_controller->session().settings().replaceEmojiValue());
Core::App().settings().replaceEmojiValue());
_caption->setMarkdownReplacesEnabled(rpl::single(true));
_caption->setEditLinkCallback(
DefaultEditLinkCallback(&_controller->session(), _caption));
DefaultEditLinkCallback(_controller, _caption));
Ui::Emoji::SuggestionsController::Init(
getDelegate()->outerContainer(),
_caption,
&_controller->session());
InitSpellchecker(&_controller->session(), _caption);
InitSpellchecker(_controller, _caption);
updateCaptionPlaceholder();
setupEmojiPanel();
@@ -2174,7 +2208,10 @@ bool SendFilesBox::addFiles(not_null<const QMimeData*> data) {
if (result.error == Storage::PreparedList::Error::None) {
return result;
} else if (data->hasImage()) {
auto image = qvariant_cast<QImage>(data->imageData());
auto image = Platform::GetImageFromClipboard();
if (image.isNull()) {
image = qvariant_cast<QImage>(data->imageData());
}
if (!image.isNull()) {
return Storage::PrepareMediaFromImage(
std::move(image),
@@ -2341,7 +2378,7 @@ void SendFilesBox::send(
const auto way = _sendWay ? _sendWay->value() : Way::Files;
if (_compressConfirm == CompressConfirm::Auto) {
const auto oldWay = _controller->session().settings().sendFilesWay();
const auto oldWay = Core::App().settings().sendFilesWay();
if (way != oldWay) {
// Check if the user _could_ use the old value, but didn't.
if ((oldWay == Way::Album && _sendAlbum)
@@ -2349,8 +2386,8 @@ void SendFilesBox::send(
|| (oldWay == Way::Files && _sendFiles)
|| (way == Way::Files && (_sendAlbum || _sendPhotos))) {
// And in that case save it to settings.
_controller->session().settings().setSendFilesWay(way);
_controller->session().saveSettingsDelayed();
Core::App().settings().setSendFilesWay(way);
Core::App().saveSettingsDelayed();
}
}
}

Some files were not shown because too many files have changed in this diff Show More