summaryrefslogtreecommitdiff
Unidiff
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
@@ -54,51 +54,45 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n
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
@@ -113,12 +107,14 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n
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 );
@@ -136,21 +132,22 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n
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
@@ -176,13 +173,12 @@ void WellenreiterMainWindow::showConfigure()
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 ) )
@@ -201,23 +197,27 @@ void WellenreiterMainWindow::updateToolButtonState()
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 ) );
@@ -340,19 +340,21 @@ void WellenreiterMainWindow::fileLoadSession()
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." ) );
@@ -362,6 +364,12 @@ void WellenreiterMainWindow::closeEvent( QCloseEvent* e )
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
@@ -33,21 +33,18 @@ class WellenreiterMainWindow: public QMainWindow
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:
@@ -55,10 +52,11 @@ class WellenreiterMainWindow: public QMainWindow
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
@@ -299,13 +299,13 @@ QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
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 )
@@ -503,35 +503,35 @@ void Wellenreiter::startClicked()
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 }