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
|
|
|
#ifndef TDLIBRECEIVER_H
|
|
|
|
#define TDLIBRECEIVER_H
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#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);
|
|
|
|
void setActive(const bool &active);
|
|
|
|
|
2020-08-11 00:37:25 +03:00
|
|
|
signals:
|
|
|
|
void versionDetected(const QString &version);
|
|
|
|
void authorizationStateChanged(const QString &authorizationState);
|
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);
|
2020-08-21 00:56:21 +03:00
|
|
|
void chatReadInboxUpdated(const QString &chatId, const int &unreadCount);
|
2020-08-30 20:04:16 +03:00
|
|
|
void chatReadOutboxUpdated(const QString &chatId, const QString &lastReadOutboxMessageId);
|
2020-08-21 19:03:51 +03:00
|
|
|
void basicGroupUpdated(const QString &groupId, const QVariantMap &groupInformation);
|
|
|
|
void superGroupUpdated(const QString &groupId, const QVariantMap &groupInformation);
|
|
|
|
void chatOnlineMemberCountUpdated(const QString &chatId, const int &onlineMemberCount);
|
2020-08-22 18:30:02 +03:00
|
|
|
void messagesReceived(const QVariantList &messages);
|
2020-08-23 00:49:02 +03:00
|
|
|
void newMessageReceived(const QString &chatId, const QVariantMap &message);
|
2020-08-25 17:42:46 +03:00
|
|
|
void messageInformation(const QString &messageId, const QVariantMap &message);
|
2020-08-11 00:37:25 +03:00
|
|
|
|
2020-08-10 21:17:13 +03:00
|
|
|
private:
|
|
|
|
void *tdLibClient;
|
|
|
|
bool isActive;
|
|
|
|
|
|
|
|
void receiverLoop();
|
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-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);
|
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);
|
2020-08-10 21:17:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TDLIBRECEIVER_H
|