2020-07-26 14:51:51 +02:00
|
|
|
#ifndef _FILE_TRANSFER_H
|
|
|
|
#define _FILE_TRANSFER_H
|
|
|
|
|
|
|
|
#include "account-data.h"
|
|
|
|
|
2020-08-15 01:58:45 +02:00
|
|
|
enum {
|
|
|
|
FILE_DOWNLOAD_PRIORITY = 1,
|
|
|
|
};
|
|
|
|
|
2020-07-26 14:51:51 +02:00
|
|
|
bool saveImage(int id, char **fileName);
|
2020-10-04 15:17:04 +02:00
|
|
|
void startDocumentUpload(ChatId chatId, const std::string &filename, PurpleXfer *xfer,
|
2020-07-26 14:51:51 +02:00
|
|
|
TdTransceiver &transceiver, TdAccountData &account,
|
|
|
|
TdTransceiver::ResponseCb response);
|
|
|
|
void uploadResponseError(PurpleXfer *xfer, const std::string &message, TdAccountData &account);
|
2020-10-04 15:17:04 +02:00
|
|
|
void startDocumentUploadProgress(ChatId chatId, PurpleXfer *xfer, const td::td_api::file &file,
|
2020-07-26 14:51:51 +02:00
|
|
|
TdTransceiver &transceiver, TdAccountData &account,
|
|
|
|
TdTransceiver::ResponseCb sendMessageResponse);
|
2020-10-11 14:57:38 +02:00
|
|
|
void downloadFileInline(int32_t fileId, ChatId chatId, TgMessageInfo &message,
|
|
|
|
const std::string &fileDescription,
|
|
|
|
td::td_api::object_ptr<td::td_api::file> thumbnail,
|
|
|
|
TdTransceiver &transceiver, TdAccountData &account);
|
2020-07-26 14:51:51 +02:00
|
|
|
void updateFileTransferProgress(const td::td_api::file &file, TdTransceiver &transceiver,
|
|
|
|
TdAccountData &account, TdTransceiver::ResponseCb sendMessageResponse);
|
|
|
|
|
2020-10-04 18:57:14 +02:00
|
|
|
void requestStandardDownload(ChatId chatId, const TgMessageInfo &message, const std::string &fileName,
|
2020-08-14 23:22:26 +02:00
|
|
|
const td::td_api::file &file, TdTransceiver &transceiver, TdAccountData &account);
|
2020-11-25 17:54:04 +01:00
|
|
|
std::string getDownloadPath(const td::td_api::object_ptr<td::td_api::Object> &downloadResponse);
|
2020-08-14 23:22:26 +02:00
|
|
|
|
2020-07-26 14:51:51 +02:00
|
|
|
unsigned getFileSize(const td::td_api::file &file);
|
|
|
|
unsigned getFileSizeKb(const td::td_api::file &file);
|
|
|
|
|
|
|
|
template<typename DocumentType>
|
|
|
|
std::string makeDocumentDescription(const DocumentType *document)
|
|
|
|
{
|
|
|
|
if (!document)
|
|
|
|
// Unlikely error message not worth translating
|
|
|
|
return "(faulty file)";
|
|
|
|
return document->file_name_ + " [" + document->mime_type_ + "]";
|
|
|
|
}
|
|
|
|
|
2020-08-14 23:22:26 +02:00
|
|
|
template<typename DocumentType>
|
|
|
|
std::string getFileName(const DocumentType *document)
|
|
|
|
{
|
|
|
|
return document->file_name_;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string getFileName(const td::td_api::voiceNote *document);
|
|
|
|
std::string getFileName(const td::td_api::videoNote *document);
|
|
|
|
|
2020-07-26 14:51:51 +02:00
|
|
|
std::string makeDocumentDescription(const td::td_api::voiceNote *document);
|
|
|
|
std::string makeDocumentDescription(const td::td_api::videoNote *document);
|
|
|
|
|
|
|
|
#endif
|