initial
This commit is contained in:
commit
ab9a0bd4e2
183 changed files with 20701 additions and 0 deletions
3
src/qt5gui/.gitignore
vendored
Normal file
3
src/qt5gui/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
.qmake.stash
|
||||
Makefile
|
||||
bredbandskollen
|
||||
89
src/qt5gui/bredbandskollen.pro
Normal file
89
src/qt5gui/bredbandskollen.pro
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
QT += webenginewidgets
|
||||
TARGET = bredbandskollen
|
||||
TEMPLATE = app
|
||||
QMAKE_CXXFLAGS += -std=c++11 -DBBK_WEBVIEW
|
||||
|
||||
# To enable logging:
|
||||
QMAKE_CXXFLAGS += -DTASKRUNNER_LOGERR
|
||||
QMAKE_CXXFLAGS += -DTASKRUNNER_LOGWARN
|
||||
QMAKE_CXXFLAGS += -DTASKRUNNER_LOGINFO
|
||||
# QMAKE_CXXFLAGS += -DTASKRUNNER_LOGDBG
|
||||
|
||||
SOURCES += main.cpp \
|
||||
../cli/utils.cpp \
|
||||
../measurement/defs.cpp \
|
||||
../framework/logger.cpp \
|
||||
../framework/socket.cpp \
|
||||
../framework/engine.cpp \
|
||||
../framework/task.cpp \
|
||||
../framework/taskconfig.cpp \
|
||||
../framework/bridgetask.cpp \
|
||||
../framework/socketconnection.cpp \
|
||||
../framework/serversocket.cpp \
|
||||
../framework/socketreceiver.cpp \
|
||||
../framework/eventloop.cpp \
|
||||
../http/httptask.cpp \
|
||||
../http/httpconnection.cpp \
|
||||
../http/cookiemanager.cpp \
|
||||
../http/cookiefile.cpp \
|
||||
../http/websocketbridge.cpp \
|
||||
../http/sha1.cpp \
|
||||
../http/httpclienttask.cpp \
|
||||
../http/webservertask.cpp \
|
||||
../http/http_common.cpp \
|
||||
../http/httpclientconnection.cpp \
|
||||
../http/httpserverconnection.cpp \
|
||||
../http/singlerequest.cpp \
|
||||
../json11/json11.cpp \
|
||||
../measurement/measurementtask.cpp \
|
||||
../measurement/singlerequesttask.cpp \
|
||||
../measurement/infotask.cpp \
|
||||
../measurement/latencytask.cpp \
|
||||
../measurement/rpingtask.cpp \
|
||||
../measurement/pingsweeptask.cpp \
|
||||
../measurement/warmuptask.cpp \
|
||||
../measurement/tickettask.cpp \
|
||||
../measurement/progresstask.cpp \
|
||||
../measurement/downloadtask.cpp \
|
||||
../measurement/uploadtask.cpp \
|
||||
../measurement/measurementagent.cpp \
|
||||
../measurement/speedtest.cpp \
|
||||
../measurement/uploadinfotask.cpp
|
||||
|
||||
HEADERS += ../cli/utils.h \
|
||||
../measurement/defs.h \
|
||||
../framework/logger.h \
|
||||
../framework/socket.h \
|
||||
../framework/engine.h \
|
||||
../framework/task.h \
|
||||
../framework/taskconfig.h \
|
||||
../framework/bridgetask.h \
|
||||
../framework/socketconnection.h \
|
||||
../framework/serversocket.h \
|
||||
../framework/eventloop.h \
|
||||
../http/httptask.h \
|
||||
../http/httpconnection.h \
|
||||
../http/cookiemanager.h \
|
||||
../http/cookiefile.h \
|
||||
../http/websocketbridge.h \
|
||||
../http/sha1.h \
|
||||
../http/httpclienttask.h \
|
||||
../http/webservertask.h \
|
||||
../http/http_common.h \
|
||||
../http/httpclientconnection.h \
|
||||
../http/httpserverconnection.h \
|
||||
../json11/json11.hpp \
|
||||
../measurement/measurementtask.h \
|
||||
../measurement/singlerequesttask.h \
|
||||
../measurement/infotask.h \
|
||||
../measurement/latencytask.h \
|
||||
../measurement/pingsweeptask.h \
|
||||
../measurement/rpingtask.h \
|
||||
../measurement/warmuptask.h \
|
||||
../measurement/tickettask.h \
|
||||
../measurement/progresstask.h \
|
||||
../measurement/downloadtask.h \
|
||||
../measurement/uploadtask.h \
|
||||
../measurement/measurementagent.h \
|
||||
../measurement/speedtest.h \
|
||||
../measurement/uploadinfotask.h
|
||||
67
src/qt5gui/main.cpp
Normal file
67
src/qt5gui/main.cpp
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#include <QApplication>
|
||||
#include <QWebEngineView>
|
||||
|
||||
#include <fstream>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
#include "../measurement/measurementagent.h"
|
||||
#include "../cli/utils.h"
|
||||
#include "../http/websocketbridge.h"
|
||||
|
||||
namespace {
|
||||
|
||||
void runAgent(BridgeTask *bridge, const TaskConfig &cfg) {
|
||||
CookieFile cf(cfg.value("config_file"));
|
||||
HttpHost webserver(cfg.value("Measure.Webserver"), 80, "", 0, &cf);
|
||||
EventLoop loop;
|
||||
bridge->setAgent(new MeasurementAgent(cfg, webserver));
|
||||
loop.addTask(bridge);
|
||||
loop.runUntilComplete();
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
TaskConfig agent_cfg, config;
|
||||
if (!parseArgs(argc, argv, config, agent_cfg))
|
||||
return 1;
|
||||
agent_cfg.set("Measure.AutoSaveReport", "true");
|
||||
std::ofstream log_file;
|
||||
if (config.value("logfile") != "-") {
|
||||
log_file.open(config.value("logfile"));
|
||||
Logger::setLogFile(log_file);
|
||||
}
|
||||
|
||||
config.set("listen_pw", MeasurementAgent::createHashKey(12));
|
||||
config.set("listen", "0");
|
||||
config.set("listen_addr", "127.0.0.1");
|
||||
config.set("browser", "2");
|
||||
agent_cfg.set("config_file", config.value("config_file"));
|
||||
|
||||
WebsocketBridge *bridge = new WebsocketBridge(nullptr, config);
|
||||
std::thread agent_thread(runAgent, bridge, agent_cfg);
|
||||
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QApplication app(argc, argv);
|
||||
QWebEngineView view;
|
||||
view.resize(700, 950);
|
||||
view.show();
|
||||
|
||||
// Wait for a few seconds for the agent to start listening on a port
|
||||
for (unsigned int i = 0; bridge->url().empty() && i < 400; ++i)
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1+i/10));
|
||||
|
||||
int ret;
|
||||
if (bridge->url().empty()) {
|
||||
std::cerr << "cannot start measurement engine";
|
||||
ret = 1;
|
||||
} else {
|
||||
view.setUrl(QUrl(bridge->url().c_str()));
|
||||
ret = app.exec();
|
||||
}
|
||||
|
||||
bridge->die();
|
||||
agent_thread.join();
|
||||
return ret;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue