author | mickeyl <mickeyl> | 2003-04-09 21:40:31 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-04-09 21:40:31 (UTC) |
commit | cf029a4007ea344c530d8a71cd0b012393ebd7ba (patch) (unidiff) | |
tree | e9f584885299548b9316a6da05ad31845487e6d9 /noncore/net/wellenreiter/gui | |
parent | b055856776807f0a459a86b1e1f62902d2d3a9c3 (diff) | |
download | opie-cf029a4007ea344c530d8a71cd0b012393ebd7ba.zip opie-cf029a4007ea344c530d8a71cd0b012393ebd7ba.tar.gz opie-cf029a4007ea344c530d8a71cd0b012393ebd7ba.tar.bz2 |
- improve keyboard handling
- enable sniffer-menu
- fix handling of start/stop button
- add simple statistic window, fancy will follow ;-)
Diffstat (limited to 'noncore/net/wellenreiter/gui') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/gui.pro | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 99 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.h | 12 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/statwindow.cpp | 45 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/statwindow.h | 40 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 178 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 10 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.cpp | 21 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.h | 4 |
9 files changed, 278 insertions, 133 deletions
diff --git a/noncore/net/wellenreiter/gui/gui.pro b/noncore/net/wellenreiter/gui/gui.pro index 5970b01..08eb18a 100644 --- a/noncore/net/wellenreiter/gui/gui.pro +++ b/noncore/net/wellenreiter/gui/gui.pro | |||
@@ -11,4 +11,5 @@ HEADERS = wellenreiterbase.h \ | |||
11 | logwindow.h \ | 11 | logwindow.h \ |
12 | hexwindow.h \ | 12 | hexwindow.h \ |
13 | statwindow.h \ | ||
13 | configwindow.h \ | 14 | configwindow.h \ |
14 | manufacturers.h | 15 | manufacturers.h |
@@ -21,4 +22,5 @@ SOURCES = main.cpp \ | |||
21 | logwindow.cpp \ | 22 | logwindow.cpp \ |
22 | hexwindow.cpp \ | 23 | hexwindow.cpp \ |
24 | statwindow.cpp \ | ||
23 | configwindow.cpp \ | 25 | configwindow.cpp \ |
24 | manufacturers.cpp | 26 | manufacturers.cpp |
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 69d2b3a..94e3f28 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp | |||
@@ -61,28 +61,24 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
61 | infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) ); | 61 | infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) ); |
62 | settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) ); | 62 | settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) ); |
63 | #ifdef QWS | 63 | startIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); |
64 | searchIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); | 64 | stopIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); |
65 | cancelIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); | ||
66 | #else | ||
67 | startStopIconSet = new QIconSet(); | ||
68 | startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/SearchIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::Off ); | ||
69 | startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/CancelIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::On ); | ||
70 | #endif | ||
71 | 65 | ||
72 | // setup tool buttons | 66 | // setup tool buttons |
73 | 67 | ||
74 | startStopButton = new QToolButton( 0 ); | 68 | startButton = new QToolButton( 0 ); |
75 | #ifdef QWS | 69 | #ifdef QWS |
76 | startStopButton->setAutoRaise( true ); | 70 | startButton->setAutoRaise( true ); |
77 | #endif | 71 | #endif |
72 | startButton->setIconSet( *startIconSet ); | ||
73 | startButton->setEnabled( false ); | ||
74 | connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); | ||
75 | |||
76 | stopButton = new QToolButton( 0 ); | ||
78 | #ifdef QWS | 77 | #ifdef QWS |
79 | startStopButton->setOnIconSet( *cancelIconSet ); | 78 | stopButton->setAutoRaise( true ); |
80 | startStopButton->setOffIconSet( *searchIconSet ); | ||
81 | #else | ||
82 | startStopButton->setIconSet( *startStopIconSet ); | ||
83 | #endif | 79 | #endif |
84 | startStopButton->setToggleButton( true ); | 80 | stopButton->setIconSet( *stopIconSet ); |
85 | connect( startStopButton, SIGNAL( clicked() ), mw, SLOT( startStopClicked() ) ); | 81 | stopButton->setEnabled( false ); |
86 | startStopButton->setEnabled( false ); | 82 | connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); |
87 | 83 | ||
88 | QToolButton* c = new QToolButton( 0 ); | 84 | QToolButton* c = new QToolButton( 0 ); |
@@ -126,6 +122,10 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
126 | 122 | ||
127 | QPopupMenu* sniffer = new QPopupMenu( mb ); | 123 | QPopupMenu* sniffer = new QPopupMenu( mb ); |
128 | sniffer->insertItem( "&Configure..." ); | 124 | sniffer->insertItem( "&Configure...", this, SLOT( showConfigure() ) ); |
129 | sniffer->insertSeparator(); | 125 | sniffer->insertSeparator(); |
126 | startID = sniffer->insertItem( "&Start", mw, SLOT( startClicked() ) ); | ||
127 | sniffer->setItemEnabled( startID, false ); | ||
128 | stopID = sniffer->insertItem( "Sto&p", mw, SLOT( stopClicked() ) ); | ||
129 | sniffer->setItemEnabled( stopID, false ); | ||
130 | 130 | ||
131 | QPopupMenu* demo = new QPopupMenu( mb ); | 131 | QPopupMenu* demo = new QPopupMenu( mb ); |
@@ -136,10 +136,10 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
136 | mb->setItemEnabled( id, false ); | 136 | mb->setItemEnabled( id, false ); |
137 | id = mb->insertItem( "&Sniffer", sniffer ); | 137 | id = mb->insertItem( "&Sniffer", sniffer ); |
138 | mb->setItemEnabled( id, false ); | ||
139 | id = mb->insertItem( "&Demo", demo ); | 138 | id = mb->insertItem( "&Demo", demo ); |
140 | mb->setItemEnabled( id, true ); | 139 | mb->setItemEnabled( id, true ); |
141 | 140 | ||
142 | #ifdef QWS | 141 | #ifdef QWS |
143 | mb->insertItem( startStopButton ); | 142 | mb->insertItem( startButton ); |
143 | mb->insertItem( stopButton ); | ||
144 | mb->insertItem( c ); | 144 | mb->insertItem( c ); |
145 | mb->insertItem( d ); | 145 | mb->insertItem( d ); |
@@ -147,7 +147,10 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
147 | mb->insertItem( d ); | 147 | mb->insertItem( d ); |
148 | mb->insertItem( c ); | 148 | mb->insertItem( c ); |
149 | mb->insertItem( startStopButton ); | 149 | mb->insertItem( stopButton ); |
150 | mb->insertItem( startButton ); | ||
150 | #endif | 151 | #endif |
151 | 152 | ||
153 | updateToolButtonState(); | ||
154 | |||
152 | // setup status bar (for now only on X11) | 155 | // setup status bar (for now only on X11) |
153 | 156 | ||
@@ -156,6 +159,10 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
156 | #endif | 159 | #endif |
157 | 160 | ||
161 | connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); | ||
162 | connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); | ||
158 | }; | 163 | }; |
159 | 164 | ||
165 | |||
166 | |||
160 | void WellenreiterMainWindow::showConfigure() | 167 | void WellenreiterMainWindow::showConfigure() |
161 | { | 168 | { |
@@ -167,33 +174,43 @@ void WellenreiterMainWindow::showConfigure() | |||
167 | int result = cw->exec(); | 174 | int result = cw->exec(); |
168 | 175 | ||
169 | if ( result ) | 176 | if ( result ) updateToolButtonState(); |
170 | { | 177 | } |
171 | // check configuration from config window | ||
172 | 178 | ||
173 | const QString& interface = cw->interfaceName->currentText(); | ||
174 | const int cardtype = cw->daemonDeviceType(); | ||
175 | const int interval = cw->daemonHopInterval(); | ||
176 | 179 | ||
177 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) | 180 | |
178 | startStopButton->setEnabled( true ); | 181 | void WellenreiterMainWindow::updateToolButtonState() |
179 | //TODO ... | 182 | { |
180 | else | 183 | const QString& interface = cw->interfaceName->currentText(); |
181 | startStopButton->setEnabled( false ); | 184 | const int cardtype = cw->daemonDeviceType(); |
182 | //TODO ... | 185 | const int interval = cw->daemonHopInterval(); |
186 | |||
187 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) | ||
188 | { | ||
189 | startButton->setEnabled( true ); | ||
190 | menuBar()->setItemEnabled( startID, true ); | ||
191 | } | ||
192 | else | ||
193 | { | ||
194 | startButton->setEnabled( false ); | ||
195 | menuBar()->setItemEnabled( startID, false ); | ||
183 | } | 196 | } |
184 | } | 197 | } |
185 | 198 | ||
186 | WellenreiterMainWindow::~WellenreiterMainWindow() | 199 | |
200 | void WellenreiterMainWindow::changedSniffingState() | ||
187 | { | 201 | { |
202 | startButton->setEnabled( !mw->sniffing ); | ||
203 | menuBar()->setItemEnabled( startID, !mw->sniffing ); | ||
204 | stopButton->setEnabled( mw->sniffing ); | ||
205 | menuBar()->setItemEnabled( stopID, mw->sniffing ); | ||
206 | } | ||
188 | 207 | ||
208 | |||
209 | WellenreiterMainWindow::~WellenreiterMainWindow() | ||
210 | { | ||
189 | delete infoIconSet; | 211 | delete infoIconSet; |
190 | delete settingsIconSet; | 212 | delete settingsIconSet; |
191 | #ifdef QWS | 213 | delete startIconSet; |
192 | delete searchIconSet; | 214 | delete stopIconSet; |
193 | delete cancelIconSet; | ||
194 | #else | ||
195 | delete startStopIconSet; | ||
196 | #endif | ||
197 | |||
198 | }; | 215 | }; |
199 | 216 | ||
diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h index 1b08c5b..1e191e5 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.h +++ b/noncore/net/wellenreiter/gui/mainwindow.h | |||
@@ -36,14 +36,17 @@ class WellenreiterMainWindow: public QMainWindow | |||
36 | WellenreiterConfigWindow* cw; | 36 | WellenreiterConfigWindow* cw; |
37 | 37 | ||
38 | QIconSet* startStopIconSet; | 38 | const QIconSet* startIconSet; |
39 | const QIconSet* searchIconSet; | 39 | const QIconSet* stopIconSet; |
40 | const QIconSet* infoIconSet; | 40 | const QIconSet* infoIconSet; |
41 | const QIconSet* settingsIconSet; | 41 | const QIconSet* settingsIconSet; |
42 | const QIconSet* cancelIconSet; | ||
43 | 42 | ||
44 | QToolButton* startStopButton; | 43 | QToolButton* startButton; |
44 | QToolButton* stopButton; | ||
45 | int startID; | ||
46 | int stopID; | ||
45 | 47 | ||
46 | protected: | 48 | protected: |
47 | virtual void closeEvent( QCloseEvent* ); | 49 | virtual void closeEvent( QCloseEvent* ); |
50 | void updateToolButtonState(); | ||
48 | 51 | ||
49 | private: | 52 | private: |
@@ -58,4 +61,5 @@ class WellenreiterMainWindow: public QMainWindow | |||
58 | void fileLoadSession(); | 61 | void fileLoadSession(); |
59 | void fileNew(); | 62 | void fileNew(); |
63 | void changedSniffingState(); | ||
60 | }; | 64 | }; |
61 | 65 | ||
diff --git a/noncore/net/wellenreiter/gui/statwindow.cpp b/noncore/net/wellenreiter/gui/statwindow.cpp new file mode 100644 index 0000000..07d34ef --- a/dev/null +++ b/noncore/net/wellenreiter/gui/statwindow.cpp | |||
@@ -0,0 +1,45 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #include "statwindow.h" | ||
17 | #include <qmultilineedit.h> | ||
18 | |||
19 | MStatWindow::MStatWindow( QWidget * parent, const char * name, WFlags f ) | ||
20 | :QVBox( parent, name, f ) | ||
21 | { | ||
22 | ledit = new QMultiLineEdit( this ); | ||
23 | ledit->setFont( QFont( "fixed", 10 ) ); | ||
24 | |||
25 | // FIXME: Set properties( font, read-only, etc...) | ||
26 | |||
27 | }; | ||
28 | |||
29 | void MStatWindow::log( QString text ) | ||
30 | { | ||
31 | |||
32 | ledit->append( text ); | ||
33 | |||
34 | }; | ||
35 | |||
36 | const QString MStatWindow::getLog() const | ||
37 | { | ||
38 | return ledit->text(); | ||
39 | } | ||
40 | |||
41 | void MStatWindow::clear() | ||
42 | { | ||
43 | ledit->clear(); | ||
44 | } | ||
45 | |||
diff --git a/noncore/net/wellenreiter/gui/statwindow.h b/noncore/net/wellenreiter/gui/statwindow.h new file mode 100644 index 0000000..bbdf777 --- a/dev/null +++ b/noncore/net/wellenreiter/gui/statwindow.h | |||
@@ -0,0 +1,40 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #ifndef STATWINDOW_H | ||
17 | #define STATWINDOW_H | ||
18 | |||
19 | #include <qvbox.h> | ||
20 | |||
21 | class QString; | ||
22 | class QMultiLineEdit; | ||
23 | |||
24 | class MStatWindow: public QVBox | ||
25 | { | ||
26 | |||
27 | public: | ||
28 | MStatWindow( QWidget * parent = 0, const char * name = "MStatWindow", WFlags f = 0 ); | ||
29 | |||
30 | void log( QString text ); | ||
31 | const QString getLog() const; | ||
32 | void clear(); | ||
33 | |||
34 | protected: | ||
35 | QMultiLineEdit* ledit; | ||
36 | |||
37 | }; | ||
38 | |||
39 | #endif | ||
40 | |||
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 0bfc8e9..3372883 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -35,4 +35,5 @@ using namespace Opie; | |||
35 | #include <qcombobox.h> | 35 | #include <qcombobox.h> |
36 | #include <qspinbox.h> | 36 | #include <qspinbox.h> |
37 | #include <qtoolbutton.h> | ||
37 | #include <qmainwindow.h> | 38 | #include <qmainwindow.h> |
38 | 39 | ||
@@ -53,5 +54,5 @@ using namespace Opie; | |||
53 | #include "hexwindow.h" | 54 | #include "hexwindow.h" |
54 | #include "configwindow.h" | 55 | #include "configwindow.h" |
55 | 56 | #include "statwindow.h" | |
56 | #include "manufacturers.h" | 57 | #include "manufacturers.h" |
57 | 58 | ||
@@ -218,98 +219,121 @@ void Wellenreiter::receivePacket(OPacket* p) | |||
218 | } | 219 | } |
219 | 220 | ||
220 | void Wellenreiter::startStopClicked() | 221 | |
222 | void Wellenreiter::stopClicked() | ||
221 | { | 223 | { |
222 | if ( sniffing ) | 224 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
225 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | ||
226 | iface->setChannelHopping(); // stop hopping channels | ||
227 | pcap->close(); | ||
228 | sniffing = false; | ||
229 | #ifdef QWS | ||
230 | oApp->setTitle(); | ||
231 | #else | ||
232 | qApp->mainWidget()->setCaption( "Wellenreiter II" ); | ||
233 | #endif | ||
234 | |||
235 | // get interface name from config window | ||
236 | const QString& interface = configwindow->interfaceName->currentText(); | ||
237 | ONetwork* net = ONetwork::instance(); | ||
238 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | ||
239 | |||
240 | // switch off monitor mode | ||
241 | iface->setMonitorMode( false ); | ||
242 | // switch off promisc flag | ||
243 | iface->setPromiscuousMode( false ); | ||
244 | |||
245 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess | ||
246 | logwindow->log( "(i) Stopped Scanning." ); | ||
247 | assert( parent() ); | ||
248 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); | ||
249 | |||
250 | // message the user | ||
251 | QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); | ||
252 | |||
253 | sniffing = false; | ||
254 | emit( stoppedSniffing() ); | ||
255 | |||
256 | // print out statistics | ||
257 | statwindow->log( "-----------------------------------------" ); | ||
258 | statwindow->log( "- Wellenreiter II Capturing Statistic -" ); | ||
259 | statwindow->log( "-----------------------------------------" ); | ||
260 | statwindow->log( "Packet Type | Receive Count" ); | ||
261 | |||
262 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) | ||
223 | { | 263 | { |
224 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 264 | QString left; |
225 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 265 | left.sprintf( "%s", (const char*) it.key() ); |
226 | iface->setChannelHopping(); // stop hopping channels | 266 | left = left.leftJustify( 20 ); |
227 | pcap->close(); | 267 | left.append( '|' ); |
228 | sniffing = false; | 268 | QString right; |
229 | #ifdef QWS | 269 | right.sprintf( "%d", it.data() ); |
230 | oApp->setTitle(); | 270 | right = right.rightJustify( 7 ); |
231 | #else | 271 | statwindow->log( left + right ); |
232 | qApp->mainWidget()->setCaption( "Wellenreiter II" ); | ||
233 | #endif | ||
234 | |||
235 | // get interface name from config window | ||
236 | const QString& interface = configwindow->interfaceName->currentText(); | ||
237 | ONetwork* net = ONetwork::instance(); | ||
238 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | ||
239 | |||
240 | // switch off monitor mode | ||
241 | iface->setMonitorMode( false ); | ||
242 | // switch off promisc flag | ||
243 | iface->setPromiscuousMode( false ); | ||
244 | |||
245 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess | ||
246 | logwindow->log( "(i) Stopped Scanning." ); | ||
247 | assert( parent() ); | ||
248 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); | ||
249 | |||
250 | // message the user | ||
251 | QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); | ||
252 | } | 272 | } |
253 | 273 | ||
254 | else | 274 | } |
255 | { | ||
256 | // get configuration from config window | ||
257 | 275 | ||
258 | const QString& interface = configwindow->interfaceName->currentText(); | ||
259 | const int cardtype = configwindow->daemonDeviceType(); | ||
260 | const int interval = configwindow->daemonHopInterval(); | ||
261 | 276 | ||
262 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 277 | void Wellenreiter::startClicked() |
263 | { | 278 | { |
264 | QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); | 279 | // get configuration from config window |
265 | return; | ||
266 | } | ||
267 | 280 | ||
268 | // configure device | 281 | const QString& interface = configwindow->interfaceName->currentText(); |
282 | const int cardtype = configwindow->daemonDeviceType(); | ||
283 | const int interval = configwindow->daemonHopInterval(); | ||
269 | 284 | ||
270 | ONetwork* net = ONetwork::instance(); | 285 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
271 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | 286 | { |
287 | QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); | ||
288 | return; | ||
289 | } | ||
272 | 290 | ||
273 | // set monitor mode | 291 | // configure device |
274 | 292 | ||
275 | switch ( cardtype ) | 293 | ONetwork* net = ONetwork::instance(); |
276 | { | 294 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); |
277 | case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; | ||
278 | case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; | ||
279 | case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; | ||
280 | case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; | ||
281 | default: assert( 0 ); // shouldn't happen | ||
282 | } | ||
283 | 295 | ||
284 | iface->setMonitorMode( true ); | 296 | // set monitor mode |
285 | 297 | ||
286 | if ( !iface->monitorMode() ) | 298 | switch ( cardtype ) |
287 | { | 299 | { |
288 | QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); | 300 | case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; |
289 | return; | 301 | case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; |
290 | } | 302 | case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; |
303 | case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; | ||
304 | default: | ||
305 | QMessageBox::information( this, "Wellenreiter II", "Bring your device into\nmonitor mode now." ); | ||
306 | } | ||
291 | 307 | ||
292 | // open pcap and start sniffing | 308 | if ( cardtype > 0 && cardtype < 5 ) |
293 | pcap->open( interface ); | 309 | iface->setMonitorMode( true ); |
294 | 310 | ||
295 | if ( !pcap->isOpen() ) | 311 | if ( !iface->monitorMode() ) |
296 | { | 312 | { |
297 | QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); | 313 | QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); |
298 | return; | 314 | return; |
299 | } | 315 | } |
300 | 316 | ||
301 | // set capturer to non-blocking mode | 317 | // open pcap and start sniffing |
302 | pcap->setBlocking( false ); | 318 | pcap->open( interface ); |
303 | 319 | ||
304 | // start channel hopper | 320 | if ( !pcap->isOpen() ) |
305 | iface->setChannelHopping( 1000 ); //use interval from config window | 321 | { |
322 | QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); | ||
323 | return; | ||
324 | } | ||
306 | 325 | ||
307 | // connect | 326 | // set capturer to non-blocking mode |
308 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 327 | pcap->setBlocking( false ); |
309 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | ||
310 | 328 | ||
311 | logwindow->log( "(i) Started Scanning." ); | 329 | // start channel hopper |
312 | sniffing = true; | 330 | iface->setChannelHopping( 1000 ); //use interval from config window |
313 | 331 | ||
314 | } | 332 | // connect |
333 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | ||
334 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | ||
335 | |||
336 | logwindow->log( "(i) Started Scanning." ); | ||
337 | sniffing = true; | ||
338 | emit( startedSniffing() ); | ||
315 | } | 339 | } |
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index 85f889b..839c77e 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h | |||
@@ -48,8 +48,15 @@ class Wellenreiter : public WellenreiterBase { | |||
48 | bool isDaemonRunning() const { return sniffing; }; | 48 | bool isDaemonRunning() const { return sniffing; }; |
49 | 49 | ||
50 | bool sniffing; | ||
51 | |||
50 | public slots: | 52 | public slots: |
51 | void channelHopped(int); | 53 | void channelHopped(int); |
52 | void receivePacket(OPacket*); | 54 | void receivePacket(OPacket*); |
53 | void startStopClicked(); | 55 | void startClicked(); |
56 | void stopClicked(); | ||
57 | |||
58 | signals: | ||
59 | void startedSniffing(); | ||
60 | void stoppedSniffing(); | ||
54 | 61 | ||
55 | private: | 62 | private: |
@@ -58,5 +65,4 @@ class Wellenreiter : public WellenreiterBase { | |||
58 | #endif | 65 | #endif |
59 | 66 | ||
60 | bool sniffing; | ||
61 | OWirelessNetworkInterface* iface; | 67 | OWirelessNetworkInterface* iface; |
62 | OPacketCapturer* pcap; | 68 | OPacketCapturer* pcap; |
diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp index 3a703bc..245b9fc 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp | |||
@@ -31,4 +31,5 @@ | |||
31 | #include "hexwindow.h" | 31 | #include "hexwindow.h" |
32 | #include "scanlist.h" | 32 | #include "scanlist.h" |
33 | #include "statwindow.h" | ||
33 | 34 | ||
34 | #ifdef QWS | 35 | #ifdef QWS |
@@ -41,6 +42,6 @@ | |||
41 | 42 | ||
42 | 43 | ||
43 | /* | 44 | /* |
44 | * Constructs a WellenreiterBase which is a child of 'parent', with the | 45 | * Constructs a WellenreiterBase which is a child of 'parent', with the |
45 | * name 'name' and widget flags set to 'f' | 46 | * name 'name' and widget flags set to 'f' |
46 | */ | 47 | */ |
@@ -79,14 +80,16 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f | |||
79 | apLayout->addWidget( netview ); | 80 | apLayout->addWidget( netview ); |
80 | 81 | ||
81 | |||
82 | //--------- LOG TAB -------------- | 82 | //--------- LOG TAB -------------- |
83 | 83 | ||
84 | logwindow = new MLogWindow( TabWidget, "Log" ); | 84 | logwindow = new MLogWindow( TabWidget, "Log" ); |
85 | 85 | ||
86 | |||
87 | //--------- HEX TAB -------------- | 86 | //--------- HEX TAB -------------- |
88 | 87 | ||
89 | hexwindow = new MHexWindow( TabWidget, "Hex" ); | 88 | hexwindow = new MHexWindow( TabWidget, "Hex" ); |
90 | 89 | ||
90 | //--------- STAT TAB -------------- | ||
91 | |||
92 | statwindow = new MStatWindow( TabWidget, "Stat" ); | ||
93 | |||
91 | //--------- ABOUT TAB -------------- | 94 | //--------- ABOUT TAB -------------- |
92 | 95 | ||
@@ -126,7 +129,8 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f | |||
126 | 129 | ||
127 | #ifdef QWS | 130 | #ifdef QWS |
128 | TabWidget->addTab( ap, "wellenreiter/networks", tr( "Networks" ) ); | 131 | TabWidget->addTab( ap, "wellenreiter/networks", tr( "Nets" ) ); |
129 | TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) ); | 132 | TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) ); |
130 | TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) ); | 133 | TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) ); |
134 | TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stats" ) ); | ||
131 | TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) ); | 135 | TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) ); |
132 | #else | 136 | #else |
@@ -134,15 +138,16 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f | |||
134 | TabWidget->addTab( logwindow, /* "wellenreiter/log", */ tr( "Log" ) ); | 138 | TabWidget->addTab( logwindow, /* "wellenreiter/log", */ tr( "Log" ) ); |
135 | TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) ); | 139 | TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) ); |
140 | TabWidget->addTab( statwindow, /* "wellenreiter/hex", */ tr( "Stat" ) ); | ||
136 | TabWidget->addTab( about, /* "wellenreiter/about", */ tr( "About" ) ); | 141 | TabWidget->addTab( about, /* "wellenreiter/about", */ tr( "About" ) ); |
137 | #endif | 142 | #endif |
138 | WellenreiterBaseLayout->addWidget( TabWidget ); | 143 | WellenreiterBaseLayout->addWidget( TabWidget ); |
139 | 144 | ||
140 | #ifdef QWS | 145 | #ifdef QWS |
141 | TabWidget->setCurrentTab( tr( "Networks" ) ); | 146 | TabWidget->setCurrentTab( tr( "Nets" ) ); |
142 | #endif | 147 | #endif |
143 | 148 | ||
144 | } | 149 | } |
145 | 150 | ||
146 | /* | 151 | /* |
147 | * Destroys the object and frees any allocated resources | 152 | * Destroys the object and frees any allocated resources |
148 | */ | 153 | */ |
diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.h b/noncore/net/wellenreiter/gui/wellenreiterbase.h index 1fa1ea3..ad2e96c 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.h +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.h | |||
@@ -28,4 +28,5 @@ class QPushButton; | |||
28 | class MLogWindow; | 28 | class MLogWindow; |
29 | class MHexWindow; | 29 | class MHexWindow; |
30 | class MStatWindow; | ||
30 | 31 | ||
31 | #ifdef QWS | 32 | #ifdef QWS |
@@ -52,4 +53,5 @@ public: | |||
52 | MLogWindow* logwindow; | 53 | MLogWindow* logwindow; |
53 | MHexWindow* hexwindow; | 54 | MHexWindow* hexwindow; |
55 | MStatWindow* statwindow; | ||
54 | QWidget* about; | 56 | QWidget* about; |
55 | QLabel* PixmapLabel1_3_2; | 57 | QLabel* PixmapLabel1_3_2; |
@@ -67,5 +69,5 @@ protected: | |||
67 | QPixmap* ani4; | 69 | QPixmap* ani4; |
68 | 70 | ||
69 | 71 | ||
70 | }; | 72 | }; |
71 | 73 | ||