2022-03-02 12:03:41 +01:00
|
|
|
//
|
2022-12-31 22:28:08 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
2022-03-02 12:03:41 +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
|
|
|
|
|
2022-03-02 12:25:52 +01:00
|
|
|
#include "td/telegram/DownloadManager.h"
|
2022-03-02 12:03:41 +01:00
|
|
|
#include "td/telegram/files/FileId.h"
|
2022-03-09 01:27:03 +01:00
|
|
|
#include "td/telegram/files/FileManager.h"
|
2022-03-02 12:03:41 +01:00
|
|
|
#include "td/telegram/files/FileSourceId.h"
|
|
|
|
#include "td/telegram/td_api.h"
|
|
|
|
|
|
|
|
#include "td/actor/actor.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
2022-08-14 14:04:08 +02:00
|
|
|
#include "td/utils/Promise.h"
|
2022-03-02 12:03:41 +01:00
|
|
|
|
2022-03-09 01:27:03 +01:00
|
|
|
#include <memory>
|
|
|
|
|
2022-03-02 12:03:41 +01:00
|
|
|
namespace td {
|
|
|
|
|
2022-03-02 12:25:52 +01:00
|
|
|
class Td;
|
|
|
|
|
2022-03-02 12:03:41 +01:00
|
|
|
class DownloadManagerCallback final : public DownloadManager::Callback {
|
|
|
|
public:
|
2022-03-02 12:16:06 +01:00
|
|
|
DownloadManagerCallback(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
|
2022-03-02 12:03:41 +01:00
|
|
|
}
|
|
|
|
|
2022-03-02 12:25:52 +01:00
|
|
|
void update_counters(DownloadManager::Counters counters) final;
|
|
|
|
|
2022-03-05 01:14:31 +01:00
|
|
|
void update_file_added(FileId file_id, FileSourceId file_source_id, int32 add_date, int32 complete_date,
|
2022-03-06 01:20:18 +01:00
|
|
|
bool is_paused, DownloadManager::FileCounters counters) final;
|
2022-03-05 01:14:31 +01:00
|
|
|
|
2022-03-06 01:20:18 +01:00
|
|
|
void update_file_changed(FileId file_id, int32 complete_date, bool is_paused,
|
|
|
|
DownloadManager::FileCounters counters) final;
|
2022-03-05 01:14:31 +01:00
|
|
|
|
2022-03-06 01:20:18 +01:00
|
|
|
void update_file_removed(FileId file_id, DownloadManager::FileCounters counters) final;
|
2022-03-02 12:25:52 +01:00
|
|
|
|
|
|
|
void start_file(FileId file_id, int8 priority, ActorShared<DownloadManager> download_manager) final;
|
|
|
|
|
|
|
|
void pause_file(FileId file_id) final;
|
|
|
|
|
|
|
|
void delete_file(FileId file_id) final;
|
|
|
|
|
|
|
|
FileId dup_file_id(FileId file_id) final;
|
|
|
|
|
2022-07-23 16:01:27 +02:00
|
|
|
void get_file_search_text(FileId file_id, FileSourceId file_source_id, Promise<string> &&promise) final;
|
2022-03-02 12:25:52 +01:00
|
|
|
|
2022-03-03 19:11:34 +01:00
|
|
|
FileView get_sync_file_view(FileId file_id) final;
|
|
|
|
|
2022-07-23 16:11:25 +02:00
|
|
|
td_api::object_ptr<td_api::file> get_file_object(FileId file_id) final;
|
|
|
|
|
2022-03-02 12:03:41 +01:00
|
|
|
td_api::object_ptr<td_api::fileDownload> get_file_download_object(FileId file_id, FileSourceId file_source_id,
|
|
|
|
int32 add_date, int32 complete_date,
|
2022-07-23 16:11:25 +02:00
|
|
|
bool is_paused) final;
|
2022-03-02 12:03:41 +01:00
|
|
|
|
|
|
|
private:
|
2022-03-02 12:16:06 +01:00
|
|
|
Td *td_;
|
2022-03-02 12:03:41 +01:00
|
|
|
ActorShared<> parent_;
|
|
|
|
|
2022-07-23 16:01:27 +02:00
|
|
|
FileView get_file_view(FileId file_id);
|
|
|
|
|
2022-03-02 12:03:41 +01:00
|
|
|
static std::shared_ptr<FileManager::DownloadCallback> make_download_file_callback(
|
2022-03-02 12:25:52 +01:00
|
|
|
Td *td, ActorShared<DownloadManager> download_manager);
|
2022-03-02 12:03:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace td
|