MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / process

Method process

Telegram/SourceFiles/storage/localimageloader.cpp:659–1044  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

657}
658
659void FileLoadTask::process(ProcessArgs &&args) {
660 _result = MakePreparedFile({
661 .taskId = id(),
662 .id = _id,
663 .to = _to,
664 .caption = _caption,
665 .spoiler = _spoiler,
666 .album = _album,
667 });
668 if (const auto cover = _videoCover.get()) {
669 cover->process();
670 if (const auto &result = cover->peekResult()) {
671 if (result->type == SendMediaType::Photo
672 && !result->fileparts.empty()) {
673 _result->videoCover = result;
674 }
675 }
676 }
677
678 QString filename, filemime;
679 qint64 filesize = 0;
680 QByteArray filedata;
681
682 auto isAnimation = false;
683 auto isSong = false;
684 auto isVideo = false;
685 auto isVoice = (_type == SendMediaType::Audio);
686 auto isRound = (_type == SendMediaType::Round);
687 auto isSticker = false;
688
689 auto fullimage = QImage();
690 auto fullimagebytes = QByteArray();
691 auto fullimageformat = QByteArray();
692 auto info = _filepath.isEmpty() ? QFileInfo() : QFileInfo(_filepath);
693 if (info.exists()) {
694 if (info.isDir()) {
695 _result->filesize = -1;
696 return;
697 }
698
699 // Voice sending is supported only from memory for now.
700 // Because for voice we force mime type and don't read MediaInformation.
701 // For a real file we always read mime type and read MediaInformation.
702 Assert(!isVoice && !isRound);
703
704 filesize = info.size();
705 filename = info.fileName();
706 if (!_information) {
707 _information = readMediaInformation(Core::MimeTypeForFile(info).name());
708 }
709 filemime = _information->filemime;
710 if (auto image = std::get_if<Ui::PreparedFileInformation::Image>(
711 &_information->media)) {
712 fullimage = base::take(image->data);
713 fullimagebytes = base::take(image->bytes);
714 fullimageformat = base::take(image->format);
715 if (!Core::IsMimeSticker(filemime)
716 && fullimageformat != u"jpeg"_q) {

Callers 1

onTaskAddedMethod · 0.45

Calls 15

MakePreparedFileFunction · 0.85
QByteArrayClass · 0.85
QFileInfoClass · 0.85
MimeTypeForFileFunction · 0.85
IsMimeStickerFunction · 0.85
filedialogDefaultNameFunction · 0.85
MimeTypeForDataFunction · 0.85
ValidateThumbDimensionsFunction · 0.85
MimeTypeForNameFunction · 0.85
MTP_stringFunction · 0.85
MTP_longFunction · 0.85

Tested by

no test coverage detected