summaryrefslogtreecommitdiffstats
path: root/src/scanwidget.h
blob: decb7cb5cbbd8893ce8f46b5ef23e7dc9a18566b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/***************************************************************************
 *                                                                         *
 *   Copyright (C) 2005, 2006 by Kevin Gilbert                             *
 *   [email protected]                                                *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 *                                                                         *
 ***************************************************************************/

#ifndef _SCANWIDGET_H_
#define _SCANWIDGET_H_

#ifdef HAVE_CONFIG_H
#	include <config.h>
#endif

#include <qframe.h>
#include "global.h"

//	forward class definitions
//	=========================

class CommonWidget;
class CompoundWidget;
class HTMLWidget;
class KConfig;
class KProcess;
class KTabWidget;
class LoggingOptions;
class OutputWidget;
class PAndSOptions;
class QFile;
class QLineEdit;
class QPushButton;
class QStringList;
class ScanMonitor;
class SimpleOptions;
class TimingWidget;

//	ScanWidget class definition
//	===========================

class ScanWidget : public QFrame
{	Q_OBJECT

	public:
		ScanWidget( const QString& scanName,
					const bool     useTargetHost,
					QWidget*       parent = NULL,
					const char*    name = NULL );
		virtual ~ScanWidget( );

		enum State
		{	dormant,
			finished,
			running
		};

		void    fileSave( );
		void    fileSaveAs( );
		void    ignoreTabChanges( const bool b ) { m_ignoreTabChanges = b; }
		bool    isDirty( ) const { return m_dirty; }
		void    profileAskAndSave( );
		void    profileCopy( );
		void    profileDelete( );
		void    profileLoad( );
		QString profileName( ) const { return m_profileName; }
		void    profileRename( );
		void    profileSave( );
		void    profileSaveAs( );
		void    readSettings( );
		void    renameScan( const QString& newScanName );
		void    saveSettings( );
		QString scanName( ) const { return m_scanName; }
		void    setProfileName( const QString& profileName );
		State   state( ) const { return m_state; }
		void    state( const State s ) { m_state = s; }
		void    updateStatusBarText( );
		bool    useTargetHost( ) const { return m_useTargetHost; }
		void    useTargetHost( const bool b );
		void    wrapText( const bool wrap );

	signals:
		void displayHelp( const QString& );
		void errorLoadingLocalManPage( const QString& );
		void optionsDirty( );
		void outputAvailable( const bool, const bool );
		void scanRename( const QString& );
		void scanStarted( );
		void scanStopped( ScanWidget* );
		void setManPageActionStuff( const bool );
		void statusBarText( const QString& );

	private slots:
		void slotClearOutput( );
		void slotDisplayDocBook( const QString& anchor );
		void slotDisplayUnknown( );
		void slotFinaliseInitialisation( );
		void slotHideOptions( );
		void slotOptionsDirty( const bool dirty = true );
		void slotProcessExited( );
		void slotReceivedStderr( KProcess* process, char* buffer, int buflen );
		void slotReceivedStdout( KProcess* process, char* buffer, int buflen );
		void slotStartClicked( );
		void slotStopClicked( );
		void slotTabChanged( QWidget* toWidget );
		void slotTargetChanged( const QString& target );

	private:
		QStringList buildNmapOptionsList( );
		void        closePipe( QFile*& pipe, int& pipeFD );
		void        createLayout( );
		bool        createPipe( const QString type, const QString& tempDir, QFile*& pipe, int& pipeFD );
		bool        createPipes( );
		void        customEvent( QCustomEvent* event );
		bool        getOptions( );
		void        getPortRanges( QStringList* portRanges );
		void        initialiseManPage( );
		void        profileRead( );
		void        saveProfileName( );
		void        setInitialValues( );

		QPushButton*    m_clearOutputButton;
		int             m_commonIndex;
		CommonWidget*   m_commonWidget;
		int             m_compoundIndex;
		CompoundWidget* m_compoundWidget;
		int             m_currentTab;
		bool            m_dirty;
		bool            m_hideOptions;
		QPushButton*    m_hideOptionsButton;
		int             m_htmlIndex;
		bool            m_ignoreTabChanges;
		int             m_loggingIndex;
		LoggingOptions* m_loggingWidget;
		KProcess*       m_nmapProcess;
		OutputWidget*   m_outputWidget;
		int             m_pAndSIndex;
		PAndSOptions*   m_pAndSWidget;
		QFile*          m_pipeStderr;
		QFile*          m_pipeStdout;
		int             m_pipeStderrFD;
		int             m_pipeStdoutFD;
		bool            m_piping;
		QString         m_profileName;
		ScanMonitor*    m_scanMonitor;
		QString         m_scanName;
		int             m_simpleIndex;
		SimpleOptions*  m_simpleWidget;
		QPushButton*    m_startButton;
		State           m_state;
		QPushButton*    m_stopButton;
		KTabWidget*     m_tabWidget;
		int             m_timingIndex;
		TimingWidget*   m_timingWidget;
		bool            m_useTargetHost;
};

#endif	// _SCANWIDGET_H_