summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-05-02 20:08:30 (UTC)
committer mickeyl <mickeyl>2004-05-02 20:08:30 (UTC)
commit109ed5f2a1cdfeb3680c9ec057a1083fcf8fab95 (patch) (unidiff)
treef7484ada7bff7e4f7a91184f6a8e078af6053dca
parent8602449caa5a055bd5f033e3792d0a59a0b41bfa (diff)
downloadopie-109ed5f2a1cdfeb3680c9ec057a1083fcf8fab95.zip
opie-109ed5f2a1cdfeb3680c9ec057a1083fcf8fab95.tar.gz
opie-109ed5f2a1cdfeb3680c9ec057a1083fcf8fab95.tar.bz2
PacketViewer improvements:
- expose buffer size through API - improve packet viewer logic - display time/date of capture + capture length
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
@@ -1,184 +1,185 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Wellenreiter II. 4** This file is part of Wellenreiter II.
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/* LOCAL */ 16/* LOCAL */
17#include "configwindow.h" 17#include "configwindow.h"
18#include "mainwindow.h" 18#include "mainwindow.h"
19 19
20/* OPIE */ 20/* OPIE */
21#include <opie2/onetwork.h> 21#include <opie2/onetwork.h>
22#ifdef QWS 22#ifdef QWS
23#include <opie2/oapplication.h> 23#include <opie2/oapplication.h>
24#include <opie2/oconfig.h> 24#include <opie2/oconfig.h>
25#include <opie2/odevice.h> 25#include <opie2/odevice.h>
26#include <opie2/odebug.h> 26#include <opie2/odebug.h>
27using namespace Opie::Core; 27using namespace Opie::Core;
28using namespace Opie::Net; 28using namespace Opie::Net;
29#endif 29#endif
30 30
31/* QT */ 31/* QT */
32#include <qapplication.h> 32#include <qapplication.h>
33#include <qcheckbox.h> 33#include <qcheckbox.h>
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;
49 50
50WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) 51WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f )
51 :WellenreiterConfigBase( parent, name, true, f ) 52 :WellenreiterConfigBase( parent, name, true, f )
52{ 53{
53 _devicetype[ "cisco" ] = DEVTYPE_CISCO; 54 _devicetype[ "cisco" ] = DEVTYPE_CISCO;
54 _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; 55 _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG;
55 _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; 56 _devicetype[ "hostap" ] = DEVTYPE_HOSTAP;
56 _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; 57 _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO;
57 _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; 58 _devicetype[ "<manual>" ] = DEVTYPE_MANUAL;
58 _devicetype[ "<file>" ] = DEVTYPE_FILE; 59 _devicetype[ "<file>" ] = DEVTYPE_FILE;
59 60
60 // gather possible interface names from ONetwork 61 // gather possible interface names from ONetwork
61 ONetwork* net = ONetwork::instance(); 62 ONetwork* net = ONetwork::instance();
62 ONetwork::InterfaceIterator it = net->iterator(); 63 ONetwork::InterfaceIterator it = net->iterator();
63 while ( it.current() ) 64 while ( it.current() )
64 { 65 {
65 if ( it.current()->isWireless() ) 66 if ( it.current()->isWireless() )
66 interfaceName->insertItem( it.current()->name() ); 67 interfaceName->insertItem( it.current()->name() );
67 ++it; 68 ++it;
68 } 69 }
69 70
70 load(); 71 load();
71 72
72 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here 73 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here
73 QPushButton* okButton = new QPushButton( "ok", this ); 74 QPushButton* okButton = new QPushButton( "ok", this );
74 okButton->show(); 75 okButton->show();
75 WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui 76 WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui
76 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); 77 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
77 #endif 78 #endif
78 79
79 WellenreiterConfigWindow::_instance = this; 80 WellenreiterConfigWindow::_instance = this;
80 81
81 connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); 82 connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) );
82 connect( newNetworkAction, SIGNAL( activated(int) ), this, SLOT( changedNetworkAction(int) ) ); 83 connect( newNetworkAction, SIGNAL( activated(int) ), this, SLOT( changedNetworkAction(int) ) );
83 connect( newClientAction, SIGNAL( activated(int) ), this, SLOT( changedClientAction(int) ) ); 84 connect( newClientAction, SIGNAL( activated(int) ), this, SLOT( changedClientAction(int) ) );
84 connect( newStationAction, SIGNAL( activated(int) ), this, SLOT( changedStationAction(int) ) ); 85 connect( newStationAction, SIGNAL( activated(int) ), this, SLOT( changedStationAction(int) ) );
85 connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); 86 connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) );
86 87
87 // make the checkbox 'channelAll' control all other channels 88 // make the checkbox 'channelAll' control all other channels
88 connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); 89 connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) );
89 90
90 connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); 91 connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) );
91 92
92 // hide tab4 (parse) until Wellenreiter 1.2 93 // hide tab4 (parse) until Wellenreiter 1.2
93 tab->removePage( tab_4 ); 94 tab->removePage( tab_4 );
94}; 95};
95 96
96 97
97void WellenreiterConfigWindow::accept() 98void WellenreiterConfigWindow::accept()
98{ 99{
99 save(); 100 save();
100 QDialog::accept(); 101 QDialog::accept();
101} 102}
102 103
103 104
104WellenreiterConfigWindow::~WellenreiterConfigWindow() 105WellenreiterConfigWindow::~WellenreiterConfigWindow()
105{ 106{
106} 107}
107 108
108 109
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);
122 QString line; 123 QString line;
123 QTextStream modules( &m ); 124 QTextStream modules( &m );
124 while( !modules.atEnd() && !devicetype ) 125 while( !modules.atEnd() && !devicetype )
125 { 126 {
126 modules >> line; 127 modules >> line;
127 if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; 128 if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO;
128 else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; 129 else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP;
129 else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; 130 else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG;
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
143{ 144{
144 QString name = deviceType->currentText(); 145 QString name = deviceType->currentText();
145 if ( _devicetype.contains( name ) ) 146 if ( _devicetype.contains( name ) )
146 { 147 {
147 return _devicetype[name]; 148 return _devicetype[name];
148 } 149 }
149 else 150 else
150 { 151 {
151 return 0; 152 return 0;
152 } 153 }
153}; 154};
154 155
155 156
156int WellenreiterConfigWindow::hoppingInterval() const 157int WellenreiterConfigWindow::hoppingInterval() const
157{ 158{
158 return hopInterval->cleanText().toInt(); 159 return hopInterval->cleanText().toInt();
159} 160}
160 161
161 162
162bool WellenreiterConfigWindow::usePrismHeader() const 163bool WellenreiterConfigWindow::usePrismHeader() const
163{ 164{
164 return prismHeader->isChecked(); 165 return prismHeader->isChecked();
165} 166}
166 167
167 168
168bool WellenreiterConfigWindow::isChannelChecked( int channel ) const 169bool WellenreiterConfigWindow::isChannelChecked( int channel ) const
169{ 170{
170 switch ( channel ) 171 switch ( channel )
171 { 172 {
172 case 1: return channel1->isOn(); 173 case 1: return channel1->isOn();
173 case 2: return channel2->isOn(); 174 case 2: return channel2->isOn();
174 case 3: return channel3->isOn(); 175 case 3: return channel3->isOn();
175 case 4: return channel4->isOn(); 176 case 4: return channel4->isOn();
176 case 5: return channel5->isOn(); 177 case 5: return channel5->isOn();
177 case 6: return channel6->isOn(); 178 case 6: return channel6->isOn();
178 case 7: return channel7->isOn(); 179 case 7: return channel7->isOn();
179 case 8: return channel8->isOn(); 180 case 8: return channel8->isOn();
180 case 9: return channel9->isOn(); 181 case 9: return channel9->isOn();
181 case 10: return channel10->isOn(); 182 case 10: return channel10->isOn();
182 case 11: return channel11->isOn(); 183 case 11: return channel11->isOn();
183 case 12: return channel12->isOn(); 184 case 12: return channel12->isOn();
184 case 13: return channel13->isOn(); 185 case 13: return channel13->isOn();
@@ -192,285 +193,291 @@ void WellenreiterConfigWindow::changedDeviceType(int t)
192 if ( t != DEVTYPE_FILE ) return; 193 if ( t != DEVTYPE_FILE ) return;
193 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false); 194 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false);
194 if ( !name.isEmpty() && QFile::exists( name ) ) 195 if ( !name.isEmpty() && QFile::exists( name ) )
195 { 196 {
196 interfaceName->insertItem( name ); 197 interfaceName->insertItem( name );
197 interfaceName->setCurrentItem( interfaceName->count()-1 ); 198 interfaceName->setCurrentItem( interfaceName->count()-1 );
198 } 199 }
199 else 200 else
200 { 201 {
201 deviceType->setCurrentItem( _guess ); 202 deviceType->setCurrentItem( _guess );
202 } 203 }
203 204
204} 205}
205 206
206 207
207void WellenreiterConfigWindow::synchronizeActionsAndScripts() 208void WellenreiterConfigWindow::synchronizeActionsAndScripts()
208{ 209{
209 if ( newNetworkAction->currentItem() == 4 ) newNetworkScript->show(); else newNetworkScript->hide(); 210 if ( newNetworkAction->currentItem() == 4 ) newNetworkScript->show(); else newNetworkScript->hide();
210 if ( newClientAction->currentItem() == 4 ) newClientScript->show(); else newClientScript->hide(); 211 if ( newClientAction->currentItem() == 4 ) newClientScript->show(); else newClientScript->hide();
211 if ( newStationAction->currentItem() == 4 ) newStationScript->show(); else newStationScript->hide(); 212 if ( newStationAction->currentItem() == 4 ) newStationScript->show(); else newStationScript->hide();
212 213
213 //newNetworkScript->setEnabled( newNetworkAction->currentItem() == 4 ); 214 //newNetworkScript->setEnabled( newNetworkAction->currentItem() == 4 );
214 //newClientScript->setEnabled( newClientAction->currentItem() == 4 ); 215 //newClientScript->setEnabled( newClientAction->currentItem() == 4 );
215 //newStationScript->setEnabled( newStationAction->currentItem() == 4 ); 216 //newStationScript->setEnabled( newStationAction->currentItem() == 4 );
216} 217}
217 218
218 219
219void WellenreiterConfigWindow::changedNetworkAction(int t) 220void WellenreiterConfigWindow::changedNetworkAction(int t)
220{ 221{
221 synchronizeActionsAndScripts(); 222 synchronizeActionsAndScripts();
222} 223}
223 224
224 225
225void WellenreiterConfigWindow::changedClientAction(int t) 226void WellenreiterConfigWindow::changedClientAction(int t)
226{ 227{
227 synchronizeActionsAndScripts(); 228 synchronizeActionsAndScripts();
228} 229}
229 230
230 231
231void WellenreiterConfigWindow::changedStationAction(int t) 232void WellenreiterConfigWindow::changedStationAction(int t)
232{ 233{
233 synchronizeActionsAndScripts(); 234 synchronizeActionsAndScripts();
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
247 248
248void WellenreiterConfigWindow::channelAllClicked(int state) 249void WellenreiterConfigWindow::channelAllClicked(int state)
249{ 250{
250 bool b = state; 251 bool b = state;
251 channel1->setChecked( b ); 252 channel1->setChecked( b );
252 channel2->setChecked( b ); 253 channel2->setChecked( b );
253 channel3->setChecked( b ); 254 channel3->setChecked( b );
254 channel4->setChecked( b ); 255 channel4->setChecked( b );
255 channel5->setChecked( b ); 256 channel5->setChecked( b );
256 channel6->setChecked( b ); 257 channel6->setChecked( b );
257 channel7->setChecked( b ); 258 channel7->setChecked( b );
258 channel8->setChecked( b ); 259 channel8->setChecked( b );
259 channel9->setChecked( b ); 260 channel9->setChecked( b );
260 channel10->setChecked( b ); 261 channel10->setChecked( b );
261 channel11->setChecked( b ); 262 channel11->setChecked( b );
262 channel12->setChecked( b ); 263 channel12->setChecked( b );
263 channel13->setChecked( b ); 264 channel13->setChecked( b );
264 channel14->setChecked( b ); 265 channel14->setChecked( b );
265} 266}
266 267
267 268
268bool WellenreiterConfigWindow::useGPS() const 269bool WellenreiterConfigWindow::useGPS() const
269{ 270{
270 return enableGPS->isChecked(); 271 return enableGPS->isChecked();
271} 272}
272 273
273 274
274const QString WellenreiterConfigWindow::gpsHost() const 275const QString WellenreiterConfigWindow::gpsHost() const
275{ 276{
276 return useGPS() ? gpsdHost->currentText() : QString::null; 277 return useGPS() ? gpsdHost->currentText() : QString::null;
277} 278}
278 279
279 280
280int WellenreiterConfigWindow::gpsPort() const 281int WellenreiterConfigWindow::gpsPort() const
281{ 282{
282 bool ok; 283 bool ok;
283 return useGPS() ? gpsdPort->value() : -1; 284 return useGPS() ? gpsdPort->value() : -1;
284} 285}
285 286
286 287
287void WellenreiterConfigWindow::performAction( const QString& type, 288void WellenreiterConfigWindow::performAction( const QString& type,
288 const QString& essid, 289 const QString& essid,
289 const QString& mac, 290 const QString& mac,
290 bool wep, 291 bool wep,
291 int channel, 292 int channel,
292 int signal 293 int signal
293 /* , const GpsLocation& loc */ ) 294 /* , const GpsLocation& loc */ )
294{ 295{
295 int action; 296 int action;
296 QString script; 297 QString script;
297 298
298 if ( type == "network" ) 299 if ( type == "network" )
299 { 300 {
300 action = newNetworkAction->currentItem(); 301 action = newNetworkAction->currentItem();
301 script = newNetworkScript->text(); 302 script = newNetworkScript->text();
302 } 303 }
303 else if ( type == "managed" || type == "adhoc" ) 304 else if ( type == "managed" || type == "adhoc" )
304 { 305 {
305 action = newClientAction->currentItem(); 306 action = newClientAction->currentItem();
306 script = newClientScript->text(); 307 script = newClientScript->text();
307 } 308 }
308 else if ( type == "station" ) 309 else if ( type == "station" )
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;
326 case 3: /* Blink LED */ break; //FIXME: Implement this 327 case 3: /* Blink LED */ break; //FIXME: Implement this
327 case 4: /* Run Script */ 328 case 4: /* Run Script */
328 { 329 {
329 /** 330 /**
330 * 331 *
331 * Script Substitution Information: 332 * Script Substitution Information:
332 * 333 *
333 * $SSID = SSID 334 * $SSID = SSID
334 * $MAC = MAC 335 * $MAC = MAC
335 * $WEP = Wep 336 * $WEP = Wep
336 * $CHAN = Channel 337 * $CHAN = Channel
337 * 338 *
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
353 354
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" );
367 368
368 QString interface = c->readEntry( "name", "<none>" ); 369 QString interface = c->readEntry( "name", "<none>" );
369 if ( interface != "<none>" ) 370 if ( interface != "<none>" )
370 { 371 {
371#if QT_VERSION < 300 372#if QT_VERSION < 300
372 interfaceName->insertItem( interface, 0 ); 373 interfaceName->insertItem( interface, 0 );
373 interfaceName->setCurrentItem( 0 ); 374 interfaceName->setCurrentItem( 0 );
374#else 375#else
375 interfaceName->setCurrentText( interface ); 376 interfaceName->setCurrentText( interface );
376#endif 377#endif
377 378
378 QString device = c->readEntry( "type", "<select>" ); 379 QString device = c->readEntry( "type", "<select>" );
379#if QT_VERSION < 300 380#if QT_VERSION < 300
380 for ( int i = 0; i < deviceType->count(); ++i ) 381 for ( int i = 0; i < deviceType->count(); ++i )
381 { 382 {
382 if ( deviceType->text( i ) == device ) 383 if ( deviceType->text( i ) == device )
383 { 384 {
384 deviceType->setCurrentItem( i ); 385 deviceType->setCurrentItem( i );
385 break; 386 break;
386 } 387 }
387 } 388 }
388#else 389#else
389 deviceType->setCurrentText( device ); 390 deviceType->setCurrentText( device );
390#endif 391#endif
391 } 392 }
392 else 393 else
393 { 394 {
394 performAutodetection(); 395 performAutodetection();
395 } 396 }
396 397
397 prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); 398 prismHeader->setChecked( c->readBoolEntry( "prism", false ) );
398 hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); 399 hopChannels->setChecked( c->readBoolEntry( "hop", true ) );
399 hopInterval->setValue( c->readNumEntry( "interval", 250 ) ); 400 hopInterval->setValue( c->readNumEntry( "interval", 250 ) );
400 adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); 401 adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) );
401 402
402 c->setGroup( "Capture" ); 403 c->setGroup( "Capture" );
403 captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); 404 captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) );
404 405
405 c->setGroup( "UI" ); 406 c->setGroup( "UI" );
406 lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); 407 lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) );
407 openTree->setChecked( c->readBoolEntry( "openTree", true ) ); 408 openTree->setChecked( c->readBoolEntry( "openTree", true ) );
408 disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); 409 disablePM->setChecked( c->readBoolEntry( "disablePM", true ) );
409 newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 1 ) ); // Default: Play Alarm 410 newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 1 ) ); // Default: Play Alarm
410 newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) ); 411 newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) );
411 newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 2 ) ); // Default: Play Click 412 newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 2 ) ); // Default: Play Click
412 newClientScript->setText( c->readEntry( "newClientScript", "" ) ); 413 newClientScript->setText( c->readEntry( "newClientScript", "" ) );
413 newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 2 ) ); // Default: Play Click 414 newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 2 ) ); // Default: Play Click
414 newStationScript->setText( c->readEntry( "newStationScript", "" ) ); 415 newStationScript->setText( c->readEntry( "newStationScript", "" ) );
415 synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand 416 synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand
416 417
417 c->setGroup( "GPS" ); 418 c->setGroup( "GPS" );
418 enableGPS->setChecked( c->readBoolEntry( "use", false ) ); 419 enableGPS->setChecked( c->readBoolEntry( "use", false ) );
419#if QT_VERSION < 300 420#if QT_VERSION < 300
420 gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); 421 gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 );
421 gpsdHost->setCurrentItem( 0 ); 422 gpsdHost->setCurrentItem( 0 );
422#else 423#else
423 gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); 424 gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) );
424#endif 425#endif
425 gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); 426 gpsdPort->setValue( c->readNumEntry( "port", 2947 ) );
426 startGPS->setChecked( c->readBoolEntry( "start", false ) ); 427 startGPS->setChecked( c->readBoolEntry( "start", false ) );
427 commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); 428 commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) );
428 429
429#endif 430#endif
430} 431}
431 432
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" );
445 c->writeEntry( "name", interfaceName->currentText() ); 446 c->writeEntry( "name", interfaceName->currentText() );
446 c->writeEntry( "type", deviceType->currentText() ); 447 c->writeEntry( "type", deviceType->currentText() );
447 c->writeEntry( "prism", prismHeader->isChecked() ); 448 c->writeEntry( "prism", prismHeader->isChecked() );
448 c->writeEntry( "hop", hopChannels->isChecked() ); 449 c->writeEntry( "hop", hopChannels->isChecked() );
449 c->writeEntry( "interval", hopInterval->value() ); 450 c->writeEntry( "interval", hopInterval->value() );
450 c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); 451 c->writeEntry( "adaptive", adaptiveHopping->isChecked() );
451 452
452 c->setGroup( "Capture" ); 453 c->setGroup( "Capture" );
453 c->writeEntry( "filename", captureFileName->text() ); 454 c->writeEntry( "filename", captureFileName->text() );
454 455
455 c->setGroup( "UI" ); 456 c->setGroup( "UI" );
456 c->writeEntry( "lookupVendor", lookupVendor->isChecked() ); 457 c->writeEntry( "lookupVendor", lookupVendor->isChecked() );
457 c->writeEntry( "openTree", openTree->isChecked() ); 458 c->writeEntry( "openTree", openTree->isChecked() );
458 c->writeEntry( "disablePM", disablePM->isChecked() ); 459 c->writeEntry( "disablePM", disablePM->isChecked() );
459 c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() ); 460 c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() );
460 c->writeEntry( "newNetworkScript", newNetworkScript->text() ); 461 c->writeEntry( "newNetworkScript", newNetworkScript->text() );
461 c->writeEntry( "newClientAction", newClientAction->currentItem() ); 462 c->writeEntry( "newClientAction", newClientAction->currentItem() );
462 c->writeEntry( "newClientScript", newClientScript->text() ); 463 c->writeEntry( "newClientScript", newClientScript->text() );
463 c->writeEntry( "newStationAction", newStationAction->currentItem() ); 464 c->writeEntry( "newStationAction", newStationAction->currentItem() );
464 c->writeEntry( "newStationScript", newStationScript->text() ); 465 c->writeEntry( "newStationScript", newStationScript->text() );
465 466
466 c->setGroup( "GPS" ); 467 c->setGroup( "GPS" );
467 c->writeEntry( "use", enableGPS->isChecked() ); 468 c->writeEntry( "use", enableGPS->isChecked() );
468 c->writeEntry( "host", gpsdHost->currentText() ); 469 c->writeEntry( "host", gpsdHost->currentText() );
469 c->writeEntry( "port", gpsdPort->value() ); 470 c->writeEntry( "port", gpsdPort->value() );
470 c->writeEntry( "start", startGPS->isChecked() ); 471 c->writeEntry( "start", startGPS->isChecked() );
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
@@ -13,70 +13,72 @@
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef WELLENREITERCONFIGWINDOW_H 16#ifndef WELLENREITERCONFIGWINDOW_H
17#define WELLENREITERCONFIGWINDOW_H 17#define WELLENREITERCONFIGWINDOW_H
18 18
19#include "configbase.h" 19#include "configbase.h"
20#include "gps.h" 20#include "gps.h"
21 21
22/* QT */ 22/* QT */
23#include <qmap.h> 23#include <qmap.h>
24#include <qcombobox.h> 24#include <qcombobox.h>
25#include <qstring.h> 25#include <qstring.h>
26 26
27const int DEVTYPE_SELECT = 0; 27const int DEVTYPE_SELECT = 0;
28const int DEVTYPE_CISCO = 1; 28const int DEVTYPE_CISCO = 1;
29const int DEVTYPE_WLAN_NG = 2; 29const int DEVTYPE_WLAN_NG = 2;
30const int DEVTYPE_HOSTAP = 3; 30const int DEVTYPE_HOSTAP = 3;
31const int DEVTYPE_ORINOCO = 4; 31const int DEVTYPE_ORINOCO = 4;
32const int DEVTYPE_MANUAL = 5; 32const int DEVTYPE_MANUAL = 5;
33const int DEVTYPE_FILE = 6; 33const int DEVTYPE_FILE = 6;
34 34
35class WellenreiterConfigWindow; 35class WellenreiterConfigWindow;
36 36
37class WellenreiterConfigWindow : public WellenreiterConfigBase 37class WellenreiterConfigWindow : public WellenreiterConfigBase
38{ 38{
39 Q_OBJECT 39 Q_OBJECT
40 40
41 public: 41 public:
42 WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 ); 42 WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 );
43 ~WellenreiterConfigWindow(); 43 ~WellenreiterConfigWindow();
44 44
45 int driverType() const; 45 int driverType() const;
46 const QString soundOnNetwork() const { return "";/*netSound->currentText();*/ }; 46 const QString soundOnNetwork() const { return "";/*netSound->currentText();*/ };
47 const QString soundOnBeacon() const { return "";/*beaconSound->currentText();*/ }; 47 const QString soundOnBeacon() const { return "";/*beaconSound->currentText();*/ };
48 static WellenreiterConfigWindow* instance() { return _instance; }; 48 static WellenreiterConfigWindow* instance() { return _instance; };
49 49
50 int hoppingInterval() const; 50 int hoppingInterval() const;
51 bool usePrismHeader() const; 51 bool usePrismHeader() const;
52 bool isChannelChecked( int ) const; 52 bool isChannelChecked( int ) const;
53 53
54 bool useGPS() const; 54 bool useGPS() const;
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();
67 void performAutodetection(); 69 void performAutodetection();
68 void channelAllClicked(int); 70 void channelAllClicked(int);
69 void performAction( const QString&, const QString&, const QString&, bool, int, int /* , const GpsLocation& */ ); 71 void performAction( const QString&, const QString&, const QString&, bool, int, int /* , const GpsLocation& */ );
70 72
71 protected slots: 73 protected slots:
72 void synchronizeActionsAndScripts(); 74 void synchronizeActionsAndScripts();
73 virtual void accept(); 75 virtual void accept();
74 76
75 protected: 77 protected:
76 QMap<QString, int> _devicetype; 78 QMap<QString, int> _devicetype;
77 static WellenreiterConfigWindow* _instance; 79 static WellenreiterConfigWindow* _instance;
78 int _guess; 80 int _guess;
79 81
80}; 82};
81 83
82#endif 84#endif
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
@@ -1,121 +1,151 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Wellenreiter II. 4** This file is part of Wellenreiter II.
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#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>
28#include <qlistview.h> 29#include <qlistview.h>
29#include <qobjectlist.h> 30#include <qobjectlist.h>
30#include <qspinbox.h> 31#include <qspinbox.h>
31#include <qtextview.h> 32#include <qtextview.h>
32 33
33using namespace Opie::Net; 34using namespace Opie::Net;
34using namespace Opie::Core; 35using 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;
94 QObject* o = l->first(); 121 QObject* o = l->first();
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
112void PacketView::clear() 142void 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
@@ -1,60 +1,62 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Wellenreiter II. 4** This file is part of Wellenreiter II.
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 PACKETVIEW_H 16#ifndef PACKETVIEW_H
17#define PACKETVIEW_H 17#define PACKETVIEW_H
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
59#endif 61#endif
60 62
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
@@ -368,97 +368,97 @@ void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source,
368 368
369 369
370QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 370QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
371{ 371{
372 if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) 372 if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
373 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) 373 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
374 return 0; 374 return 0;
375 375
376 return p->child( protocol ); 376 return p->child( protocol );
377} 377}
378 378
379 379
380bool Wellenreiter::checkDumpPacket( OPacket* p ) 380bool Wellenreiter::checkDumpPacket( OPacket* p )
381{ 381{
382 // go through all child packets and see if one is inside the child hierarchy for p 382 // go through all child packets and see if one is inside the child hierarchy for p
383 // if so, do what the user requested (protocolAction), e.g. pass or discard 383 // if so, do what the user requested (protocolAction), e.g. pass or discard
384 if ( !configwindow->writeCaptureFile->isChecked() ) 384 if ( !configwindow->writeCaptureFile->isChecked() )
385 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter 385 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter
386 386
387 QObjectList* l = p->queryList(); 387 QObjectList* l = p->queryList();
388 QObjectListIt it( *l ); 388 QObjectListIt it( *l );
389 QObject* o; 389 QObject* o;
390 390
391 while ( (o = it.current()) != 0 ) 391 while ( (o = it.current()) != 0 )
392 { 392 {
393 QString name = it.current()->name(); 393 QString name = it.current()->name();
394 if ( configwindow->capturePackets->isProtocolChecked( name ) ) 394 if ( configwindow->capturePackets->isProtocolChecked( name ) )
395 { 395 {
396 QString action = configwindow->capturePackets->protocolAction( name ); 396 QString action = configwindow->capturePackets->protocolAction( name );
397 odebug << "capturePackets-action for '" << (const char*) name << "' seems to be '" << action << "'" << oendl; 397 odebug << "capturePackets-action for '" << (const char*) name << "' seems to be '" << action << "'" << oendl;
398 if ( action == "Discard" ) 398 if ( action == "Discard" )
399 { 399 {
400 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); 400 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) );
401 return false; 401 return false;
402 } 402 }
403 } 403 }
404 else 404 else
405 { 405 {
406 odebug << "protocol '" << name << "' not checked in capturePackets." << oendl; 406 odebug << "protocol '" << name << "' not checked in capturePackets." << oendl;
407 } 407 }
408 ++it; 408 ++it;
409 } 409 }
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
423 // check for a management frame 423 // check for a management frame
424 OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); 424 OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) );
425 if ( manage ) 425 if ( manage )
426 { 426 {
427 handleManagementFrame( p, manage ); 427 handleManagementFrame( p, manage );
428 return; 428 return;
429 } 429 }
430 430
431 // check for a control frame 431 // check for a control frame
432 OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) ); 432 OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) );
433 if ( control ) 433 if ( control )
434 { 434 {
435 handleControlFrame( p, control ); 435 handleControlFrame( p, control );
436 return; 436 return;
437 } 437 }
438 438
439 OMacAddress source; 439 OMacAddress source;
440 OMacAddress dest; 440 OMacAddress dest;
441 441
442 //TODO: WEP check here 442 //TODO: WEP check here
443 443
444 // check for a wireless data frame 444 // check for a wireless data frame
445 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); 445 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
446 if ( wlan ) 446 if ( wlan )
447 { 447 {
448 handleWlanData( p, wlan, source, dest ); 448 handleWlanData( p, wlan, source, dest );
449 } 449 }
450 450
451 // check for a wired data frame 451 // check for a wired data frame
452 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); 452 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) );
453 if ( eth ) 453 if ( eth )
454 { 454 {
455 handleEthernetData( p, eth, source, dest ); 455 handleEthernetData( p, eth, source, dest );
456 } 456 }
457 457
458 // check for an arp frame since arp frames come in two flavours: 458 // check for an arp frame since arp frames come in two flavours:
459 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't. 459 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't.
460 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) ); 460 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) );
461 if ( arp ) 461 if ( arp )
462 { 462 {
463 handleARPData( p, arp, source, dest ); 463 handleARPData( p, arp, source, dest );
464 } 464 }