Anoncoin  0.9.4
P2P Digital Currency
i2poptionswidget.cpp
Go to the documentation of this file.
1 // Copyright (c) 2013-2014 The Anoncoin Core developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 // Many builder specific things set in the config file, don't see a need for it here, still better to not forget to include it in your source files.
6 #if defined(HAVE_CONFIG_H)
8 #endif
9 
10 #include "i2poptionswidget.h"
11 #include "ui_i2poptionswidget.h"
12 
13 #include "optionsmodel.h"
14 #include "monitoreddatamapper.h"
15 #include "i2pshowaddresses.h"
16 #include "util.h"
17 #include "clientmodel.h"
18 
19 
21  QWidget(parent),
22  ui(new Ui::I2POptionsWidget),
23  clientModel(0)
24 {
25  ui->setupUi(this);
26 
27  QObject::connect(ui->pushButtonCurrentI2PAddress, SIGNAL(clicked()), this, SLOT(ShowCurrentI2PAddress()));
28  QObject::connect(ui->pushButtonGenerateI2PAddress, SIGNAL(clicked()), this, SLOT(GenerateNewI2PAddress()));
29 
30  QObject::connect(ui->checkBoxAllowZeroHop , SIGNAL(stateChanged(int)) , this, SIGNAL(settingsChanged()));
31  QObject::connect(ui->checkBoxInboundAllowZeroHop , SIGNAL(stateChanged(int)) , this, SIGNAL(settingsChanged()));
32  QObject::connect(ui->checkBoxUseI2POnly , SIGNAL(stateChanged(int)) , this, SIGNAL(settingsChanged()));
33  QObject::connect(ui->lineEditSAMHost , SIGNAL(textChanged(QString)), this, SIGNAL(settingsChanged()));
34  QObject::connect(ui->lineEditTunnelName , SIGNAL(textChanged(QString)), this, SIGNAL(settingsChanged()));
35  QObject::connect(ui->spinBoxInboundBackupQuality , SIGNAL(valueChanged(int)) , this, SIGNAL(settingsChanged()));
36  QObject::connect(ui->spinBoxInboundIPRestriction , SIGNAL(valueChanged(int)) , this, SIGNAL(settingsChanged()));
37  QObject::connect(ui->spinBoxInboundLength , SIGNAL(valueChanged(int)) , this, SIGNAL(settingsChanged()));
38  QObject::connect(ui->spinBoxInboundLengthVariance , SIGNAL(valueChanged(int)) , this, SIGNAL(settingsChanged()));
39  QObject::connect(ui->spinBoxInboundQuantity , SIGNAL(valueChanged(int)) , this, SIGNAL(settingsChanged()));
40  QObject::connect(ui->spinBoxOutboundBackupQuantity, SIGNAL(valueChanged(int)) , this, SIGNAL(settingsChanged()));
41  QObject::connect(ui->spinBoxOutboundIPRestriction , SIGNAL(valueChanged(int)) , this, SIGNAL(settingsChanged()));
42  QObject::connect(ui->spinBoxOutboundLength , SIGNAL(valueChanged(int)) , this, SIGNAL(settingsChanged()));
43  QObject::connect(ui->spinBoxOutboundLengthVariance, SIGNAL(valueChanged(int)) , this, SIGNAL(settingsChanged()));
44  QObject::connect(ui->spinBoxOutboundPriority , SIGNAL(valueChanged(int)) , this, SIGNAL(settingsChanged()));
45  QObject::connect(ui->spinBoxOutboundQuantity , SIGNAL(valueChanged(int)) , this, SIGNAL(settingsChanged()));
46  QObject::connect(ui->spinBoxSAMPort , SIGNAL(valueChanged(int)) , this, SIGNAL(settingsChanged()));
47 }
48 
50 {
51  delete ui;
52 }
53 
55 {
56  mapper.addMapping(ui->checkBoxUseI2POnly , OptionsModel::eI2PUseI2POnly);
57  mapper.addMapping(ui->lineEditSAMHost , OptionsModel::eI2PSAMHost);
58  mapper.addMapping(ui->spinBoxSAMPort , OptionsModel::eI2PSAMPort);
59  mapper.addMapping(ui->lineEditTunnelName , OptionsModel::eI2PSessionName);
60  mapper.addMapping(ui->spinBoxInboundQuantity , OptionsModel::I2PInboundQuantity);
61  mapper.addMapping(ui->spinBoxInboundLength , OptionsModel::I2PInboundLength);
62  mapper.addMapping(ui->spinBoxInboundLengthVariance , OptionsModel::I2PInboundLengthVariance);
63  mapper.addMapping(ui->spinBoxInboundBackupQuality , OptionsModel::I2PInboundBackupQuantity);
64  mapper.addMapping(ui->checkBoxInboundAllowZeroHop , OptionsModel::I2PInboundAllowZeroHop);
65  mapper.addMapping(ui->spinBoxInboundIPRestriction , OptionsModel::I2PInboundIPRestriction);
66  mapper.addMapping(ui->spinBoxOutboundQuantity , OptionsModel::I2POutboundQuantity);
67  mapper.addMapping(ui->spinBoxOutboundLength , OptionsModel::I2POutboundLength);
68  mapper.addMapping(ui->spinBoxOutboundLengthVariance, OptionsModel::I2POutboundLengthVariance);
69  mapper.addMapping(ui->spinBoxOutboundBackupQuantity, OptionsModel::I2POutboundBackupQuantity);
70  mapper.addMapping(ui->checkBoxAllowZeroHop , OptionsModel::I2POutboundAllowZeroHop);
71  mapper.addMapping(ui->spinBoxOutboundIPRestriction , OptionsModel::I2POutboundIPRestriction);
72  mapper.addMapping(ui->spinBoxOutboundPriority , OptionsModel::I2POutboundPriority);
73 }
74 
76 {
77  clientModel = model;
78 }
79 
81 {
82  if (clientModel)
83  {
84  const QString pub = clientModel->getPublicI2PKey();
85  const QString priv = clientModel->getPrivateI2PKey();
86  const QString b32 = clientModel->getB32Address(pub);
87  const QString configFile = QString::fromStdString(GetConfigFile().string());
88 
89  ShowI2PAddresses i2pCurrDialog("Your current I2P-address", pub, priv, b32, configFile, this);
90  i2pCurrDialog.exec();
91  }
92 }
93 
95 {
96  if (clientModel)
97  {
98  QString pub, priv;
99  clientModel->generateI2PDestination(pub, priv);
100  const QString b32 = clientModel->getB32Address(pub);
101  const QString configFile = QString::fromStdString(GetConfigFile().string());
102 
103  ShowI2PAddresses i2pCurrDialog("Generated I2P address", pub, priv, b32, configFile, this);
104  i2pCurrDialog.exec();
105  }
106 }
107 
108 
Ui::I2POptionsWidget * ui
I2POptionsWidget(QWidget *parent=0)
QLineEdit * lineEditTunnelName
QSpinBox * spinBoxInboundIPRestriction
QCheckBox * checkBoxUseI2POnly
QSpinBox * spinBoxOutboundPriority
QCheckBox * checkBoxInboundAllowZeroHop
QPushButton * pushButtonCurrentI2PAddress
QSpinBox * spinBoxInboundLengthVariance
void setModel(ClientModel *model)
QSpinBox * spinBoxInboundQuantity
QSpinBox * spinBoxOutboundQuantity
QSpinBox * spinBoxOutboundLength
QSpinBox * spinBoxInboundBackupQuality
Model for Anoncoin network client.
Definition: clientmodel.h:45
QPushButton * pushButtonGenerateI2PAddress
void addMapping(QWidget *widget, int section)
QCheckBox * checkBoxAllowZeroHop
Data to Widget mapper that watches for edits and notifies listeners when a field is edited...
QSpinBox * spinBoxOutboundIPRestriction
void setupUi(QWidget *I2POptionsWidget)
void setMapper(MonitoredDataMapper &mapper)
ClientModel * clientModel
QSpinBox * spinBoxOutboundLengthVariance
QSpinBox * spinBoxOutboundBackupQuantity
boost::filesystem::path GetConfigFile()
Definition: util.cpp:1007