2020-08-10 15:17:29 +03:00
|
|
|
#ifndef TDLIBWRAPPER_H
|
|
|
|
#define TDLIBWRAPPER_H
|
|
|
|
|
2020-08-10 21:17:13 +03:00
|
|
|
#include <QCoreApplication>
|
2020-08-10 15:17:29 +03:00
|
|
|
#include <QObject>
|
|
|
|
#include <QDebug>
|
2020-08-13 00:51:09 +03:00
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QStandardPaths>
|
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-08-10 15:17:29 +03:00
|
|
|
|
|
|
|
class TDLibWrapper : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit TDLibWrapper(QObject *parent = nullptr);
|
|
|
|
~TDLibWrapper();
|
|
|
|
|
2020-08-13 00:51:09 +03:00
|
|
|
enum AuthorizationState {
|
|
|
|
Closed,
|
|
|
|
Closing,
|
|
|
|
LoggingOut,
|
|
|
|
Ready,
|
|
|
|
WaitCode,
|
|
|
|
WaitEncryptionKey,
|
|
|
|
WaitOtherDeviceConfirmation,
|
|
|
|
WaitPassword,
|
|
|
|
WaitPhoneNumber,
|
|
|
|
WaitRegistration,
|
|
|
|
WaitTdlibParameters
|
|
|
|
};
|
|
|
|
|
2020-08-13 01:20:28 +03:00
|
|
|
enum ConnectionState {
|
|
|
|
Connecting,
|
|
|
|
ConnectingToProxy,
|
|
|
|
IsReady,
|
|
|
|
Updating,
|
|
|
|
WaitingForNetwork
|
|
|
|
};
|
|
|
|
|
2020-08-13 00:51:09 +03:00
|
|
|
Q_INVOKABLE void sendRequest(const QVariantMap &requestObject);
|
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-08-13 01:20:28 +03:00
|
|
|
Q_INVOKABLE TDLibWrapper::ConnectionState getConnectionState();
|
2020-08-12 11:50:01 +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-13 00:51:09 +03:00
|
|
|
void authorizationStateChanged(const TDLibWrapper::AuthorizationState &authorizationState);
|
|
|
|
void optionUpdated(const QString &optionName, const QVariant &optionValue);
|
2020-08-13 01:20:28 +03:00
|
|
|
void connectionStateChanged(const TDLibWrapper::ConnectionState &connectionState);
|
2020-08-10 15:17:29 +03:00
|
|
|
|
|
|
|
public slots:
|
2020-08-12 11:50:01 +03:00
|
|
|
void handleVersionDetected(const QString &version);
|
|
|
|
void handleAuthorizationStateChanged(const QString &authorizationState);
|
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-10 15:17:29 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
void *tdLibClient;
|
2020-08-10 21:17:13 +03:00
|
|
|
TDLibReceiver *tdLibReceiver;
|
2020-08-12 11:50:01 +03:00
|
|
|
QString version;
|
2020-08-13 00:51:09 +03:00
|
|
|
TDLibWrapper::AuthorizationState authorizationState;
|
2020-08-13 01:20:28 +03:00
|
|
|
TDLibWrapper::ConnectionState connectionState;
|
2020-08-13 00:51:09 +03:00
|
|
|
QVariantMap options;
|
|
|
|
|
|
|
|
void setInitialParameters();
|
|
|
|
void setEncryptionKey();
|
2020-08-12 11:50:01 +03:00
|
|
|
|
2020-08-10 15:17:29 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TDLIBWRAPPER_H
|