2020-08-13 11:15:26 +03:00
|
|
|
/*
|
|
|
|
Copyright (C) 2020 Sebastian J. Wolf
|
|
|
|
|
|
|
|
This file is part of Fernschreiber.
|
|
|
|
|
2020-08-13 18:08:14 +03:00
|
|
|
Fernschreiber is free software: you can redistribute it and/or modify
|
2020-08-13 11:15:26 +03:00
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
2020-08-13 18:08:14 +03:00
|
|
|
Fernschreiber is distributed in the hope that it will be useful,
|
2020-08-13 11:15:26 +03:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Fernschreiber. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-08-10 21:17:13 +03:00
|
|
|
#include "tdlibreceiver.h"
|
|
|
|
|
2020-09-27 17:11:14 +03:00
|
|
|
#define LOG(x) qDebug() << "[TDLibReceiver]" << x
|
|
|
|
|
2020-10-06 00:08:47 +03:00
|
|
|
#if defined (QT_DEBUG) || defined (DEBUG)
|
2020-10-03 21:09:04 +03:00
|
|
|
# define VERBOSE(x) LOG(x)
|
|
|
|
#else
|
|
|
|
# define VERBOSE(x)
|
|
|
|
#endif
|
|
|
|
|
2020-09-27 17:11:14 +03:00
|
|
|
namespace {
|
|
|
|
const QString ID("id");
|
|
|
|
const QString LIST("list");
|
|
|
|
const QString CHAT_ID("chat_id");
|
|
|
|
const QString POSITION("position");
|
|
|
|
const QString POSITIONS("positions");
|
|
|
|
const QString ORDER("order");
|
2020-10-04 04:27:49 +03:00
|
|
|
const QString BASIC_GROUP("basic_group");
|
|
|
|
const QString SUPERGROUP("supergroup");
|
2020-09-27 17:11:14 +03:00
|
|
|
const QString LAST_MESSAGE("last_message");
|
|
|
|
const QString UNREAD_COUNT("unread_count");
|
|
|
|
const QString LAST_READ_INBOX_MESSAGE_ID("last_read_inbox_message_id");
|
|
|
|
const QString LAST_READ_OUTBOX_MESSAGE_ID("last_read_outbox_message_id");
|
|
|
|
|
|
|
|
const QString TYPE("@type");
|
2020-10-19 13:20:02 +03:00
|
|
|
const QString EXTRA("@extra");
|
2020-09-27 17:11:14 +03:00
|
|
|
const QString TYPE_CHAT_POSITION("chatPosition");
|
|
|
|
const QString TYPE_CHAT_LIST_MAIN("chatListMain");
|
|
|
|
}
|
|
|
|
|
|
|
|
static QString getChatPositionOrder(const QVariantMap &position)
|
|
|
|
{
|
|
|
|
if (position.value(TYPE).toString() == TYPE_CHAT_POSITION &&
|
|
|
|
position.value(LIST).toMap().value(TYPE) == TYPE_CHAT_LIST_MAIN) {
|
|
|
|
return position.value(ORDER).toString();
|
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
static QString findChatPositionOrder(const QVariantList &positions)
|
|
|
|
{
|
|
|
|
const int n = positions.count();
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
const QString order(getChatPositionOrder(positions.at(i).toMap()));
|
|
|
|
if (!order.isEmpty()) {
|
|
|
|
return order;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2020-08-10 21:17:13 +03:00
|
|
|
TDLibReceiver::TDLibReceiver(void *tdLibClient, QObject *parent) : QThread(parent)
|
|
|
|
{
|
|
|
|
this->tdLibClient = tdLibClient;
|
|
|
|
this->isActive = true;
|
2020-09-27 17:11:14 +03:00
|
|
|
|
|
|
|
handlers.insert("updateOption", &TDLibReceiver::processUpdateOption);
|
|
|
|
handlers.insert("updateAuthorizationState", &TDLibReceiver::processUpdateAuthorizationState);
|
|
|
|
handlers.insert("updateConnectionState", &TDLibReceiver::processUpdateConnectionState);
|
|
|
|
handlers.insert("updateUser", &TDLibReceiver::processUpdateUser);
|
|
|
|
handlers.insert("updateUserStatus", &TDLibReceiver::processUpdateUserStatus);
|
|
|
|
handlers.insert("updateFile", &TDLibReceiver::processUpdateFile);
|
|
|
|
handlers.insert("file", &TDLibReceiver::processFile);
|
|
|
|
handlers.insert("updateNewChat", &TDLibReceiver::processUpdateNewChat);
|
|
|
|
handlers.insert("updateUnreadMessageCount", &TDLibReceiver::processUpdateUnreadMessageCount);
|
|
|
|
handlers.insert("updateUnreadChatCount", &TDLibReceiver::processUpdateUnreadChatCount);
|
|
|
|
handlers.insert("updateChatLastMessage", &TDLibReceiver::processUpdateChatLastMessage);
|
|
|
|
handlers.insert("updateChatOrder", &TDLibReceiver::processUpdateChatOrder);
|
|
|
|
handlers.insert("updateChatPosition", &TDLibReceiver::processUpdateChatPosition);
|
|
|
|
handlers.insert("updateChatReadInbox", &TDLibReceiver::processUpdateChatReadInbox);
|
|
|
|
handlers.insert("updateChatReadOutbox", &TDLibReceiver::processUpdateChatReadOutbox);
|
|
|
|
handlers.insert("updateBasicGroup", &TDLibReceiver::processUpdateBasicGroup);
|
|
|
|
handlers.insert("updateSupergroup", &TDLibReceiver::processUpdateSuperGroup);
|
|
|
|
handlers.insert("updateChatOnlineMemberCount", &TDLibReceiver::processChatOnlineMemberCountUpdated);
|
|
|
|
handlers.insert("messages", &TDLibReceiver::processMessages);
|
|
|
|
handlers.insert("updateNewMessage", &TDLibReceiver::processUpdateNewMessage);
|
|
|
|
handlers.insert("message", &TDLibReceiver::processMessage);
|
|
|
|
handlers.insert("updateMessageSendSucceeded", &TDLibReceiver::processMessageSendSucceeded);
|
|
|
|
handlers.insert("updateActiveNotifications", &TDLibReceiver::processUpdateActiveNotifications);
|
|
|
|
handlers.insert("updateNotificationGroup", &TDLibReceiver::processUpdateNotificationGroup);
|
|
|
|
handlers.insert("updateChatNotificationSettings", &TDLibReceiver::processUpdateChatNotificationSettings);
|
|
|
|
handlers.insert("updateMessageContent", &TDLibReceiver::processUpdateMessageContent);
|
|
|
|
handlers.insert("updateDeleteMessages", &TDLibReceiver::processUpdateDeleteMessages);
|
2020-10-01 13:50:29 +03:00
|
|
|
handlers.insert("chats", &TDLibReceiver::processChats);
|
2020-10-19 13:20:02 +03:00
|
|
|
handlers.insert("chat", &TDLibReceiver::processChat);
|
2020-10-06 00:08:47 +03:00
|
|
|
handlers.insert("updateRecentStickers", &TDLibReceiver::processUpdateRecentStickers);
|
|
|
|
handlers.insert("stickers", &TDLibReceiver::processStickers);
|
|
|
|
handlers.insert("updateInstalledStickerSets", &TDLibReceiver::processUpdateInstalledStickerSets);
|
|
|
|
handlers.insert("stickerSets", &TDLibReceiver::processStickerSets);
|
2020-10-15 00:25:56 +03:00
|
|
|
handlers.insert("stickerSet", &TDLibReceiver::processStickerSet);
|
2020-10-19 13:20:02 +03:00
|
|
|
handlers.insert("chatMembers", &TDLibReceiver::processChatMembers);
|
|
|
|
handlers.insert("userFullInfo", &TDLibReceiver::processUserFullInfo);
|
|
|
|
handlers.insert("updateUserFullInfo", &TDLibReceiver::processUpdateUserFullInfo);
|
|
|
|
handlers.insert("basicGroupFullInfo", &TDLibReceiver::processBasicGroupFullInfo);
|
|
|
|
handlers.insert("updateBasicGroupFullInfo", &TDLibReceiver::processUpdateBasicGroupFullInfo);
|
|
|
|
handlers.insert("supergroupFullInfo", &TDLibReceiver::processSupergroupFullInfo);
|
|
|
|
handlers.insert("updateSupergroupFullInfo", &TDLibReceiver::processUpdateSupergroupFullInfo);
|
|
|
|
handlers.insert("userProfilePhotos", &TDLibReceiver::processUserProfilePhotos);
|
|
|
|
handlers.insert("updateChatPermissions", &TDLibReceiver::processUpdateChatPermissions);
|
|
|
|
handlers.insert("updateChatTitle", &TDLibReceiver::processUpdateChatTitle);
|
2020-08-10 21:17:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::setActive(const bool &active)
|
|
|
|
{
|
2020-08-12 11:50:01 +03:00
|
|
|
if (active) {
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("Activating receiver loop...");
|
2020-08-12 11:50:01 +03:00
|
|
|
} else {
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("Deactivating receiver loop, this may take a while...");
|
2020-08-12 11:50:01 +03:00
|
|
|
}
|
2020-08-10 21:17:13 +03:00
|
|
|
this->isActive = active;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::receiverLoop()
|
|
|
|
{
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("Starting receiver loop");
|
2020-08-10 21:17:13 +03:00
|
|
|
const double WAIT_TIMEOUT = 5.0;
|
|
|
|
while (this->isActive) {
|
|
|
|
const char *result = td_json_client_receive(this->tdLibClient, WAIT_TIMEOUT);
|
|
|
|
if (result) {
|
2020-08-11 00:37:25 +03:00
|
|
|
QJsonDocument receivedJsonDocument = QJsonDocument::fromJson(QByteArray(result));
|
2020-10-03 21:09:04 +03:00
|
|
|
VERBOSE("Raw result:" << receivedJsonDocument.toJson(QJsonDocument::Indented).constData());
|
2020-08-12 11:50:01 +03:00
|
|
|
processReceivedDocument(receivedJsonDocument);
|
2020-08-10 21:17:13 +03:00
|
|
|
}
|
|
|
|
}
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("Stopping receiver loop");
|
2020-08-10 21:17:13 +03:00
|
|
|
}
|
2020-08-11 00:37:25 +03:00
|
|
|
|
2020-08-12 11:50:01 +03:00
|
|
|
void TDLibReceiver::processReceivedDocument(const QJsonDocument &receivedJsonDocument)
|
2020-08-11 00:37:25 +03:00
|
|
|
{
|
|
|
|
QVariantMap receivedInformation = receivedJsonDocument.object().toVariantMap();
|
|
|
|
QString objectTypeName = receivedInformation.value("@type").toString();
|
|
|
|
|
2020-09-27 17:11:14 +03:00
|
|
|
Handler handler = handlers.value(objectTypeName);
|
|
|
|
if (handler) {
|
|
|
|
(this->*handler)(receivedInformation);
|
|
|
|
} else {
|
|
|
|
LOG("Unhandled object type" << objectTypeName);
|
|
|
|
}
|
2020-08-11 00:37:25 +03:00
|
|
|
}
|
|
|
|
|
2020-08-12 11:50:01 +03:00
|
|
|
void TDLibReceiver::processUpdateOption(const QVariantMap &receivedInformation)
|
2020-08-11 00:37:25 +03:00
|
|
|
{
|
|
|
|
QString currentOption = receivedInformation.value("name").toString();
|
|
|
|
if (currentOption == "version") {
|
|
|
|
QString detectedVersion = receivedInformation.value("value").toMap().value("value").toString();
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("TD Lib version detected: " << detectedVersion);
|
2020-08-11 00:37:25 +03:00
|
|
|
emit versionDetected(detectedVersion);
|
2020-08-13 00:51:09 +03:00
|
|
|
} else {
|
|
|
|
QVariant currentValue = receivedInformation.value("value").toMap().value("value");
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("Option updated: " << currentOption << currentValue);
|
2020-08-13 00:51:09 +03:00
|
|
|
emit optionUpdated(currentOption, currentValue);
|
2020-08-11 00:37:25 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-12 11:50:01 +03:00
|
|
|
void TDLibReceiver::processUpdateAuthorizationState(const QVariantMap &receivedInformation)
|
2020-08-11 00:37:25 +03:00
|
|
|
{
|
|
|
|
QString authorizationState = receivedInformation.value("authorization_state").toMap().value("@type").toString();
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("Authorization state changed: " << authorizationState);
|
2020-10-01 01:55:26 +03:00
|
|
|
emit authorizationStateChanged(authorizationState, receivedInformation);
|
2020-08-11 00:37:25 +03:00
|
|
|
}
|
2020-08-13 01:20:28 +03:00
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateConnectionState(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
QString connectionState = receivedInformation.value("state").toMap().value("@type").toString();
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("Connection state changed: " << connectionState);
|
2020-08-13 01:20:28 +03:00
|
|
|
emit connectionStateChanged(connectionState);
|
|
|
|
}
|
2020-08-13 18:08:14 +03:00
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateUser(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
QVariantMap userInformation = receivedInformation.value("user").toMap();
|
2020-09-27 17:11:14 +03:00
|
|
|
// LOG("User was updated: " << userInformation.value("username").toString() << userInformation.value("first_name").toString() << userInformation.value("last_name").toString());
|
2020-08-13 18:08:14 +03:00
|
|
|
emit userUpdated(userInformation);
|
|
|
|
}
|
2020-08-14 11:33:42 +03:00
|
|
|
|
2020-08-22 15:06:26 +03:00
|
|
|
void TDLibReceiver::processUpdateUserStatus(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
QString userId = receivedInformation.value("user_id").toString();
|
|
|
|
QVariantMap userStatusInformation = receivedInformation.value("status").toMap();
|
2020-09-27 17:11:14 +03:00
|
|
|
// LOG("User status was updated: " << receivedInformation.value("user_id").toString() << userStatusInformation.value("@type").toString());
|
2020-08-22 15:06:26 +03:00
|
|
|
emit userStatusUpdated(userId, userStatusInformation);
|
|
|
|
}
|
|
|
|
|
2020-08-14 11:33:42 +03:00
|
|
|
void TDLibReceiver::processUpdateFile(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
QVariantMap fileInformation = receivedInformation.value("file").toMap();
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("File was updated: " << fileInformation.value(ID).toString());
|
2020-08-14 11:33:42 +03:00
|
|
|
emit fileUpdated(fileInformation);
|
|
|
|
}
|
2020-08-16 18:38:51 +03:00
|
|
|
|
2020-08-25 00:02:08 +03:00
|
|
|
void TDLibReceiver::processFile(const QVariantMap &receivedInformation)
|
|
|
|
{
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("File was updated: " << receivedInformation.value(ID).toString());
|
2020-08-25 00:02:08 +03:00
|
|
|
emit fileUpdated(receivedInformation);
|
|
|
|
}
|
|
|
|
|
2020-08-16 18:38:51 +03:00
|
|
|
void TDLibReceiver::processUpdateNewChat(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
QVariantMap chatInformation = receivedInformation.value("chat").toMap();
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("New chat discovered: " << chatInformation.value(ID).toString() << chatInformation.value("title").toString());
|
2020-08-16 18:38:51 +03:00
|
|
|
emit newChatDiscovered(chatInformation);
|
|
|
|
}
|
2020-08-17 00:31:20 +03:00
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateUnreadMessageCount(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
QVariantMap messageCountInformation;
|
|
|
|
messageCountInformation.insert("chat_list_type", receivedInformation.value("chat_list").toMap().value("@type"));
|
|
|
|
messageCountInformation.insert("unread_count", receivedInformation.value("unread_count"));
|
|
|
|
messageCountInformation.insert("unread_unmuted_count", receivedInformation.value("unread_unmuted_count"));
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("Unread message count updated: " << messageCountInformation.value("chat_list_type").toString() << messageCountInformation.value("unread_count").toString());
|
2020-08-17 00:31:20 +03:00
|
|
|
emit unreadMessageCountUpdated(messageCountInformation);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateUnreadChatCount(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
QVariantMap chatCountInformation;
|
|
|
|
chatCountInformation.insert("chat_list_type", receivedInformation.value("chat_list").toMap().value("@type"));
|
|
|
|
chatCountInformation.insert("marked_as_unread_count", receivedInformation.value("marked_as_unread_count"));
|
|
|
|
chatCountInformation.insert("marked_as_unread_unmuted_count", receivedInformation.value("marked_as_unread_unmuted_count"));
|
|
|
|
chatCountInformation.insert("total_count", receivedInformation.value("total_count"));
|
|
|
|
chatCountInformation.insert("unread_count", receivedInformation.value("unread_count"));
|
|
|
|
chatCountInformation.insert("unread_unmuted_count", receivedInformation.value("unread_unmuted_count"));
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("Unread chat count updated: " << chatCountInformation.value("chat_list_type").toString() << chatCountInformation.value("unread_count").toString());
|
2020-08-17 00:31:20 +03:00
|
|
|
emit unreadChatCountUpdated(chatCountInformation);
|
|
|
|
}
|
2020-08-20 01:24:24 +03:00
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateChatLastMessage(const QVariantMap &receivedInformation)
|
|
|
|
{
|
2020-09-27 17:11:14 +03:00
|
|
|
const QString chat_id(receivedInformation.value(CHAT_ID).toString());
|
2020-09-28 21:47:03 +03:00
|
|
|
QString order;
|
|
|
|
if (receivedInformation.contains(POSITIONS)) {
|
|
|
|
order = findChatPositionOrder(receivedInformation.value(POSITIONS).toList());
|
|
|
|
} else {
|
|
|
|
order = receivedInformation.value(ORDER).toString();
|
|
|
|
}
|
2020-09-27 17:11:14 +03:00
|
|
|
const QVariantMap lastMessage = receivedInformation.value(LAST_MESSAGE).toMap();
|
|
|
|
LOG("Last message of chat" << chat_id << "updated, order" << order << "type" << lastMessage.value("@type").toString());
|
|
|
|
emit chatLastMessageUpdated(chat_id, order, lastMessage);
|
2020-08-20 01:24:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateChatOrder(const QVariantMap &receivedInformation)
|
|
|
|
{
|
2020-09-27 17:11:14 +03:00
|
|
|
const QString chat_id(receivedInformation.value(CHAT_ID).toString());
|
|
|
|
const QString order(receivedInformation.value(ORDER).toString());
|
|
|
|
LOG("Chat order updated for ID" << chat_id << "to" << order);
|
|
|
|
emit chatOrderUpdated(chat_id, order);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateChatPosition(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
const QString chat_id(receivedInformation.value(CHAT_ID).toString());
|
|
|
|
const QString order(receivedInformation.value(POSITION).toMap().value(ORDER).toString());
|
|
|
|
LOG("Chat position updated for ID" << chat_id << "new order" << order);
|
|
|
|
emit chatOrderUpdated(chat_id, order);
|
2020-08-20 01:24:24 +03:00
|
|
|
}
|
2020-08-21 00:56:21 +03:00
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateChatReadInbox(const QVariantMap &receivedInformation)
|
|
|
|
{
|
2020-09-27 17:11:14 +03:00
|
|
|
const QString chat_id(receivedInformation.value(CHAT_ID).toString());
|
|
|
|
const QString unread_count(receivedInformation.value(UNREAD_COUNT).toString());
|
|
|
|
LOG("Chat read information updated for" << chat_id << "unread count:" << unread_count);
|
|
|
|
emit chatReadInboxUpdated(chat_id, receivedInformation.value(LAST_READ_INBOX_MESSAGE_ID).toString(), unread_count.toInt());
|
2020-08-21 00:56:21 +03:00
|
|
|
}
|
2020-08-21 19:03:51 +03:00
|
|
|
|
2020-08-30 20:04:16 +03:00
|
|
|
void TDLibReceiver::processUpdateChatReadOutbox(const QVariantMap &receivedInformation)
|
|
|
|
{
|
2020-09-27 17:11:14 +03:00
|
|
|
const QString chat_id(receivedInformation.value(CHAT_ID).toString());
|
|
|
|
const QString last_read_outbox_message_id(receivedInformation.value(LAST_READ_OUTBOX_MESSAGE_ID).toString());
|
|
|
|
LOG("Sent messages read information updated for" << chat_id << "last read message ID:" << last_read_outbox_message_id);
|
|
|
|
emit chatReadOutboxUpdated(chat_id, last_read_outbox_message_id);
|
2020-08-30 20:04:16 +03:00
|
|
|
}
|
|
|
|
|
2020-08-21 19:03:51 +03:00
|
|
|
void TDLibReceiver::processUpdateBasicGroup(const QVariantMap &receivedInformation)
|
|
|
|
{
|
2020-10-04 04:27:49 +03:00
|
|
|
const QVariantMap basicGroup(receivedInformation.value(BASIC_GROUP).toMap());
|
|
|
|
const qlonglong basicGroupId = basicGroup.value(ID).toLongLong();
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("Basic group information updated for " << basicGroupId);
|
2020-10-04 04:27:49 +03:00
|
|
|
emit basicGroupUpdated(basicGroupId, basicGroup);
|
2020-08-21 19:03:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateSuperGroup(const QVariantMap &receivedInformation)
|
|
|
|
{
|
2020-10-04 04:27:49 +03:00
|
|
|
const QVariantMap supergroup(receivedInformation.value(SUPERGROUP).toMap());
|
|
|
|
const qlonglong superGroupId = supergroup.value(ID).toLongLong();
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("Super group information updated for " << superGroupId);
|
2020-10-04 04:27:49 +03:00
|
|
|
emit superGroupUpdated(superGroupId, supergroup);
|
2020-08-21 19:03:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processChatOnlineMemberCountUpdated(const QVariantMap &receivedInformation)
|
|
|
|
{
|
2020-09-27 17:11:14 +03:00
|
|
|
const QString chatId = receivedInformation.value(CHAT_ID).toString();
|
|
|
|
LOG("Online member count updated for chat " << chatId);
|
2020-08-21 19:03:51 +03:00
|
|
|
emit chatOnlineMemberCountUpdated(chatId, receivedInformation.value("online_member_count").toInt());
|
|
|
|
}
|
2020-08-22 18:30:02 +03:00
|
|
|
|
|
|
|
void TDLibReceiver::processMessages(const QVariantMap &receivedInformation)
|
|
|
|
{
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("Received new messages, amount: " << receivedInformation.value("total_count").toString());
|
2020-10-19 13:20:02 +03:00
|
|
|
emit messagesReceived(receivedInformation.value("messages").toList(), receivedInformation.value("total_count").toInt());
|
2020-08-22 18:30:02 +03:00
|
|
|
}
|
2020-08-23 00:49:02 +03:00
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateNewMessage(const QVariantMap &receivedInformation)
|
|
|
|
{
|
2020-09-27 17:11:14 +03:00
|
|
|
const QString chatId = receivedInformation.value("message").toMap().value(CHAT_ID).toString();
|
|
|
|
LOG("Received new message for chat " << chatId);
|
2020-08-23 00:49:02 +03:00
|
|
|
emit newMessageReceived(chatId, receivedInformation.value("message").toMap());
|
|
|
|
}
|
2020-08-25 17:42:46 +03:00
|
|
|
|
|
|
|
void TDLibReceiver::processMessage(const QVariantMap &receivedInformation)
|
|
|
|
{
|
2020-09-27 17:11:14 +03:00
|
|
|
const QString chatId = receivedInformation.value(CHAT_ID).toString();
|
|
|
|
const QString messageId = receivedInformation.value(ID).toString();
|
|
|
|
LOG("Received message " << chatId << messageId);
|
2020-08-25 17:42:46 +03:00
|
|
|
emit messageInformation(messageId, receivedInformation);
|
|
|
|
}
|
2020-08-31 00:52:22 +03:00
|
|
|
|
|
|
|
void TDLibReceiver::processMessageSendSucceeded(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
QString oldMessageId = receivedInformation.value("old_message_id").toString();
|
|
|
|
QVariantMap message = receivedInformation.value("message").toMap();
|
2020-09-27 17:11:14 +03:00
|
|
|
const QString messageId = message.value(ID).toString();
|
|
|
|
LOG("Message send succeeded " << messageId << oldMessageId);
|
2020-08-31 00:52:22 +03:00
|
|
|
emit messageSendSucceeded(messageId, oldMessageId, message);
|
|
|
|
}
|
2020-09-02 23:49:15 +03:00
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateActiveNotifications(const QVariantMap &receivedInformation)
|
|
|
|
{
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("Received active notification groups");
|
2020-09-02 23:49:15 +03:00
|
|
|
emit activeNotificationsUpdated(receivedInformation.value("groups").toList());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateNotificationGroup(const QVariantMap &receivedInformation)
|
|
|
|
{
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("Received updated notification group");
|
2020-09-02 23:49:15 +03:00
|
|
|
emit notificationGroupUpdated(receivedInformation);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateNotification(const QVariantMap &receivedInformation)
|
|
|
|
{
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("Received notification update");
|
2020-09-02 23:49:15 +03:00
|
|
|
emit notificationUpdated(receivedInformation);
|
|
|
|
}
|
2020-09-16 21:43:36 +03:00
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateChatNotificationSettings(const QVariantMap &receivedInformation)
|
|
|
|
{
|
2020-09-27 17:11:14 +03:00
|
|
|
const QString chatId = receivedInformation.value(CHAT_ID).toString();
|
|
|
|
LOG("Received new notification settings for chat " << chatId);
|
2020-09-16 21:43:36 +03:00
|
|
|
emit chatNotificationSettingsUpdated(chatId, receivedInformation.value("notification_settings").toMap());
|
|
|
|
}
|
2020-09-19 21:33:51 +03:00
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateMessageContent(const QVariantMap &receivedInformation)
|
|
|
|
{
|
2020-09-27 17:11:14 +03:00
|
|
|
const QString chatId = receivedInformation.value(CHAT_ID).toString();
|
2020-09-19 21:33:51 +03:00
|
|
|
QString messageId = receivedInformation.value("message_id").toString();
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("Message content updated " << chatId << messageId);
|
2020-09-19 21:33:51 +03:00
|
|
|
emit messageContentUpdated(chatId, messageId, receivedInformation.value("new_content").toMap());
|
|
|
|
}
|
2020-09-20 01:13:42 +03:00
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateDeleteMessages(const QVariantMap &receivedInformation)
|
|
|
|
{
|
2020-09-27 17:11:14 +03:00
|
|
|
const QString chatId = receivedInformation.value(CHAT_ID).toString();
|
2020-09-20 01:13:42 +03:00
|
|
|
QVariantList messageIds = receivedInformation.value("message_ids").toList();
|
2020-09-27 17:11:14 +03:00
|
|
|
LOG("Some messages were deleted " << chatId);
|
2020-09-20 01:13:42 +03:00
|
|
|
emit messagesDeleted(chatId, messageIds);
|
|
|
|
}
|
2020-10-01 13:50:29 +03:00
|
|
|
|
|
|
|
void TDLibReceiver::processChats(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
emit chats(receivedInformation);
|
|
|
|
}
|
2020-10-06 00:08:47 +03:00
|
|
|
|
2020-10-19 13:20:02 +03:00
|
|
|
void TDLibReceiver::processChat(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
emit chat(receivedInformation);
|
|
|
|
}
|
|
|
|
|
2020-10-06 00:08:47 +03:00
|
|
|
void TDLibReceiver::processUpdateRecentStickers(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
LOG("Recent stickers updated");
|
|
|
|
emit recentStickersUpdated(receivedInformation.value("sticker_ids").toList());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processStickers(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
LOG("Received some stickers...");
|
|
|
|
emit stickers(receivedInformation.value("stickers").toList());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateInstalledStickerSets(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
LOG("Recent sticker sets updated");
|
|
|
|
emit installedStickerSetsUpdated(receivedInformation.value("sticker_set_ids").toList());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processStickerSets(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
LOG("Received some sticker sets...");
|
2020-10-12 23:44:21 +03:00
|
|
|
emit stickerSets(receivedInformation.value("sets").toList());
|
2020-10-06 00:08:47 +03:00
|
|
|
}
|
2020-10-15 00:25:56 +03:00
|
|
|
|
|
|
|
void TDLibReceiver::processStickerSet(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
LOG("Received a sticker set...");
|
|
|
|
emit stickerSet(receivedInformation);
|
|
|
|
}
|
2020-10-19 13:20:02 +03:00
|
|
|
void TDLibReceiver::processChatMembers(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
LOG("Received super group members");
|
|
|
|
const QString extra = receivedInformation.value(EXTRA).toString();
|
|
|
|
emit chatMembers(extra, receivedInformation.value("members").toList(), receivedInformation.value("total_count").toInt());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processUserFullInfo(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
|
|
|
|
LOG("Received UserFullInfo");
|
|
|
|
|
|
|
|
emit userFullInfo(receivedInformation);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateUserFullInfo(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
|
|
|
|
LOG("Received UserFullInfoUpdate");
|
|
|
|
|
|
|
|
emit userFullInfoUpdated(receivedInformation.value("user_id").toString(), receivedInformation.value("user_full_info").toMap());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processBasicGroupFullInfo(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
|
|
|
|
LOG("Received BasicGroupFullInfo");
|
|
|
|
const QString groupId = receivedInformation.value(EXTRA).toString();
|
|
|
|
|
|
|
|
emit basicGroupFullInfo(groupId, receivedInformation);
|
|
|
|
}
|
|
|
|
void TDLibReceiver::processUpdateBasicGroupFullInfo(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
LOG("Received BasicGroupFullInfoUpdate");
|
|
|
|
const QString groupId = receivedInformation.value("basic_group_id").toString();
|
|
|
|
|
|
|
|
emit basicGroupFullInfoUpdated(groupId, receivedInformation.value("basic_group_full_info").toMap());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processSupergroupFullInfo(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
LOG("Received SuperGroupFullInfoUpdate");
|
|
|
|
const QString groupId = receivedInformation.value(EXTRA).toString();
|
|
|
|
|
|
|
|
emit supergroupFullInfo(groupId, receivedInformation);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateSupergroupFullInfo(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
|
|
|
|
LOG("Received SuperGroupFullInfoUpdate");
|
|
|
|
const QString groupId = receivedInformation.value("supergroup_id").toString();
|
|
|
|
|
|
|
|
emit supergroupFullInfoUpdated(groupId, receivedInformation.value("supergroup_full_info").toMap());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processUserProfilePhotos(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
const QString extra = receivedInformation.value(EXTRA).toString();
|
|
|
|
emit userProfilePhotos(extra, receivedInformation.value("photos").toList(), receivedInformation.value("total_count").toInt());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateChatPermissions(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
emit chatPermissionsUpdated(receivedInformation.value("chat_id").toString(), receivedInformation.value("permissions").toMap());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TDLibReceiver::processUpdateChatTitle(const QVariantMap &receivedInformation)
|
|
|
|
{
|
|
|
|
|
|
|
|
LOG("Received UpdateChatTitle");
|
|
|
|
emit chatTitleUpdated(receivedInformation.value("chat_id").toString(), receivedInformation.value("title").toString());
|
|
|
|
}
|