#include "mainwindow.h" #include "./ui_mainwindow.h" #include #include "networkthread.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { int metatype_id = qRegisterMetaType("httpflow"); current_session = new Session(); current_session->load("/tmp/littlesnitch.session"); thread = new QThread; NetworkThread* worker = new NetworkThread(); worker->moveToThread(thread); connect(thread, SIGNAL (started()), worker, SLOT (process())); //connect(worker, SIGNAL (error(QString)), this, SLOT (errorString(QString))); connect(worker, SIGNAL (httpMessage(http::Flow)), current_session, SLOT (saveRequest(http::Flow)), Qt::QueuedConnection); connect(worker, SIGNAL (httpMessage(http::Flow)), this, SLOT (updateHistory()), Qt::QueuedConnection); thread->start(); ui->setupUi(this); ui->historyHTTPTable->setShowGrid(true); ui->historyHTTPTable->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->historyHTTPTable->setColumnCount(4); ui->historyHTTPTable->setRowCount(1); /* ui->historyHTTPTable->setItem(0,0,new QTableWidgetItem(QString::number(data.index))); ui->historyHTTPTable->setItem(0,1,new QTableWidgetItem(QString::fromStdString(data.method))); ui->historyHTTPTable->setItem(0,2,new QTableWidgetItem(QString::fromStdString(data.url))); ui->historyHTTPTable->setItem(0,3,new QTableWidgetItem(QString::number(data.ttl))); ui->historyHTTPTable->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); */ } MainWindow::~MainWindow() { delete ui; } void MainWindow::updateHistory() { //ui->historyHTTPTable->setItem(0,0,new QTableWidgetItem(QString::fromStdString(flow.request.server_conn_id))); //ui->historyHTTPTable->setItem(0,1,new QTableWidgetItem(QString::fromStdString(flow.request.method))); //ui->historyHTTPTable->setItem(0,2,new QTableWidgetItem(QString::fromStdString(flow.request.host))); //ui->historyHTTPTable->setItem(0,3,new QTableWidgetItem(QString::number(data.ttl))); //ui->historyHTTPTable->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); } void MainWindow::on_searchEdit_textEdited(const QString &arg1) { emit updateHistory(); }