From deb5e435e525ed733aa2f640d1a2cd5adcbb506c Mon Sep 17 00:00:00 2001 From: hypnosis-i2p Date: Fri, 28 Jul 2017 09:21:25 +0800 Subject: [PATCH 1/4] fixed i2pd qt gui a bit --- qt/i2pd_qt/ClientTunnelPane.h | 1 + qt/i2pd_qt/ServerTunnelPane.h | 1 + qt/i2pd_qt/TunnelConfig.h | 3 ++- qt/i2pd_qt/TunnelPane.h | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/qt/i2pd_qt/ClientTunnelPane.h b/qt/i2pd_qt/ClientTunnelPane.h index 16416cd8..7052211a 100644 --- a/qt/i2pd_qt/ClientTunnelPane.h +++ b/qt/i2pd_qt/ClientTunnelPane.h @@ -91,6 +91,7 @@ protected: ctc->setdestinationPort(dportInt); ctc->setsigType(readSigTypeComboboxUI(sigTypeComboBox)); + return true; } }; diff --git a/qt/i2pd_qt/ServerTunnelPane.h b/qt/i2pd_qt/ServerTunnelPane.h index a6994841..4069e339 100644 --- a/qt/i2pd_qt/ServerTunnelPane.h +++ b/qt/i2pd_qt/ServerTunnelPane.h @@ -155,6 +155,7 @@ protected: stc->setisUniqueLocal(isUniqueLocalCheckBox->isChecked()); stc->setsigType(readSigTypeComboboxUI(sigTypeComboBox)); + return true; } }; diff --git a/qt/i2pd_qt/TunnelConfig.h b/qt/i2pd_qt/TunnelConfig.h index b91a318c..087ec30b 100644 --- a/qt/i2pd_qt/TunnelConfig.h +++ b/qt/i2pd_qt/TunnelConfig.h @@ -196,7 +196,8 @@ public: gzip(gzip_), sigType(sigType_), maxConns(maxConns_), - address(address_) {} + address(address_), + isUniqueLocal(isUniqueLocal_) {} std::string& gethost(){return host;} int getport(){return port;} std::string& getkeys(){return keys;} diff --git a/qt/i2pd_qt/TunnelPane.h b/qt/i2pd_qt/TunnelPane.h index d0a3d6a8..b7744555 100644 --- a/qt/i2pd_qt/TunnelPane.h +++ b/qt/i2pd_qt/TunnelPane.h @@ -88,6 +88,7 @@ protected: i2cpParams.setOutbound_length(outbound_lengthLineEdit->text()); i2cpParams.setOutbound_quantity(outbound_quantityLineEdit->text()); i2cpParams.setCrypto_tagsToSend(crypto_tagsToSendLineEdit->text()); + return true; } void setupTunnelPane( From a83be187f35b53e1baebd56734efe78cc0ce2bf4 Mon Sep 17 00:00:00 2001 From: hypnosis-i2p Date: Fri, 28 Jul 2017 10:43:20 +0800 Subject: [PATCH 2/4] ui fixes --- qt/i2pd_qt/mainwindow.cpp | 2 -- qt/i2pd_qt/mainwindow.ui | 50 ++++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/qt/i2pd_qt/mainwindow.cpp b/qt/i2pd_qt/mainwindow.cpp index 304a3758..8abffba7 100644 --- a/qt/i2pd_qt/mainwindow.cpp +++ b/qt/i2pd_qt/mainwindow.cpp @@ -48,8 +48,6 @@ MainWindow::MainWindow(QWidget *parent) : int w = 683; int h = 3060; ui->settingsContents->setFixedSize(w, h); - //ui->settingsContents->resize(w, h); - //ui->settingsContents->adjustSize(); /* QPalette pal(palette()); diff --git a/qt/i2pd_qt/mainwindow.ui b/qt/i2pd_qt/mainwindow.ui index ca07c036..0b3071e9 100644 --- a/qt/i2pd_qt/mainwindow.ui +++ b/qt/i2pd_qt/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 816 - 5000 + 516 @@ -37,8 +37,8 @@ 10 10 - 801 - 518 + 796 + 496 @@ -126,17 +126,17 @@ 0 - 516 + 496 16777215 - 516 + 496 - 1 + 4 @@ -144,8 +144,8 @@ 0 0 - 671 - 5000 + 686 + 496 @@ -192,8 +192,8 @@ 0 0 - 701 - 400 + 706 + 461 @@ -232,7 +232,7 @@ 0 0 679 - 400 + 3000 @@ -245,14 +245,13 @@ 10 - 11 + 10 679 - 2962 + 3000 - @@ -360,9 +359,6 @@ - - - @@ -2570,13 +2566,13 @@ Comma separated list of base64 identities: 0 - 370 + 400 16777215 - 370 + 400 @@ -2997,8 +2993,8 @@ Comma separated list of base64 identities: 0 0 - 681 - 460 + 706 + 461 @@ -3064,8 +3060,8 @@ Comma separated list of base64 identities: 0 0 - 663 - 395 + 699 + 425 @@ -3080,8 +3076,8 @@ Comma separated list of base64 identities: 0 0 - 681 - 451 + 686 + 496 @@ -3135,8 +3131,8 @@ Comma separated list of base64 identities: 0 0 - 671 - 480 + 686 + 496 From 3118d7bede949167cb06e6ea4859e0c616447066 Mon Sep 17 00:00:00 2001 From: hypnosis-i2p Date: Fri, 28 Jul 2017 11:59:45 +0800 Subject: [PATCH 3/4] restart button now has a handler --- qt/i2pd_qt/DaemonQT.cpp | 1 + qt/i2pd_qt/mainwindow.cpp | 15 +++++++++++++++ qt/i2pd_qt/mainwindow.h | 11 +++++++++++ 3 files changed, 27 insertions(+) diff --git a/qt/i2pd_qt/DaemonQT.cpp b/qt/i2pd_qt/DaemonQT.cpp index accd69b1..582ad0f3 100644 --- a/qt/i2pd_qt/DaemonQT.cpp +++ b/qt/i2pd_qt/DaemonQT.cpp @@ -161,6 +161,7 @@ namespace qt { i2p::qt::Controller daemonQtController(daemon); + w.setI2PController(&daemonQtController); qDebug("Starting the daemon..."); emit daemonQtController.startDaemon(); //daemon.start (); diff --git a/qt/i2pd_qt/mainwindow.cpp b/qt/i2pd_qt/mainwindow.cpp index 8abffba7..ff2061e9 100644 --- a/qt/i2pd_qt/mainwindow.cpp +++ b/qt/i2pd_qt/mainwindow.cpp @@ -17,6 +17,8 @@ #include +#include "DaemonQT.h" + std::string programOptionsWriterCurrentSection; MainWindow::MainWindow(QWidget *parent) : @@ -25,6 +27,7 @@ MainWindow::MainWindow(QWidget *parent) : ,quitting(false) #endif ,ui(new Ui::MainWindow) + ,i2pController(nullptr) ,configItems() ,datadir() ,confpath() @@ -75,6 +78,8 @@ MainWindow::MainWindow(QWidget *parent) : QObject::connect(ui->fastQuitPushButton, SIGNAL(released()), this, SLOT(handleQuitButton())); QObject::connect(ui->gracefulQuitPushButton, SIGNAL(released()), this, SLOT(handleGracefulQuitButton())); + QObject::connect(ui->doRestartI2PDPushButton, SIGNAL(released()), this, SLOT(handleDoRestartButton())); + # define OPTION(section,option,defaultValueGetter) ConfigOption(QString(section),QString(option)) initFileChooser( OPTION("","conf",[](){return "";}), ui->configFileLineEdit, ui->configFileBrowsePushButton); @@ -326,6 +331,12 @@ void MainWindow::handleGracefulQuitButton() { , this, SLOT(handleGracefulQuitTimerEvent())); } +void MainWindow::handleDoRestartButton() { + qDebug()<<"Do Restart pressed."; + emit i2pController->restartDaemon(); +} + + void MainWindow::handleGracefulQuitTimerEvent() { qDebug("Hiding the main window"); #ifndef ANDROID @@ -614,3 +625,7 @@ void MainWindow::addServerTunnelPushButtonReleased() { void MainWindow::addClientTunnelPushButtonReleased() { CreateDefaultClientTunnel(); } + +void MainWindow::setI2PController(i2p::qt::Controller* controller_) { + this->i2pController = controller_; +} diff --git a/qt/i2pd_qt/mainwindow.h b/qt/i2pd_qt/mainwindow.h index 03057f2e..77699f28 100644 --- a/qt/i2pd_qt/mainwindow.h +++ b/qt/i2pd_qt/mainwindow.h @@ -51,6 +51,8 @@ #include "TunnelsPageUpdateListener.h" +#include "DaemonQT.h" + template bool isType(boost::any& a) { return @@ -311,6 +313,10 @@ using namespace i2p::client; class TunnelPane; +using namespace i2p::qt; + +class Controller; + class MainWindow : public QMainWindow { Q_OBJECT @@ -318,6 +324,8 @@ public: explicit MainWindow(QWidget *parent=0); ~MainWindow(); + void setI2PController(i2p::qt::Controller* controller_); + //typedef std::function DefaultValueGetter; //#ifndef ANDROID @@ -327,6 +335,7 @@ public: private slots: void handleQuitButton(); void handleGracefulQuitButton(); + void handleDoRestartButton(); void handleGracefulQuitTimerEvent(); #ifndef ANDROID void setIcon(); @@ -351,6 +360,8 @@ private: Ui::MainWindow* ui; + i2p::qt::Controller* i2pController; + protected: #ifndef ANDROID void closeEvent(QCloseEvent *event); From 4776f11b6ae1c6cb4a04d42b39d22c900c1d3857 Mon Sep 17 00:00:00 2001 From: hypnosis-i2p Date: Fri, 28 Jul 2017 12:57:19 +0800 Subject: [PATCH 4/4] http proxy and socks - initialized comboboxes correctly --- qt/i2pd_qt/SignatureTypeComboboxFactory.h | 11 +++++++++-- qt/i2pd_qt/mainwindow.cpp | 2 ++ qt/i2pd_qt/mainwindow.h | 16 ++++++++-------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/qt/i2pd_qt/SignatureTypeComboboxFactory.h b/qt/i2pd_qt/SignatureTypeComboboxFactory.h index 4d2289e1..2380b67a 100644 --- a/qt/i2pd_qt/SignatureTypeComboboxFactory.h +++ b/qt/i2pd_qt/SignatureTypeComboboxFactory.h @@ -18,8 +18,11 @@ class SignatureTypeComboBoxFactory } public: - static QComboBox* createSignatureTypeComboBox(QWidget* parent, uint16_t selectedSigType) { - QComboBox* signatureTypeCombobox = new QComboBox(parent); + static const uint16_t getSigType(const QVariant& var) { + return (uint16_t)var.toInt(); + } + + static void fillComboBox(QComboBox* signatureTypeCombobox, uint16_t selectedSigType) { /* https://geti2p.net/spec/common-structures#certificate все коды перечислены @@ -78,7 +81,11 @@ public: addItem(signatureTypeCombobox, QString::number(selectedSigType), selectedSigType); //unknown sigtype signatureTypeCombobox->setCurrentIndex(index); } + } + static QComboBox* createSignatureTypeComboBox(QWidget* parent, uint16_t selectedSigType) { + QComboBox* signatureTypeCombobox = new QComboBox(parent); + fillComboBox(signatureTypeCombobox, selectedSigType); return signatureTypeCombobox; } }; diff --git a/qt/i2pd_qt/mainwindow.cpp b/qt/i2pd_qt/mainwindow.cpp index ff2061e9..9d312fa0 100644 --- a/qt/i2pd_qt/mainwindow.cpp +++ b/qt/i2pd_qt/mainwindow.cpp @@ -18,6 +18,7 @@ #include #include "DaemonQT.h" +#include "SignatureTypeComboboxFactory.h" std::string programOptionsWriterCurrentSection; @@ -123,6 +124,7 @@ MainWindow::MainWindow(QWidget *parent) : initIPAddressBox( OPTION("httpproxy","address",[]{return "";}), ui->httpProxyAddressLineEdit, tr("HTTP proxy -> IP address")); initTCPPortBox( OPTION("httpproxy","port",[]{return "4444";}), ui->httpProxyPortLineEdit, tr("HTTP proxy -> Port")); initFileChooser( OPTION("httpproxy","keys",[]{return "";}), ui->httpProxyKeyFileLineEdit, ui->httpProxyKeyFilePushButton); + initSignatureTypeCombobox(OPTION("httpproxy","signaturetype",[]{return "7";}), ui->comboBox_httpPorxySignatureType); initStringBox( OPTION("httpproxy","inbound.length",[]{return "3";}), ui->httpProxyInboundTunnelsLenLineEdit); initStringBox( OPTION("httpproxy","inbound.quantity",[]{return "5";}), ui->httpProxyInboundTunnQuantityLineEdit); diff --git a/qt/i2pd_qt/mainwindow.h b/qt/i2pd_qt/mainwindow.h index 77699f28..05cb7151 100644 --- a/qt/i2pd_qt/mainwindow.h +++ b/qt/i2pd_qt/mainwindow.h @@ -52,6 +52,7 @@ #include "TunnelsPageUpdateListener.h" #include "DaemonQT.h" +#include "SignatureTypeComboboxFactory.h" template bool isType(boost::any& a) { @@ -218,16 +219,15 @@ class SignatureTypeComboBoxItem : public ComboBoxItem { public: SignatureTypeComboBoxItem(ConfigOption option_, QComboBox* comboBox_) : ComboBoxItem(option_, comboBox_) {}; virtual ~SignatureTypeComboBoxItem(){} - virtual void loadFromConfigOption(){//TODO + virtual void loadFromConfigOption(){ MainWindowItem::loadFromConfigOption(); - comboBox->setCurrentText(QString::number(boost::any_cast(optionValue))); + while(comboBox->count()>0)comboBox->removeItem(0); + uint16_t selected = (uint16_t) boost::any_cast(optionValue); + SignatureTypeComboBoxFactory::fillComboBox(comboBox, selected); } - virtual void saveToStringStream(std::stringstream& out){//TODO - QString txt = comboBox->currentText(); - if(txt.isEmpty()) - optionValue=std::string(); - else - optionValue=(unsigned short)std::stoi(txt.toStdString()); + virtual void saveToStringStream(std::stringstream& out){ + uint16_t selected = SignatureTypeComboBoxFactory::getSigType(comboBox->currentData()); + optionValue=(unsigned short)selected; MainWindowItem::saveToStringStream(out); } virtual bool isValid() { return true; }