bigsnitch/proxyhandler.cpp

28 lines
801 B
C++
Raw Normal View History

#include "proxyhandler.h"
2021-03-19 16:40:33 +00:00
#include <QThread>
2021-01-09 10:17:50 +00:00
bool http::ProxyHandler::loadPlugin(QObject *proxy)
{
2021-01-09 10:17:50 +00:00
auto inst = qobject_cast<ProxyInterface*>(proxy);
if(!inst) {
return false;
}
2021-03-03 16:12:12 +00:00
qDebug("loading proxy");
2021-03-19 16:40:33 +00:00
auto thread = new QThread;
proxy->moveToThread(thread);
2021-03-20 16:04:13 +00:00
// TODO: get path from config or something
inst->path = "tcp://127.0.0.1:12345";
2021-03-19 16:40:33 +00:00
QObject::connect(thread, SIGNAL (started()), proxy, SLOT (process()));
2021-03-20 21:56:03 +00:00
QObject::connect(proxy, SIGNAL (error(QString)), this, SIGNAL (error(QString)), Qt::QueuedConnection);
QObject::connect(proxy, SIGNAL (message(http::Flow)), this, SIGNAL (message(http::Flow)), Qt::QueuedConnection);
2021-03-19 16:40:33 +00:00
thread->start();
2021-03-20 21:56:03 +00:00
auto name = inst->getName();
proxies.insert({name, {inst, thread}});
2021-01-09 10:17:50 +00:00
return true;
}