-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 52 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.h | 5 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/main.cpp | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 6 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 12 |
5 files changed, 56 insertions, 21 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index 1341d03..7f39230 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp | |||
@@ -1,436 +1,468 @@ | |||
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> | ||
26 | using namespace Opie; | ||
25 | #endif | 27 | #endif |
26 | 28 | ||
27 | /* QT */ | 29 | /* QT */ |
28 | #include <qapplication.h> | 30 | #include <qapplication.h> |
29 | #include <qcheckbox.h> | 31 | #include <qcheckbox.h> |
30 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
31 | #include <qfile.h> | 33 | #include <qfile.h> |
32 | #include <qlineedit.h> | 34 | #include <qlineedit.h> |
33 | #include <qlayout.h> | 35 | #include <qlayout.h> |
34 | #include <qmap.h> | 36 | #include <qmap.h> |
35 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
36 | #include <qtabwidget.h> | 38 | #include <qtabwidget.h> |
37 | #include <qtoolbutton.h> | 39 | #include <qtoolbutton.h> |
38 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
39 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
40 | 42 | ||
43 | /* POSIX */ | ||
44 | #include <assert.h> | ||
41 | 45 | ||
42 | WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; | 46 | WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; |
43 | 47 | ||
44 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) | 48 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) |
45 | :WellenreiterConfigBase( parent, name, true, f ) | 49 | :WellenreiterConfigBase( parent, name, true, f ) |
46 | { | 50 | { |
47 | _devicetype[ "cisco" ] = DEVTYPE_CISCO; | 51 | _devicetype[ "cisco" ] = DEVTYPE_CISCO; |
48 | _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; | 52 | _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; |
49 | _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; | 53 | _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; |
50 | _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; | 54 | _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; |
51 | _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; | 55 | _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; |
52 | _devicetype[ "<file>" ] = DEVTYPE_FILE; | 56 | _devicetype[ "<file>" ] = DEVTYPE_FILE; |
53 | 57 | ||
54 | // gather possible interface names from ONetwork | 58 | // gather possible interface names from ONetwork |
55 | ONetwork* net = ONetwork::instance(); | 59 | ONetwork* net = ONetwork::instance(); |
56 | ONetwork::InterfaceIterator it = net->iterator(); | 60 | ONetwork::InterfaceIterator it = net->iterator(); |
57 | while ( it.current() ) | 61 | while ( it.current() ) |
58 | { | 62 | { |
59 | if ( it.current()->isWireless() ) | 63 | if ( it.current()->isWireless() ) |
60 | interfaceName->insertItem( it.current()->name() ); | 64 | interfaceName->insertItem( it.current()->name() ); |
61 | ++it; | 65 | ++it; |
62 | } | 66 | } |
63 | 67 | ||
64 | load(); | 68 | load(); |
65 | 69 | ||
66 | #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 |
67 | QPushButton* okButton = new QPushButton( "ok", this ); | 71 | QPushButton* okButton = new QPushButton( "ok", this ); |
68 | okButton->show(); | 72 | okButton->show(); |
69 | WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui | 73 | WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui |
70 | connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); | 74 | connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); |
71 | #endif | 75 | #endif |
72 | 76 | ||
73 | WellenreiterConfigWindow::_instance = this; | 77 | WellenreiterConfigWindow::_instance = this; |
74 | 78 | ||
75 | connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); | 79 | connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); |
76 | connect( newNetworkAction, SIGNAL( activated(int) ), this, SLOT( changedNetworkAction(int) ) ); | 80 | connect( newNetworkAction, SIGNAL( activated(int) ), this, SLOT( changedNetworkAction(int) ) ); |
77 | connect( newClientAction, SIGNAL( activated(int) ), this, SLOT( changedClientAction(int) ) ); | 81 | connect( newClientAction, SIGNAL( activated(int) ), this, SLOT( changedClientAction(int) ) ); |
78 | connect( newStationAction, SIGNAL( activated(int) ), this, SLOT( changedStationAction(int) ) ); | 82 | connect( newStationAction, SIGNAL( activated(int) ), this, SLOT( changedStationAction(int) ) ); |
79 | connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); | 83 | connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); |
80 | 84 | ||
81 | // make the checkbox 'channelAll' control all other channels | 85 | // make the checkbox 'channelAll' control all other channels |
82 | connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); | 86 | connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); |
83 | 87 | ||
84 | connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); | 88 | connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); |
85 | 89 | ||
86 | // hide tab4 (parse) until Wellenreiter 1.2 | 90 | // hide tab4 (parse) until Wellenreiter 1.2 |
87 | tab->removePage( tab_4 ); | 91 | tab->removePage( tab_4 ); |
88 | }; | 92 | }; |
89 | 93 | ||
90 | 94 | ||
91 | WellenreiterConfigWindow::~WellenreiterConfigWindow() | 95 | WellenreiterConfigWindow::~WellenreiterConfigWindow() |
92 | { | 96 | { |
93 | save(); | 97 | save(); |
94 | } | 98 | } |
95 | 99 | ||
96 | 100 | ||
97 | void WellenreiterConfigWindow::performAutodetection() | 101 | void WellenreiterConfigWindow::performAutodetection() |
98 | { | 102 | { |
99 | //TODO: insert modal splash screen here | 103 | //TODO: insert modal splash screen here |
100 | // and sleep a second, so that it looks | 104 | // and sleep a second, so that it looks |
101 | // like we're actually doing something fancy... ;-) | 105 | // like we're actually doing something fancy... ;-) |
102 | 106 | ||
103 | qDebug( "WellenreiterConfigWindow::performAutodetection()" ); | 107 | qDebug( "WellenreiterConfigWindow::performAutodetection()" ); |
104 | 108 | ||
105 | // try to guess device type | 109 | // try to guess device type |
106 | QFile m( "/proc/modules" ); | 110 | QFile m( "/proc/modules" ); |
107 | if ( m.open( IO_ReadOnly ) ) | 111 | if ( m.open( IO_ReadOnly ) ) |
108 | { | 112 | { |
109 | int devicetype(0); | 113 | int devicetype(0); |
110 | QString line; | 114 | QString line; |
111 | QTextStream modules( &m ); | 115 | QTextStream modules( &m ); |
112 | while( !modules.atEnd() && !devicetype ) | 116 | while( !modules.atEnd() && !devicetype ) |
113 | { | 117 | { |
114 | modules >> line; | 118 | modules >> line; |
115 | if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; | 119 | if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; |
116 | else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; | 120 | else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; |
117 | else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; | 121 | else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; |
118 | else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; | 122 | else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; |
119 | } | 123 | } |
120 | if ( devicetype ) | 124 | if ( devicetype ) |
121 | { | 125 | { |
122 | deviceType->setCurrentItem( devicetype ); | 126 | deviceType->setCurrentItem( devicetype ); |
123 | _guess = devicetype; | 127 | _guess = devicetype; |
124 | qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); | 128 | qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); |
125 | } | 129 | } |
126 | } | 130 | } |
127 | } | 131 | } |
128 | 132 | ||
129 | 133 | ||
130 | int WellenreiterConfigWindow::driverType() const | 134 | int WellenreiterConfigWindow::driverType() const |
131 | { | 135 | { |
132 | QString name = deviceType->currentText(); | 136 | QString name = deviceType->currentText(); |
133 | if ( _devicetype.contains( name ) ) | 137 | if ( _devicetype.contains( name ) ) |
134 | { | 138 | { |
135 | return _devicetype[name]; | 139 | return _devicetype[name]; |
136 | } | 140 | } |
137 | else | 141 | else |
138 | { | 142 | { |
139 | return 0; | 143 | return 0; |
140 | } | 144 | } |
141 | }; | 145 | }; |
142 | 146 | ||
143 | 147 | ||
144 | int WellenreiterConfigWindow::hoppingInterval() const | 148 | int WellenreiterConfigWindow::hoppingInterval() const |
145 | { | 149 | { |
146 | return hopInterval->cleanText().toInt(); | 150 | return hopInterval->cleanText().toInt(); |
147 | } | 151 | } |
148 | 152 | ||
149 | 153 | ||
150 | bool WellenreiterConfigWindow::usePrismHeader() const | 154 | bool WellenreiterConfigWindow::usePrismHeader() const |
151 | { | 155 | { |
152 | return prismHeader->isChecked(); | 156 | return prismHeader->isChecked(); |
153 | } | 157 | } |
154 | 158 | ||
155 | 159 | ||
156 | bool WellenreiterConfigWindow::isChannelChecked( int channel ) const | 160 | bool WellenreiterConfigWindow::isChannelChecked( int channel ) const |
157 | { | 161 | { |
158 | switch ( channel ) | 162 | switch ( channel ) |
159 | { | 163 | { |
160 | case 1: return channel1->isOn(); | 164 | case 1: return channel1->isOn(); |
161 | case 2: return channel2->isOn(); | 165 | case 2: return channel2->isOn(); |
162 | case 3: return channel3->isOn(); | 166 | case 3: return channel3->isOn(); |
163 | case 4: return channel4->isOn(); | 167 | case 4: return channel4->isOn(); |
164 | case 5: return channel5->isOn(); | 168 | case 5: return channel5->isOn(); |
165 | case 6: return channel6->isOn(); | 169 | case 6: return channel6->isOn(); |
166 | case 7: return channel7->isOn(); | 170 | case 7: return channel7->isOn(); |
167 | case 8: return channel8->isOn(); | 171 | case 8: return channel8->isOn(); |
168 | case 9: return channel9->isOn(); | 172 | case 9: return channel9->isOn(); |
169 | case 10: return channel10->isOn(); | 173 | case 10: return channel10->isOn(); |
170 | case 11: return channel11->isOn(); | 174 | case 11: return channel11->isOn(); |
171 | case 12: return channel12->isOn(); | 175 | case 12: return channel12->isOn(); |
172 | case 13: return channel13->isOn(); | 176 | case 13: return channel13->isOn(); |
173 | case 14: return channel14->isOn(); | 177 | case 14: return channel14->isOn(); |
174 | } | 178 | } |
175 | } | 179 | } |
176 | 180 | ||
177 | 181 | ||
178 | void WellenreiterConfigWindow::changedDeviceType(int t) | 182 | void WellenreiterConfigWindow::changedDeviceType(int t) |
179 | { | 183 | { |
180 | if ( t != DEVTYPE_FILE ) return; | 184 | if ( t != DEVTYPE_FILE ) return; |
181 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false); | 185 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false); |
182 | if ( !name.isEmpty() && QFile::exists( name ) ) | 186 | if ( !name.isEmpty() && QFile::exists( name ) ) |
183 | { | 187 | { |
184 | interfaceName->insertItem( name ); | 188 | interfaceName->insertItem( name ); |
185 | interfaceName->setCurrentItem( interfaceName->count()-1 ); | 189 | interfaceName->setCurrentItem( interfaceName->count()-1 ); |
186 | } | 190 | } |
187 | else | 191 | else |
188 | { | 192 | { |
189 | deviceType->setCurrentItem( _guess ); | 193 | deviceType->setCurrentItem( _guess ); |
190 | } | 194 | } |
191 | 195 | ||
192 | } | 196 | } |
193 | 197 | ||
194 | 198 | ||
195 | void WellenreiterConfigWindow::synchronizeActionsAndScripts() | 199 | void WellenreiterConfigWindow::synchronizeActionsAndScripts() |
196 | { | 200 | { |
197 | if ( newNetworkAction->currentItem() == 4 ) newNetworkScript->show(); else newNetworkScript->hide(); | 201 | if ( newNetworkAction->currentItem() == 4 ) newNetworkScript->show(); else newNetworkScript->hide(); |
198 | if ( newClientAction->currentItem() == 4 ) newClientScript->show(); else newClientScript->hide(); | 202 | if ( newClientAction->currentItem() == 4 ) newClientScript->show(); else newClientScript->hide(); |
199 | if ( newStationAction->currentItem() == 4 ) newStationScript->show(); else newStationScript->hide(); | 203 | if ( newStationAction->currentItem() == 4 ) newStationScript->show(); else newStationScript->hide(); |
200 | 204 | ||
201 | //newNetworkScript->setEnabled( newNetworkAction->currentItem() == 4 ); | 205 | //newNetworkScript->setEnabled( newNetworkAction->currentItem() == 4 ); |
202 | //newClientScript->setEnabled( newClientAction->currentItem() == 4 ); | 206 | //newClientScript->setEnabled( newClientAction->currentItem() == 4 ); |
203 | //newStationScript->setEnabled( newStationAction->currentItem() == 4 ); | 207 | //newStationScript->setEnabled( newStationAction->currentItem() == 4 ); |
204 | } | 208 | } |
205 | 209 | ||
206 | 210 | ||
207 | void WellenreiterConfigWindow::changedNetworkAction(int t) | 211 | void WellenreiterConfigWindow::changedNetworkAction(int t) |
208 | { | 212 | { |
209 | synchronizeActionsAndScripts(); | 213 | synchronizeActionsAndScripts(); |
210 | } | 214 | } |
211 | 215 | ||
212 | 216 | ||
213 | void WellenreiterConfigWindow::changedClientAction(int t) | 217 | void WellenreiterConfigWindow::changedClientAction(int t) |
214 | { | 218 | { |
215 | synchronizeActionsAndScripts(); | 219 | synchronizeActionsAndScripts(); |
216 | } | 220 | } |
217 | 221 | ||
218 | 222 | ||
219 | void WellenreiterConfigWindow::changedStationAction(int t) | 223 | void WellenreiterConfigWindow::changedStationAction(int t) |
220 | { | 224 | { |
221 | synchronizeActionsAndScripts(); | 225 | synchronizeActionsAndScripts(); |
222 | } | 226 | } |
223 | 227 | ||
224 | 228 | ||
225 | void WellenreiterConfigWindow::getCaptureFileNameClicked() | 229 | void WellenreiterConfigWindow::getCaptureFileNameClicked() |
226 | { | 230 | { |
227 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); | 231 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); |
228 | qDebug( "name = %s", (const char*) name ); | 232 | qDebug( "name = %s", (const char*) name ); |
229 | if ( !name.isEmpty() ) | 233 | if ( !name.isEmpty() ) |
230 | { | 234 | { |
231 | captureFileName->setText( name ); | 235 | captureFileName->setText( name ); |
232 | } | 236 | } |
233 | } | 237 | } |
234 | 238 | ||
235 | 239 | ||
236 | void WellenreiterConfigWindow::channelAllClicked(int state) | 240 | void WellenreiterConfigWindow::channelAllClicked(int state) |
237 | { | 241 | { |
238 | bool b = state; | 242 | bool b = state; |
239 | channel1->setChecked( b ); | 243 | channel1->setChecked( b ); |
240 | channel2->setChecked( b ); | 244 | channel2->setChecked( b ); |
241 | channel3->setChecked( b ); | 245 | channel3->setChecked( b ); |
242 | channel4->setChecked( b ); | 246 | channel4->setChecked( b ); |
243 | channel5->setChecked( b ); | 247 | channel5->setChecked( b ); |
244 | channel6->setChecked( b ); | 248 | channel6->setChecked( b ); |
245 | channel7->setChecked( b ); | 249 | channel7->setChecked( b ); |
246 | channel8->setChecked( b ); | 250 | channel8->setChecked( b ); |
247 | channel9->setChecked( b ); | 251 | channel9->setChecked( b ); |
248 | channel10->setChecked( b ); | 252 | channel10->setChecked( b ); |
249 | channel11->setChecked( b ); | 253 | channel11->setChecked( b ); |
250 | channel12->setChecked( b ); | 254 | channel12->setChecked( b ); |
251 | channel13->setChecked( b ); | 255 | channel13->setChecked( b ); |
252 | channel14->setChecked( b ); | 256 | channel14->setChecked( b ); |
253 | } | 257 | } |
254 | 258 | ||
255 | 259 | ||
256 | bool WellenreiterConfigWindow::useGPS() const | 260 | bool WellenreiterConfigWindow::useGPS() const |
257 | { | 261 | { |
258 | return enableGPS->isChecked(); | 262 | return enableGPS->isChecked(); |
259 | } | 263 | } |
260 | 264 | ||
261 | 265 | ||
262 | const QString WellenreiterConfigWindow::gpsHost() const | 266 | const QString WellenreiterConfigWindow::gpsHost() const |
263 | { | 267 | { |
264 | return useGPS() ? gpsdHost->currentText() : QString::null; | 268 | return useGPS() ? gpsdHost->currentText() : QString::null; |
265 | } | 269 | } |
266 | 270 | ||
267 | 271 | ||
268 | int WellenreiterConfigWindow::gpsPort() const | 272 | int WellenreiterConfigWindow::gpsPort() const |
269 | { | 273 | { |
270 | bool ok; | 274 | bool ok; |
271 | return useGPS() ? gpsdPort->value() : -1; | 275 | return useGPS() ? gpsdPort->value() : -1; |
272 | } | 276 | } |
273 | 277 | ||
274 | 278 | ||
275 | void WellenreiterConfigWindow::performAction( const QString& type ) | 279 | void WellenreiterConfigWindow::performAction( const QString& type, |
280 | const QString& essid, | ||
281 | const QString& mac, | ||
282 | bool wep, | ||
283 | int channel, | ||
284 | int signal | ||
285 | /* , const GpsLocation& loc */ ) | ||
276 | { | 286 | { |
277 | int action; | 287 | int action; |
278 | QString script; | 288 | QString script; |
279 | 289 | ||
280 | if ( type == "network" ) | 290 | if ( type == "network" ) |
281 | { | 291 | { |
282 | action = newNetworkAction->currentItem(); | 292 | action = newNetworkAction->currentItem(); |
283 | script = newNetworkScript->text(); | 293 | script = newNetworkScript->text(); |
284 | } | 294 | } |
285 | else if ( type == "managed" || type == "adhoc" ) | 295 | else if ( type == "managed" || type == "adhoc" ) |
286 | { | 296 | { |
287 | action = newClientAction->currentItem(); | 297 | action = newClientAction->currentItem(); |
288 | script = newClientScript->text(); | 298 | script = newClientScript->text(); |
289 | } | 299 | } |
290 | else if ( type == "station" ) | 300 | else if ( type == "station" ) |
291 | { | 301 | { |
292 | action = newStationAction->currentItem(); | 302 | action = newStationAction->currentItem(); |
293 | script = newStationScript->text(); | 303 | script = newStationScript->text(); |
294 | } | 304 | } |
295 | else | 305 | else |
296 | { | 306 | { |
297 | qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); | 307 | qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); |
298 | return; | 308 | return; |
299 | } | 309 | } |
300 | 310 | ||
301 | qDebug( "going to perform action %d (script='%s')", action, (const char*) script ); | 311 | qDebug( "going to perform action %d (script='%s')", action, (const char*) script ); |
302 | 312 | ||
303 | /* | 313 | switch( action ) |
304 | 314 | { | |
305 | if ( sound == "Ignore" ) return; | 315 | case 0: /* Ignore */ return; |
306 | else if ( sound == "Touch" ) ODevice::inst()->touchSound(); | 316 | case 1: /* Play Alarm */ ODevice::inst()->alarmSound(); return; |
307 | else if ( sound == "Key" ) ODevice::inst()->keySound(); | 317 | case 2: /* Play Click */ ODevice::inst()->touchSound(); return; |
308 | else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); | 318 | case 3: /* Blink LED */ break; //FIXME: Implement this |
309 | 319 | case 4: /* Run Script */ | |
310 | */ | 320 | { |
321 | /** | ||
322 | * | ||
323 | * Script Substitution Information: | ||
324 | * | ||
325 | * $SSID = SSID | ||
326 | * $MAC = MAC | ||
327 | * $WEP = Wep | ||
328 | * $CHAN = Channel | ||
329 | * | ||
330 | **/ | ||
331 | script = script.replace( QRegExp( "$SSID" ), essid ); | ||
332 | script = script.replace( QRegExp( "$MAC" ), mac ); | ||
333 | script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); | ||
334 | script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); | ||
335 | |||
336 | qDebug( "going to call script '%s'", (const char*) script ); | ||
337 | ::system( script ); | ||
338 | qDebug( "script returned." ); | ||
339 | return; | ||
340 | } | ||
341 | default: assert( false ); | ||
342 | } | ||
311 | } | 343 | } |
312 | 344 | ||
313 | 345 | ||
314 | void WellenreiterConfigWindow::load() | 346 | void WellenreiterConfigWindow::load() |
315 | { | 347 | { |
316 | #ifdef Q_WS_X11 | 348 | #ifdef Q_WS_X11 |
317 | #warning Persistent Configuration not yet implemented for standalone X11 build | 349 | #warning Persistent Configuration not yet implemented for standalone X11 build |
318 | performAutodetection(); | 350 | performAutodetection(); |
319 | #else | 351 | #else |
320 | qDebug( "loading configuration settings..." ); | 352 | qDebug( "loading configuration settings..." ); |
321 | 353 | ||
322 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ | 354 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ |
323 | 355 | ||
324 | OConfig* c = oApp->config(); | 356 | OConfig* c = oApp->config(); |
325 | 357 | ||
326 | c->setGroup( "Interface" ); | 358 | c->setGroup( "Interface" ); |
327 | 359 | ||
328 | QString interface = c->readEntry( "name", "<none>" ); | 360 | QString interface = c->readEntry( "name", "<none>" ); |
329 | if ( interface != "<none>" ) | 361 | if ( interface != "<none>" ) |
330 | { | 362 | { |
331 | #if QT_VERSION < 300 | 363 | #if QT_VERSION < 300 |
332 | interfaceName->insertItem( interface, 0 ); | 364 | interfaceName->insertItem( interface, 0 ); |
333 | interfaceName->setCurrentItem( 0 ); | 365 | interfaceName->setCurrentItem( 0 ); |
334 | #else | 366 | #else |
335 | interfaceName->setCurrentText( interface ); | 367 | interfaceName->setCurrentText( interface ); |
336 | #endif | 368 | #endif |
337 | 369 | ||
338 | QString device = c->readEntry( "type", "<select>" ); | 370 | QString device = c->readEntry( "type", "<select>" ); |
339 | #if QT_VERSION < 300 | 371 | #if QT_VERSION < 300 |
340 | for ( int i = 0; i < deviceType->count(); ++i ) | 372 | for ( int i = 0; i < deviceType->count(); ++i ) |
341 | { | 373 | { |
342 | if ( deviceType->text( i ) == device ) | 374 | if ( deviceType->text( i ) == device ) |
343 | { | 375 | { |
344 | deviceType->setCurrentItem( i ); | 376 | deviceType->setCurrentItem( i ); |
345 | break; | 377 | break; |
346 | } | 378 | } |
347 | } | 379 | } |
348 | #else | 380 | #else |
349 | deviceType->setCurrentText( device ); | 381 | deviceType->setCurrentText( device ); |
350 | #endif | 382 | #endif |
351 | } | 383 | } |
352 | else | 384 | else |
353 | { | 385 | { |
354 | performAutodetection(); | 386 | performAutodetection(); |
355 | } | 387 | } |
356 | 388 | ||
357 | prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); | 389 | prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); |
358 | hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); | 390 | hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); |
359 | hopInterval->setValue( c->readNumEntry( "interval", 250 ) ); | 391 | hopInterval->setValue( c->readNumEntry( "interval", 250 ) ); |
360 | adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); | 392 | adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); |
361 | 393 | ||
362 | c->setGroup( "Capture" ); | 394 | c->setGroup( "Capture" ); |
363 | captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); | 395 | captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); |
364 | 396 | ||
365 | c->setGroup( "UI" ); | 397 | c->setGroup( "UI" ); |
366 | lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); | 398 | lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); |
367 | openTree->setChecked( c->readBoolEntry( "openTree", true ) ); | 399 | openTree->setChecked( c->readBoolEntry( "openTree", true ) ); |
368 | disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); | 400 | disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); |
369 | newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 0 ) ); | 401 | newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 0 ) ); |
370 | newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) ); | 402 | newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) ); |
371 | newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 0 ) ); | 403 | newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 0 ) ); |
372 | newClientScript->setText( c->readEntry( "newClientScript", "" ) ); | 404 | newClientScript->setText( c->readEntry( "newClientScript", "" ) ); |
373 | newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 0 ) ); | 405 | newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 0 ) ); |
374 | newStationScript->setText( c->readEntry( "newStationScript", "" ) ); | 406 | newStationScript->setText( c->readEntry( "newStationScript", "" ) ); |
375 | synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand | 407 | synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand |
376 | 408 | ||
377 | c->setGroup( "GPS" ); | 409 | c->setGroup( "GPS" ); |
378 | enableGPS->setChecked( c->readBoolEntry( "use", false ) ); | 410 | enableGPS->setChecked( c->readBoolEntry( "use", false ) ); |
379 | #if QT_VERSION < 300 | 411 | #if QT_VERSION < 300 |
380 | gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); | 412 | gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); |
381 | gpsdHost->setCurrentItem( 0 ); | 413 | gpsdHost->setCurrentItem( 0 ); |
382 | #else | 414 | #else |
383 | gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); | 415 | gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); |
384 | #endif | 416 | #endif |
385 | gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); | 417 | gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); |
386 | startGPS->setChecked( c->readBoolEntry( "start", false ) ); | 418 | startGPS->setChecked( c->readBoolEntry( "start", false ) ); |
387 | commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); | 419 | commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); |
388 | 420 | ||
389 | #endif | 421 | #endif |
390 | } | 422 | } |
391 | 423 | ||
392 | 424 | ||
393 | void WellenreiterConfigWindow::save() | 425 | void WellenreiterConfigWindow::save() |
394 | { | 426 | { |
395 | #ifdef Q_WS_X11 | 427 | #ifdef Q_WS_X11 |
396 | #warning Persistent Configuration not yet implemented for standalone X11 build | 428 | #warning Persistent Configuration not yet implemented for standalone X11 build |
397 | #else | 429 | #else |
398 | qDebug( "saving configuration settings..." ); | 430 | qDebug( "saving configuration settings..." ); |
399 | 431 | ||
400 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ | 432 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ |
401 | 433 | ||
402 | OConfig* c = oApp->config(); | 434 | OConfig* c = oApp->config(); |
403 | 435 | ||
404 | c->setGroup( "Interface" ); | 436 | c->setGroup( "Interface" ); |
405 | c->writeEntry( "name", interfaceName->currentText() ); | 437 | c->writeEntry( "name", interfaceName->currentText() ); |
406 | c->writeEntry( "type", deviceType->currentText() ); | 438 | c->writeEntry( "type", deviceType->currentText() ); |
407 | c->writeEntry( "prism", prismHeader->isChecked() ); | 439 | c->writeEntry( "prism", prismHeader->isChecked() ); |
408 | c->writeEntry( "hop", hopChannels->isChecked() ); | 440 | c->writeEntry( "hop", hopChannels->isChecked() ); |
409 | c->writeEntry( "interval", hopInterval->value() ); | 441 | c->writeEntry( "interval", hopInterval->value() ); |
410 | c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); | 442 | c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); |
411 | 443 | ||
412 | c->setGroup( "Capture" ); | 444 | c->setGroup( "Capture" ); |
413 | c->writeEntry( "filename", captureFileName->text() ); | 445 | c->writeEntry( "filename", captureFileName->text() ); |
414 | 446 | ||
415 | c->setGroup( "UI" ); | 447 | c->setGroup( "UI" ); |
416 | c->writeEntry( "lookupVendor", lookupVendor->isChecked() ); | 448 | c->writeEntry( "lookupVendor", lookupVendor->isChecked() ); |
417 | c->writeEntry( "openTree", openTree->isChecked() ); | 449 | c->writeEntry( "openTree", openTree->isChecked() ); |
418 | c->writeEntry( "disablePM", disablePM->isChecked() ); | 450 | c->writeEntry( "disablePM", disablePM->isChecked() ); |
419 | c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() ); | 451 | c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() ); |
420 | c->writeEntry( "newNetworkScript", newNetworkScript->text() ); | 452 | c->writeEntry( "newNetworkScript", newNetworkScript->text() ); |
421 | c->writeEntry( "newClientAction", newClientAction->currentItem() ); | 453 | c->writeEntry( "newClientAction", newClientAction->currentItem() ); |
422 | c->writeEntry( "newClientScript", newClientScript->text() ); | 454 | c->writeEntry( "newClientScript", newClientScript->text() ); |
423 | c->writeEntry( "newStationAction", newStationAction->currentItem() ); | 455 | c->writeEntry( "newStationAction", newStationAction->currentItem() ); |
424 | c->writeEntry( "newStationScript", newStationScript->text() ); | 456 | c->writeEntry( "newStationScript", newStationScript->text() ); |
425 | 457 | ||
426 | c->setGroup( "GPS" ); | 458 | c->setGroup( "GPS" ); |
427 | c->writeEntry( "use", enableGPS->isChecked() ); | 459 | c->writeEntry( "use", enableGPS->isChecked() ); |
428 | c->writeEntry( "host", gpsdHost->currentText() ); | 460 | c->writeEntry( "host", gpsdHost->currentText() ); |
429 | c->writeEntry( "port", gpsdPort->value() ); | 461 | c->writeEntry( "port", gpsdPort->value() ); |
430 | c->writeEntry( "start", startGPS->isChecked() ); | 462 | c->writeEntry( "start", startGPS->isChecked() ); |
431 | c->writeEntry( "command", commandGPS->text() ); | 463 | c->writeEntry( "command", commandGPS->text() ); |
432 | 464 | ||
433 | c->write(); | 465 | c->write(); |
434 | 466 | ||
435 | #endif | 467 | #endif |
436 | } | 468 | } |
diff --git a/noncore/net/wellenreiter/gui/configwindow.h b/noncore/net/wellenreiter/gui/configwindow.h index b082331..5c998cb 100644 --- a/noncore/net/wellenreiter/gui/configwindow.h +++ b/noncore/net/wellenreiter/gui/configwindow.h | |||
@@ -1,78 +1,81 @@ | |||
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 WELLENREITERCONFIGWINDOW_H | 16 | #ifndef WELLENREITERCONFIGWINDOW_H |
17 | #define WELLENREITERCONFIGWINDOW_H | 17 | #define WELLENREITERCONFIGWINDOW_H |
18 | 18 | ||
19 | #include "configbase.h" | 19 | #include "configbase.h" |
20 | #include "gps.h" | ||
21 | |||
22 | /* QT */ | ||
20 | #include <qmap.h> | 23 | #include <qmap.h> |
21 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
22 | #include <qstring.h> | 25 | #include <qstring.h> |
23 | 26 | ||
24 | const int DEVTYPE_SELECT = 0; | 27 | const int DEVTYPE_SELECT = 0; |
25 | const int DEVTYPE_CISCO = 1; | 28 | const int DEVTYPE_CISCO = 1; |
26 | const int DEVTYPE_WLAN_NG = 2; | 29 | const int DEVTYPE_WLAN_NG = 2; |
27 | const int DEVTYPE_HOSTAP = 3; | 30 | const int DEVTYPE_HOSTAP = 3; |
28 | const int DEVTYPE_ORINOCO = 4; | 31 | const int DEVTYPE_ORINOCO = 4; |
29 | const int DEVTYPE_MANUAL = 5; | 32 | const int DEVTYPE_MANUAL = 5; |
30 | const int DEVTYPE_FILE = 6; | 33 | const int DEVTYPE_FILE = 6; |
31 | 34 | ||
32 | class WellenreiterConfigWindow; | 35 | class WellenreiterConfigWindow; |
33 | 36 | ||
34 | class WellenreiterConfigWindow : public WellenreiterConfigBase | 37 | class WellenreiterConfigWindow : public WellenreiterConfigBase |
35 | { | 38 | { |
36 | Q_OBJECT | 39 | Q_OBJECT |
37 | 40 | ||
38 | public: | 41 | public: |
39 | WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 ); | 42 | WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 ); |
40 | ~WellenreiterConfigWindow(); | 43 | ~WellenreiterConfigWindow(); |
41 | 44 | ||
42 | int driverType() const; | 45 | int driverType() const; |
43 | const QString soundOnNetwork() const { return "";/*netSound->currentText();*/ }; | 46 | const QString soundOnNetwork() const { return "";/*netSound->currentText();*/ }; |
44 | const QString soundOnBeacon() const { return "";/*beaconSound->currentText();*/ }; | 47 | const QString soundOnBeacon() const { return "";/*beaconSound->currentText();*/ }; |
45 | static WellenreiterConfigWindow* instance() { return _instance; }; | 48 | static WellenreiterConfigWindow* instance() { return _instance; }; |
46 | 49 | ||
47 | int hoppingInterval() const; | 50 | int hoppingInterval() const; |
48 | bool usePrismHeader() const; | 51 | bool usePrismHeader() const; |
49 | bool isChannelChecked( int ) const; | 52 | bool isChannelChecked( int ) const; |
50 | 53 | ||
51 | bool useGPS() const; | 54 | bool useGPS() const; |
52 | const QString gpsHost() const; | 55 | const QString gpsHost() const; |
53 | int gpsPort() const; | 56 | int gpsPort() const; |
54 | 57 | ||
55 | void save(); | 58 | void save(); |
56 | void load(); | 59 | void load(); |
57 | 60 | ||
58 | public slots: | 61 | public slots: |
59 | void changedDeviceType(int); | 62 | void changedDeviceType(int); |
60 | void changedNetworkAction(int t); | 63 | void changedNetworkAction(int t); |
61 | void changedClientAction(int t); | 64 | void changedClientAction(int t); |
62 | void changedStationAction(int t); | 65 | void changedStationAction(int t); |
63 | void getCaptureFileNameClicked(); | 66 | void getCaptureFileNameClicked(); |
64 | void performAutodetection(); | 67 | void performAutodetection(); |
65 | void channelAllClicked(int); | 68 | void channelAllClicked(int); |
66 | void performAction( const QString& ); | 69 | void performAction( const QString&, const QString&, const QString&, bool, int, int /* , const GpsLocation& */ ); |
67 | 70 | ||
68 | protected: | 71 | protected: |
69 | void synchronizeActionsAndScripts(); | 72 | void synchronizeActionsAndScripts(); |
70 | 73 | ||
71 | protected: | 74 | protected: |
72 | QMap<QString, int> _devicetype; | 75 | QMap<QString, int> _devicetype; |
73 | static WellenreiterConfigWindow* _instance; | 76 | static WellenreiterConfigWindow* _instance; |
74 | int _guess; | 77 | int _guess; |
75 | 78 | ||
76 | }; | 79 | }; |
77 | 80 | ||
78 | #endif | 81 | #endif |
diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp index dd757b5..702a7cc 100644 --- a/noncore/net/wellenreiter/gui/main.cpp +++ b/noncore/net/wellenreiter/gui/main.cpp | |||
@@ -1,131 +1,131 @@ | |||
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 "mainwindow.h" | 16 | #include "mainwindow.h" |
17 | #ifdef QWS | 17 | #ifdef QWS |
18 | #include <opie2/oapplication.h> | 18 | #include <opie2/oapplication.h> |
19 | #else | 19 | #else |
20 | #include <qapplication.h> | 20 | #include <qapplication.h> |
21 | #endif | 21 | #endif |
22 | 22 | ||
23 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
24 | #include <qstringlist.h> | 24 | #include <qstringlist.h> |
25 | 25 | ||
26 | // ==> OProcess | 26 | // ==> OProcess |
27 | #include <qdir.h> | 27 | #include <qdir.h> |
28 | #include <qfileinfo.h> | 28 | #include <qfileinfo.h> |
29 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | 31 | ||
32 | #include <errno.h> | 32 | #include <errno.h> |
33 | #include <signal.h> | 33 | #include <signal.h> |
34 | #include <string.h> | 34 | #include <string.h> |
35 | #include <unistd.h> | 35 | #include <unistd.h> |
36 | 36 | ||
37 | int main( int argc, char **argv ) | 37 | int main( int argc, char **argv ) |
38 | { | 38 | { |
39 | #ifdef QWS | 39 | #ifdef QWS |
40 | OApplication a( argc, argv, "Wellenreiter II" ); | 40 | OApplication a( argc, argv, "Wellenreiter II" ); |
41 | #else | 41 | #else |
42 | QApplication a( argc, argv ); | 42 | QApplication a( argc, argv ); |
43 | #endif | 43 | #endif |
44 | WellenreiterMainWindow* w = new WellenreiterMainWindow(); | 44 | WellenreiterMainWindow* w = new WellenreiterMainWindow(); |
45 | #ifdef QWS | 45 | #ifdef QWS |
46 | a.showMainWidget( w ); | 46 | a.showMainWidget( w ); |
47 | #else | 47 | #else |
48 | a.setMainWidget( w ); | 48 | a.setMainWidget( w ); |
49 | w->setCaption( "Wellenreiter II" ); | 49 | w->setCaption( "Wellenreiter II" ); |
50 | w->show(); | 50 | w->show(); |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | a.processEvents(); // show the window before doing the safety checks | 53 | a.processEvents(); // show the window before doing the safety checks |
54 | int result = -1; | 54 | int result = -1; |
55 | static int killed = false; | 55 | static int killed = false; |
56 | 56 | ||
57 | bool check = true; | 57 | bool check = true; |
58 | for ( int i = 1; i < argc; ++i ) | 58 | for ( int i = 1; i < argc; ++i ) |
59 | { | 59 | { |
60 | if ( !strcmp( "-nocheck", argv[i] ) ) | 60 | if ( !strcmp( "-nocheck", argv[i] ) ) |
61 | { | 61 | { |
62 | qDebug( "-nocheck found" ); | 62 | qDebug( "-nocheck found" ); |
63 | check = false; | 63 | check = false; |
64 | break; | 64 | break; |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | if ( check ) | 68 | if ( check ) |
69 | { | 69 | { |
70 | // root check | 70 | // root check |
71 | if ( getuid() ) | 71 | if ( getuid() ) |
72 | { | 72 | { |
73 | qWarning( QObject::tr( "Wellenreiter: trying to run as non-root!" ) ); | 73 | qWarning( QObject::tr( "Wellenreiter: trying to run as non-root!" ) ); |
74 | result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", QObject::tr( "You have started Wellenreiter II\n" | 74 | result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", QObject::tr( "You have started Wellenreiter II\n" |
75 | "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ), | 75 | "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ), |
76 | QMessageBox::Yes, QMessageBox::No ); | 76 | QMessageBox::Yes, QMessageBox::No ); |
77 | if ( result == QMessageBox::No ) return -1; | 77 | if ( result == QMessageBox::No ) return -1; |
78 | } | 78 | } |
79 | 79 | ||
80 | // dhcp check - NOT HERE! This really belongs as a static member to OProcess | 80 | // dhcp check - NOT HERE! This really belongs as a static member to OProcess |
81 | // and I want to call it like that: if ( OProcess::isRunning( QString& ) ) ... | 81 | // and I want to call it like that: if ( OProcess::isRunning( QString& ) ) ... |
82 | 82 | ||
83 | QString line; | 83 | QString line; |
84 | QDir d = QDir( "/proc" ); | 84 | QDir d = QDir( "/proc" ); |
85 | QStringList dirs = d.entryList( QDir::Dirs ); | 85 | QStringList dirs = d.entryList( QDir::Dirs ); |
86 | QStringList::Iterator it; | 86 | QStringList::Iterator it; |
87 | for ( it = dirs.begin(); it != dirs.end(); ++it ) | 87 | for ( it = dirs.begin(); it != dirs.end(); ++it ) |
88 | { | 88 | { |
89 | //qDebug( "next entry: %s", (const char*) *it ); | 89 | //qDebug( "next entry: %s", (const char*) *it ); |
90 | QFile file( "/proc/"+*it+"/cmdline" ); | 90 | QFile file( "/proc/"+*it+"/cmdline" ); |
91 | file.open( IO_ReadOnly ); | 91 | file.open( IO_ReadOnly ); |
92 | if ( !file.isOpen() ) continue; | 92 | if ( !file.isOpen() ) continue; |
93 | QTextStream t( &file ); | 93 | QTextStream t( &file ); |
94 | line = t.readLine(); | 94 | line = t.readLine(); |
95 | //qDebug( "cmdline = %s", (const char*) line ); | 95 | //qDebug( "cmdline = %s", (const char*) line ); |
96 | if ( line.contains( "dhcp" ) ) break; | 96 | if ( line.contains( "dhcp" ) ) break; |
97 | } | 97 | } |
98 | if ( line.contains( "dhcp" ) ) | 98 | if ( line.contains( "dhcp" ) ) |
99 | { | 99 | { |
100 | qWarning( "Wellenreiter: found dhcp process #%d", (*it).toInt() ); | 100 | qWarning( "Wellenreiter: found dhcp process #%d", (*it).toInt() ); |
101 | result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n" | 101 | result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n" |
102 | "This can severly limit scanning!\nShould I kill it for you?" ), | 102 | "This can severly limit scanning!\nShould I kill it for you?" ), |
103 | QMessageBox::Yes, QMessageBox::No ); | 103 | QMessageBox::Yes, QMessageBox::No ); |
104 | if ( result == QMessageBox::Yes ) | 104 | if ( result == QMessageBox::Yes ) |
105 | { | 105 | { |
106 | if ( -1 == ::kill( (*it).toInt(), SIGTERM ) ) | 106 | if ( -1 == ::kill( (*it).toInt(), SIGTERM ) ) |
107 | qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) ); | 107 | qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) ); |
108 | else | 108 | else |
109 | killed = true; | 109 | killed = true; |
110 | } | 110 | } |
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | a.exec(); | 114 | a.exec(); |
115 | 115 | ||
116 | if ( check ) | 116 | if ( check ) |
117 | { | 117 | { |
118 | 118 | ||
119 | if ( killed ) | 119 | if ( killed ) |
120 | { | 120 | { |
121 | result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "Restart your dhcp client?" ), QMessageBox::Yes, QMessageBox::No ); | 121 | result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "Restart your dhcp client?" ), QMessageBox::Yes, QMessageBox::No ); |
122 | if ( result == QMessageBox::Yes ) | 122 | if ( result == QMessageBox::Yes ) |
123 | { | 123 | { |
124 | system( QString().sprintf( "dhclient &; udhcpcd &; dhcpcd &" ) ); | 124 | ::system( QString().sprintf( "dhclient &; udhcpcd &; dhcpcd &" ) ); |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | delete w; | 128 | delete w; |
129 | } | 129 | } |
130 | return 0; | 130 | return 0; |
131 | } | 131 | } |
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 470646d..aea7eb6 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -1,554 +1,554 @@ | |||
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 | { | 124 | { |
125 | QString macaddr = mac.toString(true); | 125 | QString macaddr = mac.toString(true); |
126 | 126 | ||
127 | #ifdef DEBUG | 127 | #ifdef DEBUG |
128 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, | 128 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, |
129 | (const char*) essid, (const char*) macaddr, channel ); | 129 | (const char*) essid, (const char*) macaddr, channel ); |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | // search, if we already have seen this net | 132 | // search, if we already have seen this net |
133 | 133 | ||
134 | QString s; | 134 | QString s; |
135 | MScanListItem* network; | 135 | MScanListItem* network; |
136 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); | 136 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); |
137 | 137 | ||
138 | while ( item && ( item->text( col_essid ) != essid ) ) | 138 | while ( item && ( item->text( col_essid ) != essid ) ) |
139 | { | 139 | { |
140 | #ifdef DEBUG | 140 | #ifdef DEBUG |
141 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); | 141 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); |
142 | #endif | 142 | #endif |
143 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 143 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
144 | } | 144 | } |
145 | if ( item ) | 145 | if ( item ) |
146 | { | 146 | { |
147 | // we have already seen this net, check all childs if MAC exists | 147 | // we have already seen this net, check all childs if MAC exists |
148 | 148 | ||
149 | network = item; | 149 | network = item; |
150 | 150 | ||
151 | item = static_cast<MScanListItem*> ( item->firstChild() ); | 151 | item = static_cast<MScanListItem*> ( item->firstChild() ); |
152 | assert( item ); // this shouldn't fail | 152 | assert( item ); // this shouldn't fail |
153 | 153 | ||
154 | while ( item && ( item->text( col_ap ) != macaddr ) ) | 154 | while ( item && ( item->text( col_ap ) != macaddr ) ) |
155 | { | 155 | { |
156 | #ifdef DEBUG | 156 | #ifdef DEBUG |
157 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); | 157 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); |
158 | #endif | 158 | #endif |
159 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 159 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
160 | } | 160 | } |
161 | 161 | ||
162 | if ( item ) | 162 | if ( item ) |
163 | { | 163 | { |
164 | // we have already seen this item, it's a dupe | 164 | // we have already seen this item, it's a dupe |
165 | #ifdef DEBUG | 165 | #ifdef DEBUG |
166 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | 166 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); |
167 | #endif | 167 | #endif |
168 | item->receivedBeacon(); | 168 | item->receivedBeacon(); |
169 | return; | 169 | return; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | else | 172 | else |
173 | { | 173 | { |
174 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); | 174 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); |
175 | MLogWindow::logwindow()->log( s ); | 175 | MLogWindow::logwindow()->log( s ); |
176 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); | 176 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); |
177 | } | 177 | } |
178 | 178 | ||
179 | 179 | ||
180 | // insert new station as child from network | 180 | // insert new station as child from network |
181 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 181 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
182 | 182 | ||
183 | #ifdef DEBUG | 183 | #ifdef DEBUG |
184 | qDebug( "inserting new station %s", (const char*) macaddr ); | 184 | qDebug( "inserting new station %s", (const char*) macaddr ); |
185 | #endif | 185 | #endif |
186 | 186 | ||
187 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 187 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
188 | station->setManufacturer( mac.manufacturer() ); | 188 | station->setManufacturer( mac.manufacturer() ); |
189 | station->setLocation( loc.dmsPosition() ); | 189 | station->setLocation( loc.dmsPosition() ); |
190 | 190 | ||
191 | if ( type == "managed" ) | 191 | if ( type == "managed" ) |
192 | { | 192 | { |
193 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); | 193 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); |
194 | } | 194 | } |
195 | else | 195 | else |
196 | { | 196 | { |
197 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); | 197 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); |
198 | } | 198 | } |
199 | MLogWindow::logwindow()->log( s ); | 199 | MLogWindow::logwindow()->log( s ); |
200 | 200 | ||
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 | QString s; | 245 | QString s; |
246 | MScanListItem* network; | 246 | MScanListItem* network; |
247 | 247 | ||
248 | QListViewItemIterator it( this ); | 248 | QListViewItemIterator it( this ); |
249 | while ( it.current() && | 249 | while ( it.current() && |
250 | it.current()->text( col_ap ) != viaFrom.toString(true) && | 250 | it.current()->text( col_ap ) != viaFrom.toString(true) && |
251 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; | 251 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; |
252 | 252 | ||
253 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 253 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
254 | 254 | ||
255 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations | 255 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations |
256 | { | 256 | { |
257 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); | 257 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); |
258 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); | 258 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); |
259 | } | 259 | } |
260 | else | 260 | else |
261 | { | 261 | { |
262 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); | 262 | 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!" ); | 263 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); |
264 | } | 264 | } |
265 | } | 265 | } |
266 | 266 | ||
267 | 267 | ||
268 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 268 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
269 | { | 269 | { |
270 | QString s; | 270 | QString s; |
271 | MScanListItem* network; | 271 | MScanListItem* network; |
272 | 272 | ||
273 | QListViewItemIterator it( this ); | 273 | QListViewItemIterator it( this ); |
274 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 274 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
275 | 275 | ||
276 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 276 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
277 | 277 | ||
278 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 278 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
279 | { | 279 | { |
280 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); | 280 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); |
281 | } | 281 | } |
282 | else | 282 | else |
283 | { | 283 | { |
284 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 284 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); |
285 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); | 285 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); |
286 | 286 | ||
287 | } | 287 | } |
288 | } | 288 | } |
289 | 289 | ||
290 | 290 | ||
291 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 291 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
292 | { | 292 | { |
293 | QString s; | 293 | QString s; |
294 | MScanListItem* network; | 294 | MScanListItem* network; |
295 | 295 | ||
296 | QListViewItemIterator it( this ); | 296 | QListViewItemIterator it( this ); |
297 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 297 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
298 | 298 | ||
299 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 299 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
300 | 300 | ||
301 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 301 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
302 | { | 302 | { |
303 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); | 303 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); |
304 | } | 304 | } |
305 | else | 305 | else |
306 | { | 306 | { |
307 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 307 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); |
308 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); | 308 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); |
309 | } | 309 | } |
310 | } | 310 | } |
311 | 311 | ||
312 | 312 | ||
313 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 313 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
314 | { | 314 | { |
315 | qWarning( "D'oh! Not yet implemented..." ); | 315 | qWarning( "D'oh! Not yet implemented..." ); |
316 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); | 316 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); |
317 | } | 317 | } |
318 | 318 | ||
319 | 319 | ||
320 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) | 320 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) |
321 | { | 321 | { |
322 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); | 322 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); |
323 | 323 | ||
324 | QListViewItemIterator it( this ); | 324 | QListViewItemIterator it( this ); |
325 | for ( ; it.current(); ++it ) | 325 | for ( ; it.current(); ++it ) |
326 | { | 326 | { |
327 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 327 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
328 | { | 328 | { |
329 | it.current()->setText( col_ip, ip ); | 329 | it.current()->setText( col_ip, ip ); |
330 | return; | 330 | return; |
331 | } | 331 | } |
332 | } | 332 | } |
333 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 333 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); |
334 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", | 334 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", |
335 | (const char*) macaddr.toString(), (const char*) ip ) ); | 335 | (const char*) macaddr.toString(), (const char*) ip ) ); |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
339 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) | 339 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) |
340 | { | 340 | { |
341 | qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip ); | 341 | qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip ); |
342 | 342 | ||
343 | //TODO: Refactor that out, we need it all over the place. | 343 | //TODO: Refactor that out, we need it all over the place. |
344 | // Best to do it in a more comfortable abstraction in OListView | 344 | // Best to do it in a more comfortable abstraction in OListView |
345 | // (Hmm, didn't I already start something in this direction?) | 345 | // (Hmm, didn't I already start something in this direction?) |
346 | 346 | ||
347 | QListViewItemIterator it( this ); | 347 | QListViewItemIterator it( this ); |
348 | for ( ; it.current(); ++it ) | 348 | for ( ; it.current(); ++it ) |
349 | { | 349 | { |
350 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 350 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
351 | { | 351 | { |
352 | 352 | ||
353 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); | 353 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); |
354 | 354 | ||
355 | while ( subitem && ( subitem->text( col_essid ) != name ) ) | 355 | while ( subitem && ( subitem->text( col_essid ) != name ) ) |
356 | { | 356 | { |
357 | #ifdef DEBUG | 357 | #ifdef DEBUG |
358 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); | 358 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); |
359 | #endif | 359 | #endif |
360 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 360 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
361 | } | 361 | } |
362 | 362 | ||
363 | if ( subitem ) | 363 | if ( subitem ) |
364 | { | 364 | { |
365 | // we have already seen this item, it's a dupe | 365 | // we have already seen this item, it's a dupe |
366 | #ifdef DEBUG | 366 | #ifdef DEBUG |
367 | qDebug( "%s is a dupe - ignoring...", (const char*) name ); | 367 | qDebug( "%s is a dupe - ignoring...", (const char*) name ); |
368 | #endif | 368 | #endif |
369 | subitem->receivedBeacon(); //FIXME: sent data bit | 369 | subitem->receivedBeacon(); //FIXME: sent data bit |
370 | return; | 370 | return; |
371 | } | 371 | } |
372 | 372 | ||
373 | // never seen that - add new item | 373 | // never seen that - add new item |
374 | 374 | ||
375 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); | 375 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); |
376 | item->setText( col_essid, name ); | 376 | item->setText( col_essid, name ); |
377 | 377 | ||
378 | return; | 378 | return; |
379 | } | 379 | } |
380 | } | 380 | } |
381 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 381 | 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!", | 382 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", |
383 | (const char*) macaddr.toString(), (const char*) ip ) ); | 383 | (const char*) macaddr.toString(), (const char*) ip ) ); |
384 | } | 384 | } |
385 | 385 | ||
386 | 386 | ||
387 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) | 387 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) |
388 | { | 388 | { |
389 | if ( !item ) return; | 389 | if ( !item ) return; |
390 | 390 | ||
391 | MScanListItem* itm = static_cast<MScanListItem*>( item ); | 391 | MScanListItem* itm = static_cast<MScanListItem*>( item ); |
392 | 392 | ||
393 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", | 393 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", |
394 | (const char*) itm->text(0), (const char*) itm->type, col ); | 394 | (const char*) itm->text(0), (const char*) itm->type, col ); |
395 | 395 | ||
396 | if ( itm->type == "adhoc" || itm->type == "managed" ) | 396 | if ( itm->type == "adhoc" || itm->type == "managed" ) |
397 | { | 397 | { |
398 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); | 398 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); |
399 | 399 | ||
400 | QPopupMenu m( this ); | 400 | QPopupMenu m( this ); |
401 | m.insertItem( entry, 37773, 0 ); | 401 | m.insertItem( entry, 37773, 0 ); |
402 | int result = m.exec( QCursor::pos() ); | 402 | int result = m.exec( QCursor::pos() ); |
403 | if ( result == 37773 ) | 403 | if ( result == 37773 ) |
404 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); | 404 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | 407 | ||
408 | //============================================================ | 408 | //============================================================ |
409 | // MScanListItem | 409 | // MScanListItem |
410 | //============================================================ | 410 | //============================================================ |
411 | 411 | ||
412 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, | 412 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, |
413 | bool wep, int channel, int signal ) | 413 | bool wep, int channel, int signal ) |
414 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 414 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
415 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 415 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
416 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 416 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
417 | { | 417 | { |
418 | #ifdef DEBUG | 418 | #ifdef DEBUG |
419 | qDebug( "creating scanlist item" ); | 419 | qDebug( "creating scanlist item" ); |
420 | #endif | 420 | #endif |
421 | 421 | ||
422 | if ( WellenreiterConfigWindow::instance() ) | 422 | if ( WellenreiterConfigWindow::instance() ) |
423 | WellenreiterConfigWindow::instance()->performAction( type ); // better use signal/slot combination here | 423 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
424 | 424 | ||
425 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 425 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
426 | } | 426 | } |
427 | 427 | ||
428 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, | 428 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, |
429 | bool wep, int channel, int signal ) | 429 | bool wep, int channel, int signal ) |
430 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 430 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
431 | { | 431 | { |
432 | #ifdef DEBUG | 432 | #ifdef DEBUG |
433 | qDebug( "creating scanlist item" ); | 433 | qDebug( "creating scanlist item" ); |
434 | #endif | 434 | #endif |
435 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 435 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
436 | } | 436 | } |
437 | 437 | ||
438 | const QString& MScanListItem::essid() const | 438 | const QString& MScanListItem::essid() const |
439 | { | 439 | { |
440 | if ( type == "network" ) | 440 | if ( type == "network" ) |
441 | return _essid; | 441 | return _essid; |
442 | else | 442 | else |
443 | return ( (MScanListItem*) parent() )->essid(); | 443 | return ( (MScanListItem*) parent() )->essid(); |
444 | } | 444 | } |
445 | 445 | ||
446 | OListViewItem* MScanListItem::childFactory() | 446 | OListViewItem* MScanListItem::childFactory() |
447 | { | 447 | { |
448 | return new MScanListItem( this ); | 448 | return new MScanListItem( this ); |
449 | } | 449 | } |
450 | 450 | ||
451 | void MScanListItem::serializeTo( QDataStream& s ) const | 451 | void MScanListItem::serializeTo( QDataStream& s ) const |
452 | { | 452 | { |
453 | #ifdef DEBUG | 453 | #ifdef DEBUG |
454 | qDebug( "serializing MScanListItem" ); | 454 | qDebug( "serializing MScanListItem" ); |
455 | #endif | 455 | #endif |
456 | OListViewItem::serializeTo( s ); | 456 | OListViewItem::serializeTo( s ); |
457 | 457 | ||
458 | s << _type; | 458 | s << _type; |
459 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); | 459 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); |
460 | } | 460 | } |
461 | 461 | ||
462 | void MScanListItem::serializeFrom( QDataStream& s ) | 462 | void MScanListItem::serializeFrom( QDataStream& s ) |
463 | { | 463 | { |
464 | #ifdef DEBUG | 464 | #ifdef DEBUG |
465 | qDebug( "serializing MScanListItem" ); | 465 | qDebug( "serializing MScanListItem" ); |
466 | #endif | 466 | #endif |
467 | OListViewItem::serializeFrom( s ); | 467 | OListViewItem::serializeFrom( s ); |
468 | 468 | ||
469 | char wep; | 469 | char wep; |
470 | s >> _type; | 470 | s >> _type; |
471 | s >> (Q_UINT8) wep; | 471 | s >> (Q_UINT8) wep; |
472 | _wep = (wep == 'y'); | 472 | _wep = (wep == 'y'); |
473 | 473 | ||
474 | QString name; | 474 | QString name; |
475 | name.sprintf( "wellenreiter/%s", (const char*) _type ); | 475 | name.sprintf( "wellenreiter/%s", (const char*) _type ); |
476 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 476 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
477 | if ( _wep ) | 477 | if ( _wep ) |
478 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 478 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
479 | listView()->triggerUpdate(); | 479 | listView()->triggerUpdate(); |
480 | } | 480 | } |
481 | 481 | ||
482 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 482 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) |
483 | { | 483 | { |
484 | #ifdef DEBUG | 484 | #ifdef DEBUG |
485 | qDebug( "decorating scanlist item %s / %s / %s [%d]", | 485 | qDebug( "decorating scanlist item %s / %s / %s [%d]", |
486 | (const char*) type, | 486 | (const char*) type, |
487 | (const char*) essid, | 487 | (const char*) essid, |
488 | (const char*) macaddr, | 488 | (const char*) macaddr, |
489 | channel ); | 489 | channel ); |
490 | #endif | 490 | #endif |
491 | 491 | ||
492 | // set icon for managed or adhoc mode | 492 | // set icon for managed or adhoc mode |
493 | QString name; | 493 | QString name; |
494 | name.sprintf( "wellenreiter/%s", (const char*) type ); | 494 | name.sprintf( "wellenreiter/%s", (const char*) type ); |
495 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 495 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
496 | 496 | ||
497 | // set icon for wep (wireless encryption protocol) | 497 | // set icon for wep (wireless encryption protocol) |
498 | if ( wep ) | 498 | if ( wep ) |
499 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 499 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
500 | 500 | ||
501 | // set channel and signal text | 501 | // set channel and signal text |
502 | 502 | ||
503 | if ( signal != -1 ) | 503 | if ( signal != -1 ) |
504 | setText( col_sig, QString::number( signal ) ); | 504 | setText( col_sig, QString::number( signal ) ); |
505 | if ( channel != -1 ) | 505 | if ( channel != -1 ) |
506 | setText( col_channel, QString::number( channel ) ); | 506 | setText( col_channel, QString::number( channel ) ); |
507 | 507 | ||
508 | setText( col_firstseen, QTime::currentTime().toString() ); | 508 | setText( col_firstseen, QTime::currentTime().toString() ); |
509 | //setText( col_lastseen, QTime::currentTime().toString() ); | 509 | //setText( col_lastseen, QTime::currentTime().toString() ); |
510 | 510 | ||
511 | listView()->triggerUpdate(); | 511 | listView()->triggerUpdate(); |
512 | 512 | ||
513 | this->type = type; | 513 | this->type = type; |
514 | _type = type; | 514 | _type = type; |
515 | _essid = essid; | 515 | _essid = essid; |
516 | _macaddr = macaddr; | 516 | _macaddr = macaddr; |
517 | _channel = channel; | 517 | _channel = channel; |
518 | _beacons = 1; | 518 | _beacons = 1; |
519 | _signal = 0; | 519 | _signal = 0; |
520 | 520 | ||
521 | if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) | 521 | if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) |
522 | { | 522 | { |
523 | listView()->ensureItemVisible( this ); | 523 | listView()->ensureItemVisible( this ); |
524 | } | 524 | } |
525 | 525 | ||
526 | } | 526 | } |
527 | 527 | ||
528 | 528 | ||
529 | void MScanListItem::setManufacturer( const QString& manufacturer ) | 529 | void MScanListItem::setManufacturer( const QString& manufacturer ) |
530 | { | 530 | { |
531 | setText( col_manuf, manufacturer ); | 531 | setText( col_manuf, manufacturer ); |
532 | } | 532 | } |
533 | 533 | ||
534 | 534 | ||
535 | void MScanListItem::setLocation( const QString& location ) | 535 | void MScanListItem::setLocation( const QString& location ) |
536 | { | 536 | { |
537 | setText( col_location, location ); | 537 | setText( col_location, location ); |
538 | } | 538 | } |
539 | 539 | ||
540 | 540 | ||
541 | void MScanListItem::receivedBeacon() | 541 | void MScanListItem::receivedBeacon() |
542 | { | 542 | { |
543 | _beacons++; | 543 | _beacons++; |
544 | #ifdef DEBUG | 544 | #ifdef DEBUG |
545 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); | 545 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); |
546 | #endif | 546 | #endif |
547 | setText( col_sig, QString::number( _beacons ) ); | 547 | setText( col_sig, QString::number( _beacons ) ); |
548 | setText( col_lastseen, QTime::currentTime().toString() ); | 548 | setText( col_lastseen, QTime::currentTime().toString() ); |
549 | 549 | ||
550 | MScanListItem* p = (MScanListItem*) parent(); | 550 | MScanListItem* p = (MScanListItem*) parent(); |
551 | if ( p ) p->receivedBeacon(); | 551 | if ( p ) p->receivedBeacon(); |
552 | 552 | ||
553 | } | 553 | } |
554 | 554 | ||
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index 42f35c2..e8d48c3 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h | |||
@@ -1,139 +1,139 @@ | |||
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 SCANLIST_H | 16 | #ifndef SCANLIST_H |
17 | #define SCANLIST_H | 17 | #define SCANLIST_H |
18 | 18 | ||
19 | #include "gps.h" | 19 | #include "gps.h" |
20 | 20 | ||
21 | /* OPIE */ | 21 | /* OPIE */ |
22 | #include <opie2/olistview.h> | 22 | #include <opie2/olistview.h> |
23 | #include <opie2/onetutils.h> | 23 | #include <opie2/onetutils.h> |
24 | 24 | ||
25 | /* QT */ | 25 | /* QT */ |
26 | #include <qtextstream.h> | 26 | #include <qtextstream.h> |
27 | 27 | ||
28 | class QString; | 28 | class QString; |
29 | class MScanListItem; | 29 | class MScanListItem; |
30 | 30 | ||
31 | class MScanListView: public OListView | 31 | class MScanListView: public OListView |
32 | { | 32 | { |
33 | Q_OBJECT | 33 | Q_OBJECT |
34 | 34 | ||
35 | public: | 35 | public: |
36 | MScanListView( QWidget* parent = 0, const char* name = 0 ); | 36 | MScanListView( QWidget* parent = 0, const char* name = 0 ); |
37 | virtual ~MScanListView(); | 37 | virtual ~MScanListView(); |
38 | 38 | ||
39 | virtual OListViewItem* childFactory(); | 39 | virtual OListViewItem* childFactory(); |
40 | virtual void serializeTo( QDataStream& s ) const; | 40 | virtual void serializeTo( QDataStream& s ) const; |
41 | virtual void serializeFrom( QDataStream& s ); | 41 | virtual void serializeFrom( QDataStream& s ); |
42 | 42 | ||
43 | public slots: | 43 | public slots: |
44 | void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal, const GpsLocation& location ); | 44 | void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal, const GpsLocation& location ); |
45 | void addService( const QString& name, const OMacAddress& macaddr, const QString& ip ); | 45 | void addService( const QString& name, const OMacAddress& macaddr, const QString& ip ); |
46 | 46 | ||
47 | void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); | 47 | void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); |
48 | void toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); | 48 | void toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); |
49 | void WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ); | 49 | void WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ); |
50 | void IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); | 50 | void IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); |
51 | 51 | ||
52 | void identify( const OMacAddress&, const QString& ipaddr ); | 52 | void identify( const OMacAddress&, const QString& ipaddr ); |
53 | 53 | ||
54 | void contextMenuRequested( QListViewItem* item, const QPoint&, int ); | 54 | void contextMenuRequested( QListViewItem* item, const QPoint&, int ); |
55 | 55 | ||
56 | signals: | 56 | signals: |
57 | void rightButtonClicked(QListViewItem*,const QPoint&,int); | 57 | void rightButtonClicked(QListViewItem*,const QPoint&,int); |
58 | void joinNetwork( const QString&, const QString&, int, const QString& ); | 58 | void joinNetwork( const QString&, const QString&, int, const QString& ); |
59 | 59 | ||
60 | protected: | 60 | protected: |
61 | void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" ); | 61 | void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" ); |
62 | 62 | ||
63 | }; | 63 | }; |
64 | 64 | ||
65 | //****************************** MScanListItem **************************************************************** | 65 | //****************************** MScanListItem **************************************************************** |
66 | 66 | ||
67 | class MScanListItem: public OListViewItem | 67 | class MScanListItem: public OListViewItem |
68 | { | 68 | { |
69 | public: | 69 | public: |
70 | MScanListItem::MScanListItem( QListView* parent, | 70 | MScanListItem::MScanListItem( QListView* parent, |
71 | QString type = "unknown", | 71 | const QString& type = "unknown", |
72 | QString essid = "unknown", | 72 | const QString& essid = "unknown", |
73 | QString macaddr = "unknown", | 73 | const QString& macaddr = "unknown", |
74 | bool wep = false, | 74 | bool wep = false, |
75 | int channel = 0, | 75 | int channel = 0, |
76 | int signal = 0 ); | 76 | int signal = 0 ); |
77 | 77 | ||
78 | MScanListItem::MScanListItem( QListViewItem* parent, | 78 | MScanListItem::MScanListItem( QListViewItem* parent, |
79 | QString type = "unknown", | 79 | const QString& type = "unknown", |
80 | QString essid = "unknown", | 80 | const QString& essid = "unknown", |
81 | QString macaddr = "unknown", | 81 | const QString& macaddr = "unknown", |
82 | bool wep = false, | 82 | bool wep = false, |
83 | int channel = 0, | 83 | int channel = 0, |
84 | int signal = 0 ); | 84 | int signal = 0 ); |
85 | 85 | ||
86 | 86 | ||
87 | protected: | 87 | protected: |
88 | virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); | 88 | virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); |
89 | 89 | ||
90 | public: | 90 | public: |
91 | QString type; | 91 | QString type; |
92 | 92 | ||
93 | public: | 93 | public: |
94 | //const QString& type() { return _type; }; | 94 | //const QString& type() { return _type; }; |
95 | const QString& essid() const; | 95 | const QString& essid() const; |
96 | const QString& macaddr() { return _macaddr; }; | 96 | const QString& macaddr() { return _macaddr; }; |
97 | bool wep() { return _wep; }; | 97 | bool wep() { return _wep; }; |
98 | int channel() { return _channel; }; | 98 | int channel() { return _channel; }; |
99 | int signal() { return _signal; }; | 99 | int signal() { return _signal; }; |
100 | int beacons() { return _beacons; }; | 100 | int beacons() { return _beacons; }; |
101 | 101 | ||
102 | void setSignal( int signal ) { /* TODO */ }; | 102 | void setSignal( int signal ) { /* TODO */ }; |
103 | void receivedBeacon(); | 103 | void receivedBeacon(); |
104 | 104 | ||
105 | void setManufacturer( const QString& manufacturer ); | 105 | void setManufacturer( const QString& manufacturer ); |
106 | void setLocation( const QString& location ); | 106 | void setLocation( const QString& location ); |
107 | 107 | ||
108 | virtual OListViewItem* childFactory(); | 108 | virtual OListViewItem* childFactory(); |
109 | virtual void serializeTo( QDataStream& s ) const; | 109 | virtual void serializeTo( QDataStream& s ) const; |
110 | virtual void serializeFrom( QDataStream& s ); | 110 | virtual void serializeFrom( QDataStream& s ); |
111 | 111 | ||
112 | private: | 112 | private: |
113 | QString _type; | 113 | QString _type; |
114 | QString _essid; | 114 | QString _essid; |
115 | QString _macaddr; | 115 | QString _macaddr; |
116 | bool _wep; | 116 | bool _wep; |
117 | int _channel; | 117 | int _channel; |
118 | int _signal; | 118 | int _signal; |
119 | int _beacons; | 119 | int _beacons; |
120 | 120 | ||
121 | }; | 121 | }; |
122 | 122 | ||
123 | //****************************** MScanListViewFactory **************************************************************** | 123 | //****************************** MScanListViewFactory **************************************************************** |
124 | 124 | ||
125 | /* | 125 | /* |
126 | 126 | ||
127 | class MScanListViewFactory : public OListViewFactory | 127 | class MScanListViewFactory : public OListViewFactory |
128 | { | 128 | { |
129 | public: | 129 | public: |
130 | virtual QListView* listViewFactory(); | 130 | virtual QListView* listViewFactory(); |
131 | virtual QListViewItem* listViewItemFactory( QListView* lv ); | 131 | virtual QListViewItem* listViewItemFactory( QListView* lv ); |
132 | virtual QListViewItem* listViewItemFactory( QListViewItem* lvi ); | 132 | virtual QListViewItem* listViewItemFactory( QListViewItem* lvi ); |
133 | virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text ); | 133 | virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text ); |
134 | virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text ); | 134 | virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text ); |
135 | } | 135 | } |
136 | */ | 136 | */ |
137 | 137 | ||
138 | #endif | 138 | #endif |
139 | 139 | ||