2020-10-14 03:37:03 +03:00
|
|
|
#include <fstream>
|
|
|
|
#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:
|
|
|
|
void statusChanged(const QString &);
|
|
|
|
|
|
|
|
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);
|
|
|
|
long methodToReceive(QString method, QJsonObject params);
|
2020-10-14 03:37:03 +03:00
|
|
|
QString getStatus();
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool isConnected();
|
|
|
|
bool startChrome(QString path, bool headless = false, int port = 9222);
|
|
|
|
bool GetwebSocketDebuggerUrl(QString& url, int port = 9222);
|
|
|
|
long idIncrement();
|
2020-10-15 02:32:58 +03:00
|
|
|
long idmIncrement();
|
|
|
|
bool compareJson(QJsonObject storedparams, QJsonObject 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
|
|
|
bool pagenavigated;
|
|
|
|
bool translateready;
|
|
|
|
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;
|
|
|
|
};
|