|
|
@ -40,6 +40,7 @@ namespace {
|
|
|
|
const QString STATUS("status");
|
|
|
|
const QString STATUS("status");
|
|
|
|
const QString ID("id");
|
|
|
|
const QString ID("id");
|
|
|
|
const QString CHAT_ID("chat_id");
|
|
|
|
const QString CHAT_ID("chat_id");
|
|
|
|
|
|
|
|
const QString MESSAGE_ID("message_id");
|
|
|
|
const QString TYPE("type");
|
|
|
|
const QString TYPE("type");
|
|
|
|
const QString LAST_NAME("last_name");
|
|
|
|
const QString LAST_NAME("last_name");
|
|
|
|
const QString FIRST_NAME("first_name");
|
|
|
|
const QString FIRST_NAME("first_name");
|
|
|
@ -90,7 +91,7 @@ TDLibWrapper::TDLibWrapper(AppSettings *appSettings, MceInterface *mceInterface,
|
|
|
|
connect(this->tdLibReceiver, SIGNAL(chatOnlineMemberCountUpdated(QString, int)), this, SIGNAL(chatOnlineMemberCountUpdated(QString, int)));
|
|
|
|
connect(this->tdLibReceiver, SIGNAL(chatOnlineMemberCountUpdated(QString, int)), this, SIGNAL(chatOnlineMemberCountUpdated(QString, int)));
|
|
|
|
connect(this->tdLibReceiver, SIGNAL(messagesReceived(QVariantList, int)), this, SIGNAL(messagesReceived(QVariantList, int)));
|
|
|
|
connect(this->tdLibReceiver, SIGNAL(messagesReceived(QVariantList, int)), this, SIGNAL(messagesReceived(QVariantList, int)));
|
|
|
|
connect(this->tdLibReceiver, SIGNAL(newMessageReceived(qlonglong, QVariantMap)), this, SIGNAL(newMessageReceived(qlonglong, QVariantMap)));
|
|
|
|
connect(this->tdLibReceiver, SIGNAL(newMessageReceived(qlonglong, QVariantMap)), this, SIGNAL(newMessageReceived(qlonglong, QVariantMap)));
|
|
|
|
connect(this->tdLibReceiver, SIGNAL(messageInformation(QString, QVariantMap)), this, SLOT(handleMessageInformation(QString, QVariantMap)));
|
|
|
|
connect(this->tdLibReceiver, SIGNAL(messageInformation(qlonglong, qlonglong, QVariantMap)), this, SLOT(handleMessageInformation(qlonglong, qlonglong, QVariantMap)));
|
|
|
|
connect(this->tdLibReceiver, SIGNAL(messageSendSucceeded(qlonglong, qlonglong, QVariantMap)), this, SIGNAL(messageSendSucceeded(qlonglong, qlonglong, QVariantMap)));
|
|
|
|
connect(this->tdLibReceiver, SIGNAL(messageSendSucceeded(qlonglong, qlonglong, QVariantMap)), this, SIGNAL(messageSendSucceeded(qlonglong, qlonglong, QVariantMap)));
|
|
|
|
connect(this->tdLibReceiver, SIGNAL(activeNotificationsUpdated(QVariantList)), this, SIGNAL(activeNotificationsUpdated(QVariantList)));
|
|
|
|
connect(this->tdLibReceiver, SIGNAL(activeNotificationsUpdated(QVariantList)), this, SIGNAL(activeNotificationsUpdated(QVariantList)));
|
|
|
|
connect(this->tdLibReceiver, SIGNAL(notificationGroupUpdated(QVariantMap)), this, SIGNAL(notificationGroupUpdated(QVariantMap)));
|
|
|
|
connect(this->tdLibReceiver, SIGNAL(notificationGroupUpdated(QVariantMap)), this, SIGNAL(notificationGroupUpdated(QVariantMap)));
|
|
|
@ -211,9 +212,9 @@ void TDLibWrapper::registerUser(const QString &firstName, const QString &lastNam
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOG("Register User " << firstName << lastName);
|
|
|
|
LOG("Register User " << firstName << lastName);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert("@type", "registerUser");
|
|
|
|
requestObject.insert(_TYPE, "registerUser");
|
|
|
|
requestObject.insert("first_name", firstName);
|
|
|
|
requestObject.insert(FIRST_NAME, firstName);
|
|
|
|
requestObject.insert("last_name", lastName);
|
|
|
|
requestObject.insert(LAST_NAME, lastName);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -244,7 +245,7 @@ void TDLibWrapper::openChat(const QString &chatId)
|
|
|
|
LOG("Opening chat " << chatId);
|
|
|
|
LOG("Opening chat " << chatId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "openChat");
|
|
|
|
requestObject.insert(_TYPE, "openChat");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -253,7 +254,7 @@ void TDLibWrapper::closeChat(const QString &chatId)
|
|
|
|
LOG("Closing chat " << chatId);
|
|
|
|
LOG("Closing chat " << chatId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "closeChat");
|
|
|
|
requestObject.insert(_TYPE, "closeChat");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -262,7 +263,7 @@ void TDLibWrapper::joinChat(const QString &chatId)
|
|
|
|
LOG("Joining chat " << chatId);
|
|
|
|
LOG("Joining chat " << chatId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "joinChat");
|
|
|
|
requestObject.insert(_TYPE, "joinChat");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
this->joinChatRequested = true;
|
|
|
|
this->joinChatRequested = true;
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -272,16 +273,16 @@ void TDLibWrapper::leaveChat(const QString &chatId)
|
|
|
|
LOG("Leaving chat " << chatId);
|
|
|
|
LOG("Leaving chat " << chatId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "leaveChat");
|
|
|
|
requestObject.insert(_TYPE, "leaveChat");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TDLibWrapper::getChatHistory(qlonglong chatId, const qlonglong &fromMessageId, int offset, int limit, bool onlyLocal)
|
|
|
|
void TDLibWrapper::getChatHistory(qlonglong chatId, qlonglong fromMessageId, int offset, int limit, bool onlyLocal)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOG("Retrieving chat history" << chatId << fromMessageId << offset << limit << onlyLocal);
|
|
|
|
LOG("Retrieving chat history" << chatId << fromMessageId << offset << limit << onlyLocal);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "getChatHistory");
|
|
|
|
requestObject.insert(_TYPE, "getChatHistory");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("from_message_id", fromMessageId);
|
|
|
|
requestObject.insert("from_message_id", fromMessageId);
|
|
|
|
requestObject.insert("offset", offset);
|
|
|
|
requestObject.insert("offset", offset);
|
|
|
|
requestObject.insert("limit", limit);
|
|
|
|
requestObject.insert("limit", limit);
|
|
|
@ -294,7 +295,7 @@ void TDLibWrapper::viewMessage(const QString &chatId, const QString &messageId,
|
|
|
|
LOG("Mark message as viewed" << chatId << messageId);
|
|
|
|
LOG("Mark message as viewed" << chatId << messageId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "viewMessages");
|
|
|
|
requestObject.insert(_TYPE, "viewMessages");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("force_read", force);
|
|
|
|
requestObject.insert("force_read", force);
|
|
|
|
QVariantList messageIds;
|
|
|
|
QVariantList messageIds;
|
|
|
|
messageIds.append(messageId);
|
|
|
|
messageIds.append(messageId);
|
|
|
@ -307,8 +308,8 @@ void TDLibWrapper::pinMessage(const QString &chatId, const QString &messageId, b
|
|
|
|
LOG("Pin message to chat" << chatId << messageId << disableNotification);
|
|
|
|
LOG("Pin message to chat" << chatId << messageId << disableNotification);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "pinChatMessage");
|
|
|
|
requestObject.insert(_TYPE, "pinChatMessage");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("message_id", messageId);
|
|
|
|
requestObject.insert(MESSAGE_ID, messageId);
|
|
|
|
requestObject.insert("disable_notification", disableNotification);
|
|
|
|
requestObject.insert("disable_notification", disableNotification);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -318,8 +319,8 @@ void TDLibWrapper::unpinMessage(const QString &chatId, const QString &messageId)
|
|
|
|
LOG("Unpin message from chat" << chatId);
|
|
|
|
LOG("Unpin message from chat" << chatId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "unpinChatMessage");
|
|
|
|
requestObject.insert(_TYPE, "unpinChatMessage");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("message_id", messageId);
|
|
|
|
requestObject.insert(MESSAGE_ID, messageId);
|
|
|
|
requestObject.insert(_EXTRA, "unpinChatMessage:" + chatId);
|
|
|
|
requestObject.insert(_EXTRA, "unpinChatMessage:" + chatId);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -341,7 +342,7 @@ void TDLibWrapper::sendTextMessage(const QString &chatId, const QString &message
|
|
|
|
LOG("Sending text message" << chatId << message << replyToMessageId);
|
|
|
|
LOG("Sending text message" << chatId << message << replyToMessageId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "sendMessage");
|
|
|
|
requestObject.insert(_TYPE, "sendMessage");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
if (replyToMessageId != "0") {
|
|
|
|
if (replyToMessageId != "0") {
|
|
|
|
requestObject.insert("reply_to_message_id", replyToMessageId);
|
|
|
|
requestObject.insert("reply_to_message_id", replyToMessageId);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -402,7 +403,7 @@ void TDLibWrapper::sendPhotoMessage(const QString &chatId, const QString &filePa
|
|
|
|
LOG("Sending photo message" << chatId << filePath << message << replyToMessageId);
|
|
|
|
LOG("Sending photo message" << chatId << filePath << message << replyToMessageId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "sendMessage");
|
|
|
|
requestObject.insert(_TYPE, "sendMessage");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
if (replyToMessageId != "0") {
|
|
|
|
if (replyToMessageId != "0") {
|
|
|
|
requestObject.insert("reply_to_message_id", replyToMessageId);
|
|
|
|
requestObject.insert("reply_to_message_id", replyToMessageId);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -426,7 +427,7 @@ void TDLibWrapper::sendVideoMessage(const QString &chatId, const QString &filePa
|
|
|
|
LOG("Sending video message" << chatId << filePath << message << replyToMessageId);
|
|
|
|
LOG("Sending video message" << chatId << filePath << message << replyToMessageId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "sendMessage");
|
|
|
|
requestObject.insert(_TYPE, "sendMessage");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
if (replyToMessageId != "0") {
|
|
|
|
if (replyToMessageId != "0") {
|
|
|
|
requestObject.insert("reply_to_message_id", replyToMessageId);
|
|
|
|
requestObject.insert("reply_to_message_id", replyToMessageId);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -450,7 +451,7 @@ void TDLibWrapper::sendDocumentMessage(const QString &chatId, const QString &fil
|
|
|
|
LOG("Sending document message" << chatId << filePath << message << replyToMessageId);
|
|
|
|
LOG("Sending document message" << chatId << filePath << message << replyToMessageId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "sendMessage");
|
|
|
|
requestObject.insert(_TYPE, "sendMessage");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
if (replyToMessageId != "0") {
|
|
|
|
if (replyToMessageId != "0") {
|
|
|
|
requestObject.insert("reply_to_message_id", replyToMessageId);
|
|
|
|
requestObject.insert("reply_to_message_id", replyToMessageId);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -474,7 +475,7 @@ void TDLibWrapper::sendStickerMessage(const QString &chatId, const QString &file
|
|
|
|
LOG("Sending sticker message" << chatId << fileId << replyToMessageId);
|
|
|
|
LOG("Sending sticker message" << chatId << fileId << replyToMessageId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "sendMessage");
|
|
|
|
requestObject.insert(_TYPE, "sendMessage");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
if (replyToMessageId != "0") {
|
|
|
|
if (replyToMessageId != "0") {
|
|
|
|
requestObject.insert("reply_to_message_id", replyToMessageId);
|
|
|
|
requestObject.insert("reply_to_message_id", replyToMessageId);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -491,12 +492,12 @@ void TDLibWrapper::sendStickerMessage(const QString &chatId, const QString &file
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TDLibWrapper::sendPollMessage(const QString &chatId, const QString &question, const QVariantList &options, const bool &anonymous, const int &correctOption, const bool &multiple, const QString &replyToMessageId)
|
|
|
|
void TDLibWrapper::sendPollMessage(const QString &chatId, const QString &question, const QVariantList &options, bool anonymous, int correctOption, bool multiple, const QString &replyToMessageId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOG("Sending poll message" << chatId << question << replyToMessageId);
|
|
|
|
LOG("Sending poll message" << chatId << question << replyToMessageId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "sendMessage");
|
|
|
|
requestObject.insert(_TYPE, "sendMessage");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
if (replyToMessageId != "0") {
|
|
|
|
if (replyToMessageId != "0") {
|
|
|
|
requestObject.insert("reply_to_message_id", replyToMessageId);
|
|
|
|
requestObject.insert("reply_to_message_id", replyToMessageId);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -521,12 +522,12 @@ void TDLibWrapper::sendPollMessage(const QString &chatId, const QString &questio
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TDLibWrapper::forwardMessages(const QString &chatId, const QString &fromChatId, const QVariantList &messageIds, const bool sendCopy, const bool removeCaption)
|
|
|
|
void TDLibWrapper::forwardMessages(const QString &chatId, const QString &fromChatId, const QVariantList &messageIds, bool sendCopy, bool removeCaption)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOG("Forwarding messages" << chatId << fromChatId << messageIds);
|
|
|
|
LOG("Forwarding messages" << chatId << fromChatId << messageIds);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "forwardMessages");
|
|
|
|
requestObject.insert(_TYPE, "forwardMessages");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("from_chat_id", fromChatId);
|
|
|
|
requestObject.insert("from_chat_id", fromChatId);
|
|
|
|
requestObject.insert("message_ids", messageIds);
|
|
|
|
requestObject.insert("message_ids", messageIds);
|
|
|
|
requestObject.insert("send_copy", sendCopy);
|
|
|
|
requestObject.insert("send_copy", sendCopy);
|
|
|
@ -535,14 +536,14 @@ void TDLibWrapper::forwardMessages(const QString &chatId, const QString &fromCha
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TDLibWrapper::getMessage(const QString &chatId, const QString &messageId)
|
|
|
|
void TDLibWrapper::getMessage(qlonglong chatId, qlonglong messageId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOG("Retrieving message" << chatId << messageId);
|
|
|
|
LOG("Retrieving message" << chatId << messageId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "getMessage");
|
|
|
|
requestObject.insert(_TYPE, "getMessage");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("message_id", messageId);
|
|
|
|
requestObject.insert(MESSAGE_ID, messageId);
|
|
|
|
requestObject.insert(_EXTRA, "getMessage:" + messageId);
|
|
|
|
requestObject.insert(_EXTRA, QString("getMessage:%1:%2").arg(chatId).arg(messageId));
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -551,18 +552,18 @@ void TDLibWrapper::getCallbackQueryAnswer(const QString &chatId, const QString &
|
|
|
|
LOG("Getting Callback Query Answer" << chatId << messageId);
|
|
|
|
LOG("Getting Callback Query Answer" << chatId << messageId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "getCallbackQueryAnswer");
|
|
|
|
requestObject.insert(_TYPE, "getCallbackQueryAnswer");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("message_id", messageId);
|
|
|
|
requestObject.insert(MESSAGE_ID, messageId);
|
|
|
|
requestObject.insert("payload", payload);
|
|
|
|
requestObject.insert("payload", payload);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TDLibWrapper::getChatPinnedMessage(const qlonglong &chatId)
|
|
|
|
void TDLibWrapper::getChatPinnedMessage(qlonglong chatId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOG("Retrieving pinned message" << chatId);
|
|
|
|
LOG("Retrieving pinned message" << chatId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "getChatPinnedMessage");
|
|
|
|
requestObject.insert(_TYPE, "getChatPinnedMessage");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert(_EXTRA, "getChatPinnedMessage:" + QString::number(chatId));
|
|
|
|
requestObject.insert(_EXTRA, "getChatPinnedMessage:" + QString::number(chatId));
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -596,7 +597,7 @@ void TDLibWrapper::setChatNotificationSettings(const QString &chatId, const QVar
|
|
|
|
LOG("Notification settings for chat " << chatId << notificationSettings);
|
|
|
|
LOG("Notification settings for chat " << chatId << notificationSettings);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "setChatNotificationSettings");
|
|
|
|
requestObject.insert(_TYPE, "setChatNotificationSettings");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("notification_settings", notificationSettings);
|
|
|
|
requestObject.insert("notification_settings", notificationSettings);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -606,8 +607,8 @@ void TDLibWrapper::editMessageText(const QString &chatId, const QString &message
|
|
|
|
LOG("Editing message text" << chatId << messageId);
|
|
|
|
LOG("Editing message text" << chatId << messageId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "editMessageText");
|
|
|
|
requestObject.insert(_TYPE, "editMessageText");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("message_id", messageId);
|
|
|
|
requestObject.insert(MESSAGE_ID, messageId);
|
|
|
|
QVariantMap inputMessageContent;
|
|
|
|
QVariantMap inputMessageContent;
|
|
|
|
inputMessageContent.insert(_TYPE, "inputMessageText");
|
|
|
|
inputMessageContent.insert(_TYPE, "inputMessageText");
|
|
|
|
QVariantMap formattedText;
|
|
|
|
QVariantMap formattedText;
|
|
|
@ -622,7 +623,7 @@ void TDLibWrapper::deleteMessages(const QString &chatId, const QVariantList mess
|
|
|
|
LOG("Deleting some messages" << chatId << messageIds);
|
|
|
|
LOG("Deleting some messages" << chatId << messageIds);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "deleteMessages");
|
|
|
|
requestObject.insert(_TYPE, "deleteMessages");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("message_ids", messageIds);
|
|
|
|
requestObject.insert("message_ids", messageIds);
|
|
|
|
requestObject.insert("revoke", true);
|
|
|
|
requestObject.insert("revoke", true);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
@ -646,7 +647,7 @@ void TDLibWrapper::getMapThumbnailFile(const QString &chatId, double latitude, d
|
|
|
|
requestObject.insert("width", boundsWidth);
|
|
|
|
requestObject.insert("width", boundsWidth);
|
|
|
|
requestObject.insert("height", boundsHeight);
|
|
|
|
requestObject.insert("height", boundsHeight);
|
|
|
|
requestObject.insert("scale", 1); // 1-3
|
|
|
|
requestObject.insert("scale", 1); // 1-3
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
|
|
|
|
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -782,7 +783,7 @@ void TDLibWrapper::setChatPermissions(const QString &chatId, const QVariantMap &
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "setChatPermissions");
|
|
|
|
requestObject.insert(_TYPE, "setChatPermissions");
|
|
|
|
requestObject.insert(_EXTRA, chatId);
|
|
|
|
requestObject.insert(_EXTRA, chatId);
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("permissions", chatPermissions);
|
|
|
|
requestObject.insert("permissions", chatPermissions);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -793,7 +794,7 @@ void TDLibWrapper::setChatSlowModeDelay(const QString &chatId, int delay)
|
|
|
|
LOG("Setting Chat Slow Mode Delay");
|
|
|
|
LOG("Setting Chat Slow Mode Delay");
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "setChatSlowModeDelay");
|
|
|
|
requestObject.insert(_TYPE, "setChatSlowModeDelay");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("slow_mode_delay", delay);
|
|
|
|
requestObject.insert("slow_mode_delay", delay);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -803,7 +804,7 @@ void TDLibWrapper::setChatDescription(const QString &chatId, const QString &desc
|
|
|
|
LOG("Setting Chat Description");
|
|
|
|
LOG("Setting Chat Description");
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "setChatDescription");
|
|
|
|
requestObject.insert(_TYPE, "setChatDescription");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("description", description);
|
|
|
|
requestObject.insert("description", description);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -813,7 +814,7 @@ void TDLibWrapper::setChatTitle(const QString &chatId, const QString &title)
|
|
|
|
LOG("Setting Chat Title");
|
|
|
|
LOG("Setting Chat Title");
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "setChatTitle");
|
|
|
|
requestObject.insert(_TYPE, "setChatTitle");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("title", title);
|
|
|
|
requestObject.insert("title", title);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -837,35 +838,35 @@ void TDLibWrapper::toggleSupergroupIsAllHistoryAvailable(const QString &groupId,
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TDLibWrapper::setPollAnswer(const QString &chatId, const qlonglong &messageId, QVariantList optionIds)
|
|
|
|
void TDLibWrapper::setPollAnswer(const QString &chatId, qlonglong messageId, QVariantList optionIds)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOG("Setting Poll Answer");
|
|
|
|
LOG("Setting Poll Answer");
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "setPollAnswer");
|
|
|
|
requestObject.insert(_TYPE, "setPollAnswer");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("message_id", messageId);
|
|
|
|
requestObject.insert(MESSAGE_ID, messageId);
|
|
|
|
requestObject.insert("option_ids", optionIds);
|
|
|
|
requestObject.insert("option_ids", optionIds);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TDLibWrapper::stopPoll(const QString &chatId, const qlonglong &messageId)
|
|
|
|
void TDLibWrapper::stopPoll(const QString &chatId, qlonglong messageId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOG("Stopping Poll");
|
|
|
|
LOG("Stopping Poll");
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "stopPoll");
|
|
|
|
requestObject.insert(_TYPE, "stopPoll");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("message_id", messageId);
|
|
|
|
requestObject.insert(MESSAGE_ID, messageId);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TDLibWrapper::getPollVoters(const QString &chatId, const qlonglong &messageId, const int &optionId, const int &limit, const int &offset, const QString &extra)
|
|
|
|
void TDLibWrapper::getPollVoters(const QString &chatId, qlonglong messageId, int optionId, int limit, int offset, const QString &extra)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOG("Retrieving Poll Voters");
|
|
|
|
LOG("Retrieving Poll Voters");
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "getPollVoters");
|
|
|
|
requestObject.insert(_TYPE, "getPollVoters");
|
|
|
|
requestObject.insert(_EXTRA, extra);
|
|
|
|
requestObject.insert(_EXTRA, extra);
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("message_id", messageId);
|
|
|
|
requestObject.insert(MESSAGE_ID, messageId);
|
|
|
|
requestObject.insert("option_id", optionId);
|
|
|
|
requestObject.insert("option_id", optionId);
|
|
|
|
requestObject.insert("offset", offset);
|
|
|
|
requestObject.insert("offset", offset);
|
|
|
|
requestObject.insert("limit", limit); //max 50
|
|
|
|
requestObject.insert("limit", limit); //max 50
|
|
|
@ -878,7 +879,7 @@ void TDLibWrapper::searchPublicChat(const QString &userName)
|
|
|
|
this->activeChatSearchName = userName;
|
|
|
|
this->activeChatSearchName = userName;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "searchPublicChat");
|
|
|
|
requestObject.insert(_TYPE, "searchPublicChat");
|
|
|
|
requestObject.insert("username", userName);
|
|
|
|
requestObject.insert(USERNAME, userName);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -937,12 +938,12 @@ void TDLibWrapper::importContacts(const QVariantList &contacts)
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TDLibWrapper::searchChatMessages(const qlonglong &chatId, const QString &query, const qlonglong fromMessageId)
|
|
|
|
void TDLibWrapper::searchChatMessages(qlonglong chatId, const QString &query, qlonglong fromMessageId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOG("Searching for messages" << chatId << query << fromMessageId);
|
|
|
|
LOG("Searching for messages" << chatId << query << fromMessageId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "searchChatMessages");
|
|
|
|
requestObject.insert(_TYPE, "searchChatMessages");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
requestObject.insert("query", query);
|
|
|
|
requestObject.insert("query", query);
|
|
|
|
requestObject.insert("from_message_id", fromMessageId);
|
|
|
|
requestObject.insert("from_message_id", fromMessageId);
|
|
|
|
requestObject.insert("offset", 0);
|
|
|
|
requestObject.insert("offset", 0);
|
|
|
@ -966,7 +967,7 @@ void TDLibWrapper::readAllChatMentions(qlonglong chatId)
|
|
|
|
LOG("Read all chat mentions" << chatId);
|
|
|
|
LOG("Read all chat mentions" << chatId);
|
|
|
|
QVariantMap requestObject;
|
|
|
|
QVariantMap requestObject;
|
|
|
|
requestObject.insert(_TYPE, "readAllChatMentions");
|
|
|
|
requestObject.insert(_TYPE, "readAllChatMentions");
|
|
|
|
requestObject.insert("chat_id", chatId);
|
|
|
|
requestObject.insert(CHAT_ID, chatId);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
this->sendRequest(requestObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1203,9 +1204,9 @@ void TDLibWrapper::handleUserUpdated(const QVariantMap &userInformation)
|
|
|
|
LOG("Own user information updated :)");
|
|
|
|
LOG("Own user information updated :)");
|
|
|
|
this->userInformation = userInformation;
|
|
|
|
this->userInformation = userInformation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LOG("User information updated:" << userInformation.value("username").toString() << userInformation.value("first_name").toString() << userInformation.value("last_name").toString());
|
|
|
|
LOG("User information updated:" << userInformation.value(USERNAME).toString() << userInformation.value(FIRST_NAME).toString() << userInformation.value(LAST_NAME).toString());
|
|
|
|
this->allUsers.insert(updatedUserId, userInformation);
|
|
|
|
this->allUsers.insert(updatedUserId, userInformation);
|
|
|
|
this->allUserNames.insert(userInformation.value("username").toString(), userInformation);
|
|
|
|
this->allUserNames.insert(userInformation.value(USERNAME).toString(), userInformation);
|
|
|
|
emit userUpdated(updatedUserId, userInformation);
|
|
|
|
emit userUpdated(updatedUserId, userInformation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1219,7 +1220,7 @@ void TDLibWrapper::handleUserStatusUpdated(const QString &userId, const QVariant
|
|
|
|
QVariantMap updatedUserInformation = this->allUsers.value(userId).toMap();
|
|
|
|
QVariantMap updatedUserInformation = this->allUsers.value(userId).toMap();
|
|
|
|
updatedUserInformation.insert("status", userStatusInformation);
|
|
|
|
updatedUserInformation.insert("status", userStatusInformation);
|
|
|
|
this->allUsers.insert(userId, updatedUserInformation);
|
|
|
|
this->allUsers.insert(userId, updatedUserInformation);
|
|
|
|
this->allUserNames.insert(userInformation.value("username").toString(), userInformation);
|
|
|
|
this->allUserNames.insert(userInformation.value(USERNAME).toString(), userInformation);
|
|
|
|
emit userUpdated(userId, updatedUserInformation);
|
|
|
|
emit userUpdated(userId, updatedUserInformation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1273,7 +1274,7 @@ void TDLibWrapper::handleUnreadChatCountUpdated(const QVariantMap &chatCountInfo
|
|
|
|
void TDLibWrapper::handleBasicGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation)
|
|
|
|
void TDLibWrapper::handleBasicGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
emit basicGroupUpdated(updateGroup(groupId, groupInformation, &basicGroups)->groupId);
|
|
|
|
emit basicGroupUpdated(updateGroup(groupId, groupInformation, &basicGroups)->groupId);
|
|
|
|
if (!this->activeChatSearchName.isEmpty() && this->activeChatSearchName == groupInformation.value("username").toString()) {
|
|
|
|
if (!this->activeChatSearchName.isEmpty() && this->activeChatSearchName == groupInformation.value(USERNAME).toString()) {
|
|
|
|
LOG("Found basic group for active search" << this->activeChatSearchName);
|
|
|
|
LOG("Found basic group for active search" << this->activeChatSearchName);
|
|
|
|
this->activeChatSearchName.clear();
|
|
|
|
this->activeChatSearchName.clear();
|
|
|
|
this->createBasicGroupChat(groupInformation.value(ID).toString());
|
|
|
|
this->createBasicGroupChat(groupInformation.value(ID).toString());
|
|
|
@ -1283,7 +1284,7 @@ void TDLibWrapper::handleBasicGroupUpdated(qlonglong groupId, const QVariantMap
|
|
|
|
void TDLibWrapper::handleSuperGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation)
|
|
|
|
void TDLibWrapper::handleSuperGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
emit superGroupUpdated(updateGroup(groupId, groupInformation, &superGroups)->groupId);
|
|
|
|
emit superGroupUpdated(updateGroup(groupId, groupInformation, &superGroups)->groupId);
|
|
|
|
if (!this->activeChatSearchName.isEmpty() && this->activeChatSearchName == groupInformation.value("username").toString()) {
|
|
|
|
if (!this->activeChatSearchName.isEmpty() && this->activeChatSearchName == groupInformation.value(USERNAME).toString()) {
|
|
|
|
LOG("Found supergroup for active search" << this->activeChatSearchName);
|
|
|
|
LOG("Found supergroup for active search" << this->activeChatSearchName);
|
|
|
|
this->activeChatSearchName.clear();
|
|
|
|
this->activeChatSearchName.clear();
|
|
|
|
this->createSupergroupChat(groupInformation.value(ID).toString());
|
|
|
|
this->createSupergroupChat(groupInformation.value(ID).toString());
|
|
|
@ -1332,21 +1333,24 @@ void TDLibWrapper::handleStorageOptimizerChanged()
|
|
|
|
setOptionBoolean("use_storage_optimizer", appSettings->storageOptimizer());
|
|
|
|
setOptionBoolean("use_storage_optimizer", appSettings->storageOptimizer());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TDLibWrapper::handleErrorReceived(const int code, const QString &message, const QString &extra)
|
|
|
|
void TDLibWrapper::handleErrorReceived(int code, const QString &message, const QString &extra)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (code == 404 && extra.startsWith("getMessage:")) {
|
|
|
|
if (!extra.isEmpty()) {
|
|
|
|
emit messageNotFound(extra.mid(11).toLongLong());
|
|
|
|
QStringList parts(extra.split(':'));
|
|
|
|
|
|
|
|
if (parts.size() == 3 && parts.at(0) == QStringLiteral("getMessage")) {
|
|
|
|
|
|
|
|
emit messageNotFound(parts.at(1).toLongLong(), parts.at(2).toLongLong());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
emit errorReceived(code, message, extra);
|
|
|
|
emit errorReceived(code, message, extra);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TDLibWrapper::handleMessageInformation(const QString &messageId, const QVariantMap &receivedInformation)
|
|
|
|
void TDLibWrapper::handleMessageInformation(qlonglong chatId, qlonglong messageId, const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QString extraInformation = receivedInformation.value(_EXTRA).toString();
|
|
|
|
QString extraInformation = receivedInformation.value(_EXTRA).toString();
|
|
|
|
if (extraInformation.startsWith("getChatPinnedMessage")) {
|
|
|
|
if (extraInformation.startsWith("getChatPinnedMessage:")) {
|
|
|
|
emit chatPinnedMessageUpdated(receivedInformation.value(CHAT_ID).toLongLong(), messageId.toLongLong());
|
|
|
|
emit chatPinnedMessageUpdated(chatId, messageId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
emit receivedMessage(messageId, receivedInformation);
|
|
|
|
emit receivedMessage(chatId, messageId, receivedInformation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TDLibWrapper::handleMessageIsPinnedUpdated(qlonglong chatId, qlonglong messageId, bool isPinned)
|
|
|
|
void TDLibWrapper::handleMessageIsPinnedUpdated(qlonglong chatId, qlonglong messageId, bool isPinned)
|
|
|
|