KNMap – nmap graphical interface
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

commonwidget.h 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /***************************************************************************
  2. * *
  3. * Copyright (C) 2005, 2006 by Kevin Gilbert *
  4. * kev.gilbert@cdu.edu.au *
  5. * *
  6. * This program is free software; you can redistribute it and/or modify *
  7. * it under the terms of the GNU General Public License as published by *
  8. * the Free Software Foundation; either version 2 of the License, or *
  9. * (at your option) any later version. *
  10. * *
  11. * This program is distributed in the hope that it will be useful, *
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  14. * GNU General Public License for more details. *
  15. * *
  16. * You should have received a copy of the GNU General Public License *
  17. * along with this program; if not, write to the *
  18. * Free Software Foundation, Inc., *
  19. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  20. * *
  21. ***************************************************************************/
  22. #ifndef _COMMONWIDGET_H_
  23. #define _COMMONWIDGET_H_
  24. #ifdef HAVE_CONFIG_H
  25. # include <config.h>
  26. #endif
  27. #include <qwidget.h>
  28. #include "global.h"
  29. // forward class definitions
  30. // =========================
  31. class KConfig;
  32. class QCheckBox;
  33. class QComboBox;
  34. class QLineEdit;
  35. class QListBox;
  36. class QListBoxItem;
  37. class QPushButton;
  38. class QRadioButton;
  39. class QStringList;
  40. // CommonWidget class definition
  41. // =============================
  42. class CommonWidget : public QWidget
  43. { Q_OBJECT
  44. public:
  45. CommonWidget( QWidget* parent, const char* name = NULL );
  46. virtual ~CommonWidget( );
  47. void finaliseInitialisation( );
  48. bool getOptions( );
  49. void readProfile( KConfig* config );
  50. void saveProfile( KConfig* config );
  51. void setInitialValues( );
  52. QString getHostName( ) const;
  53. int hostCurrentItem( ) const { return m_hostCurrentItem; }
  54. QString host( ) const { return m_host; }
  55. int portRangeCurrentItem( ) const { return m_portRangeCurrentItem; }
  56. QStringList* portRanges( ) const { return m_portRanges; }
  57. bool portRangesState( ) const { return m_portRangesState; }
  58. bool resovleAlwaysState( ) const { return m_resovleAlwaysState; }
  59. bool resovleDefaultState( ) const { return m_resovleDefaultState; }
  60. bool resovleNeverState( ) const { return m_resovleNeverState; }
  61. signals:
  62. void disableFastScan( );
  63. void displayDocBook( const QString& );
  64. void displayHelp( const QString& );
  65. void displayUnknown( );
  66. void optionsDirty( );
  67. void targetChanged( const QString& );
  68. public slots:
  69. void slotDisablePortRanges( );
  70. private slots:
  71. void slotHostActivated( int index );
  72. void slotHostButtonClicked( );
  73. void slotHostTextChanged( const QString& text );
  74. void slotPortRangeActivated( int index );
  75. void slotPortRangeAddClicked( );
  76. void slotPortRangeDeleteClicked( );
  77. void slotPortRangeButtonClicked( );
  78. void slotPortRangeDoubleClicked( QListBoxItem* item );
  79. void slotPortRangeHighlighted( );
  80. void slotPortRangesClicked( );
  81. void slotPortRangeTextChanged( const QString& text );
  82. void slotWhatsThisClicked( );
  83. private:
  84. bool buildPortRangesTables( const boolPtr tcpPorts, const boolPtr udpPorts );
  85. void createLayout( );
  86. void enablePortRangeWidgets( );
  87. void getHosts( QStringList* hosts );
  88. void getPortRanges( QStringList* portRanges );
  89. bool portRangesOverlapping( const ushort portFirst, const ushort portLast );
  90. bool validatePortRange( QString& text );
  91. bool validatePortRangeText( QString& text, uint& portFirst, uint& portLast );
  92. // protocol indices
  93. // ================
  94. enum Protocol
  95. { BothProtocol,
  96. TCPProtocol,
  97. UDPProtocol
  98. };
  99. QString m_host;
  100. QPushButton* m_hostButton;
  101. QComboBox* m_hostComboBox;
  102. int m_hostCurrentItem;
  103. QStringList* m_hosts;
  104. QPushButton* m_portRangeAddButton;
  105. QPushButton* m_portRangeButton;
  106. QComboBox* m_portRangeComboBox;
  107. int m_portRangeCurrentItem;
  108. QPushButton* m_portRangeDeleteButton;
  109. bool m_portRangeIgnoreChange;
  110. QLineEdit* m_portRangeLineEdit;
  111. QListBox* m_portRangeListBox;
  112. QStringList* m_portRanges;
  113. QCheckBox* m_portRangesCheckBox;
  114. bool m_portRangesState;
  115. QRadioButton* m_resovleAlwaysRadio;
  116. bool m_resovleAlwaysState;
  117. QRadioButton* m_resovleDefaultRadio;
  118. bool m_resovleDefaultState;
  119. QRadioButton* m_resovleNeverRadio;
  120. bool m_resovleNeverState;
  121. };
  122. #endif // _COMMONWIDGET_H_