Move FileType to FileType.h.
GitOrigin-RevId: 7e35c0f30b7755755b0583704dcfe344cc28d117
This commit is contained in:
parent
3c46828749
commit
e5400074ce
@ -501,6 +501,7 @@ set(TDLIB_SOURCE
|
||||
td/telegram/files/FileLoadManager.h
|
||||
td/telegram/files/FileLocation.h
|
||||
td/telegram/files/FileManager.h
|
||||
td/telegram/files/FileType.h
|
||||
td/telegram/files/FileSourceId.h
|
||||
td/telegram/files/FileStats.h
|
||||
td/telegram/files/FileStatsWorker.h
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/DocumentsManager.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/logevent/LogEvent.h"
|
||||
#include "td/telegram/misc.h"
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/ConfigShared.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/InlineQueriesManager.h"
|
||||
#include "td/telegram/logevent/LogEvent.h"
|
||||
|
@ -9,7 +9,9 @@
|
||||
#include "td/telegram/AnimationsManager.h"
|
||||
#include "td/telegram/AudiosManager.h"
|
||||
#include "td/telegram/files/FileEncryptionKey.h"
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/net/DcId.h"
|
||||
#include "td/telegram/Photo.h"
|
||||
#include "td/telegram/StickersManager.h"
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DocumentsManager.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Game.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/InputMessageText.h"
|
||||
|
@ -20,7 +20,9 @@
|
||||
#include "td/telegram/DocumentsManager.hpp"
|
||||
#include "td/telegram/files/FileId.h"
|
||||
#include "td/telegram/files/FileId.hpp"
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Game.h"
|
||||
#include "td/telegram/Game.hpp"
|
||||
#include "td/telegram/Global.h"
|
||||
|
@ -15,7 +15,9 @@
|
||||
#include "td/telegram/DraftMessage.hpp"
|
||||
#include "td/telegram/FileReferenceManager.h"
|
||||
#include "td/telegram/files/FileId.hpp"
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/HashtagHints.h"
|
||||
#include "td/telegram/InlineQueriesManager.h"
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
||||
#include "td/telegram/files/FileEncryptionKey.h"
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/net/DcId.h"
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/files/FileId.h"
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/SecretInputMedia.h"
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/files/FileId.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/net/NetQueryDispatcher.h"
|
||||
|
@ -8,7 +8,9 @@
|
||||
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/files/FileEncryptionKey.h"
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/net/DcId.h"
|
||||
|
@ -16,7 +16,9 @@
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/DocumentsManager.h"
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/logevent/LogEvent.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
|
@ -6,16 +6,6 @@
|
||||
//
|
||||
#include "td/telegram/Td.h"
|
||||
|
||||
#include "td/telegram/net/ConnectionCreator.h"
|
||||
#include "td/telegram/net/DcId.h"
|
||||
#include "td/telegram/net/MtprotoHeader.h"
|
||||
#include "td/telegram/net/NetQuery.h"
|
||||
#include "td/telegram/net/NetQueryDelayer.h"
|
||||
#include "td/telegram/net/NetQueryDispatcher.h"
|
||||
#include "td/telegram/net/NetStatsManager.h"
|
||||
#include "td/telegram/net/NetType.h"
|
||||
#include "td/telegram/net/TempAuthKeyWatchdog.h"
|
||||
|
||||
#include "td/telegram/AccessRights.h"
|
||||
#include "td/telegram/AnimationsManager.h"
|
||||
#include "td/telegram/AudiosManager.h"
|
||||
@ -36,6 +26,7 @@
|
||||
#include "td/telegram/files/FileGcParameters.h"
|
||||
#include "td/telegram/files/FileId.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/HashtagHints.h"
|
||||
#include "td/telegram/InlineQueriesManager.h"
|
||||
@ -46,6 +37,15 @@
|
||||
#include "td/telegram/MessageId.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/net/ConnectionCreator.h"
|
||||
#include "td/telegram/net/DcId.h"
|
||||
#include "td/telegram/net/MtprotoHeader.h"
|
||||
#include "td/telegram/net/NetQuery.h"
|
||||
#include "td/telegram/net/NetQueryDelayer.h"
|
||||
#include "td/telegram/net/NetQueryDispatcher.h"
|
||||
#include "td/telegram/net/NetStatsManager.h"
|
||||
#include "td/telegram/net/NetType.h"
|
||||
#include "td/telegram/net/TempAuthKeyWatchdog.h"
|
||||
#include "td/telegram/NotificationGroupId.h"
|
||||
#include "td/telegram/NotificationId.h"
|
||||
#include "td/telegram/NotificationManager.h"
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/Photo.h"
|
||||
#include "td/telegram/Td.h"
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "td/telegram/files/FileData.h"
|
||||
#include "td/telegram/files/FileDbId.h"
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
|
||||
#include "td/actor/PromiseFuture.h"
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
||||
#include "td/telegram/files/FileLoaderUtils.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/net/DcId.h"
|
||||
#include "td/telegram/SecureStorage.h"
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "td/telegram/files/FileLoader.h"
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/common.h"
|
||||
|
@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/StringBuilder.h"
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "td/telegram/files/FileGcWorker.h"
|
||||
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Global.h"
|
||||
|
||||
#include "td/utils/format.h"
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "td/actor/PromiseFuture.h"
|
||||
|
||||
#include "td/telegram/files/FileGcParameters.h"
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileStats.h"
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "td/telegram/files/FileId.h"
|
||||
#include "td/telegram/files/FileLoaderUtils.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/net/NetQuery.h"
|
||||
#include "td/telegram/net/NetQueryDispatcher.h"
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/net/DcId.h"
|
||||
#include "td/telegram/net/NetQueryDispatcher.h"
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "td/telegram/files/FileFromBytes.h"
|
||||
#include "td/telegram/files/FileHashUploader.h"
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/files/FileUploader.h"
|
||||
#include "td/telegram/files/ResourceManager.h"
|
||||
#include "td/telegram/net/DcId.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/ResourceState.h"
|
||||
#include "td/telegram/net/NetQuery.h"
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/common.h"
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include "td/telegram/files/FileBitmask.h"
|
||||
#include "td/telegram/files/FileEncryptionKey.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/net/DcId.h"
|
||||
|
||||
#include "td/utils/base64.h"
|
||||
@ -27,151 +28,6 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
enum class FileType : int8 {
|
||||
Thumbnail,
|
||||
ProfilePhoto,
|
||||
Photo,
|
||||
VoiceNote,
|
||||
Video,
|
||||
Document,
|
||||
Encrypted,
|
||||
Temp,
|
||||
Sticker,
|
||||
Audio,
|
||||
Animation,
|
||||
EncryptedThumbnail,
|
||||
Wallpaper,
|
||||
VideoNote,
|
||||
SecureRaw,
|
||||
Secure,
|
||||
Size,
|
||||
None
|
||||
};
|
||||
|
||||
inline FileType from_td_api(const td_api::FileType &file_type) {
|
||||
switch (file_type.get_id()) {
|
||||
case td_api::fileTypeThumbnail::ID:
|
||||
return FileType::Thumbnail;
|
||||
case td_api::fileTypeProfilePhoto::ID:
|
||||
return FileType::ProfilePhoto;
|
||||
case td_api::fileTypePhoto::ID:
|
||||
return FileType::Photo;
|
||||
case td_api::fileTypeVoiceNote::ID:
|
||||
return FileType::VoiceNote;
|
||||
case td_api::fileTypeVideo::ID:
|
||||
return FileType::Video;
|
||||
case td_api::fileTypeDocument::ID:
|
||||
return FileType::Document;
|
||||
case td_api::fileTypeSecret::ID:
|
||||
return FileType::Encrypted;
|
||||
case td_api::fileTypeUnknown::ID:
|
||||
return FileType::Temp;
|
||||
case td_api::fileTypeSticker::ID:
|
||||
return FileType::Sticker;
|
||||
case td_api::fileTypeAudio::ID:
|
||||
return FileType::Audio;
|
||||
case td_api::fileTypeAnimation::ID:
|
||||
return FileType::Animation;
|
||||
case td_api::fileTypeSecretThumbnail::ID:
|
||||
return FileType::EncryptedThumbnail;
|
||||
case td_api::fileTypeWallpaper::ID:
|
||||
return FileType::Wallpaper;
|
||||
case td_api::fileTypeVideoNote::ID:
|
||||
return FileType::VideoNote;
|
||||
case td_api::fileTypeSecure::ID:
|
||||
return FileType::Secure;
|
||||
case td_api::fileTypeNone::ID:
|
||||
return FileType::None;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return FileType::None;
|
||||
}
|
||||
}
|
||||
|
||||
inline tl_object_ptr<td_api::FileType> as_td_api(FileType file_type) {
|
||||
switch (file_type) {
|
||||
case FileType::Thumbnail:
|
||||
return make_tl_object<td_api::fileTypeThumbnail>();
|
||||
case FileType::ProfilePhoto:
|
||||
return make_tl_object<td_api::fileTypeProfilePhoto>();
|
||||
case FileType::Photo:
|
||||
return make_tl_object<td_api::fileTypePhoto>();
|
||||
case FileType::VoiceNote:
|
||||
return make_tl_object<td_api::fileTypeVoiceNote>();
|
||||
case FileType::Video:
|
||||
return make_tl_object<td_api::fileTypeVideo>();
|
||||
case FileType::Document:
|
||||
return make_tl_object<td_api::fileTypeDocument>();
|
||||
case FileType::Encrypted:
|
||||
return make_tl_object<td_api::fileTypeSecret>();
|
||||
case FileType::Temp:
|
||||
return make_tl_object<td_api::fileTypeUnknown>();
|
||||
case FileType::Sticker:
|
||||
return make_tl_object<td_api::fileTypeSticker>();
|
||||
case FileType::Audio:
|
||||
return make_tl_object<td_api::fileTypeAudio>();
|
||||
case FileType::Animation:
|
||||
return make_tl_object<td_api::fileTypeAnimation>();
|
||||
case FileType::EncryptedThumbnail:
|
||||
return make_tl_object<td_api::fileTypeSecretThumbnail>();
|
||||
case FileType::Wallpaper:
|
||||
return make_tl_object<td_api::fileTypeWallpaper>();
|
||||
case FileType::VideoNote:
|
||||
return make_tl_object<td_api::fileTypeVideoNote>();
|
||||
case FileType::Secure:
|
||||
return make_tl_object<td_api::fileTypeSecure>();
|
||||
case FileType::SecureRaw:
|
||||
UNREACHABLE();
|
||||
return make_tl_object<td_api::fileTypeSecure>();
|
||||
case FileType::None:
|
||||
return make_tl_object<td_api::fileTypeNone>();
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr int32 file_type_size = static_cast<int32>(FileType::Size);
|
||||
extern const char *file_type_name[file_type_size];
|
||||
|
||||
inline StringBuilder &operator<<(StringBuilder &string_builder, FileType file_type) {
|
||||
return string_builder << file_type_name[static_cast<int32>(file_type)];
|
||||
}
|
||||
|
||||
enum class FileDirType : int8 { Secure, Common };
|
||||
|
||||
inline FileDirType get_file_dir_type(FileType file_type) {
|
||||
switch (file_type) {
|
||||
case FileType::Thumbnail:
|
||||
case FileType::ProfilePhoto:
|
||||
case FileType::Encrypted:
|
||||
case FileType::Sticker:
|
||||
case FileType::Temp:
|
||||
case FileType::Wallpaper:
|
||||
case FileType::EncryptedThumbnail:
|
||||
case FileType::Secure:
|
||||
case FileType::SecureRaw:
|
||||
return FileDirType::Secure;
|
||||
default:
|
||||
return FileDirType::Common;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool is_file_big(FileType file_type, int64 expected_size) {
|
||||
switch (file_type) {
|
||||
case FileType::Thumbnail:
|
||||
case FileType::ProfilePhoto:
|
||||
case FileType::Photo:
|
||||
case FileType::EncryptedThumbnail:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
constexpr int64 SMALL_FILE_MAX_SIZE = 10 << 20;
|
||||
return expected_size > SMALL_FILE_MAX_SIZE;
|
||||
}
|
||||
|
||||
struct EmptyRemoteFileLocation {
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileSourceId.h"
|
||||
#include "td/telegram/files/FileStats.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Location.h"
|
||||
|
||||
#include "td/actor/actor.h"
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/files/FileEncryptionKey.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Version.h"
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
|
@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/StringBuilder.h"
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "td/telegram/files/FileData.h"
|
||||
#include "td/telegram/files/FileDb.h"
|
||||
#include "td/telegram/files/FileLoaderUtils.h"
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
|
||||
|
160
td/telegram/files/FileType.h
Normal file
160
td/telegram/files/FileType.h
Normal file
@ -0,0 +1,160 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2019
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/td_api.h"
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
enum class FileType : int8 {
|
||||
Thumbnail,
|
||||
ProfilePhoto,
|
||||
Photo,
|
||||
VoiceNote,
|
||||
Video,
|
||||
Document,
|
||||
Encrypted,
|
||||
Temp,
|
||||
Sticker,
|
||||
Audio,
|
||||
Animation,
|
||||
EncryptedThumbnail,
|
||||
Wallpaper,
|
||||
VideoNote,
|
||||
SecureRaw,
|
||||
Secure,
|
||||
Size,
|
||||
None
|
||||
};
|
||||
|
||||
inline FileType from_td_api(const td_api::FileType &file_type) {
|
||||
switch (file_type.get_id()) {
|
||||
case td_api::fileTypeThumbnail::ID:
|
||||
return FileType::Thumbnail;
|
||||
case td_api::fileTypeProfilePhoto::ID:
|
||||
return FileType::ProfilePhoto;
|
||||
case td_api::fileTypePhoto::ID:
|
||||
return FileType::Photo;
|
||||
case td_api::fileTypeVoiceNote::ID:
|
||||
return FileType::VoiceNote;
|
||||
case td_api::fileTypeVideo::ID:
|
||||
return FileType::Video;
|
||||
case td_api::fileTypeDocument::ID:
|
||||
return FileType::Document;
|
||||
case td_api::fileTypeSecret::ID:
|
||||
return FileType::Encrypted;
|
||||
case td_api::fileTypeUnknown::ID:
|
||||
return FileType::Temp;
|
||||
case td_api::fileTypeSticker::ID:
|
||||
return FileType::Sticker;
|
||||
case td_api::fileTypeAudio::ID:
|
||||
return FileType::Audio;
|
||||
case td_api::fileTypeAnimation::ID:
|
||||
return FileType::Animation;
|
||||
case td_api::fileTypeSecretThumbnail::ID:
|
||||
return FileType::EncryptedThumbnail;
|
||||
case td_api::fileTypeWallpaper::ID:
|
||||
return FileType::Wallpaper;
|
||||
case td_api::fileTypeVideoNote::ID:
|
||||
return FileType::VideoNote;
|
||||
case td_api::fileTypeSecure::ID:
|
||||
return FileType::Secure;
|
||||
case td_api::fileTypeNone::ID:
|
||||
return FileType::None;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return FileType::None;
|
||||
}
|
||||
}
|
||||
|
||||
inline tl_object_ptr<td_api::FileType> as_td_api(FileType file_type) {
|
||||
switch (file_type) {
|
||||
case FileType::Thumbnail:
|
||||
return make_tl_object<td_api::fileTypeThumbnail>();
|
||||
case FileType::ProfilePhoto:
|
||||
return make_tl_object<td_api::fileTypeProfilePhoto>();
|
||||
case FileType::Photo:
|
||||
return make_tl_object<td_api::fileTypePhoto>();
|
||||
case FileType::VoiceNote:
|
||||
return make_tl_object<td_api::fileTypeVoiceNote>();
|
||||
case FileType::Video:
|
||||
return make_tl_object<td_api::fileTypeVideo>();
|
||||
case FileType::Document:
|
||||
return make_tl_object<td_api::fileTypeDocument>();
|
||||
case FileType::Encrypted:
|
||||
return make_tl_object<td_api::fileTypeSecret>();
|
||||
case FileType::Temp:
|
||||
return make_tl_object<td_api::fileTypeUnknown>();
|
||||
case FileType::Sticker:
|
||||
return make_tl_object<td_api::fileTypeSticker>();
|
||||
case FileType::Audio:
|
||||
return make_tl_object<td_api::fileTypeAudio>();
|
||||
case FileType::Animation:
|
||||
return make_tl_object<td_api::fileTypeAnimation>();
|
||||
case FileType::EncryptedThumbnail:
|
||||
return make_tl_object<td_api::fileTypeSecretThumbnail>();
|
||||
case FileType::Wallpaper:
|
||||
return make_tl_object<td_api::fileTypeWallpaper>();
|
||||
case FileType::VideoNote:
|
||||
return make_tl_object<td_api::fileTypeVideoNote>();
|
||||
case FileType::Secure:
|
||||
return make_tl_object<td_api::fileTypeSecure>();
|
||||
case FileType::SecureRaw:
|
||||
UNREACHABLE();
|
||||
return make_tl_object<td_api::fileTypeSecure>();
|
||||
case FileType::None:
|
||||
return make_tl_object<td_api::fileTypeNone>();
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr int32 file_type_size = static_cast<int32>(FileType::Size);
|
||||
extern const char *file_type_name[file_type_size];
|
||||
|
||||
inline StringBuilder &operator<<(StringBuilder &string_builder, FileType file_type) {
|
||||
return string_builder << file_type_name[static_cast<int32>(file_type)];
|
||||
}
|
||||
|
||||
enum class FileDirType : int8 { Secure, Common };
|
||||
|
||||
inline FileDirType get_file_dir_type(FileType file_type) {
|
||||
switch (file_type) {
|
||||
case FileType::Thumbnail:
|
||||
case FileType::ProfilePhoto:
|
||||
case FileType::Encrypted:
|
||||
case FileType::Sticker:
|
||||
case FileType::Temp:
|
||||
case FileType::Wallpaper:
|
||||
case FileType::EncryptedThumbnail:
|
||||
case FileType::Secure:
|
||||
case FileType::SecureRaw:
|
||||
return FileDirType::Secure;
|
||||
default:
|
||||
return FileDirType::Common;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool is_file_big(FileType file_type, int64 expected_size) {
|
||||
switch (file_type) {
|
||||
case FileType::Thumbnail:
|
||||
case FileType::ProfilePhoto:
|
||||
case FileType::Photo:
|
||||
case FileType::EncryptedThumbnail:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
constexpr int64 SMALL_FILE_MAX_SIZE = 10 << 20;
|
||||
return expected_size > SMALL_FILE_MAX_SIZE;
|
||||
}
|
||||
|
||||
} // namespace td
|
@ -9,6 +9,7 @@
|
||||
#include "td/telegram/files/FileEncryptionKey.h"
|
||||
#include "td/telegram/files/FileLoader.h"
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
|
||||
#include "td/utils/port/FileFd.h"
|
||||
#include "td/utils/Status.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include "td/telegram/td_api.h"
|
||||
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/net/NetType.h"
|
||||
|
||||
#include "td/net/NetStats.h"
|
||||
|
Reference in New Issue
Block a user