harbour-fernschreiber/src/tdlibwrapper.h

60 lines
1.5 KiB
C
Raw Normal View History

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
};
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-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-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-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;
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