#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 QString getVersion();
Q_INVOKABLE TDLibWrapper::AuthorizationState getAuthorizationState();
Q_INVOKABLE TDLibWrapper::ConnectionState getConnectionState();
Q_INVOKABLE QVariantMap getUserInformation();
// Direct TDLib functions
Q_INVOKABLE void sendRequest(const QVariantMap &requestObject);
Q_INVOKABLE void setAuthenticationPhoneNumber(const QString &phoneNumber);
Q_INVOKABLE void setAuthenticationCode(const QString &authenticationCode);
Q_INVOKABLE void getChats();
Q_INVOKABLE void downloadFile(const QString &fileId);
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);
void fileUpdated(const int fileId, const QVariantMap fileInformation);
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);
void handleUserUpdated(const QVariantMap &userInformation);
void handleFileUpdated(const QVariantMap &userInformation);
private:
void *tdLibClient;
TDLibReceiver *tdLibReceiver;
QString version;
TDLibWrapper::AuthorizationState authorizationState;
TDLibWrapper::ConnectionState connectionState;
QVariantMap options;
QVariantMap userInformation;
void setInitialParameters();
void setEncryptionKey();
void setLogVerbosityLevel();
};
#endif // TDLIBWRAPPER_H
|