2019-01-19 22:26:23 +01:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2019-01-19 22:26:23 +01:00
|
|
|
//
|
|
|
|
// 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/DialogId.h"
|
|
|
|
#include "td/telegram/files/FileEncryptionKey.h"
|
2019-01-20 01:21:26 +01:00
|
|
|
#include "td/telegram/files/FileLocation.h"
|
2019-01-29 12:07:58 +01:00
|
|
|
#include "td/telegram/files/FileSourceId.h"
|
2019-01-19 22:26:23 +01:00
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/format.h"
|
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
class FileData {
|
|
|
|
public:
|
|
|
|
DialogId owner_dialog_id_;
|
|
|
|
uint64 pmc_id_ = 0;
|
|
|
|
RemoteFileLocation remote_;
|
|
|
|
LocalFileLocation local_;
|
|
|
|
unique_ptr<FullGenerateFileLocation> generate_;
|
|
|
|
int64 size_ = 0;
|
|
|
|
int64 expected_size_ = 0;
|
|
|
|
string remote_name_;
|
|
|
|
string url_;
|
|
|
|
FileEncryptionKey encryption_key_;
|
2019-01-30 22:37:38 +01:00
|
|
|
vector<FileSourceId> file_source_ids_;
|
2019-01-19 22:26:23 +01:00
|
|
|
|
|
|
|
template <class StorerT>
|
2019-02-06 01:06:29 +01:00
|
|
|
void store(StorerT &storer) const;
|
2019-01-19 22:26:23 +01:00
|
|
|
|
|
|
|
template <class ParserT>
|
2019-03-17 22:40:10 +01:00
|
|
|
void parse(ParserT &parser, bool register_file_sources);
|
2019-01-19 22:26:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
inline StringBuilder &operator<<(StringBuilder &sb, const FileData &file_data) {
|
2022-05-31 15:19:08 +02:00
|
|
|
sb << "[" << tag("remote_name", file_data.remote_name_) << " " << tag("size", file_data.size_)
|
|
|
|
<< tag("expected_size", file_data.expected_size_) << " " << file_data.encryption_key_;
|
2019-01-19 22:26:23 +01:00
|
|
|
if (!file_data.url_.empty()) {
|
|
|
|
sb << tag("url", file_data.url_);
|
|
|
|
}
|
|
|
|
if (file_data.local_.type() == LocalFileLocation::Type::Full) {
|
|
|
|
sb << " local " << file_data.local_.full();
|
|
|
|
}
|
|
|
|
if (file_data.generate_ != nullptr) {
|
|
|
|
sb << " generate " << *file_data.generate_;
|
|
|
|
}
|
|
|
|
if (file_data.remote_.type() == RemoteFileLocation::Type::Full) {
|
|
|
|
sb << " remote " << file_data.remote_.full();
|
|
|
|
}
|
2022-10-06 12:48:52 +02:00
|
|
|
sb << ", sources = " << format::as_array(file_data.file_source_ids_);
|
2019-01-19 22:26:23 +01:00
|
|
|
return sb << "]";
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|