TunnelPane.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #ifndef TUNNELPANE_H
  2. #define TUNNELPANE_H
  3. #include "QObject"
  4. #include "QWidget"
  5. #include "QComboBox"
  6. #include "QGridLayout"
  7. #include "QLabel"
  8. #include "QPushButton"
  9. #include "QApplication"
  10. #include "QLineEdit"
  11. #include "QGroupBox"
  12. #include "QVBoxLayout"
  13. #include "TunnelConfig.h"
  14. #include <widgetlock.h>
  15. #include <widgetlockregistry.h>
  16. class ServerTunnelPane;
  17. class ClientTunnelPane;
  18. class TunnelConfig;
  19. class I2CPParameters;
  20. class MainWindow;
  21. class TunnelPane : public QObject {
  22. Q_OBJECT
  23. public:
  24. TunnelPane(TunnelsPageUpdateListener* tunnelsPageUpdateListener_, TunnelConfig* tunconf, QWidget* wrongInputPane_, QLabel* wrongInputLabel_, MainWindow* mainWindow_);
  25. virtual ~TunnelPane(){}
  26. void deleteTunnelForm();
  27. void hideWrongInputLabel() const;
  28. void highlightWrongInput(QString warningText, QWidget* controlWithWrongInput);
  29. virtual ServerTunnelPane* asServerTunnelPane()=0;
  30. virtual ClientTunnelPane* asClientTunnelPane()=0;
  31. protected:
  32. MainWindow* mainWindow;
  33. QWidget * wrongInputPane;
  34. QLabel* wrongInputLabel;
  35. TunnelConfig* tunnelConfig;
  36. widgetlockregistry widgetlocks;
  37. TunnelsPageUpdateListener* tunnelsPageUpdateListener;
  38. QVBoxLayout *tunnelGridLayout;
  39. QGroupBox *tunnelGroupBox;
  40. QWidget* gridLayoutWidget_2;
  41. //header
  42. QLabel *nameLabel;
  43. QLineEdit *nameLineEdit;
  44. public:
  45. QLineEdit * getNameLineEdit() { return nameLineEdit; }
  46. public slots:
  47. void updated();
  48. void deleteButtonReleased();
  49. protected:
  50. QSpacerItem *headerHorizontalSpacer;
  51. QPushButton *deletePushButton;
  52. //type
  53. QComboBox *tunnelTypeComboBox;
  54. QLabel *typeLabel;
  55. //i2cp
  56. QLabel * inbound_lengthLabel;
  57. QLineEdit * inbound_lengthLineEdit;
  58. QLabel * outbound_lengthLabel;
  59. QLineEdit * outbound_lengthLineEdit;
  60. QLabel * inbound_quantityLabel;
  61. QLineEdit * inbound_quantityLineEdit;
  62. QLabel * outbound_quantityLabel;
  63. QLineEdit * outbound_quantityLineEdit;
  64. QLabel * crypto_tagsToSendLabel;
  65. QLineEdit * crypto_tagsToSendLineEdit;
  66. QString readTunnelTypeComboboxData();
  67. //should be created by factory
  68. i2p::data::SigningKeyType readSigTypeComboboxUI(QComboBox* sigTypeComboBox);
  69. public:
  70. //returns false when invalid data at UI
  71. virtual bool applyDataFromUIToTunnelConfig() {
  72. tunnelConfig->setName(nameLineEdit->text().toStdString());
  73. tunnelConfig->setType(readTunnelTypeComboboxData());
  74. I2CPParameters& i2cpParams=tunnelConfig->getI2cpParameters();
  75. i2cpParams.setInbound_length(inbound_lengthLineEdit->text());
  76. i2cpParams.setInbound_quantity(inbound_quantityLineEdit->text());
  77. i2cpParams.setOutbound_length(outbound_lengthLineEdit->text());
  78. i2cpParams.setOutbound_quantity(outbound_quantityLineEdit->text());
  79. i2cpParams.setCrypto_tagsToSend(crypto_tagsToSendLineEdit->text());
  80. return true;
  81. }
  82. protected:
  83. void setupTunnelPane(
  84. TunnelConfig* tunnelConfig,
  85. QGroupBox *tunnelGroupBox,
  86. QWidget* gridLayoutWidget_2, QComboBox * tunnelTypeComboBox,
  87. QWidget *tunnelsFormGridLayoutWidget, int tunnelsRow, int height, int h);
  88. void appendControlsForI2CPParameters(I2CPParameters& i2cpParameters, int& gridIndex);
  89. public:
  90. int height() {
  91. return gridLayoutWidget_2?gridLayoutWidget_2->height():0;
  92. }
  93. protected slots:
  94. virtual void setGroupBoxTitle(const QString & title)=0;
  95. private:
  96. void retranslateTunnelForm(TunnelPane& ui) {
  97. ui.deletePushButton->setText(QApplication::translate("tunForm", "Delete Tunnel", 0));
  98. ui.nameLabel->setText(QApplication::translate("tunForm", "Tunnel name:", 0));
  99. }
  100. void retranslateI2CPParameters() {
  101. inbound_lengthLabel->setText(QApplication::translate("tunForm", "Number of hops of an inbound tunnel:", 0));;
  102. outbound_lengthLabel->setText(QApplication::translate("tunForm", "Number of hops of an outbound tunnel:", 0));;
  103. inbound_quantityLabel->setText(QApplication::translate("tunForm", "Number of inbound tunnels:", 0));;
  104. outbound_quantityLabel->setText(QApplication::translate("tunForm", "Number of outbound tunnels:", 0));;
  105. crypto_tagsToSendLabel->setText(QApplication::translate("tunForm", "Number of ElGamal/AES tags to send:", 0));;
  106. }
  107. };
  108. #endif // TUNNELPANE_H