2020-05-15 19:46:07 +02:00
|
|
|
#ifndef _CLIENT_UTILS_H
|
|
|
|
#define _CLIENT_UTILS_H
|
2020-05-11 20:18:25 +02:00
|
|
|
|
|
|
|
#include "account-data.h"
|
2020-05-15 19:46:07 +02:00
|
|
|
#include "transceiver.h"
|
2020-05-11 20:18:25 +02:00
|
|
|
#include <purple.h>
|
|
|
|
|
2020-06-05 20:14:17 +02:00
|
|
|
const char *errorCodeMessage();
|
|
|
|
|
2020-05-11 20:18:25 +02:00
|
|
|
std::string messageTypeToString(const td::td_api::MessageContent &content);
|
2020-05-20 18:31:37 +02:00
|
|
|
std::string proxyTypeToString(PurpleProxyType proxyType);
|
|
|
|
|
|
|
|
const char * getPurpleStatusId(const td::td_api::UserStatus &tdStatus);
|
2020-05-16 20:38:58 +02:00
|
|
|
std::string getPurpleBuddyName(const td::td_api::user &user);
|
|
|
|
void getUsersByPurpleName(const char *username, std::vector<const td::td_api::user*> &users,
|
2020-05-22 13:05:11 +02:00
|
|
|
TdAccountData &account);
|
2020-06-06 14:20:56 +02:00
|
|
|
const td::td_api::user *getUserByPurpleName(const char *buddyName, TdAccountData &account,
|
|
|
|
const char *action);
|
2020-05-11 20:18:25 +02:00
|
|
|
PurpleConversation *getImConversation(PurpleAccount *account, const char *username);
|
2020-05-22 13:05:11 +02:00
|
|
|
PurpleConvChat * getChatConversation(TdAccountData &account, const td::td_api::chat &chat,
|
|
|
|
int chatPurpleId);
|
2020-05-20 18:31:37 +02:00
|
|
|
PurpleConvChat * findChatConversation(PurpleAccount *account, const td::td_api::chat &chat);
|
2020-05-22 13:05:11 +02:00
|
|
|
void updatePrivateChat(TdAccountData &account, const td::td_api::chat &chat, const td::td_api::user &user);
|
|
|
|
void updateBasicGroupChat(TdAccountData &account, int32_t groupId);
|
|
|
|
void updateSupergroupChat(TdAccountData &account, int32_t groupId);
|
2020-05-22 13:46:37 +02:00
|
|
|
void removeGroupChat(PurpleAccount *purpleAccount, const td::td_api::chat &chat);
|
2020-05-12 09:35:40 +02:00
|
|
|
std::string getSenderPurpleName(const td::td_api::chat &chat, const td::td_api::message &message,
|
2020-05-22 13:05:11 +02:00
|
|
|
TdAccountData &account);
|
2020-05-16 15:32:56 +02:00
|
|
|
std::string getForwardSource(const td::td_api::messageForwardInfo &forwardInfo,
|
|
|
|
TdAccountData &accountData);
|
2020-05-14 14:42:05 +02:00
|
|
|
void getNamesFromAlias(const char *alias, std::string &firstName, std::string &lastName);
|
2020-05-12 19:37:59 +02:00
|
|
|
std::vector<PurpleChat *> findChatsByInviteLink(const std::string &inviteLink);
|
2020-05-22 14:48:17 +02:00
|
|
|
std::vector<PurpleChat *> findChatsByNewGroup(const char *name, int type);
|
2020-05-12 09:35:40 +02:00
|
|
|
|
2020-05-29 12:16:03 +02:00
|
|
|
std::string getSenderDisplayName(const td::td_api::chat &chat, const TgMessageInfo &message,
|
|
|
|
PurpleAccount *account);
|
|
|
|
std::string makeNoticeWithSender(const td::td_api::chat &chat, const TgMessageInfo &message,
|
|
|
|
const char *noticeText, PurpleAccount *account);
|
2020-06-06 11:16:43 +02:00
|
|
|
std::string getMessageText(const td::td_api::formattedText &text);
|
2020-05-22 13:05:11 +02:00
|
|
|
void showMessageText(TdAccountData &account, const td::td_api::chat &chat, const TgMessageInfo &message,
|
|
|
|
const char *text, const char *notification, uint32_t extraFlags = 0);
|
2020-05-29 12:43:09 +02:00
|
|
|
void showGenericFile(const td::td_api::chat &chat, const TgMessageInfo &message,
|
2020-05-29 12:16:03 +02:00
|
|
|
const std::string &filePath, const std::string &fileDescription,
|
2020-05-29 12:43:09 +02:00
|
|
|
TdAccountData &account);
|
|
|
|
void showWebpSticker(const td::td_api::chat &chat, const TgMessageInfo &message,
|
|
|
|
const std::string &filePath, const std::string &fileDescription,
|
|
|
|
TdAccountData &account);
|
2020-06-05 20:14:17 +02:00
|
|
|
void notifySendFailed(const td::td_api::updateMessageSendFailed &sendFailed, TdAccountData &account);
|
2020-06-02 17:25:06 +02:00
|
|
|
void updateChatConversation(PurpleConvChat *purpleChat, const td::td_api::basicGroupFullInfo &groupInfo,
|
|
|
|
const TdAccountData &account);
|
|
|
|
void updateChatConversation(PurpleConvChat *purpleChat, const td::td_api::supergroupFullInfo &groupInfo,
|
2020-05-22 13:05:11 +02:00
|
|
|
const TdAccountData &account);
|
2020-05-11 20:18:25 +02:00
|
|
|
|
2020-06-06 13:57:36 +02:00
|
|
|
int transmitMessage(int64_t chatId, const char *message, TdTransceiver &transceiver,
|
2020-05-22 13:05:11 +02:00
|
|
|
TdAccountData &account, TdTransceiver::ResponseCb response);
|
2020-05-28 21:29:58 +02:00
|
|
|
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,
|
2020-06-05 20:14:17 +02:00
|
|
|
TdTransceiver &transceiver, TdAccountData &account,
|
|
|
|
TdTransceiver::ResponseCb sendMessageResponse);
|
2020-06-04 01:28:49 +02:00
|
|
|
void startDownloadProgress(DownloadRequest &request, TdTransceiver &transceiver, TdAccountData &account);
|
2020-06-02 21:08:11 +02:00
|
|
|
void updateFileTransferProgress(const td::td_api::file &file, TdTransceiver &transceiver,
|
2020-06-05 20:14:17 +02:00
|
|
|
TdAccountData &account, TdTransceiver::ResponseCb sendMessageResponse);
|
2020-06-04 01:28:49 +02:00
|
|
|
void finishDownloadProgress(DownloadRequest &downloadReq, TdAccountData &account);
|
2020-05-15 19:46:07 +02:00
|
|
|
|
2020-05-25 23:21:04 +02:00
|
|
|
void requestRecoveryEmailConfirmation(PurpleConnection *gc, const char *emailInfo);
|
|
|
|
|
2020-05-27 00:51:35 +02:00
|
|
|
unsigned getFileSize(const td::td_api::file &file);
|
2020-05-26 20:06:09 +02:00
|
|
|
unsigned getFileSizeKb(const td::td_api::file &file);
|
|
|
|
|
2020-05-27 22:14:35 +02:00
|
|
|
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_ + "]";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string makeDocumentDescription(const td::td_api::voiceNote *document);
|
2020-05-31 14:27:35 +02:00
|
|
|
std::string makeDocumentDescription(const td::td_api::videoNote *document);
|
2020-05-27 22:14:35 +02:00
|
|
|
|
2020-05-31 15:55:28 +02:00
|
|
|
void updateSecretChat(td::td_api::object_ptr<td::td_api::secretChat> secretChat,
|
|
|
|
TdTransceiver &transceiver, TdAccountData &account);
|
2020-06-06 13:57:36 +02:00
|
|
|
void updateOption(const td::td_api::updateOption &option, TdAccountData &account);
|
2020-05-31 15:55:28 +02:00
|
|
|
|
2020-05-11 20:18:25 +02:00
|
|
|
#endif
|