2022-04-04 18:43:23 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "mtproto/sender.h"
|
|
|
|
|
|
|
|
class ApiWrap;
|
|
|
|
class PeerData;
|
|
|
|
|
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
|
|
|
namespace Api {
|
|
|
|
|
|
|
|
class Ringtones final {
|
|
|
|
public:
|
|
|
|
explicit Ringtones(not_null<ApiWrap*> api);
|
|
|
|
|
2022-04-06 15:19:50 +00:00
|
|
|
using Ids = std::vector<DocumentId>;
|
2022-04-04 19:06:25 +00:00
|
|
|
|
|
|
|
void requestList();
|
|
|
|
void applyUpdate();
|
|
|
|
void remove(DocumentId id);
|
|
|
|
|
2022-04-04 18:43:23 +00:00
|
|
|
void upload(
|
|
|
|
const QString &filename,
|
|
|
|
const QString &filemime,
|
|
|
|
const QByteArray &content);
|
|
|
|
|
2022-04-04 19:06:25 +00:00
|
|
|
[[nodiscard]] const Ids &list() const;
|
|
|
|
[[nodiscard]] rpl::producer<> listUpdates() const;
|
|
|
|
[[nodiscard]] rpl::producer<QString> uploadFails() const;
|
2022-04-06 15:19:50 +00:00
|
|
|
[[nodiscard]] rpl::producer<DocumentId> uploadDones() const;
|
2022-04-04 19:06:25 +00:00
|
|
|
|
2022-04-04 18:43:23 +00:00
|
|
|
private:
|
|
|
|
struct UploadedData {
|
|
|
|
QString filename;
|
|
|
|
QString filemime;
|
2022-04-07 07:34:29 +00:00
|
|
|
QByteArray content;
|
2022-04-04 18:43:23 +00:00
|
|
|
};
|
|
|
|
void ready(const FullMsgId &msgId, const MTPInputFile &file);
|
|
|
|
|
|
|
|
const not_null<Main::Session*> _session;
|
|
|
|
MTP::Sender _api;
|
|
|
|
|
|
|
|
base::flat_map<FullMsgId, UploadedData> _uploads;
|
2022-04-04 19:06:25 +00:00
|
|
|
rpl::event_stream<QString> _uploadFails;
|
2022-04-06 15:19:50 +00:00
|
|
|
rpl::event_stream<DocumentId> _uploadDones;
|
2022-04-04 19:06:25 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
uint64 hash = 0;
|
|
|
|
Ids documents;
|
|
|
|
rpl::event_stream<> updates;
|
2022-04-05 14:07:37 +00:00
|
|
|
mtpRequestId requestId = 0;
|
2022-04-04 19:06:25 +00:00
|
|
|
} _list;
|
2022-04-04 18:43:23 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Api
|