#include
#include "tdlibreceiver.h"
class TDLibWrapper : public QObject
{
Q_OBJECT
public:
explicit TDLibWrapper(QObject *parent = nullptr);
~TDLibWrapper();
enum AuthorizationState {
Closed,
Closing,
LoggingOut,
AuthorizationReady,
WaitCode,
WaitEncryptionKey,
WaitOtherDeviceConfirmation,
WaitPassword,
WaitPhoneNumber,
WaitRegistration,
WaitTdlibParameters
};
Q_ENUM(AuthorizationState)
enum ConnectionState {
Connecting,
ConnectingToProxy,
ConnectionReady,
Updating,
WaitingForNetwork
};
Q_ENUM(ConnectionState)
Q_INVOKABLE void sendRequest(const QVariantMap &requestObject);
Q_INVOKABLE QString getVersion();
Q_INVOKABLE TDLibWrapper::AuthorizationState getAuthorizationState();
Q_INVOKABLE TDLibWrapper::ConnectionState getConnectionState();
Q_INVOKABLE void setAuthenticationPhoneNumber(const QString &phoneNumber);
Q_INVOKABLE void setAuthenticationCode(const QString &authenticationCode);
signals:
void versionDetected(const QString &version);
void authorizationStateChanged(const TDLibWrapper::AuthorizationState &authorizationState);
void optionUpdated(const QString &optionName, const QVariant &optionValue);
void connectionStateChanged(const TDLibWrapper::ConnectionState &connectionState);
public slots:
void handleVersionDetected(const QString &version);
void handleAuthorizationStateChanged(const QString &authorizationState);
void handleOptionUpdated(const QString &optionName, const QVariant &optionValue);
void handleConnectionStateChanged(const QString &connectionState);
private:
void *tdLibClient;
TDLibReceiver *tdLibReceiver;
QString version;
TDLibWrapper::AuthorizationState authorizationState;
TDLibWrapper::ConnectionState connectionState;
QVariantMap options;
void setInitialParameters();
void setEncryptionKey();
};
#endif // TDLIBWRAPPER_H
|