-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gui.pro | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 3 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 1 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 13 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 6 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.cpp | 3 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.h | 3 |
8 files changed, 15 insertions, 18 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index 9358866..ca53471 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp | |||
@@ -1,474 +1,474 @@ | |||
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 | /* 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 <opie/odevice.h> | 25 | #include <opie2/odevice.h> |
26 | using namespace Opie; | 26 | using namespace Opie; |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | /* QT */ | 29 | /* QT */ |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | #include <qcheckbox.h> | 31 | #include <qcheckbox.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qlineedit.h> | 34 | #include <qlineedit.h> |
35 | #include <qlayout.h> | 35 | #include <qlayout.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qtabwidget.h> | 38 | #include <qtabwidget.h> |
39 | #include <qtoolbutton.h> | 39 | #include <qtoolbutton.h> |
40 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | 42 | ||
43 | /* POSIX */ | 43 | /* POSIX */ |
44 | #include <assert.h> | 44 | #include <assert.h> |
45 | 45 | ||
46 | WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; | 46 | WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; |
47 | 47 | ||
48 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) | 48 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) |
49 | :WellenreiterConfigBase( parent, name, true, f ) | 49 | :WellenreiterConfigBase( parent, name, true, f ) |
50 | { | 50 | { |
51 | _devicetype[ "cisco" ] = DEVTYPE_CISCO; | 51 | _devicetype[ "cisco" ] = DEVTYPE_CISCO; |
52 | _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; | 52 | _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; |
53 | _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; | 53 | _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; |
54 | _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; | 54 | _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; |
55 | _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; | 55 | _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; |
56 | _devicetype[ "<file>" ] = DEVTYPE_FILE; | 56 | _devicetype[ "<file>" ] = DEVTYPE_FILE; |
57 | 57 | ||
58 | // gather possible interface names from ONetwork | 58 | // gather possible interface names from ONetwork |
59 | ONetwork* net = ONetwork::instance(); | 59 | ONetwork* net = ONetwork::instance(); |
60 | ONetwork::InterfaceIterator it = net->iterator(); | 60 | ONetwork::InterfaceIterator it = net->iterator(); |
61 | while ( it.current() ) | 61 | while ( it.current() ) |
62 | { | 62 | { |
63 | if ( it.current()->isWireless() ) | 63 | if ( it.current()->isWireless() ) |
64 | interfaceName->insertItem( it.current()->name() ); | 64 | interfaceName->insertItem( it.current()->name() ); |
65 | ++it; | 65 | ++it; |
66 | } | 66 | } |
67 | 67 | ||
68 | load(); | 68 | load(); |
69 | 69 | ||
70 | #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here | 70 | #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here |
71 | QPushButton* okButton = new QPushButton( "ok", this ); | 71 | QPushButton* okButton = new QPushButton( "ok", this ); |
72 | okButton->show(); | 72 | okButton->show(); |
73 | WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui | 73 | WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui |
74 | connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); | 74 | connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | WellenreiterConfigWindow::_instance = this; | 77 | WellenreiterConfigWindow::_instance = this; |
78 | 78 | ||
79 | connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); | 79 | connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); |
80 | connect( newNetworkAction, SIGNAL( activated(int) ), this, SLOT( changedNetworkAction(int) ) ); | 80 | connect( newNetworkAction, SIGNAL( activated(int) ), this, SLOT( changedNetworkAction(int) ) ); |
81 | connect( newClientAction, SIGNAL( activated(int) ), this, SLOT( changedClientAction(int) ) ); | 81 | connect( newClientAction, SIGNAL( activated(int) ), this, SLOT( changedClientAction(int) ) ); |
82 | connect( newStationAction, SIGNAL( activated(int) ), this, SLOT( changedStationAction(int) ) ); | 82 | connect( newStationAction, SIGNAL( activated(int) ), this, SLOT( changedStationAction(int) ) ); |
83 | connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); | 83 | connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); |
84 | 84 | ||
85 | // make the checkbox 'channelAll' control all other channels | 85 | // make the checkbox 'channelAll' control all other channels |
86 | connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); | 86 | connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); |
87 | 87 | ||
88 | connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); | 88 | connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); |
89 | 89 | ||
90 | // hide tab4 (parse) until Wellenreiter 1.2 | 90 | // hide tab4 (parse) until Wellenreiter 1.2 |
91 | tab->removePage( tab_4 ); | 91 | tab->removePage( tab_4 ); |
92 | }; | 92 | }; |
93 | 93 | ||
94 | 94 | ||
95 | void WellenreiterConfigWindow::accept() | 95 | void WellenreiterConfigWindow::accept() |
96 | { | 96 | { |
97 | save(); | 97 | save(); |
98 | QDialog::accept(); | 98 | QDialog::accept(); |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | WellenreiterConfigWindow::~WellenreiterConfigWindow() | 102 | WellenreiterConfigWindow::~WellenreiterConfigWindow() |
103 | { | 103 | { |
104 | } | 104 | } |
105 | 105 | ||
106 | 106 | ||
107 | void WellenreiterConfigWindow::performAutodetection() | 107 | void WellenreiterConfigWindow::performAutodetection() |
108 | { | 108 | { |
109 | //TODO: insert modal splash screen here | 109 | //TODO: insert modal splash screen here |
110 | // and sleep a second, so that it looks | 110 | // and sleep a second, so that it looks |
111 | // like we're actually doing something fancy... ;-) | 111 | // like we're actually doing something fancy... ;-) |
112 | 112 | ||
113 | qDebug( "WellenreiterConfigWindow::performAutodetection()" ); | 113 | qDebug( "WellenreiterConfigWindow::performAutodetection()" ); |
114 | 114 | ||
115 | // try to guess device type | 115 | // try to guess device type |
116 | QFile m( "/proc/modules" ); | 116 | QFile m( "/proc/modules" ); |
117 | if ( m.open( IO_ReadOnly ) ) | 117 | if ( m.open( IO_ReadOnly ) ) |
118 | { | 118 | { |
119 | int devicetype(0); | 119 | int devicetype(0); |
120 | QString line; | 120 | QString line; |
121 | QTextStream modules( &m ); | 121 | QTextStream modules( &m ); |
122 | while( !modules.atEnd() && !devicetype ) | 122 | while( !modules.atEnd() && !devicetype ) |
123 | { | 123 | { |
124 | modules >> line; | 124 | modules >> line; |
125 | if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; | 125 | if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; |
126 | else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; | 126 | else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; |
127 | else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; | 127 | else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; |
128 | else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; | 128 | else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; |
129 | } | 129 | } |
130 | if ( devicetype ) | 130 | if ( devicetype ) |
131 | { | 131 | { |
132 | deviceType->setCurrentItem( devicetype ); | 132 | deviceType->setCurrentItem( devicetype ); |
133 | _guess = devicetype; | 133 | _guess = devicetype; |
134 | qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); | 134 | qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); |
135 | } | 135 | } |
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
139 | 139 | ||
140 | int WellenreiterConfigWindow::driverType() const | 140 | int WellenreiterConfigWindow::driverType() const |
141 | { | 141 | { |
142 | QString name = deviceType->currentText(); | 142 | QString name = deviceType->currentText(); |
143 | if ( _devicetype.contains( name ) ) | 143 | if ( _devicetype.contains( name ) ) |
144 | { | 144 | { |
145 | return _devicetype[name]; | 145 | return _devicetype[name]; |
146 | } | 146 | } |
147 | else | 147 | else |
148 | { | 148 | { |
149 | return 0; | 149 | return 0; |
150 | } | 150 | } |
151 | }; | 151 | }; |
152 | 152 | ||
153 | 153 | ||
154 | int WellenreiterConfigWindow::hoppingInterval() const | 154 | int WellenreiterConfigWindow::hoppingInterval() const |
155 | { | 155 | { |
156 | return hopInterval->cleanText().toInt(); | 156 | return hopInterval->cleanText().toInt(); |
157 | } | 157 | } |
158 | 158 | ||
159 | 159 | ||
160 | bool WellenreiterConfigWindow::usePrismHeader() const | 160 | bool WellenreiterConfigWindow::usePrismHeader() const |
161 | { | 161 | { |
162 | return prismHeader->isChecked(); | 162 | return prismHeader->isChecked(); |
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | bool WellenreiterConfigWindow::isChannelChecked( int channel ) const | 166 | bool WellenreiterConfigWindow::isChannelChecked( int channel ) const |
167 | { | 167 | { |
168 | switch ( channel ) | 168 | switch ( channel ) |
169 | { | 169 | { |
170 | case 1: return channel1->isOn(); | 170 | case 1: return channel1->isOn(); |
171 | case 2: return channel2->isOn(); | 171 | case 2: return channel2->isOn(); |
172 | case 3: return channel3->isOn(); | 172 | case 3: return channel3->isOn(); |
173 | case 4: return channel4->isOn(); | 173 | case 4: return channel4->isOn(); |
174 | case 5: return channel5->isOn(); | 174 | case 5: return channel5->isOn(); |
175 | case 6: return channel6->isOn(); | 175 | case 6: return channel6->isOn(); |
176 | case 7: return channel7->isOn(); | 176 | case 7: return channel7->isOn(); |
177 | case 8: return channel8->isOn(); | 177 | case 8: return channel8->isOn(); |
178 | case 9: return channel9->isOn(); | 178 | case 9: return channel9->isOn(); |
179 | case 10: return channel10->isOn(); | 179 | case 10: return channel10->isOn(); |
180 | case 11: return channel11->isOn(); | 180 | case 11: return channel11->isOn(); |
181 | case 12: return channel12->isOn(); | 181 | case 12: return channel12->isOn(); |
182 | case 13: return channel13->isOn(); | 182 | case 13: return channel13->isOn(); |
183 | case 14: return channel14->isOn(); | 183 | case 14: return channel14->isOn(); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||
188 | void WellenreiterConfigWindow::changedDeviceType(int t) | 188 | void WellenreiterConfigWindow::changedDeviceType(int t) |
189 | { | 189 | { |
190 | if ( t != DEVTYPE_FILE ) return; | 190 | if ( t != DEVTYPE_FILE ) return; |
191 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false); | 191 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false); |
192 | if ( !name.isEmpty() && QFile::exists( name ) ) | 192 | if ( !name.isEmpty() && QFile::exists( name ) ) |
193 | { | 193 | { |
194 | interfaceName->insertItem( name ); | 194 | interfaceName->insertItem( name ); |
195 | interfaceName->setCurrentItem( interfaceName->count()-1 ); | 195 | interfaceName->setCurrentItem( interfaceName->count()-1 ); |
196 | } | 196 | } |
197 | else | 197 | else |
198 | { | 198 | { |
199 | deviceType->setCurrentItem( _guess ); | 199 | deviceType->setCurrentItem( _guess ); |
200 | } | 200 | } |
201 | 201 | ||
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | void WellenreiterConfigWindow::synchronizeActionsAndScripts() | 205 | void WellenreiterConfigWindow::synchronizeActionsAndScripts() |
206 | { | 206 | { |
207 | if ( newNetworkAction->currentItem() == 4 ) newNetworkScript->show(); else newNetworkScript->hide(); | 207 | if ( newNetworkAction->currentItem() == 4 ) newNetworkScript->show(); else newNetworkScript->hide(); |
208 | if ( newClientAction->currentItem() == 4 ) newClientScript->show(); else newClientScript->hide(); | 208 | if ( newClientAction->currentItem() == 4 ) newClientScript->show(); else newClientScript->hide(); |
209 | if ( newStationAction->currentItem() == 4 ) newStationScript->show(); else newStationScript->hide(); | 209 | if ( newStationAction->currentItem() == 4 ) newStationScript->show(); else newStationScript->hide(); |
210 | 210 | ||
211 | //newNetworkScript->setEnabled( newNetworkAction->currentItem() == 4 ); | 211 | //newNetworkScript->setEnabled( newNetworkAction->currentItem() == 4 ); |
212 | //newClientScript->setEnabled( newClientAction->currentItem() == 4 ); | 212 | //newClientScript->setEnabled( newClientAction->currentItem() == 4 ); |
213 | //newStationScript->setEnabled( newStationAction->currentItem() == 4 ); | 213 | //newStationScript->setEnabled( newStationAction->currentItem() == 4 ); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | void WellenreiterConfigWindow::changedNetworkAction(int t) | 217 | void WellenreiterConfigWindow::changedNetworkAction(int t) |
218 | { | 218 | { |
219 | synchronizeActionsAndScripts(); | 219 | synchronizeActionsAndScripts(); |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | void WellenreiterConfigWindow::changedClientAction(int t) | 223 | void WellenreiterConfigWindow::changedClientAction(int t) |
224 | { | 224 | { |
225 | synchronizeActionsAndScripts(); | 225 | synchronizeActionsAndScripts(); |
226 | } | 226 | } |
227 | 227 | ||
228 | 228 | ||
229 | void WellenreiterConfigWindow::changedStationAction(int t) | 229 | void WellenreiterConfigWindow::changedStationAction(int t) |
230 | { | 230 | { |
231 | synchronizeActionsAndScripts(); | 231 | synchronizeActionsAndScripts(); |
232 | } | 232 | } |
233 | 233 | ||
234 | 234 | ||
235 | void WellenreiterConfigWindow::getCaptureFileNameClicked() | 235 | void WellenreiterConfigWindow::getCaptureFileNameClicked() |
236 | { | 236 | { |
237 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); | 237 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); |
238 | qDebug( "name = %s", (const char*) name ); | 238 | qDebug( "name = %s", (const char*) name ); |
239 | if ( !name.isEmpty() ) | 239 | if ( !name.isEmpty() ) |
240 | { | 240 | { |
241 | captureFileName->setText( name ); | 241 | captureFileName->setText( name ); |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | 245 | ||
246 | void WellenreiterConfigWindow::channelAllClicked(int state) | 246 | void WellenreiterConfigWindow::channelAllClicked(int state) |
247 | { | 247 | { |
248 | bool b = state; | 248 | bool b = state; |
249 | channel1->setChecked( b ); | 249 | channel1->setChecked( b ); |
250 | channel2->setChecked( b ); | 250 | channel2->setChecked( b ); |
251 | channel3->setChecked( b ); | 251 | channel3->setChecked( b ); |
252 | channel4->setChecked( b ); | 252 | channel4->setChecked( b ); |
253 | channel5->setChecked( b ); | 253 | channel5->setChecked( b ); |
254 | channel6->setChecked( b ); | 254 | channel6->setChecked( b ); |
255 | channel7->setChecked( b ); | 255 | channel7->setChecked( b ); |
256 | channel8->setChecked( b ); | 256 | channel8->setChecked( b ); |
257 | channel9->setChecked( b ); | 257 | channel9->setChecked( b ); |
258 | channel10->setChecked( b ); | 258 | channel10->setChecked( b ); |
259 | channel11->setChecked( b ); | 259 | channel11->setChecked( b ); |
260 | channel12->setChecked( b ); | 260 | channel12->setChecked( b ); |
261 | channel13->setChecked( b ); | 261 | channel13->setChecked( b ); |
262 | channel14->setChecked( b ); | 262 | channel14->setChecked( b ); |
263 | } | 263 | } |
264 | 264 | ||
265 | 265 | ||
266 | bool WellenreiterConfigWindow::useGPS() const | 266 | bool WellenreiterConfigWindow::useGPS() const |
267 | { | 267 | { |
268 | return enableGPS->isChecked(); | 268 | return enableGPS->isChecked(); |
269 | } | 269 | } |
270 | 270 | ||
271 | 271 | ||
272 | const QString WellenreiterConfigWindow::gpsHost() const | 272 | const QString WellenreiterConfigWindow::gpsHost() const |
273 | { | 273 | { |
274 | return useGPS() ? gpsdHost->currentText() : QString::null; | 274 | return useGPS() ? gpsdHost->currentText() : QString::null; |
275 | } | 275 | } |
276 | 276 | ||
277 | 277 | ||
278 | int WellenreiterConfigWindow::gpsPort() const | 278 | int WellenreiterConfigWindow::gpsPort() const |
279 | { | 279 | { |
280 | bool ok; | 280 | bool ok; |
281 | return useGPS() ? gpsdPort->value() : -1; | 281 | return useGPS() ? gpsdPort->value() : -1; |
282 | } | 282 | } |
283 | 283 | ||
284 | 284 | ||
285 | void WellenreiterConfigWindow::performAction( const QString& type, | 285 | void WellenreiterConfigWindow::performAction( const QString& type, |
286 | const QString& essid, | 286 | const QString& essid, |
287 | const QString& mac, | 287 | const QString& mac, |
288 | bool wep, | 288 | bool wep, |
289 | int channel, | 289 | int channel, |
290 | int signal | 290 | int signal |
291 | /* , const GpsLocation& loc */ ) | 291 | /* , const GpsLocation& loc */ ) |
292 | { | 292 | { |
293 | int action; | 293 | int action; |
294 | QString script; | 294 | QString script; |
295 | 295 | ||
296 | if ( type == "network" ) | 296 | if ( type == "network" ) |
297 | { | 297 | { |
298 | action = newNetworkAction->currentItem(); | 298 | action = newNetworkAction->currentItem(); |
299 | script = newNetworkScript->text(); | 299 | script = newNetworkScript->text(); |
300 | } | 300 | } |
301 | else if ( type == "managed" || type == "adhoc" ) | 301 | else if ( type == "managed" || type == "adhoc" ) |
302 | { | 302 | { |
303 | action = newClientAction->currentItem(); | 303 | action = newClientAction->currentItem(); |
304 | script = newClientScript->text(); | 304 | script = newClientScript->text(); |
305 | } | 305 | } |
306 | else if ( type == "station" ) | 306 | else if ( type == "station" ) |
307 | { | 307 | { |
308 | action = newStationAction->currentItem(); | 308 | action = newStationAction->currentItem(); |
309 | script = newStationScript->text(); | 309 | script = newStationScript->text(); |
310 | } | 310 | } |
311 | else | 311 | else |
312 | { | 312 | { |
313 | qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); | 313 | qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); |
314 | return; | 314 | return; |
315 | } | 315 | } |
316 | 316 | ||
317 | qDebug( "for event '%s' I'm going to perform action %d (script='%s')", (const char*) type, action, (const char*) script ); | 317 | qDebug( "for event '%s' I'm going to perform action %d (script='%s')", (const char*) type, action, (const char*) script ); |
318 | 318 | ||
319 | switch( action ) | 319 | switch( action ) |
320 | { | 320 | { |
321 | case 0: /* Ignore */ return; | 321 | case 0: /* Ignore */ return; |
322 | case 1: /* Play Alarm */ ODevice::inst()->alarmSound(); return; | 322 | case 1: /* Play Alarm */ ODevice::inst()->alarmSound(); return; |
323 | case 2: /* Play Click */ ODevice::inst()->touchSound(); return; | 323 | case 2: /* Play Click */ ODevice::inst()->touchSound(); return; |
324 | case 3: /* Blink LED */ break; //FIXME: Implement this | 324 | case 3: /* Blink LED */ break; //FIXME: Implement this |
325 | case 4: /* Run Script */ | 325 | case 4: /* Run Script */ |
326 | { | 326 | { |
327 | /** | 327 | /** |
328 | * | 328 | * |
329 | * Script Substitution Information: | 329 | * Script Substitution Information: |
330 | * | 330 | * |
331 | * $SSID = SSID | 331 | * $SSID = SSID |
332 | * $MAC = MAC | 332 | * $MAC = MAC |
333 | * $WEP = Wep | 333 | * $WEP = Wep |
334 | * $CHAN = Channel | 334 | * $CHAN = Channel |
335 | * | 335 | * |
336 | **/ | 336 | **/ |
337 | script = script.replace( QRegExp( "$SSID" ), essid ); | 337 | script = script.replace( QRegExp( "$SSID" ), essid ); |
338 | script = script.replace( QRegExp( "$MAC" ), mac ); | 338 | script = script.replace( QRegExp( "$MAC" ), mac ); |
339 | script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); | 339 | script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); |
340 | script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); | 340 | script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); |
341 | 341 | ||
342 | qDebug( "going to call script '%s'", (const char*) script ); | 342 | qDebug( "going to call script '%s'", (const char*) script ); |
343 | ::system( script ); | 343 | ::system( script ); |
344 | qDebug( "script returned." ); | 344 | qDebug( "script returned." ); |
345 | return; | 345 | return; |
346 | } | 346 | } |
347 | default: assert( false ); | 347 | default: assert( false ); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | 350 | ||
351 | 351 | ||
352 | void WellenreiterConfigWindow::load() | 352 | void WellenreiterConfigWindow::load() |
353 | { | 353 | { |
354 | #ifdef Q_WS_X11 | 354 | #ifdef Q_WS_X11 |
355 | #warning Persistent Configuration not yet implemented for standalone X11 build | 355 | #warning Persistent Configuration not yet implemented for standalone X11 build |
356 | performAutodetection(); | 356 | performAutodetection(); |
357 | #else | 357 | #else |
358 | qDebug( "loading configuration settings..." ); | 358 | qDebug( "loading configuration settings..." ); |
359 | 359 | ||
360 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ | 360 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ |
361 | 361 | ||
362 | OConfig* c = oApp->config(); | 362 | OConfig* c = oApp->config(); |
363 | 363 | ||
364 | c->setGroup( "Interface" ); | 364 | c->setGroup( "Interface" ); |
365 | 365 | ||
366 | QString interface = c->readEntry( "name", "<none>" ); | 366 | QString interface = c->readEntry( "name", "<none>" ); |
367 | if ( interface != "<none>" ) | 367 | if ( interface != "<none>" ) |
368 | { | 368 | { |
369 | #if QT_VERSION < 300 | 369 | #if QT_VERSION < 300 |
370 | interfaceName->insertItem( interface, 0 ); | 370 | interfaceName->insertItem( interface, 0 ); |
371 | interfaceName->setCurrentItem( 0 ); | 371 | interfaceName->setCurrentItem( 0 ); |
372 | #else | 372 | #else |
373 | interfaceName->setCurrentText( interface ); | 373 | interfaceName->setCurrentText( interface ); |
374 | #endif | 374 | #endif |
375 | 375 | ||
376 | QString device = c->readEntry( "type", "<select>" ); | 376 | QString device = c->readEntry( "type", "<select>" ); |
377 | #if QT_VERSION < 300 | 377 | #if QT_VERSION < 300 |
378 | for ( int i = 0; i < deviceType->count(); ++i ) | 378 | for ( int i = 0; i < deviceType->count(); ++i ) |
379 | { | 379 | { |
380 | if ( deviceType->text( i ) == device ) | 380 | if ( deviceType->text( i ) == device ) |
381 | { | 381 | { |
382 | deviceType->setCurrentItem( i ); | 382 | deviceType->setCurrentItem( i ); |
383 | break; | 383 | break; |
384 | } | 384 | } |
385 | } | 385 | } |
386 | #else | 386 | #else |
387 | deviceType->setCurrentText( device ); | 387 | deviceType->setCurrentText( device ); |
388 | #endif | 388 | #endif |
389 | } | 389 | } |
390 | else | 390 | else |
391 | { | 391 | { |
392 | performAutodetection(); | 392 | performAutodetection(); |
393 | } | 393 | } |
394 | 394 | ||
395 | prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); | 395 | prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); |
396 | hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); | 396 | hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); |
397 | hopInterval->setValue( c->readNumEntry( "interval", 250 ) ); | 397 | hopInterval->setValue( c->readNumEntry( "interval", 250 ) ); |
398 | adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); | 398 | adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); |
399 | 399 | ||
400 | c->setGroup( "Capture" ); | 400 | c->setGroup( "Capture" ); |
401 | captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); | 401 | captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); |
402 | 402 | ||
403 | c->setGroup( "UI" ); | 403 | c->setGroup( "UI" ); |
404 | lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); | 404 | lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); |
405 | openTree->setChecked( c->readBoolEntry( "openTree", true ) ); | 405 | openTree->setChecked( c->readBoolEntry( "openTree", true ) ); |
406 | disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); | 406 | disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); |
407 | newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 1 ) ); // Default: Play Alarm | 407 | newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 1 ) ); // Default: Play Alarm |
408 | newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) ); | 408 | newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) ); |
409 | newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 2 ) ); // Default: Play Click | 409 | newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 2 ) ); // Default: Play Click |
410 | newClientScript->setText( c->readEntry( "newClientScript", "" ) ); | 410 | newClientScript->setText( c->readEntry( "newClientScript", "" ) ); |
411 | newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 2 ) ); // Default: Play Click | 411 | newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 2 ) ); // Default: Play Click |
412 | newStationScript->setText( c->readEntry( "newStationScript", "" ) ); | 412 | newStationScript->setText( c->readEntry( "newStationScript", "" ) ); |
413 | synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand | 413 | synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand |
414 | 414 | ||
415 | c->setGroup( "GPS" ); | 415 | c->setGroup( "GPS" ); |
416 | enableGPS->setChecked( c->readBoolEntry( "use", false ) ); | 416 | enableGPS->setChecked( c->readBoolEntry( "use", false ) ); |
417 | #if QT_VERSION < 300 | 417 | #if QT_VERSION < 300 |
418 | gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); | 418 | gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); |
419 | gpsdHost->setCurrentItem( 0 ); | 419 | gpsdHost->setCurrentItem( 0 ); |
420 | #else | 420 | #else |
421 | gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); | 421 | gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); |
422 | #endif | 422 | #endif |
423 | gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); | 423 | gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); |
424 | startGPS->setChecked( c->readBoolEntry( "start", false ) ); | 424 | startGPS->setChecked( c->readBoolEntry( "start", false ) ); |
425 | commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); | 425 | commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); |
426 | 426 | ||
427 | #endif | 427 | #endif |
428 | } | 428 | } |
429 | 429 | ||
430 | 430 | ||
431 | void WellenreiterConfigWindow::save() | 431 | void WellenreiterConfigWindow::save() |
432 | { | 432 | { |
433 | #ifdef Q_WS_X11 | 433 | #ifdef Q_WS_X11 |
434 | #warning Persistent Configuration not yet implemented for standalone X11 build | 434 | #warning Persistent Configuration not yet implemented for standalone X11 build |
435 | #else | 435 | #else |
436 | qDebug( "saving configuration settings..." ); | 436 | qDebug( "saving configuration settings..." ); |
437 | 437 | ||
438 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ | 438 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ |
439 | 439 | ||
440 | OConfig* c = oApp->config(); | 440 | OConfig* c = oApp->config(); |
441 | 441 | ||
442 | c->setGroup( "Interface" ); | 442 | c->setGroup( "Interface" ); |
443 | c->writeEntry( "name", interfaceName->currentText() ); | 443 | c->writeEntry( "name", interfaceName->currentText() ); |
444 | c->writeEntry( "type", deviceType->currentText() ); | 444 | c->writeEntry( "type", deviceType->currentText() ); |
445 | c->writeEntry( "prism", prismHeader->isChecked() ); | 445 | c->writeEntry( "prism", prismHeader->isChecked() ); |
446 | c->writeEntry( "hop", hopChannels->isChecked() ); | 446 | c->writeEntry( "hop", hopChannels->isChecked() ); |
447 | c->writeEntry( "interval", hopInterval->value() ); | 447 | c->writeEntry( "interval", hopInterval->value() ); |
448 | c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); | 448 | c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); |
449 | 449 | ||
450 | c->setGroup( "Capture" ); | 450 | c->setGroup( "Capture" ); |
451 | c->writeEntry( "filename", captureFileName->text() ); | 451 | c->writeEntry( "filename", captureFileName->text() ); |
452 | 452 | ||
453 | c->setGroup( "UI" ); | 453 | c->setGroup( "UI" ); |
454 | c->writeEntry( "lookupVendor", lookupVendor->isChecked() ); | 454 | c->writeEntry( "lookupVendor", lookupVendor->isChecked() ); |
455 | c->writeEntry( "openTree", openTree->isChecked() ); | 455 | c->writeEntry( "openTree", openTree->isChecked() ); |
456 | c->writeEntry( "disablePM", disablePM->isChecked() ); | 456 | c->writeEntry( "disablePM", disablePM->isChecked() ); |
457 | c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() ); | 457 | c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() ); |
458 | c->writeEntry( "newNetworkScript", newNetworkScript->text() ); | 458 | c->writeEntry( "newNetworkScript", newNetworkScript->text() ); |
459 | c->writeEntry( "newClientAction", newClientAction->currentItem() ); | 459 | c->writeEntry( "newClientAction", newClientAction->currentItem() ); |
460 | c->writeEntry( "newClientScript", newClientScript->text() ); | 460 | c->writeEntry( "newClientScript", newClientScript->text() ); |
461 | c->writeEntry( "newStationAction", newStationAction->currentItem() ); | 461 | c->writeEntry( "newStationAction", newStationAction->currentItem() ); |
462 | c->writeEntry( "newStationScript", newStationScript->text() ); | 462 | c->writeEntry( "newStationScript", newStationScript->text() ); |
463 | 463 | ||
464 | c->setGroup( "GPS" ); | 464 | c->setGroup( "GPS" ); |
465 | c->writeEntry( "use", enableGPS->isChecked() ); | 465 | c->writeEntry( "use", enableGPS->isChecked() ); |
466 | c->writeEntry( "host", gpsdHost->currentText() ); | 466 | c->writeEntry( "host", gpsdHost->currentText() ); |
467 | c->writeEntry( "port", gpsdPort->value() ); | 467 | c->writeEntry( "port", gpsdPort->value() ); |
468 | c->writeEntry( "start", startGPS->isChecked() ); | 468 | c->writeEntry( "start", startGPS->isChecked() ); |
469 | c->writeEntry( "command", commandGPS->text() ); | 469 | c->writeEntry( "command", commandGPS->text() ); |
470 | 470 | ||
471 | c->write(); | 471 | c->write(); |
472 | 472 | ||
473 | #endif | 473 | #endif |
474 | } | 474 | } |
diff --git a/noncore/net/wellenreiter/gui/gui.pro b/noncore/net/wellenreiter/gui/gui.pro index 188d96a..7957d4c 100644 --- a/noncore/net/wellenreiter/gui/gui.pro +++ b/noncore/net/wellenreiter/gui/gui.pro | |||
@@ -1,47 +1,47 @@ | |||
1 | DESTDIR = $(OPIEDIR)/bin | 1 | DESTDIR = $(OPIEDIR)/bin |
2 | TEMPLATE = app | 2 | TEMPLATE = app |
3 | CONFIG = qt warn_on debug | 3 | CONFIG = qt warn_on debug |
4 | 4 | ||
5 | HEADERS = wellenreiterbase.h \ | 5 | HEADERS = wellenreiterbase.h \ |
6 | mainwindow.h \ | 6 | mainwindow.h \ |
7 | wellenreiter.h \ | 7 | wellenreiter.h \ |
8 | scanlist.h \ | 8 | scanlist.h \ |
9 | logwindow.h \ | 9 | logwindow.h \ |
10 | hexwindow.h \ | 10 | hexwindow.h \ |
11 | statwindow.h \ | 11 | statwindow.h \ |
12 | configwindow.h \ | 12 | configwindow.h \ |
13 | graphwindow.h \ | 13 | graphwindow.h \ |
14 | protolistview.h \ | 14 | protolistview.h \ |
15 | gps.h | 15 | gps.h |
16 | 16 | ||
17 | SOURCES = main.cpp \ | 17 | SOURCES = main.cpp \ |
18 | mainwindow.cpp \ | 18 | mainwindow.cpp \ |
19 | wellenreiterbase.cpp \ | 19 | wellenreiterbase.cpp \ |
20 | wellenreiter.cpp \ | 20 | wellenreiter.cpp \ |
21 | scanlist.cpp \ | 21 | scanlist.cpp \ |
22 | logwindow.cpp \ | 22 | logwindow.cpp \ |
23 | hexwindow.cpp \ | 23 | hexwindow.cpp \ |
24 | statwindow.cpp \ | 24 | statwindow.cpp \ |
25 | configwindow.cpp \ | 25 | configwindow.cpp \ |
26 | graphwindow.cpp \ | 26 | graphwindow.cpp \ |
27 | protolistview.cpp \ | 27 | protolistview.cpp \ |
28 | gps.cpp | 28 | gps.cpp |
29 | 29 | ||
30 | INCLUDEPATH += $(OPIEDIR)/include | 30 | INCLUDEPATH += $(OPIEDIR)/include |
31 | DEPENDPATH += $(OPIEDIR)/include | 31 | DEPENDPATH += $(OPIEDIR)/include |
32 | INTERFACES = configbase.ui | 32 | INTERFACES = configbase.ui |
33 | TARGET = wellenreiter | 33 | TARGET = wellenreiter |
34 | 34 | ||
35 | !contains( platform, x11 ) { | 35 | !contains( platform, x11 ) { |
36 | message( qws ) | 36 | message( qws ) |
37 | include ( $(OPIEDIR)/include.pro ) | 37 | include ( $(OPIEDIR)/include.pro ) |
38 | LIBS += -lqpe -lopie -lopiecore2 -lopieui2 -lopienet2 | 38 | LIBS += -lqpe -lopiecore2 -lopieui2 -lopienet2 |
39 | } | 39 | } |
40 | 40 | ||
41 | contains( platform, x11 ) { | 41 | contains( platform, x11 ) { |
42 | LIBS += -L$(OPIEDIR)/output/lib -Wl,-rpath,$(OPIEDIR)/output/lib -Wl,-rpath,/usr/local/lib -lwellenreiter | 42 | LIBS += -L$(OPIEDIR)/output/lib -Wl,-rpath,$(OPIEDIR)/output/lib -Wl,-rpath,/usr/local/lib -lwellenreiter |
43 | SOURCES += resource.cpp | 43 | SOURCES += resource.cpp |
44 | HEADERS += resource.h | 44 | HEADERS += resource.h |
45 | DESTDIR = $(OPIEDIR)/output/bin | 45 | DESTDIR = $(OPIEDIR)/output/bin |
46 | } | 46 | } |
47 | 47 | ||
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index d4e3279..05a8913 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp | |||
@@ -1,541 +1,542 @@ | |||
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 "gps.h" | 17 | #include "gps.h" |
18 | #include "logwindow.h" | 18 | #include "logwindow.h" |
19 | #include "hexwindow.h" | 19 | #include "hexwindow.h" |
20 | #include "mainwindow.h" | 20 | #include "mainwindow.h" |
21 | #include "wellenreiter.h" | 21 | #include "wellenreiter.h" |
22 | #include "scanlist.h" | 22 | #include "scanlist.h" |
23 | 23 | ||
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qdatastream.h> | 25 | #include <qdatastream.h> |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qfileinfo.h> | 27 | #include <qfileinfo.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qiconset.h> | 31 | #include <qiconset.h> |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qstatusbar.h> | 36 | #include <qstatusbar.h> |
37 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
38 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
39 | 39 | ||
40 | #ifdef QWS | 40 | #ifdef QWS |
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | #include <opie/ofiledialog.h> | 42 | #include <opie2/ofiledialog.h> |
43 | using namespace Opie; | ||
43 | #else | 44 | #else |
44 | #include "resource.h" | 45 | #include "resource.h" |
45 | #include <qapplication.h> | 46 | #include <qapplication.h> |
46 | #include <qfiledialog.h> | 47 | #include <qfiledialog.h> |
47 | #endif | 48 | #endif |
48 | 49 | ||
49 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) | 50 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) |
50 | :QMainWindow( parent, name, f ) | 51 | :QMainWindow( parent, name, f ) |
51 | { | 52 | { |
52 | cw = new WellenreiterConfigWindow( this ); | 53 | cw = new WellenreiterConfigWindow( this ); |
53 | mw = new Wellenreiter( this ); | 54 | mw = new Wellenreiter( this ); |
54 | mw->setConfigWindow( cw ); | 55 | mw->setConfigWindow( cw ); |
55 | setCentralWidget( mw ); | 56 | setCentralWidget( mw ); |
56 | 57 | ||
57 | // setup application icon | 58 | // setup application icon |
58 | 59 | ||
59 | #ifndef QWS | 60 | #ifndef QWS |
60 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); | 61 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); |
61 | setIconText( "Wellenreiter/X11" ); | 62 | setIconText( "Wellenreiter/X11" ); |
62 | #endif | 63 | #endif |
63 | 64 | ||
64 | // setup tool buttons | 65 | // setup tool buttons |
65 | 66 | ||
66 | startButton = new QToolButton( 0 ); | 67 | startButton = new QToolButton( 0 ); |
67 | #ifdef QWS | 68 | #ifdef QWS |
68 | startButton->setAutoRaise( true ); | 69 | startButton->setAutoRaise( true ); |
69 | #endif | 70 | #endif |
70 | startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); | 71 | startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); |
71 | startButton->setEnabled( false ); | 72 | startButton->setEnabled( false ); |
72 | connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); | 73 | connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); |
73 | 74 | ||
74 | stopButton = new QToolButton( 0 ); | 75 | stopButton = new QToolButton( 0 ); |
75 | #ifdef QWS | 76 | #ifdef QWS |
76 | stopButton->setAutoRaise( true ); | 77 | stopButton->setAutoRaise( true ); |
77 | #endif | 78 | #endif |
78 | stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) ); | 79 | stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) ); |
79 | stopButton->setEnabled( false ); | 80 | stopButton->setEnabled( false ); |
80 | connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); | 81 | connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); |
81 | 82 | ||
82 | QToolButton* d = new QToolButton( 0 ); | 83 | QToolButton* d = new QToolButton( 0 ); |
83 | #ifdef QWS | 84 | #ifdef QWS |
84 | d->setAutoRaise( true ); | 85 | d->setAutoRaise( true ); |
85 | #endif | 86 | #endif |
86 | d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) ); | 87 | d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) ); |
87 | connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); | 88 | connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); |
88 | 89 | ||
89 | uploadButton = new QToolButton( 0 ); | 90 | uploadButton = new QToolButton( 0 ); |
90 | #ifdef QWS | 91 | #ifdef QWS |
91 | uploadButton->setAutoRaise( true ); | 92 | uploadButton->setAutoRaise( true ); |
92 | #endif | 93 | #endif |
93 | uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); | 94 | uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); |
94 | uploadButton->setEnabled( false ); | 95 | uploadButton->setEnabled( false ); |
95 | //uploadButton->setEnabled( true ); // DEBUGGING | 96 | //uploadButton->setEnabled( true ); // DEBUGGING |
96 | connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); | 97 | connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); |
97 | 98 | ||
98 | // setup menu bar | 99 | // setup menu bar |
99 | 100 | ||
100 | int id; | 101 | int id; |
101 | 102 | ||
102 | QMenuBar* mb = menuBar(); | 103 | QMenuBar* mb = menuBar(); |
103 | 104 | ||
104 | QPopupMenu* fileSave = new QPopupMenu( mb ); | 105 | QPopupMenu* fileSave = new QPopupMenu( mb ); |
105 | fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); | 106 | fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); |
106 | fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); | 107 | fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); |
107 | fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); | 108 | fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); |
108 | 109 | ||
109 | QPopupMenu* fileLoad = new QPopupMenu( mb ); | 110 | QPopupMenu* fileLoad = new QPopupMenu( mb ); |
110 | fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); | 111 | fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); |
111 | //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); | 112 | //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); |
112 | 113 | ||
113 | QPopupMenu* file = new QPopupMenu( mb ); | 114 | QPopupMenu* file = new QPopupMenu( mb ); |
114 | file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); | 115 | file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); |
115 | id = file->insertItem( tr( "&Load" ), fileLoad ); | 116 | id = file->insertItem( tr( "&Load" ), fileLoad ); |
116 | file->insertItem( tr( "&Save" ), fileSave ); | 117 | file->insertItem( tr( "&Save" ), fileSave ); |
117 | file->insertSeparator(); | 118 | file->insertSeparator(); |
118 | uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) ); | 119 | uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) ); |
119 | file->insertSeparator(); | 120 | file->insertSeparator(); |
120 | file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); | 121 | file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); |
121 | 122 | ||
122 | QPopupMenu* view = new QPopupMenu( mb ); | 123 | QPopupMenu* view = new QPopupMenu( mb ); |
123 | view->insertItem( tr( "&Configure..." ) ); | 124 | view->insertItem( tr( "&Configure..." ) ); |
124 | 125 | ||
125 | QPopupMenu* sniffer = new QPopupMenu( mb ); | 126 | QPopupMenu* sniffer = new QPopupMenu( mb ); |
126 | sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); | 127 | sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); |
127 | sniffer->insertSeparator(); | 128 | sniffer->insertSeparator(); |
128 | startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); | 129 | startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); |
129 | sniffer->setItemEnabled( startID, false ); | 130 | sniffer->setItemEnabled( startID, false ); |
130 | stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); | 131 | stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); |
131 | sniffer->setItemEnabled( stopID, false ); | 132 | sniffer->setItemEnabled( stopID, false ); |
132 | 133 | ||
133 | QPopupMenu* demo = new QPopupMenu( mb ); | 134 | QPopupMenu* demo = new QPopupMenu( mb ); |
134 | demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); | 135 | demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); |
135 | 136 | ||
136 | id = mb->insertItem( tr( "&File" ), file ); | 137 | id = mb->insertItem( tr( "&File" ), file ); |
137 | //id = mb->insertItem( tr( "&View" ), view ); | 138 | //id = mb->insertItem( tr( "&View" ), view ); |
138 | //mb->setItemEnabled( id, false ); | 139 | //mb->setItemEnabled( id, false ); |
139 | id = mb->insertItem( tr( "&Sniffer" ), sniffer ); | 140 | id = mb->insertItem( tr( "&Sniffer" ), sniffer ); |
140 | 141 | ||
141 | id = mb->insertItem( tr( "&Demo" ), demo ); | 142 | id = mb->insertItem( tr( "&Demo" ), demo ); |
142 | mb->setItemEnabled( id, true ); | 143 | mb->setItemEnabled( id, true ); |
143 | mb->setItemEnabled( uploadID, false ); | 144 | mb->setItemEnabled( uploadID, false ); |
144 | 145 | ||
145 | #ifdef QWS | 146 | #ifdef QWS |
146 | mb->insertItem( startButton ); | 147 | mb->insertItem( startButton ); |
147 | mb->insertItem( stopButton ); | 148 | mb->insertItem( stopButton ); |
148 | mb->insertItem( uploadButton ); | 149 | mb->insertItem( uploadButton ); |
149 | mb->insertItem( d ); | 150 | mb->insertItem( d ); |
150 | #else // Qt3 changed the insertion order. It's now totally random :( | 151 | #else // Qt3 changed the insertion order. It's now totally random :( |
151 | mb->insertItem( d ); | 152 | mb->insertItem( d ); |
152 | mb->insertItem( uploadButton ); | 153 | mb->insertItem( uploadButton ); |
153 | mb->insertItem( stopButton ); | 154 | mb->insertItem( stopButton ); |
154 | mb->insertItem( startButton ); | 155 | mb->insertItem( startButton ); |
155 | #endif | 156 | #endif |
156 | 157 | ||
157 | updateToolButtonState(); | 158 | updateToolButtonState(); |
158 | 159 | ||
159 | // setup status bar (for now only on X11) | 160 | // setup status bar (for now only on X11) |
160 | 161 | ||
161 | #ifndef QWS | 162 | #ifndef QWS |
162 | statusBar()->message( tr( "Ready." ) ); | 163 | statusBar()->message( tr( "Ready." ) ); |
163 | #endif | 164 | #endif |
164 | 165 | ||
165 | connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); | 166 | connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); |
166 | connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); | 167 | connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); |
167 | }; | 168 | }; |
168 | 169 | ||
169 | 170 | ||
170 | 171 | ||
171 | void WellenreiterMainWindow::showConfigure() | 172 | void WellenreiterMainWindow::showConfigure() |
172 | { | 173 | { |
173 | qDebug( "show configure..." ); | 174 | qDebug( "show configure..." ); |
174 | cw->setCaption( tr( "Configure" ) ); | 175 | cw->setCaption( tr( "Configure" ) ); |
175 | #ifdef QWS | 176 | #ifdef QWS |
176 | cw->showMaximized(); | 177 | cw->showMaximized(); |
177 | #endif | 178 | #endif |
178 | int result = cw->exec(); | 179 | int result = cw->exec(); |
179 | 180 | ||
180 | if ( result ) updateToolButtonState(); | 181 | if ( result ) updateToolButtonState(); |
181 | } | 182 | } |
182 | 183 | ||
183 | 184 | ||
184 | void WellenreiterMainWindow::updateToolButtonState() | 185 | void WellenreiterMainWindow::updateToolButtonState() |
185 | { | 186 | { |
186 | const QString& interface = cw->interfaceName->currentText(); | 187 | const QString& interface = cw->interfaceName->currentText(); |
187 | const int cardtype = cw->driverType(); | 188 | const int cardtype = cw->driverType(); |
188 | 189 | ||
189 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) | 190 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) |
190 | { | 191 | { |
191 | startButton->setEnabled( true ); | 192 | startButton->setEnabled( true ); |
192 | menuBar()->setItemEnabled( startID, true ); | 193 | menuBar()->setItemEnabled( startID, true ); |
193 | } | 194 | } |
194 | else | 195 | else |
195 | { | 196 | { |
196 | startButton->setEnabled( false ); | 197 | startButton->setEnabled( false ); |
197 | menuBar()->setItemEnabled( startID, false ); | 198 | menuBar()->setItemEnabled( startID, false ); |
198 | } | 199 | } |
199 | } | 200 | } |
200 | 201 | ||
201 | 202 | ||
202 | void WellenreiterMainWindow::changedSniffingState() | 203 | void WellenreiterMainWindow::changedSniffingState() |
203 | { | 204 | { |
204 | startButton->setEnabled( !mw->sniffing ); | 205 | startButton->setEnabled( !mw->sniffing ); |
205 | menuBar()->setItemEnabled( startID, !mw->sniffing ); | 206 | menuBar()->setItemEnabled( startID, !mw->sniffing ); |
206 | stopButton->setEnabled( mw->sniffing ); | 207 | stopButton->setEnabled( mw->sniffing ); |
207 | menuBar()->setItemEnabled( stopID, mw->sniffing ); | 208 | menuBar()->setItemEnabled( stopID, mw->sniffing ); |
208 | 209 | ||
209 | if ( !mw->sniffing ) | 210 | if ( !mw->sniffing ) |
210 | { | 211 | { |
211 | menuBar()->setItemEnabled( uploadID, true ); | 212 | menuBar()->setItemEnabled( uploadID, true ); |
212 | uploadButton->setEnabled( true ); | 213 | uploadButton->setEnabled( true ); |
213 | } | 214 | } |
214 | } | 215 | } |
215 | 216 | ||
216 | 217 | ||
217 | WellenreiterMainWindow::~WellenreiterMainWindow() | 218 | WellenreiterMainWindow::~WellenreiterMainWindow() |
218 | { | 219 | { |
219 | qDebug( "Wellenreiter:: bye." ); | 220 | qDebug( "Wellenreiter:: bye." ); |
220 | }; | 221 | }; |
221 | 222 | ||
222 | 223 | ||
223 | void WellenreiterMainWindow::demoAddStations() | 224 | void WellenreiterMainWindow::demoAddStations() |
224 | { | 225 | { |
225 | //mw = 0; // test SIGSGV handling | 226 | //mw = 0; // test SIGSGV handling |
226 | 227 | ||
227 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); | 228 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); |
228 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); | 229 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); |
229 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); | 230 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); |
230 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); | 231 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); |
231 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); | 232 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); |
232 | } | 233 | } |
233 | 234 | ||
234 | 235 | ||
235 | QString WellenreiterMainWindow::getFileName( bool save ) | 236 | QString WellenreiterMainWindow::getFileName( bool save ) |
236 | { | 237 | { |
237 | QMap<QString, QStringList> map; | 238 | QMap<QString, QStringList> map; |
238 | map.insert( tr("All"), QStringList() ); | 239 | map.insert( tr("All"), QStringList() ); |
239 | QStringList text; | 240 | QStringList text; |
240 | text << "text/*"; | 241 | text << "text/*"; |
241 | map.insert( tr("Text"), text ); | 242 | map.insert( tr("Text"), text ); |
242 | text << "*"; | 243 | text << "*"; |
243 | map.insert( tr("All"), text ); | 244 | map.insert( tr("All"), text ); |
244 | 245 | ||
245 | QString str; | 246 | QString str; |
246 | if ( save ) | 247 | if ( save ) |
247 | { | 248 | { |
248 | #ifdef QWS | 249 | #ifdef QWS |
249 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); | 250 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); |
250 | #else | 251 | #else |
251 | str = QFileDialog::getSaveFileName(); | 252 | str = QFileDialog::getSaveFileName(); |
252 | #endif | 253 | #endif |
253 | if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) | 254 | if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) |
254 | return ""; | 255 | return ""; |
255 | } | 256 | } |
256 | else | 257 | else |
257 | { | 258 | { |
258 | #ifdef QWS | 259 | #ifdef QWS |
259 | str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); | 260 | str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); |
260 | #else | 261 | #else |
261 | str = QFileDialog::getOpenFileName(); | 262 | str = QFileDialog::getOpenFileName(); |
262 | #endif | 263 | #endif |
263 | if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) | 264 | if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) |
264 | return ""; | 265 | return ""; |
265 | } | 266 | } |
266 | return str; | 267 | return str; |
267 | } | 268 | } |
268 | 269 | ||
269 | 270 | ||
270 | void WellenreiterMainWindow::fileSaveLog() | 271 | void WellenreiterMainWindow::fileSaveLog() |
271 | { | 272 | { |
272 | QString fname = getFileName( true ); | 273 | QString fname = getFileName( true ); |
273 | if ( !fname.isEmpty() ) | 274 | if ( !fname.isEmpty() ) |
274 | { | 275 | { |
275 | QFile f( fname ); | 276 | QFile f( fname ); |
276 | if ( f.open(IO_WriteOnly) ) | 277 | if ( f.open(IO_WriteOnly) ) |
277 | { | 278 | { |
278 | QTextStream t( &f ); | 279 | QTextStream t( &f ); |
279 | t << mw->logWindow()->getLog(); | 280 | t << mw->logWindow()->getLog(); |
280 | f.close(); | 281 | f.close(); |
281 | qDebug( "Saved log to file '%s'", (const char*) fname ); | 282 | qDebug( "Saved log to file '%s'", (const char*) fname ); |
282 | } | 283 | } |
283 | else | 284 | else |
284 | { | 285 | { |
285 | qDebug( "Problem saving log to file '%s'", (const char*) fname ); | 286 | qDebug( "Problem saving log to file '%s'", (const char*) fname ); |
286 | } | 287 | } |
287 | } | 288 | } |
288 | } | 289 | } |
289 | 290 | ||
290 | void WellenreiterMainWindow::fileSaveSession() | 291 | void WellenreiterMainWindow::fileSaveSession() |
291 | { | 292 | { |
292 | QString fname = getFileName( true ); | 293 | QString fname = getFileName( true ); |
293 | if ( !fname.isEmpty() ) | 294 | if ( !fname.isEmpty() ) |
294 | { | 295 | { |
295 | 296 | ||
296 | QFile f( fname ); | 297 | QFile f( fname ); |
297 | if ( f.open(IO_WriteOnly) ) | 298 | if ( f.open(IO_WriteOnly) ) |
298 | { | 299 | { |
299 | QDataStream t( &f ); | 300 | QDataStream t( &f ); |
300 | t << *mw->netView(); | 301 | t << *mw->netView(); |
301 | f.close(); | 302 | f.close(); |
302 | qDebug( "Saved session to file '%s'", (const char*) fname ); | 303 | qDebug( "Saved session to file '%s'", (const char*) fname ); |
303 | } | 304 | } |
304 | else | 305 | else |
305 | { | 306 | { |
306 | qDebug( "Problem saving session to file '%s'", (const char*) fname ); | 307 | qDebug( "Problem saving session to file '%s'", (const char*) fname ); |
307 | } | 308 | } |
308 | } | 309 | } |
309 | } | 310 | } |
310 | 311 | ||
311 | void WellenreiterMainWindow::fileSaveHex() | 312 | void WellenreiterMainWindow::fileSaveHex() |
312 | { | 313 | { |
313 | QString fname = getFileName( true ); | 314 | QString fname = getFileName( true ); |
314 | if ( !fname.isEmpty() ) | 315 | if ( !fname.isEmpty() ) |
315 | { | 316 | { |
316 | QFile f( fname ); | 317 | QFile f( fname ); |
317 | if ( f.open(IO_WriteOnly) ) | 318 | if ( f.open(IO_WriteOnly) ) |
318 | { | 319 | { |
319 | QTextStream t( &f ); | 320 | QTextStream t( &f ); |
320 | t << mw->hexWindow()->getLog(); | 321 | t << mw->hexWindow()->getLog(); |
321 | f.close(); | 322 | f.close(); |
322 | qDebug( "Saved hex log to file '%s'", (const char*) fname ); | 323 | qDebug( "Saved hex log to file '%s'", (const char*) fname ); |
323 | } | 324 | } |
324 | else | 325 | else |
325 | { | 326 | { |
326 | qDebug( "Problem saving hex log to file '%s'", (const char*) fname ); | 327 | qDebug( "Problem saving hex log to file '%s'", (const char*) fname ); |
327 | } | 328 | } |
328 | } | 329 | } |
329 | } | 330 | } |
330 | 331 | ||
331 | void WellenreiterMainWindow::fileLoadSession() | 332 | void WellenreiterMainWindow::fileLoadSession() |
332 | { | 333 | { |
333 | QString fname = getFileName( false ); | 334 | QString fname = getFileName( false ); |
334 | if ( !fname.isEmpty() ) | 335 | if ( !fname.isEmpty() ) |
335 | { | 336 | { |
336 | QFile f( fname ); | 337 | QFile f( fname ); |
337 | if ( f.open(IO_ReadOnly) ) | 338 | if ( f.open(IO_ReadOnly) ) |
338 | { | 339 | { |
339 | QDataStream t( &f ); | 340 | QDataStream t( &f ); |
340 | t >> *mw->netView(); | 341 | t >> *mw->netView(); |
341 | f.close(); | 342 | f.close(); |
342 | qDebug( "Loaded session from file '%s'", (const char*) fname ); | 343 | qDebug( "Loaded session from file '%s'", (const char*) fname ); |
343 | } | 344 | } |
344 | else | 345 | else |
345 | { | 346 | { |
346 | qDebug( "Problem loading session from file '%s'", (const char*) fname ); | 347 | qDebug( "Problem loading session from file '%s'", (const char*) fname ); |
347 | } | 348 | } |
348 | } | 349 | } |
349 | } | 350 | } |
350 | 351 | ||
351 | 352 | ||
352 | void WellenreiterMainWindow::fileNew() | 353 | void WellenreiterMainWindow::fileNew() |
353 | { | 354 | { |
354 | mw->netView()->clear(); | 355 | mw->netView()->clear(); |
355 | mw->logWindow()->clear(); | 356 | mw->logWindow()->clear(); |
356 | mw->hexWindow()->clear(); | 357 | mw->hexWindow()->clear(); |
357 | } | 358 | } |
358 | 359 | ||
359 | 360 | ||
360 | void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) | 361 | void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) |
361 | { | 362 | { |
362 | if ( mw->isDaemonRunning() ) | 363 | if ( mw->isDaemonRunning() ) |
363 | { | 364 | { |
364 | QMessageBox::warning( this, "Wellenreiter/Opie", | 365 | QMessageBox::warning( this, "Wellenreiter/Opie", |
365 | tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); | 366 | tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); |
366 | e->ignore(); | 367 | e->ignore(); |
367 | } | 368 | } |
368 | else | 369 | else |
369 | { | 370 | { |
370 | QMainWindow::closeEvent( e ); | 371 | QMainWindow::closeEvent( e ); |
371 | } | 372 | } |
372 | } | 373 | } |
373 | 374 | ||
374 | static const char* CAP_hostname = "www.vanille.de"; | 375 | static const char* CAP_hostname = "www.vanille.de"; |
375 | 376 | ||
376 | #include <netdb.h> | 377 | #include <netdb.h> |
377 | #include <unistd.h> | 378 | #include <unistd.h> |
378 | #include <sys/types.h> | 379 | #include <sys/types.h> |
379 | #include <sys/socket.h> | 380 | #include <sys/socket.h> |
380 | 381 | ||
381 | void WellenreiterMainWindow::uploadSession() | 382 | void WellenreiterMainWindow::uploadSession() |
382 | { | 383 | { |
383 | QLineEdit* from; | 384 | QLineEdit* from; |
384 | QLineEdit* location; | 385 | QLineEdit* location; |
385 | QLineEdit* comments; | 386 | QLineEdit* comments; |
386 | QPushButton* accept; | 387 | QPushButton* accept; |
387 | QPushButton* reject; | 388 | QPushButton* reject; |
388 | 389 | ||
389 | QDialog* d = new QDialog( 0, "session upload", true ); | 390 | QDialog* d = new QDialog( 0, "session upload", true ); |
390 | d->setCaption( tr( "Upload Session" ) ); | 391 | d->setCaption( tr( "Upload Session" ) ); |
391 | QGridLayout* g = new QGridLayout( d, 4, 2, 3 ); | 392 | QGridLayout* g = new QGridLayout( d, 4, 2, 3 ); |
392 | g->addWidget( new QLabel( tr( "From: " ), d ), 0, 0 ); | 393 | g->addWidget( new QLabel( tr( "From: " ), d ), 0, 0 ); |
393 | g->addWidget( from = new QLineEdit( d ), 0, 1 ); | 394 | g->addWidget( from = new QLineEdit( d ), 0, 1 ); |
394 | g->addWidget( new QLabel( tr( "Location: " ), d ), 1, 0 ); | 395 | g->addWidget( new QLabel( tr( "Location: " ), d ), 1, 0 ); |
395 | g->addWidget( location = new QLineEdit( d ), 1, 1 ); | 396 | g->addWidget( location = new QLineEdit( d ), 1, 1 ); |
396 | g->addWidget( new QLabel( tr( "Comments: " ), d ), 2, 0 ); | 397 | g->addWidget( new QLabel( tr( "Comments: " ), d ), 2, 0 ); |
397 | g->addWidget( comments = new QLineEdit( d ), 2, 1 ); | 398 | g->addWidget( comments = new QLineEdit( d ), 2, 1 ); |
398 | g->addWidget( accept = new QPushButton( tr( "&Ok" ), d ), 3, 0 ); | 399 | g->addWidget( accept = new QPushButton( tr( "&Ok" ), d ), 3, 0 ); |
399 | g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); | 400 | g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); |
400 | accept->setDefault( true ); | 401 | accept->setDefault( true ); |
401 | accept->setAutoDefault( true ); | 402 | accept->setAutoDefault( true ); |
402 | from->setText( "WL II User" ); | 403 | from->setText( "WL II User" ); |
403 | location->setText( "WL II Location" ); | 404 | location->setText( "WL II Location" ); |
404 | comments->setText( "No Comments." ); | 405 | comments->setText( "No Comments." ); |
405 | connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); | 406 | connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); |
406 | connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); | 407 | connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); |
407 | int result = d->exec(); | 408 | int result = d->exec(); |
408 | 409 | ||
409 | if ( !result ) | 410 | if ( !result ) |
410 | { | 411 | { |
411 | qDebug( "Session upload cancelled :(" ); | 412 | qDebug( "Session upload cancelled :(" ); |
412 | return; | 413 | return; |
413 | } | 414 | } |
414 | 415 | ||
415 | qDebug( "Starting upload..." ); | 416 | qDebug( "Starting upload..." ); |
416 | 417 | ||
417 | struct sockaddr_in raddr; | 418 | struct sockaddr_in raddr; |
418 | struct hostent *rhost_info; | 419 | struct hostent *rhost_info; |
419 | int sock = -1; | 420 | int sock = -1; |
420 | bool ok = false; | 421 | bool ok = false; |
421 | 422 | ||
422 | rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); | 423 | rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); |
423 | if ( rhost_info ) | 424 | if ( rhost_info ) |
424 | { | 425 | { |
425 | 426 | ||
426 | 427 | ||
427 | if ( !QFile::exists( mw->captureFileName() ) ) | 428 | if ( !QFile::exists( mw->captureFileName() ) ) |
428 | { | 429 | { |
429 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Logfile '%1' doesn't exist</p>").arg( mw->captureFileName() ) ); | 430 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Logfile '%1' doesn't exist</p>").arg( mw->captureFileName() ) ); |
430 | return; | 431 | return; |
431 | } | 432 | } |
432 | 433 | ||
433 | QFile f( mw->captureFileName() ); | 434 | QFile f( mw->captureFileName() ); |
434 | if ( !f.open( IO_ReadOnly ) ) | 435 | if ( !f.open( IO_ReadOnly ) ) |
435 | { | 436 | { |
436 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Can't open Logfile '%1'</p>").arg( mw->captureFileName() ) ); | 437 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Can't open Logfile '%1'</p>").arg( mw->captureFileName() ) ); |
437 | return; | 438 | return; |
438 | } | 439 | } |
439 | 440 | ||
440 | int content_length = f.size(); | 441 | int content_length = f.size(); |
441 | 442 | ||
442 | ::memset( &raddr, 0, sizeof (struct sockaddr_in) ); | 443 | ::memset( &raddr, 0, sizeof (struct sockaddr_in) ); |
443 | ::memcpy( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); | 444 | ::memcpy( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); |
444 | raddr.sin_family = rhost_info-> h_addrtype; | 445 | raddr.sin_family = rhost_info-> h_addrtype; |
445 | raddr.sin_port = htons ( 80 ); | 446 | raddr.sin_port = htons ( 80 ); |
446 | 447 | ||
447 | sock = ::socket( AF_INET, SOCK_STREAM, 0 ); | 448 | sock = ::socket( AF_INET, SOCK_STREAM, 0 ); |
448 | 449 | ||
449 | if ( sock >= 0 ) | 450 | if ( sock >= 0 ) |
450 | { | 451 | { |
451 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) | 452 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) |
452 | { | 453 | { |
453 | QString header; | 454 | QString header; |
454 | QString content; | 455 | QString content; |
455 | QString preambel; | 456 | QString preambel; |
456 | 457 | ||
457 | header = "" | 458 | header = "" |
458 | "POST /projects/capturedump.spy HTTP/1.1\r\n" | 459 | "POST /projects/capturedump.spy HTTP/1.1\r\n" |
459 | "Host: www.vanille.de\r\n" | 460 | "Host: www.vanille.de\r\n" |
460 | "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031010 Galeon/1.3.10\r\n" | 461 | "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031010 Galeon/1.3.10\r\n" |
461 | "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1\r\n" | 462 | "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1\r\n" |
462 | "Accept-Language: en\r\n" | 463 | "Accept-Language: en\r\n" |
463 | "Accept-Encoding: gzip, deflate, compress;q=0.9\r\n" | 464 | "Accept-Encoding: gzip, deflate, compress;q=0.9\r\n" |
464 | "Accept-Charset: us-ascii,utf-8;q=0.7,*;q=0.7\r\n" | 465 | "Accept-Charset: us-ascii,utf-8;q=0.7,*;q=0.7\r\n" |
465 | "Keep-Alive: 300\r\n" | 466 | "Keep-Alive: 300\r\n" |
466 | "Connection: keep-alive\r\n" | 467 | "Connection: keep-alive\r\n" |
467 | "Referer: http://www.vanille.de/projects/capturedump.spy\r\n" | 468 | "Referer: http://www.vanille.de/projects/capturedump.spy\r\n" |
468 | "Content-Type: multipart/form-data; boundary=---------------------------97267758015830030481215568065\r\n" | 469 | "Content-Type: multipart/form-data; boundary=---------------------------97267758015830030481215568065\r\n" |
469 | "Content-Length: %1\r\n" | 470 | "Content-Length: %1\r\n" |
470 | "\r\n"; | 471 | "\r\n"; |
471 | 472 | ||
472 | content = "" | 473 | content = "" |
473 | "-----------------------------97267758015830030481215568065\r\n" | 474 | "-----------------------------97267758015830030481215568065\r\n" |
474 | "Content-Disposition: form-data; name=\"Name\"\r\n" | 475 | "Content-Disposition: form-data; name=\"Name\"\r\n" |
475 | "\r\n" | 476 | "\r\n" |
476 | "%1\r\n" | 477 | "%1\r\n" |
477 | "-----------------------------97267758015830030481215568065\r\n" | 478 | "-----------------------------97267758015830030481215568065\r\n" |
478 | "Content-Disposition: form-data; name=\"Location\"\r\n" | 479 | "Content-Disposition: form-data; name=\"Location\"\r\n" |
479 | "\r\n" | 480 | "\r\n" |
480 | "%2\r\n" | 481 | "%2\r\n" |
481 | "-----------------------------97267758015830030481215568065\r\n" | 482 | "-----------------------------97267758015830030481215568065\r\n" |
482 | "Content-Disposition: form-data; name=\"Comments\"\r\n" | 483 | "Content-Disposition: form-data; name=\"Comments\"\r\n" |
483 | "\r\n" | 484 | "\r\n" |
484 | "%3\r\n" | 485 | "%3\r\n" |
485 | "-----------------------------97267758015830030481215568065\r\n" | 486 | "-----------------------------97267758015830030481215568065\r\n" |
486 | "Content-Disposition: form-data; name=\"upfile\"; filename=\"%4\"\r\n" | 487 | "Content-Disposition: form-data; name=\"upfile\"; filename=\"%4\"\r\n" |
487 | "Content-Type: application/octet-stream\r\n" | 488 | "Content-Type: application/octet-stream\r\n" |
488 | "\r\n"; | 489 | "\r\n"; |
489 | 490 | ||
490 | preambel = "" | 491 | preambel = "" |
491 | "\r\n-----------------------------97267758015830030481215568065--\r\n"; | 492 | "\r\n-----------------------------97267758015830030481215568065--\r\n"; |
492 | 493 | ||
493 | content = content.arg( from->text().isEmpty() ? QString( "Anonymous Wellenreiter II User" ) : from->text() ); | 494 | content = content.arg( from->text().isEmpty() ? QString( "Anonymous Wellenreiter II User" ) : from->text() ); |
494 | content = content.arg( location->text().isEmpty() ? QString( "Anonymous Wellenreiter II Location" ) : location->text() ); | 495 | content = content.arg( location->text().isEmpty() ? QString( "Anonymous Wellenreiter II Location" ) : location->text() ); |
495 | content = content.arg( comments->text().isEmpty() ? QString( "Anonymous Wellenreiter II Comments" ) : comments->text() ); | 496 | content = content.arg( comments->text().isEmpty() ? QString( "Anonymous Wellenreiter II Comments" ) : comments->text() ); |
496 | content = content.arg( mw->captureFileName() ); | 497 | content = content.arg( mw->captureFileName() ); |
497 | 498 | ||
498 | header = header.arg( QString::number( content.length() + f.size() + preambel.length() ) ); | 499 | header = header.arg( QString::number( content.length() + f.size() + preambel.length() ) ); |
499 | 500 | ||
500 | // write header | 501 | // write header |
501 | 502 | ||
502 | const char* ascii = header.latin1(); | 503 | const char* ascii = header.latin1(); |
503 | uint ascii_len = ::strlen( ascii ); | 504 | uint ascii_len = ::strlen( ascii ); |
504 | ::write ( sock, ascii, ascii_len ); | 505 | ::write ( sock, ascii, ascii_len ); |
505 | 506 | ||
506 | // write fixed content | 507 | // write fixed content |
507 | 508 | ||
508 | ascii = content.latin1(); | 509 | ascii = content.latin1(); |
509 | ascii_len = ::strlen( ascii ); | 510 | ascii_len = ::strlen( ascii ); |
510 | ::write ( sock, ascii, ascii_len ); | 511 | ::write ( sock, ascii, ascii_len ); |
511 | 512 | ||
512 | // write variable content | 513 | // write variable content |
513 | 514 | ||
514 | char ch; | 515 | char ch; |
515 | while ( !f.atEnd() ) | 516 | while ( !f.atEnd() ) |
516 | { | 517 | { |
517 | f.readBlock( &ch, 1 ); | 518 | f.readBlock( &ch, 1 ); |
518 | ::write ( sock, &ch, 1 ); | 519 | ::write ( sock, &ch, 1 ); |
519 | } | 520 | } |
520 | 521 | ||
521 | // write preambel | 522 | // write preambel |
522 | 523 | ||
523 | ascii = preambel.latin1(); | 524 | ascii = preambel.latin1(); |
524 | ascii_len = ::strlen( ascii ); | 525 | ascii_len = ::strlen( ascii ); |
525 | ::write ( sock, ascii, ascii_len ); | 526 | ::write ( sock, ascii, ascii_len ); |
526 | 527 | ||
527 | // done! | 528 | // done! |
528 | 529 | ||
529 | ok = true; | 530 | ok = true; |
530 | } | 531 | } |
531 | } | 532 | } |
532 | ::close ( sock ); | 533 | ::close ( sock ); |
533 | } | 534 | } |
534 | if ( ok ) | 535 | if ( ok ) |
535 | QMessageBox::information( 0, tr( "Success" ), | 536 | QMessageBox::information( 0, tr( "Success" ), |
536 | QString ( "<p>%1</p>" ).arg( tr( "Capture Dump was uploaded to %1" ) ).arg( CAP_hostname ) ); | 537 | QString ( "<p>%1</p>" ).arg( tr( "Capture Dump was uploaded to %1" ) ).arg( CAP_hostname ) ); |
537 | else | 538 | else |
538 | QMessageBox::warning( 0, tr( "Error" ), | 539 | QMessageBox::warning( 0, tr( "Error" ), |
539 | QString ( "<p>%1</p>" ).arg ( tr( "Connection to %1 failed" ) ).arg( CAP_hostname ) ); | 540 | QString ( "<p>%1</p>" ).arg ( tr( "Connection to %1 failed" ) ).arg( CAP_hostname ) ); |
540 | } | 541 | } |
541 | 542 | ||
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 10ead53..b42f1df 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -1,563 +1,564 @@ | |||
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 "scanlist.h" | 16 | #include "scanlist.h" |
17 | #include "configwindow.h" | 17 | #include "configwindow.h" |
18 | #include "logwindow.h" | 18 | #include "logwindow.h" |
19 | 19 | ||
20 | #include <assert.h> | 20 | #include <assert.h> |
21 | #include <qcursor.h> | 21 | #include <qcursor.h> |
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include <qtextstream.h> | 23 | #include <qtextstream.h> |
24 | #include <qpopupmenu.h> | 24 | #include <qpopupmenu.h> |
25 | #include <qcheckbox.h> | 25 | #include <qcheckbox.h> |
26 | 26 | ||
27 | #ifdef QWS | 27 | #ifdef QWS |
28 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | #ifdef QWS | 31 | #ifdef QWS |
32 | #include <qpe/resource.h> | 32 | #include <qpe/resource.h> |
33 | #else | 33 | #else |
34 | #include "resource.h" | 34 | #include "resource.h" |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | const int col_type = 0; | 37 | const int col_type = 0; |
38 | const int col_essid = 0; | 38 | const int col_essid = 0; |
39 | const int col_sig = 1; | 39 | const int col_sig = 1; |
40 | const int col_ap = 2; | 40 | const int col_ap = 2; |
41 | const int col_channel = 3; | 41 | const int col_channel = 3; |
42 | const int col_wep = 4; | 42 | const int col_wep = 4; |
43 | const int col_traffic = 5; | 43 | const int col_traffic = 5; |
44 | const int col_ip = 6; | 44 | const int col_ip = 6; |
45 | const int col_manuf = 7; | 45 | const int col_manuf = 7; |
46 | const int col_firstseen = 8; | 46 | const int col_firstseen = 8; |
47 | const int col_lastseen = 9; | 47 | const int col_lastseen = 9; |
48 | const int col_location = 10; | 48 | const int col_location = 10; |
49 | 49 | ||
50 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 50 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
51 | :OListView( parent, name ) | 51 | :OListView( parent, name ) |
52 | { | 52 | { |
53 | 53 | ||
54 | setFrameShape( QListView::StyledPanel ); | 54 | setFrameShape( QListView::StyledPanel ); |
55 | setFrameShadow( QListView::Sunken ); | 55 | setFrameShadow( QListView::Sunken ); |
56 | 56 | ||
57 | addColumn( tr( "Net/Station" ) ); | 57 | addColumn( tr( "Net/Station" ) ); |
58 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); | 58 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); |
59 | addColumn( tr( "#" ) ); | 59 | addColumn( tr( "#" ) ); |
60 | setColumnAlignment( col_sig, AlignCenter ); | 60 | setColumnAlignment( col_sig, AlignCenter ); |
61 | addColumn( tr( "MAC" ) ); | 61 | addColumn( tr( "MAC" ) ); |
62 | setColumnAlignment( col_ap, AlignCenter ); | 62 | setColumnAlignment( col_ap, AlignCenter ); |
63 | addColumn( tr( "Chn" ) ); | 63 | addColumn( tr( "Chn" ) ); |
64 | setColumnAlignment( col_channel, AlignCenter ); | 64 | setColumnAlignment( col_channel, AlignCenter ); |
65 | addColumn( tr( "W" ) ); | 65 | addColumn( tr( "W" ) ); |
66 | setColumnAlignment( col_wep, AlignCenter ); | 66 | setColumnAlignment( col_wep, AlignCenter ); |
67 | addColumn( tr( "T" ) ); | 67 | addColumn( tr( "T" ) ); |
68 | setColumnAlignment( col_traffic, AlignCenter ); | 68 | setColumnAlignment( col_traffic, AlignCenter ); |
69 | addColumn( tr( "IP" ) ); | 69 | addColumn( tr( "IP" ) ); |
70 | setColumnAlignment( col_ip, AlignCenter ); | 70 | setColumnAlignment( col_ip, AlignCenter ); |
71 | addColumn( tr( "Manufacturer" ) ); | 71 | addColumn( tr( "Manufacturer" ) ); |
72 | setColumnAlignment( col_manuf, AlignCenter ); | 72 | setColumnAlignment( col_manuf, AlignCenter ); |
73 | addColumn( tr( "First Seen" ) ); | 73 | addColumn( tr( "First Seen" ) ); |
74 | setColumnAlignment( col_firstseen, AlignCenter ); | 74 | setColumnAlignment( col_firstseen, AlignCenter ); |
75 | addColumn( tr( "Last Seen" ) ); | 75 | addColumn( tr( "Last Seen" ) ); |
76 | setColumnAlignment( col_lastseen, AlignCenter ); | 76 | setColumnAlignment( col_lastseen, AlignCenter ); |
77 | addColumn( tr( "Location" ) ); | 77 | addColumn( tr( "Location" ) ); |
78 | setColumnAlignment( col_location, AlignCenter ); | 78 | setColumnAlignment( col_location, AlignCenter ); |
79 | setRootIsDecorated( true ); | 79 | setRootIsDecorated( true ); |
80 | setAllColumnsShowFocus( true ); | 80 | setAllColumnsShowFocus( true ); |
81 | 81 | ||
82 | connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), | 82 | connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), |
83 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); | 83 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); |
84 | 84 | ||
85 | #ifdef QWS | 85 | #ifdef QWS |
86 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 86 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | }; | 89 | }; |
90 | 90 | ||
91 | 91 | ||
92 | MScanListView::~MScanListView() | 92 | MScanListView::~MScanListView() |
93 | { | 93 | { |
94 | }; | 94 | }; |
95 | 95 | ||
96 | 96 | ||
97 | OListViewItem* MScanListView::childFactory() | 97 | OListViewItem* MScanListView::childFactory() |
98 | { | 98 | { |
99 | return new MScanListItem( this ); | 99 | return new MScanListItem( this ); |
100 | } | 100 | } |
101 | 101 | ||
102 | 102 | ||
103 | void MScanListView::serializeTo( QDataStream& s) const | 103 | void MScanListView::serializeTo( QDataStream& s) const |
104 | { | 104 | { |
105 | qDebug( "serializing MScanListView" ); | 105 | qDebug( "serializing MScanListView" ); |
106 | OListView::serializeTo( s ); | 106 | OListView::serializeTo( s ); |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | void MScanListView::serializeFrom( QDataStream& s) | 110 | void MScanListView::serializeFrom( QDataStream& s) |
111 | { | 111 | { |
112 | qDebug( "serializing MScanListView" ); | 112 | qDebug( "serializing MScanListView" ); |
113 | OListView::serializeFrom( s ); | 113 | OListView::serializeFrom( s ); |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | void MScanListView::addNewItem( const QString& type, | 117 | void MScanListView::addNewItem( const QString& type, |
118 | const QString& essid, | 118 | const QString& essid, |
119 | const OMacAddress& mac, | 119 | const OMacAddress& mac, |
120 | bool wep, | 120 | bool wep, |
121 | int channel, | 121 | int channel, |
122 | int signal, | 122 | int signal, |
123 | const GpsLocation& loc, | 123 | const GpsLocation& loc, |
124 | bool probe ) | 124 | bool probe ) |
125 | { | 125 | { |
126 | QString macaddr = mac.toString(true); | 126 | QString macaddr = mac.toString(true); |
127 | 127 | ||
128 | #ifdef DEBUG | 128 | #ifdef DEBUG |
129 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, | 129 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, |
130 | (const char*) essid, (const char*) macaddr, channel ); | 130 | (const char*) essid, (const char*) macaddr, channel ); |
131 | #endif | 131 | #endif |
132 | 132 | ||
133 | // search, if we already have seen this net | 133 | // search, if we already have seen this net |
134 | 134 | ||
135 | QString s; | 135 | QString s; |
136 | MScanListItem* network; | 136 | MScanListItem* network; |
137 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); | 137 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); |
138 | 138 | ||
139 | while ( item && ( item->text( col_essid ) != essid ) ) | 139 | while ( item && ( item->text( col_essid ) != essid ) ) |
140 | { | 140 | { |
141 | #ifdef DEBUG | 141 | #ifdef DEBUG |
142 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); | 142 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); |
143 | #endif | 143 | #endif |
144 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 144 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
145 | } | 145 | } |
146 | if ( item ) | 146 | if ( item ) |
147 | { | 147 | { |
148 | // we have already seen this net, check all childs if MAC exists | 148 | // we have already seen this net, check all childs if MAC exists |
149 | 149 | ||
150 | network = item; | 150 | network = item; |
151 | 151 | ||
152 | item = static_cast<MScanListItem*> ( item->firstChild() ); | 152 | item = static_cast<MScanListItem*> ( item->firstChild() ); |
153 | assert( item ); // this shouldn't fail | 153 | assert( item ); // this shouldn't fail |
154 | 154 | ||
155 | while ( item && ( item->text( col_ap ) != macaddr ) ) | 155 | while ( item && ( item->text( col_ap ) != macaddr ) ) |
156 | { | 156 | { |
157 | #ifdef DEBUG | 157 | #ifdef DEBUG |
158 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); | 158 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); |
159 | #endif | 159 | #endif |
160 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 160 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
161 | } | 161 | } |
162 | 162 | ||
163 | if ( item ) | 163 | if ( item ) |
164 | { | 164 | { |
165 | // we have already seen this item, it's a dupe | 165 | // we have already seen this item, it's a dupe |
166 | #ifdef DEBUG | 166 | #ifdef DEBUG |
167 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | 167 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); |
168 | #endif | 168 | #endif |
169 | item->receivedBeacon(); | 169 | item->receivedBeacon(); |
170 | return; | 170 | return; |
171 | } | 171 | } |
172 | } | 172 | } |
173 | else | 173 | else |
174 | { | 174 | { |
175 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); | 175 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); |
176 | MLogWindow::logwindow()->log( s ); | 176 | MLogWindow::logwindow()->log( s ); |
177 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); | 177 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); |
178 | } | 178 | } |
179 | 179 | ||
180 | 180 | ||
181 | // insert new station as child from network | 181 | // insert new station as child from network |
182 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 182 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
183 | 183 | ||
184 | #ifdef DEBUG | 184 | #ifdef DEBUG |
185 | qDebug( "inserting new station %s", (const char*) macaddr ); | 185 | qDebug( "inserting new station %s", (const char*) macaddr ); |
186 | #endif | 186 | #endif |
187 | 187 | ||
188 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 188 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
189 | station->setManufacturer( mac.manufacturer() ); | 189 | station->setManufacturer( mac.manufacturer() ); |
190 | station->setLocation( loc.dmsPosition() ); | 190 | station->setLocation( loc.dmsPosition() ); |
191 | 191 | ||
192 | if ( type == "managed" ) | 192 | if ( type == "managed" ) |
193 | { | 193 | { |
194 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); | 194 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); |
195 | } | 195 | } |
196 | else | 196 | else |
197 | { | 197 | { |
198 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); | 198 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); |
199 | } | 199 | } |
200 | MLogWindow::logwindow()->log( s ); | 200 | MLogWindow::logwindow()->log( s ); |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) | 204 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) |
205 | { | 205 | { |
206 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); | 206 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); |
207 | 207 | ||
208 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) | 208 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) |
209 | { | 209 | { |
210 | #ifdef DEBUG | 210 | #ifdef DEBUG |
211 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); | 211 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); |
212 | #endif | 212 | #endif |
213 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 213 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
214 | } | 214 | } |
215 | 215 | ||
216 | if ( subitem ) | 216 | if ( subitem ) |
217 | { | 217 | { |
218 | // we have already seen this item, it's a dupe | 218 | // we have already seen this item, it's a dupe |
219 | #ifdef DEBUG | 219 | #ifdef DEBUG |
220 | qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); | 220 | qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); |
221 | #endif | 221 | #endif |
222 | subitem->receivedBeacon(); //FIXME: sent data bit | 222 | subitem->receivedBeacon(); //FIXME: sent data bit |
223 | return; | 223 | return; |
224 | } | 224 | } |
225 | 225 | ||
226 | // Hey, it seems to be a new item :-D | 226 | // Hey, it seems to be a new item :-D |
227 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); | 227 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); |
228 | station->setManufacturer( addr.manufacturer() ); | 228 | station->setManufacturer( addr.manufacturer() ); |
229 | 229 | ||
230 | QString s; | 230 | QString s; |
231 | if ( type == "station" ) | 231 | if ( type == "station" ) |
232 | { | 232 | { |
233 | s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); | 233 | s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); |
234 | } | 234 | } |
235 | else | 235 | else |
236 | { | 236 | { |
237 | s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); | 237 | s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); |
238 | } | 238 | } |
239 | MLogWindow::logwindow()->log( s ); | 239 | MLogWindow::logwindow()->log( s ); |
240 | } | 240 | } |
241 | 241 | ||
242 | 242 | ||
243 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) | 243 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) |
244 | { | 244 | { |
245 | qDebug( "WDSTraffic: %s and %s seem to form a WDS", (const char*) viaFrom.toString(), (const char*) viaTo.toString() ); | ||
245 | QString s; | 246 | QString s; |
246 | MScanListItem* network; | 247 | MScanListItem* network; |
247 | 248 | ||
248 | QListViewItemIterator it( this ); | 249 | QListViewItemIterator it( this ); |
249 | while ( it.current() && | 250 | while ( it.current() && |
250 | it.current()->text( col_ap ) != viaFrom.toString(true) && | 251 | it.current()->text( col_ap ) != viaFrom.toString(true) && |
251 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; | 252 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; |
252 | 253 | ||
253 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 254 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
254 | 255 | ||
255 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations | 256 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations |
256 | { | 257 | { |
257 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); | 258 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); |
258 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); | 259 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); |
259 | } | 260 | } |
260 | else | 261 | else |
261 | { | 262 | { |
262 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); | 263 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); |
263 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); | 264 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); |
264 | } | 265 | } |
265 | } | 266 | } |
266 | 267 | ||
267 | 268 | ||
268 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 269 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
269 | { | 270 | { |
270 | QString s; | 271 | QString s; |
271 | MScanListItem* network; | 272 | MScanListItem* network; |
272 | 273 | ||
273 | QListViewItemIterator it( this ); | 274 | QListViewItemIterator it( this ); |
274 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 275 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
275 | 276 | ||
276 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 277 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
277 | 278 | ||
278 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 279 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
279 | { | 280 | { |
280 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); | 281 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); |
281 | } | 282 | } |
282 | else | 283 | else |
283 | { | 284 | { |
284 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 285 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); |
285 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); | 286 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); |
286 | 287 | ||
287 | } | 288 | } |
288 | } | 289 | } |
289 | 290 | ||
290 | 291 | ||
291 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 292 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
292 | { | 293 | { |
293 | QString s; | 294 | QString s; |
294 | MScanListItem* network; | 295 | MScanListItem* network; |
295 | 296 | ||
296 | QListViewItemIterator it( this ); | 297 | QListViewItemIterator it( this ); |
297 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 298 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
298 | 299 | ||
299 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 300 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
300 | 301 | ||
301 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 302 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
302 | { | 303 | { |
303 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); | 304 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); |
304 | } | 305 | } |
305 | else | 306 | else |
306 | { | 307 | { |
307 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 308 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); |
308 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); | 309 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); |
309 | } | 310 | } |
310 | } | 311 | } |
311 | 312 | ||
312 | 313 | ||
313 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 314 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
314 | { | 315 | { |
315 | qWarning( "D'oh! Not yet implemented..." ); | 316 | qWarning( "D'oh! Not yet implemented..." ); |
316 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); | 317 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); |
317 | } | 318 | } |
318 | 319 | ||
319 | 320 | ||
320 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) | 321 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) |
321 | { | 322 | { |
322 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); | 323 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); |
323 | 324 | ||
324 | QListViewItemIterator it( this ); | 325 | QListViewItemIterator it( this ); |
325 | for ( ; it.current(); ++it ) | 326 | for ( ; it.current(); ++it ) |
326 | { | 327 | { |
327 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 328 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
328 | { | 329 | { |
329 | it.current()->setText( col_ip, ip ); | 330 | it.current()->setText( col_ip, ip ); |
330 | return; | 331 | return; |
331 | } | 332 | } |
332 | } | 333 | } |
333 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 334 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); |
334 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", | 335 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", |
335 | (const char*) macaddr.toString(), (const char*) ip ) ); | 336 | (const char*) macaddr.toString(), (const char*) ip ) ); |
336 | } | 337 | } |
337 | 338 | ||
338 | 339 | ||
339 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) | 340 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) |
340 | { | 341 | { |
341 | qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip ); | 342 | qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip ); |
342 | 343 | ||
343 | //TODO: Refactor that out, we need it all over the place. | 344 | //TODO: Refactor that out, we need it all over the place. |
344 | // Best to do it in a more comfortable abstraction in OListView | 345 | // Best to do it in a more comfortable abstraction in OListView |
345 | // (Hmm, didn't I already start something in this direction?) | 346 | // (Hmm, didn't I already start something in this direction?) |
346 | 347 | ||
347 | QListViewItemIterator it( this ); | 348 | QListViewItemIterator it( this ); |
348 | for ( ; it.current(); ++it ) | 349 | for ( ; it.current(); ++it ) |
349 | { | 350 | { |
350 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 351 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
351 | { | 352 | { |
352 | 353 | ||
353 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); | 354 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); |
354 | 355 | ||
355 | while ( subitem && ( subitem->text( col_essid ) != name ) ) | 356 | while ( subitem && ( subitem->text( col_essid ) != name ) ) |
356 | { | 357 | { |
357 | #ifdef DEBUG | 358 | #ifdef DEBUG |
358 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); | 359 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); |
359 | #endif | 360 | #endif |
360 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 361 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
361 | } | 362 | } |
362 | 363 | ||
363 | if ( subitem ) | 364 | if ( subitem ) |
364 | { | 365 | { |
365 | // we have already seen this item, it's a dupe | 366 | // we have already seen this item, it's a dupe |
366 | #ifdef DEBUG | 367 | #ifdef DEBUG |
367 | qDebug( "%s is a dupe - ignoring...", (const char*) name ); | 368 | qDebug( "%s is a dupe - ignoring...", (const char*) name ); |
368 | #endif | 369 | #endif |
369 | subitem->receivedBeacon(); //FIXME: sent data bit | 370 | subitem->receivedBeacon(); //FIXME: sent data bit |
370 | return; | 371 | return; |
371 | } | 372 | } |
372 | 373 | ||
373 | // never seen that - add new item | 374 | // never seen that - add new item |
374 | 375 | ||
375 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); | 376 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); |
376 | item->setText( col_essid, name ); | 377 | item->setText( col_essid, name ); |
377 | 378 | ||
378 | return; | 379 | return; |
379 | } | 380 | } |
380 | } | 381 | } |
381 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 382 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); |
382 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", | 383 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", |
383 | (const char*) macaddr.toString(), (const char*) ip ) ); | 384 | (const char*) macaddr.toString(), (const char*) ip ) ); |
384 | } | 385 | } |
385 | 386 | ||
386 | 387 | ||
387 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) | 388 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) |
388 | { | 389 | { |
389 | if ( !item ) return; | 390 | if ( !item ) return; |
390 | 391 | ||
391 | MScanListItem* itm = static_cast<MScanListItem*>( item ); | 392 | MScanListItem* itm = static_cast<MScanListItem*>( item ); |
392 | 393 | ||
393 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", | 394 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", |
394 | (const char*) itm->text(0), (const char*) itm->type, col ); | 395 | (const char*) itm->text(0), (const char*) itm->type, col ); |
395 | 396 | ||
396 | if ( itm->type == "adhoc" || itm->type == "managed" ) | 397 | if ( itm->type == "adhoc" || itm->type == "managed" ) |
397 | { | 398 | { |
398 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); | 399 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); |
399 | 400 | ||
400 | QPopupMenu m( this ); | 401 | QPopupMenu m( this ); |
401 | m.insertItem( entry, 37773, 0 ); | 402 | m.insertItem( entry, 37773, 0 ); |
402 | int result = m.exec( QCursor::pos() ); | 403 | int result = m.exec( QCursor::pos() ); |
403 | if ( result == 37773 ) | 404 | if ( result == 37773 ) |
404 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); | 405 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); |
405 | } | 406 | } |
406 | } | 407 | } |
407 | 408 | ||
408 | //============================================================ | 409 | //============================================================ |
409 | // MScanListItem | 410 | // MScanListItem |
410 | //============================================================ | 411 | //============================================================ |
411 | 412 | ||
412 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, | 413 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, |
413 | bool wep, int channel, int signal, bool probed ) | 414 | bool wep, int channel, int signal, bool probed ) |
414 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 415 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
415 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 416 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
416 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 417 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
417 | { | 418 | { |
418 | #ifdef DEBUG | 419 | #ifdef DEBUG |
419 | qDebug( "creating scanlist item" ); | 420 | qDebug( "creating scanlist item" ); |
420 | #endif | 421 | #endif |
421 | 422 | ||
422 | if ( WellenreiterConfigWindow::instance() ) | 423 | if ( WellenreiterConfigWindow::instance() ) |
423 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 424 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
424 | 425 | ||
425 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); | 426 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); |
426 | } | 427 | } |
427 | 428 | ||
428 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, | 429 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, |
429 | bool wep, int channel, int signal ) | 430 | bool wep, int channel, int signal ) |
430 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 431 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
431 | { | 432 | { |
432 | #ifdef DEBUG | 433 | #ifdef DEBUG |
433 | qDebug( "creating scanlist item" ); | 434 | qDebug( "creating scanlist item" ); |
434 | #endif | 435 | #endif |
435 | if ( WellenreiterConfigWindow::instance() ) | 436 | if ( WellenreiterConfigWindow::instance() ) |
436 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 437 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
437 | 438 | ||
438 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); | 439 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); |
439 | } | 440 | } |
440 | 441 | ||
441 | const QString& MScanListItem::essid() const | 442 | const QString& MScanListItem::essid() const |
442 | { | 443 | { |
443 | if ( type == "network" ) | 444 | if ( type == "network" ) |
444 | return _essid; | 445 | return _essid; |
445 | else | 446 | else |
446 | return ( (MScanListItem*) parent() )->essid(); | 447 | return ( (MScanListItem*) parent() )->essid(); |
447 | } | 448 | } |
448 | 449 | ||
449 | OListViewItem* MScanListItem::childFactory() | 450 | OListViewItem* MScanListItem::childFactory() |
450 | { | 451 | { |
451 | return new MScanListItem( this ); | 452 | return new MScanListItem( this ); |
452 | } | 453 | } |
453 | 454 | ||
454 | void MScanListItem::serializeTo( QDataStream& s ) const | 455 | void MScanListItem::serializeTo( QDataStream& s ) const |
455 | { | 456 | { |
456 | #ifdef DEBUG | 457 | #ifdef DEBUG |
457 | qDebug( "serializing MScanListItem" ); | 458 | qDebug( "serializing MScanListItem" ); |
458 | #endif | 459 | #endif |
459 | OListViewItem::serializeTo( s ); | 460 | OListViewItem::serializeTo( s ); |
460 | 461 | ||
461 | s << _type; | 462 | s << _type; |
462 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); | 463 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); |
463 | } | 464 | } |
464 | 465 | ||
465 | void MScanListItem::serializeFrom( QDataStream& s ) | 466 | void MScanListItem::serializeFrom( QDataStream& s ) |
466 | { | 467 | { |
467 | #ifdef DEBUG | 468 | #ifdef DEBUG |
468 | qDebug( "serializing MScanListItem" ); | 469 | qDebug( "serializing MScanListItem" ); |
469 | #endif | 470 | #endif |
470 | OListViewItem::serializeFrom( s ); | 471 | OListViewItem::serializeFrom( s ); |
471 | 472 | ||
472 | char wep; | 473 | char wep; |
473 | s >> _type; | 474 | s >> _type; |
474 | s >> (Q_UINT8) wep; | 475 | s >> (Q_UINT8) wep; |
475 | _wep = (wep == 'y'); | 476 | _wep = (wep == 'y'); |
476 | 477 | ||
477 | QString name; | 478 | QString name; |
478 | name.sprintf( "wellenreiter/%s", (const char*) _type ); | 479 | name.sprintf( "wellenreiter/%s", (const char*) _type ); |
479 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 480 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
480 | if ( _wep ) | 481 | if ( _wep ) |
481 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 482 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
482 | listView()->triggerUpdate(); | 483 | listView()->triggerUpdate(); |
483 | } | 484 | } |
484 | 485 | ||
485 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ) | 486 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ) |
486 | { | 487 | { |
487 | #ifdef DEBUG | 488 | #ifdef DEBUG |
488 | qDebug( "decorating scanlist item %s / %s / %s [%d]", | 489 | qDebug( "decorating scanlist item %s / %s / %s [%d]", |
489 | (const char*) type, | 490 | (const char*) type, |
490 | (const char*) essid, | 491 | (const char*) essid, |
491 | (const char*) macaddr, | 492 | (const char*) macaddr, |
492 | channel ); | 493 | channel ); |
493 | #endif | 494 | #endif |
494 | 495 | ||
495 | // set icon for managed or adhoc mode | 496 | // set icon for managed or adhoc mode |
496 | QString name; | 497 | QString name; |
497 | name.sprintf( "wellenreiter/%s", (const char*) type ); | 498 | name.sprintf( "wellenreiter/%s", (const char*) type ); |
498 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 499 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
499 | 500 | ||
500 | // special case for probed networks FIXME: This is ugly at present | 501 | // special case for probed networks FIXME: This is ugly at present |
501 | if ( type == "network" && probed ) | 502 | if ( type == "network" && probed ) |
502 | { | 503 | { |
503 | setPixmap( col_type, Resource::loadPixmap( "wellenreiter/network-probed.png" ) ); | 504 | setPixmap( col_type, Resource::loadPixmap( "wellenreiter/network-probed.png" ) ); |
504 | } | 505 | } |
505 | 506 | ||
506 | // set icon for wep (wireless encryption protocol) | 507 | // set icon for wep (wireless encryption protocol) |
507 | if ( wep ) | 508 | if ( wep ) |
508 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 509 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
509 | 510 | ||
510 | // set channel and signal text | 511 | // set channel and signal text |
511 | 512 | ||
512 | if ( signal != -1 ) | 513 | if ( signal != -1 ) |
513 | setText( col_sig, QString::number( signal ) ); | 514 | setText( col_sig, QString::number( signal ) ); |
514 | if ( channel != -1 ) | 515 | if ( channel != -1 ) |
515 | setText( col_channel, QString::number( channel ) ); | 516 | setText( col_channel, QString::number( channel ) ); |
516 | 517 | ||
517 | setText( col_firstseen, QTime::currentTime().toString() ); | 518 | setText( col_firstseen, QTime::currentTime().toString() ); |
518 | //setText( col_lastseen, QTime::currentTime().toString() ); | 519 | //setText( col_lastseen, QTime::currentTime().toString() ); |
519 | 520 | ||
520 | listView()->triggerUpdate(); | 521 | listView()->triggerUpdate(); |
521 | 522 | ||
522 | this->type = type; | 523 | this->type = type; |
523 | _type = type; | 524 | _type = type; |
524 | _essid = essid; | 525 | _essid = essid; |
525 | _macaddr = macaddr; | 526 | _macaddr = macaddr; |
526 | _channel = channel; | 527 | _channel = channel; |
527 | _beacons = 1; | 528 | _beacons = 1; |
528 | _signal = 0; | 529 | _signal = 0; |
529 | 530 | ||
530 | if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) | 531 | if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) |
531 | { | 532 | { |
532 | listView()->ensureItemVisible( this ); | 533 | listView()->ensureItemVisible( this ); |
533 | } | 534 | } |
534 | 535 | ||
535 | } | 536 | } |
536 | 537 | ||
537 | 538 | ||
538 | void MScanListItem::setManufacturer( const QString& manufacturer ) | 539 | void MScanListItem::setManufacturer( const QString& manufacturer ) |
539 | { | 540 | { |
540 | setText( col_manuf, manufacturer ); | 541 | setText( col_manuf, manufacturer ); |
541 | } | 542 | } |
542 | 543 | ||
543 | 544 | ||
544 | void MScanListItem::setLocation( const QString& location ) | 545 | void MScanListItem::setLocation( const QString& location ) |
545 | { | 546 | { |
546 | setText( col_location, location ); | 547 | setText( col_location, location ); |
547 | } | 548 | } |
548 | 549 | ||
549 | 550 | ||
550 | void MScanListItem::receivedBeacon() | 551 | void MScanListItem::receivedBeacon() |
551 | { | 552 | { |
552 | _beacons++; | 553 | _beacons++; |
553 | #ifdef DEBUG | 554 | #ifdef DEBUG |
554 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); | 555 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); |
555 | #endif | 556 | #endif |
556 | setText( col_sig, QString::number( _beacons ) ); | 557 | setText( col_sig, QString::number( _beacons ) ); |
557 | setText( col_lastseen, QTime::currentTime().toString() ); | 558 | setText( col_lastseen, QTime::currentTime().toString() ); |
558 | 559 | ||
559 | MScanListItem* p = (MScanListItem*) parent(); | 560 | MScanListItem* p = (MScanListItem*) parent(); |
560 | if ( p ) p->receivedBeacon(); | 561 | if ( p ) p->receivedBeacon(); |
561 | 562 | ||
562 | } | 563 | } |
563 | 564 | ||
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index cd74bed..43a04e3 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -1,720 +1,715 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | 3 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 4 | ** 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 | 5 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 6 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 7 | ** packaging of this file. |
10 | ** | 8 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 9 | ** 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. | 10 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 11 | ** |
14 | ***********************************************************************/ | 12 | ***********************************************************************/ |
15 | 13 | ||
16 | // Local | 14 | // Local |
17 | 15 | ||
18 | #include "gps.h" | 16 | #include "gps.h" |
19 | #include "wellenreiter.h" | 17 | #include "wellenreiter.h" |
20 | #include "scanlist.h" | 18 | #include "scanlist.h" |
21 | #include "logwindow.h" | 19 | #include "logwindow.h" |
22 | #include "hexwindow.h" | 20 | #include "hexwindow.h" |
23 | #include "configwindow.h" | 21 | #include "configwindow.h" |
24 | #include "statwindow.h" | 22 | #include "statwindow.h" |
25 | #include "graphwindow.h" | 23 | #include "graphwindow.h" |
26 | #include "protolistview.h" | 24 | #include "protolistview.h" |
27 | 25 | ||
28 | // Opie | 26 | // Opie |
29 | 27 | ||
30 | #ifdef QWS | 28 | #ifdef QWS |
31 | #include <opie/odevice.h> | ||
32 | #include <qpe/qcopenvelope_qws.h> | ||
33 | using namespace Opie; | ||
34 | #endif | ||
35 | |||
36 | #ifdef QWS | ||
37 | #include <opie2/oapplication.h> | 29 | #include <opie2/oapplication.h> |
30 | #include <opie2/odevice.h> | ||
38 | #else | 31 | #else |
39 | #include <qapplication.h> | 32 | #include <qapplication.h> |
40 | #endif | 33 | #endif |
41 | #include <opie2/omanufacturerdb.h> | 34 | #include <opie2/omanufacturerdb.h> |
42 | #include <opie2/onetwork.h> | 35 | #include <opie2/onetwork.h> |
43 | #include <opie2/opcap.h> | 36 | #include <opie2/opcap.h> |
37 | #include <qpe/qcopenvelope_qws.h> | ||
38 | using namespace Opie; | ||
44 | 39 | ||
45 | // Qt | 40 | // Qt |
46 | 41 | ||
47 | #include <qcheckbox.h> | 42 | #include <qcheckbox.h> |
48 | #include <qcombobox.h> | 43 | #include <qcombobox.h> |
49 | #include <qdatetime.h> | 44 | #include <qdatetime.h> |
50 | #include <qpushbutton.h> | 45 | #include <qpushbutton.h> |
51 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
52 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
53 | #include <qobjectlist.h> | 48 | #include <qobjectlist.h> |
54 | #include <qregexp.h> | 49 | #include <qregexp.h> |
55 | #include <qspinbox.h> | 50 | #include <qspinbox.h> |
56 | #include <qtimer.h> | 51 | #include <qtimer.h> |
57 | #include <qtoolbutton.h> | 52 | #include <qtoolbutton.h> |
58 | #include <qmainwindow.h> | 53 | #include <qmainwindow.h> |
59 | 54 | ||
60 | // Standard | 55 | // Standard |
61 | 56 | ||
62 | #include <assert.h> | 57 | #include <assert.h> |
63 | #include <errno.h> | 58 | #include <errno.h> |
64 | #include <unistd.h> | 59 | #include <unistd.h> |
65 | #include <string.h> | 60 | #include <string.h> |
66 | #include <sys/types.h> | 61 | #include <sys/types.h> |
67 | #include <stdlib.h> | 62 | #include <stdlib.h> |
68 | 63 | ||
69 | Wellenreiter::Wellenreiter( QWidget* parent ) | 64 | Wellenreiter::Wellenreiter( QWidget* parent ) |
70 | : WellenreiterBase( parent, 0, 0 ), | 65 | : WellenreiterBase( parent, 0, 0 ), |
71 | sniffing( false ), iface( 0 ), configwindow( 0 ) | 66 | sniffing( false ), iface( 0 ), configwindow( 0 ) |
72 | { | 67 | { |
73 | 68 | ||
74 | logwindow->log( "(i) Wellenreiter has been started." ); | 69 | logwindow->log( "(i) Wellenreiter has been started." ); |
75 | 70 | ||
76 | // | 71 | // |
77 | // detect operating system | 72 | // detect operating system |
78 | // | 73 | // |
79 | 74 | ||
80 | #ifdef QWS | 75 | #ifdef QWS |
81 | QString sys; | 76 | QString sys; |
82 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); | 77 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); |
83 | _system = ODevice::inst()->system(); | 78 | _system = ODevice::inst()->system(); |
84 | logwindow->log( sys ); | 79 | logwindow->log( sys ); |
85 | #endif | 80 | #endif |
86 | 81 | ||
87 | netview->setColumnWidthMode( 1, QListView::Manual ); | 82 | netview->setColumnWidthMode( 1, QListView::Manual ); |
88 | connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), | 83 | connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), |
89 | this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); | 84 | this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); |
90 | pcap = new OPacketCapturer(); | 85 | pcap = new OPacketCapturer(); |
91 | 86 | ||
92 | gps = new GPS( this ); | 87 | gps = new GPS( this ); |
93 | 88 | ||
94 | QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); | 89 | QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); |
95 | 90 | ||
96 | } | 91 | } |
97 | 92 | ||
98 | 93 | ||
99 | Wellenreiter::~Wellenreiter() | 94 | Wellenreiter::~Wellenreiter() |
100 | { | 95 | { |
101 | delete pcap; | 96 | delete pcap; |
102 | } | 97 | } |
103 | 98 | ||
104 | 99 | ||
105 | void Wellenreiter::initialTimer() | 100 | void Wellenreiter::initialTimer() |
106 | { | 101 | { |
107 | qDebug( "Wellenreiter::preloading manufacturer database..." ); | 102 | qDebug( "Wellenreiter::preloading manufacturer database..." ); |
108 | OManufacturerDB::instance(); | 103 | OManufacturerDB::instance(); |
109 | } | 104 | } |
110 | 105 | ||
111 | 106 | ||
112 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 107 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
113 | { | 108 | { |
114 | configwindow = cw; | 109 | configwindow = cw; |
115 | } | 110 | } |
116 | 111 | ||
117 | 112 | ||
118 | void Wellenreiter::channelHopped(int c) | 113 | void Wellenreiter::channelHopped(int c) |
119 | { | 114 | { |
120 | QString title = "Wellenreiter II -scan- ["; | 115 | QString title = "Wellenreiter II -scan- ["; |
121 | QString left; | 116 | QString left; |
122 | if ( c > 1 ) left.fill( '.', c-1 ); | 117 | if ( c > 1 ) left.fill( '.', c-1 ); |
123 | title.append( left ); | 118 | title.append( left ); |
124 | title.append( '|' ); | 119 | title.append( '|' ); |
125 | if ( c < iface->channels() ) | 120 | if ( c < iface->channels() ) |
126 | { | 121 | { |
127 | QString right; | 122 | QString right; |
128 | right.fill( '.', iface->channels()-c ); | 123 | right.fill( '.', iface->channels()-c ); |
129 | title.append( right ); | 124 | title.append( right ); |
130 | } | 125 | } |
131 | title.append( "]" ); | 126 | title.append( "]" ); |
132 | //title.append( QString().sprintf( " %02d", c ) ); | 127 | //title.append( QString().sprintf( " %02d", c ) ); |
133 | assert( parent() ); | 128 | assert( parent() ); |
134 | ( (QMainWindow*) parent() )->setCaption( title ); | 129 | ( (QMainWindow*) parent() )->setCaption( title ); |
135 | } | 130 | } |
136 | 131 | ||
137 | 132 | ||
138 | void Wellenreiter::handleNotification( OPacket* p ) | 133 | void Wellenreiter::handleNotification( OPacket* p ) |
139 | { | 134 | { |
140 | QObjectList* l = p->queryList(); | 135 | QObjectList* l = p->queryList(); |
141 | QObjectListIt it( *l ); | 136 | QObjectListIt it( *l ); |
142 | QObject* o; | 137 | QObject* o; |
143 | 138 | ||
144 | while ( (o = it.current()) != 0 ) | 139 | while ( (o = it.current()) != 0 ) |
145 | { | 140 | { |
146 | QString name = it.current()->name(); | 141 | QString name = it.current()->name(); |
147 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) | 142 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) |
148 | { | 143 | { |
149 | QString action = configwindow->parsePackets->protocolAction( name ); | 144 | QString action = configwindow->parsePackets->protocolAction( name ); |
150 | qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | 145 | qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); |
151 | doAction( action, name, p ); | 146 | doAction( action, name, p ); |
152 | } | 147 | } |
153 | else | 148 | else |
154 | { | 149 | { |
155 | qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); | 150 | qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); |
156 | } | 151 | } |
157 | ++it; | 152 | ++it; |
158 | } | 153 | } |
159 | } | 154 | } |
160 | 155 | ||
161 | 156 | ||
162 | void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) | 157 | void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) |
163 | { | 158 | { |
164 | if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage ); | 159 | if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage ); |
165 | else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage ); | 160 | else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage ); |
166 | else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage ); | 161 | else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage ); |
167 | else qWarning( "Wellenreiter::handleManagementFrame(): '%s' - please handle me!", (const char*) manage->managementType() ); | 162 | else qWarning( "Wellenreiter::handleManagementFrame(): '%s' - please handle me!", (const char*) manage->managementType() ); |
168 | } | 163 | } |
169 | 164 | ||
170 | 165 | ||
171 | void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request ) | 166 | void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request ) |
172 | { | 167 | { |
173 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 168 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
174 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); | 169 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); |
175 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 170 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
176 | int channel = ds ? ds->channel() : -1; | 171 | int channel = ds ? ds->channel() : -1; |
177 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 172 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
178 | 173 | ||
179 | GpsLocation loc( -111, -111 ); | 174 | GpsLocation loc( -111, -111 ); |
180 | if ( configwindow->enableGPS->isChecked() ) | 175 | if ( configwindow->enableGPS->isChecked() ) |
181 | { | 176 | { |
182 | // TODO: add check if GPS is working!? | 177 | // TODO: add check if GPS is working!? |
183 | qDebug( "Wellenreiter::gathering GPS data..." ); | 178 | qDebug( "Wellenreiter::gathering GPS data..." ); |
184 | loc = gps->position(); | 179 | loc = gps->position(); |
185 | qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); | 180 | qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); |
186 | } | 181 | } |
187 | 182 | ||
188 | if ( essid.length() ) | 183 | if ( essid.length() ) |
189 | netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ ); | 184 | netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ ); |
190 | qDebug( "Wellenreiter::invalid frame [possibly noise] detected!" ); | 185 | qDebug( "Wellenreiter::invalid frame [possibly noise] detected!" ); |
191 | } | 186 | } |
192 | 187 | ||
193 | 188 | ||
194 | void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response ) | 189 | void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response ) |
195 | { | 190 | { |
196 | } | 191 | } |
197 | 192 | ||
198 | 193 | ||
199 | void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) | 194 | void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) |
200 | { | 195 | { |
201 | QString type; | 196 | QString type; |
202 | if ( beacon->canIBSS() ) | 197 | if ( beacon->canIBSS() ) |
203 | { | 198 | { |
204 | type = "adhoc"; | 199 | type = "adhoc"; |
205 | } | 200 | } |
206 | else if ( beacon->canESS() ) | 201 | else if ( beacon->canESS() ) |
207 | { | 202 | { |
208 | type = "managed"; | 203 | type = "managed"; |
209 | } | 204 | } |
210 | else | 205 | else |
211 | { | 206 | { |
212 | qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); | 207 | qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); |
213 | return; | 208 | return; |
214 | } | 209 | } |
215 | 210 | ||
216 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 211 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
217 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); | 212 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); |
218 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 213 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
219 | int channel = ds ? ds->channel() : -1; | 214 | int channel = ds ? ds->channel() : -1; |
220 | 215 | ||
221 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 216 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
222 | 217 | ||
223 | GpsLocation loc( -111, -111 ); | 218 | GpsLocation loc( -111, -111 ); |
224 | if ( configwindow->enableGPS->isChecked() ) | 219 | if ( configwindow->enableGPS->isChecked() ) |
225 | { | 220 | { |
226 | // TODO: add check if GPS is working!? | 221 | // TODO: add check if GPS is working!? |
227 | qDebug( "Wellenreiter::gathering GPS data..." ); | 222 | qDebug( "Wellenreiter::gathering GPS data..." ); |
228 | loc = gps->position(); | 223 | loc = gps->position(); |
229 | qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); | 224 | qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); |
230 | } | 225 | } |
231 | 226 | ||
232 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); | 227 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); |
233 | 228 | ||
234 | // update graph window | 229 | // update graph window |
235 | if ( ds ) | 230 | if ( ds ) |
236 | { | 231 | { |
237 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); | 232 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); |
238 | if ( prism ) | 233 | if ( prism ) |
239 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); | 234 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); |
240 | else | 235 | else |
241 | graphwindow->traffic( ds->channel(), 95 ); | 236 | graphwindow->traffic( ds->channel(), 95 ); |
242 | } | 237 | } |
243 | } | 238 | } |
244 | 239 | ||
245 | 240 | ||
246 | void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control ) | 241 | void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control ) |
247 | { | 242 | { |
248 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 243 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
249 | 244 | ||
250 | if ( control->controlType() == "Acknowledge" ) | 245 | if ( control->controlType() == "Acknowledge" ) |
251 | { | 246 | { |
252 | netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); | 247 | netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); |
253 | } | 248 | } |
254 | else | 249 | else |
255 | { | 250 | { |
256 | qDebug( "Wellenreiter::handleControlFrame - please handle %s in a future version! :D", (const char*) control->controlType() ); | 251 | qDebug( "Wellenreiter::handleControlFrame - please handle %s in a future version! :D", (const char*) control->controlType() ); |
257 | } | 252 | } |
258 | } | 253 | } |
259 | 254 | ||
260 | 255 | ||
261 | void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) | 256 | void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) |
262 | { | 257 | { |
263 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); | 258 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); |
264 | if ( wlan->fromDS() && !wlan->toDS() ) | 259 | if ( wlan->fromDS() && !wlan->toDS() ) |
265 | { | 260 | { |
266 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); | 261 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); |
267 | from = wlan->macAddress3(); | 262 | from = wlan->macAddress3(); |
268 | to = wlan->macAddress2(); | 263 | to = wlan->macAddress2(); |
269 | } | 264 | } |
270 | else if ( !wlan->fromDS() && wlan->toDS() ) | 265 | else if ( !wlan->fromDS() && wlan->toDS() ) |
271 | { | 266 | { |
272 | netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); | 267 | netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); |
273 | from = wlan->macAddress2(); | 268 | from = wlan->macAddress2(); |
274 | to = wlan->macAddress3(); | 269 | to = wlan->macAddress3(); |
275 | } | 270 | } |
276 | else if ( wlan->fromDS() && wlan->toDS() ) | 271 | else if ( wlan->fromDS() && wlan->toDS() ) |
277 | { | 272 | { |
278 | netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); | 273 | netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); |
279 | from = wlan->macAddress4(); | 274 | from = wlan->macAddress4(); |
280 | to = wlan->macAddress3(); | 275 | to = wlan->macAddress3(); |
281 | } | 276 | } |
282 | else | 277 | else |
283 | { | 278 | { |
284 | netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); | 279 | netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); |
285 | from = wlan->macAddress2(); | 280 | from = wlan->macAddress2(); |
286 | to = wlan->macAddress1(); | 281 | to = wlan->macAddress1(); |
287 | } | 282 | } |
288 | } | 283 | } |
289 | 284 | ||
290 | 285 | ||
291 | void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) | 286 | void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) |
292 | { | 287 | { |
293 | from = data->sourceAddress(); | 288 | from = data->sourceAddress(); |
294 | to = data->destinationAddress(); | 289 | to = data->destinationAddress(); |
295 | 290 | ||
296 | netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) ); | 291 | netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) ); |
297 | } | 292 | } |
298 | 293 | ||
299 | 294 | ||
300 | void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) | 295 | void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) |
301 | { | 296 | { |
302 | OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); | 297 | OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); |
303 | if ( arp ) | 298 | if ( arp ) |
304 | { | 299 | { |
305 | qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); | 300 | qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); |
306 | if ( arp->type() == "REQUEST" ) | 301 | if ( arp->type() == "REQUEST" ) |
307 | { | 302 | { |
308 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); | 303 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); |
309 | } | 304 | } |
310 | else if ( arp->type() == "REPLY" ) | 305 | else if ( arp->type() == "REPLY" ) |
311 | { | 306 | { |
312 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); | 307 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); |
313 | netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); | 308 | netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); |
314 | } | 309 | } |
315 | } | 310 | } |
316 | } | 311 | } |
317 | 312 | ||
318 | 313 | ||
319 | void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) | 314 | void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) |
320 | { | 315 | { |
321 | //TODO: Implement more IP based protocols | 316 | //TODO: Implement more IP based protocols |
322 | 317 | ||
323 | ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); | 318 | ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); |
324 | if ( dhcp ) | 319 | if ( dhcp ) |
325 | { | 320 | { |
326 | qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); | 321 | qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); |
327 | if ( dhcp->type() == "OFFER" ) | 322 | if ( dhcp->type() == "OFFER" ) |
328 | { | 323 | { |
329 | qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); | 324 | qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); |
330 | netView()->identify( source, dhcp->serverAddress().toString() ); | 325 | netView()->identify( source, dhcp->serverAddress().toString() ); |
331 | netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); | 326 | netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); |
332 | } | 327 | } |
333 | else if ( dhcp->type() == "ACK" ) | 328 | else if ( dhcp->type() == "ACK" ) |
334 | { | 329 | { |
335 | qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); | 330 | qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); |
336 | netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); | 331 | netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); |
337 | } | 332 | } |
338 | } | 333 | } |
339 | } | 334 | } |
340 | 335 | ||
341 | 336 | ||
342 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) | 337 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) |
343 | { | 338 | { |
344 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) | 339 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) |
345 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) | 340 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) |
346 | return 0; | 341 | return 0; |
347 | 342 | ||
348 | return p->child( protocol ); | 343 | return p->child( protocol ); |
349 | } | 344 | } |
350 | 345 | ||
351 | 346 | ||
352 | bool Wellenreiter::checkDumpPacket( OPacket* p ) | 347 | bool Wellenreiter::checkDumpPacket( OPacket* p ) |
353 | { | 348 | { |
354 | // go through all child packets and see if one is inside the child hierarchy for p | 349 | // go through all child packets and see if one is inside the child hierarchy for p |
355 | // if so, do what the user requested (protocolAction), e.g. pass or discard | 350 | // if so, do what the user requested (protocolAction), e.g. pass or discard |
356 | if ( !configwindow->writeCaptureFile->isChecked() ) | 351 | if ( !configwindow->writeCaptureFile->isChecked() ) |
357 | return true; // semantic change - we're logging anyway now to /tmp/wellenreiter | 352 | return true; // semantic change - we're logging anyway now to /tmp/wellenreiter |
358 | 353 | ||
359 | QObjectList* l = p->queryList(); | 354 | QObjectList* l = p->queryList(); |
360 | QObjectListIt it( *l ); | 355 | QObjectListIt it( *l ); |
361 | QObject* o; | 356 | QObject* o; |
362 | 357 | ||
363 | while ( (o = it.current()) != 0 ) | 358 | while ( (o = it.current()) != 0 ) |
364 | { | 359 | { |
365 | QString name = it.current()->name(); | 360 | QString name = it.current()->name(); |
366 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) | 361 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) |
367 | { | 362 | { |
368 | QString action = configwindow->capturePackets->protocolAction( name ); | 363 | QString action = configwindow->capturePackets->protocolAction( name ); |
369 | qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | 364 | qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); |
370 | if ( action == "Discard" ) | 365 | if ( action == "Discard" ) |
371 | { | 366 | { |
372 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); | 367 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); |
373 | return false; | 368 | return false; |
374 | } | 369 | } |
375 | } | 370 | } |
376 | else | 371 | else |
377 | { | 372 | { |
378 | qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); | 373 | qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); |
379 | } | 374 | } |
380 | ++it; | 375 | ++it; |
381 | } | 376 | } |
382 | return true; | 377 | return true; |
383 | } | 378 | } |
384 | 379 | ||
385 | 380 | ||
386 | void Wellenreiter::receivePacket( OPacket* p ) | 381 | void Wellenreiter::receivePacket( OPacket* p ) |
387 | { | 382 | { |
388 | hexWindow()->log( p->dump( 8 ) ); | 383 | hexWindow()->log( p->dump( 8 ) ); |
389 | 384 | ||
390 | if ( checkDumpPacket( p ) ) | 385 | if ( checkDumpPacket( p ) ) |
391 | { | 386 | { |
392 | pcap->dump( p ); | 387 | pcap->dump( p ); |
393 | } | 388 | } |
394 | 389 | ||
395 | // check for a management frame | 390 | // check for a management frame |
396 | OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); | 391 | OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); |
397 | if ( manage ) | 392 | if ( manage ) |
398 | { | 393 | { |
399 | handleManagementFrame( p, manage ); | 394 | handleManagementFrame( p, manage ); |
400 | return; | 395 | return; |
401 | } | 396 | } |
402 | 397 | ||
403 | // check for a control frame | 398 | // check for a control frame |
404 | OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) ); | 399 | OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) ); |
405 | if ( control ) | 400 | if ( control ) |
406 | { | 401 | { |
407 | handleControlFrame( p, control ); | 402 | handleControlFrame( p, control ); |
408 | return; | 403 | return; |
409 | } | 404 | } |
410 | 405 | ||
411 | OMacAddress source; | 406 | OMacAddress source; |
412 | OMacAddress dest; | 407 | OMacAddress dest; |
413 | 408 | ||
414 | //TODO: WEP check here | 409 | //TODO: WEP check here |
415 | 410 | ||
416 | // check for a wireless data frame | 411 | // check for a wireless data frame |
417 | OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); | 412 | OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); |
418 | if ( wlan ) | 413 | if ( wlan ) |
419 | { | 414 | { |
420 | handleWlanData( p, wlan, source, dest ); | 415 | handleWlanData( p, wlan, source, dest ); |
421 | } | 416 | } |
422 | 417 | ||
423 | // check for a wired data frame | 418 | // check for a wired data frame |
424 | OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); | 419 | OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); |
425 | if ( eth ) | 420 | if ( eth ) |
426 | { | 421 | { |
427 | handleEthernetData( p, eth, source, dest ); | 422 | handleEthernetData( p, eth, source, dest ); |
428 | } | 423 | } |
429 | 424 | ||
430 | // check for an arp frame since arp frames come in two flavours: | 425 | // check for an arp frame since arp frames come in two flavours: |
431 | // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't. | 426 | // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't. |
432 | OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) ); | 427 | OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) ); |
433 | if ( arp ) | 428 | if ( arp ) |
434 | { | 429 | { |
435 | handleARPData( p, arp, source, dest ); | 430 | handleARPData( p, arp, source, dest ); |
436 | } | 431 | } |
437 | 432 | ||
438 | // check for a ip frame | 433 | // check for a ip frame |
439 | OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); | 434 | OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); |
440 | if ( ip ) | 435 | if ( ip ) |
441 | { | 436 | { |
442 | handleIPData( p, ip, source, dest ); | 437 | handleIPData( p, ip, source, dest ); |
443 | } | 438 | } |
444 | 439 | ||
445 | //handleNotification( p ); | 440 | //handleNotification( p ); |
446 | 441 | ||
447 | } | 442 | } |
448 | 443 | ||
449 | 444 | ||
450 | void Wellenreiter::stopClicked() | 445 | void Wellenreiter::stopClicked() |
451 | { | 446 | { |
452 | if ( iface ) | 447 | if ( iface ) |
453 | { | 448 | { |
454 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 449 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
455 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 450 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
456 | iface->setChannelHopping(); // stop hopping channels | 451 | iface->setChannelHopping(); // stop hopping channels |
457 | } | 452 | } |
458 | else | 453 | else |
459 | killTimers(); | 454 | killTimers(); |
460 | 455 | ||
461 | pcap->close(); | 456 | pcap->close(); |
462 | sniffing = false; | 457 | sniffing = false; |
463 | 458 | ||
464 | if ( iface ) | 459 | if ( iface ) |
465 | { | 460 | { |
466 | // switch off monitor mode | 461 | // switch off monitor mode |
467 | iface->setMode( "managed" ); | 462 | iface->setMode( "managed" ); |
468 | // switch off promisc flag | 463 | // switch off promisc flag |
469 | iface->setPromiscuousMode( false ); | 464 | iface->setPromiscuousMode( false ); |
470 | 465 | ||
471 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess | 466 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess |
472 | } | 467 | } |
473 | 468 | ||
474 | logwindow->log( "(i) Stopped Scanning." ); | 469 | logwindow->log( "(i) Stopped Scanning." ); |
475 | assert( parent() ); | 470 | assert( parent() ); |
476 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); | 471 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); |
477 | 472 | ||
478 | // message the user | 473 | // message the user |
479 | QMessageBox::information( this, "Wellenreiter II", | 474 | QMessageBox::information( this, "Wellenreiter II", |
480 | tr( "Your wireless card\nshould now be usable again." ) ); | 475 | tr( "Your wireless card\nshould now be usable again." ) ); |
481 | 476 | ||
482 | sniffing = false; | 477 | sniffing = false; |
483 | emit( stoppedSniffing() ); | 478 | emit( stoppedSniffing() ); |
484 | 479 | ||
485 | #ifdef QWS | 480 | #ifdef QWS |
486 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) | 481 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) |
487 | { | 482 | { |
488 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 483 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
489 | } | 484 | } |
490 | #else | 485 | #else |
491 | #warning FIXME: setScreenSaverMode is not operational on the X11 build | 486 | #warning FIXME: setScreenSaverMode is not operational on the X11 build |
492 | #endif | 487 | #endif |
493 | 488 | ||
494 | // print out statistics | 489 | // print out statistics |
495 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) | 490 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) |
496 | statwindow->updateCounter( it.key(), it.data() ); | 491 | statwindow->updateCounter( it.key(), it.data() ); |
497 | } | 492 | } |
498 | 493 | ||
499 | 494 | ||
500 | void Wellenreiter::startClicked() | 495 | void Wellenreiter::startClicked() |
501 | { | 496 | { |
502 | // get configuration from config window | 497 | // get configuration from config window |
503 | 498 | ||
504 | const QString& interface = configwindow->interfaceName->currentText(); | 499 | const QString& interface = configwindow->interfaceName->currentText(); |
505 | const int cardtype = configwindow->driverType(); | 500 | const int cardtype = configwindow->driverType(); |
506 | const int interval = configwindow->hoppingInterval(); | 501 | const int interval = configwindow->hoppingInterval(); |
507 | 502 | ||
508 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 503 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
509 | { | 504 | { |
510 | QMessageBox::information( this, "Wellenreiter II", | 505 | QMessageBox::information( this, "Wellenreiter II", |
511 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); | 506 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); |
512 | return; | 507 | return; |
513 | } | 508 | } |
514 | 509 | ||
515 | // configure device | 510 | // configure device |
516 | ONetwork* net = ONetwork::instance(); | 511 | ONetwork* net = ONetwork::instance(); |
517 | 512 | ||
518 | // TODO: check if interface is wireless and support sniffing for non-wireless interfaces | 513 | // TODO: check if interface is wireless and support sniffing for non-wireless interfaces |
519 | 514 | ||
520 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! | 515 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! |
521 | 516 | ||
522 | // bring device UP | 517 | // bring device UP |
523 | if ( cardtype != DEVTYPE_FILE ) | 518 | if ( cardtype != DEVTYPE_FILE ) |
524 | { | 519 | { |
525 | iface->setUp( true ); | 520 | iface->setUp( true ); |
526 | if ( !iface->isUp() ) | 521 | if ( !iface->isUp() ) |
527 | { | 522 | { |
528 | QMessageBox::warning( this, "Wellenreiter II", | 523 | QMessageBox::warning( this, "Wellenreiter II", |
529 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); | 524 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); |
530 | return; | 525 | return; |
531 | } | 526 | } |
532 | } | 527 | } |
533 | // set monitor mode | 528 | // set monitor mode |
534 | bool usePrism = configwindow->usePrismHeader(); | 529 | bool usePrism = configwindow->usePrismHeader(); |
535 | 530 | ||
536 | switch ( cardtype ) | 531 | switch ( cardtype ) |
537 | { | 532 | { |
538 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; | 533 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; |
539 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; | 534 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; |
540 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; | 535 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; |
541 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; | 536 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; |
542 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; | 537 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; |
543 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; | 538 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; |
544 | default: assert( 0 ); // shouldn't reach this | 539 | default: assert( 0 ); // shouldn't reach this |
545 | } | 540 | } |
546 | 541 | ||
547 | // switch device into monitor mode | 542 | // switch device into monitor mode |
548 | if ( cardtype < DEVTYPE_FILE ) | 543 | if ( cardtype < DEVTYPE_FILE ) |
549 | { | 544 | { |
550 | if ( cardtype != DEVTYPE_MANUAL ) | 545 | if ( cardtype != DEVTYPE_MANUAL ) |
551 | iface->setMode( "monitor" ); | 546 | iface->setMode( "monitor" ); |
552 | if ( iface->mode() != "monitor" ) | 547 | if ( iface->mode() != "monitor" ) |
553 | { | 548 | { |
554 | if ( QMessageBox::warning( this, "Wellenreiter II", | 549 | if ( QMessageBox::warning( this, "Wellenreiter II", |
555 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + | 550 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + |
556 | tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 551 | tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
557 | return; | 552 | return; |
558 | } | 553 | } |
559 | } | 554 | } |
560 | 555 | ||
561 | // open GPS device | 556 | // open GPS device |
562 | if ( configwindow->enableGPS->isChecked() ) | 557 | if ( configwindow->enableGPS->isChecked() ) |
563 | { | 558 | { |
564 | qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 559 | qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); |
565 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 560 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); |
566 | } | 561 | } |
567 | 562 | ||
568 | // open pcap and start sniffing | 563 | // open pcap and start sniffing |
569 | 564 | ||
570 | if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? | 565 | if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? |
571 | { | 566 | { |
572 | dumpname = configwindow->captureFileName->text(); | 567 | dumpname = configwindow->captureFileName->text(); |
573 | if ( dumpname.isEmpty() ) dumpname = "captureFile"; | 568 | if ( dumpname.isEmpty() ) dumpname = "captureFile"; |
574 | dumpname.append( '-' ); | 569 | dumpname.append( '-' ); |
575 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); | 570 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); |
576 | dumpname.append( ".wellenreiter" ); | 571 | dumpname.append( ".wellenreiter" ); |
577 | } | 572 | } |
578 | else // write it anyway ;) | 573 | else // write it anyway ;) |
579 | { | 574 | { |
580 | dumpname = "/var/log/dump.wellenreiter"; | 575 | dumpname = "/var/log/dump.wellenreiter"; |
581 | } | 576 | } |
582 | 577 | ||
583 | if ( cardtype != DEVTYPE_FILE ) | 578 | if ( cardtype != DEVTYPE_FILE ) |
584 | pcap->open( interface ); | 579 | pcap->open( interface ); |
585 | else | 580 | else |
586 | pcap->open( QFile( interface ) ); | 581 | pcap->open( QFile( interface ) ); |
587 | 582 | ||
588 | qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname ); | 583 | qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname ); |
589 | pcap->openDumpFile( dumpname ); | 584 | pcap->openDumpFile( dumpname ); |
590 | 585 | ||
591 | if ( !pcap->isOpen() ) | 586 | if ( !pcap->isOpen() ) |
592 | { | 587 | { |
593 | QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( | 588 | QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( |
594 | cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); | 589 | cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); |
595 | return; | 590 | return; |
596 | } | 591 | } |
597 | 592 | ||
598 | // set capturer to non-blocking mode | 593 | // set capturer to non-blocking mode |
599 | pcap->setBlocking( false ); | 594 | pcap->setBlocking( false ); |
600 | 595 | ||
601 | // start channel hopper | 596 | // start channel hopper |
602 | if ( cardtype != DEVTYPE_FILE ) | 597 | if ( cardtype != DEVTYPE_FILE ) |
603 | { | 598 | { |
604 | logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); | 599 | logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); |
605 | iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window | 600 | iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window |
606 | } | 601 | } |
607 | 602 | ||
608 | if ( cardtype != DEVTYPE_FILE ) | 603 | if ( cardtype != DEVTYPE_FILE ) |
609 | { | 604 | { |
610 | // connect socket notifier and start channel hopper | 605 | // connect socket notifier and start channel hopper |
611 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 606 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
612 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 607 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
613 | } | 608 | } |
614 | else | 609 | else |
615 | { | 610 | { |
616 | // start timer for reading packets | 611 | // start timer for reading packets |
617 | startTimer( 100 ); | 612 | startTimer( 100 ); |
618 | } | 613 | } |
619 | 614 | ||
620 | logwindow->log( "(i) Started Scanning." ); | 615 | logwindow->log( "(i) Started Scanning." ); |
621 | sniffing = true; | 616 | sniffing = true; |
622 | 617 | ||
623 | #ifdef QWS | 618 | #ifdef QWS |
624 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) | 619 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) |
625 | { | 620 | { |
626 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; | 621 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; |
627 | } | 622 | } |
628 | #else | 623 | #else |
629 | #warning FIXME: setScreenSaverMode is not operational on the X11 build | 624 | #warning FIXME: setScreenSaverMode is not operational on the X11 build |
630 | #endif | 625 | #endif |
631 | 626 | ||
632 | emit( startedSniffing() ); | 627 | emit( startedSniffing() ); |
633 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title | 628 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title |
634 | else | 629 | else |
635 | { | 630 | { |
636 | assert( parent() ); | 631 | assert( parent() ); |
637 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); | 632 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); |
638 | } | 633 | } |
639 | } | 634 | } |
640 | 635 | ||
641 | 636 | ||
642 | void Wellenreiter::timerEvent( QTimerEvent* ) | 637 | void Wellenreiter::timerEvent( QTimerEvent* ) |
643 | { | 638 | { |
644 | qDebug( "Wellenreiter::timerEvent()" ); | 639 | qDebug( "Wellenreiter::timerEvent()" ); |
645 | OPacket* p = pcap->next(); | 640 | OPacket* p = pcap->next(); |
646 | if ( !p ) // no more packets available | 641 | if ( !p ) // no more packets available |
647 | { | 642 | { |
648 | stopClicked(); | 643 | stopClicked(); |
649 | } | 644 | } |
650 | else | 645 | else |
651 | { | 646 | { |
652 | receivePacket( p ); | 647 | receivePacket( p ); |
653 | delete p; | 648 | delete p; |
654 | } | 649 | } |
655 | } | 650 | } |
656 | 651 | ||
657 | 652 | ||
658 | void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) | 653 | void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) |
659 | { | 654 | { |
660 | #ifdef QWS | 655 | #ifdef QWS |
661 | if ( action == "TouchSound" ) | 656 | if ( action == "TouchSound" ) |
662 | ODevice::inst()->touchSound(); | 657 | ODevice::inst()->touchSound(); |
663 | else if ( action == "AlarmSound" ) | 658 | else if ( action == "AlarmSound" ) |
664 | ODevice::inst()->alarmSound(); | 659 | ODevice::inst()->alarmSound(); |
665 | else if ( action == "KeySound" ) | 660 | else if ( action == "KeySound" ) |
666 | ODevice::inst()->keySound(); | 661 | ODevice::inst()->keySound(); |
667 | else if ( action == "LedOn" ) | 662 | else if ( action == "LedOn" ) |
668 | ODevice::inst()->setLedState( Led_Mail, Led_On ); | 663 | ODevice::inst()->setLedState( Led_Mail, Led_On ); |
669 | else if ( action == "LedOff" ) | 664 | else if ( action == "LedOff" ) |
670 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); | 665 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); |
671 | else if ( action == "LogMessage" ) | 666 | else if ( action == "LogMessage" ) |
672 | logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); | 667 | logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); |
673 | else if ( action == "MessageBox" ) | 668 | else if ( action == "MessageBox" ) |
674 | QMessageBox::information( this, "Notification!", | 669 | QMessageBox::information( this, "Notification!", |
675 | QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); | 670 | QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); |
676 | #else | 671 | #else |
677 | #warning Actions do not work with Qt/X11 yet | 672 | #warning Actions do not work with Qt/X11 yet |
678 | #endif | 673 | #endif |
679 | } | 674 | } |
680 | 675 | ||
681 | void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) | 676 | void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) |
682 | { | 677 | { |
683 | #ifdef QWS | 678 | #ifdef QWS |
684 | if ( !iface ) | 679 | if ( !iface ) |
685 | { | 680 | { |
686 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); | 681 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); |
687 | return; | 682 | return; |
688 | } | 683 | } |
689 | 684 | ||
690 | if ( sniffing ) | 685 | if ( sniffing ) |
691 | { | 686 | { |
692 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); | 687 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); |
693 | return; | 688 | return; |
694 | } | 689 | } |
695 | 690 | ||
696 | qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", | 691 | qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", |
697 | (const char*) iface->name(), | 692 | (const char*) iface->name(), |
698 | (const char*) type, | 693 | (const char*) type, |
699 | (const char*) essid, | 694 | (const char*) essid, |
700 | channel, | 695 | channel, |
701 | (const char*) macaddr ); | 696 | (const char*) macaddr ); |
702 | 697 | ||
703 | QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); | 698 | QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); |
704 | int count = 3; | 699 | int count = 3; |
705 | qDebug("sending %d messages",count); | 700 | qDebug("sending %d messages",count); |
706 | msg << QString("count") << QString::number(count); | 701 | msg << QString("count") << QString::number(count); |
707 | qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); | 702 | qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); |
708 | msg << QString(iface->name()) << QString("Mode") << type; | 703 | msg << QString(iface->name()) << QString("Mode") << type; |
709 | qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); | 704 | qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); |
710 | msg << QString(iface->name()) << QString("ESSID") << essid; | 705 | msg << QString(iface->name()) << QString("ESSID") << essid; |
711 | qDebug("msg >%s< channel >%d<", iface->name(),channel); | 706 | qDebug("msg >%s< channel >%d<", iface->name(),channel); |
712 | msg << QString(iface->name()) << QString("Channel") << channel; | 707 | msg << QString(iface->name()) << QString("Channel") << channel; |
713 | // qDebug("msg >%s< mac >%s<", iface->name(),macaddr); | 708 | // qDebug("msg >%s< mac >%s<", iface->name(),macaddr); |
714 | // msg << QString(iface->name()) << QString("MacAddr") << macaddr; | 709 | // msg << QString(iface->name()) << QString("MacAddr") << macaddr; |
715 | #else | 710 | #else |
716 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); | 711 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); |
717 | #endif | 712 | #endif |
718 | 713 | ||
719 | } | 714 | } |
720 | 715 | ||
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index a28740b..745486f 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h | |||
@@ -1,109 +1,107 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | 3 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 4 | ** 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 | 5 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 6 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 7 | ** packaging of this file. |
10 | ** | 8 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 9 | ** 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. | 10 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 11 | ** |
14 | **********************************************************************/ | 12 | **********************************************************************/ |
15 | 13 | ||
16 | #ifndef WELLENREITER_H | 14 | #ifndef WELLENREITER_H |
17 | #define WELLENREITER_H | 15 | #define WELLENREITER_H |
18 | 16 | ||
19 | #include "wellenreiterbase.h" | 17 | #include "wellenreiterbase.h" |
20 | 18 | ||
21 | #ifdef QWS | 19 | #ifdef QWS |
22 | #include <opie/odevice.h> | 20 | #include <opie2/odevice.h> |
23 | using namespace Opie; | 21 | using namespace Opie; |
24 | #endif | 22 | #endif |
25 | 23 | ||
26 | class QTimerEvent; | 24 | class QTimerEvent; |
27 | class QPixmap; | 25 | class QPixmap; |
28 | class OPacket; | 26 | class OPacket; |
29 | class OWaveLanManagementPacket; | 27 | class OWaveLanManagementPacket; |
30 | class OWaveLanControlPacket; | 28 | class OWaveLanControlPacket; |
31 | class OWaveLanDataPacket; | 29 | class OWaveLanDataPacket; |
32 | class OEthernetPacket; | 30 | class OEthernetPacket; |
33 | class OARPPacket; | 31 | class OARPPacket; |
34 | class OMacAddress; | 32 | class OMacAddress; |
35 | class OIPPacket; | 33 | class OIPPacket; |
36 | class OPacketCapturer; | 34 | class OPacketCapturer; |
37 | class OWirelessNetworkInterface; | 35 | class OWirelessNetworkInterface; |
38 | class WellenreiterConfigWindow; | 36 | class WellenreiterConfigWindow; |
39 | class MLogWindow; | 37 | class MLogWindow; |
40 | class MHexWindow; | 38 | class MHexWindow; |
41 | class GPS; | 39 | class GPS; |
42 | 40 | ||
43 | class Wellenreiter : public WellenreiterBase { | 41 | class Wellenreiter : public WellenreiterBase { |
44 | Q_OBJECT | 42 | Q_OBJECT |
45 | 43 | ||
46 | public: | 44 | public: |
47 | Wellenreiter( QWidget* parent = 0 ); | 45 | Wellenreiter( QWidget* parent = 0 ); |
48 | ~Wellenreiter(); | 46 | ~Wellenreiter(); |
49 | 47 | ||
50 | void setConfigWindow( WellenreiterConfigWindow* cw ); | 48 | void setConfigWindow( WellenreiterConfigWindow* cw ); |
51 | MScanListView* netView() const { return netview; }; | 49 | MScanListView* netView() const { return netview; }; |
52 | MLogWindow* logWindow() const { return logwindow; }; | 50 | MLogWindow* logWindow() const { return logwindow; }; |
53 | MHexWindow* hexWindow() const { return hexwindow; }; | 51 | MHexWindow* hexWindow() const { return hexwindow; }; |
54 | bool isDaemonRunning() const { return sniffing; }; | 52 | bool isDaemonRunning() const { return sniffing; }; |
55 | QString captureFileName() const { return dumpname; }; | 53 | QString captureFileName() const { return dumpname; }; |
56 | 54 | ||
57 | public: | 55 | public: |
58 | bool sniffing; | 56 | bool sniffing; |
59 | 57 | ||
60 | protected: | 58 | protected: |
61 | virtual void timerEvent( QTimerEvent* ); | 59 | virtual void timerEvent( QTimerEvent* ); |
62 | 60 | ||
63 | public slots: | 61 | public slots: |
64 | void initialTimer(); | 62 | void initialTimer(); |
65 | 63 | ||
66 | void channelHopped(int); | 64 | void channelHopped(int); |
67 | void receivePacket(OPacket*); | 65 | void receivePacket(OPacket*); |
68 | void startClicked(); | 66 | void startClicked(); |
69 | void stopClicked(); | 67 | void stopClicked(); |
70 | 68 | ||
71 | void joinNetwork(const QString&,const QString&,int,const QString&); | 69 | void joinNetwork(const QString&,const QString&,int,const QString&); |
72 | 70 | ||
73 | signals: | 71 | signals: |
74 | void startedSniffing(); | 72 | void startedSniffing(); |
75 | void stoppedSniffing(); | 73 | void stoppedSniffing(); |
76 | 74 | ||
77 | private: | 75 | private: |
78 | void handleManagementFrame( OPacket* p, OWaveLanManagementPacket* ); | 76 | void handleManagementFrame( OPacket* p, OWaveLanManagementPacket* ); |
79 | void handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* ); | 77 | void handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* ); |
80 | void handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* ); | 78 | void handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* ); |
81 | void handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* ); | 79 | void handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* ); |
82 | void handleControlFrame( OPacket* p, OWaveLanControlPacket* control ); | 80 | void handleControlFrame( OPacket* p, OWaveLanControlPacket* control ); |
83 | void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ); | 81 | void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ); |
84 | void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ); | 82 | void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ); |
85 | void handleARPData( OPacket* p, OARPPacket* arp, OMacAddress& from, OMacAddress& to ); | 83 | void handleARPData( OPacket* p, OARPPacket* arp, OMacAddress& from, OMacAddress& to ); |
86 | void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to ); | 84 | void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to ); |
87 | void handleNotification( OPacket* p ); | 85 | void handleNotification( OPacket* p ); |
88 | void doAction( const QString& action, const QString& protocol, OPacket* p ); | 86 | void doAction( const QString& action, const QString& protocol, OPacket* p ); |
89 | QObject* childIfToParse( OPacket* p, const QString& protocol ); | 87 | QObject* childIfToParse( OPacket* p, const QString& protocol ); |
90 | bool checkDumpPacket( OPacket* p ); | 88 | bool checkDumpPacket( OPacket* p ); |
91 | 89 | ||
92 | private: | 90 | private: |
93 | #ifdef QWS | 91 | #ifdef QWS |
94 | OSystem _system; // Opie Operating System identifier | 92 | OSystem _system; // Opie Operating System identifier |
95 | #endif | 93 | #endif |
96 | 94 | ||
97 | QString dumpname; | 95 | QString dumpname; |
98 | OWirelessNetworkInterface* iface; | 96 | OWirelessNetworkInterface* iface; |
99 | OPacketCapturer* pcap; | 97 | OPacketCapturer* pcap; |
100 | WellenreiterConfigWindow* configwindow; | 98 | WellenreiterConfigWindow* configwindow; |
101 | GPS* gps; | 99 | GPS* gps; |
102 | 100 | ||
103 | //void readConfig(); | 101 | //void readConfig(); |
104 | //void writeConfig(); | 102 | //void writeConfig(); |
105 | }; | 103 | }; |
106 | 104 | ||
107 | 105 | ||
108 | 106 | ||
109 | #endif | 107 | #endif |
diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp index eac5d89..c2413dc 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp | |||
@@ -1,185 +1,186 @@ | |||
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 "wellenreiterbase.h" | 16 | #include "wellenreiterbase.h" |
17 | 17 | ||
18 | #include <qheader.h> | 18 | #include <qheader.h> |
19 | #include <qlabel.h> | 19 | #include <qlabel.h> |
20 | #include <qlistview.h> | 20 | #include <qlistview.h> |
21 | #include <qmultilineedit.h> | 21 | #include <qmultilineedit.h> |
22 | #include <qpushbutton.h> | 22 | #include <qpushbutton.h> |
23 | #include <qlayout.h> | 23 | #include <qlayout.h> |
24 | #include <qvariant.h> | 24 | #include <qvariant.h> |
25 | #include <qtooltip.h> | 25 | #include <qtooltip.h> |
26 | #include <qwhatsthis.h> | 26 | #include <qwhatsthis.h> |
27 | #include <qimage.h> | 27 | #include <qimage.h> |
28 | #include <qpixmap.h> | 28 | #include <qpixmap.h> |
29 | 29 | ||
30 | #include "logwindow.h" | 30 | #include "logwindow.h" |
31 | #include "hexwindow.h" | 31 | #include "hexwindow.h" |
32 | #include "scanlist.h" | 32 | #include "scanlist.h" |
33 | #include "statwindow.h" | 33 | #include "statwindow.h" |
34 | #include "graphwindow.h" | 34 | #include "graphwindow.h" |
35 | 35 | ||
36 | #ifdef QWS | 36 | #ifdef QWS |
37 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
38 | #include <opie/otabwidget.h> | 38 | #include <opie2/otabwidget.h> |
39 | using namespace Opie; | ||
39 | #else | 40 | #else |
40 | #include "resource.h" | 41 | #include "resource.h" |
41 | #include <qtabwidget.h> | 42 | #include <qtabwidget.h> |
42 | #endif | 43 | #endif |
43 | 44 | ||
44 | 45 | ||
45 | /* | 46 | /* |
46 | * Constructs a WellenreiterBase which is a child of 'parent', with the | 47 | * Constructs a WellenreiterBase which is a child of 'parent', with the |
47 | * name 'name' and widget flags set to 'f' | 48 | * name 'name' and widget flags set to 'f' |
48 | */ | 49 | */ |
49 | WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags fl ) | 50 | WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags fl ) |
50 | : QWidget( parent, name, fl ) | 51 | : QWidget( parent, name, fl ) |
51 | { | 52 | { |
52 | //ani1 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot0" ) ); | 53 | //ani1 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot0" ) ); |
53 | //ani2 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot90" ) ); | 54 | //ani2 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot90" ) ); |
54 | //ani3 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot180" ) ); | 55 | //ani3 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot180" ) ); |
55 | //ani4 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot270" ) ); | 56 | //ani4 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot270" ) ); |
56 | 57 | ||
57 | if ( !name ) | 58 | if ( !name ) |
58 | setName( "WellenreiterBase" ); | 59 | setName( "WellenreiterBase" ); |
59 | resize( 191, 294 ); | 60 | resize( 191, 294 ); |
60 | #ifdef QWS | 61 | #ifdef QWS |
61 | setCaption( tr( "Wellenreiter/Opie" ) ); | 62 | setCaption( tr( "Wellenreiter/Opie" ) ); |
62 | #else | 63 | #else |
63 | setCaption( tr( "Wellenreiter/X11" ) ); | 64 | setCaption( tr( "Wellenreiter/X11" ) ); |
64 | #endif | 65 | #endif |
65 | WellenreiterBaseLayout = new QVBoxLayout( this ); | 66 | WellenreiterBaseLayout = new QVBoxLayout( this ); |
66 | WellenreiterBaseLayout->setSpacing( 2 ); | 67 | WellenreiterBaseLayout->setSpacing( 2 ); |
67 | WellenreiterBaseLayout->setMargin( 0 ); | 68 | WellenreiterBaseLayout->setMargin( 0 ); |
68 | #ifdef QWS | 69 | #ifdef QWS |
69 | TabWidget = new OTabWidget( this, "TabWidget", OTabWidget::Global ); | 70 | TabWidget = new OTabWidget( this, "TabWidget", OTabWidget::Global ); |
70 | #else | 71 | #else |
71 | TabWidget = new QTabWidget( this, "TabWidget" ); | 72 | TabWidget = new QTabWidget( this, "TabWidget" ); |
72 | #endif | 73 | #endif |
73 | ap = new QWidget( TabWidget, "ap" ); | 74 | ap = new QWidget( TabWidget, "ap" ); |
74 | apLayout = new QVBoxLayout( ap ); | 75 | apLayout = new QVBoxLayout( ap ); |
75 | apLayout->setSpacing( 2 ); | 76 | apLayout->setSpacing( 2 ); |
76 | apLayout->setMargin( 2 ); | 77 | apLayout->setMargin( 2 ); |
77 | 78 | ||
78 | //--------- NETVIEW TAB -------------- | 79 | //--------- NETVIEW TAB -------------- |
79 | 80 | ||
80 | netview = new MScanListView( ap ); | 81 | netview = new MScanListView( ap ); |
81 | apLayout->addWidget( netview ); | 82 | apLayout->addWidget( netview ); |
82 | 83 | ||
83 | //--------- GRAPH TAB -------------- | 84 | //--------- GRAPH TAB -------------- |
84 | 85 | ||
85 | graphwindow = new MGraphWindow( TabWidget, "Graph" ); | 86 | graphwindow = new MGraphWindow( TabWidget, "Graph" ); |
86 | 87 | ||
87 | //--------- LOG TAB -------------- | 88 | //--------- LOG TAB -------------- |
88 | 89 | ||
89 | logwindow = new MLogWindow( TabWidget, "Log" ); | 90 | logwindow = new MLogWindow( TabWidget, "Log" ); |
90 | 91 | ||
91 | //--------- HEX TAB -------------- | 92 | //--------- HEX TAB -------------- |
92 | 93 | ||
93 | hexwindow = new MHexWindow( TabWidget, "Hex" ); | 94 | hexwindow = new MHexWindow( TabWidget, "Hex" ); |
94 | 95 | ||
95 | //--------- STAT TAB -------------- | 96 | //--------- STAT TAB -------------- |
96 | 97 | ||
97 | statwindow = new MStatWindow( TabWidget, "Stat" ); | 98 | statwindow = new MStatWindow( TabWidget, "Stat" ); |
98 | 99 | ||
99 | //--------- ABOUT TAB -------------- | 100 | //--------- ABOUT TAB -------------- |
100 | 101 | ||
101 | about = new QWidget( TabWidget, "about" ); | 102 | about = new QWidget( TabWidget, "about" ); |
102 | aboutLayout = new QGridLayout( about ); | 103 | aboutLayout = new QGridLayout( about ); |
103 | aboutLayout->setSpacing( 6 ); | 104 | aboutLayout->setSpacing( 6 ); |
104 | aboutLayout->setMargin( 11 ); | 105 | aboutLayout->setMargin( 11 ); |
105 | 106 | ||
106 | PixmapLabel1_3_2 = new QLabel( about, "PixmapLabel1_3_2" ); | 107 | PixmapLabel1_3_2 = new QLabel( about, "PixmapLabel1_3_2" ); |
107 | PixmapLabel1_3_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, PixmapLabel1_3_2->sizePolicy().hasHeightForWidth() ) ); | 108 | PixmapLabel1_3_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, PixmapLabel1_3_2->sizePolicy().hasHeightForWidth() ) ); |
108 | PixmapLabel1_3_2->setFrameShape( QLabel::Panel ); | 109 | PixmapLabel1_3_2->setFrameShape( QLabel::Panel ); |
109 | PixmapLabel1_3_2->setFrameShadow( QLabel::Sunken ); | 110 | PixmapLabel1_3_2->setFrameShadow( QLabel::Sunken ); |
110 | PixmapLabel1_3_2->setLineWidth( 2 ); | 111 | PixmapLabel1_3_2->setLineWidth( 2 ); |
111 | PixmapLabel1_3_2->setMargin( 0 ); | 112 | PixmapLabel1_3_2->setMargin( 0 ); |
112 | PixmapLabel1_3_2->setMidLineWidth( 0 ); | 113 | PixmapLabel1_3_2->setMidLineWidth( 0 ); |
113 | PixmapLabel1_3_2->setPixmap( Resource::loadPixmap( "wellenreiter/logo" ) ); | 114 | PixmapLabel1_3_2->setPixmap( Resource::loadPixmap( "wellenreiter/logo" ) ); |
114 | PixmapLabel1_3_2->setScaledContents( TRUE ); | 115 | PixmapLabel1_3_2->setScaledContents( TRUE ); |
115 | PixmapLabel1_3_2->setAlignment( int( QLabel::AlignCenter ) ); | 116 | PixmapLabel1_3_2->setAlignment( int( QLabel::AlignCenter ) ); |
116 | 117 | ||
117 | aboutLayout->addWidget( PixmapLabel1_3_2, 0, 0 ); | 118 | aboutLayout->addWidget( PixmapLabel1_3_2, 0, 0 ); |
118 | 119 | ||
119 | TextLabel1_4_2 = new QLabel( about, "TextLabel1_4_2" ); | 120 | TextLabel1_4_2 = new QLabel( about, "TextLabel1_4_2" ); |
120 | QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); | 121 | QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); |
121 | TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); | 122 | TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); |
122 | TextLabel1_4_2_font.setPointSize( 10 ); | 123 | TextLabel1_4_2_font.setPointSize( 10 ); |
123 | TextLabel1_4_2->setFont( TextLabel1_4_2_font ); | 124 | TextLabel1_4_2->setFont( TextLabel1_4_2_font ); |
124 | TextLabel1_4_2->setText( tr( "<p align=center>\n" | 125 | TextLabel1_4_2->setText( tr( "<p align=center>\n" |
125 | "<hr>\n" | 126 | "<hr>\n" |
126 | "Michael 'Mickey' Lauer<br><hr>\n" | 127 | "Michael 'Mickey' Lauer<br><hr>\n" |
127 | "Max Moser<br>\n" | 128 | "Max Moser<br>\n" |
128 | "Martin J. Muench<br>\n" | 129 | "Martin J. Muench<br>\n" |
129 | "<b>www.wellenreiter.net</b>\n" | 130 | "<b>www.wellenreiter.net</b>\n" |
130 | "</p>" ) ); | 131 | "</p>" ) ); |
131 | TextLabel1_4_2->setAlignment( int( QLabel::AlignCenter ) ); | 132 | TextLabel1_4_2->setAlignment( int( QLabel::AlignCenter ) ); |
132 | 133 | ||
133 | aboutLayout->addWidget( TextLabel1_4_2, 1, 0 ); | 134 | aboutLayout->addWidget( TextLabel1_4_2, 1, 0 ); |
134 | 135 | ||
135 | #ifdef QWS | 136 | #ifdef QWS |
136 | TabWidget->addTab( ap, "wellenreiter/networks", tr( "Nets" ) ); | 137 | TabWidget->addTab( ap, "wellenreiter/networks", tr( "Nets" ) ); |
137 | TabWidget->addTab( graphwindow, "wellenreiter/graph", tr( "Graph" ) ); | 138 | TabWidget->addTab( graphwindow, "wellenreiter/graph", tr( "Graph" ) ); |
138 | TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) ); | 139 | TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) ); |
139 | TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) ); | 140 | TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) ); |
140 | TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stat" ) ); | 141 | TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stat" ) ); |
141 | TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) ); | 142 | TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) ); |
142 | #else | 143 | #else |
143 | TabWidget->addTab( ap, /* "wellenreiter/networks", */ tr( "Networks" ) ); | 144 | TabWidget->addTab( ap, /* "wellenreiter/networks", */ tr( "Networks" ) ); |
144 | TabWidget->addTab( graphwindow, /* "wellenreiter/graph", */ tr( "Graph" ) ); | 145 | TabWidget->addTab( graphwindow, /* "wellenreiter/graph", */ tr( "Graph" ) ); |
145 | TabWidget->addTab( logwindow, /* "wellenreiter/log", */ tr( "Log" ) ); | 146 | TabWidget->addTab( logwindow, /* "wellenreiter/log", */ tr( "Log" ) ); |
146 | TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) ); | 147 | TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) ); |
147 | TabWidget->addTab( statwindow, /* "wellenreiter/hex", */ tr( "Stat" ) ); | 148 | TabWidget->addTab( statwindow, /* "wellenreiter/hex", */ tr( "Stat" ) ); |
148 | TabWidget->addTab( about, /* "wellenreiter/about", */ tr( "About" ) ); | 149 | TabWidget->addTab( about, /* "wellenreiter/about", */ tr( "About" ) ); |
149 | #endif | 150 | #endif |
150 | WellenreiterBaseLayout->addWidget( TabWidget ); | 151 | WellenreiterBaseLayout->addWidget( TabWidget ); |
151 | 152 | ||
152 | #ifdef QWS | 153 | #ifdef QWS |
153 | TabWidget->setCurrentTab( tr( "Nets" ) ); | 154 | TabWidget->setCurrentTab( tr( "Nets" ) ); |
154 | #endif | 155 | #endif |
155 | 156 | ||
156 | } | 157 | } |
157 | 158 | ||
158 | /* | 159 | /* |
159 | * Destroys the object and frees any allocated resources | 160 | * Destroys the object and frees any allocated resources |
160 | */ | 161 | */ |
161 | WellenreiterBase::~WellenreiterBase() | 162 | WellenreiterBase::~WellenreiterBase() |
162 | { | 163 | { |
163 | // no need to delete child widgets, Qt does it all for us | 164 | // no need to delete child widgets, Qt does it all for us |
164 | } | 165 | } |
165 | 166 | ||
166 | /* | 167 | /* |
167 | * Main event handler. Reimplemented to handle application | 168 | * Main event handler. Reimplemented to handle application |
168 | * font changes | 169 | * font changes |
169 | */ | 170 | */ |
170 | bool WellenreiterBase::event( QEvent* ev ) | 171 | bool WellenreiterBase::event( QEvent* ev ) |
171 | { | 172 | { |
172 | bool ret = QWidget::event( ev ); | 173 | bool ret = QWidget::event( ev ); |
173 | if ( ev->type() == QEvent::ApplicationFontChange ) { | 174 | if ( ev->type() == QEvent::ApplicationFontChange ) { |
174 | //QFont Log_2_font( Log_2->font() ); | 175 | //QFont Log_2_font( Log_2->font() ); |
175 | //Log_2_font.setFamily( "adobe-courier" ); | 176 | //Log_2_font.setFamily( "adobe-courier" ); |
176 | //Log_2_font.setPointSize( 8 ); | 177 | //Log_2_font.setPointSize( 8 ); |
177 | //Log_2->setFont( Log_2_font ); | 178 | //Log_2->setFont( Log_2_font ); |
178 | QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); | 179 | QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); |
179 | TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); | 180 | TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); |
180 | TextLabel1_4_2_font.setPointSize( 10 ); | 181 | TextLabel1_4_2_font.setPointSize( 10 ); |
181 | TextLabel1_4_2->setFont( TextLabel1_4_2_font ); | 182 | TextLabel1_4_2->setFont( TextLabel1_4_2_font ); |
182 | } | 183 | } |
183 | return ret; | 184 | return ret; |
184 | } | 185 | } |
185 | 186 | ||
diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.h b/noncore/net/wellenreiter/gui/wellenreiterbase.h index e8dc924..2cc273e 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.h +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.h | |||
@@ -1,76 +1,77 @@ | |||
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 WELLENREITERBASE_H | 16 | #ifndef WELLENREITERBASE_H |
17 | #define WELLENREITERBASE_H | 17 | #define WELLENREITERBASE_H |
18 | 18 | ||
19 | #include <qvariant.h> | 19 | #include <qvariant.h> |
20 | #include <qwidget.h> | 20 | #include <qwidget.h> |
21 | class QVBoxLayout; | 21 | class QVBoxLayout; |
22 | class QHBoxLayout; | 22 | class QHBoxLayout; |
23 | class QGridLayout; | 23 | class QGridLayout; |
24 | class QLabel; | 24 | class QLabel; |
25 | class MScanListView; | 25 | class MScanListView; |
26 | class MScanListItem; | 26 | class MScanListItem; |
27 | class QPushButton; | 27 | class QPushButton; |
28 | class MLogWindow; | 28 | class MLogWindow; |
29 | class MHexWindow; | 29 | class MHexWindow; |
30 | class MStatWindow; | 30 | class MStatWindow; |
31 | class MGraphWindow; | 31 | class MGraphWindow; |
32 | 32 | ||
33 | #ifdef QWS | 33 | #ifdef QWS |
34 | class OTabWidget; | 34 | #include <opie2/otabwidget.h> |
35 | using namespace Opie; | ||
35 | #else | 36 | #else |
36 | class QTabWidget; | 37 | class QTabWidget; |
37 | #endif | 38 | #endif |
38 | 39 | ||
39 | class WellenreiterBase : public QWidget | 40 | class WellenreiterBase : public QWidget |
40 | { | 41 | { |
41 | Q_OBJECT | 42 | Q_OBJECT |
42 | 43 | ||
43 | public: | 44 | public: |
44 | WellenreiterBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 45 | WellenreiterBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
45 | ~WellenreiterBase(); | 46 | ~WellenreiterBase(); |
46 | 47 | ||
47 | #ifdef QWS | 48 | #ifdef QWS |
48 | OTabWidget* TabWidget; | 49 | OTabWidget* TabWidget; |
49 | #else | 50 | #else |
50 | QTabWidget* TabWidget; | 51 | QTabWidget* TabWidget; |
51 | #endif | 52 | #endif |
52 | QWidget* ap; | 53 | QWidget* ap; |
53 | MScanListView* netview; | 54 | MScanListView* netview; |
54 | MLogWindow* logwindow; | 55 | MLogWindow* logwindow; |
55 | MHexWindow* hexwindow; | 56 | MHexWindow* hexwindow; |
56 | MStatWindow* statwindow; | 57 | MStatWindow* statwindow; |
57 | MGraphWindow* graphwindow; | 58 | MGraphWindow* graphwindow; |
58 | QWidget* about; | 59 | QWidget* about; |
59 | QLabel* PixmapLabel1_3_2; | 60 | QLabel* PixmapLabel1_3_2; |
60 | QLabel* TextLabel1_4_2; | 61 | QLabel* TextLabel1_4_2; |
61 | 62 | ||
62 | protected: | 63 | protected: |
63 | QVBoxLayout* WellenreiterBaseLayout; | 64 | QVBoxLayout* WellenreiterBaseLayout; |
64 | QVBoxLayout* apLayout; | 65 | QVBoxLayout* apLayout; |
65 | QGridLayout* aboutLayout; | 66 | QGridLayout* aboutLayout; |
66 | bool event( QEvent* ); | 67 | bool event( QEvent* ); |
67 | 68 | ||
68 | QPixmap* ani1; | 69 | QPixmap* ani1; |
69 | QPixmap* ani2; | 70 | QPixmap* ani2; |
70 | QPixmap* ani3; | 71 | QPixmap* ani3; |
71 | QPixmap* ani4; | 72 | QPixmap* ani4; |
72 | 73 | ||
73 | 74 | ||
74 | }; | 75 | }; |
75 | 76 | ||
76 | #endif // WELLENREITERBASE_H | 77 | #endif // WELLENREITERBASE_H |