implement DownloadManagerCallback
This commit is contained in:
parent
21a71e6441
commit
da436915c1
@ -205,5 +205,7 @@ unique_ptr<DownloadManager> DownloadManager::create() {
|
|||||||
tl_object_ptr<td_api::foundFileDownloads> DownloadManager::FoundFileDownloads::to_td_api() const {
|
tl_object_ptr<td_api::foundFileDownloads> DownloadManager::FoundFileDownloads::to_td_api() const {
|
||||||
return make_tl_object<td_api::foundFileDownloads>();
|
return make_tl_object<td_api::foundFileDownloads>();
|
||||||
}
|
}
|
||||||
|
tl_object_ptr<td_api::updateFileDownloads> DownloadManager::Counters::to_td_api() const {
|
||||||
|
return make_tl_object<td_api::updateFileDownloads>(total_size, total_count, downloaded_size);
|
||||||
|
}
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -27,6 +27,8 @@ class DownloadManager : public Actor {
|
|||||||
int64 total_size{};
|
int64 total_size{};
|
||||||
int32 total_count{};
|
int32 total_count{};
|
||||||
int64 downloaded_size{};
|
int64 downloaded_size{};
|
||||||
|
|
||||||
|
tl_object_ptr<td_api::updateFileDownloads> to_td_api() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FileDownload {
|
struct FileDownload {
|
||||||
|
@ -3975,39 +3975,40 @@ void Td::init_managers() {
|
|||||||
// TODO: move this callback somewhere else
|
// TODO: move this callback somewhere else
|
||||||
class DownloadManagerCallback final : public DownloadManager::Callback {
|
class DownloadManagerCallback final : public DownloadManager::Callback {
|
||||||
public:
|
public:
|
||||||
explicit DownloadManagerCallback(ActorShared<> parent) : parent_(std::move(parent)) {
|
DownloadManagerCallback(ActorShared<> parent, std::shared_ptr<DownloadFileCallback> download_file_callback)
|
||||||
// TODO
|
: parent_(std::move(parent)), download_file_callback_(std::move(download_file_callback)) {
|
||||||
}
|
}
|
||||||
void update_counters(DownloadManager::Counters counters) final {
|
void update_counters(DownloadManager::Counters counters) final {
|
||||||
// TODO
|
send_closure(G()->td(), &Td::send_update, counters.to_td_api());
|
||||||
}
|
}
|
||||||
void start_file(FileId file_id, int8 priority) final {
|
void start_file(FileId file_id, int8 priority) final {
|
||||||
// TODO
|
send_closure(G()->file_manager(), &FileManager::download, file_id, download_file_callback_, priority, -1, -1);
|
||||||
}
|
}
|
||||||
void pause_file(FileId file_id) final {
|
void pause_file(FileId file_id) final {
|
||||||
// TODO
|
send_closure(G()->file_manager(), &FileManager::download, file_id, nullptr, 0, -1, -1);
|
||||||
}
|
}
|
||||||
void delete_file(FileId file_id) final {
|
void delete_file(FileId file_id) final {
|
||||||
// TODO
|
send_closure(
|
||||||
|
G()->file_manager(), &FileManager::delete_file, file_id, [](Result<Unit>) {}, "download manager callback");
|
||||||
}
|
}
|
||||||
FileId dup_file_id(FileId file_id) final {
|
FileId dup_file_id(FileId file_id) final {
|
||||||
// TODO
|
return G()->file_manager().get_actor_unsafe()->dup_file_id(file_id);
|
||||||
return FileId();
|
|
||||||
}
|
}
|
||||||
string get_unique_file_id(FileId file_id) final {
|
string get_unique_file_id(FileId file_id) final {
|
||||||
// TODO
|
return G()->file_manager().get_actor_unsafe()->get_file_view(file_id).get_unique_file_id();
|
||||||
return string();
|
|
||||||
}
|
}
|
||||||
string get_file_source_serialized(FileSourceId file_source_id) final {
|
string get_file_source_serialized(FileSourceId file_source_id) final {
|
||||||
// TODO
|
TlStorerToString storer;
|
||||||
return string();
|
G()->file_reference_manager().get_actor_unsafe()->store_file_source(file_source_id, storer);
|
||||||
|
return storer.move_as_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ActorShared<> parent_;
|
ActorShared<> parent_;
|
||||||
|
std::shared_ptr<DownloadFileCallback> download_file_callback_;
|
||||||
};
|
};
|
||||||
send_closure_later(download_manager_actor_, &DownloadManager::set_callback,
|
send_closure_later(download_manager_actor_, &DownloadManager::set_callback,
|
||||||
make_unique<DownloadManagerCallback>(create_reference()));
|
td::make_unique<DownloadManagerCallback>(create_reference(), download_file_callback_));
|
||||||
|
|
||||||
game_manager_ = make_unique<GameManager>(this, create_reference());
|
game_manager_ = make_unique<GameManager>(this, create_reference());
|
||||||
game_manager_actor_ = register_actor("GameManager", game_manager_.get());
|
game_manager_actor_ = register_actor("GameManager", game_manager_.get());
|
||||||
|
Loading…
Reference in New Issue
Block a user