From 641ee080c17a1c10629056b5770541ee7334bbea Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 25 Apr 2022 19:00:40 +0300 Subject: [PATCH] Improve names of FileType::Secure. --- td/telegram/SecureManager.cpp | 2 +- td/telegram/SecureValue.cpp | 19 ++++++++++--------- td/telegram/Td.cpp | 2 +- td/telegram/files/FileDownloader.cpp | 2 +- td/telegram/files/FileLocation.h | 4 ++-- td/telegram/files/FileManager.cpp | 10 +++++----- td/telegram/files/FileManager.h | 4 ++-- td/telegram/files/FileType.cpp | 22 +++++++++++----------- td/telegram/files/FileType.h | 4 ++-- td/telegram/net/NetStatsManager.h | 2 +- 10 files changed, 36 insertions(+), 35 deletions(-) diff --git a/td/telegram/SecureManager.cpp b/td/telegram/SecureManager.cpp index c26e1cbae..b2068d055 100644 --- a/td/telegram/SecureManager.cpp +++ b/td/telegram/SecureManager.cpp @@ -548,7 +548,7 @@ void SetSecureValue::start_upload(FileManager *file_manager, FileId &file_id, Se auto download_file_id = file_manager->dup_file_id(file_id); file_id = file_manager - ->register_generate(FileType::Secure, FileLocationSource::FromServer, file_view.suggested_path(), + ->register_generate(FileType::SecureEncrypted, FileLocationSource::FromServer, file_view.suggested_path(), PSTRING() << "#file_id#" << download_file_id.get(), DialogId(), file_view.size()) .ok(); } diff --git a/td/telegram/SecureValue.cpp b/td/telegram/SecureValue.cpp index 7f09ab71c..5a635fb53 100644 --- a/td/telegram/SecureValue.cpp +++ b/td/telegram/SecureValue.cpp @@ -354,8 +354,8 @@ EncryptedSecureFile get_encrypted_secure_file(FileManager *file_manager, break; } result.file.file_id = file_manager->register_remote( - FullRemoteFileLocation(FileType::Secure, secure_file->id_, secure_file->access_hash_, DcId::internal(dc_id), - ""), + FullRemoteFileLocation(FileType::SecureEncrypted, secure_file->id_, secure_file->access_hash_, + DcId::internal(dc_id), ""), FileLocationSource::FromServer, DialogId(), 0, secure_file->size_, PSTRING() << secure_file->id_ << ".jpg"); result.file.date = secure_file->date_; if (result.file.date < 0) { @@ -427,12 +427,12 @@ static td_api::object_ptr get_dated_file_object(FileManager * LOG(ERROR) << "Have wrong file in get_dated_file_object"; return nullptr; } - dated_file.file_id = - file_manager->register_remote(FullRemoteFileLocation(FileType::SecureRaw, file_view.remote_location().get_id(), - file_view.remote_location().get_access_hash(), - file_view.remote_location().get_dc_id(), ""), - FileLocationSource::FromServer, DialogId(), file_view.size(), - file_view.expected_size(), file_view.suggested_path()); + dated_file.file_id = file_manager->register_remote( + FullRemoteFileLocation(FileType::SecureDecrypted, file_view.remote_location().get_id(), + file_view.remote_location().get_access_hash(), file_view.remote_location().get_dc_id(), + ""), + FileLocationSource::FromServer, DialogId(), file_view.size(), file_view.expected_size(), + file_view.suggested_path()); return get_dated_file_object(file_manager, dated_file); } @@ -843,7 +843,8 @@ static Status check_document_number(string &number) { } static Result get_secure_file(FileManager *file_manager, td_api::object_ptr &&file) { - TRY_RESULT(file_id, file_manager->get_input_file_id(FileType::Secure, file, DialogId(), false, false, false, true)); + TRY_RESULT(file_id, + file_manager->get_input_file_id(FileType::SecureEncrypted, file, DialogId(), false, false, false, true)); DatedFile result; result.file_id = file_id; result.date = G()->unix_time(); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 06a4a352c..389faefcc 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6575,7 +6575,7 @@ void Td::on_request(uint64 id, td_api::uploadFile &request) { auto file_type = request.file_type_ == nullptr ? FileType::Temp : get_file_type(*request.file_type_); bool is_secret = file_type == FileType::Encrypted || file_type == FileType::EncryptedThumbnail; - bool is_secure = file_type == FileType::Secure; + bool is_secure = file_type == FileType::SecureEncrypted; auto r_file_id = file_manager_->get_input_file_id(file_type, request.file_, DialogId(), false, is_secret, !is_secure && !is_secret, is_secure); if (r_file_id.is_error()) { diff --git a/td/telegram/files/FileDownloader.cpp b/td/telegram/files/FileDownloader.cpp index a694426d3..bc701dbba 100644 --- a/td/telegram/files/FileDownloader.cpp +++ b/td/telegram/files/FileDownloader.cpp @@ -63,7 +63,7 @@ Result FileDownloader::init() { if (encryption_key_.is_secure() && !encryption_key_.has_value_hash()) { LOG(ERROR) << "Can't download Secure file with unknown value_hash"; } - if (remote_.file_type_ == FileType::Secure) { + if (remote_.file_type_ == FileType::SecureEncrypted) { size_ = 0; } int32 part_size = 0; diff --git a/td/telegram/files/FileLocation.h b/td/telegram/files/FileLocation.h index 7c8a4ea5c..2a120afc4 100644 --- a/td/telegram/files/FileLocation.h +++ b/td/telegram/files/FileLocation.h @@ -361,13 +361,13 @@ class FullRemoteFileLocation { return file_type_ == FileType::Encrypted; } bool is_encrypted_secure() const { - return file_type_ == FileType::Secure; + return file_type_ == FileType::SecureEncrypted; } bool is_encrypted_any() const { return is_encrypted_secret() || is_encrypted_secure(); } bool is_secure() const { - return file_type_ == FileType::SecureRaw || file_type_ == FileType::Secure; + return file_type_ == FileType::SecureDecrypted || file_type_ == FileType::SecureEncrypted; } bool is_document() const { return is_common() && !is_secure() && !is_encrypted_secret(); diff --git a/td/telegram/files/FileManager.cpp b/td/telegram/files/FileManager.cpp index c1416726a..f5cf6e510 100644 --- a/td/telegram/files/FileManager.cpp +++ b/td/telegram/files/FileManager.cpp @@ -923,8 +923,8 @@ string FileManager::get_file_name(FileType file_type, Slice path) { case FileType::Encrypted: case FileType::Temp: case FileType::EncryptedThumbnail: - case FileType::Secure: - case FileType::SecureRaw: + case FileType::SecureEncrypted: + case FileType::SecureDecrypted: case FileType::DocumentAsFile: case FileType::CallLog: break; @@ -2796,7 +2796,7 @@ void FileManager::run_upload(FileNodePtr node, std::vector bad_parts) { << ", generate_id = " << node->generate_id_ << ", generate_was_update = " << node->generate_was_update_; return; } - if (file_view.has_generate_location() && file_view.generate_location().file_type_ == FileType::Secure) { + if (file_view.has_generate_location() && file_view.generate_location().file_type_ == FileType::SecureEncrypted) { // Can't upload secure file before its size is known LOG(INFO) << "Can't upload secure file " << node->main_file_id_ << " before it's size is known"; return; @@ -2815,7 +2815,7 @@ void FileManager::run_upload(FileNodePtr node, std::vector bad_parts) { } // create encryption key if necessary - if (file_view.has_local_location() && file_view.local_location().file_type_ == FileType::Secure && + if (file_view.has_local_location() && file_view.local_location().file_type_ == FileType::SecureEncrypted && file_view.encryption_key().empty()) { CHECK(!node->file_ids_.empty()); bool success = set_encryption_key(node->file_ids_[0], FileEncryptionKey::create_secure_key()); @@ -3148,7 +3148,7 @@ Result FileManager::get_input_file_id(FileType type, const tl_object_ptr get_by_hash = false; } - auto new_type = is_encrypted ? FileType::Encrypted : (is_secure ? FileType::Secure : type); + auto new_type = is_encrypted ? FileType::Encrypted : (is_secure ? FileType::SecureEncrypted : type); auto r_file_id = [&]() -> Result { switch (file->get_id()) { diff --git a/td/telegram/files/FileManager.h b/td/telegram/files/FileManager.h index 917782ef5..9eda24825 100644 --- a/td/telegram/files/FileManager.h +++ b/td/telegram/files/FileManager.h @@ -305,10 +305,10 @@ class FileView { return get_type() == FileType::Encrypted; } bool is_encrypted_secure() const { - return get_type() == FileType::Secure; + return get_type() == FileType::SecureEncrypted; } bool is_secure() const { - return get_type() == FileType::Secure || get_type() == FileType::SecureRaw; + return get_type() == FileType::SecureEncrypted || get_type() == FileType::SecureDecrypted; } bool is_encrypted_any() const { return is_encrypted_secret() || is_encrypted_secure(); diff --git a/td/telegram/files/FileType.cpp b/td/telegram/files/FileType.cpp index 97e6dce16..b5dbec2a3 100644 --- a/td/telegram/files/FileType.cpp +++ b/td/telegram/files/FileType.cpp @@ -39,7 +39,7 @@ FileType get_file_type(const td_api::FileType &file_type) { case td_api::fileTypeVideoNote::ID: return FileType::VideoNote; case td_api::fileTypeSecure::ID: - return FileType::Secure; + return FileType::SecureEncrypted; case td_api::fileTypeNotificationSound::ID: return FileType::Ringtone; case td_api::fileTypeNone::ID: @@ -80,9 +80,9 @@ tl_object_ptr get_file_type_object(FileType file_type) { return make_tl_object(); case FileType::VideoNote: return make_tl_object(); - case FileType::Secure: + case FileType::SecureEncrypted: return make_tl_object(); - case FileType::SecureRaw: + case FileType::SecureDecrypted: UNREACHABLE(); return make_tl_object(); case FileType::Background: @@ -105,8 +105,8 @@ FileType get_main_file_type(FileType file_type) { switch (file_type) { case FileType::Wallpaper: return FileType::Background; - case FileType::SecureRaw: - return FileType::Secure; + case FileType::SecureDecrypted: + return FileType::SecureEncrypted; case FileType::DocumentAsFile: return FileType::Document; case FileType::CallLog: @@ -146,9 +146,9 @@ CSlice get_file_type_name(FileType file_type) { return CSlice("wallpapers"); case FileType::VideoNote: return CSlice("video_notes"); - case FileType::SecureRaw: + case FileType::SecureDecrypted: return CSlice("passport"); - case FileType::Secure: + case FileType::SecureEncrypted: return CSlice("passport"); case FileType::Background: return CSlice("wallpapers"); @@ -186,8 +186,8 @@ FileTypeClass get_file_type_class(FileType file_type) { case FileType::Ringtone: case FileType::CallLog: return FileTypeClass::Document; - case FileType::SecureRaw: - case FileType::Secure: + case FileType::SecureDecrypted: + case FileType::SecureEncrypted: return FileTypeClass::Secure; case FileType::Encrypted: return FileTypeClass::Encrypted; @@ -218,8 +218,8 @@ FileDirType get_file_dir_type(FileType file_type) { case FileType::Temp: case FileType::Wallpaper: case FileType::EncryptedThumbnail: - case FileType::Secure: - case FileType::SecureRaw: + case FileType::SecureEncrypted: + case FileType::SecureDecrypted: case FileType::Background: case FileType::Ringtone: return FileDirType::Secure; diff --git a/td/telegram/files/FileType.h b/td/telegram/files/FileType.h index 270cff648..5281c7901 100644 --- a/td/telegram/files/FileType.h +++ b/td/telegram/files/FileType.h @@ -29,8 +29,8 @@ enum class FileType : int32 { EncryptedThumbnail, Wallpaper, VideoNote, - SecureRaw, - Secure, + SecureDecrypted, + SecureEncrypted, Background, DocumentAsFile, Ringtone, diff --git a/td/telegram/net/NetStatsManager.h b/td/telegram/net/NetStatsManager.h index 140cf5d1d..a869aa1f2 100644 --- a/td/telegram/net/NetStatsManager.h +++ b/td/telegram/net/NetStatsManager.h @@ -52,7 +52,7 @@ struct NetworkStats { result->since_date_ = since; result->entries_.reserve(entries.size()); for (const auto &entry : entries) { - if ((entry.rx != 0 || entry.tx != 0) && entry.file_type != FileType::SecureRaw) { + if ((entry.rx != 0 || entry.tx != 0) && entry.file_type != FileType::SecureDecrypted) { result->entries_.push_back(entry.get_network_statistics_entry_object()); } }