summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.cpp27
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.h2
-rw-r--r--noncore/net/wellenreiter/gui/packetview.cpp68
-rw-r--r--noncore/net/wellenreiter/gui/packetview.h12
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp2
5 files changed, 76 insertions, 35 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp
index 279b39c..89ed24c 100644
--- a/noncore/net/wellenreiter/gui/configwindow.cpp
+++ b/noncore/net/wellenreiter/gui/configwindow.cpp
@@ -34,15 +34,16 @@ using namespace Opie::Net;
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qlineedit.h> 36#include <qlineedit.h>
37#include <qlayout.h> 37#include <qlayout.h>
38#include <qmap.h> 38#include <qmap.h>
39#include <qpushbutton.h> 39#include <qpushbutton.h>
40#include <qradiobutton.h>
41#include <qspinbox.h>
40#include <qtabwidget.h> 42#include <qtabwidget.h>
41#include <qtoolbutton.h> 43#include <qtoolbutton.h>
42#include <qspinbox.h>
43#include <qtextstream.h> 44#include <qtextstream.h>
44 45
45/* STD */ 46/* STD */
46#include <assert.h> 47#include <assert.h>
47 48
48WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; 49WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0;
@@ -109,13 +110,13 @@ WellenreiterConfigWindow::~WellenreiterConfigWindow()
109void WellenreiterConfigWindow::performAutodetection() 110void WellenreiterConfigWindow::performAutodetection()
110{ 111{
111 //TODO: insert modal splash screen here 112 //TODO: insert modal splash screen here
112 // and sleep a second, so that it looks 113 // and sleep a second, so that it looks
113 // like we're actually doing something fancy... ;-) 114 // like we're actually doing something fancy... ;-)
114 115
115 odebug << "WellenreiterConfigWindow::performAutodetection()" << oendl; 116 odebug << "WellenreiterConfigWindow::performAutodetection()" << oendl;
116 117
117 // try to guess device type 118 // try to guess device type
118 QFile m( "/proc/modules" ); 119 QFile m( "/proc/modules" );
119 if ( m.open( IO_ReadOnly ) ) 120 if ( m.open( IO_ReadOnly ) )
120 { 121 {
121 int devicetype(0); 122 int devicetype(0);
@@ -130,13 +131,13 @@ void WellenreiterConfigWindow::performAutodetection()
130 else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; 131 else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO;
131 } 132 }
132 if ( devicetype ) 133 if ( devicetype )
133 { 134 {
134 deviceType->setCurrentItem( devicetype ); 135 deviceType->setCurrentItem( devicetype );
135 _guess = devicetype; 136 _guess = devicetype;
136 odebug << "Wellenreiter: guessed device type to be #" << devicetype << "" << oendl; 137 odebug << "Wellenreiter: guessed device type to be #" << devicetype << "" << oendl;
137 } 138 }
138 } 139 }
139} 140}
140 141
141 142
142int WellenreiterConfigWindow::driverType() const 143int WellenreiterConfigWindow::driverType() const
@@ -234,13 +235,13 @@ void WellenreiterConfigWindow::changedStationAction(int t)
234} 235}
235 236
236 237
237void WellenreiterConfigWindow::getCaptureFileNameClicked() 238void WellenreiterConfigWindow::getCaptureFileNameClicked()
238{ 239{
239 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); 240 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true);
240 odebug << "name = " << name << "" << oendl; 241 odebug << "name = " << name << "" << oendl;
241 if ( !name.isEmpty() ) 242 if ( !name.isEmpty() )
242 { 243 {
243 captureFileName->setText( name ); 244 captureFileName->setText( name );
244 } 245 }
245} 246}
246 247
@@ -309,17 +310,17 @@ void WellenreiterConfigWindow::performAction( const QString& type,
309 { 310 {
310 action = newStationAction->currentItem(); 311 action = newStationAction->currentItem();
311 script = newStationScript->text(); 312 script = newStationScript->text();
312 } 313 }
313 else 314 else
314 { 315 {
315 owarn << "WellenreiterConfigWindow::performAction(): unknown type '" << type << "'" << oendl; 316 owarn << "WellenreiterConfigWindow::performAction(): unknown type '" << type << "'" << oendl;
316 return; 317 return;
317 } 318 }
318 319
319 odebug << "for event '" << (const char*) type << "' I'm going to perform action " << action << " (script='" << script << "')" << oendl; 320 odebug << "for event '" << (const char*) type << "' I'm going to perform action " << action << " (script='" << script << "')" << oendl;
320 321
321 switch( action ) 322 switch( action )
322 { 323 {
323 case 0: /* Ignore */ return; 324 case 0: /* Ignore */ return;
324 case 1: /* Play Alarm */ ODevice::inst()->playAlarmSound(); return; 325 case 1: /* Play Alarm */ ODevice::inst()->playAlarmSound(); return;
325 case 2: /* Play Click */ ODevice::inst()->playTouchSound(); return; 326 case 2: /* Play Click */ ODevice::inst()->playTouchSound(); return;
@@ -338,15 +339,15 @@ void WellenreiterConfigWindow::performAction( const QString& type,
338 **/ 339 **/
339 script = script.replace( QRegExp( "$SSID" ), essid ); 340 script = script.replace( QRegExp( "$SSID" ), essid );
340 script = script.replace( QRegExp( "$MAC" ), mac ); 341 script = script.replace( QRegExp( "$MAC" ), mac );
341 script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); 342 script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) );
342 script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); 343 script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) );
343 344
344 odebug << "going to call script '" << script << "'" << oendl; 345 odebug << "going to call script '" << script << "'" << oendl;
345 ::system( script ); 346 ::system( script );
346 odebug << "script returned." << oendl; 347 odebug << "script returned." << oendl;
347 return; 348 return;
348 } 349 }
349 default: assert( false ); 350 default: assert( false );
350 } 351 }
351} 352}
352 353
@@ -354,13 +355,13 @@ void WellenreiterConfigWindow::performAction( const QString& type,
354void WellenreiterConfigWindow::load() 355void WellenreiterConfigWindow::load()
355{ 356{
356#ifdef Q_WS_X11 357#ifdef Q_WS_X11
357 #warning Persistent Configuration not yet implemented for standalone X11 build 358 #warning Persistent Configuration not yet implemented for standalone X11 build
358 performAutodetection(); 359 performAutodetection();
359#else 360#else
360 odebug << "loading configuration settings..." << oendl; 361 odebug << "loading configuration settings..." << oendl;
361 362
362 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ 363 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */
363 364
364 OConfig* c = oApp->config(); 365 OConfig* c = oApp->config();
365 366
366 c->setGroup( "Interface" ); 367 c->setGroup( "Interface" );
@@ -432,13 +433,13 @@ void WellenreiterConfigWindow::load()
432 433
433void WellenreiterConfigWindow::save() 434void WellenreiterConfigWindow::save()
434{ 435{
435#ifdef Q_WS_X11 436#ifdef Q_WS_X11
436 #warning Persistent Configuration not yet implemented for standalone X11 build 437 #warning Persistent Configuration not yet implemented for standalone X11 build
437#else 438#else
438 odebug << "saving configuration settings..." << oendl; 439 odebug << "saving configuration settings..." << oendl;
439 440
440 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ 441 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */
441 442
442 OConfig* c = oApp->config(); 443 OConfig* c = oApp->config();
443 444
444 c->setGroup( "Interface" ); 445 c->setGroup( "Interface" );
@@ -471,6 +472,12 @@ void WellenreiterConfigWindow::save()
471 c->writeEntry( "command", commandGPS->text() ); 472 c->writeEntry( "command", commandGPS->text() );
472 473
473 c->write(); 474 c->write();
474 475
475#endif 476#endif
476} 477}
478
479
480int WellenreiterConfigWindow::hexViewBuffer() const
481{
482 return hexViewBufferUnlimited->isChecked() ? -1 : hexViewBufferSize->value();
483}
diff --git a/noncore/net/wellenreiter/gui/configwindow.h b/noncore/net/wellenreiter/gui/configwindow.h
index 0a5b3bd..2d478e7 100644
--- a/noncore/net/wellenreiter/gui/configwindow.h
+++ b/noncore/net/wellenreiter/gui/configwindow.h
@@ -55,12 +55,14 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase
55 const QString gpsHost() const; 55 const QString gpsHost() const;
56 int gpsPort() const; 56 int gpsPort() const;
57 57
58 void save(); 58 void save();
59 void load(); 59 void load();
60 60
61 int hexViewBuffer() const;
62
61 public slots: 63 public slots:
62 void changedDeviceType(int); 64 void changedDeviceType(int);
63 void changedNetworkAction(int t); 65 void changedNetworkAction(int t);
64 void changedClientAction(int t); 66 void changedClientAction(int t);
65 void changedStationAction(int t); 67 void changedStationAction(int t);
66 void getCaptureFileNameClicked(); 68 void getCaptureFileNameClicked();
diff --git a/noncore/net/wellenreiter/gui/packetview.cpp b/noncore/net/wellenreiter/gui/packetview.cpp
index 4df01da..f0f16ff 100644
--- a/noncore/net/wellenreiter/gui/packetview.cpp
+++ b/noncore/net/wellenreiter/gui/packetview.cpp
@@ -16,12 +16,13 @@
16#include "packetview.h" 16#include "packetview.h"
17 17
18/* OPIE */ 18/* OPIE */
19#include <opie2/opcap.h> 19#include <opie2/opcap.h>
20#include <opie2/odebug.h> 20#include <opie2/odebug.h>
21#include <opie2/olistview.h> 21#include <opie2/olistview.h>
22#include <opie2/oapplication.h>
22 23
23/* QT */ 24/* QT */
24#include <qfont.h> 25#include <qfont.h>
25#include <qlabel.h> 26#include <qlabel.h>
26#include <qlayout.h> 27#include <qlayout.h>
27#include <qlist.h> 28#include <qlist.h>
@@ -35,59 +36,85 @@ using namespace Opie::Core;
35using namespace Opie::Ui; 36using namespace Opie::Ui;
36 37
37PacketView::PacketView( QWidget * parent, const char * name, WFlags f ) 38PacketView::PacketView( QWidget * parent, const char * name, WFlags f )
38 :QFrame( parent, name, f ) 39 :QFrame( parent, name, f )
39{ 40{
40 _number = new QSpinBox( this ); 41 _number = new QSpinBox( this );
41 _number->setPrefix( "Packet # " ); 42 _number->setPrefix( "Pkt# " );
42 _label = new QLabel( this ); 43 _label = new QLabel( this );
43 _label->setText( "eth0 2004/03/08 - 00:00:21" );
44
45 _list = new OListView( this ); 44 _list = new OListView( this );
46 _list->addColumn( "#" ); 45 _list->addColumn( "#" );
47 _list->addColumn( "Packet Type" ); 46 _list->addColumn( "Packet Type" );
48 _list->setColumnAlignment( 0, Qt::AlignCenter ); 47 _list->setColumnAlignment( 0, Qt::AlignCenter );
49 _list->setColumnAlignment( 1, Qt::AlignLeft ); 48 _list->setColumnAlignment( 1, Qt::AlignLeft );
50 _list->setAllColumnsShowFocus( true ); 49 _list->setAllColumnsShowFocus( true );
51 _list->setFont( QFont( "Fixed", 8 ) ); 50 _list->setFont( QFont( "Fixed", 8 ) );
52 51
53 _hex = new QTextView( this ); 52 _hex = new QTextView( this );
53 _hex->setMargin( 0 );
54 _hex->setFont( QFont( "Fixed", 8 ) ); 54 _hex->setFont( QFont( "Fixed", 8 ) );
55 55
56 QVBoxLayout* vb = new QVBoxLayout( this, 2, 2 ); 56 QVBoxLayout* vb = new QVBoxLayout( this, 2, 2 );
57 QHBoxLayout* hb = new QHBoxLayout( vb, 2 ); 57 QHBoxLayout* hb = new QHBoxLayout( vb, 2 );
58 hb->addWidget( _label ); 58 hb->addWidget( _label, 5 );
59 hb->addWidget( _number ); 59 hb->addWidget( _number, 2 );
60 vb->addWidget( _list ); 60 vb->addWidget( _list, 3 );
61 vb->addWidget( _hex ); 61 vb->addWidget( _hex, 4 ); // allow a bit (4/3) more space
62 62
63 _packets.setAutoDelete( true ); 63 _packets.setAutoDelete( true );
64 64
65 connect( _number, SIGNAL( valueChanged( int ) ), this, SLOT( showPacket( int ) ) ); 65 connect( _number, SIGNAL( valueChanged( int ) ), this, SLOT( showPacket( int ) ) );
66 connect( parent, SIGNAL( currentChanged( QWidget *) ), this, SLOT( activated( QWidget* ) ) );
67
68 clear();
69
66} 70}
67 71
68void PacketView::add( const OPacket* p ) 72void PacketView::add( const OPacket* p, int size )
69{ 73{
70 _packets.append( p ); 74 odebug << "PacketView::add() size = " << size << oendl;
71 // Add Circular Buffer and check for number of elements here 75 if ( size == -1 ) // unlimited buffer
76 {
77 _packets.append( p );
78 }
79 else
80 // limited buffer, limit = size
81 if ( _packets.count() < size )
82 {
83 _packets.append( p );
84 }
85
86 _number->setMinValue( 1 );
87 _number->setMaxValue( _packets.count() );
88 _number->setValue( _packets.count() );
72} 89}
73 90
74void PacketView::showPacket( int number ) 91void PacketView::showPacket( int number )
75{ 92{
76 _list->clear(); 93 _list->clear();
77 _hex->setText(""); 94 _hex->setText("");
78 const OPacket* p = _packets.at( number ); 95 const OPacket* p = _packets.at( number-1 );
79 96
80 if ( p ) 97 if ( p )
81 { 98 {
82 _doSubPackets( const_cast<QObjectList*>( p->children() ), 0 ); 99 _doSubPackets( const_cast<QObjectList*>( p->children() ), 0 );
83 _doHexPacket( p ); 100 _doHexPacket( p );
101 QDateTime dt; dt.setTime_t( p->timeval().tv_sec );
102 _label->setText( dt.toString() + QString().sprintf( " Len=%d", p->len() ) );
84 } 103 }
85 else 104 else
86 { 105 {
87 odebug << "D'oh! No packet!" << oendl; 106 odebug << "D'oh! No packet!" << oendl;
107 }
108}
109
110void PacketView::activated( QWidget* w )
111{
112 if ( ( this == w ) && _packets.count() )
113 {
114 _number->setValue( 1 );
88 } 115 }
89} 116}
90 117
91void PacketView::_doSubPackets( QObjectList* l, int counter ) 118void PacketView::_doSubPackets( QObjectList* l, int counter )
92{ 119{
93 if (!l) return; 120 if (!l) return;
@@ -95,17 +122,20 @@ void PacketView::_doSubPackets( QObjectList* l, int counter )
95 while ( o ) 122 while ( o )
96 { 123 {
97 new OListViewItem( _list, QString::number( counter++ ), o->name() ); 124 new OListViewItem( _list, QString::number( counter++ ), o->name() );
98 _doSubPackets( const_cast<QObjectList*>( o->children() ), counter ); 125 _doSubPackets( const_cast<QObjectList*>( o->children() ), counter );
99 o = l->next(); 126 o = l->next();
100 } 127 }
101} 128}
102 129
103void PacketView::_doHexPacket( const OPacket* p ) 130void PacketView::_doHexPacket( const OPacket* p )
104{ 131{
105 _hex->setText( p->dump( 16 ) ); 132 if ( oApp->desktop()->width() > 320 )
133 _hex->setText( p->dump( 16 ) );
134 else
135 _hex->setText( p->dump( 8 ) );
106} 136}
107 137
108const QString PacketView::getLog() const 138const QString PacketView::getLog() const
109{ 139{
110} 140}
111 141
@@ -113,9 +143,9 @@ void PacketView::clear()
113{ 143{
114 _packets.clear(); 144 _packets.clear();
115 _number->setMinValue( 0 ); 145 _number->setMinValue( 0 );
116 _number->setMaxValue( 0 ); 146 _number->setMaxValue( 0 );
117 _label->setText( "---" ); 147 _label->setText( "---" );
118 _list->clear(); 148 _list->clear();
119 _hex->setText( " <i>-- no Packet available --</i> " ); 149 _hex->setText( " <center><i>-- no Packet available --</i></center> " );
120} 150}
121 151
diff --git a/noncore/net/wellenreiter/gui/packetview.h b/noncore/net/wellenreiter/gui/packetview.h
index 42e8f5d..bb366c5 100644
--- a/noncore/net/wellenreiter/gui/packetview.h
+++ b/noncore/net/wellenreiter/gui/packetview.h
@@ -18,41 +18,43 @@
18 18
19#include <qlist.h> 19#include <qlist.h>
20#include <qframe.h> 20#include <qframe.h>
21 21
22#include <opie2/opcap.h> 22#include <opie2/opcap.h>
23 23
24class QWidget;
24class QLabel; 25class QLabel;
25class QString; 26class QString;
26class QSpinBox; 27class QSpinBox;
27class QTextView; 28class QTextView;
28class QObjectList; 29class QObjectList;
29namespace Opie {namespace Net {class OPacket;}} 30namespace Opie {namespace Net {class OPacket;}}
30namespace Opie {namespace Ui {class OListView;}} 31namespace Opie {namespace Ui {class OListView;}}
31 32
32class PacketView: public QFrame 33class PacketView: public QFrame
33{ 34{
34 Q_OBJECT 35 Q_OBJECT
35 36
36 public: 37 public:
37 PacketView( QWidget * parent = 0, const char * name = "PacketView", WFlags f = 0 ); 38 PacketView( QWidget * parent = 0, const char * name = "PacketView", WFlags f = 0 );
38 39
39 void add( const Opie::Net::OPacket* p ); 40 void add( const Opie::Net::OPacket* p, int size );
40 const QString getLog() const; 41 const QString getLog() const;
41 void clear(); 42 void clear();
42 43
43 public slots: 44 public slots:
44 void showPacket( int number ); 45 void showPacket( int number );
46 void activated( QWidget* );
45 47
46 protected: 48 protected:
47 QSpinBox* _number; 49 QSpinBox* _number;
48 QLabel* _label; 50 QLabel* _label;
49 Opie::Ui::OListView* _list; 51 Opie::Ui::OListView* _list;
50 QTextView* _hex; 52 QTextView* _hex;
51 QList<const Opie::Net::OPacket> _packets; 53 QList<const Opie::Net::OPacket> _packets;
52 54
53 protected: 55 protected:
54 void _doSubPackets( QObjectList*, int ); 56 void _doSubPackets( QObjectList*, int );
55 void _doHexPacket( const Opie::Net::OPacket* ); 57 void _doHexPacket( const Opie::Net::OPacket* );
56 58
57}; 59};
58 60
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 12b3978..fe8f22d 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -410,13 +410,13 @@ bool Wellenreiter::checkDumpPacket( OPacket* p )
410 return true; 410 return true;
411} 411}
412 412
413 413
414void Wellenreiter::receivePacket( OPacket* p ) 414void Wellenreiter::receivePacket( OPacket* p )
415{ 415{
416 hexWindow()->add( p ); 416 hexWindow()->add( p, configwindow->hexViewBuffer() );
417 417
418 if ( checkDumpPacket( p ) ) 418 if ( checkDumpPacket( p ) )
419 { 419 {
420 pcap->dump( p ); 420 pcap->dump( p );
421 } 421 }
422 422