summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-12-09 21:33:48 (UTC)
committer mickeyl <mickeyl>2003-12-09 21:33:48 (UTC)
commit0a1f6405780b18c9f3d953adcfd072de8fd4dc18 (patch) (unidiff)
treeb155d2ee3c7766155b028f4e8ee92599fd50e8a9
parentdc1fc74ee3988fb3a89f6fc46cbcfe8b74416647 (diff)
downloadopie-0a1f6405780b18c9f3d953adcfd072de8fd4dc18.zip
opie-0a1f6405780b18c9f3d953adcfd072de8fd4dc18.tar.gz
opie-0a1f6405780b18c9f3d953adcfd072de8fd4dc18.tar.bz2
misc. fixes and preparations for uploading dumps
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp56
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.h8
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp38
3 files changed, 54 insertions, 48 deletions
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp
index 868b0b0..ab7e0c7 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.cpp
+++ b/noncore/net/wellenreiter/gui/mainwindow.cpp
@@ -12,254 +12,254 @@
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "configwindow.h" 16#include "configwindow.h"
17#include "gps.h" 17#include "gps.h"
18#include "logwindow.h" 18#include "logwindow.h"
19#include "hexwindow.h" 19#include "hexwindow.h"
20#include "mainwindow.h" 20#include "mainwindow.h"
21#include "wellenreiter.h" 21#include "wellenreiter.h"
22#include "scanlist.h" 22#include "scanlist.h"
23 23
24#include <qcombobox.h> 24#include <qcombobox.h>
25#include <qdatastream.h> 25#include <qdatastream.h>
26#include <qfile.h> 26#include <qfile.h>
27#include <qfileinfo.h> 27#include <qfileinfo.h>
28#include <qiconset.h> 28#include <qiconset.h>
29#include <qmenubar.h> 29#include <qmenubar.h>
30#include <qmessagebox.h> 30#include <qmessagebox.h>
31#include <qpopupmenu.h> 31#include <qpopupmenu.h>
32#include <qstatusbar.h> 32#include <qstatusbar.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qtoolbutton.h> 34#include <qtoolbutton.h>
35 35
36#ifdef QWS 36#ifdef QWS
37#include <qpe/resource.h> 37#include <qpe/resource.h>
38#include <opie/ofiledialog.h> 38#include <opie/ofiledialog.h>
39#else 39#else
40#include "resource.h" 40#include "resource.h"
41#include <qapplication.h> 41#include <qapplication.h>
42#include <qfiledialog.h> 42#include <qfiledialog.h>
43#endif 43#endif
44 44
45WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) 45WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f )
46 :QMainWindow( parent, name, f ) 46 :QMainWindow( parent, name, f )
47{ 47{
48 cw = new WellenreiterConfigWindow( this ); 48 cw = new WellenreiterConfigWindow( this );
49 mw = new Wellenreiter( this ); 49 mw = new Wellenreiter( this );
50 mw->setConfigWindow( cw ); 50 mw->setConfigWindow( cw );
51 setCentralWidget( mw ); 51 setCentralWidget( mw );
52 52
53 // setup application icon 53 // setup application icon
54 54
55 #ifndef QWS 55 #ifndef QWS
56 setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); 56 setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) );
57 setIconText( "Wellenreiter/X11" ); 57 setIconText( "Wellenreiter/X11" );
58 #endif 58 #endif
59 59
60 // setup icon sets
61
62 infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) );
63 settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) );
64 startIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) );
65 stopIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) );
66
67 // setup tool buttons 60 // setup tool buttons
68 61
69 startButton = new QToolButton( 0 ); 62 startButton = new QToolButton( 0 );
70 #ifdef QWS 63 #ifdef QWS
71 startButton->setAutoRaise( true ); 64 startButton->setAutoRaise( true );
72 #endif 65 #endif
73 startButton->setIconSet( *startIconSet ); 66 startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) );
74 startButton->setEnabled( false ); 67 startButton->setEnabled( false );
75 connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); 68 connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) );
76 69
77 stopButton = new QToolButton( 0 ); 70 stopButton = new QToolButton( 0 );
78 #ifdef QWS 71 #ifdef QWS
79 stopButton->setAutoRaise( true ); 72 stopButton->setAutoRaise( true );
80 #endif 73 #endif
81 stopButton->setIconSet( *stopIconSet ); 74 stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) );
82 stopButton->setEnabled( false ); 75 stopButton->setEnabled( false );
83 connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); 76 connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) );
84 77
85 QToolButton* c = new QToolButton( 0 );
86 #ifdef QWS
87 c->setAutoRaise( true );
88 #endif
89 c->setIconSet( *infoIconSet );
90 c->setEnabled( false );
91
92 QToolButton* d = new QToolButton( 0 ); 78 QToolButton* d = new QToolButton( 0 );
93 #ifdef QWS 79 #ifdef QWS
94 d->setAutoRaise( true ); 80 d->setAutoRaise( true );
95 #endif 81 #endif
96 d->setIconSet( *settingsIconSet ); 82 d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) );
97 connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); 83 connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) );
98 84
85 uploadButton = new QToolButton( 0 );
86 #ifdef QWS
87 uploadButton->setAutoRaise( true );
88 #endif
89 uploadButton->setIconSet( Resource::loadIconSet( "up" ) );
90 uploadButton->setEnabled( false );
91 connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) );
92
99 // setup menu bar 93 // setup menu bar
100 94
101 int id; 95 int id;
102 96
103 QMenuBar* mb = menuBar(); 97 QMenuBar* mb = menuBar();
104 98
105 QPopupMenu* fileSave = new QPopupMenu( mb ); 99 QPopupMenu* fileSave = new QPopupMenu( mb );
106 fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); 100 fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) );
107 fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); 101 fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) );
108 fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); 102 fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) );
109 103
110 QPopupMenu* fileLoad = new QPopupMenu( mb ); 104 QPopupMenu* fileLoad = new QPopupMenu( mb );
111 fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); 105 fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) );
112 //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); 106 //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) );
113 107
114 QPopupMenu* file = new QPopupMenu( mb ); 108 QPopupMenu* file = new QPopupMenu( mb );
115 file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); 109 file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) );
116 id = file->insertItem( tr( "&Load" ), fileLoad ); 110 id = file->insertItem( tr( "&Load" ), fileLoad );
117 file->insertItem( tr( "&Save" ), fileSave ); 111 file->insertItem( tr( "&Save" ), fileSave );
118 file->insertSeparator(); 112 file->insertSeparator();
113 uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) );
114 file->insertSeparator();
119 file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); 115 file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) );
120 116
121 QPopupMenu* view = new QPopupMenu( mb ); 117 QPopupMenu* view = new QPopupMenu( mb );
122 view->insertItem( tr( "&Configure..." ) ); 118 view->insertItem( tr( "&Configure..." ) );
123 119
124 QPopupMenu* sniffer = new QPopupMenu( mb ); 120 QPopupMenu* sniffer = new QPopupMenu( mb );
125 sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); 121 sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) );
126 sniffer->insertSeparator(); 122 sniffer->insertSeparator();
127 startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); 123 startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) );
128 sniffer->setItemEnabled( startID, false ); 124 sniffer->setItemEnabled( startID, false );
129 stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); 125 stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) );
130 sniffer->setItemEnabled( stopID, false ); 126 sniffer->setItemEnabled( stopID, false );
131 127
132 QPopupMenu* demo = new QPopupMenu( mb ); 128 QPopupMenu* demo = new QPopupMenu( mb );
133 demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); 129 demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) );
134 130
135 id = mb->insertItem( tr( "&File" ), file ); 131 id = mb->insertItem( tr( "&File" ), file );
136 //id = mb->insertItem( tr( "&View" ), view ); 132 //id = mb->insertItem( tr( "&View" ), view );
137 //mb->setItemEnabled( id, false ); 133 //mb->setItemEnabled( id, false );
138 id = mb->insertItem( tr( "&Sniffer" ), sniffer ); 134 id = mb->insertItem( tr( "&Sniffer" ), sniffer );
139 135
140 id = mb->insertItem( tr( "&Demo" ), demo ); 136 id = mb->insertItem( tr( "&Demo" ), demo );
141 mb->setItemEnabled( id, true ); 137 mb->setItemEnabled( id, true );
138 mb->setItemEnabled( uploadID, false );
142 139
143 #ifdef QWS 140 #ifdef QWS
144 mb->insertItem( startButton ); 141 mb->insertItem( startButton );
145 mb->insertItem( stopButton ); 142 mb->insertItem( stopButton );
146 mb->insertItem( c ); 143 mb->insertItem( uploadButton );
147 mb->insertItem( d ); 144 mb->insertItem( d );
148 #else // Qt3 changed the insertion order. It's now totally random :( 145 #else // Qt3 changed the insertion order. It's now totally random :(
149 mb->insertItem( d ); 146 mb->insertItem( d );
150 mb->insertItem( c ); 147 mb->insertItem( uploadButton );
151 mb->insertItem( stopButton ); 148 mb->insertItem( stopButton );
152 mb->insertItem( startButton ); 149 mb->insertItem( startButton );
153 #endif 150 #endif
154 151
155 updateToolButtonState(); 152 updateToolButtonState();
156 153
157 // setup status bar (for now only on X11) 154 // setup status bar (for now only on X11)
158 155
159 #ifndef QWS 156 #ifndef QWS
160 statusBar()->message( tr( "Ready." ) ); 157 statusBar()->message( tr( "Ready." ) );
161 #endif 158 #endif
162 159
163 connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); 160 connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) );
164 connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); 161 connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) );
165}; 162};
166 163
167 164
168 165
169void WellenreiterMainWindow::showConfigure() 166void WellenreiterMainWindow::showConfigure()
170{ 167{
171 qDebug( "show configure..." ); 168 qDebug( "show configure..." );
172 cw->setCaption( tr( "Configure" ) ); 169 cw->setCaption( tr( "Configure" ) );
173 #ifdef QWS 170 #ifdef QWS
174 cw->showMaximized(); 171 cw->showMaximized();
175 #endif 172 #endif
176 int result = cw->exec(); 173 int result = cw->exec();
177 174
178 if ( result ) updateToolButtonState(); 175 if ( result ) updateToolButtonState();
179} 176}
180 177
181 178
182
183void WellenreiterMainWindow::updateToolButtonState() 179void WellenreiterMainWindow::updateToolButtonState()
184{ 180{
185 const QString& interface = cw->interfaceName->currentText(); 181 const QString& interface = cw->interfaceName->currentText();
186 const int cardtype = cw->driverType(); 182 const int cardtype = cw->driverType();
187 183
188 if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) 184 if ( ( interface != "<select>" ) && ( cardtype != 0 ) )
189 { 185 {
190 startButton->setEnabled( true ); 186 startButton->setEnabled( true );
191 menuBar()->setItemEnabled( startID, true ); 187 menuBar()->setItemEnabled( startID, true );
192 } 188 }
193 else 189 else
194 { 190 {
195 startButton->setEnabled( false ); 191 startButton->setEnabled( false );
196 menuBar()->setItemEnabled( startID, false ); 192 menuBar()->setItemEnabled( startID, false );
197 } 193 }
198} 194}
199 195
200 196
201void WellenreiterMainWindow::changedSniffingState() 197void WellenreiterMainWindow::changedSniffingState()
202{ 198{
203 startButton->setEnabled( !mw->sniffing ); 199 startButton->setEnabled( !mw->sniffing );
204 menuBar()->setItemEnabled( startID, !mw->sniffing ); 200 menuBar()->setItemEnabled( startID, !mw->sniffing );
205 stopButton->setEnabled( mw->sniffing ); 201 stopButton->setEnabled( mw->sniffing );
206 menuBar()->setItemEnabled( stopID, mw->sniffing ); 202 menuBar()->setItemEnabled( stopID, mw->sniffing );
203
204 if ( !mw->sniffing )
205 {
206 menuBar()->setItemEnabled( uploadID, true );
207 uploadButton->setEnabled( true );
208 }
207} 209}
208 210
209 211
210WellenreiterMainWindow::~WellenreiterMainWindow() 212WellenreiterMainWindow::~WellenreiterMainWindow()
211{ 213{
212 delete infoIconSet; 214 qDebug( "Wellenreiter:: bye." );
213 delete settingsIconSet;
214 delete startIconSet;
215 delete stopIconSet;
216}; 215};
217 216
217
218void WellenreiterMainWindow::demoAddStations() 218void WellenreiterMainWindow::demoAddStations()
219{ 219{
220 //mw = 0; // test SIGSGV handling 220 //mw = 0; // test SIGSGV handling
221 221
222 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 10.10, 20.20 ) ); 222 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 10.10, 20.20 ) );
223 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); 223 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) );
224 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:A0:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); 224 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:A0:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) );
225 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:AA:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); 225 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:AA:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) );
226 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:B0:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); 226 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:B0:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) );
227} 227}
228 228
229 229
230QString WellenreiterMainWindow::getFileName( bool save ) 230QString WellenreiterMainWindow::getFileName( bool save )
231{ 231{
232 QMap<QString, QStringList> map; 232 QMap<QString, QStringList> map;
233 map.insert( tr("All"), QStringList() ); 233 map.insert( tr("All"), QStringList() );
234 QStringList text; 234 QStringList text;
235 text << "text/*"; 235 text << "text/*";
236 map.insert( tr("Text"), text ); 236 map.insert( tr("Text"), text );
237 text << "*"; 237 text << "*";
238 map.insert( tr("All"), text ); 238 map.insert( tr("All"), text );
239 239
240 QString str; 240 QString str;
241 if ( save ) 241 if ( save )
242 { 242 {
243 #ifdef QWS 243 #ifdef QWS
244 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); 244 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map );
245 #else 245 #else
246 str = QFileDialog::getSaveFileName(); 246 str = QFileDialog::getSaveFileName();
247 #endif 247 #endif
248 if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) 248 if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ )
249 return ""; 249 return "";
250 } 250 }
251 else 251 else
252 { 252 {
253 #ifdef QWS 253 #ifdef QWS
254 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); 254 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map );
255 #else 255 #else
256 str = QFileDialog::getOpenFileName(); 256 str = QFileDialog::getOpenFileName();
257 #endif 257 #endif
258 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) 258 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() )
259 return ""; 259 return "";
260 } 260 }
261 return str; 261 return str;
262} 262}
263 263
264 264
265void WellenreiterMainWindow::fileSaveLog() 265void WellenreiterMainWindow::fileSaveLog()
@@ -298,70 +298,78 @@ void WellenreiterMainWindow::fileSaveSession()
298 } 298 }
299 else 299 else
300 { 300 {
301 qDebug( "Problem saving session to file '%s'", (const char*) fname ); 301 qDebug( "Problem saving session to file '%s'", (const char*) fname );
302 } 302 }
303 } 303 }
304} 304}
305 305
306void WellenreiterMainWindow::fileSaveHex() 306void WellenreiterMainWindow::fileSaveHex()
307{ 307{
308 QString fname = getFileName( true ); 308 QString fname = getFileName( true );
309 if ( !fname.isEmpty() ) 309 if ( !fname.isEmpty() )
310 { 310 {
311 QFile f( fname ); 311 QFile f( fname );
312 if ( f.open(IO_WriteOnly) ) 312 if ( f.open(IO_WriteOnly) )
313 { 313 {
314 QTextStream t( &f ); 314 QTextStream t( &f );
315 t << mw->hexWindow()->getLog(); 315 t << mw->hexWindow()->getLog();
316 f.close(); 316 f.close();
317 qDebug( "Saved hex log to file '%s'", (const char*) fname ); 317 qDebug( "Saved hex log to file '%s'", (const char*) fname );
318 } 318 }
319 else 319 else
320 { 320 {
321 qDebug( "Problem saving hex log to file '%s'", (const char*) fname ); 321 qDebug( "Problem saving hex log to file '%s'", (const char*) fname );
322 } 322 }
323 } 323 }
324} 324}
325 325
326void WellenreiterMainWindow::fileLoadSession() 326void WellenreiterMainWindow::fileLoadSession()
327{ 327{
328 QString fname = getFileName( false ); 328 QString fname = getFileName( false );
329 if ( !fname.isEmpty() ) 329 if ( !fname.isEmpty() )
330 { 330 {
331 QFile f( fname ); 331 QFile f( fname );
332 if ( f.open(IO_ReadOnly) ) 332 if ( f.open(IO_ReadOnly) )
333 { 333 {
334 QDataStream t( &f ); 334 QDataStream t( &f );
335 t >> *mw->netView(); 335 t >> *mw->netView();
336 f.close(); 336 f.close();
337 qDebug( "Loaded session from file '%s'", (const char*) fname ); 337 qDebug( "Loaded session from file '%s'", (const char*) fname );
338 } 338 }
339 else 339 else
340 { 340 {
341 qDebug( "Problem loading session from file '%s'", (const char*) fname ); 341 qDebug( "Problem loading session from file '%s'", (const char*) fname );
342 } 342 }
343 } 343 }
344} 344}
345 345
346
346void WellenreiterMainWindow::fileNew() 347void WellenreiterMainWindow::fileNew()
347{ 348{
348 mw->netView()->clear(); 349 mw->netView()->clear();
349 mw->logWindow()->clear(); 350 mw->logWindow()->clear();
350 mw->hexWindow()->clear(); 351 mw->hexWindow()->clear();
351} 352}
352 353
354
353void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) 355void WellenreiterMainWindow::closeEvent( QCloseEvent* e )
354{ 356{
355 if ( mw->isDaemonRunning() ) 357 if ( mw->isDaemonRunning() )
356 { 358 {
357 QMessageBox::warning( this, "Wellenreiter/Opie", 359 QMessageBox::warning( this, "Wellenreiter/Opie",
358 tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); 360 tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) );
359 e->ignore(); 361 e->ignore();
360 } 362 }
361 else 363 else
362 { 364 {
363 QMainWindow::closeEvent( e ); 365 QMainWindow::closeEvent( e );
364 } 366 }
365} 367}
366 368
367 369
370void WellenreiterMainWindow::uploadSession()
371{
372 QMessageBox::warning( this, "Wellenreiter/Opie",
373 tr( "This feature is\nunder construction... ;-)" ) );
374}
375
diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h
index 926bb0a..8d4e768 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.h
+++ b/noncore/net/wellenreiter/gui/mainwindow.h
@@ -1,64 +1,62 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef MAINWINDOW_H 16#ifndef MAINWINDOW_H
17#define MAINWINDOW_H 17#define MAINWINDOW_H
18 18
19#include <qmainwindow.h> 19#include <qmainwindow.h>
20 20
21class Wellenreiter; 21class Wellenreiter;
22class WellenreiterConfigWindow; 22class WellenreiterConfigWindow;
23class QIconSet; 23class QIconSet;
24class QToolButton; 24class QToolButton;
25 25
26class WellenreiterMainWindow: public QMainWindow 26class WellenreiterMainWindow: public QMainWindow
27{ 27{
28 Q_OBJECT 28 Q_OBJECT
29 29
30 public: 30 public:
31 WellenreiterMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 ); 31 WellenreiterMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 );
32 ~WellenreiterMainWindow(); 32 ~WellenreiterMainWindow();
33 QString getFileName( bool save ); 33 QString getFileName( bool save );
34 34
35 protected: 35 protected:
36 Wellenreiter* mw; 36 Wellenreiter* mw;
37 WellenreiterConfigWindow* cw; 37 WellenreiterConfigWindow* cw;
38 38
39 const QIconSet* startIconSet;
40 const QIconSet* stopIconSet;
41 const QIconSet* infoIconSet;
42 const QIconSet* settingsIconSet;
43
44 QToolButton* startButton; 39 QToolButton* startButton;
45 QToolButton* stopButton; 40 QToolButton* stopButton;
41 QToolButton* uploadButton;
46 int startID; 42 int startID;
47 int stopID; 43 int stopID;
44 int uploadID;
48 45
49 protected: 46 protected:
50 virtual void closeEvent( QCloseEvent* ); 47 virtual void closeEvent( QCloseEvent* );
51 void updateToolButtonState(); 48 void updateToolButtonState();
52 49
53 public slots: 50 public slots:
54 void showConfigure(); 51 void showConfigure();
55 void demoAddStations(); 52 void demoAddStations();
56 void fileSaveLog(); 53 void fileSaveLog();
57 void fileSaveHex(); 54 void fileSaveHex();
58 void fileSaveSession(); 55 void fileSaveSession();
59 void fileLoadSession(); 56 void fileLoadSession();
60 void fileNew(); 57 void fileNew();
58 void uploadSession();
61 void changedSniffingState(); 59 void changedSniffingState();
62}; 60};
63 61
64#endif 62#endif
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 1d4a98b..ec89f1e 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -257,97 +257,97 @@ void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source,
257 } 257 }
258 else if ( arp->type() == "REPLY" ) 258 else if ( arp->type() == "REPLY" )
259 { 259 {
260 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 260 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
261 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); 261 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() );
262 } 262 }
263 } 263 }
264} 264}
265 265
266 266
267void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) 267void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest )
268{ 268{
269 //TODO: Implement more IP based protocols 269 //TODO: Implement more IP based protocols
270 270
271 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); 271 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" );
272 if ( dhcp ) 272 if ( dhcp )
273 { 273 {
274 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); 274 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() );
275 if ( dhcp->type() == "OFFER" ) 275 if ( dhcp->type() == "OFFER" )
276 { 276 {
277 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); 277 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() );
278 netView()->identify( source, dhcp->serverAddress().toString() ); 278 netView()->identify( source, dhcp->serverAddress().toString() );
279 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); 279 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
280 } 280 }
281 else if ( dhcp->type() == "ACK" ) 281 else if ( dhcp->type() == "ACK" )
282 { 282 {
283 qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); 283 qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() );
284 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); 284 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() );
285 } 285 }
286 } 286 }
287} 287}
288 288
289 289
290QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 290QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
291{ 291{
292 if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) 292 if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
293 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) 293 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
294 return 0; 294 return 0;
295 295
296 return p->child( protocol ); 296 return p->child( protocol );
297} 297}
298 298
299 299
300bool Wellenreiter::checkDumpPacket( OPacket* p ) 300bool Wellenreiter::checkDumpPacket( OPacket* p )
301{ 301{
302 // go through all child packets and see if one is inside the child hierarchy for p 302 // go through all child packets and see if one is inside the child hierarchy for p
303 // if so, do what the user requested (protocolAction), e.g. pass or discard 303 // if so, do what the user requested (protocolAction), e.g. pass or discard
304 if ( !configwindow->writeCaptureFile->isChecked() ) 304 if ( !configwindow->writeCaptureFile->isChecked() )
305 return false; 305 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter
306 306
307 QObjectList* l = p->queryList(); 307 QObjectList* l = p->queryList();
308 QObjectListIt it( *l ); 308 QObjectListIt it( *l );
309 QObject* o; 309 QObject* o;
310 310
311 while ( (o = it.current()) != 0 ) 311 while ( (o = it.current()) != 0 )
312 { 312 {
313 QString name = it.current()->name(); 313 QString name = it.current()->name();
314 if ( configwindow->capturePackets->isProtocolChecked( name ) ) 314 if ( configwindow->capturePackets->isProtocolChecked( name ) )
315 { 315 {
316 QString action = configwindow->capturePackets->protocolAction( name ); 316 QString action = configwindow->capturePackets->protocolAction( name );
317 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 317 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
318 if ( action == "Discard" ) 318 if ( action == "Discard" )
319 { 319 {
320 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); 320 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) );
321 return false; 321 return false;
322 } 322 }
323 } 323 }
324 else 324 else
325 { 325 {
326 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); 326 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name );
327 } 327 }
328 ++it; 328 ++it;
329 } 329 }
330 return true; 330 return true;
331} 331}
332 332
333 333
334void Wellenreiter::receivePacket( OPacket* p ) 334void Wellenreiter::receivePacket( OPacket* p )
335{ 335{
336 hexWindow()->log( p->dump( 8 ) ); 336 hexWindow()->log( p->dump( 8 ) );
337 337
338 if ( checkDumpPacket( p ) ) 338 if ( checkDumpPacket( p ) )
339 { 339 {
340 pcap->dump( p ); 340 pcap->dump( p );
341 } 341 }
342 342
343 // check if we received a beacon frame 343 // check if we received a beacon frame
344 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); 344 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) );
345 if ( beacon && beacon->managementType() == "Beacon" ) 345 if ( beacon && beacon->managementType() == "Beacon" )
346 { 346 {
347 handleBeacon( p, beacon ); 347 handleBeacon( p, beacon );
348 return; 348 return;
349 } 349 }
350 350
351 OMacAddress source; 351 OMacAddress source;
352 OMacAddress dest; 352 OMacAddress dest;
353 353
@@ -461,119 +461,119 @@ void Wellenreiter::startClicked()
461 461
462 // bring device UP 462 // bring device UP
463 if ( cardtype != DEVTYPE_FILE ) 463 if ( cardtype != DEVTYPE_FILE )
464 { 464 {
465 iface->setUp( true ); 465 iface->setUp( true );
466 if ( !iface->isUp() ) 466 if ( !iface->isUp() )
467 { 467 {
468 QMessageBox::warning( this, "Wellenreiter II", 468 QMessageBox::warning( this, "Wellenreiter II",
469 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); 469 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) );
470 return; 470 return;
471 } 471 }
472 } 472 }
473 // set monitor mode 473 // set monitor mode
474 bool usePrism = configwindow->usePrismHeader(); 474 bool usePrism = configwindow->usePrismHeader();
475 475
476 switch ( cardtype ) 476 switch ( cardtype )
477 { 477 {
478 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; 478 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break;
479 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; 479 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break;
480 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; 480 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break;
481 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; 481 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break;
482 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; 482 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break;
483 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; 483 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break;
484 default: assert( 0 ); // shouldn't reach this 484 default: assert( 0 ); // shouldn't reach this
485 } 485 }
486 486
487 // switch device into monitor mode 487 // switch device into monitor mode
488 if ( cardtype < DEVTYPE_FILE ) 488 if ( cardtype < DEVTYPE_FILE )
489 { 489 {
490 if ( cardtype != DEVTYPE_MANUAL ) 490 if ( cardtype != DEVTYPE_MANUAL )
491 iface->setMode( "monitor" ); 491 iface->setMode( "monitor" );
492 if ( iface->mode() != "monitor" ) 492 if ( iface->mode() != "monitor" )
493 { 493 {
494 if ( QMessageBox::warning( this, "Wellenreiter II", 494 if ( QMessageBox::warning( this, "Wellenreiter II",
495 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + 495 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) +
496 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) 496 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
497 return; 497 return;
498 } 498 }
499 } 499 }
500 500
501 // open GPS device 501 // open GPS device
502 if ( configwindow->enableGPS->isChecked() ) 502 if ( configwindow->enableGPS->isChecked() )
503 { 503 {
504 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 504 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
505 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 505 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
506 } 506 }
507 507
508 // open pcap and start sniffing 508 // open pcap and start sniffing
509 if ( cardtype != DEVTYPE_FILE )
510 {
511 pcap->open( interface );
512 509
513 if ( configwindow->writeCaptureFile->isChecked() ) 510 QString dumpname;
514 { 511 if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file?
515 QString dumpname( configwindow->captureFileName->text() ); 512 {
516 if ( dumpname.isEmpty() ) dumpname = "captureFile"; 513 dumpname = configwindow->captureFileName->text();
517 dumpname.append( '-' ); 514 if ( dumpname.isEmpty() ) dumpname = "captureFile";
518 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); 515 dumpname.append( '-' );
519 dumpname.append( ".wellenreiter" ); 516 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
520 pcap->openDumpFile( dumpname ); 517 dumpname.append( ".wellenreiter" );
521 }
522 else
523 {
524 pcap->open( interface );
525 }
526 } 518 }
527 else 519 else // write it anyway ;)
528 { 520 {
529 pcap->open( QFile( interface ) ); 521 dumpname = "/var/log/dump.wellenreiter";
530 } 522 }
531 523
524 if ( cardtype != DEVTYPE_FILE )
525 pcap->open( interface );
526 else
527 pcap->open( QFile( interface ) );
528
529 qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname );
530 pcap->openDumpFile( dumpname );
531
532 if ( !pcap->isOpen() ) 532 if ( !pcap->isOpen() )
533 { 533 {
534 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( 534 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg(
535 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); 535 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) ));
536 return; 536 return;
537 } 537 }
538 538
539 // set capturer to non-blocking mode 539 // set capturer to non-blocking mode
540 pcap->setBlocking( false ); 540 pcap->setBlocking( false );
541 541
542 // start channel hopper 542 // start channel hopper
543 if ( cardtype != DEVTYPE_FILE ) 543 if ( cardtype != DEVTYPE_FILE )
544 { 544 {
545 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); 545 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) );
546 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window 546 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window
547 } 547 }
548 548
549 if ( cardtype != DEVTYPE_FILE ) 549 if ( cardtype != DEVTYPE_FILE )
550 { 550 {
551 // connect socket notifier and start channel hopper 551 // connect socket notifier and start channel hopper
552 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 552 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
553 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 553 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
554 } 554 }
555 else 555 else
556 { 556 {
557 // start timer for reading packets 557 // start timer for reading packets
558 startTimer( 100 ); 558 startTimer( 100 );
559 } 559 }
560 560
561 logwindow->log( "(i) Started Scanning." ); 561 logwindow->log( "(i) Started Scanning." );
562 sniffing = true; 562 sniffing = true;
563 563
564 #ifdef QWS 564 #ifdef QWS
565 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 565 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
566 { 566 {
567 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; 567 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
568 } 568 }
569 #else 569 #else
570 #warning FIXME: setScreenSaverMode is not operational on the X11 build 570 #warning FIXME: setScreenSaverMode is not operational on the X11 build
571 #endif 571 #endif
572 572
573 emit( startedSniffing() ); 573 emit( startedSniffing() );
574 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title 574 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title
575 else 575 else
576 { 576 {
577 assert( parent() ); 577 assert( parent() );
578 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); 578 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) );
579 } 579 }