summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2002-12-18 00:00:51 (UTC)
committer mickeyl <mickeyl>2002-12-18 00:00:51 (UTC)
commit930884a92b064766ed436111778fc55f157c6e1c (patch) (unidiff)
treed3c4b56b4b50f7cf7ef52cc486b377f39aaab044
parent96a9654c2fccce382a4a9ad5d2d0b991b4191468 (diff)
downloadopie-930884a92b064766ed436111778fc55f157c6e1c.zip
opie-930884a92b064766ed436111778fc55f157c6e1c.tar.gz
opie-930884a92b064766ed436111778fc55f157c6e1c.tar.bz2
use system() to start daemon and hopper instead of Global::execute,
which makes nothing but trouble for non-gui processes.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 764ef34..0e95b28 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -160,166 +160,176 @@ bool Wellenreiter::hasMessage()
160 160
161void Wellenreiter::timerEvent( QTimerEvent* e ) 161void Wellenreiter::timerEvent( QTimerEvent* e )
162{ 162{
163 //qDebug( "checking for message..." ); 163 //qDebug( "checking for message..." );
164 if ( hasMessage() ) 164 if ( hasMessage() )
165 { 165 {
166 //qDebug( "got message from daemon" ); 166 //qDebug( "got message from daemon" );
167 handleMessage(); 167 handleMessage();
168 } 168 }
169 else 169 else
170 { 170 {
171 //qDebug( "no message..." ); 171 //qDebug( "no message..." );
172 } 172 }
173} 173}
174 174
175void Wellenreiter::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) 175void Wellenreiter::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
176{ 176{
177 // FIXME: this code belongs in customized QListView, not into this class 177 // FIXME: this code belongs in customized QListView, not into this class
178 // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) 178 // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...)
179 179
180 qDebug( "Wellenreiter::addNewItem( %s / %s / %s [%d]", 180 qDebug( "Wellenreiter::addNewItem( %s / %s / %s [%d]",
181 (const char*) type, 181 (const char*) type,
182 (const char*) essid, 182 (const char*) essid,
183 (const char*) macaddr, 183 (const char*) macaddr,
184 channel ); 184 channel );
185 185
186 // search, if we already have seen this net 186 // search, if we already have seen this net
187 187
188 QString s; 188 QString s;
189 MScanListItem* network; 189 MScanListItem* network;
190 MScanListItem* item = static_cast<MScanListItem*> ( netview->firstChild() ); 190 MScanListItem* item = static_cast<MScanListItem*> ( netview->firstChild() );
191 191
192 while ( item && ( item->text( 0 ) != essid ) ) 192 while ( item && ( item->text( 0 ) != essid ) )
193 { 193 {
194 qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); 194 qDebug( "itemtext: %s", (const char*) item->text( 0 ) );
195 item = static_cast<MScanListItem*> ( item->itemBelow() ); 195 item = static_cast<MScanListItem*> ( item->itemBelow() );
196 } 196 }
197 if ( item ) 197 if ( item )
198 { 198 {
199 // we have already seen this net, check all childs if MAC exists 199 // we have already seen this net, check all childs if MAC exists
200 200
201 network = item; 201 network = item;
202 202
203 item = static_cast<MScanListItem*> ( item->firstChild() ); 203 item = static_cast<MScanListItem*> ( item->firstChild() );
204 assert( item ); // this shouldn't fail 204 assert( item ); // this shouldn't fail
205 205
206 while ( item && ( item->text( 2 ) != macaddr ) ) 206 while ( item && ( item->text( 2 ) != macaddr ) )
207 { 207 {
208 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); 208 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) );
209 item = static_cast<MScanListItem*> ( item->itemBelow() ); 209 item = static_cast<MScanListItem*> ( item->itemBelow() );
210 } 210 }
211 211
212 if ( item ) 212 if ( item )
213 { 213 {
214 // we have already seen this item, it's a dupe 214 // we have already seen this item, it's a dupe
215 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); 215 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr );
216 return; 216 return;
217 } 217 }
218 } 218 }
219 else 219 else
220 { 220 {
221 s.sprintf( "(i) new network: '%s'", (const char*) essid ); 221 s.sprintf( "(i) new network: '%s'", (const char*) essid );
222 logwindow->log( s ); 222 logwindow->log( s );
223 223
224 network = new MScanListItem( netview, "networks", essid, QString::null, 0, 0, 0 ); 224 network = new MScanListItem( netview, "networks", essid, QString::null, 0, 0, 0 );
225 } 225 }
226 226
227 227
228 // insert new station as child from network 228 // insert new station as child from network
229 229
230 // no essid to reduce clutter, maybe later we have a nick or stationname to display!? 230 // no essid to reduce clutter, maybe later we have a nick or stationname to display!?
231 231
232 qDebug( "inserting new station %s", (const char*) macaddr ); 232 qDebug( "inserting new station %s", (const char*) macaddr );
233 233
234 new MScanListItem( network, type, "", macaddr, wep, channel, signal ); 234 new MScanListItem( network, type, "", macaddr, wep, channel, signal );
235 235
236 if ( type == "managed" ) 236 if ( type == "managed" )
237 { 237 {
238 s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); 238 s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel );
239 } 239 }
240 else 240 else
241 { 241 {
242 s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); 242 s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel );
243 } 243 }
244 244
245 logwindow->log( s ); 245 logwindow->log( s );
246 246
247} 247}
248 248
249void Wellenreiter::buttonClicked() 249void Wellenreiter::buttonClicked()
250{ 250{
251 if ( daemonRunning ) 251 if ( daemonRunning )
252 { 252 {
253 logwindow->log( "(i) Daemon has been stopped." ); 253 logwindow->log( "(i) Daemon has been stopped." );
254 button->setText( "Start Scanning" ); 254 button->setText( "Start Scanning" );
255 255
256 // Stop daemon 256 // Stop daemon - ugly for now... later better
257 257
258 // find out pids of wellenreiterd and orinoco_hopper 258 system( "killall orinoco_hopper" );
259 system( "killall wellenreiterd" );
259 260
261 // FIXME: reset the card trying to get into a usable state again
262
263 // for now, just message the user
264
265 QMessageBox::information( this, "Wellenreiter/Opie", "You should reset your\ndevice before using it again." );
260 } 266 }
261 267
262 else 268 else
263 { 269 {
264 270
271 logwindow->log( "(i) Daemon has been started." );
272 daemonRunning = true;
273 button->setText( "Stop Scanning" );
274
265 // get configuration from config window 275 // get configuration from config window
266 276
267 const QString& interface = configwindow->interfaceName->currentText(); 277 const QString& interface = configwindow->interfaceName->currentText();
268 const QString& cardtype = configwindow->deviceType->currentText(); 278 const QString& cardtype = configwindow->deviceType->currentText();
269 const QString& interval = configwindow->hopInterval->cleanText(); 279 const QString& interval = configwindow->hopInterval->cleanText();
270 280
271 if ( ( interface == "<select>" ) || ( cardtype == "<select>" ) ) 281 if ( ( interface == "<select>" ) || ( cardtype == "<select>" ) )
272 { 282 {
273 QMessageBox::information( this, "Wellenreiter/Opie", "You must configure your\ndevice before scanning." ); 283 QMessageBox::information( this, "Wellenreiter/Opie", "You must configure your\ndevice before scanning." );
274 return; 284 return;
275 } 285 }
276 286
277 logwindow->log( "(i) Daemon has been started." );
278 button->setText( "Stop Scanning" );
279
280#ifdef QWS
281
282 // set interface into monitor mode 287 // set interface into monitor mode
288 /* Global::Execute definitely does not work very well with non-gui stuff! :( */
283 289
284 QString cmdline; 290 QString cmdline;
285 291
286 cmdline.sprintf( "iwpriv %s monitor 2", (const char*) interface ); 292 cmdline.sprintf( "iwpriv %s monitor 2", (const char*) interface );
287 system( cmdline ); 293 system( cmdline );
288 cmdline.sprintf( "iwpriv %s monitor 2 1", (const char*) interface ); 294 cmdline.sprintf( "iwpriv %s monitor 2 1", (const char*) interface );
289 system( cmdline ); 295 system( cmdline );
290 296
291 // start channel hopper 297 // start channel hopper
292 298
293 cmdline = "orinoco_hopper "; 299 cmdline = "orinoco_hopper ";
294 cmdline += interface; 300 cmdline += interface;
295 cmdline += " -i "; 301 cmdline += " -i ";
296 cmdline += interval; 302 cmdline += interval;
297 //qDebug( "execute: %s", (const char*) cmdline ); 303 cmdline += " &";
298 Global::execute( cmdline ); 304 qDebug( "execute: %s", (const char*) cmdline );
305 system( cmdline );
306 qDebug( "done" );
299 307
300 // start daemon 308 // start daemon
301 309
302 cmdline = "wellenreiterd "; 310 cmdline = "wellenreiterd ";
303 cmdline += interface; 311 cmdline += interface;
304 cmdline += " 3"; 312 cmdline += " 3";
305 //qDebug( "execute: %s", (const char*) cmdline ); 313 cmdline += " &";
306 Global::execute( cmdline );
307#endif
308 314
309 /* 315 qDebug( "execute: %s", (const char*) cmdline );
316 system( cmdline );
317 qDebug( "done" );
310 318
319 /*
320
311 // add some test stations, so that we can see if the GUI part works 321 // add some test stations, so that we can see if the GUI part works
312 322
313 addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 ); 323 addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 );
314 addNewItem( "managed", "Vanille", "04:00:20:EF:A6:23", true, 11, 10 ); 324 addNewItem( "managed", "Vanille", "04:00:20:EF:A6:23", true, 11, 10 );
315 addNewItem( "adhoc", "ELAN", "40:03:43:E7:16:22", false, 3, 10 ); 325 addNewItem( "adhoc", "ELAN", "40:03:43:E7:16:22", false, 3, 10 );
316 addNewItem( "adhoc", "ELAN", "40:03:53:E7:56:62", false, 3, 15 ); 326 addNewItem( "adhoc", "ELAN", "40:03:53:E7:56:62", false, 3, 15 );
317 addNewItem( "adhoc", "ELAN", "40:03:63:E7:56:E2", false, 3, 20 ); 327 addNewItem( "adhoc", "ELAN", "40:03:63:E7:56:E2", false, 3, 20 );
318 328
319 QString command ("98"); 329 QString command ("98");
320 330
321 //sendcomm( DAEMONADDR, DAEMONPORT, (const char*) command ); 331 //sendcomm( DAEMONADDR, DAEMONPORT, (const char*) command );
322 332
323 */ 333 */
324 } 334 }
325} 335}