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