ServerTunnelPane.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. #include "ServerTunnelPane.h"
  2. #include "ClientContext.h"
  3. #include "SignatureTypeComboboxFactory.h"
  4. ServerTunnelPane::ServerTunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener, ServerTunnelConfig* tunconf, QWidget* wrongInputPane_, QLabel* wrongInputLabel_, MainWindow* mainWindow):
  5. TunnelPane(tunnelsPageUpdateListener, tunconf, wrongInputPane_, wrongInputLabel_, mainWindow) {}
  6. void ServerTunnelPane::setGroupBoxTitle(const QString & title) {
  7. serverTunnelNameGroupBox->setTitle(title);
  8. }
  9. int ServerTunnelPane::appendServerTunnelForm(
  10. ServerTunnelConfig* tunnelConfig, QWidget *tunnelsFormGridLayoutWidget, int tunnelsRow, int height) {
  11. ServerTunnelPane& ui = *this;
  12. serverTunnelNameGroupBox = new QGroupBox(tunnelsFormGridLayoutWidget);
  13. serverTunnelNameGroupBox->setObjectName(QStringLiteral("serverTunnelNameGroupBox"));
  14. //tunnel
  15. gridLayoutWidget_2 = new QWidget(serverTunnelNameGroupBox);
  16. QComboBox *tunnelTypeComboBox = new QComboBox(gridLayoutWidget_2);
  17. tunnelTypeComboBox->setObjectName(QStringLiteral("tunnelTypeComboBox"));
  18. tunnelTypeComboBox->addItem("Server", i2p::client::I2P_TUNNELS_SECTION_TYPE_SERVER);
  19. tunnelTypeComboBox->addItem("HTTP", i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTP);
  20. tunnelTypeComboBox->addItem("IRC", i2p::client::I2P_TUNNELS_SECTION_TYPE_IRC);
  21. tunnelTypeComboBox->addItem("UDP Server", i2p::client::I2P_TUNNELS_SECTION_TYPE_UDPSERVER);
  22. int h=19*60;
  23. gridLayoutWidget_2->setGeometry(QRect(0, 0, 561, h));
  24. serverTunnelNameGroupBox->setGeometry(QRect(0, 0, 561, h));
  25. {
  26. const QString& type = tunnelConfig->getType();
  27. int index=0;
  28. if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_SERVER)tunnelTypeComboBox->setCurrentIndex(index);
  29. ++index;
  30. if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTP)tunnelTypeComboBox->setCurrentIndex(index);
  31. ++index;
  32. if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_IRC)tunnelTypeComboBox->setCurrentIndex(index);
  33. ++index;
  34. if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_UDPSERVER)tunnelTypeComboBox->setCurrentIndex(index);
  35. ++index;
  36. }
  37. setupTunnelPane(tunnelConfig,
  38. serverTunnelNameGroupBox,
  39. gridLayoutWidget_2, tunnelTypeComboBox,
  40. tunnelsFormGridLayoutWidget, tunnelsRow, height, h);
  41. //this->tunnelGroupBox->setGeometry(QRect(0, tunnelsFormGridLayoutWidget->height()+10, 561, 18*40+10));
  42. //host
  43. ui.horizontalLayout_2 = new QHBoxLayout();
  44. horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
  45. ui.hostLabel = new QLabel(gridLayoutWidget_2);
  46. hostLabel->setObjectName(QStringLiteral("hostLabel"));
  47. horizontalLayout_2->addWidget(hostLabel);
  48. ui.hostLineEdit = new QLineEdit(gridLayoutWidget_2);
  49. hostLineEdit->setObjectName(QStringLiteral("hostLineEdit"));
  50. hostLineEdit->setText(tunnelConfig->gethost().c_str());
  51. QObject::connect(hostLineEdit, SIGNAL(textChanged(const QString &)),
  52. this, SLOT(updated()));
  53. horizontalLayout_2->addWidget(hostLineEdit);
  54. ui.hostHorizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  55. horizontalLayout_2->addItem(hostHorizontalSpacer);
  56. tunnelGridLayout->addLayout(horizontalLayout_2);
  57. int gridIndex = 2;
  58. {
  59. int port = tunnelConfig->getport();
  60. QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
  61. horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
  62. ui.portLabel = new QLabel(gridLayoutWidget_2);
  63. portLabel->setObjectName(QStringLiteral("portLabel"));
  64. horizontalLayout_2->addWidget(portLabel);
  65. ui.portLineEdit = new QLineEdit(gridLayoutWidget_2);
  66. portLineEdit->setObjectName(QStringLiteral("portLineEdit"));
  67. portLineEdit->setText(QString::number(port));
  68. portLineEdit->setMaximumWidth(80);
  69. QObject::connect(portLineEdit, SIGNAL(textChanged(const QString &)),
  70. this, SLOT(updated()));
  71. horizontalLayout_2->addWidget(portLineEdit);
  72. QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  73. horizontalLayout_2->addItem(horizontalSpacer);
  74. tunnelGridLayout->addLayout(horizontalLayout_2);
  75. }
  76. {
  77. std::string keys = tunnelConfig->getkeys();
  78. QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
  79. horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
  80. ui.keysLabel = new QLabel(gridLayoutWidget_2);
  81. keysLabel->setObjectName(QStringLiteral("keysLabel"));
  82. horizontalLayout_2->addWidget(keysLabel);
  83. ui.keysLineEdit = new QLineEdit(gridLayoutWidget_2);
  84. keysLineEdit->setObjectName(QStringLiteral("keysLineEdit"));
  85. keysLineEdit->setText(keys.c_str());
  86. QObject::connect(keysLineEdit, SIGNAL(textChanged(const QString &)),
  87. this, SLOT(updated()));
  88. horizontalLayout_2->addWidget(keysLineEdit);
  89. QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  90. horizontalLayout_2->addItem(horizontalSpacer);
  91. tunnelGridLayout->addLayout(horizontalLayout_2);
  92. }
  93. {
  94. int inPort = tunnelConfig->getinPort();
  95. QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
  96. horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
  97. ui.inPortLabel = new QLabel(gridLayoutWidget_2);
  98. inPortLabel->setObjectName(QStringLiteral("inPortLabel"));
  99. horizontalLayout_2->addWidget(inPortLabel);
  100. ui.inPortLineEdit = new QLineEdit(gridLayoutWidget_2);
  101. inPortLineEdit->setObjectName(QStringLiteral("inPortLineEdit"));
  102. inPortLineEdit->setText(QString::number(inPort));
  103. inPortLineEdit->setMaximumWidth(80);
  104. QObject::connect(inPortLineEdit, SIGNAL(textChanged(const QString &)),
  105. this, SLOT(updated()));
  106. horizontalLayout_2->addWidget(inPortLineEdit);
  107. QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  108. horizontalLayout_2->addItem(horizontalSpacer);
  109. tunnelGridLayout->addLayout(horizontalLayout_2);
  110. }
  111. {
  112. std::string accessList = tunnelConfig->getaccessList();
  113. QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
  114. horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
  115. ui.accessListLabel = new QLabel(gridLayoutWidget_2);
  116. accessListLabel->setObjectName(QStringLiteral("accessListLabel"));
  117. horizontalLayout_2->addWidget(accessListLabel);
  118. ui.accessListLineEdit = new QLineEdit(gridLayoutWidget_2);
  119. accessListLineEdit->setObjectName(QStringLiteral("accessListLineEdit"));
  120. accessListLineEdit->setText(accessList.c_str());
  121. QObject::connect(accessListLineEdit, SIGNAL(textChanged(const QString &)),
  122. this, SLOT(updated()));
  123. horizontalLayout_2->addWidget(accessListLineEdit);
  124. QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  125. horizontalLayout_2->addItem(horizontalSpacer);
  126. tunnelGridLayout->addLayout(horizontalLayout_2);
  127. }
  128. {
  129. std::string hostOverride = tunnelConfig->gethostOverride();
  130. QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
  131. horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
  132. ui.hostOverrideLabel = new QLabel(gridLayoutWidget_2);
  133. hostOverrideLabel->setObjectName(QStringLiteral("hostOverrideLabel"));
  134. horizontalLayout_2->addWidget(hostOverrideLabel);
  135. ui.hostOverrideLineEdit = new QLineEdit(gridLayoutWidget_2);
  136. hostOverrideLineEdit->setObjectName(QStringLiteral("hostOverrideLineEdit"));
  137. hostOverrideLineEdit->setText(hostOverride.c_str());
  138. QObject::connect(hostOverrideLineEdit, SIGNAL(textChanged(const QString &)),
  139. this, SLOT(updated()));
  140. horizontalLayout_2->addWidget(hostOverrideLineEdit);
  141. QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  142. horizontalLayout_2->addItem(horizontalSpacer);
  143. tunnelGridLayout->addLayout(horizontalLayout_2);
  144. }
  145. {
  146. std::string webIRCPass = tunnelConfig->getwebircpass();
  147. QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
  148. horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
  149. ui.webIRCPassLabel = new QLabel(gridLayoutWidget_2);
  150. webIRCPassLabel->setObjectName(QStringLiteral("webIRCPassLabel"));
  151. horizontalLayout_2->addWidget(webIRCPassLabel);
  152. ui.webIRCPassLineEdit = new QLineEdit(gridLayoutWidget_2);
  153. webIRCPassLineEdit->setObjectName(QStringLiteral("webIRCPassLineEdit"));
  154. webIRCPassLineEdit->setText(webIRCPass.c_str());
  155. QObject::connect(webIRCPassLineEdit, SIGNAL(textChanged(const QString &)),
  156. this, SLOT(updated()));
  157. horizontalLayout_2->addWidget(webIRCPassLineEdit);
  158. QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  159. horizontalLayout_2->addItem(horizontalSpacer);
  160. tunnelGridLayout->addLayout(horizontalLayout_2);
  161. }
  162. {
  163. bool gzip = tunnelConfig->getgzip();
  164. QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
  165. horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
  166. ui.gzipCheckBox = new QCheckBox(gridLayoutWidget_2);
  167. gzipCheckBox->setObjectName(QStringLiteral("gzipCheckBox"));
  168. gzipCheckBox->setChecked(gzip);
  169. QObject::connect(gzipCheckBox, SIGNAL(stateChanged(int)),
  170. this, SLOT(updated()));
  171. horizontalLayout_2->addWidget(gzipCheckBox);
  172. QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  173. horizontalLayout_2->addItem(horizontalSpacer);
  174. tunnelGridLayout->addLayout(horizontalLayout_2);
  175. }
  176. {
  177. i2p::data::SigningKeyType sigType = tunnelConfig->getsigType();
  178. QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
  179. horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
  180. ui.sigTypeLabel = new QLabel(gridLayoutWidget_2);
  181. sigTypeLabel->setObjectName(QStringLiteral("sigTypeLabel"));
  182. horizontalLayout_2->addWidget(sigTypeLabel);
  183. ui.sigTypeComboBox = SignatureTypeComboBoxFactory::createSignatureTypeComboBox(gridLayoutWidget_2, sigType);
  184. sigTypeComboBox->setObjectName(QStringLiteral("sigTypeComboBox"));
  185. QObject::connect(sigTypeComboBox, SIGNAL(currentIndexChanged(int)),
  186. this, SLOT(updated()));
  187. horizontalLayout_2->addWidget(sigTypeComboBox);
  188. QPushButton * lockButton2 = new QPushButton(gridLayoutWidget_2);
  189. horizontalLayout_2->addWidget(lockButton2);
  190. widgetlocks.add(new widgetlock(sigTypeComboBox, lockButton2));
  191. QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  192. horizontalLayout_2->addItem(horizontalSpacer);
  193. tunnelGridLayout->addLayout(horizontalLayout_2);
  194. }
  195. {
  196. std::string address = tunnelConfig->getaddress();
  197. QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
  198. horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
  199. ui.addressLabel = new QLabel(gridLayoutWidget_2);
  200. addressLabel->setObjectName(QStringLiteral("addressLabel"));
  201. horizontalLayout_2->addWidget(addressLabel);
  202. ui.addressLineEdit = new QLineEdit(gridLayoutWidget_2);
  203. addressLineEdit->setObjectName(QStringLiteral("addressLineEdit"));
  204. addressLineEdit->setText(address.c_str());
  205. QObject::connect(addressLineEdit, SIGNAL(textChanged(const QString &)),
  206. this, SLOT(updated()));
  207. horizontalLayout_2->addWidget(addressLineEdit);
  208. QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  209. horizontalLayout_2->addItem(horizontalSpacer);
  210. tunnelGridLayout->addLayout(horizontalLayout_2);
  211. }
  212. {
  213. bool isUniqueLocal = tunnelConfig->getisUniqueLocal();
  214. QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
  215. horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
  216. ui.isUniqueLocalCheckBox = new QCheckBox(gridLayoutWidget_2);
  217. isUniqueLocalCheckBox->setObjectName(QStringLiteral("isUniqueLocalCheckBox"));
  218. isUniqueLocalCheckBox->setChecked(isUniqueLocal);
  219. QObject::connect(gzipCheckBox, SIGNAL(stateChanged(int)),
  220. this, SLOT(updated()));
  221. horizontalLayout_2->addWidget(isUniqueLocalCheckBox);
  222. QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  223. horizontalLayout_2->addItem(horizontalSpacer);
  224. tunnelGridLayout->addLayout(horizontalLayout_2);
  225. }
  226. {
  227. I2CPParameters& i2cpParameters = tunnelConfig->getI2cpParameters();
  228. appendControlsForI2CPParameters(i2cpParameters, gridIndex);
  229. }
  230. retranslateServerTunnelForm(ui);
  231. tunnelGridLayout->invalidate();
  232. return h;
  233. }
  234. void ServerTunnelPane::deleteServerTunnelForm() {
  235. TunnelPane::deleteTunnelForm();
  236. delete serverTunnelNameGroupBox;//->deleteLater();
  237. serverTunnelNameGroupBox=nullptr;
  238. //gridLayoutWidget_2->deleteLater();
  239. //gridLayoutWidget_2=nullptr;
  240. }
  241. ServerTunnelPane* ServerTunnelPane::asServerTunnelPane(){return this;}
  242. ClientTunnelPane* ServerTunnelPane::asClientTunnelPane(){return nullptr;}