2020-08-13 11:15:26 +03:00
|
|
|
/*
|
2022-05-01 00:51:47 +03:00
|
|
|
Copyright (C) 2020-22 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 15:17:29 +03:00
|
|
|
#ifndef TDLIBWRAPPER_H
|
|
|
|
#define TDLIBWRAPPER_H
|
|
|
|
|
2020-08-10 21:17:13 +03:00
|
|
|
#include <QCoreApplication>
|
2022-05-01 15:04:28 +03:00
|
|
|
#include <QUrl>
|
|
|
|
#include <QNetworkRequest>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QNetworkAccessManager>
|
2022-07-10 23:39:52 +03:00
|
|
|
#include <QNetworkConfigurationManager>
|
2020-08-10 15:17:29 +03:00
|
|
|
#include <td/telegram/td_json_client.h>
|
2020-08-10 21:17:13 +03:00
|
|
|
#include "tdlibreceiver.h"
|
2020-09-15 00:43:21 +03:00
|
|
|
#include "dbusadaptor.h"
|
|
|
|
#include "dbusinterface.h"
|
2020-10-18 19:57:01 +03:00
|
|
|
#include "emojisearchworker.h"
|
2020-11-08 23:13:04 +03:00
|
|
|
#include "appsettings.h"
|
2020-11-23 01:32:00 +03:00
|
|
|
#include "mceinterface.h"
|
2020-08-10 15:17:29 +03:00
|
|
|
|
|
|
|
class TDLibWrapper : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2021-02-25 03:57:24 +03:00
|
|
|
Q_PROPERTY(AuthorizationState authorizationState READ getAuthorizationState NOTIFY authorizationStateChanged)
|
|
|
|
Q_PROPERTY(QVariantMap userInformation READ getUserInformation NOTIFY ownUserUpdated)
|
|
|
|
|
2020-08-10 15:17:29 +03:00
|
|
|
public:
|
2020-11-23 01:32:00 +03:00
|
|
|
explicit TDLibWrapper(AppSettings *appSettings, MceInterface *mceInterface, QObject *parent = nullptr);
|
2020-08-10 15:17:29 +03:00
|
|
|
~TDLibWrapper();
|
|
|
|
|
2020-08-13 00:51:09 +03:00
|
|
|
enum AuthorizationState {
|
|
|
|
Closed,
|
|
|
|
Closing,
|
|
|
|
LoggingOut,
|
2020-08-13 11:15:26 +03:00
|
|
|
AuthorizationReady,
|
2020-08-13 00:51:09 +03:00
|
|
|
WaitCode,
|
|
|
|
WaitEncryptionKey,
|
|
|
|
WaitOtherDeviceConfirmation,
|
|
|
|
WaitPassword,
|
|
|
|
WaitPhoneNumber,
|
|
|
|
WaitRegistration,
|
2021-01-11 21:05:55 +03:00
|
|
|
WaitTdlibParameters,
|
|
|
|
AuthorizationStateClosed,
|
|
|
|
AuthorizationStateLoggingOut
|
2020-08-13 00:51:09 +03:00
|
|
|
};
|
2020-08-13 11:15:26 +03:00
|
|
|
Q_ENUM(AuthorizationState)
|
2020-08-13 00:51:09 +03:00
|
|
|
|
2020-08-13 01:20:28 +03:00
|
|
|
enum ConnectionState {
|
|
|
|
Connecting,
|
|
|
|
ConnectingToProxy,
|
2020-08-13 11:15:26 +03:00
|
|
|
ConnectionReady,
|
2020-08-13 01:20:28 +03:00
|
|
|
Updating,
|
|
|
|
WaitingForNetwork
|
|
|
|
};
|
2020-08-13 11:15:26 +03:00
|
|
|
Q_ENUM(ConnectionState)
|
2020-08-13 01:20:28 +03:00
|
|
|
|
2020-10-04 04:27:49 +03:00
|
|
|
enum ChatType {
|
|
|
|
ChatTypeUnknown,
|
|
|
|
ChatTypePrivate,
|
|
|
|
ChatTypeBasicGroup,
|
|
|
|
ChatTypeSupergroup,
|
|
|
|
ChatTypeSecret
|
|
|
|
};
|
|
|
|
Q_ENUM(ChatType)
|
|
|
|
|
|
|
|
enum ChatMemberStatus {
|
|
|
|
ChatMemberStatusUnknown,
|
|
|
|
ChatMemberStatusCreator,
|
|
|
|
ChatMemberStatusAdministrator,
|
|
|
|
ChatMemberStatusMember,
|
|
|
|
ChatMemberStatusRestricted,
|
|
|
|
ChatMemberStatusLeft,
|
|
|
|
ChatMemberStatusBanned
|
|
|
|
};
|
|
|
|
Q_ENUM(ChatMemberStatus)
|
|
|
|
|
2020-11-26 00:09:47 +03:00
|
|
|
enum SecretChatState {
|
|
|
|
SecretChatStateUnknown,
|
|
|
|
SecretChatStateClosed,
|
|
|
|
SecretChatStatePending,
|
|
|
|
SecretChatStateReady,
|
|
|
|
};
|
|
|
|
Q_ENUM(SecretChatState)
|
|
|
|
|
2021-01-20 01:58:58 +03:00
|
|
|
enum UserPrivacySetting {
|
|
|
|
SettingAllowChatInvites,
|
|
|
|
SettingAllowFindingByPhoneNumber,
|
|
|
|
SettingShowLinkInForwardedMessages,
|
|
|
|
SettingShowPhoneNumber,
|
|
|
|
SettingShowProfilePhoto,
|
2021-01-25 01:46:30 +03:00
|
|
|
SettingShowStatus,
|
|
|
|
SettingUnknown
|
2021-01-20 01:58:58 +03:00
|
|
|
};
|
|
|
|
Q_ENUM(UserPrivacySetting)
|
|
|
|
|
|
|
|
enum UserPrivacySettingRule {
|
|
|
|
RuleAllowAll,
|
|
|
|
RuleAllowContacts,
|
2021-01-25 01:46:30 +03:00
|
|
|
RuleRestrictAll
|
2021-01-20 01:58:58 +03:00
|
|
|
};
|
|
|
|
Q_ENUM(UserPrivacySettingRule)
|
|
|
|
|
2022-07-10 23:39:52 +03:00
|
|
|
enum NetworkType {
|
|
|
|
Mobile,
|
|
|
|
MobileRoaming,
|
|
|
|
None,
|
|
|
|
Other,
|
|
|
|
WiFi
|
|
|
|
};
|
|
|
|
Q_ENUM(NetworkType)
|
|
|
|
|
2020-10-04 04:27:49 +03:00
|
|
|
class Group {
|
|
|
|
public:
|
|
|
|
Group(qlonglong id) : groupId(id) { }
|
|
|
|
ChatMemberStatus chatMemberStatus() const;
|
|
|
|
public:
|
|
|
|
const qlonglong groupId;
|
|
|
|
QVariantMap groupInfo;
|
|
|
|
};
|
|
|
|
|
2020-08-12 11:50:01 +03:00
|
|
|
Q_INVOKABLE QString getVersion();
|
2020-08-13 00:51:09 +03:00
|
|
|
Q_INVOKABLE TDLibWrapper::AuthorizationState getAuthorizationState();
|
2020-10-01 01:55:26 +03:00
|
|
|
Q_INVOKABLE QVariantMap getAuthorizationStateData();
|
2020-08-13 01:20:28 +03:00
|
|
|
Q_INVOKABLE TDLibWrapper::ConnectionState getConnectionState();
|
2020-08-14 11:33:42 +03:00
|
|
|
Q_INVOKABLE QVariantMap getUserInformation();
|
2020-08-16 18:38:51 +03:00
|
|
|
Q_INVOKABLE QVariantMap getUserInformation(const QString &userId);
|
2020-11-20 20:30:33 +03:00
|
|
|
Q_INVOKABLE bool hasUserInformation(const QString &userId);
|
2020-11-04 00:21:01 +03:00
|
|
|
Q_INVOKABLE QVariantMap getUserInformationByName(const QString &userName);
|
2021-01-25 01:46:30 +03:00
|
|
|
Q_INVOKABLE UserPrivacySettingRule getUserPrivacySettingRule(UserPrivacySetting userPrivacySetting);
|
2020-08-17 00:31:20 +03:00
|
|
|
Q_INVOKABLE QVariantMap getUnreadMessageInformation();
|
|
|
|
Q_INVOKABLE QVariantMap getUnreadChatInformation();
|
2020-10-04 04:27:49 +03:00
|
|
|
Q_INVOKABLE QVariantMap getBasicGroup(qlonglong groupId) const;
|
|
|
|
Q_INVOKABLE QVariantMap getSuperGroup(qlonglong groupId) const;
|
2020-09-15 22:17:44 +03:00
|
|
|
Q_INVOKABLE QVariantMap getChat(const QString &chatId);
|
2020-11-27 21:42:39 +03:00
|
|
|
Q_INVOKABLE QVariantMap getSecretChatFromCache(qlonglong secretChatId);
|
2023-11-18 16:45:22 +03:00
|
|
|
Q_INVOKABLE QStringList getChatReactions(const QString &chatId);
|
2020-11-04 01:39:09 +03:00
|
|
|
Q_INVOKABLE QString getOptionString(const QString &optionName);
|
2021-02-09 00:49:34 +03:00
|
|
|
Q_INVOKABLE void copyFileToDownloads(const QString &filePath, bool openAfterCopy = false);
|
2020-08-28 17:18:33 +03:00
|
|
|
Q_INVOKABLE void openFileOnDevice(const QString &filePath);
|
2020-10-24 02:05:49 +03:00
|
|
|
Q_INVOKABLE void controlScreenSaver(bool enabled);
|
2020-11-10 01:22:24 +03:00
|
|
|
Q_INVOKABLE bool getJoinChatRequested();
|
|
|
|
Q_INVOKABLE void registerJoinChat();
|
2020-08-14 11:33:42 +03:00
|
|
|
|
2020-09-15 00:43:21 +03:00
|
|
|
DBusAdaptor *getDBusAdaptor();
|
|
|
|
|
2020-08-14 11:33:42 +03:00
|
|
|
// Direct TDLib functions
|
|
|
|
Q_INVOKABLE void sendRequest(const QVariantMap &requestObject);
|
2020-08-13 11:15:26 +03:00
|
|
|
Q_INVOKABLE void setAuthenticationPhoneNumber(const QString &phoneNumber);
|
2020-08-13 16:35:43 +03:00
|
|
|
Q_INVOKABLE void setAuthenticationCode(const QString &authenticationCode);
|
2020-09-16 23:36:43 +03:00
|
|
|
Q_INVOKABLE void setAuthenticationPassword(const QString &authenticationPassword);
|
2020-10-01 01:55:26 +03:00
|
|
|
Q_INVOKABLE void registerUser(const QString &firstName, const QString &lastName);
|
2021-01-11 21:05:55 +03:00
|
|
|
Q_INVOKABLE void logout();
|
2020-08-13 23:32:35 +03:00
|
|
|
Q_INVOKABLE void getChats();
|
2020-11-08 07:00:13 +03:00
|
|
|
Q_INVOKABLE void downloadFile(int fileId);
|
2020-08-21 15:47:08 +03:00
|
|
|
Q_INVOKABLE void openChat(const QString &chatId);
|
|
|
|
Q_INVOKABLE void closeChat(const QString &chatId);
|
2020-11-07 22:29:44 +03:00
|
|
|
Q_INVOKABLE void joinChat(const QString &chatId);
|
2020-10-19 13:20:02 +03:00
|
|
|
Q_INVOKABLE void leaveChat(const QString &chatId);
|
2021-12-09 00:35:26 +03:00
|
|
|
Q_INVOKABLE void deleteChat(qlonglong chatId);
|
2020-12-30 19:11:01 +03:00
|
|
|
Q_INVOKABLE void getChatHistory(qlonglong chatId, qlonglong fromMessageId = 0, int offset = -1, int limit = 50, bool onlyLocal = false);
|
2022-03-27 21:39:47 +03:00
|
|
|
Q_INVOKABLE void viewMessage(qlonglong chatId, qlonglong messageId, bool force);
|
2020-11-17 22:25:57 +03:00
|
|
|
Q_INVOKABLE void pinMessage(const QString &chatId, const QString &messageId, bool disableNotification = false);
|
2020-12-26 00:38:13 +03:00
|
|
|
Q_INVOKABLE void unpinMessage(const QString &chatId, const QString &messageId);
|
2023-11-19 00:14:59 +03:00
|
|
|
Q_INVOKABLE void sendTextMessage(qlonglong chatId, const QString &message, qlonglong replyToMessageId = 0);
|
|
|
|
Q_INVOKABLE void sendPhotoMessage(qlonglong chatId, const QString &filePath, const QString &message, qlonglong replyToMessageId = 0);
|
|
|
|
Q_INVOKABLE void sendVideoMessage(qlonglong chatId, const QString &filePath, const QString &message, qlonglong replyToMessageId = 0);
|
|
|
|
Q_INVOKABLE void sendDocumentMessage(qlonglong chatId, const QString &filePath, const QString &message, qlonglong replyToMessageId = 0);
|
|
|
|
Q_INVOKABLE void sendVoiceNoteMessage(qlonglong chatId, const QString &filePath, const QString &message, qlonglong replyToMessageId = 0);
|
|
|
|
Q_INVOKABLE void sendLocationMessage(qlonglong chatId, double latitude, double longitude, double horizontalAccuracy, qlonglong replyToMessageId = 0);
|
|
|
|
Q_INVOKABLE void sendStickerMessage(qlonglong chatId, const QString &fileId, qlonglong replyToMessageId = 0);
|
|
|
|
Q_INVOKABLE void sendPollMessage(qlonglong chatId, const QString &question, const QVariantList &options, bool anonymous, int correctOption, bool multiple, const QString &explanation, qlonglong replyToMessageId = 0);
|
2020-12-30 19:11:01 +03:00
|
|
|
Q_INVOKABLE void forwardMessages(const QString &chatId, const QString &fromChatId, const QVariantList &messageIds, bool sendCopy, bool removeCaption);
|
|
|
|
Q_INVOKABLE void getMessage(qlonglong chatId, qlonglong messageId);
|
2021-12-11 20:29:31 +03:00
|
|
|
Q_INVOKABLE void getMessageLinkInfo(const QString &url, const QString &extra = "");
|
2022-05-01 02:17:37 +03:00
|
|
|
Q_INVOKABLE void getExternalLinkInfo(const QString &url, const QString &extra = "");
|
2020-12-27 02:01:59 +03:00
|
|
|
Q_INVOKABLE void getCallbackQueryAnswer(const QString &chatId, const QString &messageId, const QVariantMap &payload);
|
2020-12-30 19:11:01 +03:00
|
|
|
Q_INVOKABLE void getChatPinnedMessage(qlonglong chatId);
|
2022-01-08 00:03:58 +03:00
|
|
|
Q_INVOKABLE void getChatSponsoredMessage(qlonglong chatId);
|
2020-10-24 02:05:49 +03:00
|
|
|
Q_INVOKABLE void setOptionInteger(const QString &optionName, int optionValue);
|
2020-11-24 01:15:17 +03:00
|
|
|
Q_INVOKABLE void setOptionBoolean(const QString &optionName, bool optionValue);
|
2020-09-16 01:15:43 +03:00
|
|
|
Q_INVOKABLE void setChatNotificationSettings(const QString &chatId, const QVariantMap ¬ificationSettings);
|
2020-09-19 21:33:51 +03:00
|
|
|
Q_INVOKABLE void editMessageText(const QString &chatId, const QString &messageId, const QString &message);
|
2020-09-20 01:13:42 +03:00
|
|
|
Q_INVOKABLE void deleteMessages(const QString &chatId, const QVariantList messageIds);
|
2021-01-10 04:06:41 +03:00
|
|
|
Q_INVOKABLE void getMapThumbnailFile(const QString &chatId, double latitude, double longitude, int width, int height, const QString &extra);
|
2020-10-06 00:08:47 +03:00
|
|
|
Q_INVOKABLE void getRecentStickers();
|
|
|
|
Q_INVOKABLE void getInstalledStickerSets();
|
2020-10-15 00:25:56 +03:00
|
|
|
Q_INVOKABLE void getStickerSet(const QString &setId);
|
2020-10-24 02:05:49 +03:00
|
|
|
Q_INVOKABLE void getSupergroupMembers(const QString &groupId, int limit, int offset);
|
|
|
|
Q_INVOKABLE void getGroupFullInfo(const QString &groupId, bool isSuperGroup);
|
2020-10-19 13:20:02 +03:00
|
|
|
Q_INVOKABLE void getUserFullInfo(const QString &userId);
|
2021-01-10 04:06:41 +03:00
|
|
|
Q_INVOKABLE void createPrivateChat(const QString &userId, const QString &extra);
|
|
|
|
Q_INVOKABLE void createNewSecretChat(const QString &userId, const QString &extra);
|
|
|
|
Q_INVOKABLE void createSupergroupChat(const QString &supergroupId, const QString &extra);
|
|
|
|
Q_INVOKABLE void createBasicGroupChat(const QString &basicGroupId, const QString &extra);
|
2020-10-24 02:05:49 +03:00
|
|
|
Q_INVOKABLE void getGroupsInCommon(const QString &userId, int limit, int offset);
|
|
|
|
Q_INVOKABLE void getUserProfilePhotos(const QString &userId, int limit, int offset);
|
2020-10-19 13:20:02 +03:00
|
|
|
Q_INVOKABLE void setChatPermissions(const QString &chatId, const QVariantMap &chatPermissions);
|
2020-10-24 02:05:49 +03:00
|
|
|
Q_INVOKABLE void setChatSlowModeDelay(const QString &chatId, int delay);
|
2020-10-19 13:20:02 +03:00
|
|
|
Q_INVOKABLE void setChatDescription(const QString &chatId, const QString &description);
|
|
|
|
Q_INVOKABLE void setChatTitle(const QString &chatId, const QString &title);
|
|
|
|
Q_INVOKABLE void setBio(const QString &bio);
|
2020-10-24 02:05:49 +03:00
|
|
|
Q_INVOKABLE void toggleSupergroupIsAllHistoryAvailable(const QString &groupId, bool isAllHistoryAvailable);
|
2020-12-30 19:11:01 +03:00
|
|
|
Q_INVOKABLE void setPollAnswer(const QString &chatId, qlonglong messageId, QVariantList optionIds);
|
|
|
|
Q_INVOKABLE void stopPoll(const QString &chatId, qlonglong messageId);
|
|
|
|
Q_INVOKABLE void getPollVoters(const QString &chatId, qlonglong messageId, int optionId, int limit, int offset, const QString &extra);
|
2021-01-10 04:06:41 +03:00
|
|
|
Q_INVOKABLE void searchPublicChat(const QString &userName, bool doOpenOnFound);
|
2020-11-04 01:39:09 +03:00
|
|
|
Q_INVOKABLE void joinChatByInviteLink(const QString &inviteLink);
|
2020-11-08 23:13:04 +03:00
|
|
|
Q_INVOKABLE void getDeepLinkInfo(const QString &link);
|
2020-11-20 20:30:33 +03:00
|
|
|
Q_INVOKABLE void getContacts();
|
2020-11-27 21:42:39 +03:00
|
|
|
Q_INVOKABLE void getSecretChat(qlonglong secretChatId);
|
|
|
|
Q_INVOKABLE void closeSecretChat(qlonglong secretChatId);
|
2020-11-27 00:18:51 +03:00
|
|
|
Q_INVOKABLE void importContacts(const QVariantList &contacts);
|
2020-12-30 19:11:01 +03:00
|
|
|
Q_INVOKABLE void searchChatMessages(qlonglong chatId, const QString &query, qlonglong fromMessageId = 0);
|
2020-12-28 01:30:25 +03:00
|
|
|
Q_INVOKABLE void searchPublicChats(const QString &query);
|
2020-12-28 23:57:34 +03:00
|
|
|
Q_INVOKABLE void readAllChatMentions(qlonglong chatId);
|
2022-05-24 22:19:15 +03:00
|
|
|
Q_INVOKABLE void readAllChatReactions(qlonglong chatId);
|
2020-12-31 02:19:36 +03:00
|
|
|
Q_INVOKABLE void toggleChatIsMarkedAsUnread(qlonglong chatId, bool isMarkedAsUnread);
|
2021-01-08 00:47:42 +03:00
|
|
|
Q_INVOKABLE void toggleChatIsPinned(qlonglong chatId, bool isPinned);
|
2020-12-31 02:59:05 +03:00
|
|
|
Q_INVOKABLE void setChatDraftMessage(qlonglong chatId, qlonglong threadId, qlonglong replyToMessageId, const QString &draft);
|
2021-01-10 04:06:41 +03:00
|
|
|
Q_INVOKABLE void getInlineQueryResults(qlonglong botUserId, qlonglong chatId, const QVariantMap &userLocation, const QString &query, const QString &offset, const QString &extra);
|
|
|
|
Q_INVOKABLE void sendInlineQueryResultMessage(qlonglong chatId, qlonglong threadId, qlonglong replyToMessageId, const QString &queryId, const QString &resultId);
|
|
|
|
Q_INVOKABLE void sendBotStartMessage(qlonglong botUserId, qlonglong chatId, const QString ¶meter, const QString &extra);
|
2021-01-17 23:19:29 +03:00
|
|
|
Q_INVOKABLE void cancelDownloadFile(int fileId);
|
|
|
|
Q_INVOKABLE void cancelUploadFile(int fileId);
|
|
|
|
Q_INVOKABLE void deleteFile(int fileId);
|
2021-01-19 02:02:37 +03:00
|
|
|
Q_INVOKABLE void setName(const QString &firstName, const QString &lastName);
|
2021-01-20 01:58:58 +03:00
|
|
|
Q_INVOKABLE void setUsername(const QString &userName);
|
|
|
|
Q_INVOKABLE void setUserPrivacySettingRule(UserPrivacySetting setting, UserPrivacySettingRule rule);
|
2021-01-25 01:46:30 +03:00
|
|
|
Q_INVOKABLE void getUserPrivacySettingRules(UserPrivacySetting setting);
|
2021-01-27 01:26:40 +03:00
|
|
|
Q_INVOKABLE void setProfilePhoto(const QString &filePath);
|
|
|
|
Q_INVOKABLE void deleteProfilePhoto(const QString &profilePhotoId);
|
2021-02-12 01:39:56 +03:00
|
|
|
Q_INVOKABLE void changeStickerSet(const QString &stickerSetId, bool isInstalled);
|
2021-02-20 02:14:43 +03:00
|
|
|
Q_INVOKABLE void getActiveSessions();
|
|
|
|
Q_INVOKABLE void terminateSession(const QString &sessionId);
|
2022-05-01 00:51:47 +03:00
|
|
|
Q_INVOKABLE void getMessageAvailableReactions(qlonglong chatId, qlonglong messageId);
|
2022-05-01 15:04:28 +03:00
|
|
|
Q_INVOKABLE void getPageSource(const QString &address);
|
2022-05-24 00:33:17 +03:00
|
|
|
Q_INVOKABLE void setMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction);
|
2022-07-10 23:39:52 +03:00
|
|
|
Q_INVOKABLE void setNetworkType(NetworkType networkType);
|
2020-08-12 11:50:01 +03:00
|
|
|
|
2020-10-18 19:57:01 +03:00
|
|
|
// Others (candidates for extraction ;))
|
|
|
|
Q_INVOKABLE void searchEmoji(const QString &queryString);
|
2020-11-08 23:13:04 +03:00
|
|
|
Q_INVOKABLE void initializeOpenWith();
|
|
|
|
Q_INVOKABLE void removeOpenWith();
|
2020-10-18 19:57:01 +03:00
|
|
|
|
2020-10-04 04:27:49 +03:00
|
|
|
public:
|
|
|
|
const Group* getGroup(qlonglong groupId) const;
|
2020-10-31 22:18:12 +03:00
|
|
|
static ChatType chatTypeFromString(const QString &type);
|
2020-10-04 04:27:49 +03:00
|
|
|
static ChatMemberStatus chatMemberStatusFromString(const QString &status);
|
2020-11-26 00:09:47 +03:00
|
|
|
static SecretChatState secretChatStateFromString(const QString &state);
|
2020-10-04 04:27:49 +03:00
|
|
|
|
2020-08-10 15:17:29 +03:00
|
|
|
signals:
|
2020-08-12 11:50:01 +03:00
|
|
|
void versionDetected(const QString &version);
|
2020-08-20 01:24:24 +03:00
|
|
|
void ownUserIdFound(const QString &ownUserId);
|
2020-10-01 01:55:26 +03:00
|
|
|
void authorizationStateChanged(const TDLibWrapper::AuthorizationState &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 TDLibWrapper::ConnectionState &connectionState);
|
2020-10-24 02:05:49 +03:00
|
|
|
void fileUpdated(int fileId, const QVariantMap &fileInformation);
|
2020-08-19 10:55:13 +03:00
|
|
|
void newChatDiscovered(const QString &chatId, 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-08-21 19:03:51 +03:00
|
|
|
void userUpdated(const QString &userId, const QVariantMap &userInformation);
|
2021-01-19 02:02:37 +03:00
|
|
|
void ownUserUpdated(const QVariantMap &userInformation);
|
2020-10-04 04:27:49 +03:00
|
|
|
void basicGroupUpdated(qlonglong groupId);
|
|
|
|
void superGroupUpdated(qlonglong groupId);
|
2020-10-24 02:05:49 +03:00
|
|
|
void chatOnlineMemberCountUpdated(const QString &chatId, int onlineMemberCount);
|
|
|
|
void messagesReceived(const QVariantList &messages, int totalCount);
|
2022-01-08 00:03:58 +03:00
|
|
|
void sponsoredMessageReceived(qlonglong chatId, const QVariantMap &message);
|
2021-12-11 20:29:31 +03:00
|
|
|
void messageLinkInfoReceived(const QString &url, const QVariantMap &messageLinkInfo, const QString &extra);
|
2020-12-06 07:38:03 +03:00
|
|
|
void newMessageReceived(qlonglong chatId, const QVariantMap &message);
|
2020-08-25 00:02:08 +03:00
|
|
|
void copyToDownloadsSuccessful(const QString &fileName, const QString &filePath);
|
|
|
|
void copyToDownloadsError(const QString &fileName, const QString &filePath);
|
2020-12-30 19:11:01 +03:00
|
|
|
void receivedMessage(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 chatNotificationSettings);
|
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 chatsReceived(const QVariantMap &chats);
|
2020-10-19 13:20:02 +03:00
|
|
|
void chatReceived(const QVariantMap &chat);
|
2020-11-27 21:42:39 +03:00
|
|
|
void secretChatReceived(qlonglong secretChatId, const QVariantMap &secretChat);
|
|
|
|
void secretChatUpdated(qlonglong secretChatId, const QVariantMap &secretChat);
|
2020-10-06 00:08:47 +03:00
|
|
|
void recentStickersUpdated(const QVariantList &stickerIds);
|
|
|
|
void stickersReceived(const QVariantList &stickers);
|
|
|
|
void installedStickerSetsUpdated(const QVariantList &stickerSetIds);
|
|
|
|
void stickerSetsReceived(const QVariantList &stickerSets);
|
2020-10-15 00:25:56 +03:00
|
|
|
void stickerSetReceived(const QVariantMap &stickerSet);
|
2020-10-18 19:57:01 +03:00
|
|
|
void emojiSearchSuccessful(const QVariantList &result);
|
2020-10-24 02:05:49 +03:00
|
|
|
void chatMembersReceived(const QString &extra, const QVariantList &members, int totalMembers);
|
2020-10-19 13:20:02 +03:00
|
|
|
void userFullInfoReceived(const QVariantMap &userFullInfo);
|
|
|
|
void userFullInfoUpdated(const QString &userId, const QVariantMap &userFullInfo);
|
|
|
|
void basicGroupFullInfoReceived(const QString &groupId, const QVariantMap &groupFullInfo);
|
|
|
|
void supergroupFullInfoReceived(const QString &groupId, const QVariantMap &groupFullInfo);
|
|
|
|
void basicGroupFullInfoUpdated(const QString &groupId, const QVariantMap &groupFullInfo);
|
|
|
|
void supergroupFullInfoUpdated(const QString &groupId, const QVariantMap &groupFullInfo);
|
2020-10-24 02:05:49 +03:00
|
|
|
void userProfilePhotosReceived(const QString &extra, const QVariantList &photos, int totalPhotos);
|
2020-10-19 13:20:02 +03:00
|
|
|
void chatPermissionsUpdated(const QString &chatId, const QVariantMap &permissions);
|
2020-11-15 07:11:10 +03:00
|
|
|
void chatPhotoUpdated(qlonglong chatId, const QVariantMap &photo);
|
2020-10-19 13:20:02 +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-10-24 20:28:20 +03:00
|
|
|
void usersReceived(const QString &extra, const QVariantList &userIds, int totalUsers);
|
2020-12-30 19:11:01 +03:00
|
|
|
void errorReceived(int code, const QString &message, const QString &extra);
|
2020-11-27 00:18:51 +03:00
|
|
|
void contactsImported(const QVariantList &importerCount, const QVariantList &userIds);
|
2020-12-30 19:11:01 +03:00
|
|
|
void messageNotFound(qlonglong chatId, qlonglong messageId);
|
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 userPrivacySettingUpdated(UserPrivacySetting setting, UserPrivacySettingRule rule);
|
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);
|
2022-04-24 21:55:06 +03:00
|
|
|
void openFileExternally(const QString &filePath);
|
2022-05-01 00:51:47 +03:00
|
|
|
void availableReactionsReceived(qlonglong messageId, const QStringList &reactions);
|
2022-06-06 16:55:21 +03:00
|
|
|
void chatUnreadMentionCountUpdated(qlonglong chatId, int unreadMentionCount);
|
|
|
|
void chatUnreadReactionCountUpdated(qlonglong chatId, int unreadReactionCount);
|
2022-05-01 15:04:28 +03:00
|
|
|
void tgUrlFound(const QString &tgUrl);
|
2020-08-10 15:17:29 +03:00
|
|
|
|
|
|
|
public slots:
|
2020-08-12 11:50:01 +03:00
|
|
|
void handleVersionDetected(const QString &version);
|
2020-10-01 01:55:26 +03:00
|
|
|
void handleAuthorizationStateChanged(const QString &authorizationState, const QVariantMap authorizationStateData);
|
2020-08-13 00:51:09 +03:00
|
|
|
void handleOptionUpdated(const QString &optionName, const QVariant &optionValue);
|
2020-08-13 01:20:28 +03:00
|
|
|
void handleConnectionStateChanged(const QString &connectionState);
|
2020-08-13 18:08:14 +03:00
|
|
|
void handleUserUpdated(const QVariantMap &userInformation);
|
2020-08-22 15:06:26 +03:00
|
|
|
void handleUserStatusUpdated(const QString &userId, const QVariantMap &userStatusInformation);
|
2020-08-16 18:38:51 +03:00
|
|
|
void handleFileUpdated(const QVariantMap &fileInformation);
|
|
|
|
void handleNewChatDiscovered(const QVariantMap &chatInformation);
|
2020-11-05 02:02:27 +03:00
|
|
|
void handleChatReceived(const QVariantMap &chatInformation);
|
2020-08-17 00:31:20 +03:00
|
|
|
void handleUnreadMessageCountUpdated(const QVariantMap &messageCountInformation);
|
|
|
|
void handleUnreadChatCountUpdated(const QVariantMap &chatCountInformation);
|
2020-10-04 04:27:49 +03:00
|
|
|
void handleBasicGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation);
|
|
|
|
void handleSuperGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation);
|
2020-10-06 00:08:47 +03:00
|
|
|
void handleStickerSets(const QVariantList &stickerSets);
|
2020-10-18 19:57:01 +03:00
|
|
|
void handleEmojiSearchCompleted(const QString &queryString, const QVariantList &resultList);
|
2020-11-08 23:13:04 +03:00
|
|
|
void handleOpenWithChanged();
|
2020-11-27 21:42:39 +03:00
|
|
|
void handleSecretChatReceived(qlonglong secretChatId, const QVariantMap &secretChat);
|
|
|
|
void handleSecretChatUpdated(qlonglong secretChatId, const QVariantMap &secretChat);
|
2020-11-24 01:15:17 +03:00
|
|
|
void handleStorageOptimizerChanged();
|
2020-12-30 19:11:01 +03:00
|
|
|
void handleErrorReceived(int code, const QString &message, const QString &extra);
|
|
|
|
void handleMessageInformation(qlonglong chatId, qlonglong messageId, const QVariantMap &receivedInformation);
|
2020-12-26 00:38:13 +03:00
|
|
|
void handleMessageIsPinnedUpdated(qlonglong chatId, qlonglong messageId, bool isPinned);
|
2021-01-25 01:46:30 +03:00
|
|
|
void handleUserPrivacySettingRules(const QVariantMap &rules);
|
|
|
|
void handleUpdatedUserPrivacySettingRules(const QVariantMap &updatedRules);
|
2022-01-08 00:03:58 +03:00
|
|
|
void handleSponsoredMessage(qlonglong chatId, const QVariantMap &message);
|
2022-07-10 23:39:52 +03:00
|
|
|
void handleNetworkConfigurationChanged(const QNetworkConfiguration &config);
|
2023-11-18 16:45:22 +03:00
|
|
|
void handleActiveEmojiReactionsUpdated(const QStringList& emojis);
|
2022-05-01 15:04:28 +03:00
|
|
|
void handleGetPageSourceFinished();
|
|
|
|
|
2020-10-04 04:27:49 +03:00
|
|
|
private:
|
2020-11-24 01:15:17 +03:00
|
|
|
void setOption(const QString &name, const QString &type, const QVariant &value);
|
2020-10-04 04:27:49 +03:00
|
|
|
void setInitialParameters();
|
|
|
|
void setEncryptionKey();
|
|
|
|
void setLogVerbosityLevel();
|
2023-11-18 16:45:22 +03:00
|
|
|
QVariantMap &fillTdlibParameters(QVariantMap ¶meters);
|
2020-10-04 04:27:49 +03:00
|
|
|
const Group *updateGroup(qlonglong groupId, const QVariantMap &groupInfo, QHash<qlonglong,Group*> *groups);
|
2023-11-19 00:14:59 +03:00
|
|
|
QVariantMap newSendMessageRequest(qlonglong chatId, qlonglong replyToMessageId);
|
2022-04-21 23:37:14 +03:00
|
|
|
void initializeTDLibReceiver();
|
2020-10-04 04:27:49 +03:00
|
|
|
|
2020-08-10 15:17:29 +03:00
|
|
|
private:
|
|
|
|
void *tdLibClient;
|
2022-05-01 15:04:28 +03:00
|
|
|
QNetworkAccessManager *manager;
|
2022-07-10 23:39:52 +03:00
|
|
|
QNetworkConfigurationManager *networkConfigurationManager;
|
2020-11-08 23:13:04 +03:00
|
|
|
AppSettings *appSettings;
|
2020-11-23 01:32:00 +03:00
|
|
|
MceInterface *mceInterface;
|
2020-08-10 21:17:13 +03:00
|
|
|
TDLibReceiver *tdLibReceiver;
|
2020-09-15 00:43:21 +03:00
|
|
|
DBusInterface *dbusInterface;
|
2023-11-18 16:45:22 +03:00
|
|
|
QString versionString;
|
2020-08-13 00:51:09 +03:00
|
|
|
TDLibWrapper::AuthorizationState authorizationState;
|
2020-10-01 01:55:26 +03:00
|
|
|
QVariantMap authorizationStateData;
|
2020-08-13 01:20:28 +03:00
|
|
|
TDLibWrapper::ConnectionState connectionState;
|
2020-08-13 00:51:09 +03:00
|
|
|
QVariantMap options;
|
2020-08-13 18:08:14 +03:00
|
|
|
QVariantMap userInformation;
|
2021-01-25 01:46:30 +03:00
|
|
|
QMap<UserPrivacySetting, UserPrivacySettingRule> userPrivacySettingRules;
|
2020-08-20 01:24:24 +03:00
|
|
|
QVariantMap allUsers;
|
2020-11-04 00:21:01 +03:00
|
|
|
QVariantMap allUserNames;
|
2020-08-16 18:38:51 +03:00
|
|
|
QVariantMap chats;
|
2020-11-27 21:42:39 +03:00
|
|
|
QMap<qlonglong, QVariantMap> secretChats;
|
2020-08-17 00:31:20 +03:00
|
|
|
QVariantMap unreadMessageInformation;
|
|
|
|
QVariantMap unreadChatInformation;
|
2020-10-04 04:27:49 +03:00
|
|
|
QHash<qlonglong,Group*> basicGroups;
|
|
|
|
QHash<qlonglong,Group*> superGroups;
|
2020-10-18 19:57:01 +03:00
|
|
|
EmojiSearchWorker emojiSearchWorker;
|
2023-11-18 16:45:22 +03:00
|
|
|
QStringList activeEmojiReactions;
|
2020-10-18 19:57:01 +03:00
|
|
|
|
2023-11-18 16:45:22 +03:00
|
|
|
int versionNumber;
|
2020-11-05 02:02:27 +03:00
|
|
|
QString activeChatSearchName;
|
2020-11-10 01:22:24 +03:00
|
|
|
bool joinChatRequested;
|
2021-01-11 21:05:55 +03:00
|
|
|
bool isLoggingOut;
|
2020-11-05 02:02:27 +03:00
|
|
|
|
2020-08-10 15:17:29 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TDLIBWRAPPER_H
|