mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Update API scheme to layer 143.
This commit is contained in:
parent
dd05fb4d14
commit
6dedf7c63e
81 changed files with 595 additions and 458 deletions
|
@ -110,7 +110,7 @@ storage.fileMp4#b3cea0e4 = storage.FileType;
|
||||||
storage.fileWebp#1081464c = storage.FileType;
|
storage.fileWebp#1081464c = storage.FileType;
|
||||||
|
|
||||||
userEmpty#d3bc4b7a id:long = User;
|
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<RestrictionReason> 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<RestrictionReason> bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User;
|
||||||
|
|
||||||
userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto;
|
userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto;
|
||||||
userProfilePhoto#82d1f706 flags:# has_video:flags.0?true photo_id:long stripped_thumb:flags.1?bytes dc_id:int = 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;
|
messageActionHistoryClear#9fbab604 = MessageAction;
|
||||||
messageActionGameScore#92a72876 game_id:long score:int = 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;
|
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;
|
messageActionPhoneCall#80e11a7f flags:# video:flags.2?true call_id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = MessageAction;
|
||||||
messageActionScreenshotTaken#4792929b = MessageAction;
|
messageActionScreenshotTaken#4792929b = MessageAction;
|
||||||
messageActionCustomAction#fae69f56 message:string = 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;
|
inputEncryptedChat#f141b5e1 chat_id:int access_hash:long = InputEncryptedChat;
|
||||||
|
|
||||||
encryptedFileEmpty#c21f497e = EncryptedFile;
|
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;
|
inputEncryptedFileEmpty#1837c364 = InputEncryptedFile;
|
||||||
inputEncryptedFileUploaded#64bd0306 id:long parts:int md5_checksum:string key_fingerprint:int = 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;
|
inputDocument#1abfb575 id:long access_hash:long file_reference:bytes = InputDocument;
|
||||||
|
|
||||||
documentEmpty#36f8c871 id:long = Document;
|
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<PhotoSize> video_thumbs:flags.1?Vector<VideoSize> dc_id:int attributes:Vector<DocumentAttribute> = Document;
|
document#8fd4c4d8 flags:# id:long access_hash:long file_reference:bytes date:int mime_type:string size:long 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;
|
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;
|
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<User> = 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<User> = payments.PaymentForm;
|
||||||
|
|
||||||
payments.validatedRequestedInfo#d1451883 flags:# id:flags.0?string shipping_options:flags.1?Vector<ShippingOption> = payments.ValidatedRequestedInfo;
|
payments.validatedRequestedInfo#d1451883 flags:# id:flags.0?string shipping_options:flags.1?Vector<ShippingOption> = payments.ValidatedRequestedInfo;
|
||||||
|
|
||||||
|
@ -973,7 +973,7 @@ dialogPeerFolder#514519e2 folder_id:int = DialogPeer;
|
||||||
messages.foundStickerSetsNotModified#d54b65d = messages.FoundStickerSets;
|
messages.foundStickerSetsNotModified#d54b65d = messages.FoundStickerSets;
|
||||||
messages.foundStickerSets#8af09dd2 hash:long sets:Vector<StickerSetCovered> = messages.FoundStickerSets;
|
messages.foundStickerSets#8af09dd2 hash:long sets:Vector<StickerSetCovered> = 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;
|
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;
|
inputSecureFile#5367e5be id:long access_hash:long = InputSecureFile;
|
||||||
|
|
||||||
secureFileEmpty#64199744 = SecureFile;
|
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;
|
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;
|
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;
|
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;
|
payments.exportedInvoice#aed0cbd9 url:string = payments.ExportedInvoice;
|
||||||
|
|
||||||
|
messages.transcribedAudio#aa01cb2f text:string = messages.TranscribedAudio;
|
||||||
|
|
||||||
---functions---
|
---functions---
|
||||||
|
|
||||||
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
|
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.verifyPhone#4dd3a7f6 phone_number:string phone_code_hash:string phone_code:string = Bool;
|
||||||
account.sendVerifyEmailCode#7011509f email:string = account.SentEmailCode;
|
account.sendVerifyEmailCode#7011509f email:string = account.SentEmailCode;
|
||||||
account.verifyEmail#ecba39db email:string code:string = Bool;
|
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.finishTakeoutSession#1d2652ee flags:# success:flags.0?true = Bool;
|
||||||
account.confirmPasswordEmail#8fdf1920 code:string = Bool;
|
account.confirmPasswordEmail#8fdf1920 code:string = Bool;
|
||||||
account.resendPasswordEmail#7a7f2a15 = 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.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.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<long> = Bool;
|
messages.reorderStickerSets#78337739 flags:# masks:flags.0?true order:Vector<long> = 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.getSavedGifs#5cf09635 hash:long = messages.SavedGifs;
|
||||||
messages.saveGif#327a30cb id:InputDocument unsave:Bool = Bool;
|
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;
|
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.requestSimpleWebView#6abb2f73 flags:# bot:InputUser url:string theme_params:flags.0?DataJSON = SimpleWebViewResult;
|
||||||
messages.sendWebViewResultMessage#a4314f5 bot_query_id:string result:InputBotInlineResult = WebViewMessageSent;
|
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.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.getState#edd4882a = updates.State;
|
||||||
updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference;
|
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<InputPhoto> = Vector<long>;
|
||||||
photos.getUserPhotos#91cd32a8 user_id:InputUser offset:int max_id:long limit:int = photos.Photos;
|
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.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.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.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<FileHash>;
|
upload.reuploadCdnFile#9b2754a8 file_token:bytes request_token:bytes = Vector<FileHash>;
|
||||||
upload.getCdnFileHashes#4da54231 file_token:bytes offset:int = Vector<FileHash>;
|
upload.getCdnFileHashes#91dc3f31 file_token:bytes offset:long = Vector<FileHash>;
|
||||||
upload.getFileHashes#c7025931 location:InputFileLocation offset:int = Vector<FileHash>;
|
upload.getFileHashes#9156982a location:InputFileLocation offset:long = Vector<FileHash>;
|
||||||
|
|
||||||
help.getConfig#c4f9186b = Config;
|
help.getConfig#c4f9186b = Config;
|
||||||
help.getNearestDc#1fb33026 = NearestDc;
|
help.getNearestDc#1fb33026 = NearestDc;
|
||||||
|
@ -1782,7 +1785,7 @@ payments.sendPaymentForm#2d03522f flags:# form_id:long invoice:InputInvoice requ
|
||||||
payments.getSavedInfo#227d824b = payments.SavedInfo;
|
payments.getSavedInfo#227d824b = payments.SavedInfo;
|
||||||
payments.clearSavedInfo#d83d70c1 flags:# credentials:flags.0?true info:flags.1?true = Bool;
|
payments.clearSavedInfo#d83d70c1 flags:# credentials:flags.0?true info:flags.1?true = Bool;
|
||||||
payments.getBankCardData#2e79d779 number:string = payments.BankCardData;
|
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<InputStickerSetItem> software:flags.3?string = messages.StickerSet;
|
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<InputStickerSetItem> software:flags.3?string = messages.StickerSet;
|
||||||
stickers.removeStickerFromSet#f7760f51 sticker:InputDocument = 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.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;
|
stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats;
|
||||||
|
|
||||||
// LAYER 142
|
// LAYER 143
|
||||||
|
|
|
@ -75,7 +75,7 @@ SendMediaReady PreparePeerPhoto(
|
||||||
MTP_int(dcId));
|
MTP_int(dcId));
|
||||||
|
|
||||||
QString file, filename;
|
QString file, filename;
|
||||||
int32 filesize = 0;
|
int64 filesize = 0;
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
|
|
||||||
return SendMediaReady(
|
return SendMediaReady(
|
||||||
|
|
|
@ -41,7 +41,7 @@ SendMediaReady PrepareRingtoneDocument(
|
||||||
MTP_bytes(),
|
MTP_bytes(),
|
||||||
MTP_int(base::unixtime::now()),
|
MTP_int(base::unixtime::now()),
|
||||||
MTP_string(filemime),
|
MTP_string(filemime),
|
||||||
MTP_int(content.size()),
|
MTP_long(content.size()),
|
||||||
MTP_vector<MTPPhotoSize>(),
|
MTP_vector<MTPPhotoSize>(),
|
||||||
MTPVector<MTPVideoSize>(),
|
MTPVector<MTPVideoSize>(),
|
||||||
MTP_int(dcId),
|
MTP_int(dcId),
|
||||||
|
@ -191,8 +191,8 @@ void Ringtones::remove(DocumentId id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Ringtones::maxSize() const {
|
int64 Ringtones::maxSize() const {
|
||||||
return int(base::SafeRound(_session->account().appConfig().get<double>(
|
return int64(base::SafeRound(_session->account().appConfig().get<double>(
|
||||||
"ringtone_size_max",
|
"ringtone_size_max",
|
||||||
100 * 1024)));
|
100 * 1024)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
[[nodiscard]] rpl::producer<QString> uploadFails() const;
|
[[nodiscard]] rpl::producer<QString> uploadFails() const;
|
||||||
[[nodiscard]] rpl::producer<DocumentId> uploadDones() const;
|
[[nodiscard]] rpl::producer<DocumentId> uploadDones() const;
|
||||||
|
|
||||||
[[nodiscard]] int maxSize() const;
|
[[nodiscard]] int64 maxSize() const;
|
||||||
[[nodiscard]] int maxSavedCount() const;
|
[[nodiscard]] int maxSavedCount() const;
|
||||||
[[nodiscard]] int maxDuration() const;
|
[[nodiscard]] int maxDuration() const;
|
||||||
|
|
||||||
|
|
|
@ -31,12 +31,12 @@ constexpr auto kDefaultAutoPlayLimit = 50 * kMegabyte;
|
||||||
|
|
||||||
using Type = Data::AutoDownload::Type;
|
using Type = Data::AutoDownload::Type;
|
||||||
|
|
||||||
not_null<int*> AddSizeLimitSlider(
|
not_null<int64*> AddSizeLimitSlider(
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
const base::flat_map<Type, int> &values,
|
const base::flat_map<Type, int64> &values,
|
||||||
int defaultValue) {
|
int64 defaultValue) {
|
||||||
using namespace Settings;
|
using namespace Settings;
|
||||||
using Pair = base::flat_map<Type, int>::value_type;
|
using Pair = base::flat_map<Type, int64>::value_type;
|
||||||
|
|
||||||
const auto limits = Ui::CreateChild<rpl::event_stream<int>>(
|
const auto limits = Ui::CreateChild<rpl::event_stream<int>>(
|
||||||
container.get());
|
container.get());
|
||||||
|
@ -44,13 +44,13 @@ not_null<int*> AddSizeLimitSlider(
|
||||||
values,
|
values,
|
||||||
std::less<>(),
|
std::less<>(),
|
||||||
[](Pair pair) { return pair.second; })->second;
|
[](Pair pair) { return pair.second; })->second;
|
||||||
const auto initialLimit = currentLimit ? currentLimit : defaultValue;
|
const auto startLimit = currentLimit ? currentLimit : defaultValue;
|
||||||
const auto result = Ui::CreateChild<int>(container.get(), initialLimit);
|
const auto result = Ui::CreateChild<int64>(container.get(), startLimit);
|
||||||
AddButtonWithLabel(
|
AddButtonWithLabel(
|
||||||
container,
|
container,
|
||||||
tr::lng_media_size_limit(),
|
tr::lng_media_size_limit(),
|
||||||
limits->events_starting_with_copy(
|
limits->events_starting_with_copy(
|
||||||
initialLimit
|
startLimit
|
||||||
) | rpl::map([](int value) {
|
) | rpl::map([](int value) {
|
||||||
return tr::lng_media_size_up_to(
|
return tr::lng_media_size_up_to(
|
||||||
tr::now,
|
tr::now,
|
||||||
|
@ -92,7 +92,7 @@ void AutoDownloadBox::setupContent() {
|
||||||
using namespace Settings;
|
using namespace Settings;
|
||||||
using namespace Data::AutoDownload;
|
using namespace Data::AutoDownload;
|
||||||
using Type = Data::AutoDownload::Type;
|
using Type = Data::AutoDownload::Type;
|
||||||
using Pair = base::flat_map<Type, int>::value_type;
|
using Pair = base::flat_map<Type, int64>::value_type;
|
||||||
|
|
||||||
setTitle(tr::lng_profile_settings_section());
|
setTitle(tr::lng_profile_settings_section());
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ void AutoDownloadBox::setupContent() {
|
||||||
std::move(wrap)));
|
std::move(wrap)));
|
||||||
|
|
||||||
const auto add = [&](
|
const auto add = [&](
|
||||||
not_null<base::flat_map<Type, int>*> values,
|
not_null<base::flat_map<Type, int64>*> values,
|
||||||
Type type,
|
Type type,
|
||||||
rpl::producer<QString> label) {
|
rpl::producer<QString> label) {
|
||||||
const auto value = settings->bytesLimit(_source, type);
|
const auto value = settings->bytesLimit(_source, type);
|
||||||
|
@ -124,7 +124,7 @@ void AutoDownloadBox::setupContent() {
|
||||||
|
|
||||||
AddSubsectionTitle(content, tr::lng_media_auto_title());
|
AddSubsectionTitle(content, tr::lng_media_auto_title());
|
||||||
|
|
||||||
const auto downloadValues = Ui::CreateChild<base::flat_map<Type, int>>(
|
const auto downloadValues = Ui::CreateChild<base::flat_map<Type, int64>>(
|
||||||
content);
|
content);
|
||||||
add(downloadValues, Type::Photo, tr::lng_media_photo_title());
|
add(downloadValues, Type::Photo, tr::lng_media_photo_title());
|
||||||
add(downloadValues, Type::File, tr::lng_media_file_title());
|
add(downloadValues, Type::File, tr::lng_media_file_title());
|
||||||
|
@ -137,7 +137,7 @@ void AutoDownloadBox::setupContent() {
|
||||||
AddSkip(content);
|
AddSkip(content);
|
||||||
AddSubsectionTitle(content, tr::lng_media_auto_play());
|
AddSubsectionTitle(content, tr::lng_media_auto_play());
|
||||||
|
|
||||||
const auto autoPlayValues = Ui::CreateChild<base::flat_map<Type, int>>(
|
const auto autoPlayValues = Ui::CreateChild<base::flat_map<Type, int64>>(
|
||||||
content);
|
content);
|
||||||
add(
|
add(
|
||||||
autoPlayValues,
|
autoPlayValues,
|
||||||
|
|
|
@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "data/data_photo_media.h"
|
#include "data/data_photo_media.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_user.h"
|
||||||
#include "editor/photo_editor_layer_widget.h"
|
#include "editor/photo_editor_layer_widget.h"
|
||||||
#include "history/history_drag_area.h"
|
#include "history/history_drag_area.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
|
@ -56,13 +57,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
auto ListFromMimeData(not_null<const QMimeData*> data) {
|
auto ListFromMimeData(not_null<const QMimeData*> data, bool premium) {
|
||||||
using Error = Ui::PreparedList::Error;
|
using Error = Ui::PreparedList::Error;
|
||||||
auto result = data->hasUrls()
|
auto result = data->hasUrls()
|
||||||
? Storage::PrepareMediaList(
|
? Storage::PrepareMediaList(
|
||||||
// When we edit media, we need only 1 file.
|
// When we edit media, we need only 1 file.
|
||||||
data->urls().mid(0, 1),
|
data->urls().mid(0, 1),
|
||||||
st::sendMediaPreviewSize)
|
st::sendMediaPreviewSize,
|
||||||
|
premium)
|
||||||
: Ui::PreparedList(Error::EmptyFile, QString());
|
: Ui::PreparedList(Error::EmptyFile, QString());
|
||||||
if (result.error == Error::None) {
|
if (result.error == Error::None) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -343,11 +345,13 @@ void EditCaptionBox::setupEditEventHandler() {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
const auto premium = _controller->session().user()->isPremium();
|
||||||
auto list = Storage::PreparedFileFromFilesDialog(
|
auto list = Storage::PreparedFileFromFilesDialog(
|
||||||
std::move(result),
|
std::move(result),
|
||||||
checkResult,
|
checkResult,
|
||||||
showError,
|
showError,
|
||||||
st::sendMediaPreviewSize);
|
st::sendMediaPreviewSize,
|
||||||
|
premium);
|
||||||
|
|
||||||
if (list) {
|
if (list) {
|
||||||
setPreparedList(std::move(*list));
|
setPreparedList(std::move(*list));
|
||||||
|
@ -520,7 +524,8 @@ void EditCaptionBox::updateEmojiPanelGeometry() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditCaptionBox::fileFromClipboard(not_null<const QMimeData*> data) {
|
bool EditCaptionBox::fileFromClipboard(not_null<const QMimeData*> data) {
|
||||||
return setPreparedList(ListFromMimeData(data));
|
const auto premium = _controller->session().user()->isPremium();
|
||||||
|
return setPreparedList(ListFromMimeData(data, premium));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditCaptionBox::setPreparedList(Ui::PreparedList &&list) {
|
bool EditCaptionBox::setPreparedList(Ui::PreparedList &&list) {
|
||||||
|
|
|
@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/controls/emoji_button.h"
|
#include "ui/controls/emoji_button.h"
|
||||||
#include "lottie/lottie_single_player.h"
|
#include "lottie/lottie_single_player.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
|
#include "data/data_user.h"
|
||||||
#include "media/clip/media_clip_reader.h"
|
#include "media/clip/media_clip_reader.h"
|
||||||
#include "api/api_common.h"
|
#include "api/api_common.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
@ -68,7 +69,8 @@ inline bool CanAddUrls(const QList<QUrl> &urls) {
|
||||||
void FileDialogCallback(
|
void FileDialogCallback(
|
||||||
FileDialog::OpenResult &&result,
|
FileDialog::OpenResult &&result,
|
||||||
Fn<bool(const Ui::PreparedList&)> checkResult,
|
Fn<bool(const Ui::PreparedList&)> checkResult,
|
||||||
Fn<void(Ui::PreparedList)> callback) {
|
Fn<void(Ui::PreparedList)> callback,
|
||||||
|
bool premium) {
|
||||||
auto showError = [](tr::phrase<> text) {
|
auto showError = [](tr::phrase<> text) {
|
||||||
Ui::Toast::Show(text(tr::now));
|
Ui::Toast::Show(text(tr::now));
|
||||||
};
|
};
|
||||||
|
@ -77,7 +79,8 @@ void FileDialogCallback(
|
||||||
std::move(result),
|
std::move(result),
|
||||||
checkResult,
|
checkResult,
|
||||||
showError,
|
showError,
|
||||||
st::sendMediaPreviewSize);
|
st::sendMediaPreviewSize,
|
||||||
|
premium);
|
||||||
|
|
||||||
if (!list) {
|
if (!list) {
|
||||||
return;
|
return;
|
||||||
|
@ -397,10 +400,12 @@ void SendFilesBox::openDialogToAddFileToAlbum() {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
const auto callback = [=](FileDialog::OpenResult &&result) {
|
const auto callback = [=](FileDialog::OpenResult &&result) {
|
||||||
|
const auto premium = _controller->session().user()->isPremium();
|
||||||
FileDialogCallback(
|
FileDialogCallback(
|
||||||
std::move(result),
|
std::move(result),
|
||||||
checkResult,
|
checkResult,
|
||||||
[=](Ui::PreparedList list) { addFiles(std::move(list)); });
|
[=](Ui::PreparedList list) { addFiles(std::move(list)); },
|
||||||
|
premium);
|
||||||
};
|
};
|
||||||
|
|
||||||
FileDialog::GetOpenPaths(
|
FileDialog::GetOpenPaths(
|
||||||
|
@ -566,10 +571,12 @@ void SendFilesBox::pushBlock(int from, int till) {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
const auto callback = [=](FileDialog::OpenResult &&result) {
|
const auto callback = [=](FileDialog::OpenResult &&result) {
|
||||||
|
const auto premium = _controller->session().user()->isPremium();
|
||||||
FileDialogCallback(
|
FileDialogCallback(
|
||||||
std::move(result),
|
std::move(result),
|
||||||
checkResult,
|
checkResult,
|
||||||
replace);
|
replace,
|
||||||
|
premium);
|
||||||
};
|
};
|
||||||
|
|
||||||
FileDialog::GetOpenPath(
|
FileDialog::GetOpenPath(
|
||||||
|
@ -763,10 +770,14 @@ bool SendFilesBox::canAddFiles(not_null<const QMimeData*> data) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SendFilesBox::addFiles(not_null<const QMimeData*> data) {
|
bool SendFilesBox::addFiles(not_null<const QMimeData*> data) {
|
||||||
|
const auto premium = _controller->session().user()->isPremium();
|
||||||
auto list = [&] {
|
auto list = [&] {
|
||||||
const auto urls = data->hasUrls() ? data->urls() : QList<QUrl>();
|
const auto urls = data->hasUrls() ? data->urls() : QList<QUrl>();
|
||||||
auto result = CanAddUrls(urls)
|
auto result = CanAddUrls(urls)
|
||||||
? Storage::PrepareMediaList(urls, st::sendMediaPreviewSize)
|
? Storage::PrepareMediaList(
|
||||||
|
urls,
|
||||||
|
st::sendMediaPreviewSize,
|
||||||
|
premium)
|
||||||
: Ui::PreparedList(
|
: Ui::PreparedList(
|
||||||
Ui::PreparedList::Error::EmptyFile,
|
Ui::PreparedList::Error::EmptyFile,
|
||||||
QString());
|
QString());
|
||||||
|
|
|
@ -2515,7 +2515,7 @@ void GroupCall::broadcastPartStart(std::shared_ptr<LoadPartTask> task) {
|
||||||
: (videoQuality == Quality::Medium)
|
: (videoQuality == Quality::Medium)
|
||||||
? 1
|
? 1
|
||||||
: 0)),
|
: 0)),
|
||||||
MTP_int(0),
|
MTP_long(0),
|
||||||
MTP_int(128 * 1024)
|
MTP_int(128 * 1024)
|
||||||
)).done([=](
|
)).done([=](
|
||||||
const MTPupload_File &result,
|
const MTPupload_File &result,
|
||||||
|
|
|
@ -120,7 +120,7 @@ void SetGlobalLoader(base::unique_qptr<Loader> loader) {
|
||||||
GlobalLoaderValues.fire(GlobalLoader.get());
|
GlobalLoaderValues.fire(GlobalLoader.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetDownloadSize(int id) {
|
int64 GetDownloadSize(int id) {
|
||||||
return ranges::find(kSets, id, &Set::id)->size;
|
return ranges::find(kSets, id, &Set::id)->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ DictLoader::DictLoader(
|
||||||
int id,
|
int id,
|
||||||
MTP::DedicatedLoader::Location location,
|
MTP::DedicatedLoader::Location location,
|
||||||
const QString &folder,
|
const QString &folder,
|
||||||
int size,
|
int64 size,
|
||||||
Fn<void()> destroyCallback)
|
Fn<void()> destroyCallback)
|
||||||
: BlobLoader(parent, session, id, location, folder, size)
|
: BlobLoader(parent, session, id, location, folder, size)
|
||||||
, _destroyCallback(std::move(destroyCallback)) {
|
, _destroyCallback(std::move(destroyCallback)) {
|
||||||
|
@ -233,7 +233,7 @@ std::vector<Dict> Dictionaries() {
|
||||||
return kDictionaries | ranges::to_vector;
|
return kDictionaries | ranges::to_vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetDownloadSize(int id) {
|
int64 GetDownloadSize(int id) {
|
||||||
return ranges::find(kDictionaries, id, &Spellchecker::Dict::id)->size;
|
return ranges::find(kDictionaries, id, &Spellchecker::Dict::id)->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace Spellchecker {
|
||||||
struct Dict : public Storage::CloudBlob::Blob {
|
struct Dict : public Storage::CloudBlob::Blob {
|
||||||
};
|
};
|
||||||
|
|
||||||
int GetDownloadSize(int id);
|
int64 GetDownloadSize(int id);
|
||||||
MTP::DedicatedLoader::Location GetDownloadLocation(int id);
|
MTP::DedicatedLoader::Location GetDownloadLocation(int id);
|
||||||
|
|
||||||
[[nodiscard]] QString DictionariesPath();
|
[[nodiscard]] QString DictionariesPath();
|
||||||
|
@ -48,7 +48,7 @@ public:
|
||||||
int id,
|
int id,
|
||||||
MTP::DedicatedLoader::Location location,
|
MTP::DedicatedLoader::Location location,
|
||||||
const QString &folder,
|
const QString &folder,
|
||||||
int size,
|
int64 size,
|
||||||
Fn<void()> destroyCallback);
|
Fn<void()> destroyCallback);
|
||||||
|
|
||||||
void destroy() override;
|
void destroy() override;
|
||||||
|
|
|
@ -17,8 +17,8 @@ namespace Data {
|
||||||
namespace AutoDownload {
|
namespace AutoDownload {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kDefaultMaxSize = 8 * 1024 * 1024;
|
constexpr auto kDefaultMaxSize = 8 * int64(1024 * 1024);
|
||||||
constexpr auto kDefaultAutoPlaySize = 50 * 1024 * 1024;
|
constexpr auto kDefaultAutoPlaySize = 50 * int64(1024 * 1024);
|
||||||
constexpr auto kVersion1 = char(1);
|
constexpr auto kVersion1 = char(1);
|
||||||
constexpr auto kVersion = char(2);
|
constexpr auto kVersion = char(2);
|
||||||
|
|
||||||
|
@ -82,26 +82,29 @@ Type AutoPlayTypeFromDocument(not_null<DocumentData*> document) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void Single::setBytesLimit(int bytesLimit) {
|
void Single::setBytesLimit(int64 bytesLimit) {
|
||||||
Expects(bytesLimit >= 0 && bytesLimit <= kMaxBytesLimit);
|
Expects(bytesLimit >= 0 && bytesLimit <= kMaxBytesLimit);
|
||||||
|
|
||||||
_limit = bytesLimit;
|
_limit = int32(uint32(bytesLimit));
|
||||||
|
|
||||||
|
Ensures(hasValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Single::hasValue() const {
|
bool Single::hasValue() const {
|
||||||
return (_limit >= 0);
|
return (_limit != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Single::shouldDownload(int fileSize) const {
|
bool Single::shouldDownload(int64 fileSize) const {
|
||||||
Expects(hasValue());
|
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());
|
Expects(hasValue());
|
||||||
|
|
||||||
return _limit;
|
return uint32(_limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint32 Single::serialize() const {
|
qint32 Single::serialize() const {
|
||||||
|
@ -109,7 +112,8 @@ qint32 Single::serialize() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Single::setFromSerialized(qint32 serialized) {
|
bool Single::setFromSerialized(qint32 serialized) {
|
||||||
if (serialized < -1 || serialized > kMaxBytesLimit) {
|
auto realLimit = quint32(serialized);
|
||||||
|
if (serialized != -1 && int64(realLimit) > kMaxBytesLimit) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_limit = serialized;
|
_limit = serialized;
|
||||||
|
@ -127,7 +131,7 @@ Single &Set::single(Type type) {
|
||||||
return const_cast<Single&>(static_cast<const Set*>(this)->single(type));
|
return const_cast<Single&>(static_cast<const Set*>(this)->single(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Set::setBytesLimit(Type type, int bytesLimit) {
|
void Set::setBytesLimit(Type type, int64 bytesLimit) {
|
||||||
single(type).setBytesLimit(bytesLimit);
|
single(type).setBytesLimit(bytesLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,11 +139,11 @@ bool Set::hasValue(Type type) const {
|
||||||
return single(type).hasValue();
|
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);
|
return single(type).shouldDownload(fileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Set::bytesLimit(Type type) const {
|
int64 Set::bytesLimit(Type type) const {
|
||||||
return single(type).bytesLimit();
|
return single(type).bytesLimit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,11 +178,11 @@ const Set &Full::setOrDefault(Source source, Type type) const {
|
||||||
return result;
|
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);
|
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)) {
|
if (ranges::find(kStreamedTypes, type) != end(kStreamedTypes)) {
|
||||||
// With streaming we disable autodownload and hide them in Settings.
|
// With streaming we disable autodownload and hide them in Settings.
|
||||||
return false;
|
return false;
|
||||||
|
@ -186,7 +190,7 @@ bool Full::shouldDownload(Source source, Type type, int fileSize) const {
|
||||||
return setOrDefault(source, type).shouldDownload(type, fileSize);
|
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);
|
return setOrDefault(source, type).bytesLimit(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace AutoDownload {
|
namespace AutoDownload {
|
||||||
|
|
||||||
constexpr auto kMaxBytesLimit = 4000 * 512 * 1024;
|
constexpr auto kMaxBytesLimit = 8000 * int64(512 * 1024);
|
||||||
|
|
||||||
enum class Source {
|
enum class Source {
|
||||||
User = 0x00,
|
User = 0x00,
|
||||||
|
@ -47,27 +47,27 @@ constexpr auto kTypesCount = 7;
|
||||||
|
|
||||||
class Single {
|
class Single {
|
||||||
public:
|
public:
|
||||||
void setBytesLimit(int bytesLimit);
|
void setBytesLimit(int64 bytesLimit);
|
||||||
|
|
||||||
bool hasValue() const;
|
bool hasValue() const;
|
||||||
bool shouldDownload(int fileSize) const;
|
bool shouldDownload(int64 fileSize) const;
|
||||||
int bytesLimit() const;
|
int64 bytesLimit() const;
|
||||||
|
|
||||||
qint32 serialize() const;
|
qint32 serialize() const;
|
||||||
bool setFromSerialized(qint32 serialized);
|
bool setFromSerialized(qint32 serialized);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _limit = -1;
|
int _limit = -1; // FileSize: Right now any file size fits 32 bit.
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Set {
|
class Set {
|
||||||
public:
|
public:
|
||||||
void setBytesLimit(Type type, int bytesLimit);
|
void setBytesLimit(Type type, int64 bytesLimit);
|
||||||
|
|
||||||
bool hasValue(Type type) const;
|
bool hasValue(Type type) const;
|
||||||
bool shouldDownload(Type type, int fileSize) const;
|
bool shouldDownload(Type type, int64 fileSize) const;
|
||||||
int bytesLimit(Type type) const;
|
int64 bytesLimit(Type type) const;
|
||||||
|
|
||||||
qint32 serialize(Type type) const;
|
qint32 serialize(Type type) const;
|
||||||
bool setFromSerialized(Type type, qint32 serialized);
|
bool setFromSerialized(Type type, qint32 serialized);
|
||||||
|
@ -82,13 +82,13 @@ private:
|
||||||
|
|
||||||
class Full {
|
class Full {
|
||||||
public:
|
public:
|
||||||
void setBytesLimit(Source source, Type type, int bytesLimit);
|
void setBytesLimit(Source source, Type type, int64 bytesLimit);
|
||||||
|
|
||||||
[[nodiscard]] bool shouldDownload(
|
[[nodiscard]] bool shouldDownload(
|
||||||
Source source,
|
Source source,
|
||||||
Type type,
|
Type type,
|
||||||
int fileSize) const;
|
int64 fileSize) const;
|
||||||
[[nodiscard]] int bytesLimit(Source source, Type type) const;
|
[[nodiscard]] int64 bytesLimit(Source source, Type type) const;
|
||||||
|
|
||||||
[[nodiscard]] QByteArray serialize() const;
|
[[nodiscard]] QByteArray serialize() const;
|
||||||
bool setFromSerialized(const QByteArray &serialized);
|
bool setFromSerialized(const QByteArray &serialized);
|
||||||
|
|
|
@ -756,7 +756,7 @@ float64 DocumentData::progress() const {
|
||||||
if (uploading()) {
|
if (uploading()) {
|
||||||
if (uploadingData->size > 0) {
|
if (uploadingData->size > 0) {
|
||||||
const auto result = float64(uploadingData->offset)
|
const auto result = float64(uploadingData->offset)
|
||||||
/ uploadingData->size;
|
/ float64(uploadingData->size);
|
||||||
return std::clamp(result, 0., 1.);
|
return std::clamp(result, 0., 1.);
|
||||||
}
|
}
|
||||||
return 0.;
|
return 0.;
|
||||||
|
@ -764,7 +764,7 @@ float64 DocumentData::progress() const {
|
||||||
return loading() ? _loader->currentProgress() : 0.;
|
return loading() ? _loader->currentProgress() : 0.;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DocumentData::loadOffset() const {
|
int64 DocumentData::loadOffset() const {
|
||||||
return loading() ? _loader->currentOffset() : 0;
|
return loading() ? _loader->currentOffset() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ public:
|
||||||
void cancel();
|
void cancel();
|
||||||
[[nodiscard]] bool cancelled() const;
|
[[nodiscard]] bool cancelled() const;
|
||||||
[[nodiscard]] float64 progress() const;
|
[[nodiscard]] float64 progress() const;
|
||||||
[[nodiscard]] int loadOffset() const;
|
[[nodiscard]] int64 loadOffset() const;
|
||||||
[[nodiscard]] bool uploading() const;
|
[[nodiscard]] bool uploading() const;
|
||||||
[[nodiscard]] bool loadedInMediaCache() const;
|
[[nodiscard]] bool loadedInMediaCache() const;
|
||||||
void setLoadedInMediaCache(bool loaded);
|
void setLoadedInMediaCache(bool loaded);
|
||||||
|
@ -260,11 +260,10 @@ public:
|
||||||
[[nodiscard]] bool inappPlaybackFailed() const;
|
[[nodiscard]] bool inappPlaybackFailed() const;
|
||||||
|
|
||||||
DocumentId id = 0;
|
DocumentId id = 0;
|
||||||
DocumentType type = FileDocument;
|
int64 size = 0;
|
||||||
QSize dimensions;
|
QSize dimensions;
|
||||||
int32 date = 0;
|
int32 date = 0;
|
||||||
int32 size = 0;
|
DocumentType type = FileDocument;
|
||||||
|
|
||||||
FileStatus status = FileReady;
|
FileStatus status = FileReady;
|
||||||
|
|
||||||
std::unique_ptr<Data::UploadState> uploadingData;
|
std::unique_ptr<Data::UploadState> uploadingData;
|
||||||
|
|
|
@ -295,7 +295,7 @@ void DownloadManager::addLoaded(
|
||||||
.download = id,
|
.download = id,
|
||||||
.started = started,
|
.started = started,
|
||||||
.path = path,
|
.path = path,
|
||||||
.size = int32(size),
|
.size = size,
|
||||||
.itemId = item->fullId(),
|
.itemId = item->fullId(),
|
||||||
.peerAccessHash = PeerAccessHash(item->history()->peer),
|
.peerAccessHash = PeerAccessHash(item->history()->peer),
|
||||||
.object = std::make_unique<DownloadObject>(object),
|
.object = std::make_unique<DownloadObject>(object),
|
||||||
|
|
|
@ -58,7 +58,7 @@ struct DownloadedId {
|
||||||
DownloadId download;
|
DownloadId download;
|
||||||
DownloadDate started = 0;
|
DownloadDate started = 0;
|
||||||
QString path;
|
QString path;
|
||||||
int32 size = 0;
|
int64 size = 0;
|
||||||
FullMsgId itemId;
|
FullMsgId itemId;
|
||||||
uint64 peerAccessHash = 0;
|
uint64 peerAccessHash = 0;
|
||||||
|
|
||||||
|
@ -69,8 +69,8 @@ struct DownloadingId {
|
||||||
DownloadObject object;
|
DownloadObject object;
|
||||||
DownloadDate started = 0;
|
DownloadDate started = 0;
|
||||||
QString path;
|
QString path;
|
||||||
int ready = 0;
|
int64 ready = 0;
|
||||||
int total = 0;
|
int64 total = 0;
|
||||||
bool hiddenByView = false;
|
bool hiddenByView = false;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -2731,7 +2731,7 @@ not_null<DocumentData*> Session::document(
|
||||||
const ImageWithLocation &videoThumbnail,
|
const ImageWithLocation &videoThumbnail,
|
||||||
bool isPremiumSticker,
|
bool isPremiumSticker,
|
||||||
int32 dc,
|
int32 dc,
|
||||||
int32 size) {
|
int64 size) {
|
||||||
const auto result = document(id);
|
const auto result = document(id);
|
||||||
documentApplyFields(
|
documentApplyFields(
|
||||||
result,
|
result,
|
||||||
|
@ -2814,7 +2814,7 @@ DocumentData *Session::documentFromWeb(
|
||||||
ImageWithLocation{ .location = videoThumbnailLocation },
|
ImageWithLocation{ .location = videoThumbnailLocation },
|
||||||
false, // isPremiumSticker
|
false, // isPremiumSticker
|
||||||
session().mainDcId(),
|
session().mainDcId(),
|
||||||
int32(0)); // data.vsize().v
|
int64(0)); // data.vsize().v
|
||||||
result->setWebLocation(WebFileLocation(
|
result->setWebLocation(WebFileLocation(
|
||||||
data.vurl().v,
|
data.vurl().v,
|
||||||
data.vaccess_hash().v));
|
data.vaccess_hash().v));
|
||||||
|
@ -2837,7 +2837,7 @@ DocumentData *Session::documentFromWeb(
|
||||||
ImageWithLocation{ .location = videoThumbnailLocation },
|
ImageWithLocation{ .location = videoThumbnailLocation },
|
||||||
false, // isPremiumSticker
|
false, // isPremiumSticker
|
||||||
session().mainDcId(),
|
session().mainDcId(),
|
||||||
int32(0)); // data.vsize().v
|
int64(0)); // data.vsize().v
|
||||||
result->setContentUrl(qs(data.vurl()));
|
result->setContentUrl(qs(data.vurl()));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -2892,7 +2892,7 @@ void Session::documentApplyFields(
|
||||||
const ImageWithLocation &videoThumbnail,
|
const ImageWithLocation &videoThumbnail,
|
||||||
bool isPremiumSticker,
|
bool isPremiumSticker,
|
||||||
int32 dc,
|
int32 dc,
|
||||||
int32 size) {
|
int64 size) {
|
||||||
if (!date) {
|
if (!date) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -509,7 +509,7 @@ public:
|
||||||
const ImageWithLocation &videoThumbnail,
|
const ImageWithLocation &videoThumbnail,
|
||||||
bool isPremiumSticker,
|
bool isPremiumSticker,
|
||||||
int32 dc,
|
int32 dc,
|
||||||
int32 size);
|
int64 size);
|
||||||
void documentConvert(
|
void documentConvert(
|
||||||
not_null<DocumentData*> original,
|
not_null<DocumentData*> original,
|
||||||
const MTPDocument &data);
|
const MTPDocument &data);
|
||||||
|
@ -761,7 +761,7 @@ private:
|
||||||
const ImageWithLocation &videoThumbnail,
|
const ImageWithLocation &videoThumbnail,
|
||||||
bool isPremiumSticker,
|
bool isPremiumSticker,
|
||||||
int32 dc,
|
int32 dc,
|
||||||
int32 size);
|
int64 size);
|
||||||
DocumentData *documentFromWeb(
|
DocumentData *documentFromWeb(
|
||||||
const MTPDwebDocument &data,
|
const MTPDwebDocument &data,
|
||||||
const ImageLocation &thumbnailLocation,
|
const ImageLocation &thumbnailLocation,
|
||||||
|
|
|
@ -37,10 +37,10 @@ using Options = base::flags<Option>;
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
struct UploadState {
|
struct UploadState {
|
||||||
UploadState(int size) : size(size) {
|
explicit UploadState(int64 size) : size(size) {
|
||||||
}
|
}
|
||||||
int offset = 0;
|
int64 offset = 0;
|
||||||
int size = 0;
|
int64 size = 0;
|
||||||
bool waitingForAlbum = false;
|
bool waitingForAlbum = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ enum LocationType {
|
||||||
SecureFileLocation = 0xcbc7ee28, // mtpc_inputSecureFileLocation
|
SecureFileLocation = 0xcbc7ee28, // mtpc_inputSecureFileLocation
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FileStatus {
|
enum FileStatus : char {
|
||||||
FileDownloadFailed = -2,
|
FileDownloadFailed = -2,
|
||||||
FileUploadFailed = -1,
|
FileUploadFailed = -1,
|
||||||
FileReady = 1,
|
FileReady = 1,
|
||||||
|
|
|
@ -203,10 +203,12 @@ void Paint::handleMimeData(const QMimeData *data) {
|
||||||
};
|
};
|
||||||
|
|
||||||
using Error = Ui::PreparedList::Error;
|
using Error = Ui::PreparedList::Error;
|
||||||
|
const auto premium = false; // Don't support > 2GB files here.
|
||||||
auto result = data->hasUrls()
|
auto result = data->hasUrls()
|
||||||
? Storage::PrepareMediaList(
|
? Storage::PrepareMediaList(
|
||||||
data->urls().mid(0, 1),
|
data->urls().mid(0, 1),
|
||||||
_imageSize.width() / 2)
|
_imageSize.width() / 2,
|
||||||
|
premium)
|
||||||
: Ui::PreparedList(Error::EmptyFile, QString());
|
: Ui::PreparedList(Error::EmptyFile, QString());
|
||||||
if (result.error == Error::None) {
|
if (result.error == Error::None) {
|
||||||
add(base::take(result.files.front().preview));
|
add(base::take(result.files.front().preview));
|
||||||
|
|
|
@ -68,7 +68,7 @@ struct File {
|
||||||
DateLimits,
|
DateLimits,
|
||||||
};
|
};
|
||||||
FileLocation location;
|
FileLocation location;
|
||||||
int size = 0;
|
int64 size = 0;
|
||||||
QByteArray content;
|
QByteArray content;
|
||||||
|
|
||||||
QString suggestedPath;
|
QString suggestedPath;
|
||||||
|
|
|
@ -28,7 +28,7 @@ constexpr auto kFileRequestsCount = 2;
|
||||||
constexpr auto kChatsSliceLimit = 100;
|
constexpr auto kChatsSliceLimit = 100;
|
||||||
constexpr auto kMessagesSliceLimit = 100;
|
constexpr auto kMessagesSliceLimit = 100;
|
||||||
constexpr auto kTopPeerSliceLimit = 100;
|
constexpr auto kTopPeerSliceLimit = 100;
|
||||||
constexpr auto kFileMaxSize = 2000 * 1024 * 1024;
|
constexpr auto kFileMaxSize = 4000 * 1024 * 1024;
|
||||||
constexpr auto kLocationCacheSize = 100'000;
|
constexpr auto kLocationCacheSize = 100'000;
|
||||||
|
|
||||||
struct LocationKey {
|
struct LocationKey {
|
||||||
|
@ -156,11 +156,11 @@ struct ApiWrap::FileProcess {
|
||||||
uint64 randomId = 0;
|
uint64 randomId = 0;
|
||||||
Data::FileLocation location;
|
Data::FileLocation location;
|
||||||
Data::FileOrigin origin;
|
Data::FileOrigin origin;
|
||||||
int offset = 0;
|
int64 offset = 0;
|
||||||
int size = 0;
|
int64 size = 0;
|
||||||
|
|
||||||
struct Request {
|
struct Request {
|
||||||
int offset = 0;
|
int64 offset = 0;
|
||||||
QByteArray bytes;
|
QByteArray bytes;
|
||||||
};
|
};
|
||||||
std::deque<Request> requests;
|
std::deque<Request> requests;
|
||||||
|
@ -168,8 +168,8 @@ struct ApiWrap::FileProcess {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ApiWrap::FileProgress {
|
struct ApiWrap::FileProgress {
|
||||||
int ready = 0;
|
int64 ready = 0;
|
||||||
int total = 0;
|
int64 total = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ApiWrap::ChatsProcess {
|
struct ApiWrap::ChatsProcess {
|
||||||
|
@ -352,7 +352,7 @@ auto ApiWrap::splitRequest(int index, Request &&request) {
|
||||||
std::forward<Request>(request)));
|
std::forward<Request>(request)));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ApiWrap::fileRequest(const Data::FileLocation &location, int offset) {
|
auto ApiWrap::fileRequest(const Data::FileLocation &location, int64 offset) {
|
||||||
Expects(location.dcId != 0
|
Expects(location.dcId != 0
|
||||||
|| location.data.type() == mtpc_inputTakeoutFileLocation);
|
|| location.data.type() == mtpc_inputTakeoutFileLocation);
|
||||||
Expects(_takeoutId.has_value());
|
Expects(_takeoutId.has_value());
|
||||||
|
@ -363,7 +363,7 @@ auto ApiWrap::fileRequest(const Data::FileLocation &location, int offset) {
|
||||||
MTPupload_GetFile(
|
MTPupload_GetFile(
|
||||||
MTP_flags(0),
|
MTP_flags(0),
|
||||||
location.data,
|
location.data,
|
||||||
MTP_int(offset),
|
MTP_long(offset),
|
||||||
MTP_int(kFileChunkSize))
|
MTP_int(kFileChunkSize))
|
||||||
)).fail([=](const MTP::Error &result) {
|
)).fail([=](const MTP::Error &result) {
|
||||||
_fileProcess->requestId = 0;
|
_fileProcess->requestId = 0;
|
||||||
|
@ -656,7 +656,7 @@ void ApiWrap::startMainSession(FnMut<void()> done) {
|
||||||
}
|
}
|
||||||
_mtp.request(MTPaccount_InitTakeoutSession(
|
_mtp.request(MTPaccount_InitTakeoutSession(
|
||||||
MTP_flags(flags),
|
MTP_flags(flags),
|
||||||
MTP_int(sizeLimit)
|
MTP_long(sizeLimit)
|
||||||
)).done([=, done = std::move(done)](
|
)).done([=, done = std::move(done)](
|
||||||
const MTPaccount_Takeout &result) mutable {
|
const MTPaccount_Takeout &result) mutable {
|
||||||
_takeoutId = result.match([](const MTPDaccount_takeout &data) {
|
_takeoutId = result.match([](const MTPDaccount_takeout &data) {
|
||||||
|
@ -1785,7 +1785,7 @@ void ApiWrap::loadFilePart() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiWrap::filePartDone(int offset, const MTPupload_File &result) {
|
void ApiWrap::filePartDone(int64 offset, const MTPupload_File &result) {
|
||||||
Expects(_fileProcess != nullptr);
|
Expects(_fileProcess != nullptr);
|
||||||
Expects(!_fileProcess->requests.empty());
|
Expects(!_fileProcess->requests.empty());
|
||||||
|
|
||||||
|
@ -1845,7 +1845,7 @@ void ApiWrap::filePartDone(int offset, const MTPupload_File &result) {
|
||||||
process->done(process->relativePath);
|
process->done(process->relativePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiWrap::filePartRefreshReference(int offset) {
|
void ApiWrap::filePartRefreshReference(int64 offset) {
|
||||||
Expects(_fileProcess != nullptr);
|
Expects(_fileProcess != nullptr);
|
||||||
Expects(_fileProcess->requestId == 0);
|
Expects(_fileProcess->requestId == 0);
|
||||||
|
|
||||||
|
@ -1897,7 +1897,7 @@ void ApiWrap::filePartRefreshReference(int offset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiWrap::filePartExtractReference(
|
void ApiWrap::filePartExtractReference(
|
||||||
int offset,
|
int64 offset,
|
||||||
const MTPmessages_Messages &result) {
|
const MTPmessages_Messages &result) {
|
||||||
Expects(_fileProcess != nullptr);
|
Expects(_fileProcess != nullptr);
|
||||||
Expects(_fileProcess->requestId == 0);
|
Expects(_fileProcess->requestId == 0);
|
||||||
|
|
|
@ -64,8 +64,8 @@ public:
|
||||||
uint64 randomId = 0;
|
uint64 randomId = 0;
|
||||||
QString path;
|
QString path;
|
||||||
int itemIndex = 0;
|
int itemIndex = 0;
|
||||||
int ready = 0;
|
int64 ready = 0;
|
||||||
int total = 0;
|
int64 total = 0;
|
||||||
};
|
};
|
||||||
void requestUserpics(
|
void requestUserpics(
|
||||||
FnMut<bool(Data::UserpicsInfo&&)> start,
|
FnMut<bool(Data::UserpicsInfo&&)> start,
|
||||||
|
@ -186,11 +186,11 @@ private:
|
||||||
Fn<bool(FileProgress)> progress,
|
Fn<bool(FileProgress)> progress,
|
||||||
FnMut<void(QString)> done);
|
FnMut<void(QString)> done);
|
||||||
void loadFilePart();
|
void loadFilePart();
|
||||||
void filePartDone(int offset, const MTPupload_File &result);
|
void filePartDone(int64 offset, const MTPupload_File &result);
|
||||||
void filePartUnavailable();
|
void filePartUnavailable();
|
||||||
void filePartRefreshReference(int offset);
|
void filePartRefreshReference(int64 offset);
|
||||||
void filePartExtractReference(
|
void filePartExtractReference(
|
||||||
int offset,
|
int64 offset,
|
||||||
const MTPmessages_Messages &result);
|
const MTPmessages_Messages &result);
|
||||||
|
|
||||||
template <typename Request>
|
template <typename Request>
|
||||||
|
@ -204,7 +204,7 @@ private:
|
||||||
|
|
||||||
[[nodiscard]] auto fileRequest(
|
[[nodiscard]] auto fileRequest(
|
||||||
const Data::FileLocation &location,
|
const Data::FileLocation &location,
|
||||||
int offset);
|
int64 offset);
|
||||||
|
|
||||||
void error(const MTP::Error &error);
|
void error(const MTP::Error &error);
|
||||||
void error(const QString &text);
|
void error(const QString &text);
|
||||||
|
|
|
@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Export {
|
namespace Export {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kMaxFileSize = 2000 * 1024 * 1024;
|
constexpr auto kMaxFileSize = 4000 * 1024 * 1024;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ struct MediaSettings {
|
||||||
friend inline constexpr auto is_flag_type(Type) { return true; };
|
friend inline constexpr auto is_flag_type(Type) { return true; };
|
||||||
|
|
||||||
Types types = DefaultTypes();
|
Types types = DefaultTypes();
|
||||||
int sizeLimit = 8 * 1024 * 1024;
|
int64 sizeLimit = 8 * 1024 * 1024;
|
||||||
|
|
||||||
static inline Types DefaultTypes() {
|
static inline Types DefaultTypes() {
|
||||||
return Type::Photo;
|
return Type::Photo;
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace Output {
|
||||||
File::File(const QString &path, Stats *stats) : _path(path), _stats(stats) {
|
File::File(const QString &path, Stats *stats) : _path(path), _stats(stats) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int File::size() const {
|
int64 File::size() const {
|
||||||
return _offset;
|
return _offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ class File {
|
||||||
public:
|
public:
|
||||||
File(const QString &path, Stats *stats);
|
File(const QString &path, Stats *stats);
|
||||||
|
|
||||||
[[nodiscard]] int size() const;
|
[[nodiscard]] int64 size() const;
|
||||||
[[nodiscard]] bool empty() const;
|
[[nodiscard]] bool empty() const;
|
||||||
|
|
||||||
[[nodiscard]] Result writeBlock(const QByteArray &block);
|
[[nodiscard]] Result writeBlock(const QByteArray &block);
|
||||||
|
@ -45,7 +45,7 @@ private:
|
||||||
[[nodiscard]] Result fatalError() const;
|
[[nodiscard]] Result fatalError() const;
|
||||||
|
|
||||||
QString _path;
|
QString _path;
|
||||||
int _offset = 0;
|
int64 _offset = 0;
|
||||||
std::optional<QFile> _file;
|
std::optional<QFile> _file;
|
||||||
|
|
||||||
Stats *_stats = nullptr;
|
Stats *_stats = nullptr;
|
||||||
|
|
|
@ -81,7 +81,7 @@ void ChooseFormatBox(
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int SizeLimitByIndex(int index) {
|
int64 SizeLimitByIndex(int index) {
|
||||||
Expects(index >= 0 && index < kSizeValueCount);
|
Expects(index >= 0 && index < kSizeValueCount);
|
||||||
|
|
||||||
index += 1;
|
index += 1;
|
||||||
|
@ -98,8 +98,10 @@ int SizeLimitByIndex(int index) {
|
||||||
return 300 + (index - 60) * 20;
|
return 300 + (index - 60) * 20;
|
||||||
} else if (index <= 80) {
|
} else if (index <= 80) {
|
||||||
return 500 + (index - 70) * 50;
|
return 500 + (index - 70) * 50;
|
||||||
} else {
|
} else if (index <= 90) {
|
||||||
return 1000 + (index - 80) * 100;
|
return 1000 + (index - 80) * 100;
|
||||||
|
} else {
|
||||||
|
return 2000 + (index - 90) * 200;
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
return megabytes * kMegabyte;
|
return megabytes * kMegabyte;
|
||||||
|
@ -693,7 +695,7 @@ void SettingsWidget::addSizeSlider(
|
||||||
kSizeValueCount,
|
kSizeValueCount,
|
||||||
SizeLimitByIndex,
|
SizeLimitByIndex,
|
||||||
readData().media.sizeLimit,
|
readData().media.sizeLimit,
|
||||||
[=](int limit) {
|
[=](int64 limit) {
|
||||||
changeData([&](Settings &data) {
|
changeData([&](Settings &data) {
|
||||||
data.media.sizeLimit = limit;
|
data.media.sizeLimit = limit;
|
||||||
});
|
});
|
||||||
|
@ -704,10 +706,13 @@ void SettingsWidget::addSizeSlider(
|
||||||
st::exportFileSizeLabel);
|
st::exportFileSizeLabel);
|
||||||
value() | rpl::map([](const Settings &data) {
|
value() | rpl::map([](const Settings &data) {
|
||||||
return data.media.sizeLimit;
|
return data.media.sizeLimit;
|
||||||
}) | rpl::start_with_next([=](int sizeLimit) {
|
}) | rpl::start_with_next([=](int64 sizeLimit) {
|
||||||
const auto limit = sizeLimit / kMegabyte;
|
const auto limit = sizeLimit / kMegabyte;
|
||||||
const auto size = QString::number(limit) + " MB";
|
const auto size = QString::number(limit) + " MB";
|
||||||
const auto text = tr::lng_export_option_size_limit(tr::now, lt_size, size);
|
const auto text = tr::lng_export_option_size_limit(
|
||||||
|
tr::now,
|
||||||
|
lt_size,
|
||||||
|
size);
|
||||||
label->setText(text);
|
label->setText(text);
|
||||||
}, slider->lifetime());
|
}, slider->lifetime());
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@ class Session;
|
||||||
namespace Export {
|
namespace Export {
|
||||||
namespace View {
|
namespace View {
|
||||||
|
|
||||||
constexpr auto kSizeValueCount = 90;
|
constexpr auto kSizeValueCount = 100;
|
||||||
int SizeLimitByIndex(int index);
|
int64 SizeLimitByIndex(int index);
|
||||||
|
|
||||||
class SettingsWidget : public Ui::RpWidget {
|
class SettingsWidget : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -4106,9 +4106,11 @@ void HistoryWidget::chooseAttach(
|
||||||
uploadFile(result.remoteContent, SendMediaType::File);
|
uploadFile(result.remoteContent, SendMediaType::File);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
const auto premium = controller()->session().user()->isPremium();
|
||||||
auto list = Storage::PrepareMediaList(
|
auto list = Storage::PrepareMediaList(
|
||||||
result.paths,
|
result.paths,
|
||||||
st::sendMediaPreviewSize);
|
st::sendMediaPreviewSize,
|
||||||
|
premium);
|
||||||
list.overrideSendImagesAsPhotos = overrideSendImagesAsPhotos;
|
list.overrideSendImagesAsPhotos = overrideSendImagesAsPhotos;
|
||||||
confirmSendingFiles(std::move(list));
|
confirmSendingFiles(std::move(list));
|
||||||
}
|
}
|
||||||
|
@ -4963,6 +4965,7 @@ bool HistoryWidget::showSendingFilesError(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_name,
|
lt_name,
|
||||||
list.errorData);
|
list.errorData);
|
||||||
|
case Error::PremiumRequired: return u"premium.."_q;
|
||||||
}
|
}
|
||||||
return tr::lng_forward_send_files_cant(tr::now);
|
return tr::lng_forward_send_files_cant(tr::now);
|
||||||
}();
|
}();
|
||||||
|
@ -4987,8 +4990,9 @@ bool HistoryWidget::confirmSendingFiles(not_null<const QMimeData*> data) {
|
||||||
bool HistoryWidget::confirmSendingFiles(
|
bool HistoryWidget::confirmSendingFiles(
|
||||||
const QStringList &files,
|
const QStringList &files,
|
||||||
const QString &insertTextOnCancel) {
|
const QString &insertTextOnCancel) {
|
||||||
|
const auto premium = controller()->session().user()->isPremium();
|
||||||
return confirmSendingFiles(
|
return confirmSendingFiles(
|
||||||
Storage::PrepareMediaList(files, st::sendMediaPreviewSize),
|
Storage::PrepareMediaList(files, st::sendMediaPreviewSize, premium),
|
||||||
insertTextOnCancel);
|
insertTextOnCancel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5127,11 +5131,13 @@ bool HistoryWidget::confirmSendingFiles(
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto hasImage = data->hasImage();
|
const auto hasImage = data->hasImage();
|
||||||
|
const auto premium = controller()->session().user()->isPremium();
|
||||||
|
|
||||||
if (const auto urls = data->urls(); !urls.empty()) {
|
if (const auto urls = data->urls(); !urls.empty()) {
|
||||||
auto list = Storage::PrepareMediaList(
|
auto list = Storage::PrepareMediaList(
|
||||||
urls,
|
urls,
|
||||||
st::sendMediaPreviewSize);
|
st::sendMediaPreviewSize,
|
||||||
|
premium);
|
||||||
if (list.error != Ui::PreparedList::Error::NonLocalUrl) {
|
if (list.error != Ui::PreparedList::Error::NonLocalUrl) {
|
||||||
if (list.error == Ui::PreparedList::Error::None
|
if (list.error == Ui::PreparedList::Error::None
|
||||||
|| !hasImage) {
|
|| !hasImage) {
|
||||||
|
|
|
@ -677,9 +677,11 @@ void RepliesWidget::chooseAttach() {
|
||||||
uploadFile(result.remoteContent, SendMediaType::File);
|
uploadFile(result.remoteContent, SendMediaType::File);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
const auto premium = controller()->session().user()->isPremium();
|
||||||
auto list = Storage::PrepareMediaList(
|
auto list = Storage::PrepareMediaList(
|
||||||
result.paths,
|
result.paths,
|
||||||
st::sendMediaPreviewSize);
|
st::sendMediaPreviewSize,
|
||||||
|
premium);
|
||||||
confirmSendingFiles(std::move(list));
|
confirmSendingFiles(std::move(list));
|
||||||
}
|
}
|
||||||
}), nullptr);
|
}), nullptr);
|
||||||
|
@ -690,11 +692,13 @@ bool RepliesWidget::confirmSendingFiles(
|
||||||
std::optional<bool> overrideSendImagesAsPhotos,
|
std::optional<bool> overrideSendImagesAsPhotos,
|
||||||
const QString &insertTextOnCancel) {
|
const QString &insertTextOnCancel) {
|
||||||
const auto hasImage = data->hasImage();
|
const auto hasImage = data->hasImage();
|
||||||
|
const auto premium = controller()->session().user()->isPremium();
|
||||||
|
|
||||||
if (const auto urls = data->urls(); !urls.empty()) {
|
if (const auto urls = data->urls(); !urls.empty()) {
|
||||||
auto list = Storage::PrepareMediaList(
|
auto list = Storage::PrepareMediaList(
|
||||||
urls,
|
urls,
|
||||||
st::sendMediaPreviewSize);
|
st::sendMediaPreviewSize,
|
||||||
|
premium);
|
||||||
if (list.error != Ui::PreparedList::Error::NonLocalUrl) {
|
if (list.error != Ui::PreparedList::Error::NonLocalUrl) {
|
||||||
if (list.error == Ui::PreparedList::Error::None
|
if (list.error == Ui::PreparedList::Error::None
|
||||||
|| !hasImage) {
|
|| !hasImage) {
|
||||||
|
@ -936,6 +940,7 @@ bool RepliesWidget::showSendingFilesError(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_name,
|
lt_name,
|
||||||
list.errorData);
|
list.errorData);
|
||||||
|
case Error::PremiumRequired: return u"premium.."_q;
|
||||||
}
|
}
|
||||||
return tr::lng_forward_send_files_cant(tr::now);
|
return tr::lng_forward_send_files_cant(tr::now);
|
||||||
}();
|
}();
|
||||||
|
|
|
@ -332,9 +332,11 @@ void ScheduledWidget::chooseAttach() {
|
||||||
uploadFile(result.remoteContent, SendMediaType::File);
|
uploadFile(result.remoteContent, SendMediaType::File);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
const auto premium = controller()->session().user()->isPremium();
|
||||||
auto list = Storage::PrepareMediaList(
|
auto list = Storage::PrepareMediaList(
|
||||||
result.paths,
|
result.paths,
|
||||||
st::sendMediaPreviewSize);
|
st::sendMediaPreviewSize,
|
||||||
|
premium);
|
||||||
confirmSendingFiles(std::move(list));
|
confirmSendingFiles(std::move(list));
|
||||||
}
|
}
|
||||||
}), nullptr);
|
}), nullptr);
|
||||||
|
@ -345,11 +347,13 @@ bool ScheduledWidget::confirmSendingFiles(
|
||||||
std::optional<bool> overrideSendImagesAsPhotos,
|
std::optional<bool> overrideSendImagesAsPhotos,
|
||||||
const QString &insertTextOnCancel) {
|
const QString &insertTextOnCancel) {
|
||||||
const auto hasImage = data->hasImage();
|
const auto hasImage = data->hasImage();
|
||||||
|
const auto premium = controller()->session().user()->isPremium();
|
||||||
|
|
||||||
if (const auto urls = data->urls(); !urls.empty()) {
|
if (const auto urls = data->urls(); !urls.empty()) {
|
||||||
auto list = Storage::PrepareMediaList(
|
auto list = Storage::PrepareMediaList(
|
||||||
urls,
|
urls,
|
||||||
st::sendMediaPreviewSize);
|
st::sendMediaPreviewSize,
|
||||||
|
premium);
|
||||||
if (list.error != Ui::PreparedList::Error::NonLocalUrl) {
|
if (list.error != Ui::PreparedList::Error::NonLocalUrl) {
|
||||||
if (list.error == Ui::PreparedList::Error::None
|
if (list.error == Ui::PreparedList::Error::None
|
||||||
|| !hasImage) {
|
|| !hasImage) {
|
||||||
|
@ -505,6 +509,7 @@ bool ScheduledWidget::showSendingFilesError(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_name,
|
lt_name,
|
||||||
list.errorData);
|
list.errorData);
|
||||||
|
case Error::PremiumRequired: return u"premium.."_q;
|
||||||
}
|
}
|
||||||
return tr::lng_forward_send_files_cant(tr::now);
|
return tr::lng_forward_send_files_cant(tr::now);
|
||||||
}();
|
}();
|
||||||
|
|
|
@ -839,8 +839,8 @@ bool Document::uploading() const {
|
||||||
return _data->uploading();
|
return _data->uploading();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Document::setStatusSize(int newSize, qint64 realDuration) const {
|
void Document::setStatusSize(int64 newSize, TimeId realDuration) const {
|
||||||
auto duration = _data->isSong()
|
TimeId duration = _data->isSong()
|
||||||
? _data->song()->duration
|
? _data->song()->duration
|
||||||
: (_data->isVoiceMessage()
|
: (_data->isVoiceMessage()
|
||||||
? _data->voice()->duration
|
? _data->voice()->duration
|
||||||
|
@ -864,8 +864,8 @@ void Document::setStatusSize(int newSize, qint64 realDuration) const {
|
||||||
|
|
||||||
bool Document::updateStatusText() const {
|
bool Document::updateStatusText() const {
|
||||||
auto showPause = false;
|
auto showPause = false;
|
||||||
auto statusSize = 0;
|
auto statusSize = int64();
|
||||||
auto realDuration = 0;
|
auto realDuration = TimeId();
|
||||||
if (_data->status == FileDownloadFailed || _data->status == FileUploadFailed) {
|
if (_data->status == FileDownloadFailed || _data->status == FileUploadFailed) {
|
||||||
statusSize = Ui::FileStatusSizeFailed;
|
statusSize = Ui::FileStatusSizeFailed;
|
||||||
} else if (_data->uploading()) {
|
} else if (_data->uploading()) {
|
||||||
|
|
|
@ -95,9 +95,9 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct StateFromPlayback {
|
struct StateFromPlayback {
|
||||||
int statusSize = 0;
|
int64 statusSize = 0;
|
||||||
bool showPause = false;
|
bool showPause = false;
|
||||||
int realDuration = 0;
|
TimeId realDuration = 0;
|
||||||
};
|
};
|
||||||
enum class LayoutMode {
|
enum class LayoutMode {
|
||||||
Full,
|
Full,
|
||||||
|
@ -124,7 +124,7 @@ private:
|
||||||
void createComponents(bool caption);
|
void createComponents(bool caption);
|
||||||
void fillNamedFromData(HistoryDocumentNamed *named);
|
void fillNamedFromData(HistoryDocumentNamed *named);
|
||||||
|
|
||||||
void setStatusSize(int newSize, qint64 realDuration = 0) const;
|
void setStatusSize(int64 newSize, TimeId realDuration = 0) const;
|
||||||
bool updateStatusText() const; // returns showPause
|
bool updateStatusText() const; // returns showPause
|
||||||
|
|
||||||
[[nodiscard]] bool downloadInCorner() const;
|
[[nodiscard]] bool downloadInCorner() const;
|
||||||
|
|
|
@ -65,7 +65,11 @@ void File::refreshParentId(not_null<HistoryItem*> realParent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void File::setStatusSize(int newSize, int fullSize, int duration, qint64 realDuration) const {
|
void File::setStatusSize(
|
||||||
|
int64 newSize,
|
||||||
|
int64 fullSize,
|
||||||
|
TimeId duration,
|
||||||
|
TimeId realDuration) const {
|
||||||
_statusSize = newSize;
|
_statusSize = newSize;
|
||||||
if (_statusSize == Ui::FileStatusSizeReady) {
|
if (_statusSize == Ui::FileStatusSizeReady) {
|
||||||
_statusText = (duration >= 0) ? Ui::FormatDurationAndSizeText(duration, fullSize) : (duration < -1 ? Ui::FormatGifAndSizeText(fullSize) : Ui::FormatSizeText(fullSize));
|
_statusText = (duration >= 0) ? Ui::FormatDurationAndSizeText(duration, fullSize) : (duration < -1 ? Ui::FormatGifAndSizeText(fullSize) : Ui::FormatSizeText(fullSize));
|
||||||
|
|
|
@ -56,14 +56,14 @@ protected:
|
||||||
|
|
||||||
// >= 0 will contain download / upload string, _statusSize = loaded bytes
|
// >= 0 will contain download / upload string, _statusSize = loaded bytes
|
||||||
// < 0 will contain played string, _statusSize = -(seconds + 1) played
|
// < 0 will contain played string, _statusSize = -(seconds + 1) played
|
||||||
// 0x7FFFFFF0 will contain status for not yet downloaded file
|
// 0xFFFFFFF0LL will contain status for not yet downloaded file
|
||||||
// 0x7FFFFFF1 will contain status for already downloaded file
|
// 0xFFFFFFF1LL will contain status for already downloaded file
|
||||||
// 0x7FFFFFF2 will contain status for failed to download / upload file
|
// 0xFFFFFFF2LL will contain status for failed to download / upload file
|
||||||
mutable int _statusSize;
|
mutable int64 _statusSize = 0;
|
||||||
mutable QString _statusText;
|
mutable QString _statusText;
|
||||||
|
|
||||||
// duration = -1 - no duration, duration = -2 - "GIF" duration
|
// duration = -1 - no duration, duration = -2 - "GIF" duration
|
||||||
void setStatusSize(int newSize, int fullSize, int duration, qint64 realDuration) const;
|
void setStatusSize(int64 newSize, int64 fullSize, TimeId duration, TimeId realDuration) const;
|
||||||
|
|
||||||
void radialAnimationCallback(crl::time now) const;
|
void radialAnimationCallback(crl::time now) const;
|
||||||
|
|
||||||
|
|
|
@ -1386,7 +1386,7 @@ void Gif::validateGroupedCache(
|
||||||
{ .options = options, .outer = { width, height } });
|
{ .options = options, .outer = { width, height } });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gif::setStatusSize(int newSize) const {
|
void Gif::setStatusSize(int64 newSize) const {
|
||||||
if (newSize < 0) {
|
if (newSize < 0) {
|
||||||
_statusSize = newSize;
|
_statusSize = newSize;
|
||||||
_statusText = Ui::FormatDurationText(-newSize - 1);
|
_statusText = Ui::FormatDurationText(-newSize - 1);
|
||||||
|
@ -1404,7 +1404,7 @@ void Gif::setStatusSize(int newSize) const {
|
||||||
|
|
||||||
void Gif::updateStatusText() const {
|
void Gif::updateStatusText() const {
|
||||||
ensureDataMediaCreated();
|
ensureDataMediaCreated();
|
||||||
auto statusSize = 0;
|
auto statusSize = int64();
|
||||||
if (_data->status == FileDownloadFailed || _data->status == FileUploadFailed) {
|
if (_data->status == FileDownloadFailed || _data->status == FileUploadFailed) {
|
||||||
statusSize = Ui::FileStatusSizeFailed;
|
statusSize = Ui::FileStatusSizeFailed;
|
||||||
} else if (_data->uploading()) {
|
} else if (_data->uploading()) {
|
||||||
|
|
|
@ -167,7 +167,7 @@ private:
|
||||||
RectParts corners,
|
RectParts corners,
|
||||||
not_null<uint64*> cacheKey,
|
not_null<uint64*> cacheKey,
|
||||||
not_null<QPixmap*> cache) const;
|
not_null<QPixmap*> cache) const;
|
||||||
void setStatusSize(int newSize) const;
|
void setStatusSize(int64 newSize) const;
|
||||||
void updateStatusText() const;
|
void updateStatusText() const;
|
||||||
[[nodiscard]] QSize sizeForAspectRatio() const;
|
[[nodiscard]] QSize sizeForAspectRatio() const;
|
||||||
|
|
||||||
|
|
|
@ -1105,8 +1105,9 @@ void File::checkAnimationFinished() const {
|
||||||
|
|
||||||
bool File::updateStatusText() const {
|
bool File::updateStatusText() const {
|
||||||
ensureDataMediaCreated();
|
ensureDataMediaCreated();
|
||||||
bool showPause = false;
|
auto showPause = false;
|
||||||
int32 statusSize = 0, realDuration = 0;
|
auto statusSize = int64();
|
||||||
|
auto realDuration = TimeId();
|
||||||
if (_document->status == FileDownloadFailed || _document->status == FileUploadFailed) {
|
if (_document->status == FileDownloadFailed || _document->status == FileUploadFailed) {
|
||||||
statusSize = Ui::FileStatusSizeFailed;
|
statusSize = Ui::FileStatusSizeFailed;
|
||||||
} else if (_document->uploading()) {
|
} else if (_document->uploading()) {
|
||||||
|
@ -1133,7 +1134,7 @@ bool File::updateStatusText() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statusSize != _statusSize) {
|
if (statusSize != _statusSize) {
|
||||||
int32 duration = _document->isSong()
|
TimeId duration = _document->isSong()
|
||||||
? _document->song()->duration
|
? _document->song()->duration
|
||||||
: (_document->isVoiceMessage()
|
: (_document->isVoiceMessage()
|
||||||
? _document->voice()->duration
|
? _document->voice()->duration
|
||||||
|
@ -1143,7 +1144,11 @@ bool File::updateStatusText() const {
|
||||||
return showPause;
|
return showPause;
|
||||||
}
|
}
|
||||||
|
|
||||||
void File::setStatusSize(int32 newSize, int32 fullSize, int32 duration, qint64 realDuration) const {
|
void File::setStatusSize(
|
||||||
|
int64 newSize,
|
||||||
|
int64 fullSize,
|
||||||
|
TimeId duration,
|
||||||
|
TimeId realDuration) const {
|
||||||
_statusSize = newSize;
|
_statusSize = newSize;
|
||||||
if (_statusSize == Ui::FileStatusSizeReady) {
|
if (_statusSize == Ui::FileStatusSizeReady) {
|
||||||
_statusText = (duration >= 0) ? Ui::FormatDurationAndSizeText(duration, fullSize) : (duration < -1 ? Ui::FormatGifAndSizeText(fullSize) : Ui::FormatSizeText(fullSize));
|
_statusText = (duration >= 0) ? Ui::FormatDurationAndSizeText(duration, fullSize) : (duration < -1 ? Ui::FormatGifAndSizeText(fullSize) : Ui::FormatSizeText(fullSize));
|
||||||
|
|
|
@ -327,14 +327,18 @@ private:
|
||||||
|
|
||||||
// >= 0 will contain download / upload string, _statusSize = loaded bytes
|
// >= 0 will contain download / upload string, _statusSize = loaded bytes
|
||||||
// < 0 will contain played string, _statusSize = -(seconds + 1) played
|
// < 0 will contain played string, _statusSize = -(seconds + 1) played
|
||||||
// 0x7FFFFFF0 will contain status for not yet downloaded file
|
// 0xFFFFFFF0LL will contain status for not yet downloaded file
|
||||||
// 0x7FFFFFF1 will contain status for already downloaded file
|
// 0xFFFFFFF1LL will contain status for already downloaded file
|
||||||
// 0x7FFFFFF2 will contain status for failed to download / upload file
|
// 0xFFFFFFF2LL will contain status for failed to download / upload file
|
||||||
mutable int32 _statusSize;
|
mutable int64 _statusSize = 0;
|
||||||
mutable QString _statusText;
|
mutable QString _statusText;
|
||||||
|
|
||||||
// duration = -1 - no duration, duration = -2 - "GIF" duration
|
// duration = -1 - no duration, duration = -2 - "GIF" duration
|
||||||
void setStatusSize(int32 newSize, int32 fullSize, int32 duration, qint64 realDuration) const;
|
void setStatusSize(
|
||||||
|
int64 newSize,
|
||||||
|
int64 fullSize,
|
||||||
|
TimeId duration,
|
||||||
|
TimeId realDuration) const;
|
||||||
|
|
||||||
not_null<DocumentData*> _document;
|
not_null<DocumentData*> _document;
|
||||||
mutable std::shared_ptr<Data::DocumentMedia> _documentMedia;
|
mutable std::shared_ptr<Data::DocumentMedia> _documentMedia;
|
||||||
|
|
|
@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Media {
|
namespace Media {
|
||||||
namespace Streaming {
|
namespace Streaming {
|
||||||
|
|
||||||
bool LoadedPart::valid(int size) const {
|
bool LoadedPart::valid(int64 size) const {
|
||||||
return (offset != kFailedOffset)
|
return (offset != kFailedOffset)
|
||||||
&& ((bytes.size() == Loader::kPartSize)
|
&& ((bytes.size() == Loader::kPartSize)
|
||||||
|| (offset + bytes.size() == size));
|
|| (offset + bytes.size() == size));
|
||||||
|
@ -28,7 +28,7 @@ bool operator<(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PriorityQueue::add(int value) {
|
bool PriorityQueue::add(int64 value) {
|
||||||
const auto i = ranges::find(_data, value, &Entry::value);
|
const auto i = ranges::find(_data, value, &Entry::value);
|
||||||
if (i == end(_data)) {
|
if (i == end(_data)) {
|
||||||
_data.insert({ value, _priority });
|
_data.insert({ value, _priority });
|
||||||
|
@ -41,7 +41,7 @@ bool PriorityQueue::add(int value) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PriorityQueue::remove(int value) {
|
bool PriorityQueue::remove(int64 value) {
|
||||||
const auto i = ranges::find(_data, value, &Entry::value);
|
const auto i = ranges::find(_data, value, &Entry::value);
|
||||||
if (i == end(_data)) {
|
if (i == end(_data)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -54,13 +54,13 @@ bool PriorityQueue::empty() const {
|
||||||
return _data.empty();
|
return _data.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<int> PriorityQueue::front() const {
|
std::optional<int64> PriorityQueue::front() const {
|
||||||
return _data.empty()
|
return _data.empty()
|
||||||
? std::nullopt
|
? std::nullopt
|
||||||
: std::make_optional(_data.front().value);
|
: std::make_optional(_data.front().value);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<int> PriorityQueue::take() {
|
std::optional<int64> PriorityQueue::take() {
|
||||||
if (_data.empty()) {
|
if (_data.empty()) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,8 @@ std::optional<int> PriorityQueue::take() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
base::flat_set<int> PriorityQueue::takeInRange(int from, int till) {
|
base::flat_set<int64> PriorityQueue::takeInRange(int64 from, int64 till) {
|
||||||
auto result = base::flat_set<int>();
|
auto result = base::flat_set<int64>();
|
||||||
for (auto i = _data.begin(); i != _data.end();) {
|
for (auto i = _data.begin(); i != _data.end();) {
|
||||||
if (i->value >= from && i->value < till) {
|
if (i->value >= from && i->value < till) {
|
||||||
result.emplace(i->value);
|
result.emplace(i->value);
|
||||||
|
|
|
@ -15,12 +15,12 @@ namespace Media {
|
||||||
namespace Streaming {
|
namespace Streaming {
|
||||||
|
|
||||||
struct LoadedPart {
|
struct LoadedPart {
|
||||||
int offset = 0;
|
int64 offset = 0;
|
||||||
QByteArray bytes;
|
QByteArray bytes;
|
||||||
|
|
||||||
static constexpr auto kFailedOffset = -1;
|
static constexpr auto kFailedOffset = int64(-1);
|
||||||
|
|
||||||
[[nodiscard]] bool valid(int size) const;
|
[[nodiscard]] bool valid(int64 size) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Loader {
|
class Loader {
|
||||||
|
@ -28,10 +28,10 @@ public:
|
||||||
static constexpr auto kPartSize = 128 * 1024;
|
static constexpr auto kPartSize = 128 * 1024;
|
||||||
|
|
||||||
[[nodiscard]] virtual Storage::Cache::Key baseCacheKey() const = 0;
|
[[nodiscard]] virtual Storage::Cache::Key baseCacheKey() const = 0;
|
||||||
[[nodiscard]] virtual int size() const = 0;
|
[[nodiscard]] virtual int64 size() const = 0;
|
||||||
|
|
||||||
virtual void load(int offset) = 0;
|
virtual void load(int64 offset) = 0;
|
||||||
virtual void cancel(int offset) = 0;
|
virtual void cancel(int64 offset) = 0;
|
||||||
virtual void resetPriorities() = 0;
|
virtual void resetPriorities() = 0;
|
||||||
virtual void setPriority(int priority) = 0;
|
virtual void setPriority(int priority) = 0;
|
||||||
virtual void stop() = 0;
|
virtual void stop() = 0;
|
||||||
|
@ -52,18 +52,18 @@ public:
|
||||||
|
|
||||||
class PriorityQueue {
|
class PriorityQueue {
|
||||||
public:
|
public:
|
||||||
bool add(int value);
|
bool add(int64 value);
|
||||||
bool remove(int value);
|
bool remove(int64 value);
|
||||||
void resetPriorities();
|
void resetPriorities();
|
||||||
[[nodiscard]] bool empty() const;
|
[[nodiscard]] bool empty() const;
|
||||||
[[nodiscard]] std::optional<int> front() const;
|
[[nodiscard]] std::optional<int64> front() const;
|
||||||
[[nodiscard]] std::optional<int> take();
|
[[nodiscard]] std::optional<int64> take();
|
||||||
[[nodiscard]] base::flat_set<int> takeInRange(int from, int till);
|
[[nodiscard]] base::flat_set<int64> takeInRange(int64 from, int64 till);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Entry {
|
struct Entry {
|
||||||
int value = 0;
|
int64 value = 0;
|
||||||
int priority = 0;
|
int priority = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,10 @@ namespace Streaming {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// This is the maximum file size in Telegram API.
|
// This is the maximum file size in Telegram API.
|
||||||
constexpr auto kMaxFileSize = 4000 * 512 * 1024;
|
constexpr auto kMaxFileSize = 8000 * int64(512 * 1024);
|
||||||
|
|
||||||
int ValidateLocalSize(int64 size) {
|
[[nodiscard]] int64 ValidateLocalSize(int64 size) {
|
||||||
return (size > 0 && size <= kMaxFileSize) ? int(size) : 0;
|
return (size > 0 && size <= kMaxFileSize) ? size : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -38,11 +38,11 @@ Storage::Cache::Key LoaderLocal::baseCacheKey() const {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
int LoaderLocal::size() const {
|
int64 LoaderLocal::size() const {
|
||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoaderLocal::load(int offset) {
|
void LoaderLocal::load(int64 offset) {
|
||||||
if (_device->pos() != offset && !_device->seek(offset)) {
|
if (_device->pos() != offset && !_device->seek(offset)) {
|
||||||
fail();
|
fail();
|
||||||
return;
|
return;
|
||||||
|
@ -65,7 +65,7 @@ void LoaderLocal::fail() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoaderLocal::cancel(int offset) {
|
void LoaderLocal::cancel(int64 offset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoaderLocal::resetPriorities() {
|
void LoaderLocal::resetPriorities() {
|
||||||
|
|
|
@ -21,10 +21,10 @@ public:
|
||||||
LoaderLocal(std::unique_ptr<QIODevice> device);
|
LoaderLocal(std::unique_ptr<QIODevice> device);
|
||||||
|
|
||||||
[[nodiscard]] Storage::Cache::Key baseCacheKey() const override;
|
[[nodiscard]] Storage::Cache::Key baseCacheKey() const override;
|
||||||
[[nodiscard]] int size() const override;
|
[[nodiscard]] int64 size() const override;
|
||||||
|
|
||||||
void load(int offset) override;
|
void load(int64 offset) override;
|
||||||
void cancel(int offset) override;
|
void cancel(int64 offset) override;
|
||||||
void resetPriorities() override;
|
void resetPriorities() override;
|
||||||
void setPriority(int priority) override;
|
void setPriority(int priority) override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
|
@ -42,7 +42,7 @@ private:
|
||||||
void fail();
|
void fail();
|
||||||
|
|
||||||
const std::unique_ptr<QIODevice> _device;
|
const std::unique_ptr<QIODevice> _device;
|
||||||
const int _size = 0;
|
const int64 _size = 0;
|
||||||
rpl::event_stream<LoadedPart> _parts;
|
rpl::event_stream<LoadedPart> _parts;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Streaming {
|
||||||
LoaderMtproto::LoaderMtproto(
|
LoaderMtproto::LoaderMtproto(
|
||||||
not_null<Storage::DownloadManagerMtproto*> owner,
|
not_null<Storage::DownloadManagerMtproto*> owner,
|
||||||
const StorageFileLocation &location,
|
const StorageFileLocation &location,
|
||||||
int size,
|
int64 size,
|
||||||
Data::FileOrigin origin)
|
Data::FileOrigin origin)
|
||||||
: DownloadMtprotoTask(owner, location, origin)
|
: DownloadMtprotoTask(owner, location, origin)
|
||||||
, _size(size)
|
, _size(size)
|
||||||
|
@ -31,11 +31,11 @@ Storage::Cache::Key LoaderMtproto::baseCacheKey() const {
|
||||||
).bigFileBaseCacheKey();
|
).bigFileBaseCacheKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
int LoaderMtproto::size() const {
|
int64 LoaderMtproto::size() const {
|
||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoaderMtproto::load(int offset) {
|
void LoaderMtproto::load(int64 offset) {
|
||||||
crl::on_main(this, [=] {
|
crl::on_main(this, [=] {
|
||||||
if (_downloader) {
|
if (_downloader) {
|
||||||
auto bytes = _downloader->readLoadedPart(offset);
|
auto bytes = _downloader->readLoadedPart(offset);
|
||||||
|
@ -73,13 +73,13 @@ void LoaderMtproto::tryRemoveFromQueue() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoaderMtproto::cancel(int offset) {
|
void LoaderMtproto::cancel(int64 offset) {
|
||||||
crl::on_main(this, [=] {
|
crl::on_main(this, [=] {
|
||||||
cancelForOffset(offset);
|
cancelForOffset(offset);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoaderMtproto::cancelForOffset(int offset) {
|
void LoaderMtproto::cancelForOffset(int64 offset) {
|
||||||
if (haveSentRequestForOffset(offset)) {
|
if (haveSentRequestForOffset(offset)) {
|
||||||
cancelRequestForOffset(offset);
|
cancelRequestForOffset(offset);
|
||||||
if (!_requested.empty()) {
|
if (!_requested.empty()) {
|
||||||
|
@ -119,14 +119,14 @@ bool LoaderMtproto::readyToRequest() const {
|
||||||
return !_requested.empty();
|
return !_requested.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
int LoaderMtproto::takeNextRequestOffset() {
|
int64 LoaderMtproto::takeNextRequestOffset() {
|
||||||
const auto offset = _requested.take();
|
const auto offset = _requested.take();
|
||||||
|
|
||||||
Ensures(offset.has_value());
|
Ensures(offset.has_value());
|
||||||
return *offset;
|
return *offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoaderMtproto::feedPart(int offset, const QByteArray &bytes) {
|
bool LoaderMtproto::feedPart(int64 offset, const QByteArray &bytes) {
|
||||||
_parts.fire({ offset, bytes });
|
_parts.fire({ offset, bytes });
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,14 +20,14 @@ public:
|
||||||
LoaderMtproto(
|
LoaderMtproto(
|
||||||
not_null<Storage::DownloadManagerMtproto*> owner,
|
not_null<Storage::DownloadManagerMtproto*> owner,
|
||||||
const StorageFileLocation &location,
|
const StorageFileLocation &location,
|
||||||
int size,
|
int64 size,
|
||||||
Data::FileOrigin origin);
|
Data::FileOrigin origin);
|
||||||
|
|
||||||
[[nodiscard]] Storage::Cache::Key baseCacheKey() const override;
|
[[nodiscard]] Storage::Cache::Key baseCacheKey() const override;
|
||||||
[[nodiscard]] int size() const override;
|
[[nodiscard]] int64 size() const override;
|
||||||
|
|
||||||
void load(int offset) override;
|
void load(int64 offset) override;
|
||||||
void cancel(int offset) override;
|
void cancel(int64 offset) override;
|
||||||
void resetPriorities() override;
|
void resetPriorities() override;
|
||||||
void setPriority(int priority) override;
|
void setPriority(int priority) override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
|
@ -43,14 +43,14 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool readyToRequest() const override;
|
bool readyToRequest() const override;
|
||||||
int takeNextRequestOffset() override;
|
int64 takeNextRequestOffset() override;
|
||||||
bool feedPart(int offset, const QByteArray &bytes) override;
|
bool feedPart(int64 offset, const QByteArray &bytes) override;
|
||||||
void cancelOnFail() override;
|
void cancelOnFail() override;
|
||||||
|
|
||||||
void cancelForOffset(int offset);
|
void cancelForOffset(int64 offset);
|
||||||
void addToQueueWithPriority();
|
void addToQueueWithPriority();
|
||||||
|
|
||||||
const int _size = 0;
|
const int64 _size = 0;
|
||||||
int _priority = 0;
|
int _priority = 0;
|
||||||
|
|
||||||
MTP::Sender _api;
|
MTP::Sender _api;
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace {
|
||||||
|
|
||||||
constexpr auto kPartSize = Loader::kPartSize;
|
constexpr auto kPartSize = Loader::kPartSize;
|
||||||
constexpr auto kPartsInSlice = 64;
|
constexpr auto kPartsInSlice = 64;
|
||||||
constexpr auto kInSlice = kPartsInSlice * kPartSize;
|
constexpr auto kInSlice = uint32(kPartsInSlice * kPartSize);
|
||||||
constexpr auto kMaxPartsInHeader = 64;
|
constexpr auto kMaxPartsInHeader = 64;
|
||||||
constexpr auto kMaxOnlyInHeader = 80 * kPartSize;
|
constexpr auto kMaxOnlyInHeader = 80 * kPartSize;
|
||||||
constexpr auto kPartsOutsideFirstSliceGood = 8;
|
constexpr auto kPartsOutsideFirstSliceGood = 8;
|
||||||
|
@ -27,7 +27,7 @@ constexpr auto kSlicesInMemory = 2;
|
||||||
constexpr auto kPreloadPartsAhead = 8;
|
constexpr auto kPreloadPartsAhead = 8;
|
||||||
constexpr auto kDownloaderRequestsLimit = 4;
|
constexpr auto kDownloaderRequestsLimit = 4;
|
||||||
|
|
||||||
using PartsMap = base::flat_map<int, QByteArray>;
|
using PartsMap = base::flat_map<uint32, QByteArray>;
|
||||||
|
|
||||||
struct ParsedCacheEntry {
|
struct ParsedCacheEntry {
|
||||||
PartsMap parts;
|
PartsMap parts;
|
||||||
|
@ -38,11 +38,11 @@ bool IsContiguousSerialization(int serializedSize, int maxSliceSize) {
|
||||||
return !(serializedSize % kPartSize) || (serializedSize == maxSliceSize);
|
return !(serializedSize % kPartSize) || (serializedSize == maxSliceSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsFullInHeader(int size) {
|
bool IsFullInHeader(int64 size) {
|
||||||
return (size <= kMaxOnlyInHeader);
|
return (size <= kMaxOnlyInHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ComputeIsGoodHeader(int size, const PartsMap &header) {
|
bool ComputeIsGoodHeader(int64 size, const PartsMap &header) {
|
||||||
if (IsFullInHeader(size)) {
|
if (IsFullInHeader(size)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -55,11 +55,14 @@ bool ComputeIsGoodHeader(int size, const PartsMap &header) {
|
||||||
return (outsideFirstSlice <= kPartsOutsideFirstSliceGood);
|
return (outsideFirstSlice <= kPartsOutsideFirstSliceGood);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SlicesCount(int size) {
|
int SlicesCount(uint32 size) {
|
||||||
return (size + kInSlice - 1) / kInSlice;
|
const auto result = (size + kInSlice - 1) / kInSlice;
|
||||||
|
|
||||||
|
Ensures(result < 0x1FFU);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MaxSliceSize(int sliceNumber, int size) {
|
int MaxSliceSize(int sliceNumber, uint32 size) {
|
||||||
return !sliceNumber
|
return !sliceNumber
|
||||||
? size
|
? size
|
||||||
: (sliceNumber == SlicesCount(size))
|
: (sliceNumber == SlicesCount(size))
|
||||||
|
@ -71,13 +74,13 @@ bytes::const_span ParseComplexCachedMap(
|
||||||
PartsMap &result,
|
PartsMap &result,
|
||||||
bytes::const_span data,
|
bytes::const_span data,
|
||||||
int maxSize) {
|
int maxSize) {
|
||||||
const auto takeInt = [&]() -> std::optional<int> {
|
const auto takeInt = [&]() -> std::optional<uint32> {
|
||||||
if (data.size() < sizeof(int32)) {
|
if (data.size() < sizeof(uint32)) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
const auto bytes = data.data();
|
const auto bytes = data.data();
|
||||||
const auto result = *reinterpret_cast<const int32*>(bytes);
|
const auto result = *reinterpret_cast<const uint32*>(bytes);
|
||||||
data = data.subspan(sizeof(int32));
|
data = data.subspan(sizeof(uint32));
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
const auto takeBytes = [&](int count) {
|
const auto takeBytes = [&](int count) {
|
||||||
|
@ -93,18 +96,15 @@ bytes::const_span ParseComplexCachedMap(
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const auto count = *maybeCount;
|
const auto count = *maybeCount;
|
||||||
if (count < 0) {
|
if (!count || count > (kMaxOnlyInHeader / kPartSize)) {
|
||||||
return {};
|
|
||||||
} else if (!count) {
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
for (auto i = 0; i != count; ++i) {
|
for (auto i = 0; i != count; ++i) {
|
||||||
const auto offset = takeInt().value_or(0);
|
const auto offset = takeInt().value_or(0);
|
||||||
const auto size = takeInt().value_or(0);
|
const auto size = takeInt().value_or(0);
|
||||||
const auto bytes = takeBytes(size);
|
const auto bytes = takeBytes(size);
|
||||||
if (offset < 0
|
if (offset >= maxSize
|
||||||
|| offset >= maxSize
|
|| !size
|
||||||
|| size <= 0
|
|
||||||
|| size > maxSize
|
|| size > maxSize
|
||||||
|| offset + size > maxSize
|
|| offset + size > maxSize
|
||||||
|| bytes.size() != size) {
|
|| bytes.size() != size) {
|
||||||
|
@ -132,7 +132,7 @@ bytes::const_span ParseCachedMap(
|
||||||
offset,
|
offset,
|
||||||
std::min(kPartSize, size - offset));
|
std::min(kPartSize, size - offset));
|
||||||
result.try_emplace(
|
result.try_emplace(
|
||||||
offset,
|
uint32(offset),
|
||||||
reinterpret_cast<const char*>(part.data()),
|
reinterpret_cast<const char*>(part.data()),
|
||||||
part.size());
|
part.size());
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ bytes::const_span ParseCachedMap(
|
||||||
ParsedCacheEntry ParseCacheEntry(
|
ParsedCacheEntry ParseCacheEntry(
|
||||||
bytes::const_span data,
|
bytes::const_span data,
|
||||||
int sliceNumber,
|
int sliceNumber,
|
||||||
int size) {
|
int64 size) {
|
||||||
auto result = ParsedCacheEntry();
|
auto result = ParsedCacheEntry();
|
||||||
const auto remaining = ParseCachedMap(
|
const auto remaining = ParseCachedMap(
|
||||||
result.parts,
|
result.parts,
|
||||||
|
@ -158,7 +158,7 @@ ParsedCacheEntry ParseCacheEntry(
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Range> // Range::value_type is Pair<int, QByteArray>
|
template <typename Range> // Range::value_type is Pair<int, QByteArray>
|
||||||
int FindNotLoadedStart(Range &&parts, int offset) {
|
uint32 FindNotLoadedStart(Range &&parts, uint32 offset) {
|
||||||
auto result = offset;
|
auto result = offset;
|
||||||
for (const auto &part : parts) {
|
for (const auto &part : parts) {
|
||||||
const auto partStart = part.first;
|
const auto partStart = part.first;
|
||||||
|
@ -172,13 +172,17 @@ int FindNotLoadedStart(Range &&parts, int offset) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Range> // Range::value_type is Pair<int, QByteArray>
|
template <typename Range> // Range::value_type is Pair<uint32, QByteArray>
|
||||||
void CopyLoaded(bytes::span buffer, Range &&parts, int offset, int till) {
|
void CopyLoaded(
|
||||||
|
bytes::span buffer,
|
||||||
|
Range &&parts,
|
||||||
|
uint32 offset,
|
||||||
|
uint32 till) {
|
||||||
auto filled = offset;
|
auto filled = offset;
|
||||||
for (const auto &part : parts) {
|
for (const auto &part : parts) {
|
||||||
const auto bytes = bytes::make_span(part.second);
|
const auto bytes = bytes::make_span(part.second);
|
||||||
const auto partStart = part.first;
|
const auto partStart = part.first;
|
||||||
const auto partEnd = int(partStart + bytes.size());
|
const auto partEnd = uint32(partStart + bytes.size());
|
||||||
const auto copyTill = std::min(partEnd, till);
|
const auto copyTill = std::min(partEnd, till);
|
||||||
Assert(partStart <= filled && filled < copyTill);
|
Assert(partStart <= filled && filled < copyTill);
|
||||||
|
|
||||||
|
@ -193,10 +197,10 @@ void CopyLoaded(bytes::span buffer, Range &&parts, int offset, int till) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
template <int Size>
|
template <int Size>
|
||||||
bool Reader::StackIntVector<Size>::add(int value) {
|
bool Reader::StackIntVector<Size>::add(uint32 value) {
|
||||||
using namespace rpl::mappers;
|
using namespace rpl::mappers;
|
||||||
|
|
||||||
const auto i = ranges::find_if(_storage, _1 < 0);
|
const auto i = ranges::find_if(_storage, _1 == uint32(-1));
|
||||||
if (i == end(_storage)) {
|
if (i == end(_storage)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -212,7 +216,9 @@ template <int Size>
|
||||||
auto Reader::StackIntVector<Size>::values() const {
|
auto Reader::StackIntVector<Size>::values() const {
|
||||||
using namespace rpl::mappers;
|
using namespace rpl::mappers;
|
||||||
|
|
||||||
return ranges::views::all(_storage) | ranges::views::take_while(_1 >= 0);
|
return ranges::views::all(
|
||||||
|
_storage
|
||||||
|
) | ranges::views::take_while(_1 != uint32(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Reader::CacheHelper {
|
struct Reader::CacheHelper {
|
||||||
|
@ -223,7 +229,7 @@ struct Reader::CacheHelper {
|
||||||
const Storage::Cache::Key baseKey;
|
const Storage::Cache::Key baseKey;
|
||||||
|
|
||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
base::flat_map<int, PartsMap> results;
|
base::flat_map<uint32, PartsMap> results;
|
||||||
std::vector<int> sizes;
|
std::vector<int> sizes;
|
||||||
std::atomic<crl::semaphore*> waiting = nullptr;
|
std::atomic<crl::semaphore*> waiting = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -253,7 +259,7 @@ void Reader::Slice::processCacheData(PartsMap &&data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reader::Slice::addPart(int offset, QByteArray bytes) {
|
void Reader::Slice::addPart(uint32 offset, QByteArray bytes) {
|
||||||
Expects(!parts.contains(offset));
|
Expects(!parts.contains(offset));
|
||||||
|
|
||||||
parts.emplace(offset, std::move(bytes));
|
parts.emplace(offset, std::move(bytes));
|
||||||
|
@ -262,7 +268,9 @@ void Reader::Slice::addPart(int offset, QByteArray bytes) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Reader::Slice::prepareFill(int from, int till) -> PrepareFillResult {
|
auto Reader::Slice::prepareFill(
|
||||||
|
uint32 from,
|
||||||
|
uint32 till) -> PrepareFillResult {
|
||||||
auto result = PrepareFillResult();
|
auto result = PrepareFillResult();
|
||||||
|
|
||||||
result.ready = false;
|
result.ready = false;
|
||||||
|
@ -308,7 +316,7 @@ auto Reader::Slice::prepareFill(int from, int till) -> PrepareFillResult {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Reader::Slice::offsetsFromLoader(int from, int till) const
|
auto Reader::Slice::offsetsFromLoader(uint32 from, uint32 till) const
|
||||||
-> StackIntVector<Reader::kLoadFromRemoteMax> {
|
-> StackIntVector<Reader::kLoadFromRemoteMax> {
|
||||||
auto result = StackIntVector<kLoadFromRemoteMax>();
|
auto result = StackIntVector<kLoadFromRemoteMax>();
|
||||||
|
|
||||||
|
@ -332,7 +340,7 @@ auto Reader::Slice::offsetsFromLoader(int from, int till) const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Reader::Slices::Slices(int size, bool useCache)
|
Reader::Slices::Slices(uint32 size, bool useCache)
|
||||||
: _size(size) {
|
: _size(size) {
|
||||||
Expects(size > 0);
|
Expects(size > 0);
|
||||||
|
|
||||||
|
@ -406,7 +414,7 @@ void Reader::Slices::applyHeaderCacheData() {
|
||||||
|
|
||||||
const auto applyWhile = [&](auto &&predicate) {
|
const auto applyWhile = [&](auto &&predicate) {
|
||||||
for (const auto &[offset, part] : _header.parts) {
|
for (const auto &[offset, part] : _header.parts) {
|
||||||
const auto index = offset / kInSlice;
|
const auto index = int(offset / kInSlice);
|
||||||
if (!predicate(index)) {
|
if (!predicate(index)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -520,7 +528,7 @@ bool Reader::Slices::checkFullInCache() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reader::Slices::processPart(
|
void Reader::Slices::processPart(
|
||||||
int offset,
|
uint32 offset,
|
||||||
QByteArray &&bytes) {
|
QByteArray &&bytes) {
|
||||||
Expects(isFullInHeader() || (offset / kInSlice < _data.size()));
|
Expects(isFullInHeader() || (offset / kInSlice < _data.size()));
|
||||||
|
|
||||||
|
@ -540,7 +548,7 @@ void Reader::Slices::processPart(
|
||||||
checkSliceFullLoaded(index + 1);
|
checkSliceFullLoaded(index + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Reader::Slices::fill(int offset, bytes::span buffer) -> FillResult {
|
auto Reader::Slices::fill(uint32 offset, bytes::span buffer) -> FillResult {
|
||||||
Expects(!buffer.empty());
|
Expects(!buffer.empty());
|
||||||
Expects(offset >= 0 && offset < _size);
|
Expects(offset >= 0 && offset < _size);
|
||||||
Expects(offset + buffer.size() <= _size);
|
Expects(offset + buffer.size() <= _size);
|
||||||
|
@ -558,7 +566,7 @@ auto Reader::Slices::fill(int offset, bytes::span buffer) -> FillResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto result = FillResult();
|
auto result = FillResult();
|
||||||
const auto till = int(offset + buffer.size());
|
const auto till = uint32(offset + buffer.size());
|
||||||
const auto fromSlice = offset / kInSlice;
|
const auto fromSlice = offset / kInSlice;
|
||||||
const auto tillSlice = (till + kInSlice - 1) / kInSlice;
|
const auto tillSlice = (till + kInSlice - 1) / kInSlice;
|
||||||
Assert(fromSlice >= 0
|
Assert(fromSlice >= 0
|
||||||
|
@ -595,7 +603,9 @@ auto Reader::Slices::fill(int offset, bytes::span buffer) -> FillResult {
|
||||||
const auto firstFrom = offset - fromSlice * kInSlice;
|
const auto firstFrom = offset - fromSlice * kInSlice;
|
||||||
const auto firstTill = std::min(kInSlice, till - fromSlice * kInSlice);
|
const auto firstTill = std::min(kInSlice, till - fromSlice * kInSlice);
|
||||||
const auto secondFrom = 0;
|
const auto secondFrom = 0;
|
||||||
const auto secondTill = till - (fromSlice + 1) * kInSlice;
|
const auto secondTill = (till > (fromSlice + 1) * kInSlice)
|
||||||
|
? (till - (fromSlice + 1) * kInSlice)
|
||||||
|
: 0;
|
||||||
const auto first = _data[fromSlice].prepareFill(firstFrom, firstTill);
|
const auto first = _data[fromSlice].prepareFill(firstFrom, firstTill);
|
||||||
const auto second = (fromSlice + 1 < tillSlice)
|
const auto second = (fromSlice + 1 < tillSlice)
|
||||||
? _data[fromSlice + 1].prepareFill(secondFrom, secondTill)
|
? _data[fromSlice + 1].prepareFill(secondFrom, secondTill)
|
||||||
|
@ -630,11 +640,11 @@ auto Reader::Slices::fill(int offset, bytes::span buffer) -> FillResult {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Reader::Slices::fillFromHeader(int offset, bytes::span buffer)
|
auto Reader::Slices::fillFromHeader(uint32 offset, bytes::span buffer)
|
||||||
-> FillResult {
|
-> FillResult {
|
||||||
auto result = FillResult();
|
auto result = FillResult();
|
||||||
const auto from = offset;
|
const auto from = offset;
|
||||||
const auto till = int(offset + buffer.size());
|
const auto till = uint32(offset + buffer.size());
|
||||||
|
|
||||||
const auto prepared = _header.prepareFill(from, till);
|
const auto prepared = _header.prepareFill(from, till);
|
||||||
for (const auto full : prepared.offsetsFromLoader.values()) {
|
for (const auto full : prepared.offsetsFromLoader.values()) {
|
||||||
|
@ -653,7 +663,7 @@ auto Reader::Slices::fillFromHeader(int offset, bytes::span buffer)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray Reader::Slices::partForDownloader(int offset) const {
|
QByteArray Reader::Slices::partForDownloader(uint32 offset) const {
|
||||||
Expects(offset < _size);
|
Expects(offset < _size);
|
||||||
|
|
||||||
if (const auto i = _header.parts.find(offset); i != end(_header.parts)) {
|
if (const auto i = _header.parts.find(offset); i != end(_header.parts)) {
|
||||||
|
@ -671,7 +681,7 @@ bool Reader::Slices::waitingForHeaderCache() const {
|
||||||
return (_header.flags & Slice::Flag::LoadingFromCache);
|
return (_header.flags & Slice::Flag::LoadingFromCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Reader::Slices::readCacheForDownloaderRequired(int offset) {
|
bool Reader::Slices::readCacheForDownloaderRequired(uint32 offset) {
|
||||||
Expects(offset < _size);
|
Expects(offset < _size);
|
||||||
Expects(!waitingForHeaderCache());
|
Expects(!waitingForHeaderCache());
|
||||||
|
|
||||||
|
@ -924,7 +934,9 @@ rpl::producer<LoadedPart> Reader::partsForDownloader() const {
|
||||||
|
|
||||||
void Reader::loadForDownloader(
|
void Reader::loadForDownloader(
|
||||||
not_null<Storage::StreamedFileDownloader*> downloader,
|
not_null<Storage::StreamedFileDownloader*> downloader,
|
||||||
int offset) {
|
int64 offset) {
|
||||||
|
Expects(offset >= 0 && offset <= std::numeric_limits<uint32>::max());
|
||||||
|
|
||||||
if (_attachedDownloader != downloader) {
|
if (_attachedDownloader != downloader) {
|
||||||
if (_attachedDownloader) {
|
if (_attachedDownloader) {
|
||||||
cancelForDownloader(_attachedDownloader);
|
cancelForDownloader(_attachedDownloader);
|
||||||
|
@ -932,7 +944,7 @@ void Reader::loadForDownloader(
|
||||||
_attachedDownloader = downloader;
|
_attachedDownloader = downloader;
|
||||||
_loader->attachDownloader(downloader);
|
_loader->attachDownloader(downloader);
|
||||||
}
|
}
|
||||||
_downloaderOffsetRequests.emplace(offset);
|
_downloaderOffsetRequests.emplace(uint32(offset));
|
||||||
if (_streamingActive) {
|
if (_streamingActive) {
|
||||||
wakeFromSleep();
|
wakeFromSleep();
|
||||||
} else {
|
} else {
|
||||||
|
@ -940,7 +952,9 @@ void Reader::loadForDownloader(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reader::doneForDownloader(int offset) {
|
void Reader::doneForDownloader(int64 offset) {
|
||||||
|
Expects(offset >= 0 && offset <= std::numeric_limits<uint32>::max());
|
||||||
|
|
||||||
_downloaderOffsetAcks.emplace(offset);
|
_downloaderOffsetAcks.emplace(offset);
|
||||||
if (!_streamingActive) {
|
if (!_streamingActive) {
|
||||||
processDownloaderRequests();
|
processDownloaderRequests();
|
||||||
|
@ -994,16 +1008,16 @@ void Reader::checkForDownloaderChange(int checkItemsCount) {
|
||||||
void Reader::checkForDownloaderReadyOffsets() {
|
void Reader::checkForDownloaderReadyOffsets() {
|
||||||
// If a requested part is available right now we simply fire it on the
|
// If a requested part is available right now we simply fire it on the
|
||||||
// main thread, until the first not-available-right-now offset is found.
|
// main thread, until the first not-available-right-now offset is found.
|
||||||
const auto unavailableInBytes = [&](int offset, QByteArray &&bytes) {
|
const auto unavailableInBytes = [&](uint32 offset, QByteArray &&bytes) {
|
||||||
if (bytes.isEmpty()) {
|
if (bytes.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
crl::on_main(this, [=, bytes = std::move(bytes)]() mutable {
|
crl::on_main(this, [=, bytes = std::move(bytes)]() mutable {
|
||||||
_partsForDownloader.fire({ offset, std::move(bytes) });
|
_partsForDownloader.fire({ int64(offset), std::move(bytes) });
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
const auto unavailableInCache = [&](int offset) {
|
const auto unavailableInCache = [&](uint32 offset) {
|
||||||
const auto index = (offset / kInSlice);
|
const auto index = (offset / kInSlice);
|
||||||
const auto sliceNumber = index + 1;
|
const auto sliceNumber = index + 1;
|
||||||
const auto i = _downloaderReadCache.find(sliceNumber);
|
const auto i = _downloaderReadCache.find(sliceNumber);
|
||||||
|
@ -1016,7 +1030,7 @@ void Reader::checkForDownloaderReadyOffsets() {
|
||||||
}
|
}
|
||||||
return unavailableInBytes(offset, std::move(j->second));
|
return unavailableInBytes(offset, std::move(j->second));
|
||||||
};
|
};
|
||||||
const auto unavailable = [&](int offset) {
|
const auto unavailable = [&](uint32 offset) {
|
||||||
return unavailableInBytes(offset, _slices.partForDownloader(offset))
|
return unavailableInBytes(offset, _slices.partForDownloader(offset))
|
||||||
&& unavailableInCache(offset);
|
&& unavailableInCache(offset);
|
||||||
};
|
};
|
||||||
|
@ -1036,13 +1050,13 @@ void Reader::processDownloaderRequests() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reader::pruneDownloaderCache(int minimalOffset) {
|
void Reader::pruneDownloaderCache(uint32 minimalOffset) {
|
||||||
const auto minimalSliceNumber = (minimalOffset / kInSlice) + 1;
|
const auto minimalSliceNumber = (minimalOffset / kInSlice) + 1;
|
||||||
const auto removeTill = ranges::lower_bound(
|
const auto removeTill = ranges::lower_bound(
|
||||||
_downloaderReadCache,
|
_downloaderReadCache,
|
||||||
minimalSliceNumber,
|
minimalSliceNumber,
|
||||||
ranges::less(),
|
ranges::less(),
|
||||||
&base::flat_map<int, std::optional<PartsMap>>::value_type::first);
|
&base::flat_map<uint32, std::optional<PartsMap>>::value_type::first);
|
||||||
_downloaderReadCache.erase(_downloaderReadCache.begin(), removeTill);
|
_downloaderReadCache.erase(_downloaderReadCache.begin(), removeTill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1068,7 +1082,7 @@ void Reader::sendDownloaderRequests() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Reader::downloaderWaitForCachedSlice(int offset) {
|
bool Reader::downloaderWaitForCachedSlice(uint32 offset) {
|
||||||
if (_slices.waitingForHeaderCache()) {
|
if (_slices.waitingForHeaderCache()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1191,7 +1205,7 @@ void Reader::putToCache(SerializedSlice &&slice) {
|
||||||
_cache->put(_cacheHelper->key(slice.number), std::move(slice.data));
|
_cache->put(_cacheHelper->key(slice.number), std::move(slice.data));
|
||||||
}
|
}
|
||||||
|
|
||||||
int Reader::size() const {
|
int64 Reader::size() const {
|
||||||
return _loader->size();
|
return _loader->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1212,10 +1226,11 @@ bool Reader::fullInCache() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
Reader::FillState Reader::fill(
|
Reader::FillState Reader::fill(
|
||||||
int offset,
|
int64 offset,
|
||||||
bytes::span buffer,
|
bytes::span buffer,
|
||||||
not_null<crl::semaphore*> notify) {
|
not_null<crl::semaphore*> notify) {
|
||||||
Expects(offset + buffer.size() <= size());
|
Expects(offset + buffer.size() <= size());
|
||||||
|
Expects(offset >= 0 && size() <= std::numeric_limits<uint32>::max());
|
||||||
|
|
||||||
const auto startWaiting = [&] {
|
const auto startWaiting = [&] {
|
||||||
if (_cacheHelper) {
|
if (_cacheHelper) {
|
||||||
|
@ -1246,7 +1261,7 @@ Reader::FillState Reader::fill(
|
||||||
|
|
||||||
auto lastResult = FillState();
|
auto lastResult = FillState();
|
||||||
do {
|
do {
|
||||||
lastResult = fillFromSlices(offset, buffer);
|
lastResult = fillFromSlices(uint32(offset), buffer);
|
||||||
if (lastResult == FillState::Success) {
|
if (lastResult == FillState::Success) {
|
||||||
return done();
|
return done();
|
||||||
}
|
}
|
||||||
|
@ -1256,7 +1271,7 @@ Reader::FillState Reader::fill(
|
||||||
return _streamingError ? failed() : lastResult;
|
return _streamingError ? failed() : lastResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
Reader::FillState Reader::fillFromSlices(int offset, bytes::span buffer) {
|
Reader::FillState Reader::fillFromSlices(uint32 offset, bytes::span buffer) {
|
||||||
using namespace rpl::mappers;
|
using namespace rpl::mappers;
|
||||||
|
|
||||||
auto result = _slices.fill(offset, buffer);
|
auto result = _slices.fill(offset, buffer);
|
||||||
|
@ -1289,7 +1304,7 @@ Reader::FillState Reader::fillFromSlices(int offset, bytes::span buffer) {
|
||||||
return result.state;
|
return result.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reader::cancelLoadInRange(int from, int till) {
|
void Reader::cancelLoadInRange(uint32 from, uint32 till) {
|
||||||
Expects(from < till);
|
Expects(from < till);
|
||||||
|
|
||||||
for (const auto offset : _loadingOffsets.takeInRange(from, till)) {
|
for (const auto offset : _loadingOffsets.takeInRange(from, till)) {
|
||||||
|
@ -1299,7 +1314,7 @@ void Reader::cancelLoadInRange(int from, int till) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reader::checkLoadWillBeFirst(int offset) {
|
void Reader::checkLoadWillBeFirst(uint32 offset) {
|
||||||
if (_loadingOffsets.front().value_or(offset) != offset) {
|
if (_loadingOffsets.front().value_or(offset) != offset) {
|
||||||
_loadingOffsets.resetPriorities();
|
_loadingOffsets.resetPriorities();
|
||||||
_loader->resetPriorities();
|
_loader->resetPriorities();
|
||||||
|
@ -1369,7 +1384,7 @@ bool Reader::checkForSomethingMoreReceived() {
|
||||||
return result1 || result2;
|
return result1 || result2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reader::loadAtOffset(int offset) {
|
void Reader::loadAtOffset(uint32 offset) {
|
||||||
if (_loadingOffsets.add(offset)) {
|
if (_loadingOffsets.add(offset)) {
|
||||||
_loader->load(offset);
|
_loader->load(offset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,12 +47,12 @@ public:
|
||||||
void setLoaderPriority(int priority);
|
void setLoaderPriority(int priority);
|
||||||
|
|
||||||
// Any thread.
|
// Any thread.
|
||||||
[[nodiscard]] int size() const;
|
[[nodiscard]] int64 size() const;
|
||||||
[[nodiscard]] bool isRemoteLoader() const;
|
[[nodiscard]] bool isRemoteLoader() const;
|
||||||
|
|
||||||
// Single thread.
|
// Single thread.
|
||||||
[[nodiscard]] FillState fill(
|
[[nodiscard]] FillState fill(
|
||||||
int offset,
|
int64 offset,
|
||||||
bytes::span buffer,
|
bytes::span buffer,
|
||||||
not_null<crl::semaphore*> notify);
|
not_null<crl::semaphore*> notify);
|
||||||
[[nodiscard]] std::optional<Error> streamingError() const;
|
[[nodiscard]] std::optional<Error> streamingError() const;
|
||||||
|
@ -73,8 +73,8 @@ public:
|
||||||
[[nodiscard]] rpl::producer<LoadedPart> partsForDownloader() const;
|
[[nodiscard]] rpl::producer<LoadedPart> partsForDownloader() const;
|
||||||
void loadForDownloader(
|
void loadForDownloader(
|
||||||
not_null<Storage::StreamedFileDownloader*> downloader,
|
not_null<Storage::StreamedFileDownloader*> downloader,
|
||||||
int offset);
|
int64 offset);
|
||||||
void doneForDownloader(int offset);
|
void doneForDownloader(int64 offset);
|
||||||
void cancelForDownloader(
|
void cancelForDownloader(
|
||||||
not_null<Storage::StreamedFileDownloader*> downloader);
|
not_null<Storage::StreamedFileDownloader*> downloader);
|
||||||
|
|
||||||
|
@ -85,16 +85,18 @@ private:
|
||||||
|
|
||||||
struct CacheHelper;
|
struct CacheHelper;
|
||||||
|
|
||||||
using PartsMap = base::flat_map<int, QByteArray>;
|
// FileSize: Right now any file size fits 32 bit.
|
||||||
|
|
||||||
|
using PartsMap = base::flat_map<uint32, QByteArray>;
|
||||||
|
|
||||||
template <int Size>
|
template <int Size>
|
||||||
class StackIntVector {
|
class StackIntVector {
|
||||||
public:
|
public:
|
||||||
bool add(int value);
|
bool add(uint32 value);
|
||||||
auto values() const;
|
auto values() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::array<int, Size> _storage = { -1 };
|
std::array<uint32, Size> _storage = { uint32(-1) };
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -128,13 +130,13 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
void processCacheData(PartsMap &&data);
|
void processCacheData(PartsMap &&data);
|
||||||
void addPart(int offset, QByteArray bytes);
|
void addPart(uint32 offset, QByteArray bytes);
|
||||||
PrepareFillResult prepareFill(int from, int till);
|
PrepareFillResult prepareFill(uint32 from, uint32 till);
|
||||||
|
|
||||||
// Get up to kLoadFromRemoteMax not loaded parts in from-till range.
|
// Get up to kLoadFromRemoteMax not loaded parts in from-till range.
|
||||||
StackIntVector<kLoadFromRemoteMax> offsetsFromLoader(
|
StackIntVector<kLoadFromRemoteMax> offsetsFromLoader(
|
||||||
int from,
|
uint32 from,
|
||||||
int till) const;
|
uint32 till) const;
|
||||||
|
|
||||||
PartsMap parts;
|
PartsMap parts;
|
||||||
Flags flags;
|
Flags flags;
|
||||||
|
@ -143,7 +145,7 @@ private:
|
||||||
|
|
||||||
class Slices {
|
class Slices {
|
||||||
public:
|
public:
|
||||||
Slices(int size, bool useCache);
|
Slices(uint32 size, bool useCache);
|
||||||
|
|
||||||
void headerDone(bool fromCache);
|
void headerDone(bool fromCache);
|
||||||
[[nodiscard]] int headerSize() const;
|
[[nodiscard]] int headerSize() const;
|
||||||
|
@ -158,13 +160,13 @@ private:
|
||||||
|
|
||||||
void processCacheResult(int sliceNumber, PartsMap &&result);
|
void processCacheResult(int sliceNumber, PartsMap &&result);
|
||||||
void processCachedSizes(const std::vector<int> &sizes);
|
void processCachedSizes(const std::vector<int> &sizes);
|
||||||
void processPart(int offset, QByteArray &&bytes);
|
void processPart(uint32 offset, QByteArray &&bytes);
|
||||||
|
|
||||||
[[nodiscard]] FillResult fill(int offset, bytes::span buffer);
|
[[nodiscard]] FillResult fill(uint32 offset, bytes::span buffer);
|
||||||
[[nodiscard]] SerializedSlice unloadToCache();
|
[[nodiscard]] SerializedSlice unloadToCache();
|
||||||
|
|
||||||
[[nodiscard]] QByteArray partForDownloader(int offset) const;
|
[[nodiscard]] QByteArray partForDownloader(uint32 offset) const;
|
||||||
[[nodiscard]] bool readCacheForDownloaderRequired(int offset);
|
[[nodiscard]] bool readCacheForDownloaderRequired(uint32 offset);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class HeaderMode {
|
enum class HeaderMode {
|
||||||
|
@ -186,7 +188,7 @@ private:
|
||||||
void markSliceUsed(int sliceIndex);
|
void markSliceUsed(int sliceIndex);
|
||||||
[[nodiscard]] bool computeIsGoodHeader() const;
|
[[nodiscard]] bool computeIsGoodHeader() const;
|
||||||
[[nodiscard]] FillResult fillFromHeader(
|
[[nodiscard]] FillResult fillFromHeader(
|
||||||
int offset,
|
uint32 offset,
|
||||||
bytes::span buffer);
|
bytes::span buffer);
|
||||||
void unloadSlice(Slice &slice) const;
|
void unloadSlice(Slice &slice) const;
|
||||||
void checkSliceFullLoaded(int sliceNumber);
|
void checkSliceFullLoaded(int sliceNumber);
|
||||||
|
@ -195,7 +197,7 @@ private:
|
||||||
std::vector<Slice> _data;
|
std::vector<Slice> _data;
|
||||||
Slice _header;
|
Slice _header;
|
||||||
std::deque<int> _usedSlices;
|
std::deque<int> _usedSlices;
|
||||||
int _size = 0;
|
uint32 _size = 0;
|
||||||
HeaderMode _headerMode = HeaderMode::Unknown;
|
HeaderMode _headerMode = HeaderMode::Unknown;
|
||||||
bool _fullInCache = false;
|
bool _fullInCache = false;
|
||||||
|
|
||||||
|
@ -208,23 +210,23 @@ private:
|
||||||
bool processCacheResults();
|
bool processCacheResults();
|
||||||
void putToCache(SerializedSlice &&data);
|
void putToCache(SerializedSlice &&data);
|
||||||
|
|
||||||
void cancelLoadInRange(int from, int till);
|
void cancelLoadInRange(uint32 from, uint32 till);
|
||||||
void loadAtOffset(int offset);
|
void loadAtOffset(uint32 offset);
|
||||||
void checkLoadWillBeFirst(int offset);
|
void checkLoadWillBeFirst(uint32 offset);
|
||||||
bool processLoadedParts();
|
bool processLoadedParts();
|
||||||
|
|
||||||
bool checkForSomethingMoreReceived();
|
bool checkForSomethingMoreReceived();
|
||||||
|
|
||||||
FillState fillFromSlices(int offset, bytes::span buffer);
|
FillState fillFromSlices(uint32 offset, bytes::span buffer);
|
||||||
|
|
||||||
void finalizeCache();
|
void finalizeCache();
|
||||||
|
|
||||||
void processDownloaderRequests();
|
void processDownloaderRequests();
|
||||||
void checkCacheResultsForDownloader();
|
void checkCacheResultsForDownloader();
|
||||||
void pruneDownloaderCache(int minimalOffset);
|
void pruneDownloaderCache(uint32 minimalOffset);
|
||||||
void pruneDoneDownloaderRequests();
|
void pruneDoneDownloaderRequests();
|
||||||
void sendDownloaderRequests();
|
void sendDownloaderRequests();
|
||||||
[[nodiscard]] bool downloaderWaitForCachedSlice(int offset);
|
[[nodiscard]] bool downloaderWaitForCachedSlice(uint32 offset);
|
||||||
void enqueueDownloaderOffsets();
|
void enqueueDownloaderOffsets();
|
||||||
void checkForDownloaderChange(int checkItemsCount);
|
void checkForDownloaderChange(int checkItemsCount);
|
||||||
void checkForDownloaderReadyOffsets();
|
void checkForDownloaderReadyOffsets();
|
||||||
|
@ -261,14 +263,14 @@ private:
|
||||||
bool _streamingActive = false;
|
bool _streamingActive = false;
|
||||||
|
|
||||||
// Streaming thread.
|
// Streaming thread.
|
||||||
std::deque<int> _offsetsForDownloader;
|
std::deque<uint32> _offsetsForDownloader;
|
||||||
base::flat_set<int> _downloaderOffsetsRequested;
|
base::flat_set<uint32> _downloaderOffsetsRequested;
|
||||||
base::flat_map<int, std::optional<PartsMap>> _downloaderReadCache;
|
base::flat_map<uint32, std::optional<PartsMap>> _downloaderReadCache;
|
||||||
|
|
||||||
// Communication from main thread to streaming thread.
|
// Communication from main thread to streaming thread.
|
||||||
// Streaming thread to main thread communicates using crl::on_main.
|
// Streaming thread to main thread communicates using crl::on_main.
|
||||||
base::thread_safe_queue<int> _downloaderOffsetRequests;
|
base::thread_safe_queue<uint32> _downloaderOffsetRequests;
|
||||||
base::thread_safe_queue<int> _downloaderOffsetAcks;
|
base::thread_safe_queue<uint32> _downloaderOffsetAcks;
|
||||||
|
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
|
|
|
@ -693,7 +693,7 @@ void OverlayWidget::documentUpdated(not_null<DocumentData*> document) {
|
||||||
const auto ready = _documentMedia->loaded()
|
const auto ready = _documentMedia->loaded()
|
||||||
? _document->size
|
? _document->size
|
||||||
: _document->loading()
|
: _document->loading()
|
||||||
? std::clamp(_document->loadOffset(), 0, _document->size)
|
? std::clamp(_document->loadOffset(), int64(), _document->size)
|
||||||
: 0;
|
: 0;
|
||||||
_streamed->controls.setLoadingProgress(ready, _document->size);
|
_streamed->controls.setLoadingProgress(ready, _document->size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,7 +425,7 @@ float64 PlaybackControls::countDownloadedTillPercent(
|
||||||
return (_loadingReady - header) / float64(_loadingTotal - header);
|
return (_loadingReady - header) / float64(_loadingTotal - header);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaybackControls::setLoadingProgress(int ready, int total) {
|
void PlaybackControls::setLoadingProgress(int64 ready, int64 total) {
|
||||||
if (_loadingReady == ready && _loadingTotal == total) {
|
if (_loadingReady == ready && _loadingTotal == total) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public:
|
||||||
void hideAnimated();
|
void hideAnimated();
|
||||||
|
|
||||||
void updatePlayback(const Player::TrackState &state);
|
void updatePlayback(const Player::TrackState &state);
|
||||||
void setLoadingProgress(int ready, int total);
|
void setLoadingProgress(int64 ready, int64 total);
|
||||||
void setInFullScreen(bool inFullScreen);
|
void setInFullScreen(bool inFullScreen);
|
||||||
[[nodiscard]] bool hasMenu() const;
|
[[nodiscard]] bool hasMenu() const;
|
||||||
|
|
||||||
|
@ -95,8 +95,8 @@ private:
|
||||||
QString _timeAlready, _timeLeft;
|
QString _timeAlready, _timeLeft;
|
||||||
crl::time _seekPositionMs = -1;
|
crl::time _seekPositionMs = -1;
|
||||||
crl::time _lastDurationMs = 0;
|
crl::time _lastDurationMs = 0;
|
||||||
int _loadingReady = 0;
|
int64 _loadingReady = 0;
|
||||||
int _loadingTotal = 0;
|
int64 _loadingTotal = 0;
|
||||||
int _loadingPercent = 0;
|
int _loadingPercent = 0;
|
||||||
|
|
||||||
object_ptr<Ui::IconButton> _playPauseResume;
|
object_ptr<Ui::IconButton> _playPauseResume;
|
||||||
|
|
|
@ -67,7 +67,7 @@ std::optional<DedicatedLoader::File> ParseFile(
|
||||||
LOG(("Update Error: MTP file name not found."));
|
LOG(("Update Error: MTP file name not found."));
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
const auto size = fields.vsize().v;
|
const auto size = int64(fields.vsize().v);
|
||||||
if (size <= 0) {
|
if (size <= 0) {
|
||||||
LOG(("Update Error: MTP file size is invalid."));
|
LOG(("Update Error: MTP file size is invalid."));
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
@ -171,12 +171,12 @@ void AbstractDedicatedLoader::start() {
|
||||||
startLoading();
|
startLoading();
|
||||||
}
|
}
|
||||||
|
|
||||||
int AbstractDedicatedLoader::alreadySize() const {
|
int64 AbstractDedicatedLoader::alreadySize() const {
|
||||||
QMutexLocker lock(&_sizesMutex);
|
QMutexLocker lock(&_sizesMutex);
|
||||||
return _alreadySize;
|
return _alreadySize;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AbstractDedicatedLoader::totalSize() const {
|
int64 AbstractDedicatedLoader::totalSize() const {
|
||||||
QMutexLocker lock(&_sizesMutex);
|
QMutexLocker lock(&_sizesMutex);
|
||||||
return _totalSize;
|
return _totalSize;
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ bool AbstractDedicatedLoader::validateOutput() {
|
||||||
if (fullSize < _chunkSize || fullSize > kMaxFileSize) {
|
if (fullSize < _chunkSize || fullSize > kMaxFileSize) {
|
||||||
return _output.remove();
|
return _output.remove();
|
||||||
}
|
}
|
||||||
const auto goodSize = int((fullSize % _chunkSize)
|
const auto goodSize = int64((fullSize % _chunkSize)
|
||||||
? (fullSize - (fullSize % _chunkSize))
|
? (fullSize - (fullSize % _chunkSize))
|
||||||
: fullSize);
|
: fullSize);
|
||||||
if (_output.resize(goodSize)) {
|
if (_output.resize(goodSize)) {
|
||||||
|
@ -319,7 +319,7 @@ void DedicatedLoader::sendRequest() {
|
||||||
MTPupload_GetFile(
|
MTPupload_GetFile(
|
||||||
MTP_flags(0),
|
MTP_flags(0),
|
||||||
_location,
|
_location,
|
||||||
MTP_int(offset),
|
MTP_long(offset),
|
||||||
MTP_int(kChunkSize)),
|
MTP_int(kChunkSize)),
|
||||||
[=](const MTPupload_File &result) { gotPart(offset, result); },
|
[=](const MTPupload_File &result) { gotPart(offset, result); },
|
||||||
failHandler(),
|
failHandler(),
|
||||||
|
|
|
@ -52,8 +52,8 @@ public:
|
||||||
static constexpr auto kMaxFileSize = 256 * 1024 * 1024;
|
static constexpr auto kMaxFileSize = 256 * 1024 * 1024;
|
||||||
|
|
||||||
struct Progress {
|
struct Progress {
|
||||||
int64 already;
|
int64 already = 0;
|
||||||
int64 size;
|
int64 size = 0;
|
||||||
|
|
||||||
inline bool operator<(const Progress &other) const {
|
inline bool operator<(const Progress &other) const {
|
||||||
return (already < other.already)
|
return (already < other.already)
|
||||||
|
@ -68,8 +68,8 @@ public:
|
||||||
void wipeFolder();
|
void wipeFolder();
|
||||||
void wipeOutput();
|
void wipeOutput();
|
||||||
|
|
||||||
int alreadySize() const;
|
int64 alreadySize() const;
|
||||||
int totalSize() const;
|
int64 totalSize() const;
|
||||||
|
|
||||||
rpl::producer<Progress> progress() const;
|
rpl::producer<Progress> progress() const;
|
||||||
rpl::producer<QString> ready() const;
|
rpl::producer<QString> ready() const;
|
||||||
|
@ -96,8 +96,8 @@ private:
|
||||||
int _chunkSize = 0;
|
int _chunkSize = 0;
|
||||||
|
|
||||||
QFile _output;
|
QFile _output;
|
||||||
int _alreadySize = 0;
|
int64 _alreadySize = 0;
|
||||||
int _totalSize = 0;
|
int64 _totalSize = 0;
|
||||||
mutable QMutex _sizesMutex;
|
mutable QMutex _sizesMutex;
|
||||||
rpl::event_stream<Progress> _progress;
|
rpl::event_stream<Progress> _progress;
|
||||||
rpl::event_stream<QString> _ready;
|
rpl::event_stream<QString> _ready;
|
||||||
|
@ -115,7 +115,7 @@ public:
|
||||||
};
|
};
|
||||||
struct File {
|
struct File {
|
||||||
QString name;
|
QString name;
|
||||||
int32 size = 0;
|
int64 size = 0;
|
||||||
DcId dcId = 0;
|
DcId dcId = 0;
|
||||||
MTPInputFileLocation location;
|
MTPInputFileLocation location;
|
||||||
};
|
};
|
||||||
|
@ -127,7 +127,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Request {
|
struct Request {
|
||||||
int offset = 0;
|
int64 offset = 0;
|
||||||
QByteArray bytes;
|
QByteArray bytes;
|
||||||
};
|
};
|
||||||
void startLoading() override;
|
void startLoading() override;
|
||||||
|
@ -139,8 +139,8 @@ private:
|
||||||
static constexpr auto kNextRequestDelay = crl::time(20);
|
static constexpr auto kNextRequestDelay = crl::time(20);
|
||||||
|
|
||||||
std::deque<Request> _requests;
|
std::deque<Request> _requests;
|
||||||
int32 _size = 0;
|
int64 _size = 0;
|
||||||
int _offset = 0;
|
int64 _offset = 0;
|
||||||
DcId _dcId = 0;
|
DcId _dcId = 0;
|
||||||
MTPInputFileLocation _location;
|
MTPInputFileLocation _location;
|
||||||
WeakInstance _mtp;
|
WeakInstance _mtp;
|
||||||
|
|
|
@ -266,7 +266,11 @@ void RadialProgressItem::checkRadialFinished() const {
|
||||||
|
|
||||||
RadialProgressItem::~RadialProgressItem() = default;
|
RadialProgressItem::~RadialProgressItem() = default;
|
||||||
|
|
||||||
void StatusText::update(int newSize, int fullSize, int duration, crl::time realDuration) {
|
void StatusText::update(
|
||||||
|
int64 newSize,
|
||||||
|
int64 fullSize,
|
||||||
|
TimeId duration,
|
||||||
|
TimeId realDuration) {
|
||||||
setSize(newSize);
|
setSize(newSize);
|
||||||
if (_size == Ui::FileStatusSizeReady) {
|
if (_size == Ui::FileStatusSizeReady) {
|
||||||
_text = (duration >= 0) ? Ui::FormatDurationAndSizeText(duration, fullSize) : (duration < -1 ? Ui::FormatGifAndSizeText(fullSize) : Ui::FormatSizeText(fullSize));
|
_text = (duration >= 0) ? Ui::FormatDurationAndSizeText(duration, fullSize) : (duration < -1 ? Ui::FormatGifAndSizeText(fullSize) : Ui::FormatSizeText(fullSize));
|
||||||
|
@ -281,7 +285,7 @@ void StatusText::update(int newSize, int fullSize, int duration, crl::time realD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusText::setSize(int newSize) {
|
void StatusText::setSize(int64 newSize) {
|
||||||
_size = newSize;
|
_size = newSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,7 +590,7 @@ TextState Video::getState(
|
||||||
}
|
}
|
||||||
|
|
||||||
void Video::updateStatusText() {
|
void Video::updateStatusText() {
|
||||||
int statusSize = 0;
|
auto statusSize = int64();
|
||||||
if (_data->status == FileDownloadFailed || _data->status == FileUploadFailed) {
|
if (_data->status == FileDownloadFailed || _data->status == FileUploadFailed) {
|
||||||
statusSize = Ui::FileStatusSizeFailed;
|
statusSize = Ui::FileStatusSizeFailed;
|
||||||
} else if (_data->uploading()) {
|
} else if (_data->uploading()) {
|
||||||
|
@ -597,8 +601,9 @@ void Video::updateStatusText() {
|
||||||
statusSize = Ui::FileStatusSizeReady;
|
statusSize = Ui::FileStatusSizeReady;
|
||||||
}
|
}
|
||||||
if (statusSize != _status.size()) {
|
if (statusSize != _status.size()) {
|
||||||
int status = statusSize, size = _data->size;
|
auto status = statusSize;
|
||||||
if (statusSize >= 0 && statusSize < 0x7F000000) {
|
auto size = _data->size;
|
||||||
|
if (statusSize >= 0 && statusSize < 0xFF000000LL) {
|
||||||
size = status;
|
size = status;
|
||||||
status = Ui::FileStatusSizeReady;
|
status = Ui::FileStatusSizeReady;
|
||||||
}
|
}
|
||||||
|
@ -893,8 +898,9 @@ int Voice::duration() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Voice::updateStatusText() {
|
bool Voice::updateStatusText() {
|
||||||
bool showPause = false;
|
auto showPause = false;
|
||||||
int32 statusSize = 0, realDuration = 0;
|
auto statusSize = int64();
|
||||||
|
auto realDuration = TimeId();
|
||||||
if (_data->status == FileDownloadFailed || _data->status == FileUploadFailed) {
|
if (_data->status == FileDownloadFailed || _data->status == FileUploadFailed) {
|
||||||
statusSize = Ui::FileStatusSizeFailed;
|
statusSize = Ui::FileStatusSizeFailed;
|
||||||
} else if (dataLoaded()) {
|
} else if (dataLoaded()) {
|
||||||
|
@ -1419,8 +1425,9 @@ bool Document::withThumb() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Document::updateStatusText() {
|
bool Document::updateStatusText() {
|
||||||
bool showPause = false;
|
auto showPause = false;
|
||||||
int32 statusSize = 0, realDuration = 0;
|
auto statusSize = int64();
|
||||||
|
auto realDuration = TimeId();
|
||||||
if (_data->status == FileDownloadFailed
|
if (_data->status == FileDownloadFailed
|
||||||
|| _data->status == FileUploadFailed) {
|
|| _data->status == FileUploadFailed) {
|
||||||
statusSize = Ui::FileStatusSizeFailed;
|
statusSize = Ui::FileStatusSizeFailed;
|
||||||
|
@ -2138,7 +2145,7 @@ TextState Gif::getState(
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gif::updateStatusText() {
|
void Gif::updateStatusText() {
|
||||||
int statusSize = 0;
|
auto statusSize = int64();
|
||||||
if (_data->status == FileDownloadFailed || _data->status == FileUploadFailed) {
|
if (_data->status == FileDownloadFailed || _data->status == FileUploadFailed) {
|
||||||
statusSize = Ui::FileStatusSizeFailed;
|
statusSize = Ui::FileStatusSizeFailed;
|
||||||
} else if (_data->uploading()) {
|
} else if (_data->uploading()) {
|
||||||
|
@ -2149,8 +2156,9 @@ void Gif::updateStatusText() {
|
||||||
statusSize = Ui::FileStatusSizeReady;
|
statusSize = Ui::FileStatusSizeReady;
|
||||||
}
|
}
|
||||||
if (statusSize != _status.size()) {
|
if (statusSize != _status.size()) {
|
||||||
int status = statusSize, size = _data->size;
|
auto status = statusSize;
|
||||||
if (statusSize >= 0 && statusSize < 0x7F000000) {
|
auto size = _data->size;
|
||||||
|
if (statusSize >= 0 && statusSize < 0xFF000000LL) {
|
||||||
size = status;
|
size = status;
|
||||||
status = Ui::FileStatusSizeReady;
|
status = Ui::FileStatusSizeReady;
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,23 +144,27 @@ protected:
|
||||||
class StatusText {
|
class StatusText {
|
||||||
public:
|
public:
|
||||||
// duration = -1 - no duration, duration = -2 - "GIF" duration
|
// duration = -1 - no duration, duration = -2 - "GIF" duration
|
||||||
void update(int newSize, int fullSize, int duration, crl::time realDuration);
|
void update(
|
||||||
void setSize(int newSize);
|
int64 newSize,
|
||||||
|
int64 fullSize,
|
||||||
|
TimeId duration,
|
||||||
|
TimeId realDuration);
|
||||||
|
void setSize(int64 newSize);
|
||||||
|
|
||||||
int size() const {
|
[[nodiscard]] int64 size() const {
|
||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
QString text() const {
|
[[nodiscard]] QString text() const {
|
||||||
return _text;
|
return _text;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// >= 0 will contain download / upload string, _size = loaded bytes
|
// >= 0 will contain download / upload string, _size = loaded bytes
|
||||||
// < 0 will contain played string, _size = -(seconds + 1) played
|
// < 0 will contain played string, _size = -(seconds + 1) played
|
||||||
// 0x7FFFFFF0 will contain status for not yet downloaded file
|
// 0xFFFFFFF0LL will contain status for not yet downloaded file
|
||||||
// 0x7FFFFFF1 will contain status for already downloaded file
|
// 0xFFFFFFF1LL will contain status for already downloaded file
|
||||||
// 0x7FFFFFF2 will contain status for failed to download / upload file
|
// 0xFFFFFFF2LL will contain status for failed to download / upload file
|
||||||
int _size = 0;
|
int64 _size = 0;
|
||||||
QString _text;
|
QString _text;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -328,7 +332,7 @@ private:
|
||||||
const style::OverviewFileLayout &_st;
|
const style::OverviewFileLayout &_st;
|
||||||
|
|
||||||
Ui::Text::String _name, _details;
|
Ui::Text::String _name, _details;
|
||||||
int _nameVersion;
|
int _nameVersion = 0;
|
||||||
|
|
||||||
void updateName();
|
void updateName();
|
||||||
bool updateStatusText();
|
bool updateStatusText();
|
||||||
|
@ -387,8 +391,9 @@ private:
|
||||||
|
|
||||||
Ui::Text::String _name;
|
Ui::Text::String _name;
|
||||||
QString _date, _ext;
|
QString _date, _ext;
|
||||||
int32 _datew, _extw;
|
int _datew = 0;
|
||||||
int32 _thumbw;
|
int _extw = 0;
|
||||||
|
int _thumbw = 0;
|
||||||
|
|
||||||
bool withThumb() const;
|
bool withThumb() const;
|
||||||
bool updateStatusText();
|
bool updateStatusText();
|
||||||
|
|
|
@ -392,7 +392,7 @@ void Form::processDetails(const MTPDpayments_paymentForm &data) {
|
||||||
.canSaveCredentials = data.is_can_save_credentials(),
|
.canSaveCredentials = data.is_can_save_credentials(),
|
||||||
.passwordMissing = data.is_password_missing(),
|
.passwordMissing = data.is_password_missing(),
|
||||||
};
|
};
|
||||||
_invoice.isTest = data.is_test();
|
//_invoice.isTest = data.is_test();
|
||||||
_invoice.cover.title = qs(data.vtitle());
|
_invoice.cover.title = qs(data.vtitle());
|
||||||
_invoice.cover.description = qs(data.vdescription());
|
_invoice.cover.description = qs(data.vdescription());
|
||||||
if (_invoice.cover.thumbnail.isNull() && !_thumbnailLoadProcess) {
|
if (_invoice.cover.thumbnail.isNull() && !_thumbnailLoadProcess) {
|
||||||
|
|
|
@ -480,7 +480,7 @@ void DownloadMtprotoTask::loadPart(int sessionIndex) {
|
||||||
void DownloadMtprotoTask::removeSession(int sessionIndex) {
|
void DownloadMtprotoTask::removeSession(int sessionIndex) {
|
||||||
struct Redirect {
|
struct Redirect {
|
||||||
mtpRequestId requestId = 0;
|
mtpRequestId requestId = 0;
|
||||||
int offset = 0;
|
int64 offset = 0;
|
||||||
};
|
};
|
||||||
auto redirect = std::vector<Redirect>();
|
auto redirect = std::vector<Redirect>();
|
||||||
for (const auto &[requestId, requestData] : _sentRequests) {
|
for (const auto &[requestId, requestData] : _sentRequests) {
|
||||||
|
@ -517,7 +517,7 @@ mtpRequestId DownloadMtprotoTask::sendRequest(
|
||||||
if (_cdnDcId) {
|
if (_cdnDcId) {
|
||||||
return api().request(MTPupload_GetCdnFile(
|
return api().request(MTPupload_GetCdnFile(
|
||||||
MTP_bytes(_cdnToken),
|
MTP_bytes(_cdnToken),
|
||||||
MTP_int(offset),
|
MTP_long(offset),
|
||||||
MTP_int(limit)
|
MTP_int(limit)
|
||||||
)).done([=](const MTPupload_CdnFile &result, mtpRequestId id) {
|
)).done([=](const MTPupload_CdnFile &result, mtpRequestId id) {
|
||||||
cdnPartLoaded(result, id);
|
cdnPartLoaded(result, id);
|
||||||
|
@ -562,7 +562,7 @@ mtpRequestId DownloadMtprotoTask::sendRequest(
|
||||||
return api().request(MTPupload_GetFile(
|
return api().request(MTPupload_GetFile(
|
||||||
MTP_flags(MTPupload_GetFile::Flag::f_cdn_supported),
|
MTP_flags(MTPupload_GetFile::Flag::f_cdn_supported),
|
||||||
location.tl(api().session().userId()),
|
location.tl(api().session().userId()),
|
||||||
MTP_int(offset),
|
MTP_long(offset),
|
||||||
MTP_int(limit)
|
MTP_int(limit)
|
||||||
)).done([=](const MTPupload_File &result, mtpRequestId id) {
|
)).done([=](const MTPupload_File &result, mtpRequestId id) {
|
||||||
normalPartLoaded(result, id);
|
normalPartLoaded(result, id);
|
||||||
|
@ -572,7 +572,7 @@ mtpRequestId DownloadMtprotoTask::sendRequest(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DownloadMtprotoTask::setWebFileSizeHook(int size) {
|
bool DownloadMtprotoTask::setWebFileSizeHook(int64 size) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -591,7 +591,7 @@ void DownloadMtprotoTask::requestMoreCdnFileHashes() {
|
||||||
requestData.sessionIndex);
|
requestData.sessionIndex);
|
||||||
_cdnHashesRequestId = api().request(MTPupload_GetCdnFileHashes(
|
_cdnHashesRequestId = api().request(MTPupload_GetCdnFileHashes(
|
||||||
MTP_bytes(_cdnToken),
|
MTP_bytes(_cdnToken),
|
||||||
MTP_int(requestData.offset)
|
MTP_long(requestData.offset)
|
||||||
)).done([=](const MTPVector<MTPFileHash> &result, mtpRequestId id) {
|
)).done([=](const MTPVector<MTPFileHash> &result, mtpRequestId id) {
|
||||||
getCdnFileHashesDone(result, id);
|
getCdnFileHashesDone(result, id);
|
||||||
}).fail([=](const MTP::Error &error, mtpRequestId id) {
|
}).fail([=](const MTP::Error &error, mtpRequestId id) {
|
||||||
|
@ -704,7 +704,7 @@ void DownloadMtprotoTask::cdnPartLoaded(const MTPupload_CdnFile &result, mtpRequ
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadMtprotoTask::CheckCdnHashResult DownloadMtprotoTask::checkCdnFileHash(
|
DownloadMtprotoTask::CheckCdnHashResult DownloadMtprotoTask::checkCdnFileHash(
|
||||||
int offset,
|
int64 offset,
|
||||||
bytes::const_span buffer) {
|
bytes::const_span buffer) {
|
||||||
const auto cdnFileHashIt = _cdnFileHashes.find(offset);
|
const auto cdnFileHashIt = _cdnFileHashes.find(offset);
|
||||||
if (cdnFileHashIt == _cdnFileHashes.cend()) {
|
if (cdnFileHashIt == _cdnFileHashes.cend()) {
|
||||||
|
@ -831,7 +831,7 @@ bool DownloadMtprotoTask::haveSentRequests() const {
|
||||||
return !_sentRequests.empty() || !_cdnUncheckedParts.empty();
|
return !_sentRequests.empty() || !_cdnUncheckedParts.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DownloadMtprotoTask::haveSentRequestForOffset(int offset) const {
|
bool DownloadMtprotoTask::haveSentRequestForOffset(int64 offset) const {
|
||||||
return _requestByOffset.contains(offset)
|
return _requestByOffset.contains(offset)
|
||||||
|| _cdnUncheckedParts.contains({ offset, 0 });
|
|| _cdnUncheckedParts.contains({ offset, 0 });
|
||||||
}
|
}
|
||||||
|
@ -843,7 +843,7 @@ void DownloadMtprotoTask::cancelAllRequests() {
|
||||||
_cdnUncheckedParts.clear();
|
_cdnUncheckedParts.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadMtprotoTask::cancelRequestForOffset(int offset) {
|
void DownloadMtprotoTask::cancelRequestForOffset(int64 offset) {
|
||||||
const auto i = _requestByOffset.find(offset);
|
const auto i = _requestByOffset.find(offset);
|
||||||
if (i != end(_requestByOffset)) {
|
if (i != end(_requestByOffset)) {
|
||||||
cancelRequest(i->second);
|
cancelRequest(i->second);
|
||||||
|
@ -873,7 +873,7 @@ void DownloadMtprotoTask::removeFromQueue() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadMtprotoTask::partLoaded(
|
void DownloadMtprotoTask::partLoaded(
|
||||||
int offset,
|
int64 offset,
|
||||||
const QByteArray &bytes) {
|
const QByteArray &bytes) {
|
||||||
feedPart(offset, bytes);
|
feedPart(offset, bytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,9 +156,9 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
[[nodiscard]] bool haveSentRequests() const;
|
[[nodiscard]] bool haveSentRequests() const;
|
||||||
[[nodiscard]] bool haveSentRequestForOffset(int offset) const;
|
[[nodiscard]] bool haveSentRequestForOffset(int64 offset) const;
|
||||||
void cancelAllRequests();
|
void cancelAllRequests();
|
||||||
void cancelRequestForOffset(int offset);
|
void cancelRequestForOffset(int64 offset);
|
||||||
|
|
||||||
void addToQueue(int priority = 0);
|
void addToQueue(int priority = 0);
|
||||||
void removeFromQueue();
|
void removeFromQueue();
|
||||||
|
@ -169,7 +169,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct RequestData {
|
struct RequestData {
|
||||||
int offset = 0;
|
int64 offset = 0;
|
||||||
mutable int sessionIndex = 0;
|
mutable int sessionIndex = 0;
|
||||||
int requestedInSession = 0;
|
int requestedInSession = 0;
|
||||||
crl::time sent = 0;
|
crl::time sent = 0;
|
||||||
|
@ -196,9 +196,9 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
// Called only if readyToRequest() == true.
|
// Called only if readyToRequest() == true.
|
||||||
[[nodiscard]] virtual int takeNextRequestOffset() = 0;
|
[[nodiscard]] virtual int64 takeNextRequestOffset() = 0;
|
||||||
virtual bool feedPart(int offset, const QByteArray &bytes) = 0;
|
virtual bool feedPart(int64 offset, const QByteArray &bytes) = 0;
|
||||||
virtual bool setWebFileSizeHook(int size);
|
virtual bool setWebFileSizeHook(int64 size);
|
||||||
virtual void cancelOnFail() = 0;
|
virtual void cancelOnFail() = 0;
|
||||||
|
|
||||||
void cancelRequest(mtpRequestId requestId);
|
void cancelRequest(mtpRequestId requestId);
|
||||||
|
@ -220,7 +220,7 @@ private:
|
||||||
const MTPVector<MTPFileHash> &result,
|
const MTPVector<MTPFileHash> &result,
|
||||||
mtpRequestId requestId);
|
mtpRequestId requestId);
|
||||||
|
|
||||||
void partLoaded(int offset, const QByteArray &bytes);
|
void partLoaded(int64 offset, const QByteArray &bytes);
|
||||||
|
|
||||||
bool partFailed(const MTP::Error &error, mtpRequestId requestId);
|
bool partFailed(const MTP::Error &error, mtpRequestId requestId);
|
||||||
bool normalPartFailed(
|
bool normalPartFailed(
|
||||||
|
@ -249,7 +249,7 @@ private:
|
||||||
const QVector<MTPFileHash> &hashes);
|
const QVector<MTPFileHash> &hashes);
|
||||||
|
|
||||||
[[nodiscard]] CheckCdnHashResult checkCdnFileHash(
|
[[nodiscard]] CheckCdnHashResult checkCdnFileHash(
|
||||||
int offset,
|
int64 offset,
|
||||||
bytes::const_span buffer);
|
bytes::const_span buffer);
|
||||||
|
|
||||||
const not_null<DownloadManagerMtproto*> _owner;
|
const not_null<DownloadManagerMtproto*> _owner;
|
||||||
|
@ -260,13 +260,13 @@ private:
|
||||||
const Data::FileOrigin _origin;
|
const Data::FileOrigin _origin;
|
||||||
|
|
||||||
base::flat_map<mtpRequestId, RequestData> _sentRequests;
|
base::flat_map<mtpRequestId, RequestData> _sentRequests;
|
||||||
base::flat_map<int, mtpRequestId> _requestByOffset;
|
base::flat_map<int64, mtpRequestId> _requestByOffset;
|
||||||
|
|
||||||
MTP::DcId _cdnDcId = 0;
|
MTP::DcId _cdnDcId = 0;
|
||||||
QByteArray _cdnToken;
|
QByteArray _cdnToken;
|
||||||
QByteArray _cdnEncryptionKey;
|
QByteArray _cdnEncryptionKey;
|
||||||
QByteArray _cdnEncryptionIV;
|
QByteArray _cdnEncryptionIV;
|
||||||
base::flat_map<int, CdnFileHash> _cdnFileHashes;
|
base::flat_map<int64, CdnFileHash> _cdnFileHashes;
|
||||||
base::flat_map<RequestData, QByteArray> _cdnUncheckedParts;
|
base::flat_map<RequestData, QByteArray> _cdnUncheckedParts;
|
||||||
mtpRequestId _cdnHashesRequestId = 0;
|
mtpRequestId _cdnHashesRequestId = 0;
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@ public:
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
const QByteArray &data,
|
const QByteArray &data,
|
||||||
const QString &toFile,
|
const QString &toFile,
|
||||||
int loadSize,
|
int64 loadSize,
|
||||||
int fullSize,
|
int64 fullSize,
|
||||||
LocationType locationType,
|
LocationType locationType,
|
||||||
LoadToCacheSetting toCache,
|
LoadToCacheSetting toCache,
|
||||||
LoadFromCloudSetting fromCloud,
|
LoadFromCloudSetting fromCloud,
|
||||||
|
@ -53,8 +53,8 @@ FromMemoryLoader::FromMemoryLoader(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
const QByteArray &data,
|
const QByteArray &data,
|
||||||
const QString &toFile,
|
const QString &toFile,
|
||||||
int loadSize,
|
int64 loadSize,
|
||||||
int fullSize,
|
int64 fullSize,
|
||||||
LocationType locationType,
|
LocationType locationType,
|
||||||
LoadToCacheSetting toCache,
|
LoadToCacheSetting toCache,
|
||||||
LoadFromCloudSetting fromCloud,
|
LoadFromCloudSetting fromCloud,
|
||||||
|
@ -93,8 +93,8 @@ void FromMemoryLoader::startLoading() {
|
||||||
FileLoader::FileLoader(
|
FileLoader::FileLoader(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
const QString &toFile,
|
const QString &toFile,
|
||||||
int loadSize,
|
int64 loadSize,
|
||||||
int fullSize,
|
int64 fullSize,
|
||||||
LocationType locationType,
|
LocationType locationType,
|
||||||
LoadToCacheSetting toCache,
|
LoadToCacheSetting toCache,
|
||||||
LoadFromCloudSetting fromCloud,
|
LoadFromCloudSetting fromCloud,
|
||||||
|
@ -193,7 +193,7 @@ void FileLoader::permitLoadFromCloud() {
|
||||||
_fromCloud = LoadFromCloudOrLocal;
|
_fromCloud = LoadFromCloudOrLocal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileLoader::increaseLoadSize(int size, bool autoLoading) {
|
void FileLoader::increaseLoadSize(int64 size, bool autoLoading) {
|
||||||
Expects(size > _loadSize);
|
Expects(size > _loadSize);
|
||||||
Expects(size <= _fullSize);
|
Expects(size <= _fullSize);
|
||||||
|
|
||||||
|
@ -358,11 +358,11 @@ void FileLoader::cancel(bool fail) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FileLoader::currentOffset() const {
|
int64 FileLoader::currentOffset() const {
|
||||||
return (_fileIsOpen ? _file.size() : _data.size()) - _skippedBytes;
|
return (_fileIsOpen ? _file.size() : _data.size()) - _skippedBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileLoader::writeResultPart(int offset, bytes::const_span buffer) {
|
bool FileLoader::writeResultPart(int64 offset, bytes::const_span buffer) {
|
||||||
Expects(!_finished);
|
Expects(!_finished);
|
||||||
|
|
||||||
if (buffer.empty()) {
|
if (buffer.empty()) {
|
||||||
|
@ -402,7 +402,7 @@ bool FileLoader::writeResultPart(int offset, bytes::const_span buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray FileLoader::readLoadedPartBack(int offset, int size) {
|
QByteArray FileLoader::readLoadedPartBack(int64 offset, int size) {
|
||||||
Expects(offset >= 0 && size > 0);
|
Expects(offset >= 0 && size > 0);
|
||||||
|
|
||||||
if (_fileIsOpen) {
|
if (_fileIsOpen) {
|
||||||
|
@ -478,8 +478,8 @@ std::unique_ptr<FileLoader> CreateFileLoader(
|
||||||
const DownloadLocation &location,
|
const DownloadLocation &location,
|
||||||
Data::FileOrigin origin,
|
Data::FileOrigin origin,
|
||||||
const QString &toFile,
|
const QString &toFile,
|
||||||
int loadSize,
|
int64 loadSize,
|
||||||
int fullSize,
|
int64 fullSize,
|
||||||
LocationType locationType,
|
LocationType locationType,
|
||||||
LoadToCacheSetting toCache,
|
LoadToCacheSetting toCache,
|
||||||
LoadFromCloudSetting fromCloud,
|
LoadFromCloudSetting fromCloud,
|
||||||
|
|
|
@ -57,8 +57,8 @@ public:
|
||||||
FileLoader(
|
FileLoader(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
const QString &toFile,
|
const QString &toFile,
|
||||||
int loadSize,
|
int64 loadSize,
|
||||||
int fullSize,
|
int64 fullSize,
|
||||||
LocationType locationType,
|
LocationType locationType,
|
||||||
LoadToCacheSetting toCache,
|
LoadToCacheSetting toCache,
|
||||||
LoadFromCloudSetting fromCloud,
|
LoadFromCloudSetting fromCloud,
|
||||||
|
@ -88,17 +88,17 @@ public:
|
||||||
// Used in MainWidget::documentLoadFailed.
|
// Used in MainWidget::documentLoadFailed.
|
||||||
[[nodiscard]] virtual Data::FileOrigin fileOrigin() const;
|
[[nodiscard]] virtual Data::FileOrigin fileOrigin() const;
|
||||||
[[nodiscard]] float64 currentProgress() const;
|
[[nodiscard]] float64 currentProgress() const;
|
||||||
[[nodiscard]] virtual int currentOffset() const;
|
[[nodiscard]] virtual int64 currentOffset() const;
|
||||||
[[nodiscard]] int fullSize() const {
|
[[nodiscard]] int64 fullSize() const {
|
||||||
return _fullSize;
|
return _fullSize;
|
||||||
}
|
}
|
||||||
[[nodiscard]] int loadSize() const {
|
[[nodiscard]] int64 loadSize() const {
|
||||||
return _loadSize;
|
return _loadSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setFileName(const QString &filename); // set filename for loaders to cache
|
bool setFileName(const QString &filename); // set filename for loaders to cache
|
||||||
void permitLoadFromCloud();
|
void permitLoadFromCloud();
|
||||||
void increaseLoadSize(int size, bool autoLoading);
|
void increaseLoadSize(int64 size, bool autoLoading);
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void cancel();
|
void cancel();
|
||||||
|
@ -148,9 +148,9 @@ protected:
|
||||||
|
|
||||||
void notifyAboutProgress();
|
void notifyAboutProgress();
|
||||||
|
|
||||||
bool writeResultPart(int offset, bytes::const_span buffer);
|
bool writeResultPart(int64 offset, bytes::const_span buffer);
|
||||||
bool finalizeResult();
|
bool finalizeResult();
|
||||||
[[nodiscard]] QByteArray readLoadedPartBack(int offset, int size);
|
[[nodiscard]] QByteArray readLoadedPartBack(int64 offset, int size);
|
||||||
|
|
||||||
const not_null<Main::Session*> _session;
|
const not_null<Main::Session*> _session;
|
||||||
|
|
||||||
|
@ -169,9 +169,9 @@ protected:
|
||||||
|
|
||||||
QByteArray _data;
|
QByteArray _data;
|
||||||
|
|
||||||
int _loadSize = 0;
|
int64 _loadSize = 0;
|
||||||
int _fullSize = 0;
|
int64 _fullSize = 0;
|
||||||
int _skippedBytes = 0;
|
int64 _skippedBytes = 0;
|
||||||
LocationType _locationType = LocationType();
|
LocationType _locationType = LocationType();
|
||||||
|
|
||||||
base::binary_guard _localLoading;
|
base::binary_guard _localLoading;
|
||||||
|
@ -188,8 +188,8 @@ protected:
|
||||||
const DownloadLocation &location,
|
const DownloadLocation &location,
|
||||||
Data::FileOrigin origin,
|
Data::FileOrigin origin,
|
||||||
const QString &toFile,
|
const QString &toFile,
|
||||||
int loadSize,
|
int64 loadSize,
|
||||||
int fullSize,
|
int64 fullSize,
|
||||||
LocationType locationType,
|
LocationType locationType,
|
||||||
LoadToCacheSetting toCache,
|
LoadToCacheSetting toCache,
|
||||||
LoadFromCloudSetting fromCloud,
|
LoadFromCloudSetting fromCloud,
|
||||||
|
|
|
@ -22,8 +22,8 @@ mtpFileLoader::mtpFileLoader(
|
||||||
Data::FileOrigin origin,
|
Data::FileOrigin origin,
|
||||||
LocationType type,
|
LocationType type,
|
||||||
const QString &to,
|
const QString &to,
|
||||||
int loadSize,
|
int64 loadSize,
|
||||||
int fullSize,
|
int64 fullSize,
|
||||||
LoadToCacheSetting toCache,
|
LoadToCacheSetting toCache,
|
||||||
LoadFromCloudSetting fromCloud,
|
LoadFromCloudSetting fromCloud,
|
||||||
bool autoLoading,
|
bool autoLoading,
|
||||||
|
@ -44,8 +44,8 @@ mtpFileLoader::mtpFileLoader(
|
||||||
mtpFileLoader::mtpFileLoader(
|
mtpFileLoader::mtpFileLoader(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
const WebFileLocation &location,
|
const WebFileLocation &location,
|
||||||
int loadSize,
|
int64 loadSize,
|
||||||
int fullSize,
|
int64 fullSize,
|
||||||
LoadFromCloudSetting fromCloud,
|
LoadFromCloudSetting fromCloud,
|
||||||
bool autoLoading,
|
bool autoLoading,
|
||||||
uint8 cacheTag)
|
uint8 cacheTag)
|
||||||
|
@ -68,8 +68,8 @@ mtpFileLoader::mtpFileLoader(
|
||||||
mtpFileLoader::mtpFileLoader(
|
mtpFileLoader::mtpFileLoader(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
const GeoPointLocation &location,
|
const GeoPointLocation &location,
|
||||||
int loadSize,
|
int64 loadSize,
|
||||||
int fullSize,
|
int64 fullSize,
|
||||||
LoadFromCloudSetting fromCloud,
|
LoadFromCloudSetting fromCloud,
|
||||||
bool autoLoading,
|
bool autoLoading,
|
||||||
uint8 cacheTag)
|
uint8 cacheTag)
|
||||||
|
@ -110,7 +110,7 @@ bool mtpFileLoader::readyToRequest() const {
|
||||||
&& (!_fullSize || _nextRequestOffset < _loadSize);
|
&& (!_fullSize || _nextRequestOffset < _loadSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
int mtpFileLoader::takeNextRequestOffset() {
|
int64 mtpFileLoader::takeNextRequestOffset() {
|
||||||
Expects(readyToRequest());
|
Expects(readyToRequest());
|
||||||
|
|
||||||
const auto result = _nextRequestOffset;
|
const auto result = _nextRequestOffset;
|
||||||
|
@ -118,7 +118,7 @@ int mtpFileLoader::takeNextRequestOffset() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mtpFileLoader::feedPart(int offset, const QByteArray &bytes) {
|
bool mtpFileLoader::feedPart(int64 offset, const QByteArray &bytes) {
|
||||||
const auto buffer = bytes::make_span(bytes);
|
const auto buffer = bytes::make_span(bytes);
|
||||||
if (!writeResultPart(offset, buffer)) {
|
if (!writeResultPart(offset, buffer)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -143,7 +143,7 @@ void mtpFileLoader::cancelOnFail() {
|
||||||
cancel(true);
|
cancel(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mtpFileLoader::setWebFileSizeHook(int size) {
|
bool mtpFileLoader::setWebFileSizeHook(int64 size) {
|
||||||
if (!_fullSize || _fullSize == size) {
|
if (!_fullSize || _fullSize == size) {
|
||||||
_fullSize = _loadSize = size;
|
_fullSize = _loadSize = size;
|
||||||
return true;
|
return true;
|
||||||
|
@ -165,7 +165,7 @@ void mtpFileLoader::startLoadingWithPartial(const QByteArray &data) {
|
||||||
|
|
||||||
constexpr auto kPrefix = 8;
|
constexpr auto kPrefix = 8;
|
||||||
const auto parts = (data.size() - kPrefix) / Storage::kDownloadPartSize;
|
const auto parts = (data.size() - kPrefix) / Storage::kDownloadPartSize;
|
||||||
const auto use = parts * Storage::kDownloadPartSize;
|
const auto use = parts * int64(Storage::kDownloadPartSize);
|
||||||
if (use > 0) {
|
if (use > 0) {
|
||||||
_nextRequestOffset = use;
|
_nextRequestOffset = use;
|
||||||
feedPart(0, QByteArray::fromRawData(data.data() + kPrefix, use));
|
feedPart(0, QByteArray::fromRawData(data.data() + kPrefix, use));
|
||||||
|
|
|
@ -20,8 +20,8 @@ public:
|
||||||
Data::FileOrigin origin,
|
Data::FileOrigin origin,
|
||||||
LocationType type,
|
LocationType type,
|
||||||
const QString &toFile,
|
const QString &toFile,
|
||||||
int loadSize,
|
int64 loadSize,
|
||||||
int fullSize,
|
int64 fullSize,
|
||||||
LoadToCacheSetting toCache,
|
LoadToCacheSetting toCache,
|
||||||
LoadFromCloudSetting fromCloud,
|
LoadFromCloudSetting fromCloud,
|
||||||
bool autoLoading,
|
bool autoLoading,
|
||||||
|
@ -29,16 +29,16 @@ public:
|
||||||
mtpFileLoader(
|
mtpFileLoader(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
const WebFileLocation &location,
|
const WebFileLocation &location,
|
||||||
int loadSize,
|
int64 loadSize,
|
||||||
int fullSize,
|
int64 fullSize,
|
||||||
LoadFromCloudSetting fromCloud,
|
LoadFromCloudSetting fromCloud,
|
||||||
bool autoLoading,
|
bool autoLoading,
|
||||||
uint8 cacheTag);
|
uint8 cacheTag);
|
||||||
mtpFileLoader(
|
mtpFileLoader(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
const GeoPointLocation &location,
|
const GeoPointLocation &location,
|
||||||
int loadSize,
|
int64 loadSize,
|
||||||
int fullSize,
|
int64 fullSize,
|
||||||
LoadFromCloudSetting fromCloud,
|
LoadFromCloudSetting fromCloud,
|
||||||
bool autoLoading,
|
bool autoLoading,
|
||||||
uint8 cacheTag);
|
uint8 cacheTag);
|
||||||
|
@ -55,12 +55,12 @@ private:
|
||||||
void cancelHook() override;
|
void cancelHook() override;
|
||||||
|
|
||||||
bool readyToRequest() const override;
|
bool readyToRequest() const override;
|
||||||
int takeNextRequestOffset() override;
|
int64 takeNextRequestOffset() override;
|
||||||
bool feedPart(int offset, const QByteArray &bytes) override;
|
bool feedPart(int64 offset, const QByteArray &bytes) override;
|
||||||
void cancelOnFail() override;
|
void cancelOnFail() override;
|
||||||
bool setWebFileSizeHook(int size) override;
|
bool setWebFileSizeHook(int64 size) override;
|
||||||
|
|
||||||
bool _lastComplete = false;
|
bool _lastComplete = false;
|
||||||
int32 _nextRequestOffset = 0;
|
int64 _nextRequestOffset = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -488,7 +488,7 @@ void webFileLoader::startLoading() {
|
||||||
_manager->enqueue(this);
|
_manager->enqueue(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
int webFileLoader::currentOffset() const {
|
int64 webFileLoader::currentOffset() const {
|
||||||
return _ready;
|
return _ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] QString url() const;
|
[[nodiscard]] QString url() const;
|
||||||
|
|
||||||
int currentOffset() const override;
|
int64 currentOffset() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void cancelRequest();
|
void cancelRequest();
|
||||||
|
@ -38,7 +38,7 @@ private:
|
||||||
void loadFailed();
|
void loadFailed();
|
||||||
|
|
||||||
const QString _url;
|
const QString _url;
|
||||||
int _ready = 0;
|
int64 _ready = 0;
|
||||||
|
|
||||||
std::shared_ptr<WebLoadManager> _manager;
|
std::shared_ptr<WebLoadManager> _manager;
|
||||||
rpl::lifetime _managerLifetime;
|
rpl::lifetime _managerLifetime;
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace {
|
||||||
// max 512kb uploaded at the same time in each session
|
// max 512kb uploaded at the same time in each session
|
||||||
constexpr auto kMaxUploadFileParallelSize = MTP::kUploadSessionsCount * 512 * 1024;
|
constexpr auto kMaxUploadFileParallelSize = MTP::kUploadSessionsCount * 512 * 1024;
|
||||||
|
|
||||||
constexpr auto kDocumentMaxPartsCount = 4000;
|
constexpr auto kDocumentMaxPartsCount = 8000;
|
||||||
|
|
||||||
// 32kb for tiny document ( < 1mb )
|
// 32kb for tiny document ( < 1mb )
|
||||||
constexpr auto kDocumentUploadPartSize0 = 32 * 1024;
|
constexpr auto kDocumentUploadPartSize0 = 32 * 1024;
|
||||||
|
@ -62,13 +62,13 @@ struct Uploader::File {
|
||||||
File(const SendMediaReady &media);
|
File(const SendMediaReady &media);
|
||||||
File(const std::shared_ptr<FileLoadResult> &file);
|
File(const std::shared_ptr<FileLoadResult> &file);
|
||||||
|
|
||||||
void setDocSize(int32 size);
|
void setDocSize(int64 size);
|
||||||
bool setPartSize(uint32 partSize);
|
bool setPartSize(uint32 partSize);
|
||||||
|
|
||||||
std::shared_ptr<FileLoadResult> file;
|
std::shared_ptr<FileLoadResult> file;
|
||||||
SendMediaReady media;
|
SendMediaReady media;
|
||||||
int32 partsCount = 0;
|
int32 partsCount = 0;
|
||||||
mutable int32 fileSentSize = 0;
|
mutable int64 fileSentSize = 0;
|
||||||
|
|
||||||
uint64 id() const;
|
uint64 id() const;
|
||||||
SendMediaType type() const;
|
SendMediaType type() const;
|
||||||
|
@ -78,10 +78,10 @@ struct Uploader::File {
|
||||||
HashMd5 md5Hash;
|
HashMd5 md5Hash;
|
||||||
|
|
||||||
std::unique_ptr<QFile> docFile;
|
std::unique_ptr<QFile> docFile;
|
||||||
int32 docSentParts = 0;
|
int64 docSize = 0;
|
||||||
int32 docSize = 0;
|
int64 docPartSize = 0;
|
||||||
int32 docPartSize = 0;
|
int docSentParts = 0;
|
||||||
int32 docPartsCount = 0;
|
int docPartsCount = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ Uploader::File::File(const std::shared_ptr<FileLoadResult> &file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uploader::File::setDocSize(int32 size) {
|
void Uploader::File::setDocSize(int64 size) {
|
||||||
docSize = size;
|
docSize = size;
|
||||||
constexpr auto limit0 = 1024 * 1024;
|
constexpr auto limit0 = 1024 * 1024;
|
||||||
constexpr auto limit1 = 32 * limit0;
|
constexpr auto limit1 = 32 * limit0;
|
||||||
|
@ -226,7 +226,8 @@ void Uploader::processDocumentProgress(const FullMsgId &newId) {
|
||||||
? Api::SendProgressType::UploadVoice
|
? Api::SendProgressType::UploadVoice
|
||||||
: Api::SendProgressType::UploadFile;
|
: Api::SendProgressType::UploadFile;
|
||||||
const auto progress = (document && document->uploading())
|
const auto progress = (document && document->uploading())
|
||||||
? document->uploadingData->offset
|
? ((document->uploadingData->offset * 100)
|
||||||
|
/ document->uploadingData->size)
|
||||||
: 0;
|
: 0;
|
||||||
sendProgressUpdate(item, sendAction, progress);
|
sendProgressUpdate(item, sendAction, progress);
|
||||||
}
|
}
|
||||||
|
@ -701,7 +702,7 @@ void Uploader::partLoaded(const MTPBool &result, mtpRequestId requestId) {
|
||||||
auto dc = dcIt->second;
|
auto dc = dcIt->second;
|
||||||
dcMap.erase(dcIt);
|
dcMap.erase(dcIt);
|
||||||
|
|
||||||
int32 sentPartSize = 0;
|
int64 sentPartSize = 0;
|
||||||
auto k = queue.find(uploadingId);
|
auto k = queue.find(uploadingId);
|
||||||
Assert(k != queue.cend());
|
Assert(k != queue.cend());
|
||||||
auto &[fullId, file] = *k;
|
auto &[fullId, file] = *k;
|
||||||
|
|
|
@ -37,8 +37,8 @@ struct UploadedMedia {
|
||||||
|
|
||||||
struct UploadSecureProgress {
|
struct UploadSecureProgress {
|
||||||
FullMsgId fullId;
|
FullMsgId fullId;
|
||||||
int offset = 0;
|
int64 offset = 0;
|
||||||
int size = 0;
|
int64 size = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct UploadSecureDone {
|
struct UploadSecureDone {
|
||||||
|
@ -126,7 +126,7 @@ private:
|
||||||
base::flat_map<mtpRequestId, QByteArray> requestsSent;
|
base::flat_map<mtpRequestId, QByteArray> requestsSent;
|
||||||
base::flat_map<mtpRequestId, int32> docRequestsSent;
|
base::flat_map<mtpRequestId, int32> docRequestsSent;
|
||||||
base::flat_map<mtpRequestId, int32> dcMap;
|
base::flat_map<mtpRequestId, int32> dcMap;
|
||||||
uint32 sentSize = 0;
|
uint32 sentSize = 0; // FileSize: Right now any file size fits 32 bit.
|
||||||
uint32 sentSizes[MTP::kUploadSessionsCount] = { 0 };
|
uint32 sentSizes[MTP::kUploadSessionsCount] = { 0 };
|
||||||
|
|
||||||
FullMsgId uploadingId;
|
FullMsgId uploadingId;
|
||||||
|
|
|
@ -91,8 +91,8 @@ struct PreparedFileThumbnail {
|
||||||
|
|
||||||
[[nodiscard]] bool FileThumbnailUploadRequired(
|
[[nodiscard]] bool FileThumbnailUploadRequired(
|
||||||
const QString &filemime,
|
const QString &filemime,
|
||||||
int32 filesize) {
|
int64 filesize) {
|
||||||
constexpr auto kThumbnailUploadBySize = 5 * 1024 * 1024;
|
constexpr auto kThumbnailUploadBySize = 5 * int64(1024 * 1024);
|
||||||
const auto kThumbnailKnownMimes = {
|
const auto kThumbnailKnownMimes = {
|
||||||
"image/jpeg",
|
"image/jpeg",
|
||||||
"image/gif",
|
"image/gif",
|
||||||
|
@ -108,7 +108,7 @@ struct PreparedFileThumbnail {
|
||||||
[[nodiscard]] PreparedFileThumbnail FinalizeFileThumbnail(
|
[[nodiscard]] PreparedFileThumbnail FinalizeFileThumbnail(
|
||||||
PreparedFileThumbnail &&prepared,
|
PreparedFileThumbnail &&prepared,
|
||||||
const QString &filemime,
|
const QString &filemime,
|
||||||
int32 filesize,
|
int64 filesize,
|
||||||
bool isSticker) {
|
bool isSticker) {
|
||||||
prepared.name = isSticker ? qsl("thumb.webp") : qsl("thumb.jpg");
|
prepared.name = isSticker ? qsl("thumb.webp") : qsl("thumb.jpg");
|
||||||
if (FileThumbnailUploadRequired(filemime, filesize)) {
|
if (FileThumbnailUploadRequired(filemime, filesize)) {
|
||||||
|
@ -249,7 +249,7 @@ SendMediaReady::SendMediaReady(
|
||||||
SendMediaType type,
|
SendMediaType type,
|
||||||
const QString &file,
|
const QString &file,
|
||||||
const QString &filename,
|
const QString &filename,
|
||||||
int32 filesize,
|
int64 filesize,
|
||||||
const QByteArray &data,
|
const QByteArray &data,
|
||||||
const uint64 &id,
|
const uint64 &id,
|
||||||
const uint64 &thumbId,
|
const uint64 &thumbId,
|
||||||
|
@ -842,9 +842,9 @@ void FileLoadTask::process(Args &&args) {
|
||||||
fullimagebytes = fullimageformat = QByteArray();
|
fullimagebytes = fullimageformat = QByteArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_result->filesize = (int32)qMin(filesize, qint64(INT_MAX));
|
_result->filesize = qMin(filesize, qint64(UINT_MAX));
|
||||||
|
|
||||||
if (!filesize || filesize > kFileSizeLimit) {
|
if (!filesize || filesize > kFileSizePremiumLimit) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -987,7 +987,7 @@ void FileLoadTask::process(Args &&args) {
|
||||||
MTP_bytes(),
|
MTP_bytes(),
|
||||||
MTP_int(base::unixtime::now()),
|
MTP_int(base::unixtime::now()),
|
||||||
MTP_string(filemime),
|
MTP_string(filemime),
|
||||||
MTP_int(filesize),
|
MTP_long(filesize),
|
||||||
MTP_vector<MTPPhotoSize>(1, thumbnail.mtpSize),
|
MTP_vector<MTPPhotoSize>(1, thumbnail.mtpSize),
|
||||||
MTPVector<MTPVideoSize>(),
|
MTPVector<MTPVideoSize>(),
|
||||||
MTP_int(_dcId),
|
MTP_int(_dcId),
|
||||||
|
@ -1000,7 +1000,7 @@ void FileLoadTask::process(Args &&args) {
|
||||||
MTP_bytes(),
|
MTP_bytes(),
|
||||||
MTP_int(base::unixtime::now()),
|
MTP_int(base::unixtime::now()),
|
||||||
MTP_string(filemime),
|
MTP_string(filemime),
|
||||||
MTP_int(filesize),
|
MTP_long(filesize),
|
||||||
MTP_vector<MTPPhotoSize>(1, thumbnail.mtpSize),
|
MTP_vector<MTPPhotoSize>(1, thumbnail.mtpSize),
|
||||||
MTPVector<MTPVideoSize>(),
|
MTPVector<MTPVideoSize>(),
|
||||||
MTP_int(_dcId),
|
MTP_int(_dcId),
|
||||||
|
@ -1048,6 +1048,12 @@ void FileLoadTask::finish() {
|
||||||
tr::lng_send_image_empty(tr::now, lt_name, _filepath)),
|
tr::lng_send_image_empty(tr::now, lt_name, _filepath)),
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
removeFromAlbum();
|
removeFromAlbum();
|
||||||
|
} else if (_result->filesize > kFileSizePremiumLimit) {
|
||||||
|
Ui::show(
|
||||||
|
Ui::MakeInformBox(
|
||||||
|
tr::lng_send_image_too_large(tr::now, lt_name, _filepath)),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
|
removeFromAlbum();
|
||||||
} else if (_result->filesize > kFileSizeLimit) {
|
} else if (_result->filesize > kFileSizeLimit) {
|
||||||
Ui::show(
|
Ui::show(
|
||||||
Ui::MakeInformBox(
|
Ui::MakeInformBox(
|
||||||
|
|
|
@ -15,7 +15,11 @@ namespace Main {
|
||||||
class Session;
|
class Session;
|
||||||
} // namespace Main
|
} // namespace Main
|
||||||
|
|
||||||
constexpr auto kFileSizeLimit = 2000 * 1024 * 1024; // Load files up to 2000MB
|
// Load files up to 2'000 MB.
|
||||||
|
constexpr auto kFileSizeLimit = 2'000 * int64(1024 * 1024);
|
||||||
|
|
||||||
|
// Load files up to 4'000 MB.
|
||||||
|
constexpr auto kFileSizePremiumLimit = 4'000 * int64(1024 * 1024);
|
||||||
|
|
||||||
enum class SendMediaType {
|
enum class SendMediaType {
|
||||||
Photo,
|
Photo,
|
||||||
|
@ -67,7 +71,7 @@ struct SendMediaReady {
|
||||||
SendMediaType type,
|
SendMediaType type,
|
||||||
const QString &file,
|
const QString &file,
|
||||||
const QString &filename,
|
const QString &filename,
|
||||||
int32 filesize,
|
int64 filesize,
|
||||||
const QByteArray &data,
|
const QByteArray &data,
|
||||||
const uint64 &id,
|
const uint64 &id,
|
||||||
const uint64 &thumbId,
|
const uint64 &thumbId,
|
||||||
|
@ -82,7 +86,7 @@ struct SendMediaReady {
|
||||||
MsgId replyTo;
|
MsgId replyTo;
|
||||||
SendMediaType type;
|
SendMediaType type;
|
||||||
QString file, filename;
|
QString file, filename;
|
||||||
int32 filesize;
|
int64 filesize = 0;
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
QString thumbExt;
|
QString thumbExt;
|
||||||
uint64 id, thumbId; // id always file-id of media, thumbId is file-id of thumb ( == id for photos)
|
uint64 id, thumbId; // id always file-id of media, thumbId is file-id of thumb ( == id for photos)
|
||||||
|
@ -226,10 +230,10 @@ struct FileLoadResult {
|
||||||
|
|
||||||
QString filename;
|
QString filename;
|
||||||
QString filemime;
|
QString filemime;
|
||||||
int32 filesize = 0;
|
int64 filesize = 0;
|
||||||
UploadFileParts fileparts;
|
UploadFileParts fileparts;
|
||||||
QByteArray filemd5;
|
QByteArray filemd5;
|
||||||
int32 partssize;
|
int64 partssize = 0;
|
||||||
|
|
||||||
uint64 thumbId = 0; // id is always file-id of media, thumbId is file-id of thumb ( == id for photos)
|
uint64 thumbId = 0; // id is always file-id of media, thumbId is file-id of thumb ( == id for photos)
|
||||||
QString thumbname;
|
QString thumbname;
|
||||||
|
|
|
@ -29,11 +29,21 @@ enum StickerSetType {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void Document::writeToStream(QDataStream &stream, DocumentData *document) {
|
void Document::writeToStream(QDataStream &stream, DocumentData *document) {
|
||||||
stream << quint64(document->id) << quint64(document->_access) << qint32(document->date);
|
stream
|
||||||
stream << document->_fileReference << qint32(kVersionTag) << qint32(kVersion);
|
<< quint64(document->id)
|
||||||
stream << document->filename() << document->mimeString() << qint32(document->_dc) << qint32(document->size);
|
<< quint64(document->_access)
|
||||||
stream << qint32(document->dimensions.width()) << qint32(document->dimensions.height());
|
<< qint32(document->date)
|
||||||
stream << qint32(document->type);
|
<< document->_fileReference
|
||||||
|
<< qint32(kVersionTag)
|
||||||
|
<< qint32(kVersion)
|
||||||
|
<< document->filename()
|
||||||
|
<< document->mimeString()
|
||||||
|
<< qint32(document->_dc)
|
||||||
|
// FileSize: Right now any file size fits 32 bit.
|
||||||
|
<< qint32(uint32(document->size))
|
||||||
|
<< qint32(document->dimensions.width())
|
||||||
|
<< qint32(document->dimensions.height())
|
||||||
|
<< qint32(document->type);
|
||||||
if (const auto sticker = document->sticker()) {
|
if (const auto sticker = document->sticker()) {
|
||||||
stream << document->sticker()->alt;
|
stream << document->sticker()->alt;
|
||||||
if (document->sticker()->set.id) {
|
if (document->sticker()->set.id) {
|
||||||
|
@ -79,9 +89,14 @@ DocumentData *Document::readFromStreamHelper(
|
||||||
versionTag = 0;
|
versionTag = 0;
|
||||||
version = 0;
|
version = 0;
|
||||||
}
|
}
|
||||||
stream >> name >> mime >> dc >> size;
|
stream
|
||||||
stream >> width >> height;
|
>> name
|
||||||
stream >> type;
|
>> mime
|
||||||
|
>> dc
|
||||||
|
>> size // FileSize: Right now any file size fits 32 bit.
|
||||||
|
>> width
|
||||||
|
>> height
|
||||||
|
>> type;
|
||||||
|
|
||||||
QVector<MTPDocumentAttribute> attributes;
|
QVector<MTPDocumentAttribute> attributes;
|
||||||
if (!name.isEmpty()) {
|
if (!name.isEmpty()) {
|
||||||
|
@ -194,7 +209,7 @@ DocumentData *Document::readFromStreamHelper(
|
||||||
},
|
},
|
||||||
(isPremiumSticker == 1),
|
(isPremiumSticker == 1),
|
||||||
dc,
|
dc,
|
||||||
size);
|
int64(uint32(size)));
|
||||||
}
|
}
|
||||||
|
|
||||||
DocumentData *Document::readStickerFromStream(
|
DocumentData *Document::readStickerFromStream(
|
||||||
|
|
|
@ -99,7 +99,7 @@ BlobLoader::BlobLoader(
|
||||||
int id,
|
int id,
|
||||||
MTP::DedicatedLoader::Location location,
|
MTP::DedicatedLoader::Location location,
|
||||||
const QString &folder,
|
const QString &folder,
|
||||||
int size)
|
int64 size)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, _folder(folder)
|
, _folder(folder)
|
||||||
, _id(id)
|
, _id(id)
|
||||||
|
|
|
@ -25,12 +25,12 @@ constexpr auto kCloudLocationUsername = "tdhbcfiles"_cs;
|
||||||
struct Blob {
|
struct Blob {
|
||||||
int id = 0;
|
int id = 0;
|
||||||
int postId = 0;
|
int postId = 0;
|
||||||
int size = 0;
|
int64 size = 0;
|
||||||
QString name;
|
QString name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Available {
|
struct Available {
|
||||||
int size = 0;
|
int64 size = 0;
|
||||||
|
|
||||||
inline bool operator<(const Available &other) const {
|
inline bool operator<(const Available &other) const {
|
||||||
return size < other.size;
|
return size < other.size;
|
||||||
|
@ -87,7 +87,7 @@ public:
|
||||||
int id,
|
int id,
|
||||||
MTP::DedicatedLoader::Location location,
|
MTP::DedicatedLoader::Location location,
|
||||||
const QString &folder,
|
const QString &folder,
|
||||||
int size);
|
int64 size);
|
||||||
|
|
||||||
int id() const;
|
int id() const;
|
||||||
|
|
||||||
|
|
|
@ -163,8 +163,10 @@ MimeDataState ComputeMimeDataState(const QMimeData *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto filesize = info.size();
|
const auto filesize = info.size();
|
||||||
if (filesize > kFileSizeLimit) {
|
if (filesize > kFileSizePremiumLimit) {
|
||||||
return MimeDataState::None;
|
return MimeDataState::None;
|
||||||
|
} else if (filesize > kFileSizeLimit) {
|
||||||
|
return MimeDataState::PremiumFile;
|
||||||
} else if (allAreSmallImages) {
|
} else if (allAreSmallImages) {
|
||||||
if (filesize > Images::kReadBytesLimit) {
|
if (filesize > Images::kReadBytesLimit) {
|
||||||
allAreSmallImages = false;
|
allAreSmallImages = false;
|
||||||
|
@ -178,7 +180,10 @@ MimeDataState ComputeMimeDataState(const QMimeData *data) {
|
||||||
: MimeDataState::Files;
|
: MimeDataState::Files;
|
||||||
}
|
}
|
||||||
|
|
||||||
PreparedList PrepareMediaList(const QList<QUrl> &files, int previewWidth) {
|
PreparedList PrepareMediaList(
|
||||||
|
const QList<QUrl> &files,
|
||||||
|
int previewWidth,
|
||||||
|
bool premium) {
|
||||||
auto locals = QStringList();
|
auto locals = QStringList();
|
||||||
locals.reserve(files.size());
|
locals.reserve(files.size());
|
||||||
for (const auto &url : files) {
|
for (const auto &url : files) {
|
||||||
|
@ -190,10 +195,13 @@ PreparedList PrepareMediaList(const QList<QUrl> &files, int previewWidth) {
|
||||||
}
|
}
|
||||||
locals.push_back(Platform::File::UrlToLocal(url));
|
locals.push_back(Platform::File::UrlToLocal(url));
|
||||||
}
|
}
|
||||||
return PrepareMediaList(locals, previewWidth);
|
return PrepareMediaList(locals, previewWidth, premium);
|
||||||
}
|
}
|
||||||
|
|
||||||
PreparedList PrepareMediaList(const QStringList &files, int previewWidth) {
|
PreparedList PrepareMediaList(
|
||||||
|
const QStringList &files,
|
||||||
|
int previewWidth,
|
||||||
|
bool premium) {
|
||||||
auto result = PreparedList();
|
auto result = PreparedList();
|
||||||
result.files.reserve(files.size());
|
result.files.reserve(files.size());
|
||||||
for (const auto &file : files) {
|
for (const auto &file : files) {
|
||||||
|
@ -209,11 +217,16 @@ PreparedList PrepareMediaList(const QStringList &files, int previewWidth) {
|
||||||
PreparedList::Error::EmptyFile,
|
PreparedList::Error::EmptyFile,
|
||||||
file
|
file
|
||||||
};
|
};
|
||||||
} else if (filesize > kFileSizeLimit) {
|
} else if (filesize > kFileSizePremiumLimit) {
|
||||||
return {
|
return {
|
||||||
PreparedList::Error::TooLargeFile,
|
PreparedList::Error::TooLargeFile,
|
||||||
file
|
file
|
||||||
};
|
};
|
||||||
|
} else if (filesize > kFileSizeLimit && !premium) {
|
||||||
|
return {
|
||||||
|
PreparedList::Error::PremiumRequired,
|
||||||
|
file
|
||||||
|
};
|
||||||
}
|
}
|
||||||
if (result.files.size() < Ui::MaxAlbumItems()) {
|
if (result.files.size() < Ui::MaxAlbumItems()) {
|
||||||
result.files.emplace_back(file);
|
result.files.emplace_back(file);
|
||||||
|
@ -253,13 +266,14 @@ std::optional<PreparedList> PreparedFileFromFilesDialog(
|
||||||
FileDialog::OpenResult &&result,
|
FileDialog::OpenResult &&result,
|
||||||
Fn<bool(const Ui::PreparedList&)> checkResult,
|
Fn<bool(const Ui::PreparedList&)> checkResult,
|
||||||
Fn<void(tr::phrase<>)> errorCallback,
|
Fn<void(tr::phrase<>)> errorCallback,
|
||||||
int previewWidth) {
|
int previewWidth,
|
||||||
|
bool premium) {
|
||||||
if (result.paths.isEmpty() && result.remoteContent.isEmpty()) {
|
if (result.paths.isEmpty() && result.remoteContent.isEmpty()) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto list = result.remoteContent.isEmpty()
|
auto list = result.remoteContent.isEmpty()
|
||||||
? PrepareMediaList(result.paths, previewWidth)
|
? PrepareMediaList(result.paths, previewWidth, premium)
|
||||||
: PrepareMediaFromImage(
|
: PrepareMediaFromImage(
|
||||||
QImage(),
|
QImage(),
|
||||||
std::move(result.remoteContent),
|
std::move(result.remoteContent),
|
||||||
|
|
|
@ -23,6 +23,7 @@ enum class MimeDataState {
|
||||||
None,
|
None,
|
||||||
Files,
|
Files,
|
||||||
PhotoFiles,
|
PhotoFiles,
|
||||||
|
PremiumFile,
|
||||||
Image,
|
Image,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,7 +31,8 @@ enum class MimeDataState {
|
||||||
FileDialog::OpenResult &&result,
|
FileDialog::OpenResult &&result,
|
||||||
Fn<bool(const Ui::PreparedList&)> checkResult,
|
Fn<bool(const Ui::PreparedList&)> checkResult,
|
||||||
Fn<void(tr::phrase<>)> errorCallback,
|
Fn<void(tr::phrase<>)> errorCallback,
|
||||||
int previewWidth);
|
int previewWidth,
|
||||||
|
bool premium);
|
||||||
[[nodiscard]] MimeDataState ComputeMimeDataState(const QMimeData *data);
|
[[nodiscard]] MimeDataState ComputeMimeDataState(const QMimeData *data);
|
||||||
[[nodiscard]] bool ValidatePhotoEditorMediaDragData(
|
[[nodiscard]] bool ValidatePhotoEditorMediaDragData(
|
||||||
not_null<const QMimeData*> data);
|
not_null<const QMimeData*> data);
|
||||||
|
@ -39,10 +41,12 @@ enum class MimeDataState {
|
||||||
Ui::AlbumType albumType);
|
Ui::AlbumType albumType);
|
||||||
[[nodiscard]] Ui::PreparedList PrepareMediaList(
|
[[nodiscard]] Ui::PreparedList PrepareMediaList(
|
||||||
const QList<QUrl> &files,
|
const QList<QUrl> &files,
|
||||||
int previewWidth);
|
int previewWidth,
|
||||||
|
bool premium);
|
||||||
[[nodiscard]] Ui::PreparedList PrepareMediaList(
|
[[nodiscard]] Ui::PreparedList PrepareMediaList(
|
||||||
const QStringList &files,
|
const QStringList &files,
|
||||||
int previewWidth);
|
int previewWidth,
|
||||||
|
bool premium);
|
||||||
[[nodiscard]] Ui::PreparedList PrepareMediaFromImage(
|
[[nodiscard]] Ui::PreparedList PrepareMediaFromImage(
|
||||||
QImage &&image,
|
QImage &&image,
|
||||||
QByteArray &&content,
|
QByteArray &&content,
|
||||||
|
|
|
@ -596,8 +596,12 @@ QString InterpretSendPath(
|
||||||
+ QString::number(peerToChannel(toId).bare);
|
+ QString::number(peerToChannel(toId).bare);
|
||||||
}
|
}
|
||||||
Ui::showPeerHistory(history, ShowAtUnreadMsgId);
|
Ui::showPeerHistory(history, ShowAtUnreadMsgId);
|
||||||
|
const auto premium = window->session().user()->isPremium();
|
||||||
history->session().api().sendFiles(
|
history->session().api().sendFiles(
|
||||||
Storage::PrepareMediaList(QStringList(filePath), st::sendMediaPreviewSize),
|
Storage::PrepareMediaList(
|
||||||
|
QStringList(filePath),
|
||||||
|
st::sendMediaPreviewSize,
|
||||||
|
premium),
|
||||||
SendMediaType::File,
|
SendMediaType::File,
|
||||||
{ caption },
|
{ caption },
|
||||||
nullptr,
|
nullptr,
|
||||||
|
|
|
@ -75,7 +75,7 @@ struct PreparedFile {
|
||||||
|
|
||||||
QString path;
|
QString path;
|
||||||
QByteArray content;
|
QByteArray content;
|
||||||
int size = 0;
|
int64 size = 0;
|
||||||
std::unique_ptr<Ui::PreparedFileInformation> information;
|
std::unique_ptr<Ui::PreparedFileInformation> information;
|
||||||
QImage preview;
|
QImage preview;
|
||||||
QSize shownDimensions;
|
QSize shownDimensions;
|
||||||
|
@ -91,6 +91,7 @@ struct PreparedList {
|
||||||
Directory,
|
Directory,
|
||||||
EmptyFile,
|
EmptyFile,
|
||||||
TooLargeFile,
|
TooLargeFile,
|
||||||
|
PremiumRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
PreparedList() = default;
|
PreparedList() = default;
|
||||||
|
|
|
@ -502,7 +502,7 @@ Storage::Cache::Key StorageFileLocation::bigFileBaseCacheKey() const {
|
||||||
| (_id >> 48);
|
| (_id >> 48);
|
||||||
const auto low = (_id << 16);
|
const auto low = (_id << 16);
|
||||||
|
|
||||||
Ensures((low & 0xFFULL) == 0);
|
Ensures((low & 0x1FFULL) == 0);
|
||||||
return Storage::Cache::Key{ high, low };
|
return Storage::Cache::Key{ high, low };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ ImageLocation FromWebDocument(const MTPWebDocument &document) {
|
||||||
// We don't use size from WebDocument, because it is not reliable.
|
// We don't use size from WebDocument, because it is not reliable.
|
||||||
// It can be > 0 and different from the real size
|
// It can be > 0 and different from the real size
|
||||||
// that we get in upload.WebFile result.
|
// that we get in upload.WebFile result.
|
||||||
//auto filesize = 0; // data.vsize().v;
|
//auto filesize = int64(); // data.vsize().v;
|
||||||
return ImageLocation(
|
return ImageLocation(
|
||||||
DownloadLocation{ WebFileLocation(
|
DownloadLocation{ WebFileLocation(
|
||||||
data.vurl().v,
|
data.vurl().v,
|
||||||
|
@ -323,7 +323,7 @@ ImageLocation FromWebDocument(const MTPWebDocument &document) {
|
||||||
// We don't use size from WebDocument, because it is not reliable.
|
// We don't use size from WebDocument, because it is not reliable.
|
||||||
// It can be > 0 and different from the real size
|
// It can be > 0 and different from the real size
|
||||||
// that we get in upload.WebFile result.
|
// that we get in upload.WebFile result.
|
||||||
//auto filesize = 0; // data.vsize().v;
|
//auto filesize = int64(); // data.vsize().v;
|
||||||
return ImageLocation(
|
return ImageLocation(
|
||||||
DownloadLocation{ PlainUrlLocation{ qs(data.vurl()) } },
|
DownloadLocation{ PlainUrlLocation{ qs(data.vurl()) } },
|
||||||
size.width(),
|
size.width(),
|
||||||
|
|
|
@ -9,9 +9,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
||||||
inline constexpr auto FileStatusSizeReady = 0x7FFFFFF0;
|
inline constexpr auto FileStatusSizeReady = 0xFFFFFFF0LL;
|
||||||
inline constexpr auto FileStatusSizeLoaded = 0x7FFFFFF1;
|
inline constexpr auto FileStatusSizeLoaded = 0xFFFFFFF1LL;
|
||||||
inline constexpr auto FileStatusSizeFailed = 0x7FFFFFF2;
|
inline constexpr auto FileStatusSizeFailed = 0xFFFFFFF2LL;
|
||||||
|
|
||||||
[[nodiscard]] QString FormatSizeText(qint64 size);
|
[[nodiscard]] QString FormatSizeText(qint64 size);
|
||||||
[[nodiscard]] QString FormatDownloadText(qint64 ready, qint64 total);
|
[[nodiscard]] QString FormatDownloadText(qint64 ready, qint64 total);
|
||||||
|
|
|
@ -496,7 +496,7 @@ SendMediaReady PrepareWallPaper(MTP::DcId dcId, const QImage &image) {
|
||||||
MTP_bytes(),
|
MTP_bytes(),
|
||||||
MTP_int(base::unixtime::now()),
|
MTP_int(base::unixtime::now()),
|
||||||
MTP_string("image/jpeg"),
|
MTP_string("image/jpeg"),
|
||||||
MTP_int(jpeg.size()),
|
MTP_long(jpeg.size()),
|
||||||
MTP_vector<MTPPhotoSize>(sizes),
|
MTP_vector<MTPPhotoSize>(sizes),
|
||||||
MTPVector<MTPVideoSize>(),
|
MTPVector<MTPVideoSize>(),
|
||||||
MTP_int(dcId),
|
MTP_int(dcId),
|
||||||
|
|
|
@ -431,7 +431,7 @@ SendMediaReady PrepareThemeMedia(
|
||||||
MTP_bytes(),
|
MTP_bytes(),
|
||||||
MTP_int(base::unixtime::now()),
|
MTP_int(base::unixtime::now()),
|
||||||
MTP_string("application/x-tgtheme-tdesktop"),
|
MTP_string("application/x-tgtheme-tdesktop"),
|
||||||
MTP_int(content.size()),
|
MTP_long(content.size()),
|
||||||
MTP_vector<MTPPhotoSize>(sizes),
|
MTP_vector<MTPPhotoSize>(sizes),
|
||||||
MTPVector<MTPVideoSize>(),
|
MTPVector<MTPVideoSize>(),
|
||||||
MTP_int(dcId),
|
MTP_int(dcId),
|
||||||
|
|
Loading…
Add table
Reference in a new issue