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-05-13 19:15:15 +02:00
|
|
|
struct TgMessageInfo {
|
|
|
|
std::string sender;
|
|
|
|
time_t timestamp;
|
|
|
|
bool outgoing;
|
2020-05-16 13:38:00 +02:00
|
|
|
int64_t repliedMessageId;
|
2020-05-13 19:15:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// Matching completed downloads to chats they belong to
|
|
|
|
class DownloadRequest: public PendingRequest {
|
|
|
|
public:
|
|
|
|
int64_t chatId;
|
|
|
|
TgMessageInfo message;
|
|
|
|
td::td_api::object_ptr<td::td_api::file> thumbnail;
|
|
|
|
|
|
|
|
// Could not pass object_ptr through variadic funciton :(
|
|
|
|
DownloadRequest(uint64_t requestId, int64_t chatId, const TgMessageInfo &message, td::td_api::file *thumbnail)
|
|
|
|
: PendingRequest(requestId), chatId(chatId), message(message), thumbnail(thumbnail) {}
|
|
|
|
};
|
|
|
|
|
2020-05-11 20:18:25 +02:00
|
|
|
std::string messageTypeToString(const td::td_api::MessageContent &content);
|
|
|
|
const char *getPurpleStatusId(const td::td_api::UserStatus &tdStatus);
|
2020-05-13 11:21:19 +02:00
|
|
|
std::string getPurpleUserName(const td::td_api::user &user);
|
2020-05-11 20:18:25 +02:00
|
|
|
PurpleConversation *getImConversation(PurpleAccount *account, const char *username);
|
|
|
|
PurpleConvChat *getChatConversation(PurpleAccount *account, const td::td_api::chat &chat,
|
|
|
|
int chatPurpleId, TdAccountData &accountData);
|
2020-05-12 09:35:40 +02:00
|
|
|
std::string getSenderPurpleName(const td::td_api::chat &chat, const td::td_api::message &message,
|
|
|
|
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-12 09:35:40 +02:00
|
|
|
|
2020-05-13 19:15:15 +02:00
|
|
|
void showMessageText(PurpleAccount *account, const td::td_api::chat &chat, const TgMessageInfo &message,
|
|
|
|
const char *text, const char *notification, TdAccountData &accountData,
|
|
|
|
uint32_t extraFlags = 0);
|
2020-05-11 20:18:25 +02:00
|
|
|
void setChatMembers(PurpleConvChat *purpleChat, const td::td_api::basicGroupFullInfo &groupInfo,
|
|
|
|
const TdAccountData &accountData);
|
|
|
|
|
2020-05-16 00:16:06 +02:00
|
|
|
void transmitMessage(int64_t chatId, const char *message, TdTransceiver &transceiver,
|
|
|
|
TdAccountData &accountData, TdTransceiver::ResponseCb response);
|
2020-05-15 19:46:07 +02:00
|
|
|
|
2020-05-11 20:18:25 +02:00
|
|
|
#endif
|