2020-07-26 14:51:51 +02:00
|
|
|
#ifndef _FILE_TRANSFER_H
|
|
|
|
#define _FILE_TRANSFER_H
|
|
|
|
|
|
|
|
#include "account-data.h"
|
|
|
|
#include "transceiver.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);
|
|
|
|
void startDocumentUpload(int64_t chatId, const std::string &filename, PurpleXfer *xfer,
|
|
|
|
TdTransceiver &transceiver, TdAccountData &account,
|
|
|
|
TdTransceiver::ResponseCb response);
|
|
|
|
void uploadResponseError(PurpleXfer *xfer, const std::string &message, TdAccountData &account);
|
|
|
|
void startDocumentUploadProgress(int64_t chatId, PurpleXfer *xfer, const td::td_api::file &file,
|
|
|
|
TdTransceiver &transceiver, TdAccountData &account,
|
|
|
|
TdTransceiver::ResponseCb sendMessageResponse);
|
2020-08-14 22:07:22 +02:00
|
|
|
void startInlineDownloadProgress(DownloadRequest &request, 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-08-14 22:07:22 +02:00
|
|
|
void finishInlineDownloadProgress(DownloadRequest &downloadReq, TdAccountData &account);
|
2020-07-26 14:51:51 +02:00
|
|
|
|
2020-08-14 23:22:26 +02:00
|
|
|
void requestStandardDownload(const TgMessageInfo &message, const std::string &fileName,
|
|
|
|
const td::td_api::file &file, TdTransceiver &transceiver, TdAccountData &account);
|
2020-08-15 01:58:45 +02:00
|
|
|
std::string getDownloadPath(const 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
|