2020-08-13 11:15:26 +03:00
|
|
|
/*
|
2020-10-19 20:34:47 +03:00
|
|
|
Copyright (C) 2020 Sebastian J. Wolf and other contributors
|
2020-08-13 11:15:26 +03:00
|
|
|
|
|
|
|
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
|
|
|
#ifndef TDLIBRECEIVER_H
|
|
|
|
#define TDLIBRECEIVER_H
|
|
|
|
|
2020-11-22 06:58:47 +03:00
|
|
|
#include <QHash>
|
|
|
|
#include <QVariantMap>
|
2020-08-10 21:17:13 +03:00
|
|
|
#include <QThread>
|
2020-08-11 00:37:25 +03:00
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QJsonObject>
|
2020-08-10 21:17:13 +03:00
|
|
|
#include <td/telegram/td_json_client.h>
|
|
|
|
|
|
|
|
class TDLibReceiver : public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
void run() Q_DECL_OVERRIDE {
|
|
|
|
receiverLoop();
|
|
|
|
}
|
|
|
|
public:
|
|
|
|
explicit TDLibReceiver(void *tdLibClient, QObject *parent = nullptr);
|
2020-10-24 02:05:49 +03:00
|
|
|
void setActive(bool active);
|
2020-08-10 21:17:13 +03:00
|
|
|
|
2020-08-11 00:37:25 +03:00
|
|
|
signals:
|
|
|
|
void versionDetected(const QString &version);
|
2020-10-01 01:55:26 +03:00
|
|
|
void authorizationStateChanged(const QString &authorizationState, const QVariantMap &authorizationStateData);
|
2020-08-13 00:51:09 +03:00
|
|
|
void optionUpdated(const QString &optionName, const QVariant &optionValue);
|
2020-08-13 01:20:28 +03:00
|
|
|
void connectionStateChanged(const QString &connectionState);
|
2020-08-13 18:08:14 +03:00
|
|
|
void userUpdated(const QVariantMap &userInformation);
|
2020-08-22 15:06:26 +03:00
|
|
|
void userStatusUpdated(const QString &userId, const QVariantMap &userStatusInformation);
|
2020-08-14 11:33:42 +03:00
|
|
|
void fileUpdated(const QVariantMap &fileInformation);
|
2020-08-16 18:38:51 +03:00
|
|
|
void newChatDiscovered(const QVariantMap &chatInformation);
|
2020-08-17 00:31:20 +03:00
|
|
|
void unreadMessageCountUpdated(const QVariantMap &messageCountInformation);
|
|
|
|
void unreadChatCountUpdated(const QVariantMap &chatCountInformation);
|
2020-08-20 15:58:32 +03:00
|
|
|
void chatLastMessageUpdated(const QString &chatId, const QString &order, const QVariantMap &lastMessage);
|
2020-08-20 01:24:24 +03:00
|
|
|
void chatOrderUpdated(const QString &chatId, const QString &order);
|
2021-01-06 12:42:12 +03:00
|
|
|
void chatPinnedUpdated(qlonglong chatId, bool isPinned);
|
2020-10-24 02:05:49 +03:00
|
|
|
void chatReadInboxUpdated(const QString &chatId, const QString &lastReadInboxMessageId, int unreadCount);
|
2020-08-30 20:04:16 +03:00
|
|
|
void chatReadOutboxUpdated(const QString &chatId, const QString &lastReadOutboxMessageId);
|
2020-10-04 04:27:49 +03:00
|
|
|
void basicGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation);
|
|
|
|
void superGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation);
|
2020-10-24 02:05:49 +03:00
|
|
|
void chatOnlineMemberCountUpdated(const QString &chatId, int onlineMemberCount);
|
|
|
|
void messagesReceived(const QVariantList &messages, int totalCount);
|
2021-12-11 20:29:31 +03:00
|
|
|
void messageLinkInfoReceived(const QString &url, const QVariantMap &messageLinkInfo, const QString &extra);
|
2021-12-06 05:29:40 +03:00
|
|
|
void sponsoredMessagesReceived(qlonglong chatId, const QVariantList &messages);
|
2020-12-06 07:38:03 +03:00
|
|
|
void newMessageReceived(qlonglong chatId, const QVariantMap &message);
|
2020-12-30 19:11:01 +03:00
|
|
|
void messageInformation(qlonglong chatId, qlonglong messageId, const QVariantMap &message);
|
2020-12-06 07:38:03 +03:00
|
|
|
void messageSendSucceeded(qlonglong messageId, qlonglong oldMessageId, const QVariantMap &message);
|
2020-09-02 23:49:15 +03:00
|
|
|
void activeNotificationsUpdated(const QVariantList notificationGroups);
|
|
|
|
void notificationGroupUpdated(const QVariantMap notificationGroupUpdate);
|
|
|
|
void notificationUpdated(const QVariantMap updatedNotification);
|
2020-09-16 21:43:36 +03:00
|
|
|
void chatNotificationSettingsUpdated(const QString &chatId, const QVariantMap updatedChatNotificationSettings);
|
2020-12-06 07:38:03 +03:00
|
|
|
void messageContentUpdated(qlonglong chatId, qlonglong messageId, const QVariantMap &newContent);
|
2020-12-27 02:01:59 +03:00
|
|
|
void messageEditedUpdated(qlonglong chatId, qlonglong messageId, const QVariantMap &replyMarkup);
|
2020-12-06 07:38:03 +03:00
|
|
|
void messagesDeleted(qlonglong chatId, const QList<qlonglong> &messageIds);
|
2020-10-01 13:50:29 +03:00
|
|
|
void chats(const QVariantMap &chats);
|
2020-10-19 13:20:02 +03:00
|
|
|
void chat(const QVariantMap &chats);
|
2020-10-06 00:08:47 +03:00
|
|
|
void recentStickersUpdated(const QVariantList &stickerIds);
|
|
|
|
void stickers(const QVariantList &stickers);
|
|
|
|
void installedStickerSetsUpdated(const QVariantList &stickerSetIds);
|
|
|
|
void stickerSets(const QVariantList &stickerSets);
|
2020-10-15 00:25:56 +03:00
|
|
|
void stickerSet(const QVariantMap &stickerSet);
|
2020-10-24 02:05:49 +03:00
|
|
|
void chatMembers(const QString &extra, const QVariantList &members, int totalMembers);
|
2020-10-19 13:20:02 +03:00
|
|
|
void userFullInfo(const QVariantMap &userFullInfo);
|
2020-12-28 01:30:25 +03:00
|
|
|
void userFullInfoUpdated(const QString &userId, const QVariantMap &userFullInfo);
|
2020-10-19 13:20:02 +03:00
|
|
|
void basicGroupFullInfo(const QString &groupId, const QVariantMap &groupFullInfo);
|
|
|
|
void basicGroupFullInfoUpdated(const QString &groupId, const QVariantMap &groupFullInfo);
|
|
|
|
void supergroupFullInfo(const QString &groupId, const QVariantMap &groupFullInfo);
|
|
|
|
void supergroupFullInfoUpdated(const QString &groupId, const QVariantMap &groupFullInfo);
|
2020-10-24 02:05:49 +03:00
|
|
|
void userProfilePhotos(const QString &extra, const QVariantList &photos, int totalPhotos);
|
2020-10-19 13:20:02 +03:00
|
|
|
void chatPermissionsUpdated(const QString &chatId, const QVariantMap &chatPermissions);
|
2020-11-15 07:11:10 +03:00
|
|
|
void chatPhotoUpdated(qlonglong chatId, const QVariantMap &photo);
|
2020-12-26 00:38:13 +03:00
|
|
|
void chatTitleUpdated(const QString &chatId, const QString &title);
|
2020-11-17 14:18:46 +03:00
|
|
|
void chatPinnedMessageUpdated(qlonglong chatId, qlonglong pinnedMessageId);
|
2020-12-26 00:38:13 +03:00
|
|
|
void messageIsPinnedUpdated(qlonglong chatId, qlonglong messageId, bool isPinned);
|
2020-10-24 20:28:20 +03:00
|
|
|
void usersReceived(const QString &extra, const QVariantList &userIds, int totalUsers);
|
2020-12-25 17:33:53 +03:00
|
|
|
void errorReceived(const int code, const QString &message, const QString &extra);
|
2020-11-27 21:42:39 +03:00
|
|
|
void secretChat(qlonglong secretChatId, const QVariantMap &secretChat);
|
|
|
|
void secretChatUpdated(qlonglong secretChatId, const QVariantMap &secretChat);
|
2020-11-27 00:18:51 +03:00
|
|
|
void contactsImported(const QVariantList &importerCount, const QVariantList &userIds);
|
2020-12-31 02:19:36 +03:00
|
|
|
void chatIsMarkedAsUnreadUpdated(qlonglong chatId, bool chatIsMarkedAsUnread);
|
2020-12-31 02:59:05 +03:00
|
|
|
void chatDraftMessageUpdated(qlonglong chatId, const QVariantMap &draftMessage, const QString &order);
|
2021-01-10 04:06:41 +03:00
|
|
|
void inlineQueryResults(const QString &inlineQueryId, const QString &nextOffset, const QVariantList &results, const QString &switchPmText, const QString &switchPmParameter, const QString &extra);
|
|
|
|
void callbackQueryAnswer(const QString &text, bool alert, const QString &url);
|
2021-01-25 01:46:30 +03:00
|
|
|
void userPrivacySettingRules(const QVariantMap &rules);
|
|
|
|
void userPrivacySettingRulesUpdated(const QVariantMap &updatedRules);
|
2021-01-31 23:08:39 +03:00
|
|
|
void messageInteractionInfoUpdated(qlonglong chatId, qlonglong messageId, const QVariantMap &updatedInfo);
|
2021-01-27 01:26:40 +03:00
|
|
|
void okReceived(const QString &request);
|
2021-02-20 02:14:43 +03:00
|
|
|
void sessionsReceived(const QVariantList &sessions);
|
2020-11-27 00:18:51 +03:00
|
|
|
|
2020-08-10 21:17:13 +03:00
|
|
|
private:
|
2020-09-27 17:11:14 +03:00
|
|
|
typedef void (TDLibReceiver::*Handler)(const QVariantMap &);
|
|
|
|
|
|
|
|
QHash<QString, Handler> handlers;
|
2020-08-10 21:17:13 +03:00
|
|
|
void *tdLibClient;
|
|
|
|
bool isActive;
|
|
|
|
|
|
|
|
void receiverLoop();
|
2021-01-31 23:08:39 +03:00
|
|
|
void nop(const QVariantMap &receivedInformation);
|
2020-08-12 11:50:01 +03:00
|
|
|
void processReceivedDocument(const QJsonDocument &receivedJsonDocument);
|
|
|
|
void processUpdateOption(const QVariantMap &receivedInformation);
|
|
|
|
void processUpdateAuthorizationState(const QVariantMap &receivedInformation);
|
2020-08-13 01:20:28 +03:00
|
|
|
void processUpdateConnectionState(const QVariantMap &receivedInformation);
|
2020-08-13 18:08:14 +03:00
|
|
|
void processUpdateUser(const QVariantMap &receivedInformation);
|
2020-08-22 15:06:26 +03:00
|
|
|
void processUpdateUserStatus(const QVariantMap &receivedInformation);
|
2020-08-14 11:33:42 +03:00
|
|
|
void processUpdateFile(const QVariantMap &receivedInformation);
|
2020-08-25 00:02:08 +03:00
|
|
|
void processFile(const QVariantMap &receivedInformation);
|
2020-08-16 18:38:51 +03:00
|
|
|
void processUpdateNewChat(const QVariantMap &receivedInformation);
|
2020-08-17 00:31:20 +03:00
|
|
|
void processUpdateUnreadMessageCount(const QVariantMap &receivedInformation);
|
|
|
|
void processUpdateUnreadChatCount(const QVariantMap &receivedInformation);
|
2020-08-20 01:24:24 +03:00
|
|
|
void processUpdateChatLastMessage(const QVariantMap &receivedInformation);
|
|
|
|
void processUpdateChatOrder(const QVariantMap &receivedInformation);
|
2020-09-27 17:11:14 +03:00
|
|
|
void processUpdateChatPosition(const QVariantMap &receivedInformation);
|
2020-08-21 00:56:21 +03:00
|
|
|
void processUpdateChatReadInbox(const QVariantMap &receivedInformation);
|
2020-08-30 20:04:16 +03:00
|
|
|
void processUpdateChatReadOutbox(const QVariantMap &receivedInformation);
|
2020-08-21 19:03:51 +03:00
|
|
|
void processUpdateBasicGroup(const QVariantMap &receivedInformation);
|
|
|
|
void processUpdateSuperGroup(const QVariantMap &receivedInformation);
|
|
|
|
void processChatOnlineMemberCountUpdated(const QVariantMap &receivedInformation);
|
2020-08-22 18:30:02 +03:00
|
|
|
void processMessages(const QVariantMap &receivedInformation);
|
2021-12-06 00:06:05 +03:00
|
|
|
void processSponsoredMessages(const QVariantMap &receivedInformation);
|
2020-08-23 00:49:02 +03:00
|
|
|
void processUpdateNewMessage(const QVariantMap &receivedInformation);
|
2020-08-25 17:42:46 +03:00
|
|
|
void processMessage(const QVariantMap &receivedInformation);
|
2021-12-08 02:33:35 +03:00
|
|
|
void processMessageLinkInfo(const QVariantMap &receivedInformation);
|
2020-08-31 00:52:22 +03:00
|
|
|
void processMessageSendSucceeded(const QVariantMap &receivedInformation);
|
2020-09-02 23:49:15 +03:00
|
|
|
void processUpdateActiveNotifications(const QVariantMap &receivedInformation);
|
|
|
|
void processUpdateNotificationGroup(const QVariantMap &receivedInformation);
|
|
|
|
void processUpdateNotification(const QVariantMap &receivedInformation);
|
2020-09-16 21:43:36 +03:00
|
|
|
void processUpdateChatNotificationSettings(const QVariantMap &receivedInformation);
|
2020-09-19 21:33:51 +03:00
|
|
|
void processUpdateMessageContent(const QVariantMap &receivedInformation);
|
2020-09-20 01:13:42 +03:00
|
|
|
void processUpdateDeleteMessages(const QVariantMap &receivedInformation);
|
2020-10-01 13:50:29 +03:00
|
|
|
void processChats(const QVariantMap &receivedInformation);
|
2020-10-19 13:20:02 +03:00
|
|
|
void processChat(const QVariantMap &receivedInformation);
|
2020-10-06 00:08:47 +03:00
|
|
|
void processUpdateRecentStickers(const QVariantMap &receivedInformation);
|
|
|
|
void processStickers(const QVariantMap &receivedInformation);
|
|
|
|
void processUpdateInstalledStickerSets(const QVariantMap &receivedInformation);
|
|
|
|
void processStickerSets(const QVariantMap &receivedInformation);
|
2020-10-15 00:25:56 +03:00
|
|
|
void processStickerSet(const QVariantMap &receivedInformation);
|
2020-10-19 13:20:02 +03:00
|
|
|
void processChatMembers(const QVariantMap &receivedInformation);
|
|
|
|
void processUserFullInfo(const QVariantMap &receivedInformation);
|
|
|
|
void processUpdateUserFullInfo(const QVariantMap &receivedInformation);
|
|
|
|
void processBasicGroupFullInfo(const QVariantMap &receivedInformation);
|
|
|
|
void processUpdateBasicGroupFullInfo(const QVariantMap &receivedInformation);
|
|
|
|
void processSupergroupFullInfo(const QVariantMap &receivedInformation);
|
|
|
|
void processUpdateSupergroupFullInfo(const QVariantMap &receivedInformation);
|
|
|
|
void processUserProfilePhotos(const QVariantMap &receivedInformation);
|
|
|
|
void processUpdateChatPermissions(const QVariantMap &receivedInformation);
|
2020-11-15 07:11:10 +03:00
|
|
|
void processUpdateChatPhoto(const QVariantMap &receivedInformation);
|
2020-10-19 13:20:02 +03:00
|
|
|
void processUpdateChatTitle(const QVariantMap &receivedInformation);
|
2020-11-17 14:18:46 +03:00
|
|
|
void processUpdateChatPinnedMessage(const QVariantMap &receivedInformation);
|
2020-12-26 00:38:13 +03:00
|
|
|
void processUpdateMessageIsPinned(const QVariantMap &receivedInformation);
|
2020-10-23 11:29:50 +03:00
|
|
|
void processUsers(const QVariantMap &receivedInformation);
|
2020-11-10 01:22:24 +03:00
|
|
|
void processError(const QVariantMap &receivedInformation);
|
2020-11-25 02:23:38 +03:00
|
|
|
void processSecretChat(const QVariantMap &receivedInformation);
|
|
|
|
void processUpdateSecretChat(const QVariantMap &receivedInformation);
|
2020-12-27 02:01:59 +03:00
|
|
|
void processUpdateMessageEdited(const QVariantMap &receivedInformation);
|
2020-11-27 00:18:51 +03:00
|
|
|
void processImportedContacts(const QVariantMap &receivedInformation);
|
2020-12-31 02:19:36 +03:00
|
|
|
void processUpdateChatIsMarkedAsUnread(const QVariantMap &receivedInformation);
|
2020-12-31 02:59:05 +03:00
|
|
|
void processUpdateChatDraftMessage(const QVariantMap &receivedInformation);
|
2021-01-10 04:06:41 +03:00
|
|
|
void processInlineQueryResults(const QVariantMap &receivedInformation);
|
|
|
|
void processCallbackQueryAnswer(const QVariantMap &receivedInformation);
|
2021-01-25 01:46:30 +03:00
|
|
|
void processUserPrivacySettingRules(const QVariantMap &receivedInformation);
|
|
|
|
void processUpdateUserPrivacySettingRules(const QVariantMap &receivedInformation);
|
2021-01-31 23:08:39 +03:00
|
|
|
void processUpdateMessageInteractionInfo(const QVariantMap &receivedInformation);
|
2021-02-20 02:14:43 +03:00
|
|
|
void processSessions(const QVariantMap &receivedInformation);
|
2020-08-10 21:17:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TDLIBRECEIVER_H
|