mirror of
https://github.com/telegramdesktop/tdesktop
synced 2024-12-29 01:52:48 +00:00
Save secure files to local storage.
This commit is contained in:
parent
c2aa9c571c
commit
2bc60fa54f
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "auth_session.h"
|
#include "auth_session.h"
|
||||||
#include "storage/localimageloader.h"
|
#include "storage/localimageloader.h"
|
||||||
|
#include "storage/localstorage.h"
|
||||||
#include "storage/file_upload.h"
|
#include "storage/file_upload.h"
|
||||||
#include "storage/file_download.h"
|
#include "storage/file_download.h"
|
||||||
|
|
||||||
@ -323,21 +324,21 @@ void FormController::uploadEncryptedScan(
|
|||||||
auto &file = _form.fields[fieldIndex].filesInEdit[fileIndex];
|
auto &file = _form.fields[fieldIndex].filesInEdit[fileIndex];
|
||||||
file.uploaded = std::make_unique<UploadedScan>(std::move(data));
|
file.uploaded = std::make_unique<UploadedScan>(std::move(data));
|
||||||
|
|
||||||
auto uploaded = std::make_shared<FileLoadResult>(
|
auto prepared = std::make_shared<FileLoadResult>(
|
||||||
TaskId(),
|
TaskId(),
|
||||||
file.uploaded->fileId,
|
file.uploaded->fileId,
|
||||||
FileLoadTo(PeerId(0), false, MsgId(0)),
|
FileLoadTo(PeerId(0), false, MsgId(0)),
|
||||||
TextWithTags(),
|
TextWithTags(),
|
||||||
std::shared_ptr<SendingAlbum>(nullptr));
|
std::shared_ptr<SendingAlbum>(nullptr));
|
||||||
uploaded->type = SendMediaType::Secure;
|
prepared->type = SendMediaType::Secure;
|
||||||
uploaded->content = QByteArray::fromRawData(
|
prepared->content = QByteArray::fromRawData(
|
||||||
reinterpret_cast<char*>(file.uploaded->bytes.data()),
|
reinterpret_cast<char*>(file.uploaded->bytes.data()),
|
||||||
file.uploaded->bytes.size());
|
file.uploaded->bytes.size());
|
||||||
uploaded->setFileData(uploaded->content);
|
prepared->setFileData(prepared->content);
|
||||||
uploaded->filemd5 = file.uploaded->md5checksum;
|
prepared->filemd5 = file.uploaded->md5checksum;
|
||||||
|
|
||||||
file.uploaded->fullId = FullMsgId(0, clientMsgId());
|
file.uploaded->fullId = FullMsgId(0, clientMsgId());
|
||||||
Auth().uploader().upload(file.uploaded->fullId, std::move(uploaded));
|
Auth().uploader().upload(file.uploaded->fullId, std::move(prepared));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormController::scanUploadDone(const Storage::UploadSecureDone &data) {
|
void FormController::scanUploadDone(const Storage::UploadSecureDone &data) {
|
||||||
@ -790,6 +791,18 @@ auto FormController::parseFiles(
|
|||||||
if (i != editData.end()) {
|
if (i != editData.end()) {
|
||||||
normal.image = i->fields.image;
|
normal.image = i->fields.image;
|
||||||
normal.downloadOffset = i->fields.downloadOffset;
|
normal.downloadOffset = i->fields.downloadOffset;
|
||||||
|
if (i->uploaded) {
|
||||||
|
Local::writeImage(
|
||||||
|
StorageKey(
|
||||||
|
storageMix32To64(
|
||||||
|
SecureFileLocation,
|
||||||
|
normal.dcId),
|
||||||
|
normal.id),
|
||||||
|
StorageImageSaved(QByteArray::fromRawData(
|
||||||
|
reinterpret_cast<const char*>(
|
||||||
|
i->uploaded->bytes.data()),
|
||||||
|
i->uploaded->bytes.size())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
result.push_back(std::move(normal));
|
result.push_back(std::move(normal));
|
||||||
} break;
|
} break;
|
||||||
|
@ -773,6 +773,12 @@ bool mtpFileLoader::feedPart(int offset, bytes::const_span buffer) {
|
|||||||
Local::writeStickerImage(mkey, _data);
|
Local::writeStickerImage(mkey, _data);
|
||||||
} else if (_locationType == AudioFileLocation) {
|
} else if (_locationType == AudioFileLocation) {
|
||||||
Local::writeAudio(mkey, _data);
|
Local::writeAudio(mkey, _data);
|
||||||
|
} else if (_locationType == SecureFileLocation) {
|
||||||
|
Local::writeImage(
|
||||||
|
StorageKey(
|
||||||
|
storageMix32To64(_locationType, _dcId),
|
||||||
|
_id),
|
||||||
|
StorageImageSaved(_data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -896,6 +902,10 @@ bool mtpFileLoader::tryLoadLocal() {
|
|||||||
_localTaskId = Local::startStickerImageLoad(mkey, this);
|
_localTaskId = Local::startStickerImageLoad(mkey, this);
|
||||||
} else if (_locationType == AudioFileLocation) {
|
} else if (_locationType == AudioFileLocation) {
|
||||||
_localTaskId = Local::startAudioLoad(mkey, this);
|
_localTaskId = Local::startAudioLoad(mkey, this);
|
||||||
|
} else if (_locationType == SecureFileLocation) {
|
||||||
|
_localTaskId = Local::startImageLoad(StorageKey(
|
||||||
|
storageMix32To64(_locationType, _dcId),
|
||||||
|
_id), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user