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/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/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/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/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( diff --git a/qt/i2pd_qt/mainwindow.cpp b/qt/i2pd_qt/mainwindow.cpp index 304a3758..9d312fa0 100644 --- a/qt/i2pd_qt/mainwindow.cpp +++ b/qt/i2pd_qt/mainwindow.cpp @@ -17,6 +17,9 @@ #include +#include "DaemonQT.h" +#include "SignatureTypeComboboxFactory.h" + std::string programOptionsWriterCurrentSection; MainWindow::MainWindow(QWidget *parent) : @@ -25,6 +28,7 @@ MainWindow::MainWindow(QWidget *parent) : ,quitting(false) #endif ,ui(new Ui::MainWindow) + ,i2pController(nullptr) ,configItems() ,datadir() ,confpath() @@ -48,8 +52,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()); @@ -77,6 +79,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); @@ -120,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); @@ -328,6 +333,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 @@ -616,3 +627,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..05cb7151 100644 --- a/qt/i2pd_qt/mainwindow.h +++ b/qt/i2pd_qt/mainwindow.h @@ -51,6 +51,9 @@ #include "TunnelsPageUpdateListener.h" +#include "DaemonQT.h" +#include "SignatureTypeComboboxFactory.h" + template bool isType(boost::any& a) { return @@ -216,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; } @@ -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); 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