From 6dedf7c63e4e1e738ea03a7d6b134fbbb2dfb015 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 10 May 2022 18:22:28 +0400 Subject: [PATCH] Update API scheme to layer 143. --- Telegram/Resources/tl/api.tl | 35 ++--- Telegram/SourceFiles/api/api_peer_photo.cpp | 2 +- Telegram/SourceFiles/api/api_ringtones.cpp | 6 +- Telegram/SourceFiles/api/api_ringtones.h | 2 +- .../SourceFiles/boxes/auto_download_box.cpp | 22 +-- .../SourceFiles/boxes/edit_caption_box.cpp | 13 +- Telegram/SourceFiles/boxes/send_files_box.cpp | 21 ++- .../calls/group/calls_group_call.cpp | 2 +- .../chat_helpers/emoji_sets_manager.cpp | 2 +- .../chat_helpers/spellchecker_common.cpp | 4 +- .../chat_helpers/spellchecker_common.h | 4 +- .../SourceFiles/data/data_auto_download.cpp | 36 ++--- .../SourceFiles/data/data_auto_download.h | 22 +-- Telegram/SourceFiles/data/data_document.cpp | 4 +- Telegram/SourceFiles/data/data_document.h | 7 +- .../data/data_download_manager.cpp | 2 +- .../SourceFiles/data/data_download_manager.h | 6 +- Telegram/SourceFiles/data/data_session.cpp | 8 +- Telegram/SourceFiles/data/data_session.h | 4 +- Telegram/SourceFiles/data/data_types.h | 8 +- Telegram/SourceFiles/editor/editor_paint.cpp | 4 +- .../export/data/export_data_types.h | 2 +- .../SourceFiles/export/export_api_wrap.cpp | 24 ++-- Telegram/SourceFiles/export/export_api_wrap.h | 12 +- .../SourceFiles/export/export_settings.cpp | 2 +- Telegram/SourceFiles/export/export_settings.h | 2 +- .../export/output/export_output_file.cpp | 2 +- .../export/output/export_output_file.h | 4 +- .../export/view/export_view_settings.cpp | 15 +- .../export/view/export_view_settings.h | 4 +- .../SourceFiles/history/history_widget.cpp | 12 +- .../view/history_view_replies_section.cpp | 9 +- .../view/history_view_scheduled_section.cpp | 9 +- .../view/media/history_view_document.cpp | 8 +- .../view/media/history_view_document.h | 6 +- .../history/view/media/history_view_file.cpp | 6 +- .../history/view/media/history_view_file.h | 10 +- .../history/view/media/history_view_gif.cpp | 4 +- .../history/view/media/history_view_gif.h | 2 +- .../inline_bot_layout_internal.cpp | 13 +- .../inline_bots/inline_bot_layout_internal.h | 14 +- .../streaming/media_streaming_loader.cpp | 14 +- .../media/streaming/media_streaming_loader.h | 24 ++-- .../media_streaming_loader_local.cpp | 12 +- .../streaming/media_streaming_loader_local.h | 8 +- .../media_streaming_loader_mtproto.cpp | 14 +- .../media_streaming_loader_mtproto.h | 16 +-- .../streaming/media_streaming_reader.cpp | 129 ++++++++++-------- .../media/streaming/media_streaming_reader.h | 60 ++++---- .../media/view/media_view_overlay_widget.cpp | 2 +- .../view/media_view_playback_controls.cpp | 2 +- .../media/view/media_view_playback_controls.h | 6 +- .../mtproto/dedicated_file_loader.cpp | 10 +- .../mtproto/dedicated_file_loader.h | 20 +-- .../SourceFiles/overview/overview_layout.cpp | 32 +++-- .../SourceFiles/overview/overview_layout.h | 27 ++-- .../SourceFiles/payments/payments_form.cpp | 2 +- .../storage/download_manager_mtproto.cpp | 18 +-- .../storage/download_manager_mtproto.h | 20 +-- .../SourceFiles/storage/file_download.cpp | 24 ++-- Telegram/SourceFiles/storage/file_download.h | 26 ++-- .../storage/file_download_mtproto.cpp | 20 +-- .../storage/file_download_mtproto.h | 20 +-- .../SourceFiles/storage/file_download_web.cpp | 2 +- .../SourceFiles/storage/file_download_web.h | 4 +- Telegram/SourceFiles/storage/file_upload.cpp | 21 +-- Telegram/SourceFiles/storage/file_upload.h | 6 +- .../SourceFiles/storage/localimageloader.cpp | 22 +-- .../SourceFiles/storage/localimageloader.h | 14 +- .../storage/serialize_document.cpp | 33 +++-- .../storage/storage_cloud_blob.cpp | 2 +- .../SourceFiles/storage/storage_cloud_blob.h | 6 +- .../storage/storage_media_prepare.cpp | 28 +++- .../storage/storage_media_prepare.h | 10 +- .../SourceFiles/support/support_helper.cpp | 6 +- .../ui/chat/attach/attach_prepare.h | 3 +- .../SourceFiles/ui/image/image_location.cpp | 2 +- .../ui/image/image_location_factory.cpp | 4 +- Telegram/SourceFiles/ui/text/format_values.h | 6 +- .../window/themes/window_theme.cpp | 2 +- .../window/themes/window_theme_editor_box.cpp | 2 +- 81 files changed, 595 insertions(+), 458 deletions(-) diff --git a/Telegram/Resources/tl/api.tl b/Telegram/Resources/tl/api.tl index 5da94956c6..d43041eb51 100644 --- a/Telegram/Resources/tl/api.tl +++ b/Telegram/Resources/tl/api.tl @@ -110,7 +110,7 @@ storage.fileMp4#b3cea0e4 = storage.FileType; storage.fileWebp#1081464c = storage.FileType; userEmpty#d3bc4b7a id:long = User; -user#3ff6ecb0 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User; +user#3ff6ecb0 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true attach_menu_enabled:flags.29?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User; userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; userProfilePhoto#82d1f706 flags:# has_video:flags.0?true photo_id:long stripped_thumb:flags.1?bytes dc_id:int = UserProfilePhoto; @@ -174,7 +174,7 @@ messageActionPinMessage#94bd38ed = MessageAction; messageActionHistoryClear#9fbab604 = MessageAction; messageActionGameScore#92a72876 game_id:long score:int = MessageAction; messageActionPaymentSentMe#8f31b327 flags:# currency:string total_amount:long payload:bytes info:flags.0?PaymentRequestedInfo shipping_option_id:flags.1?string charge:PaymentCharge = MessageAction; -messageActionPaymentSent#40699cd0 currency:string total_amount:long = MessageAction; +messageActionPaymentSent#96163f56 flags:# currency:string total_amount:long invoice_slug:flags.0?string = MessageAction; messageActionPhoneCall#80e11a7f flags:# video:flags.2?true call_id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = MessageAction; messageActionScreenshotTaken#4792929b = MessageAction; messageActionCustomAction#fae69f56 message:string = MessageAction; @@ -434,7 +434,7 @@ encryptedChatDiscarded#1e1c7c45 flags:# history_deleted:flags.0?true id:int = En inputEncryptedChat#f141b5e1 chat_id:int access_hash:long = InputEncryptedChat; encryptedFileEmpty#c21f497e = EncryptedFile; -encryptedFile#4a70994c id:long access_hash:long size:int dc_id:int key_fingerprint:int = EncryptedFile; +encryptedFile#a8008cd8 id:long access_hash:long size:long dc_id:int key_fingerprint:int = EncryptedFile; inputEncryptedFileEmpty#1837c364 = InputEncryptedFile; inputEncryptedFileUploaded#64bd0306 id:long parts:int md5_checksum:string key_fingerprint:int = InputEncryptedFile; @@ -454,7 +454,7 @@ inputDocumentEmpty#72f0eaae = InputDocument; inputDocument#1abfb575 id:long access_hash:long file_reference:bytes = InputDocument; documentEmpty#36f8c871 id:long = Document; -document#1e87342b flags:# id:long access_hash:long file_reference:bytes date:int mime_type:string size:int thumbs:flags.0?Vector video_thumbs:flags.1?Vector dc_id:int attributes:Vector = Document; +document#8fd4c4d8 flags:# id:long access_hash:long file_reference:bytes date:int mime_type:string size:long thumbs:flags.0?Vector video_thumbs:flags.1?Vector dc_id:int attributes:Vector = Document; help.support#17c6b5f6 phone_number:string user:User = help.Support; @@ -844,7 +844,7 @@ inputWebFileGeoPointLocation#9f2221c9 geo_point:InputGeoPoint access_hash:long w upload.webFile#21e753bc size:int mime_type:string file_type:storage.FileType mtime:int bytes:bytes = upload.WebFile; -payments.paymentForm#b0133b37 flags:# can_save_credentials:flags.2?true password_missing:flags.3?true test:flags.6?true form_id:long bot_id:long title:string description:string photo:flags.5?WebDocument invoice:Invoice provider_id:long url:string native_provider:flags.4?string native_params:flags.4?DataJSON saved_info:flags.0?PaymentRequestedInfo saved_credentials:flags.1?PaymentSavedCredentials users:Vector = payments.PaymentForm; +payments.paymentForm#b0133b37 flags:# can_save_credentials:flags.2?true password_missing:flags.3?true form_id:long bot_id:long title:string description:string photo:flags.5?WebDocument invoice:Invoice provider_id:long url:string native_provider:flags.4?string native_params:flags.4?DataJSON saved_info:flags.0?PaymentRequestedInfo saved_credentials:flags.1?PaymentSavedCredentials users:Vector = payments.PaymentForm; payments.validatedRequestedInfo#d1451883 flags:# id:flags.0?string shipping_options:flags.1?Vector = payments.ValidatedRequestedInfo; @@ -973,7 +973,7 @@ dialogPeerFolder#514519e2 folder_id:int = DialogPeer; messages.foundStickerSetsNotModified#d54b65d = messages.FoundStickerSets; messages.foundStickerSets#8af09dd2 hash:long sets:Vector = messages.FoundStickerSets; -fileHash#6242c773 offset:int limit:int hash:bytes = FileHash; +fileHash#f39b035c offset:long limit:int hash:bytes = FileHash; inputClientProxy#75588b3f address:string port:int = InputClientProxy; @@ -984,7 +984,7 @@ inputSecureFileUploaded#3334b0f0 id:long parts:int md5_checksum:string file_hash inputSecureFile#5367e5be id:long access_hash:long = InputSecureFile; secureFileEmpty#64199744 = SecureFile; -secureFile#e0277a62 id:long access_hash:long size:int dc_id:int date:int file_hash:bytes secret:bytes = SecureFile; +secureFile#7d09c27e id:long access_hash:long size:long dc_id:int date:int file_hash:bytes secret:bytes = SecureFile; secureData#8aeabec3 data:bytes data_hash:bytes secret:bytes = SecureData; @@ -1111,7 +1111,7 @@ codeSettings#8a6469c2 flags:# allow_flashcall:flags.0?true current_number:flags. wallPaperSettings#1dc1bca4 flags:# blur:flags.1?true motion:flags.2?true background_color:flags.0?int second_background_color:flags.4?int third_background_color:flags.5?int fourth_background_color:flags.6?int intensity:flags.3?int rotation:flags.4?int = WallPaperSettings; -autoDownloadSettings#e04232f3 flags:# disabled:flags.0?true video_preload_large:flags.1?true audio_preload_next:flags.2?true phonecalls_less_data:flags.3?true photo_size_max:int video_size_max:int file_size_max:int video_upload_maxbitrate:int = AutoDownloadSettings; +autoDownloadSettings#8efab953 flags:# disabled:flags.0?true video_preload_large:flags.1?true audio_preload_next:flags.2?true phonecalls_less_data:flags.3?true photo_size_max:int video_size_max:long file_size_max:long video_upload_maxbitrate:int = AutoDownloadSettings; account.autoDownloadSettings#63cacf26 low:AutoDownloadSettings medium:AutoDownloadSettings high:AutoDownloadSettings = account.AutoDownloadSettings; @@ -1381,6 +1381,8 @@ inputInvoiceSlug#c326caef slug:string = InputInvoice; payments.exportedInvoice#aed0cbd9 url:string = payments.ExportedInvoice; +messages.transcribedAudio#aa01cb2f text:string = messages.TranscribedAudio; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1451,7 +1453,7 @@ account.sendVerifyPhoneCode#a5a356f9 phone_number:string settings:CodeSettings = account.verifyPhone#4dd3a7f6 phone_number:string phone_code_hash:string phone_code:string = Bool; account.sendVerifyEmailCode#7011509f email:string = account.SentEmailCode; account.verifyEmail#ecba39db email:string code:string = Bool; -account.initTakeoutSession#f05b4804 flags:# contacts:flags.0?true message_users:flags.1?true message_chats:flags.2?true message_megagroups:flags.3?true message_channels:flags.4?true files:flags.5?true file_max_size:flags.5?int = account.Takeout; +account.initTakeoutSession#8ef3eab0 flags:# contacts:flags.0?true message_users:flags.1?true message_chats:flags.2?true message_megagroups:flags.3?true message_channels:flags.4?true files:flags.5?true file_max_size:flags.5?long = account.Takeout; account.finishTakeoutSession#1d2652ee flags:# success:flags.0?true = Bool; account.confirmPasswordEmail#8fdf1920 code:string = Bool; account.resendPasswordEmail#7a7f2a15 = Bool; @@ -1563,7 +1565,7 @@ messages.editChatAdmin#a85bd1c2 chat_id:long user_id:InputUser is_admin:Bool = B messages.migrateChat#a2875319 chat_id:long = Updates; messages.searchGlobal#4bc6589a flags:# folder_id:flags.0?int q:string filter:MessagesFilter min_date:int max_date:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; messages.reorderStickerSets#78337739 flags:# masks:flags.0?true order:Vector = Bool; -messages.getDocumentByHash#338e2464 sha256:bytes size:int mime_type:string = Document; +messages.getDocumentByHash#b1f2061f sha256:bytes size:long mime_type:string = Document; messages.getSavedGifs#5cf09635 hash:long = messages.SavedGifs; messages.saveGif#327a30cb id:InputDocument unsave:Bool = Bool; messages.getInlineBotResults#514e999d flags:# bot:InputUser peer:InputPeer geo_point:flags.0?InputGeoPoint query:string offset:string = messages.BotResults; @@ -1681,6 +1683,7 @@ messages.prolongWebView#ea5fbcce flags:# silent:flags.5?true peer:InputPeer bot: messages.requestSimpleWebView#6abb2f73 flags:# bot:InputUser url:string theme_params:flags.0?DataJSON = SimpleWebViewResult; messages.sendWebViewResultMessage#a4314f5 bot_query_id:string result:InputBotInlineResult = WebViewMessageSent; messages.sendWebViewData#dc0242c8 bot:InputUser random_id:long button_text:string data:string = Updates; +messages.transcribeAudio#269e9a49 peer:InputPeer msg_id:int = messages.TranscribedAudio; updates.getState#edd4882a = updates.State; updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference; @@ -1692,13 +1695,13 @@ photos.deletePhotos#87cf7f2f id:Vector = Vector; photos.getUserPhotos#91cd32a8 user_id:InputUser offset:int max_id:long limit:int = photos.Photos; upload.saveFilePart#b304a621 file_id:long file_part:int bytes:bytes = Bool; -upload.getFile#b15a9afc flags:# precise:flags.0?true cdn_supported:flags.1?true location:InputFileLocation offset:int limit:int = upload.File; +upload.getFile#be5335be flags:# precise:flags.0?true cdn_supported:flags.1?true location:InputFileLocation offset:long limit:int = upload.File; upload.saveBigFilePart#de7b673d file_id:long file_part:int file_total_parts:int bytes:bytes = Bool; upload.getWebFile#24e6818d location:InputWebFileLocation offset:int limit:int = upload.WebFile; -upload.getCdnFile#2000bcc3 file_token:bytes offset:int limit:int = upload.CdnFile; +upload.getCdnFile#395f69da file_token:bytes offset:long limit:int = upload.CdnFile; upload.reuploadCdnFile#9b2754a8 file_token:bytes request_token:bytes = Vector; -upload.getCdnFileHashes#4da54231 file_token:bytes offset:int = Vector; -upload.getFileHashes#c7025931 location:InputFileLocation offset:int = Vector; +upload.getCdnFileHashes#91dc3f31 file_token:bytes offset:long = Vector; +upload.getFileHashes#9156982a location:InputFileLocation offset:long = Vector; help.getConfig#c4f9186b = Config; help.getNearestDc#1fb33026 = NearestDc; @@ -1782,7 +1785,7 @@ payments.sendPaymentForm#2d03522f flags:# form_id:long invoice:InputInvoice requ payments.getSavedInfo#227d824b = payments.SavedInfo; payments.clearSavedInfo#d83d70c1 flags:# credentials:flags.0?true info:flags.1?true = Bool; payments.getBankCardData#2e79d779 number:string = payments.BankCardData; -payments.exportInvoice#fa7b08fd user_id:InputUser invoice_media:InputMedia = payments.ExportedInvoice; +payments.exportInvoice#f91b065 invoice_media:InputMedia = payments.ExportedInvoice; stickers.createStickerSet#9021ab67 flags:# masks:flags.0?true animated:flags.1?true videos:flags.4?true user_id:InputUser title:string short_name:string thumb:flags.2?InputDocument stickers:Vector software:flags.3?string = messages.StickerSet; stickers.removeStickerFromSet#f7760f51 sticker:InputDocument = messages.StickerSet; @@ -1839,4 +1842,4 @@ stats.getMegagroupStats#dcdf8607 flags:# dark:flags.0?true channel:InputChannel stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats; -// LAYER 142 +// LAYER 143 diff --git a/Telegram/SourceFiles/api/api_peer_photo.cpp b/Telegram/SourceFiles/api/api_peer_photo.cpp index 46b8cb980f..1ed2729fc8 100644 --- a/Telegram/SourceFiles/api/api_peer_photo.cpp +++ b/Telegram/SourceFiles/api/api_peer_photo.cpp @@ -75,7 +75,7 @@ SendMediaReady PreparePeerPhoto( MTP_int(dcId)); QString file, filename; - int32 filesize = 0; + int64 filesize = 0; QByteArray data; return SendMediaReady( diff --git a/Telegram/SourceFiles/api/api_ringtones.cpp b/Telegram/SourceFiles/api/api_ringtones.cpp index 0315de90d9..c7954a883b 100644 --- a/Telegram/SourceFiles/api/api_ringtones.cpp +++ b/Telegram/SourceFiles/api/api_ringtones.cpp @@ -41,7 +41,7 @@ SendMediaReady PrepareRingtoneDocument( MTP_bytes(), MTP_int(base::unixtime::now()), MTP_string(filemime), - MTP_int(content.size()), + MTP_long(content.size()), MTP_vector(), MTPVector(), MTP_int(dcId), @@ -191,8 +191,8 @@ void Ringtones::remove(DocumentId id) { } } -int Ringtones::maxSize() const { - return int(base::SafeRound(_session->account().appConfig().get( +int64 Ringtones::maxSize() const { + return int64(base::SafeRound(_session->account().appConfig().get( "ringtone_size_max", 100 * 1024))); } diff --git a/Telegram/SourceFiles/api/api_ringtones.h b/Telegram/SourceFiles/api/api_ringtones.h index 2707c92ad1..08918a89e1 100644 --- a/Telegram/SourceFiles/api/api_ringtones.h +++ b/Telegram/SourceFiles/api/api_ringtones.h @@ -38,7 +38,7 @@ public: [[nodiscard]] rpl::producer uploadFails() const; [[nodiscard]] rpl::producer uploadDones() const; - [[nodiscard]] int maxSize() const; + [[nodiscard]] int64 maxSize() const; [[nodiscard]] int maxSavedCount() const; [[nodiscard]] int maxDuration() const; diff --git a/Telegram/SourceFiles/boxes/auto_download_box.cpp b/Telegram/SourceFiles/boxes/auto_download_box.cpp index 5e8262a5a4..6f2cf6f3cf 100644 --- a/Telegram/SourceFiles/boxes/auto_download_box.cpp +++ b/Telegram/SourceFiles/boxes/auto_download_box.cpp @@ -31,12 +31,12 @@ constexpr auto kDefaultAutoPlayLimit = 50 * kMegabyte; using Type = Data::AutoDownload::Type; -not_null AddSizeLimitSlider( +not_null AddSizeLimitSlider( not_null container, - const base::flat_map &values, - int defaultValue) { + const base::flat_map &values, + int64 defaultValue) { using namespace Settings; - using Pair = base::flat_map::value_type; + using Pair = base::flat_map::value_type; const auto limits = Ui::CreateChild>( container.get()); @@ -44,13 +44,13 @@ not_null AddSizeLimitSlider( values, std::less<>(), [](Pair pair) { return pair.second; })->second; - const auto initialLimit = currentLimit ? currentLimit : defaultValue; - const auto result = Ui::CreateChild(container.get(), initialLimit); + const auto startLimit = currentLimit ? currentLimit : defaultValue; + const auto result = Ui::CreateChild(container.get(), startLimit); AddButtonWithLabel( container, tr::lng_media_size_limit(), limits->events_starting_with_copy( - initialLimit + startLimit ) | rpl::map([](int value) { return tr::lng_media_size_up_to( tr::now, @@ -92,7 +92,7 @@ void AutoDownloadBox::setupContent() { using namespace Settings; using namespace Data::AutoDownload; using Type = Data::AutoDownload::Type; - using Pair = base::flat_map::value_type; + using Pair = base::flat_map::value_type; setTitle(tr::lng_profile_settings_section()); @@ -105,7 +105,7 @@ void AutoDownloadBox::setupContent() { std::move(wrap))); const auto add = [&]( - not_null*> values, + not_null*> values, Type type, rpl::producer label) { const auto value = settings->bytesLimit(_source, type); @@ -124,7 +124,7 @@ void AutoDownloadBox::setupContent() { AddSubsectionTitle(content, tr::lng_media_auto_title()); - const auto downloadValues = Ui::CreateChild>( + const auto downloadValues = Ui::CreateChild>( content); add(downloadValues, Type::Photo, tr::lng_media_photo_title()); add(downloadValues, Type::File, tr::lng_media_file_title()); @@ -137,7 +137,7 @@ void AutoDownloadBox::setupContent() { AddSkip(content); AddSubsectionTitle(content, tr::lng_media_auto_play()); - const auto autoPlayValues = Ui::CreateChild>( + const auto autoPlayValues = Ui::CreateChild>( content); add( autoPlayValues, diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp index d78787bfcb..5eec242754 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp @@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_document.h" #include "data/data_photo_media.h" #include "data/data_session.h" +#include "data/data_user.h" #include "editor/photo_editor_layer_widget.h" #include "history/history_drag_area.h" #include "history/history_item.h" @@ -56,13 +57,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace { -auto ListFromMimeData(not_null data) { +auto ListFromMimeData(not_null data, bool premium) { using Error = Ui::PreparedList::Error; auto result = data->hasUrls() ? Storage::PrepareMediaList( // When we edit media, we need only 1 file. data->urls().mid(0, 1), - st::sendMediaPreviewSize) + st::sendMediaPreviewSize, + premium) : Ui::PreparedList(Error::EmptyFile, QString()); if (result.error == Error::None) { return result; @@ -343,11 +345,13 @@ void EditCaptionBox::setupEditEventHandler() { } return true; }; + const auto premium = _controller->session().user()->isPremium(); auto list = Storage::PreparedFileFromFilesDialog( std::move(result), checkResult, showError, - st::sendMediaPreviewSize); + st::sendMediaPreviewSize, + premium); if (list) { setPreparedList(std::move(*list)); @@ -520,7 +524,8 @@ void EditCaptionBox::updateEmojiPanelGeometry() { } bool EditCaptionBox::fileFromClipboard(not_null data) { - return setPreparedList(ListFromMimeData(data)); + const auto premium = _controller->session().user()->isPremium(); + return setPreparedList(ListFromMimeData(data, premium)); } bool EditCaptionBox::setPreparedList(Ui::PreparedList &&list) { diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 34853fa13a..0d44396fe6 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/controls/emoji_button.h" #include "lottie/lottie_single_player.h" #include "data/data_document.h" +#include "data/data_user.h" #include "media/clip/media_clip_reader.h" #include "api/api_common.h" #include "window/window_session_controller.h" @@ -68,7 +69,8 @@ inline bool CanAddUrls(const QList &urls) { void FileDialogCallback( FileDialog::OpenResult &&result, Fn checkResult, - Fn callback) { + Fn callback, + bool premium) { auto showError = [](tr::phrase<> text) { Ui::Toast::Show(text(tr::now)); }; @@ -77,7 +79,8 @@ void FileDialogCallback( std::move(result), checkResult, showError, - st::sendMediaPreviewSize); + st::sendMediaPreviewSize, + premium); if (!list) { return; @@ -397,10 +400,12 @@ void SendFilesBox::openDialogToAddFileToAlbum() { return true; }; const auto callback = [=](FileDialog::OpenResult &&result) { + const auto premium = _controller->session().user()->isPremium(); FileDialogCallback( std::move(result), checkResult, - [=](Ui::PreparedList list) { addFiles(std::move(list)); }); + [=](Ui::PreparedList list) { addFiles(std::move(list)); }, + premium); }; FileDialog::GetOpenPaths( @@ -566,10 +571,12 @@ void SendFilesBox::pushBlock(int from, int till) { return true; }; const auto callback = [=](FileDialog::OpenResult &&result) { + const auto premium = _controller->session().user()->isPremium(); FileDialogCallback( std::move(result), checkResult, - replace); + replace, + premium); }; FileDialog::GetOpenPath( @@ -763,10 +770,14 @@ bool SendFilesBox::canAddFiles(not_null data) const { } bool SendFilesBox::addFiles(not_null data) { + const auto premium = _controller->session().user()->isPremium(); auto list = [&] { const auto urls = data->hasUrls() ? data->urls() : QList(); auto result = CanAddUrls(urls) - ? Storage::PrepareMediaList(urls, st::sendMediaPreviewSize) + ? Storage::PrepareMediaList( + urls, + st::sendMediaPreviewSize, + premium) : Ui::PreparedList( Ui::PreparedList::Error::EmptyFile, QString()); diff --git a/Telegram/SourceFiles/calls/group/calls_group_call.cpp b/Telegram/SourceFiles/calls/group/calls_group_call.cpp index c1ee3c2348..a01f529f16 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_call.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_call.cpp @@ -2515,7 +2515,7 @@ void GroupCall::broadcastPartStart(std::shared_ptr task) { : (videoQuality == Quality::Medium) ? 1 : 0)), - MTP_int(0), + MTP_long(0), MTP_int(128 * 1024) )).done([=]( const MTPupload_File &result, diff --git a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp index 7aaa3800f1..a4ab881def 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp @@ -120,7 +120,7 @@ void SetGlobalLoader(base::unique_qptr loader) { GlobalLoaderValues.fire(GlobalLoader.get()); } -int GetDownloadSize(int id) { +int64 GetDownloadSize(int id) { return ranges::find(kSets, id, &Set::id)->size; } diff --git a/Telegram/SourceFiles/chat_helpers/spellchecker_common.cpp b/Telegram/SourceFiles/chat_helpers/spellchecker_common.cpp index dfc0e70a34..c6e1186c9f 100644 --- a/Telegram/SourceFiles/chat_helpers/spellchecker_common.cpp +++ b/Telegram/SourceFiles/chat_helpers/spellchecker_common.cpp @@ -200,7 +200,7 @@ DictLoader::DictLoader( int id, MTP::DedicatedLoader::Location location, const QString &folder, - int size, + int64 size, Fn destroyCallback) : BlobLoader(parent, session, id, location, folder, size) , _destroyCallback(std::move(destroyCallback)) { @@ -233,7 +233,7 @@ std::vector Dictionaries() { return kDictionaries | ranges::to_vector; } -int GetDownloadSize(int id) { +int64 GetDownloadSize(int id) { return ranges::find(kDictionaries, id, &Spellchecker::Dict::id)->size; } diff --git a/Telegram/SourceFiles/chat_helpers/spellchecker_common.h b/Telegram/SourceFiles/chat_helpers/spellchecker_common.h index 4d535c363e..f0e02879ae 100644 --- a/Telegram/SourceFiles/chat_helpers/spellchecker_common.h +++ b/Telegram/SourceFiles/chat_helpers/spellchecker_common.h @@ -21,7 +21,7 @@ namespace Spellchecker { struct Dict : public Storage::CloudBlob::Blob { }; -int GetDownloadSize(int id); +int64 GetDownloadSize(int id); MTP::DedicatedLoader::Location GetDownloadLocation(int id); [[nodiscard]] QString DictionariesPath(); @@ -48,7 +48,7 @@ public: int id, MTP::DedicatedLoader::Location location, const QString &folder, - int size, + int64 size, Fn destroyCallback); void destroy() override; diff --git a/Telegram/SourceFiles/data/data_auto_download.cpp b/Telegram/SourceFiles/data/data_auto_download.cpp index 15e164b93c..bbbcd84b83 100644 --- a/Telegram/SourceFiles/data/data_auto_download.cpp +++ b/Telegram/SourceFiles/data/data_auto_download.cpp @@ -17,8 +17,8 @@ namespace Data { namespace AutoDownload { namespace { -constexpr auto kDefaultMaxSize = 8 * 1024 * 1024; -constexpr auto kDefaultAutoPlaySize = 50 * 1024 * 1024; +constexpr auto kDefaultMaxSize = 8 * int64(1024 * 1024); +constexpr auto kDefaultAutoPlaySize = 50 * int64(1024 * 1024); constexpr auto kVersion1 = char(1); constexpr auto kVersion = char(2); @@ -82,26 +82,29 @@ Type AutoPlayTypeFromDocument(not_null document) { } // namespace -void Single::setBytesLimit(int bytesLimit) { +void Single::setBytesLimit(int64 bytesLimit) { Expects(bytesLimit >= 0 && bytesLimit <= kMaxBytesLimit); - _limit = bytesLimit; + _limit = int32(uint32(bytesLimit)); + + Ensures(hasValue()); } bool Single::hasValue() const { - return (_limit >= 0); + return (_limit != -1); } -bool Single::shouldDownload(int fileSize) const { +bool Single::shouldDownload(int64 fileSize) const { Expects(hasValue()); - return (_limit > 0) && (fileSize <= _limit); + const auto realLimit = bytesLimit(); + return (realLimit > 0) && (fileSize <= realLimit); } -int Single::bytesLimit() const { +int64 Single::bytesLimit() const { Expects(hasValue()); - return _limit; + return uint32(_limit); } qint32 Single::serialize() const { @@ -109,7 +112,8 @@ qint32 Single::serialize() const { } bool Single::setFromSerialized(qint32 serialized) { - if (serialized < -1 || serialized > kMaxBytesLimit) { + auto realLimit = quint32(serialized); + if (serialized != -1 && int64(realLimit) > kMaxBytesLimit) { return false; } _limit = serialized; @@ -127,7 +131,7 @@ Single &Set::single(Type type) { return const_cast(static_cast(this)->single(type)); } -void Set::setBytesLimit(Type type, int bytesLimit) { +void Set::setBytesLimit(Type type, int64 bytesLimit) { single(type).setBytesLimit(bytesLimit); } @@ -135,11 +139,11 @@ bool Set::hasValue(Type type) const { return single(type).hasValue(); } -bool Set::shouldDownload(Type type, int fileSize) const { +bool Set::shouldDownload(Type type, int64 fileSize) const { return single(type).shouldDownload(fileSize); } -int Set::bytesLimit(Type type) const { +int64 Set::bytesLimit(Type type) const { return single(type).bytesLimit(); } @@ -174,11 +178,11 @@ const Set &Full::setOrDefault(Source source, Type type) const { return result; } -void Full::setBytesLimit(Source source, Type type, int bytesLimit) { +void Full::setBytesLimit(Source source, Type type, int64 bytesLimit) { set(source).setBytesLimit(type, bytesLimit); } -bool Full::shouldDownload(Source source, Type type, int fileSize) const { +bool Full::shouldDownload(Source source, Type type, int64 fileSize) const { if (ranges::find(kStreamedTypes, type) != end(kStreamedTypes)) { // With streaming we disable autodownload and hide them in Settings. return false; @@ -186,7 +190,7 @@ bool Full::shouldDownload(Source source, Type type, int fileSize) const { return setOrDefault(source, type).shouldDownload(type, fileSize); } -int Full::bytesLimit(Source source, Type type) const { +int64 Full::bytesLimit(Source source, Type type) const { return setOrDefault(source, type).bytesLimit(type); } diff --git a/Telegram/SourceFiles/data/data_auto_download.h b/Telegram/SourceFiles/data/data_auto_download.h index 410451317f..a3275452fd 100644 --- a/Telegram/SourceFiles/data/data_auto_download.h +++ b/Telegram/SourceFiles/data/data_auto_download.h @@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Data { namespace AutoDownload { -constexpr auto kMaxBytesLimit = 4000 * 512 * 1024; +constexpr auto kMaxBytesLimit = 8000 * int64(512 * 1024); enum class Source { User = 0x00, @@ -47,27 +47,27 @@ constexpr auto kTypesCount = 7; class Single { public: - void setBytesLimit(int bytesLimit); + void setBytesLimit(int64 bytesLimit); bool hasValue() const; - bool shouldDownload(int fileSize) const; - int bytesLimit() const; + bool shouldDownload(int64 fileSize) const; + int64 bytesLimit() const; qint32 serialize() const; bool setFromSerialized(qint32 serialized); private: - int _limit = -1; + int _limit = -1; // FileSize: Right now any file size fits 32 bit. }; class Set { public: - void setBytesLimit(Type type, int bytesLimit); + void setBytesLimit(Type type, int64 bytesLimit); bool hasValue(Type type) const; - bool shouldDownload(Type type, int fileSize) const; - int bytesLimit(Type type) const; + bool shouldDownload(Type type, int64 fileSize) const; + int64 bytesLimit(Type type) const; qint32 serialize(Type type) const; bool setFromSerialized(Type type, qint32 serialized); @@ -82,13 +82,13 @@ private: class Full { public: - void setBytesLimit(Source source, Type type, int bytesLimit); + void setBytesLimit(Source source, Type type, int64 bytesLimit); [[nodiscard]] bool shouldDownload( Source source, Type type, - int fileSize) const; - [[nodiscard]] int bytesLimit(Source source, Type type) const; + int64 fileSize) const; + [[nodiscard]] int64 bytesLimit(Source source, Type type) const; [[nodiscard]] QByteArray serialize() const; bool setFromSerialized(const QByteArray &serialized); diff --git a/Telegram/SourceFiles/data/data_document.cpp b/Telegram/SourceFiles/data/data_document.cpp index faa5ce058a..80cce885cf 100644 --- a/Telegram/SourceFiles/data/data_document.cpp +++ b/Telegram/SourceFiles/data/data_document.cpp @@ -756,7 +756,7 @@ float64 DocumentData::progress() const { if (uploading()) { if (uploadingData->size > 0) { const auto result = float64(uploadingData->offset) - / uploadingData->size; + / float64(uploadingData->size); return std::clamp(result, 0., 1.); } return 0.; @@ -764,7 +764,7 @@ float64 DocumentData::progress() const { return loading() ? _loader->currentProgress() : 0.; } -int DocumentData::loadOffset() const { +int64 DocumentData::loadOffset() const { return loading() ? _loader->currentOffset() : 0; } diff --git a/Telegram/SourceFiles/data/data_document.h b/Telegram/SourceFiles/data/data_document.h index 23145b5693..41d83fae57 100644 --- a/Telegram/SourceFiles/data/data_document.h +++ b/Telegram/SourceFiles/data/data_document.h @@ -116,7 +116,7 @@ public: void cancel(); [[nodiscard]] bool cancelled() const; [[nodiscard]] float64 progress() const; - [[nodiscard]] int loadOffset() const; + [[nodiscard]] int64 loadOffset() const; [[nodiscard]] bool uploading() const; [[nodiscard]] bool loadedInMediaCache() const; void setLoadedInMediaCache(bool loaded); @@ -260,11 +260,10 @@ public: [[nodiscard]] bool inappPlaybackFailed() const; DocumentId id = 0; - DocumentType type = FileDocument; + int64 size = 0; QSize dimensions; int32 date = 0; - int32 size = 0; - + DocumentType type = FileDocument; FileStatus status = FileReady; std::unique_ptr uploadingData; diff --git a/Telegram/SourceFiles/data/data_download_manager.cpp b/Telegram/SourceFiles/data/data_download_manager.cpp index f33693b583..f344c4f2f7 100644 --- a/Telegram/SourceFiles/data/data_download_manager.cpp +++ b/Telegram/SourceFiles/data/data_download_manager.cpp @@ -295,7 +295,7 @@ void DownloadManager::addLoaded( .download = id, .started = started, .path = path, - .size = int32(size), + .size = size, .itemId = item->fullId(), .peerAccessHash = PeerAccessHash(item->history()->peer), .object = std::make_unique(object), diff --git a/Telegram/SourceFiles/data/data_download_manager.h b/Telegram/SourceFiles/data/data_download_manager.h index e20ac639b4..bb031c62e4 100644 --- a/Telegram/SourceFiles/data/data_download_manager.h +++ b/Telegram/SourceFiles/data/data_download_manager.h @@ -58,7 +58,7 @@ struct DownloadedId { DownloadId download; DownloadDate started = 0; QString path; - int32 size = 0; + int64 size = 0; FullMsgId itemId; uint64 peerAccessHash = 0; @@ -69,8 +69,8 @@ struct DownloadingId { DownloadObject object; DownloadDate started = 0; QString path; - int ready = 0; - int total = 0; + int64 ready = 0; + int64 total = 0; bool hiddenByView = false; bool done = false; }; diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index 281d1972ba..286dee0d9d 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -2731,7 +2731,7 @@ not_null Session::document( const ImageWithLocation &videoThumbnail, bool isPremiumSticker, int32 dc, - int32 size) { + int64 size) { const auto result = document(id); documentApplyFields( result, @@ -2814,7 +2814,7 @@ DocumentData *Session::documentFromWeb( ImageWithLocation{ .location = videoThumbnailLocation }, false, // isPremiumSticker session().mainDcId(), - int32(0)); // data.vsize().v + int64(0)); // data.vsize().v result->setWebLocation(WebFileLocation( data.vurl().v, data.vaccess_hash().v)); @@ -2837,7 +2837,7 @@ DocumentData *Session::documentFromWeb( ImageWithLocation{ .location = videoThumbnailLocation }, false, // isPremiumSticker session().mainDcId(), - int32(0)); // data.vsize().v + int64(0)); // data.vsize().v result->setContentUrl(qs(data.vurl())); return result; } @@ -2892,7 +2892,7 @@ void Session::documentApplyFields( const ImageWithLocation &videoThumbnail, bool isPremiumSticker, int32 dc, - int32 size) { + int64 size) { if (!date) { return; } diff --git a/Telegram/SourceFiles/data/data_session.h b/Telegram/SourceFiles/data/data_session.h index e61fc75a6b..04c392c6ab 100644 --- a/Telegram/SourceFiles/data/data_session.h +++ b/Telegram/SourceFiles/data/data_session.h @@ -509,7 +509,7 @@ public: const ImageWithLocation &videoThumbnail, bool isPremiumSticker, int32 dc, - int32 size); + int64 size); void documentConvert( not_null original, const MTPDocument &data); @@ -761,7 +761,7 @@ private: const ImageWithLocation &videoThumbnail, bool isPremiumSticker, int32 dc, - int32 size); + int64 size); DocumentData *documentFromWeb( const MTPDwebDocument &data, const ImageLocation &thumbnailLocation, diff --git a/Telegram/SourceFiles/data/data_types.h b/Telegram/SourceFiles/data/data_types.h index cfd8855cf4..6071a142b8 100644 --- a/Telegram/SourceFiles/data/data_types.h +++ b/Telegram/SourceFiles/data/data_types.h @@ -37,10 +37,10 @@ using Options = base::flags