2020-10-14 03:37:03 +03:00
|
|
|
#include <QtCore>
|
|
|
|
#include <QtWebSockets/QWebSocket>
|
|
|
|
#include <ppltasks.h>
|
|
|
|
#include "network.h"
|
|
|
|
|
|
|
|
using namespace Concurrency;
|
|
|
|
|
|
|
|
typedef std::map<long, task_completion_event<QJsonObject>> MapResponse;
|
2020-10-15 02:32:58 +03:00
|
|
|
typedef std::map<long, QJsonObject> MapMethod;
|
2020-10-14 03:37:03 +03:00
|
|
|
|
|
|
|
class DevTools : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit DevTools(QObject* parent = nullptr);
|
|
|
|
~DevTools();
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
2020-10-15 23:23:41 +03:00
|
|
|
void statusChanged(const QString&);
|
2020-10-14 03:37:03 +03:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void stateChanged(QAbstractSocket::SocketState state);
|
|
|
|
void onTextMessageReceived(QString message);
|
|
|
|
|
|
|
|
public:
|
|
|
|
void startDevTools(QString path, bool headless = false, int port = 9222);
|
|
|
|
void closeDevTools();
|
2020-10-15 02:32:58 +03:00
|
|
|
bool checkMethod(long id);
|
2020-10-14 03:37:03 +03:00
|
|
|
int getSession();
|
2020-10-15 02:32:58 +03:00
|
|
|
bool SendRequest(QString method, QJsonObject params, QJsonObject& root);
|
2020-10-15 23:23:41 +03:00
|
|
|
long methodToReceive(QString method, QJsonObject params = {});
|
2020-10-14 03:37:03 +03:00
|
|
|
QString getStatus();
|
2020-10-18 16:16:06 +03:00
|
|
|
QString getUserAgent();
|
2020-10-14 03:37:03 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool isConnected();
|
|
|
|
bool startChrome(QString path, bool headless = false, int port = 9222);
|
2020-10-18 16:16:06 +03:00
|
|
|
bool GetJsonfromHTTP(QJsonDocument& doc, QString object, int port = 9222);
|
2020-10-14 03:37:03 +03:00
|
|
|
long idIncrement();
|
2020-10-15 02:32:58 +03:00
|
|
|
long idmIncrement();
|
2020-10-15 23:23:41 +03:00
|
|
|
bool compareJson(QJsonValue storedparams, QJsonValue params);
|
2020-10-14 03:37:03 +03:00
|
|
|
int session;
|
|
|
|
QWebSocket webSocket;
|
|
|
|
std::mutex mutex;
|
|
|
|
MapResponse mapqueue;
|
2020-10-15 02:32:58 +03:00
|
|
|
MapMethod mapmethod;
|
2020-10-14 03:37:03 +03:00
|
|
|
long idcounter;
|
2020-10-15 02:32:58 +03:00
|
|
|
long idmethod;
|
2020-10-14 03:37:03 +03:00
|
|
|
PROCESS_INFORMATION processInfo;
|
|
|
|
QString status;
|
2020-10-18 16:16:06 +03:00
|
|
|
QString useragent;
|
2020-10-14 03:37:03 +03:00
|
|
|
};
|