summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-04-05 23:08:46 (UTC)
committer mickeyl <mickeyl>2003-04-05 23:08:46 (UTC)
commitb7682f160fafe69bfd47dcfb1c88f2ac2b1afaf5 (patch) (unidiff)
tree68c5a0c5da88fff94582d2e6a072d8e9bbeaaf30
parent6a949f685bd3fb50f810ad603eaafdb57720077c (diff)
downloadopie-b7682f160fafe69bfd47dcfb1c88f2ac2b1afaf5.zip
opie-b7682f160fafe69bfd47dcfb1c88f2ac2b1afaf5.tar.gz
opie-b7682f160fafe69bfd47dcfb1c88f2ac2b1afaf5.tar.bz2
- correct beacon bug (off-by-one)
- display hex dump per packet in hex window - allow saving hex window contents
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/hexwindow.cpp10
-rw-r--r--noncore/net/wellenreiter/gui/hexwindow.h1
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp23
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.h1
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp4
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp5
6 files changed, 38 insertions, 6 deletions
diff --git a/noncore/net/wellenreiter/gui/hexwindow.cpp b/noncore/net/wellenreiter/gui/hexwindow.cpp
index a3022f4..8b17285 100644
--- a/noncore/net/wellenreiter/gui/hexwindow.cpp
+++ b/noncore/net/wellenreiter/gui/hexwindow.cpp
@@ -1,39 +1,45 @@
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#include "hexwindow.h" 16#include "hexwindow.h"
17#include <qmultilineedit.h> 17#include <qmultilineedit.h>
18 18
19MHexWindow::MHexWindow( QWidget * parent, const char * name, WFlags f ) 19MHexWindow::MHexWindow( QWidget * parent, const char * name, WFlags f )
20 :QVBox( parent, name, f ) 20 :QVBox( parent, name, f )
21{ 21{
22 ledit = new QMultiLineEdit( this ); 22 ledit = new QMultiLineEdit( this );
23 23 ledit->setFont( QFont( "fixed", 10 ) );
24
24 // FIXME: Set properties( font, read-only, etc...) 25 // FIXME: Set properties( font, read-only, etc...)
25 26
26}; 27};
27 28
28void MHexWindow::log( QString text ) 29void MHexWindow::log( QString text )
29{ 30{
30 31
31 ledit->append( text ); 32 ledit->append( text );
32 33
33}; 34};
34 35
36const QString MHexWindow::getLog() const
37{
38 return ledit->text();
39}
40
35void MHexWindow::clear() 41void MHexWindow::clear()
36{ 42{
37 ledit->clear(); 43 ledit->clear();
38} 44}
39 45
diff --git a/noncore/net/wellenreiter/gui/hexwindow.h b/noncore/net/wellenreiter/gui/hexwindow.h
index 2618b8c..f2f870c 100644
--- a/noncore/net/wellenreiter/gui/hexwindow.h
+++ b/noncore/net/wellenreiter/gui/hexwindow.h
@@ -1,39 +1,40 @@
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 HEXWINDOW_H 16#ifndef HEXWINDOW_H
17#define HEXWINDOW_H 17#define HEXWINDOW_H
18 18
19#include <qvbox.h> 19#include <qvbox.h>
20 20
21class QString; 21class QString;
22class QMultiLineEdit; 22class QMultiLineEdit;
23 23
24class MHexWindow: public QVBox 24class MHexWindow: public QVBox
25{ 25{
26 26
27 public: 27 public:
28 MHexWindow( QWidget * parent = 0, const char * name = "MHexWindow", WFlags f = 0 ); 28 MHexWindow( QWidget * parent = 0, const char * name = "MHexWindow", WFlags f = 0 );
29 29
30 void log( QString text ); 30 void log( QString text );
31 const QString getLog() const;
31 void clear(); 32 void clear();
32 33
33 protected: 34 protected:
34 QMultiLineEdit* ledit; 35 QMultiLineEdit* ledit;
35 36
36}; 37};
37 38
38#endif 39#endif
39 40
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp
index 8e0164f..69d2b3a 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.cpp
+++ b/noncore/net/wellenreiter/gui/mainwindow.cpp
@@ -1,321 +1,342 @@
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#include "configwindow.h" 16#include "configwindow.h"
17#include "logwindow.h" 17#include "logwindow.h"
18#include "hexwindow.h" 18#include "hexwindow.h"
19#include "mainwindow.h" 19#include "mainwindow.h"
20#include "wellenreiter.h" 20#include "wellenreiter.h"
21#include "scanlist.h" 21#include "scanlist.h"
22 22
23#include <qcombobox.h> 23#include <qcombobox.h>
24#include <qdatastream.h> 24#include <qdatastream.h>
25#include <qfile.h> 25#include <qfile.h>
26#include <qfileinfo.h> 26#include <qfileinfo.h>
27#include <qiconset.h> 27#include <qiconset.h>
28#include <qmenubar.h> 28#include <qmenubar.h>
29#include <qmessagebox.h> 29#include <qmessagebox.h>
30#include <qpopupmenu.h> 30#include <qpopupmenu.h>
31#include <qstatusbar.h> 31#include <qstatusbar.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qtoolbutton.h> 33#include <qtoolbutton.h>
34 34
35#ifdef QWS 35#ifdef QWS
36#include <qpe/resource.h> 36#include <qpe/resource.h>
37#include <opie/ofiledialog.h> 37#include <opie/ofiledialog.h>
38#else 38#else
39#include "resource.h" 39#include "resource.h"
40#include <qapplication.h> 40#include <qapplication.h>
41#include <qfiledialog.h> 41#include <qfiledialog.h>
42#endif 42#endif
43 43
44WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) 44WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f )
45 :QMainWindow( parent, name, f ) 45 :QMainWindow( parent, name, f )
46{ 46{
47 cw = new WellenreiterConfigWindow( this ); 47 cw = new WellenreiterConfigWindow( this );
48 mw = new Wellenreiter( this ); 48 mw = new Wellenreiter( this );
49 mw->setConfigWindow( cw ); 49 mw->setConfigWindow( cw );
50 setCentralWidget( mw ); 50 setCentralWidget( mw );
51 51
52 // setup application icon 52 // setup application icon
53 53
54 #ifndef QWS 54 #ifndef QWS
55 setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); 55 setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) );
56 setIconText( "Wellenreiter/X11" ); 56 setIconText( "Wellenreiter/X11" );
57 #endif 57 #endif
58 58
59 // setup icon sets 59 // setup icon sets
60 60
61 infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) ); 61 infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) );
62 settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) ); 62 settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) );
63 #ifdef QWS 63 #ifdef QWS
64 searchIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); 64 searchIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) );
65 cancelIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); 65 cancelIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) );
66 #else 66 #else
67 startStopIconSet = new QIconSet(); 67 startStopIconSet = new QIconSet();
68 startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/SearchIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::Off ); 68 startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/SearchIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::Off );
69 startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/CancelIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::On ); 69 startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/CancelIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::On );
70 #endif 70 #endif
71 71
72 // setup tool buttons 72 // setup tool buttons
73 73
74 startStopButton = new QToolButton( 0 ); 74 startStopButton = new QToolButton( 0 );
75 #ifdef QWS 75 #ifdef QWS
76 startStopButton->setAutoRaise( true ); 76 startStopButton->setAutoRaise( true );
77 #endif 77 #endif
78 #ifdef QWS 78 #ifdef QWS
79 startStopButton->setOnIconSet( *cancelIconSet ); 79 startStopButton->setOnIconSet( *cancelIconSet );
80 startStopButton->setOffIconSet( *searchIconSet ); 80 startStopButton->setOffIconSet( *searchIconSet );
81 #else 81 #else
82 startStopButton->setIconSet( *startStopIconSet ); 82 startStopButton->setIconSet( *startStopIconSet );
83 #endif 83 #endif
84 startStopButton->setToggleButton( true ); 84 startStopButton->setToggleButton( true );
85 connect( startStopButton, SIGNAL( clicked() ), mw, SLOT( startStopClicked() ) ); 85 connect( startStopButton, SIGNAL( clicked() ), mw, SLOT( startStopClicked() ) );
86 startStopButton->setEnabled( false ); 86 startStopButton->setEnabled( false );
87 87
88 QToolButton* c = new QToolButton( 0 ); 88 QToolButton* c = new QToolButton( 0 );
89 #ifdef QWS 89 #ifdef QWS
90 c->setAutoRaise( true ); 90 c->setAutoRaise( true );
91 #endif 91 #endif
92 c->setIconSet( *infoIconSet ); 92 c->setIconSet( *infoIconSet );
93 c->setEnabled( false ); 93 c->setEnabled( false );
94 94
95 QToolButton* d = new QToolButton( 0 ); 95 QToolButton* d = new QToolButton( 0 );
96 #ifdef QWS 96 #ifdef QWS
97 d->setAutoRaise( true ); 97 d->setAutoRaise( true );
98 #endif 98 #endif
99 d->setIconSet( *settingsIconSet ); 99 d->setIconSet( *settingsIconSet );
100 connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); 100 connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) );
101 101
102 // setup menu bar 102 // setup menu bar
103 103
104 int id; 104 int id;
105 105
106 QMenuBar* mb = menuBar(); 106 QMenuBar* mb = menuBar();
107 107
108 QPopupMenu* fileSave = new QPopupMenu( mb ); 108 QPopupMenu* fileSave = new QPopupMenu( mb );
109 fileSave->insertItem( "&Session...", this, SLOT( fileSaveSession() ) ); 109 fileSave->insertItem( "&Session...", this, SLOT( fileSaveSession() ) );
110 fileSave->insertItem( "&Log...", this, SLOT( fileSaveLog() ) ); 110 fileSave->insertItem( "&Text Log...", this, SLOT( fileSaveLog() ) );
111 fileSave->insertItem( "&Hex Log...", this, SLOT( fileSaveHex() ) );
111 112
112 QPopupMenu* fileLoad = new QPopupMenu( mb ); 113 QPopupMenu* fileLoad = new QPopupMenu( mb );
113 fileLoad->insertItem( "&Session...", this, SLOT( fileLoadSession() ) ); 114 fileLoad->insertItem( "&Session...", this, SLOT( fileLoadSession() ) );
114 //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); 115 //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) );
115 116
116 QPopupMenu* file = new QPopupMenu( mb ); 117 QPopupMenu* file = new QPopupMenu( mb );
117 file->insertItem( "&New", this, SLOT( fileNew() ) ); 118 file->insertItem( "&New", this, SLOT( fileNew() ) );
118 id = file->insertItem( "&Load", fileLoad ); 119 id = file->insertItem( "&Load", fileLoad );
119 file->insertItem( "&Save", fileSave ); 120 file->insertItem( "&Save", fileSave );
120 file->insertSeparator(); 121 file->insertSeparator();
121 file->insertItem( "&Exit", qApp, SLOT( quit() ) ); 122 file->insertItem( "&Exit", qApp, SLOT( quit() ) );
122 123
123 QPopupMenu* view = new QPopupMenu( mb ); 124 QPopupMenu* view = new QPopupMenu( mb );
124 view->insertItem( "&Configure..." ); 125 view->insertItem( "&Configure..." );
125 126
126 QPopupMenu* sniffer = new QPopupMenu( mb ); 127 QPopupMenu* sniffer = new QPopupMenu( mb );
127 sniffer->insertItem( "&Configure..." ); 128 sniffer->insertItem( "&Configure..." );
128 sniffer->insertSeparator(); 129 sniffer->insertSeparator();
129 130
130 QPopupMenu* demo = new QPopupMenu( mb ); 131 QPopupMenu* demo = new QPopupMenu( mb );
131 demo->insertItem( "&Add something", this, SLOT( demoAddStations() ) ); 132 demo->insertItem( "&Add something", this, SLOT( demoAddStations() ) );
132 133
133 id = mb->insertItem( "&File", file ); 134 id = mb->insertItem( "&File", file );
134 id = mb->insertItem( "&View", view ); 135 id = mb->insertItem( "&View", view );
135 mb->setItemEnabled( id, false ); 136 mb->setItemEnabled( id, false );
136 id = mb->insertItem( "&Sniffer", sniffer ); 137 id = mb->insertItem( "&Sniffer", sniffer );
137 mb->setItemEnabled( id, false ); 138 mb->setItemEnabled( id, false );
138 id = mb->insertItem( "&Demo", demo ); 139 id = mb->insertItem( "&Demo", demo );
139 mb->setItemEnabled( id, true ); 140 mb->setItemEnabled( id, true );
140 141
141 #ifdef QWS 142 #ifdef QWS
142 mb->insertItem( startStopButton ); 143 mb->insertItem( startStopButton );
143 mb->insertItem( c ); 144 mb->insertItem( c );
144 mb->insertItem( d ); 145 mb->insertItem( d );
145 #else // Qt3 changed the insertion order. It's now totally random :( 146 #else // Qt3 changed the insertion order. It's now totally random :(
146 mb->insertItem( d ); 147 mb->insertItem( d );
147 mb->insertItem( c ); 148 mb->insertItem( c );
148 mb->insertItem( startStopButton ); 149 mb->insertItem( startStopButton );
149 #endif 150 #endif
150 151
151 // setup status bar (for now only on X11) 152 // setup status bar (for now only on X11)
152 153
153 #ifndef QWS 154 #ifndef QWS
154 statusBar()->message( "Ready." ); 155 statusBar()->message( "Ready." );
155 #endif 156 #endif
156 157
157}; 158};
158 159
159void WellenreiterMainWindow::showConfigure() 160void WellenreiterMainWindow::showConfigure()
160{ 161{
161 qDebug( "show configure..." ); 162 qDebug( "show configure..." );
162 cw->setCaption( tr( "Configure" ) ); 163 cw->setCaption( tr( "Configure" ) );
163 #ifdef QWS 164 #ifdef QWS
164 cw->showMaximized(); 165 cw->showMaximized();
165 #endif 166 #endif
166 int result = cw->exec(); 167 int result = cw->exec();
167 168
168 if ( result ) 169 if ( result )
169 { 170 {
170 // check configuration from config window 171 // check configuration from config window
171 172
172 const QString& interface = cw->interfaceName->currentText(); 173 const QString& interface = cw->interfaceName->currentText();
173 const int cardtype = cw->daemonDeviceType(); 174 const int cardtype = cw->daemonDeviceType();
174 const int interval = cw->daemonHopInterval(); 175 const int interval = cw->daemonHopInterval();
175 176
176 if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) 177 if ( ( interface != "<select>" ) && ( cardtype != 0 ) )
177 startStopButton->setEnabled( true ); 178 startStopButton->setEnabled( true );
178 //TODO ... 179 //TODO ...
179 else 180 else
180 startStopButton->setEnabled( false ); 181 startStopButton->setEnabled( false );
181 //TODO ... 182 //TODO ...
182 } 183 }
183} 184}
184 185
185WellenreiterMainWindow::~WellenreiterMainWindow() 186WellenreiterMainWindow::~WellenreiterMainWindow()
186{ 187{
187 188
188 delete infoIconSet; 189 delete infoIconSet;
189 delete settingsIconSet; 190 delete settingsIconSet;
190 #ifdef QWS 191 #ifdef QWS
191 delete searchIconSet; 192 delete searchIconSet;
192 delete cancelIconSet; 193 delete cancelIconSet;
193 #else 194 #else
194 delete startStopIconSet; 195 delete startStopIconSet;
195 #endif 196 #endif
196 197
197}; 198};
198 199
199void WellenreiterMainWindow::demoAddStations() 200void WellenreiterMainWindow::demoAddStations()
200{ 201{
201 mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 ); 202 mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 );
202 mw->netView()->addNewItem( "managed", "Vanille", "00:30:6D:EF:A6:23", true, 11, 10 ); 203 mw->netView()->addNewItem( "managed", "Vanille", "00:30:6D:EF:A6:23", true, 11, 10 );
203 mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 ); 204 mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 );
204 mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 ); 205 mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 );
205 mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 ); 206 mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 );
206} 207}
207 208
208QString WellenreiterMainWindow::getFileName( bool save ) 209QString WellenreiterMainWindow::getFileName( bool save )
209{ 210{
210 QMap<QString, QStringList> map; 211 QMap<QString, QStringList> map;
211 map.insert( tr("All"), QStringList() ); 212 map.insert( tr("All"), QStringList() );
212 QStringList text; 213 QStringList text;
213 text << "text/*"; 214 text << "text/*";
214 map.insert(tr("Text"), text ); 215 map.insert(tr("Text"), text );
215 text << "*"; 216 text << "*";
216 map.insert(tr("All"), text ); 217 map.insert(tr("All"), text );
217 218
218 QString str; 219 QString str;
219 if ( save ) 220 if ( save )
220 { 221 {
221 #ifdef QWS 222 #ifdef QWS
222 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); 223 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map );
223 #else 224 #else
224 str = QFileDialog::getSaveFileName(); 225 str = QFileDialog::getSaveFileName();
225 #endif 226 #endif
226 if ( str.isEmpty() || QFileInfo(str).isDir() ) 227 if ( str.isEmpty() || QFileInfo(str).isDir() )
227 return ""; 228 return "";
228 } 229 }
229 else 230 else
230 { 231 {
231 #ifdef QWS 232 #ifdef QWS
232 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); 233 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map );
233 #else 234 #else
234 str = QFileDialog::getOpenFileName(); 235 str = QFileDialog::getOpenFileName();
235 #endif 236 #endif
236 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) 237 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() )
237 return ""; 238 return "";
238 } 239 }
239 return str; 240 return str;
240} 241}
241 242
242void WellenreiterMainWindow::fileSaveLog() 243void WellenreiterMainWindow::fileSaveLog()
243{ 244{
244 QString fname = getFileName( true ); 245 QString fname = getFileName( true );
245 if ( !fname.isEmpty() ) 246 if ( !fname.isEmpty() )
246 { 247 {
247 QFile f( fname ); 248 QFile f( fname );
248 if ( f.open(IO_WriteOnly) ) 249 if ( f.open(IO_WriteOnly) )
249 { 250 {
250 QTextStream t( &f ); 251 QTextStream t( &f );
251 t << mw->logWindow()->getLog(); 252 t << mw->logWindow()->getLog();
252 f.close(); 253 f.close();
253 qDebug( "Saved log to file '%s'", (const char*) fname ); 254 qDebug( "Saved log to file '%s'", (const char*) fname );
254 } 255 }
255 else 256 else
256 { 257 {
257 qDebug( "Problem saving log to file '%s'", (const char*) fname ); 258 qDebug( "Problem saving log to file '%s'", (const char*) fname );
258 } 259 }
259 } 260 }
260} 261}
261 262
262void WellenreiterMainWindow::fileSaveSession() 263void WellenreiterMainWindow::fileSaveSession()
263{ 264{
264 QString fname = getFileName( true ); 265 QString fname = getFileName( true );
265 if ( !fname.isEmpty() ) 266 if ( !fname.isEmpty() )
266 { 267 {
267 268
268 QFile f( fname ); 269 QFile f( fname );
269 if ( f.open(IO_WriteOnly) ) 270 if ( f.open(IO_WriteOnly) )
270 { 271 {
271 QDataStream t( &f ); 272 QDataStream t( &f );
272 t << *mw->netView(); 273 t << *mw->netView();
273 f.close(); 274 f.close();
274 qDebug( "Saved session to file '%s'", (const char*) fname ); 275 qDebug( "Saved session to file '%s'", (const char*) fname );
275 } 276 }
276 else 277 else
277 { 278 {
278 qDebug( "Problem saving session to file '%s'", (const char*) fname ); 279 qDebug( "Problem saving session to file '%s'", (const char*) fname );
279 } 280 }
280 } 281 }
281} 282}
282 283
284void WellenreiterMainWindow::fileSaveHex()
285{
286 QString fname = getFileName( true );
287 if ( !fname.isEmpty() )
288 {
289 QFile f( fname );
290 if ( f.open(IO_WriteOnly) )
291 {
292 QTextStream t( &f );
293 t << mw->hexWindow()->getLog();
294 f.close();
295 qDebug( "Saved hex log to file '%s'", (const char*) fname );
296 }
297 else
298 {
299 qDebug( "Problem saving hex log to file '%s'", (const char*) fname );
300 }
301 }
302}
303
283void WellenreiterMainWindow::fileLoadSession() 304void WellenreiterMainWindow::fileLoadSession()
284{ 305{
285 QString fname = getFileName( false ); 306 QString fname = getFileName( false );
286 if ( !fname.isEmpty() ) 307 if ( !fname.isEmpty() )
287 { 308 {
288 QFile f( fname ); 309 QFile f( fname );
289 if ( f.open(IO_ReadOnly) ) 310 if ( f.open(IO_ReadOnly) )
290 { 311 {
291 QDataStream t( &f ); 312 QDataStream t( &f );
292 t >> *mw->netView(); 313 t >> *mw->netView();
293 f.close(); 314 f.close();
294 qDebug( "Loaded session from file '%s'", (const char*) fname ); 315 qDebug( "Loaded session from file '%s'", (const char*) fname );
295 } 316 }
296 else 317 else
297 { 318 {
298 qDebug( "Problem loading session from file '%s'", (const char*) fname ); 319 qDebug( "Problem loading session from file '%s'", (const char*) fname );
299 } 320 }
300 } 321 }
301} 322}
302 323
303void WellenreiterMainWindow::fileNew() 324void WellenreiterMainWindow::fileNew()
304{ 325{
305 mw->netView()->clear(); 326 mw->netView()->clear();
306 mw->logWindow()->clear(); 327 mw->logWindow()->clear();
307 mw->hexWindow()->clear(); 328 mw->hexWindow()->clear();
308} 329}
309 330
310void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) 331void WellenreiterMainWindow::closeEvent( QCloseEvent* e )
311{ 332{
312 if ( mw->isDaemonRunning() ) 333 if ( mw->isDaemonRunning() )
313 { 334 {
314 QMessageBox::warning( this, "Wellenreiter/Opie", "Sniffing in progress!\nPlease stop sniffing before closing." ); 335 QMessageBox::warning( this, "Wellenreiter/Opie", "Sniffing in progress!\nPlease stop sniffing before closing." );
315 e->ignore(); 336 e->ignore();
316 } 337 }
317 else 338 else
318 { 339 {
319 QMainWindow::closeEvent( e ); 340 QMainWindow::closeEvent( e );
320 } 341 }
321} 342}
diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h
index e06a60c..1b08c5b 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.h
+++ b/noncore/net/wellenreiter/gui/mainwindow.h
@@ -1,61 +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 33
34 protected: 34 protected:
35 Wellenreiter* mw; 35 Wellenreiter* mw;
36 WellenreiterConfigWindow* cw; 36 WellenreiterConfigWindow* cw;
37 37
38 QIconSet* startStopIconSet; 38 QIconSet* startStopIconSet;
39 const QIconSet* searchIconSet; 39 const QIconSet* searchIconSet;
40 const QIconSet* infoIconSet; 40 const QIconSet* infoIconSet;
41 const QIconSet* settingsIconSet; 41 const QIconSet* settingsIconSet;
42 const QIconSet* cancelIconSet; 42 const QIconSet* cancelIconSet;
43 43
44 QToolButton* startStopButton; 44 QToolButton* startStopButton;
45 45
46 protected: 46 protected:
47 virtual void closeEvent( QCloseEvent* ); 47 virtual void closeEvent( QCloseEvent* );
48 48
49 private: 49 private:
50 QString getFileName( bool save ); 50 QString getFileName( bool save );
51 51
52 public slots: 52 public slots:
53 void showConfigure(); 53 void showConfigure();
54 void demoAddStations(); 54 void demoAddStations();
55 void fileSaveLog(); 55 void fileSaveLog();
56 void fileSaveHex();
56 void fileSaveSession(); 57 void fileSaveSession();
57 void fileLoadSession(); 58 void fileLoadSession();
58 void fileNew(); 59 void fileNew();
59}; 60};
60 61
61#endif 62#endif
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index a006a3c..34c69f5 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -69,242 +69,242 @@ void MScanListView::serializeTo( QDataStream& s) const
69 qDebug( "serializing MScanListView" ); 69 qDebug( "serializing MScanListView" );
70 OListView::serializeTo( s ); 70 OListView::serializeTo( s );
71} 71}
72 72
73void MScanListView::serializeFrom( QDataStream& s) 73void MScanListView::serializeFrom( QDataStream& s)
74{ 74{
75 qDebug( "serializing MScanListView" ); 75 qDebug( "serializing MScanListView" );
76 OListView::serializeFrom( s ); 76 OListView::serializeFrom( s );
77} 77}
78 78
79void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb ) 79void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb )
80{ 80{
81 _manufacturerdb = manufacturerdb; 81 _manufacturerdb = manufacturerdb;
82} 82}
83 83
84void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) 84void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
85{ 85{
86 // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) 86 // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...)
87 87
88 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", 88 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]",
89 (const char*) type, 89 (const char*) type,
90 (const char*) essid, 90 (const char*) essid,
91 (const char*) macaddr, 91 (const char*) macaddr,
92 channel ); 92 channel );
93 93
94 // search, if we already have seen this net 94 // search, if we already have seen this net
95 95
96 QString s; 96 QString s;
97 MScanListItem* network; 97 MScanListItem* network;
98 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); 98 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() );
99 99
100 while ( item && ( item->text( 0 ) != essid ) ) 100 while ( item && ( item->text( 0 ) != essid ) )
101 { 101 {
102 qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); 102 qDebug( "itemtext: %s", (const char*) item->text( 0 ) );
103 item = static_cast<MScanListItem*> ( item->itemBelow() ); 103 item = static_cast<MScanListItem*> ( item->itemBelow() );
104 } 104 }
105 if ( item ) 105 if ( item )
106 { 106 {
107 // animate the item 107 // animate the item
108 108
109 /* 109 /*
110 110
111 const QPixmap* pixmap = item->pixmap( 0 ); 111 const QPixmap* pixmap = item->pixmap( 0 );
112 const QPixmap* nextpixmap = ani2; 112 const QPixmap* nextpixmap = ani2;
113 if ( pixmap == ani1 ) 113 if ( pixmap == ani1 )
114 nextpixmap = ani2; 114 nextpixmap = ani2;
115 else if ( pixmap == ani2 ) 115 else if ( pixmap == ani2 )
116 nextpixmap = ani3; 116 nextpixmap = ani3;
117 else if ( pixmap == ani3 ) 117 else if ( pixmap == ani3 )
118 nextpixmap = ani4; 118 nextpixmap = ani4;
119 else if ( pixmap == ani4 ) 119 else if ( pixmap == ani4 )
120 nextpixmap = ani1; 120 nextpixmap = ani1;
121 item->setPixmap( 0, *nextpixmap ); */ 121 item->setPixmap( 0, *nextpixmap ); */
122 122
123 //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap ); 123 //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap );
124 124
125 // we have already seen this net, check all childs if MAC exists 125 // we have already seen this net, check all childs if MAC exists
126 126
127 network = item; 127 network = item;
128 128
129 item = static_cast<MScanListItem*> ( item->firstChild() ); 129 item = static_cast<MScanListItem*> ( item->firstChild() );
130 assert( item ); // this shouldn't fail 130 assert( item ); // this shouldn't fail
131 131
132 while ( item && ( item->text( 2 ) != macaddr ) ) 132 while ( item && ( item->text( 2 ) != macaddr ) )
133 { 133 {
134 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); 134 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) );
135 item = static_cast<MScanListItem*> ( item->itemBelow() ); 135 item = static_cast<MScanListItem*> ( item->itemBelow() );
136 } 136 }
137 137
138 if ( item ) 138 if ( item )
139 { 139 {
140 // we have already seen this item, it's a dupe 140 // we have already seen this item, it's a dupe
141 #ifdef DEBUG 141 #ifdef DEBUG
142 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); 142 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr );
143 #endif 143 #endif
144 item->receivedBeacon(); 144 item->receivedBeacon();
145 return; 145 return;
146 } 146 }
147 } 147 }
148 else 148 else
149 { 149 {
150 s.sprintf( "(i) new network: '%s'", (const char*) essid ); 150 s.sprintf( "(i) new network: '%s'", (const char*) essid );
151 network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 ); 151 network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 );
152 } 152 }
153 153
154 154
155 // insert new station as child from network 155 // insert new station as child from network
156 156
157 // no essid to reduce clutter, maybe later we have a nick or stationname to display!? 157 // no essid to reduce clutter, maybe later we have a nick or stationname to display!?
158 158
159 qDebug( "inserting new station %s", (const char*) macaddr ); 159 qDebug( "inserting new station %s", (const char*) macaddr );
160 160
161 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); 161 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal );
162 if ( _manufacturerdb ) 162 if ( _manufacturerdb )
163 station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); 163 station->setManufacturer( _manufacturerdb->lookup( macaddr ) );
164 164
165 if ( type == "managed" ) 165 if ( type == "managed" )
166 { 166 {
167 s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); 167 s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel );
168 } 168 }
169 else 169 else
170 { 170 {
171 s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); 171 s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel );
172 } 172 }
173 173
174} 174}
175 175
176#ifdef QWS 176#ifdef QWS
177#include <qpe/resource.h> 177#include <qpe/resource.h>
178#else 178#else
179#include "resource.h" 179#include "resource.h"
180#endif 180#endif
181 181
182const int col_type = 0; 182const int col_type = 0;
183const int col_essid = 0; 183const int col_essid = 0;
184const int col_sig = 1; 184const int col_sig = 1;
185const int col_ap = 2; 185const int col_ap = 2;
186const int col_channel = 3; 186const int col_channel = 3;
187const int col_wep = 4; 187const int col_wep = 4;
188const int col_traffic = 5; 188const int col_traffic = 5;
189const int col_manuf = 6; 189const int col_manuf = 6;
190const int col_firstseen = 7; 190const int col_firstseen = 7;
191const int col_lastseen = 8; 191const int col_lastseen = 8;
192 192
193MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, 193MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr,
194 bool wep, int channel, int signal ) 194 bool wep, int channel, int signal )
195 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), 195 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
196 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), 196 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
197 _channel( channel ), _signal( signal ), _beacons( 0 ) 197 _channel( channel ), _signal( signal ), _beacons( 1 )
198{ 198{
199 qDebug( "creating scanlist item" ); 199 qDebug( "creating scanlist item" );
200 if ( WellenreiterConfigWindow::instance() && type == "networks" ) 200 if ( WellenreiterConfigWindow::instance() && type == "networks" )
201 playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); 201 playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() );
202 decorateItem( type, essid, macaddr, wep, channel, signal ); 202 decorateItem( type, essid, macaddr, wep, channel, signal );
203} 203}
204 204
205MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, 205MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr,
206 bool wep, int channel, int signal ) 206 bool wep, int channel, int signal )
207 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) 207 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
208{ 208{
209 qDebug( "creating scanlist item" ); 209 qDebug( "creating scanlist item" );
210 decorateItem( type, essid, macaddr, wep, channel, signal ); 210 decorateItem( type, essid, macaddr, wep, channel, signal );
211} 211}
212 212
213OListViewItem* MScanListItem::childFactory() 213OListViewItem* MScanListItem::childFactory()
214{ 214{
215 return new MScanListItem( this ); 215 return new MScanListItem( this );
216} 216}
217 217
218void MScanListItem::serializeTo( QDataStream& s ) const 218void MScanListItem::serializeTo( QDataStream& s ) const
219{ 219{
220 qDebug( "serializing MScanListItem" ); 220 qDebug( "serializing MScanListItem" );
221 OListViewItem::serializeTo( s ); 221 OListViewItem::serializeTo( s );
222 222
223 s << _type; 223 s << _type;
224 s << (Q_UINT8) _wep; 224 s << (Q_UINT8) _wep;
225} 225}
226 226
227void MScanListItem::serializeFrom( QDataStream& s ) 227void MScanListItem::serializeFrom( QDataStream& s )
228{ 228{
229 qDebug( "serializing MScanListItem" ); 229 qDebug( "serializing MScanListItem" );
230 OListViewItem::serializeFrom( s ); 230 OListViewItem::serializeFrom( s );
231 231
232 s >> _type; 232 s >> _type;
233 s >> (Q_UINT8) _wep; 233 s >> (Q_UINT8) _wep;
234 234
235 QString name; 235 QString name;
236 name.sprintf( "wellenreiter/%s", (const char*) _type ); 236 name.sprintf( "wellenreiter/%s", (const char*) _type );
237 setPixmap( col_type, Resource::loadPixmap( name ) ); 237 setPixmap( col_type, Resource::loadPixmap( name ) );
238 if ( _wep ) 238 if ( _wep )
239 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! 239 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
240 listView()->triggerUpdate(); 240 listView()->triggerUpdate();
241} 241}
242 242
243void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) 243void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
244{ 244{
245 qDebug( "decorating scanlist item %s / %s / %s [%d]", 245 qDebug( "decorating scanlist item %s / %s / %s [%d]",
246 (const char*) type, 246 (const char*) type,
247 (const char*) essid, 247 (const char*) essid,
248 (const char*) macaddr, 248 (const char*) macaddr,
249 channel ); 249 channel );
250 250
251 // set icon for managed or adhoc mode 251 // set icon for managed or adhoc mode
252 QString name; 252 QString name;
253 name.sprintf( "wellenreiter/%s", (const char*) type ); 253 name.sprintf( "wellenreiter/%s", (const char*) type );
254 setPixmap( col_type, Resource::loadPixmap( name ) ); 254 setPixmap( col_type, Resource::loadPixmap( name ) );
255 255
256 // set icon for wep (wireless encryption protocol) 256 // set icon for wep (wireless encryption protocol)
257 if ( wep ) 257 if ( wep )
258 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! 258 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
259 259
260 // set channel and signal text 260 // set channel and signal text
261 261
262 if ( signal != -1 ) 262 if ( signal != -1 )
263 setText( col_sig, QString::number( signal ) ); 263 setText( col_sig, QString::number( signal ) );
264 if ( channel != -1 ) 264 if ( channel != -1 )
265 setText( col_channel, QString::number( channel ) ); 265 setText( col_channel, QString::number( channel ) );
266 266
267 setText( col_firstseen, QTime::currentTime().toString() ); 267 setText( col_firstseen, QTime::currentTime().toString() );
268 //setText( col_lastseen, QTime::currentTime().toString() ); 268 //setText( col_lastseen, QTime::currentTime().toString() );
269 269
270 listView()->triggerUpdate(); 270 listView()->triggerUpdate();
271 271
272 this->type = type; 272 this->type = type;
273 _type = type; 273 _type = type;
274 _essid = essid; 274 _essid = essid;
275 _macaddr = macaddr; 275 _macaddr = macaddr;
276 _channel = channel; 276 _channel = channel;
277 _beacons = 0; 277 _beacons = 1;
278 _signal = 0; 278 _signal = 0;
279} 279}
280 280
281 281
282void MScanListItem::setManufacturer( const QString& manufacturer ) 282void MScanListItem::setManufacturer( const QString& manufacturer )
283{ 283{
284 setText( col_manuf, manufacturer ); 284 setText( col_manuf, manufacturer );
285} 285}
286 286
287 287
288void MScanListItem::playSound( const QString& sound ) const 288void MScanListItem::playSound( const QString& sound ) const
289{ 289{
290 #ifdef QWS 290 #ifdef QWS
291 if ( sound == "Ignore" ) return; 291 if ( sound == "Ignore" ) return;
292 else if ( sound == "Touch" ) ODevice::inst()->touchSound(); 292 else if ( sound == "Touch" ) ODevice::inst()->touchSound();
293 else if ( sound == "Key" ) ODevice::inst()->keySound(); 293 else if ( sound == "Key" ) ODevice::inst()->keySound();
294 else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); 294 else if ( sound == "Alarm" ) ODevice::inst()->alarmSound();
295 #endif 295 #endif
296} 296}
297 297
298 298
299void MScanListItem::receivedBeacon() 299void MScanListItem::receivedBeacon()
300{ 300{
301 _beacons++; 301 _beacons++;
302 #ifdef DEBUG 302 #ifdef DEBUG
303 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); 303 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons );
304 #endif 304 #endif
305 setText( col_sig, QString::number( _beacons ) ); 305 setText( col_sig, QString::number( _beacons ) );
306 setText( col_lastseen, QTime::currentTime().toString() ); 306 setText( col_lastseen, QTime::currentTime().toString() );
307 if ( WellenreiterConfigWindow::instance() ) 307 if ( WellenreiterConfigWindow::instance() )
308 playSound( WellenreiterConfigWindow::instance()->soundOnBeacon() ); 308 playSound( WellenreiterConfigWindow::instance()->soundOnBeacon() );
309} 309}
310 310
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index d80a6e6..aa33158 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -1,234 +1,237 @@
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// Opie 16// Opie
17 17
18#ifdef QWS 18#ifdef QWS
19#include <opie/odevice.h> 19#include <opie/odevice.h>
20using namespace Opie; 20using namespace Opie;
21#endif 21#endif
22 22
23#ifdef QWS 23#ifdef QWS
24#include <opie2/oapplication.h> 24#include <opie2/oapplication.h>
25#else 25#else
26#include <qapplication.h> 26#include <qapplication.h>
27#endif 27#endif
28#include <opie2/onetwork.h> 28#include <opie2/onetwork.h>
29#include <opie2/opcap.h> 29#include <opie2/opcap.h>
30 30
31// Qt 31// Qt
32 32
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qmessagebox.h> 34#include <qmessagebox.h>
35#include <qcombobox.h> 35#include <qcombobox.h>
36#include <qspinbox.h> 36#include <qspinbox.h>
37#include <qsocketnotifier.h> 37#include <qsocketnotifier.h>
38 38
39// Standard 39// Standard
40 40
41#include <assert.h> 41#include <assert.h>
42#include <errno.h> 42#include <errno.h>
43#include <unistd.h> 43#include <unistd.h>
44#include <string.h> 44#include <string.h>
45#include <sys/types.h> 45#include <sys/types.h>
46#include <stdlib.h> 46#include <stdlib.h>
47 47
48// Local 48// Local
49 49
50#include "wellenreiter.h" 50#include "wellenreiter.h"
51#include "scanlist.h" 51#include "scanlist.h"
52#include "logwindow.h" 52#include "logwindow.h"
53#include "hexwindow.h" 53#include "hexwindow.h"
54#include "configwindow.h" 54#include "configwindow.h"
55 55
56#include "manufacturers.h" 56#include "manufacturers.h"
57 57
58Wellenreiter::Wellenreiter( QWidget* parent ) 58Wellenreiter::Wellenreiter( QWidget* parent )
59 : WellenreiterBase( parent, 0, 0 ), 59 : WellenreiterBase( parent, 0, 0 ),
60 sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) 60 sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 )
61{ 61{
62 62
63 // 63 //
64 // construct manufacturer database 64 // construct manufacturer database
65 // 65 //
66 66
67 QString manufile; 67 QString manufile;
68 #ifdef QWS 68 #ifdef QWS
69 manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); 69 manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() );
70 #else 70 #else
71 manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); 71 manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" );
72 #endif 72 #endif
73 manufacturerdb = new ManufacturerDB( manufile ); 73 manufacturerdb = new ManufacturerDB( manufile );
74 74
75 logwindow->log( "(i) Wellenreiter has been started." ); 75 logwindow->log( "(i) Wellenreiter has been started." );
76 76
77 // 77 //
78 // detect operating system 78 // detect operating system
79 // 79 //
80 80
81 #ifdef QWS 81 #ifdef QWS
82 QString sys; 82 QString sys;
83 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); 83 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
84 _system = ODevice::inst()->system(); 84 _system = ODevice::inst()->system();
85 logwindow->log( sys ); 85 logwindow->log( sys );
86 #endif 86 #endif
87 87
88 // setup GUI 88 // setup GUI
89 netview->setColumnWidthMode( 1, QListView::Manual ); 89 netview->setColumnWidthMode( 1, QListView::Manual );
90 90
91 if ( manufacturerdb ) 91 if ( manufacturerdb )
92 netview->setManufacturerDB( manufacturerdb ); 92 netview->setManufacturerDB( manufacturerdb );
93 93
94 pcap = new OPacketCapturer(); 94 pcap = new OPacketCapturer();
95 95
96} 96}
97 97
98Wellenreiter::~Wellenreiter() 98Wellenreiter::~Wellenreiter()
99{ 99{
100 // no need to delete child widgets, Qt does it all for us 100 // no need to delete child widgets, Qt does it all for us
101 101
102 delete manufacturerdb; 102 delete manufacturerdb;
103 delete pcap; 103 delete pcap;
104} 104}
105 105
106void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 106void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
107{ 107{
108 configwindow = cw; 108 configwindow = cw;
109} 109}
110 110
111void Wellenreiter::receivePacket(OPacket* p) 111void Wellenreiter::receivePacket(OPacket* p)
112{ 112{
113 hexWindow()->log( p->dump( 8 ) );
114
113 // check if we received a beacon frame 115 // check if we received a beacon frame
114 // static_cast is justified here 116 // static_cast is justified here
115 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); 117 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) );
116 if ( !beacon ) return; 118 if ( !beacon ) return;
117 QString type; 119 QString type;
118 120
119 //FIXME: Can stations in ESS mode can be distinguished from APs? 121 //FIXME: Can stations in ESS mode can be distinguished from APs?
120 //FIXME: Apparently yes, but not by listening to beacons, because 122 //FIXME: Apparently yes, but not by listening to beacons, because
121 //FIXME: they simply don't send beacons in infrastructure mode. 123 //FIXME: they simply don't send beacons in infrastructure mode.
122 //FIXME: so we also have to listen to data packets 124 //FIXME: so we also have to listen to data packets
123 125
124 if ( beacon->canIBSS() ) 126 if ( beacon->canIBSS() )
125 type = "adhoc"; 127 type = "adhoc";
126 else 128 else
127 type = "managed"; 129 type = "managed";
128 130
129 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 131 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
130 QString essid = ssid ? ssid->ID() : QString("<unknown>"); 132 QString essid = ssid ? ssid->ID() : QString("<unknown>");
131 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 133 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
132 int channel = ds ? ds->channel() : -1; 134 int channel = ds ? ds->channel() : -1;
133 135
134 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 136 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
135 netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 ); 137 netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 );
136} 138}
137 139
138void Wellenreiter::startStopClicked() 140void Wellenreiter::startStopClicked()
139{ 141{
140 if ( sniffing ) 142 if ( sniffing )
141 { 143 {
142 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 144 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
143 145
144 iface->setChannelHopping(); // stop hopping channels 146 iface->setChannelHopping(); // stop hopping channels
145 pcap->close(); 147 pcap->close();
146 sniffing = false; 148 sniffing = false;
147 #ifdef QWS 149 #ifdef QWS
148 oApp->setTitle(); 150 oApp->setTitle();
149 #else 151 #else
150 qApp->mainWidget()->setCaption( "Wellenreiter II" ); 152 qApp->mainWidget()->setCaption( "Wellenreiter II" );
151 #endif 153 #endif
152 154
153 // get interface name from config window 155 // get interface name from config window
154 const QString& interface = configwindow->interfaceName->currentText(); 156 const QString& interface = configwindow->interfaceName->currentText();
155 ONetwork* net = ONetwork::instance(); 157 ONetwork* net = ONetwork::instance();
156 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); 158 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface ));
157 159
158 // switch off monitor mode 160 // switch off monitor mode
159 iface->setMonitorMode( false ); 161 iface->setMonitorMode( false );
160 // switch off promisc flag 162 // switch off promisc flag
161 iface->setPromiscuousMode( false ); 163 iface->setPromiscuousMode( false );
162 164
163 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess 165 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
166 logwindow->log( "(i) Stopped Scanning." );
164 167
165 // message the user 168 // message the user
166 QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); 169 QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." );
167 } 170 }
168 171
169 else 172 else
170 { 173 {
171 // get configuration from config window 174 // get configuration from config window
172 175
173 const QString& interface = configwindow->interfaceName->currentText(); 176 const QString& interface = configwindow->interfaceName->currentText();
174 const int cardtype = configwindow->daemonDeviceType(); 177 const int cardtype = configwindow->daemonDeviceType();
175 const int interval = configwindow->daemonHopInterval(); 178 const int interval = configwindow->daemonHopInterval();
176 179
177 if ( ( interface == "" ) || ( cardtype == 0 ) ) 180 if ( ( interface == "" ) || ( cardtype == 0 ) )
178 { 181 {
179 QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); 182 QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" );
180 return; 183 return;
181 } 184 }
182 185
183 // configure device 186 // configure device
184 187
185 ONetwork* net = ONetwork::instance(); 188 ONetwork* net = ONetwork::instance();
186 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); 189 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface ));
187 190
188 // set monitor mode 191 // set monitor mode
189 192
190 switch ( cardtype ) 193 switch ( cardtype )
191 { 194 {
192 case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; 195 case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break;
193 case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; 196 case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break;
194 case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; 197 case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break;
195 case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; 198 case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break;
196 default: assert( 0 ); // shouldn't happen 199 default: assert( 0 ); // shouldn't happen
197 } 200 }
198 201
199 iface->setMonitorMode( true ); 202 iface->setMonitorMode( true );
200 203
201 if ( !iface->monitorMode() ) 204 if ( !iface->monitorMode() )
202 { 205 {
203 QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); 206 QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." );
204 return; 207 return;
205 } 208 }
206 209
207 // open pcap and start sniffing 210 // open pcap and start sniffing
208 pcap->open( interface ); 211 pcap->open( interface );
209 212
210 if ( !pcap->isOpen() ) 213 if ( !pcap->isOpen() )
211 { 214 {
212 QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); 215 QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) ));
213 return; 216 return;
214 } 217 }
215 218
216 // set capturer to non-blocking mode 219 // set capturer to non-blocking mode
217 pcap->setBlocking( false ); 220 pcap->setBlocking( false );
218 221
219 // start channel hopper 222 // start channel hopper
220 iface->setChannelHopping( 1000 ); //use interval from config window 223 iface->setChannelHopping( 1000 ); //use interval from config window
221 224
222 // connect 225 // connect
223 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 226 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
224 227
225 logwindow->log( "(i) Daemon has been started." ); 228 logwindow->log( "(i) Started Scanning." );
226 #ifdef QWS 229 #ifdef QWS
227 oApp->setTitle( "Scanning ..." ); 230 oApp->setTitle( "Scanning ..." );
228 #else 231 #else
229 qApp->mainWidget()->setCaption( "Wellenreiter II / Scanning ..." ); 232 qApp->mainWidget()->setCaption( "Wellenreiter II / Scanning ..." );
230 #endif 233 #endif
231 sniffing = true; 234 sniffing = true;
232 235
233 } 236 }
234} 237}