author | ar <ar> | 2004-05-15 22:36:18 (UTC) |
---|---|---|
committer | ar <ar> | 2004-05-15 22:36:18 (UTC) |
commit | 736a153edfac343d0794ecafc5dc2f2c405260a7 (patch) (unidiff) | |
tree | ebb41331403fa78769df2a344bfe12bbd1df6c46 | |
parent | d4a82558ff3ae6ed7bbc5dbc9857461057eb3da3 (diff) | |
download | opie-736a153edfac343d0794ecafc5dc2f2c405260a7.zip opie-736a153edfac343d0794ecafc5dc2f2c405260a7.tar.gz opie-736a153edfac343d0794ecafc5dc2f2c405260a7.tar.bz2 |
- convert qDebug to odebug
-rw-r--r-- | noncore/settings/appearance2/appearance.cpp | 4 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/modem.cpp | 52 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanimp2.cpp | 29 |
3 files changed, 43 insertions, 42 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp index f918767..9638686 100644 --- a/noncore/settings/appearance2/appearance.cpp +++ b/noncore/settings/appearance2/appearance.cpp | |||
@@ -30,24 +30,25 @@ | |||
30 | #include "appearance.h" | 30 | #include "appearance.h" |
31 | #include "editScheme.h" | 31 | #include "editScheme.h" |
32 | #include "stylelistitem.h" | 32 | #include "stylelistitem.h" |
33 | #include "decolistitem.h" | 33 | #include "decolistitem.h" |
34 | #include "colorlistitem.h" | 34 | #include "colorlistitem.h" |
35 | #include "exceptlistitem.h" | 35 | #include "exceptlistitem.h" |
36 | #include "sample.h" | 36 | #include "sample.h" |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <opie2/odevice.h> | 39 | #include <opie2/odevice.h> |
40 | #include <opie2/ofiledialog.h> | 40 | #include <opie2/ofiledialog.h> |
41 | #include <opie2/otabwidget.h> | 41 | #include <opie2/otabwidget.h> |
42 | #include <opie2/odebug.h> | ||
42 | 43 | ||
43 | #include <qpe/config.h> | 44 | #include <qpe/config.h> |
44 | #include <qpe/global.h> | 45 | #include <qpe/global.h> |
45 | #include <qpe/qpeapplication.h> | 46 | #include <qpe/qpeapplication.h> |
46 | #include <qpe/qpemessagebox.h> | 47 | #include <qpe/qpemessagebox.h> |
47 | #include <qpe/qcopenvelope_qws.h> | 48 | #include <qpe/qcopenvelope_qws.h> |
48 | #include <qpe/qpestyle.h> | 49 | #include <qpe/qpestyle.h> |
49 | #include <qpe/lightstyle.h> | 50 | #include <qpe/lightstyle.h> |
50 | #include <qpe/styleinterface.h> | 51 | #include <qpe/styleinterface.h> |
51 | 52 | ||
52 | /* QT */ | 53 | /* QT */ |
53 | #include <qbuttongroup.h> | 54 | #include <qbuttongroup.h> |
@@ -823,25 +824,26 @@ public: | |||
823 | setFrame ( false ); | 824 | setFrame ( false ); |
824 | 825 | ||
825 | QRect r = it-> listView ( )-> itemRect ( it ); | 826 | QRect r = it-> listView ( )-> itemRect ( it ); |
826 | 827 | ||
827 | int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1; | 828 | int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1; |
828 | int y = r. y ( ); | 829 | int y = r. y ( ); |
829 | int w = it-> listView ( )-> viewport ( )-> width ( ) - x; | 830 | int w = it-> listView ( )-> viewport ( )-> width ( ) - x; |
830 | int h = r. height ( ); // + 2; | 831 | int h = r. height ( ); // + 2; |
831 | 832 | ||
832 | setText ( it-> pattern ( )); | 833 | setText ( it-> pattern ( )); |
833 | setGeometry ( x, y, w, h ); | 834 | setGeometry ( x, y, w, h ); |
834 | 835 | ||
835 | qDebug ( "ExEdit: [%s] at %d,%d %d,%d", it->text(2).latin1(),x,y,w,h); | 836 | odebug << "ExEdit: [" << it->text(2).latin1() << "] at " |
837 | << x << "," << y << " " << w << "," << h << oendl; | ||
836 | 838 | ||
837 | m_out = true; | 839 | m_out = true; |
838 | 840 | ||
839 | show ( ); | 841 | show ( ); |
840 | setFocus ( ); | 842 | setFocus ( ); |
841 | selectAll ( ); | 843 | selectAll ( ); |
842 | end ( true ); | 844 | end ( true ); |
843 | } | 845 | } |
844 | 846 | ||
845 | virtual void focusOutEvent ( QFocusEvent * ) | 847 | virtual void focusOutEvent ( QFocusEvent * ) |
846 | { | 848 | { |
847 | hide ( ); | 849 | hide ( ); |
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp index 5913a22..3bc7d43 100644 --- a/noncore/settings/networksettings/ppp/modem.cpp +++ b/noncore/settings/networksettings/ppp/modem.cpp | |||
@@ -161,25 +161,25 @@ speed_t Modem::modemspeed() { | |||
161 | return B38400; | 161 | return B38400; |
162 | break; | 162 | break; |
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | bool Modem::opentty() { | 166 | bool Modem::opentty() { |
167 | // int flags; | 167 | // int flags; |
168 | 168 | ||
169 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 169 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
170 | close(modemfd); | 170 | close(modemfd); |
171 | device = _pppdata->modemDevice(); | 171 | device = _pppdata->modemDevice(); |
172 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { | 172 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { |
173 | odebug << "error opening modem device !" << oendl; | 173 | odebug << "error opening modem device !" << oendl; |
174 | errmsg = QObject::tr("Unable to open modem."); | 174 | errmsg = QObject::tr("Unable to open modem."); |
175 | return false; | 175 | return false; |
176 | } | 176 | } |
177 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 177 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
178 | //} | 178 | //} |
179 | 179 | ||
180 | #if 0 | 180 | #if 0 |
181 | if(_pppdata->UseCDLine()) { | 181 | if(_pppdata->UseCDLine()) { |
182 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { | 182 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { |
183 | errmsg = QObject::tr("Unable to detect state of CD line."); | 183 | errmsg = QObject::tr("Unable to detect state of CD line."); |
184 | ::close(modemfd); | 184 | ::close(modemfd); |
185 | modemfd = -1; | 185 | modemfd = -1; |
@@ -302,56 +302,56 @@ void Modem::notify(const QObject *receiver, const char *member) { | |||
302 | 302 | ||
303 | void Modem::stop() { | 303 | void Modem::stop() { |
304 | disconnect(SIGNAL(charWaiting(unsigned char))); | 304 | disconnect(SIGNAL(charWaiting(unsigned char))); |
305 | stopNotifier(); | 305 | stopNotifier(); |
306 | } | 306 | } |
307 | 307 | ||
308 | 308 | ||
309 | void Modem::startNotifier() { | 309 | void Modem::startNotifier() { |
310 | if(modemfd >= 0) { | 310 | if(modemfd >= 0) { |
311 | if(sn == 0) { | 311 | if(sn == 0) { |
312 | sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); | 312 | sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); |
313 | connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); | 313 | connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); |
314 | odebug << "QSocketNotifier started!" << oendl; | 314 | odebug << "QSocketNotifier started!" << oendl; |
315 | } else { | 315 | } else { |
316 | odebug << "QSocketNotifier re-enabled!" << oendl; | 316 | odebug << "QSocketNotifier re-enabled!" << oendl; |
317 | sn->setEnabled(true); | 317 | sn->setEnabled(true); |
318 | } | 318 | } |
319 | } | 319 | } |
320 | } | 320 | } |
321 | 321 | ||
322 | 322 | ||
323 | void Modem::stopNotifier() { | 323 | void Modem::stopNotifier() { |
324 | if(sn != 0) { | 324 | if(sn != 0) { |
325 | sn->setEnabled(false); | 325 | sn->setEnabled(false); |
326 | disconnect(sn); | 326 | disconnect(sn); |
327 | delete sn; | 327 | delete sn; |
328 | sn = 0; | 328 | sn = 0; |
329 | odebug << "QSocketNotifier stopped!" << oendl; | 329 | odebug << "QSocketNotifier stopped!" << oendl; |
330 | } | 330 | } |
331 | } | 331 | } |
332 | 332 | ||
333 | 333 | ||
334 | void Modem::flush() { | 334 | void Modem::flush() { |
335 | char c; | 335 | char c; |
336 | while(read(modemfd, &c, 1) == 1); | 336 | while(read(modemfd, &c, 1) == 1); |
337 | } | 337 | } |
338 | 338 | ||
339 | 339 | ||
340 | bool Modem::writeChar(unsigned char c) { | 340 | bool Modem::writeChar(unsigned char c) { |
341 | int s; | 341 | int s; |
342 | do { | 342 | do { |
343 | s = write(modemfd, &c, 1); | 343 | s = write(modemfd, &c, 1); |
344 | if (s < 0) { | 344 | if (s < 0) { |
345 | oerr << "write() in Modem::writeChar failed" << oendl; | 345 | oerr << "write() in Modem::writeChar failed" << oendl; |
346 | return false; | 346 | return false; |
347 | } | 347 | } |
348 | } while(s == 0); | 348 | } while(s == 0); |
349 | 349 | ||
350 | return true; | 350 | return true; |
351 | } | 351 | } |
352 | 352 | ||
353 | 353 | ||
354 | bool Modem::writeLine(const char *buf) { | 354 | bool Modem::writeLine(const char *buf) { |
355 | int len = strlen(buf); | 355 | int len = strlen(buf); |
356 | char *b = new char[len+2]; | 356 | char *b = new char[len+2]; |
357 | memcpy(b, buf, len); | 357 | memcpy(b, buf, len); |
@@ -361,25 +361,25 @@ bool Modem::writeLine(const char *buf) { | |||
361 | b[len++]='\n'; | 361 | b[len++]='\n'; |
362 | else if(term == "CR") | 362 | else if(term == "CR") |
363 | b[len++]='\r'; | 363 | b[len++]='\r'; |
364 | else if(term == "CR/LF") { | 364 | else if(term == "CR/LF") { |
365 | b[len++]='\r'; | 365 | b[len++]='\r'; |
366 | b[len++]='\n'; | 366 | b[len++]='\n'; |
367 | } | 367 | } |
368 | int l = len; | 368 | int l = len; |
369 | while(l) { | 369 | while(l) { |
370 | int wr = write(modemfd, &b[len-l], l); | 370 | int wr = write(modemfd, &b[len-l], l); |
371 | if(wr < 0) { | 371 | if(wr < 0) { |
372 | // TODO do something meaningful with the error code (or ignore it | 372 | // TODO do something meaningful with the error code (or ignore it |
373 | oerr << "write() in Modem::writeLine failed" << oendl; | 373 | oerr << "write() in Modem::writeLine failed" << oendl; |
374 | delete[] b; | 374 | delete[] b; |
375 | return false; | 375 | return false; |
376 | } | 376 | } |
377 | l -= wr; | 377 | l -= wr; |
378 | } | 378 | } |
379 | delete[] b; | 379 | delete[] b; |
380 | return true; | 380 | return true; |
381 | } | 381 | } |
382 | 382 | ||
383 | 383 | ||
384 | bool Modem::hangup() { | 384 | bool Modem::hangup() { |
385 | // this should really get the modem to hang up and go into command mode | 385 | // this should really get the modem to hang up and go into command mode |
@@ -470,25 +470,25 @@ void Modem::escape_to_command_mode() { | |||
470 | const QString Modem::modemMessage() { | 470 | const QString Modem::modemMessage() { |
471 | return errmsg; | 471 | return errmsg; |
472 | } | 472 | } |
473 | 473 | ||
474 | 474 | ||
475 | QString Modem::parseModemSpeed(const QString &s) { | 475 | QString Modem::parseModemSpeed(const QString &s) { |
476 | // this is a small (and bad) parser for modem speeds | 476 | // this is a small (and bad) parser for modem speeds |
477 | int rx = -1; | 477 | int rx = -1; |
478 | int tx = -1; | 478 | int tx = -1; |
479 | int i; | 479 | int i; |
480 | QString result; | 480 | QString result; |
481 | 481 | ||
482 | odebug << "Modem reported result string: " << s.latin1() << "" << oendl; | 482 | odebug << "Modem reported result string: " << s.latin1() << "" << oendl; |
483 | 483 | ||
484 | const int RXMAX = 7; | 484 | const int RXMAX = 7; |
485 | const int TXMAX = 2; | 485 | const int TXMAX = 2; |
486 | QRegExp rrx[RXMAX] = { | 486 | QRegExp rrx[RXMAX] = { |
487 | QRegExp("[0-9]+[:/ ]RX", false), | 487 | QRegExp("[0-9]+[:/ ]RX", false), |
488 | QRegExp("[0-9]+RX", false), | 488 | QRegExp("[0-9]+RX", false), |
489 | QRegExp("[/: -][0-9]+[/: ]", false), | 489 | QRegExp("[/: -][0-9]+[/: ]", false), |
490 | QRegExp("[/: -][0-9]+$", false), | 490 | QRegExp("[/: -][0-9]+$", false), |
491 | QRegExp("CARRIER [^0-9]*[0-9]+", false), | 491 | QRegExp("CARRIER [^0-9]*[0-9]+", false), |
492 | QRegExp("CONNECT [^0-9]*[0-9]+", false), | 492 | QRegExp("CONNECT [^0-9]*[0-9]+", false), |
493 | QRegExp("[0-9]+") // panic mode | 493 | QRegExp("[0-9]+") // panic mode |
494 | }; | 494 | }; |
@@ -556,131 +556,131 @@ QString Modem::parseModemSpeed(const QString &s) { | |||
556 | } | 556 | } |
557 | } | 557 | } |
558 | 558 | ||
559 | if(rx == -1 && tx == -1) | 559 | if(rx == -1 && tx == -1) |
560 | result = QObject::tr("Unknown speed"); | 560 | result = QObject::tr("Unknown speed"); |
561 | else if(tx == -1) | 561 | else if(tx == -1) |
562 | result.setNum(rx); | 562 | result.setNum(rx); |
563 | else if(rx == -1) // should not happen | 563 | else if(rx == -1) // should not happen |
564 | result.setNum(tx); | 564 | result.setNum(tx); |
565 | else | 565 | else |
566 | result.sprintf("%d/%d", rx, tx); | 566 | result.sprintf("%d/%d", rx, tx); |
567 | 567 | ||
568 | odebug << "The parsed result is: " << result.latin1() << "" << oendl; | 568 | odebug << "The parsed result is: " << result.latin1() << "" << oendl; |
569 | 569 | ||
570 | return result; | 570 | return result; |
571 | } | 571 | } |
572 | 572 | ||
573 | 573 | ||
574 | // Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if | 574 | // Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if |
575 | // a lock file can't be created ( permission problem ) | 575 | // a lock file can't be created ( permission problem ) |
576 | int Modem::lockdevice() { | 576 | int Modem::lockdevice() { |
577 | int fd; | 577 | int fd; |
578 | char newlock[80]=""; // safe | 578 | char newlock[80]=""; // safe |
579 | 579 | ||
580 | if(!_pppdata->modemLockFile()) { | 580 | if(!_pppdata->modemLockFile()) { |
581 | odebug << "The user doesn't want a lockfile." << oendl; | 581 | odebug << "The user doesn't want a lockfile." << oendl; |
582 | return 0; | 582 | return 0; |
583 | } | 583 | } |
584 | 584 | ||
585 | if (modem_is_locked) | 585 | if (modem_is_locked) |
586 | return 1; | 586 | return 1; |
587 | 587 | ||
588 | QString lockfile = LOCK_DIR"/LCK.."; | 588 | QString lockfile = LOCK_DIR"/LCK.."; |
589 | lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/ | 589 | lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/ |
590 | 590 | ||
591 | if(access(QFile::encodeName(lockfile), F_OK) == 0) { | 591 | if(access(QFile::encodeName(lockfile), F_OK) == 0) { |
592 | // if ((fd = Requester::rq-> | 592 | // if ((fd = Requester::rq-> |
593 | if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { | 593 | if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { |
594 | // Mario: it's not necessary to read more than lets say 32 bytes. If | 594 | // Mario: it's not necessary to read more than lets say 32 bytes. If |
595 | // file has more than 32 bytes, skip the rest | 595 | // file has more than 32 bytes, skip the rest |
596 | char oldlock[33]; // safe | 596 | char oldlock[33]; // safe |
597 | int sz = read(fd, &oldlock, 32); | 597 | int sz = read(fd, &oldlock, 32); |
598 | close (fd); | 598 | close (fd); |
599 | if (sz <= 0) | 599 | if (sz <= 0) |
600 | return 1; | 600 | return 1; |
601 | oldlock[sz] = '\0'; | 601 | oldlock[sz] = '\0'; |
602 | 602 | ||
603 | odebug << "Device is locked by: " << oldlock << "" << oendl; | 603 | odebug << "Device is locked by: " << oldlock << "" << oendl; |
604 | 604 | ||
605 | int oldpid; | 605 | int oldpid; |
606 | int match = sscanf(oldlock, "%d", &oldpid); | 606 | int match = sscanf(oldlock, "%d", &oldpid); |
607 | 607 | ||
608 | // found a pid in lockfile ? | 608 | // found a pid in lockfile ? |
609 | if (match < 1 || oldpid <= 0) | 609 | if (match < 1 || oldpid <= 0) |
610 | return 1; | 610 | return 1; |
611 | 611 | ||
612 | // check if process exists | 612 | // check if process exists |
613 | if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) | 613 | if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) |
614 | return 1; | 614 | return 1; |
615 | 615 | ||
616 | odebug << "lockfile is stale" << oendl; | 616 | odebug << "lockfile is stale" << oendl; |
617 | } | 617 | } |
618 | } | 618 | } |
619 | 619 | ||
620 | fd = openLockfile(_pppdata->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); | 620 | fd = openLockfile(_pppdata->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); |
621 | if(fd >= 0) { | 621 | if(fd >= 0) { |
622 | sprintf(newlock,"%010d\n", getpid()); | 622 | sprintf(newlock,"%010d\n", getpid()); |
623 | odebug << "Locking Device: " << newlock << "" << oendl; | 623 | odebug << "Locking Device: " << newlock << "" << oendl; |
624 | 624 | ||
625 | write(fd, newlock, strlen(newlock)); | 625 | write(fd, newlock, strlen(newlock)); |
626 | close(fd); | 626 | close(fd); |
627 | modem_is_locked=true; | 627 | modem_is_locked=true; |
628 | 628 | ||
629 | return 0; | 629 | return 0; |
630 | } | 630 | } |
631 | 631 | ||
632 | return -1; | 632 | return -1; |
633 | 633 | ||
634 | } | 634 | } |
635 | 635 | ||
636 | 636 | ||
637 | // UnLock modem device | 637 | // UnLock modem device |
638 | void Modem::unlockdevice() { | 638 | void Modem::unlockdevice() { |
639 | if (modem_is_locked) { | 639 | if (modem_is_locked) { |
640 | odebug << "UnLocking Modem Device" << oendl; | 640 | odebug << "UnLocking Modem Device" << oendl; |
641 | close(modemfd); | 641 | close(modemfd); |
642 | modemfd = -1; | 642 | modemfd = -1; |
643 | unlink(lockfile); | 643 | unlink(lockfile); |
644 | lockfile[0] = '\0'; | 644 | lockfile[0] = '\0'; |
645 | modem_is_locked=false; | 645 | modem_is_locked=false; |
646 | } | 646 | } |
647 | } | 647 | } |
648 | 648 | ||
649 | int Modem::openLockfile( QString lockfile, int flags) | 649 | int Modem::openLockfile( QString lockfile, int flags) |
650 | { | 650 | { |
651 | int fd; | 651 | int fd; |
652 | int mode; | 652 | int mode; |
653 | flags = O_RDONLY; | 653 | flags = O_RDONLY; |
654 | if(flags == O_WRONLY|O_TRUNC|O_CREAT) | 654 | if(flags == O_WRONLY|O_TRUNC|O_CREAT) |
655 | mode = 0644; | 655 | mode = 0644; |
656 | else | 656 | else |
657 | mode = 0; | 657 | mode = 0; |
658 | 658 | ||
659 | lockfile = LOCK_DIR; | 659 | lockfile = LOCK_DIR; |
660 | lockfile += "/LCK.."; | 660 | lockfile += "/LCK.."; |
661 | lockfile += device.right( device.length() - device.findRev("/") -1 ); | 661 | lockfile += device.right( device.length() - device.findRev("/") -1 ); |
662 | odebug << "lockfile >" << lockfile.latin1() << "<" << oendl; | 662 | odebug << "lockfile >" << lockfile.latin1() << "<" << oendl; |
663 | // TODO: | 663 | // TODO: |
664 | // struct stat st; | 664 | // struct stat st; |
665 | // if(stat(lockfile.data(), &st) == -1) { | 665 | // if(stat(lockfile.data(), &st) == -1) { |
666 | // if(errno == EBADF) | 666 | // if(errno == EBADF) |
667 | // return -1; | 667 | // return -1; |
668 | // } else { | 668 | // } else { |
669 | // // make sure that this is a regular file | 669 | // // make sure that this is a regular file |
670 | // if(!S_ISREG(st.st_mode)) | 670 | // if(!S_ISREG(st.st_mode)) |
671 | // return -1; | 671 | // return -1; |
672 | // } | 672 | // } |
673 | if ((fd = open(lockfile, flags, mode)) == -1) { | 673 | if ((fd = open(lockfile, flags, mode)) == -1) { |
674 | odebug << "error opening lockfile!" << oendl; | 674 | odebug << "error opening lockfile!" << oendl; |
675 | lockfile = QString::null; | 675 | lockfile = QString::null; |
676 | fd = open(DEVNULL, O_RDONLY); | 676 | fd = open(DEVNULL, O_RDONLY); |
677 | } else | 677 | } else |
678 | fchown(fd, 0, 0); | 678 | fchown(fd, 0, 0); |
679 | return fd; | 679 | return fd; |
680 | } | 680 | } |
681 | 681 | ||
682 | 682 | ||
683 | 683 | ||
684 | void alarm_handler(int) { | 684 | void alarm_handler(int) { |
685 | // fprintf(stderr, "alarm_handler(): Received SIGALRM\n"); | 685 | // fprintf(stderr, "alarm_handler(): Received SIGALRM\n"); |
686 | 686 | ||
@@ -923,60 +923,60 @@ bool Modem::execpppd(const char *arguments) { | |||
923 | fprintf(stderr, "Kernel does not support ppp, oops.\n"); | 923 | fprintf(stderr, "Kernel does not support ppp, oops.\n"); |
924 | break; | 924 | break; |
925 | case 0: | 925 | case 0: |
926 | fprintf(stderr, "Kernel supports ppp alright.\n"); | 926 | fprintf(stderr, "Kernel supports ppp alright.\n"); |
927 | break; | 927 | break; |
928 | } | 928 | } |
929 | 929 | ||
930 | execve(pppdPath(), args, 0L); | 930 | execve(pppdPath(), args, 0L); |
931 | _exit(0); | 931 | _exit(0); |
932 | break; | 932 | break; |
933 | 933 | ||
934 | default: | 934 | default: |
935 | odebug << "In parent: pppd pid " << pppdPid << "\n" << oendl; | 935 | odebug << "In parent: pppd pid " << pppdPid << "\n" << oendl; |
936 | close(modemfd); | 936 | close(modemfd); |
937 | 937 | ||
938 | ::close( m_pppdLOG[1] ); | 938 | ::close( m_pppdLOG[1] ); |
939 | // set it to nonblocking io | 939 | // set it to nonblocking io |
940 | int flag = ::fcntl( m_pppdLOG[0], F_GETFL ); | 940 | int flag = ::fcntl( m_pppdLOG[0], F_GETFL ); |
941 | 941 | ||
942 | if ( !(flag & O_NONBLOCK) ) { | 942 | if ( !(flag & O_NONBLOCK) ) { |
943 | odebug << "Setting nonblocking io" << oendl; | 943 | odebug << "Setting nonblocking io" << oendl; |
944 | flag |= O_NONBLOCK; | 944 | flag |= O_NONBLOCK; |
945 | ::fcntl(m_pppdLOG[0], F_SETFL, flag ); | 945 | ::fcntl(m_pppdLOG[0], F_SETFL, flag ); |
946 | } | 946 | } |
947 | 947 | ||
948 | delete m_modemDebug; | 948 | delete m_modemDebug; |
949 | m_modemDebug = new QSocketNotifier(m_pppdLOG[0], QSocketNotifier::Read, this ); | 949 | m_modemDebug = new QSocketNotifier(m_pppdLOG[0], QSocketNotifier::Read, this ); |
950 | connect(m_modemDebug, SIGNAL(activated(int) ), | 950 | connect(m_modemDebug, SIGNAL(activated(int) ), |
951 | this, SLOT(slotModemDebug(int) ) ); | 951 | this, SLOT(slotModemDebug(int) ) ); |
952 | 952 | ||
953 | modemfd = -1; | 953 | modemfd = -1; |
954 | m_pppdDev = QString::fromLatin1("ppp0"); | 954 | m_pppdDev = QString::fromLatin1("ppp0"); |
955 | return true; | 955 | return true; |
956 | break; | 956 | break; |
957 | } | 957 | } |
958 | } | 958 | } |
959 | 959 | ||
960 | 960 | ||
961 | bool Modem::killpppd() { | 961 | bool Modem::killpppd() { |
962 | odebug << "In killpppd and pid is " << pppdPid << "" << oendl; | 962 | odebug << "In killpppd and pid is " << pppdPid << "" << oendl; |
963 | if(pppdPid > 0) { | 963 | if(pppdPid > 0) { |
964 | delete m_modemDebug; | 964 | delete m_modemDebug; |
965 | m_modemDebug = 0; | 965 | m_modemDebug = 0; |
966 | odebug << "In killpppd(): Sending SIGTERM to " << pppdPid << "\n" << oendl; | 966 | odebug << "In killpppd(): Sending SIGTERM to " << pppdPid << "\n" << oendl; |
967 | if(kill(pppdPid, SIGTERM) < 0) { | 967 | if(kill(pppdPid, SIGTERM) < 0) { |
968 | odebug << "Error terminating " << pppdPid << ". Sending SIGKILL\n" << oendl; | 968 | odebug << "Error terminating " << pppdPid << ". Sending SIGKILL\n" << oendl; |
969 | if(kill(pppdPid, SIGKILL) < 0) { | 969 | if(kill(pppdPid, SIGKILL) < 0) { |
970 | odebug << "Error killing " << pppdPid << "\n" << oendl; | 970 | odebug << "Error killing " << pppdPid << "\n" << oendl; |
971 | return false; | 971 | return false; |
972 | } | 972 | } |
973 | } | 973 | } |
974 | } | 974 | } |
975 | return true; | 975 | return true; |
976 | } | 976 | } |
977 | 977 | ||
978 | 978 | ||
979 | void Modem::parseargs(char* buf, char** args) { | 979 | void Modem::parseargs(char* buf, char** args) { |
980 | int nargs = 0; | 980 | int nargs = 0; |
981 | int quotes; | 981 | int quotes; |
982 | 982 | ||
@@ -995,29 +995,29 @@ void Modem::parseargs(char* buf, char** args) { | |||
995 | quotes = *buf; | 995 | quotes = *buf; |
996 | *buf++ = '\0'; | 996 | *buf++ = '\0'; |
997 | } | 997 | } |
998 | 998 | ||
999 | // save the argument | 999 | // save the argument |
1000 | if(*buf != '\0') { | 1000 | if(*buf != '\0') { |
1001 | *args++ = buf; | 1001 | *args++ = buf; |
1002 | nargs++; | 1002 | nargs++; |
1003 | } | 1003 | } |
1004 | 1004 | ||
1005 | if (!quotes) | 1005 | if (!quotes) |
1006 | while ((*buf != '\0') && (*buf != '\n') && | 1006 | while ((*buf != '\0') && (*buf != '\n') && |
1007 | (*buf != '\t') && (*buf != ' ')) | 1007 | (*buf != '\t') && (*buf != ' ')) |
1008 | buf++; | 1008 | buf++; |
1009 | else { | 1009 | else { |
1010 | while ((*buf != '\0') && (*buf != quotes)) | 1010 | while ((*buf != '\0') && (*buf != quotes)) |
1011 | buf++; | 1011 | buf++; |
1012 | *buf++ = '\0'; | 1012 | *buf++ = '\0'; |
1013 | } | 1013 | } |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | *args = 0L; | 1016 | *args = 0L; |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | bool Modem::execPPPDaemon(const QString & arguments) | 1019 | bool Modem::execPPPDaemon(const QString & arguments) |
1020 | { | 1020 | { |
1021 | if(execpppd(arguments)) { | 1021 | if(execpppd(arguments)) { |
1022 | _pppdata->setpppdRunning(true); | 1022 | _pppdata->setpppdRunning(true); |
1023 | return true; | 1023 | return true; |
@@ -1031,46 +1031,46 @@ void Modem::killPPPDaemon() | |||
1031 | killpppd(); | 1031 | killpppd(); |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | int Modem::pppdExitStatus() | 1034 | int Modem::pppdExitStatus() |
1035 | { | 1035 | { |
1036 | return _pppdExitStatus; | 1036 | return _pppdExitStatus; |
1037 | } | 1037 | } |
1038 | 1038 | ||
1039 | int Modem::openResolv(int flags) | 1039 | int Modem::openResolv(int flags) |
1040 | { | 1040 | { |
1041 | int fd; | 1041 | int fd; |
1042 | if ((fd = open(_PATH_RESCONF, flags)) == -1) { | 1042 | if ((fd = open(_PATH_RESCONF, flags)) == -1) { |
1043 | odebug << "error opening resolv.conf!" << oendl; | 1043 | odebug << "error opening resolv.conf!" << oendl; |
1044 | fd = open(DEVNULL, O_RDONLY); | 1044 | fd = open(DEVNULL, O_RDONLY); |
1045 | } | 1045 | } |
1046 | return fd; | 1046 | return fd; |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | bool Modem::setHostname(const QString & name) | 1049 | bool Modem::setHostname(const QString & name) |
1050 | { | 1050 | { |
1051 | return sethostname(name, name.length()) == 0; | 1051 | return sethostname(name, name.length()) == 0; |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | QString Modem::pppDevice()const { | 1054 | QString Modem::pppDevice()const { |
1055 | return m_pppdDev; | 1055 | return m_pppdDev; |
1056 | } | 1056 | } |
1057 | void Modem::setPPPDevice( const QString& dev ) { | 1057 | void Modem::setPPPDevice( const QString& dev ) { |
1058 | m_pppdDev = dev; | 1058 | m_pppdDev = dev; |
1059 | } | 1059 | } |
1060 | pid_t Modem::pppPID()const { | 1060 | pid_t Modem::pppPID()const { |
1061 | return pppdPid; | 1061 | return pppdPid; |
1062 | } | 1062 | } |
1063 | void Modem::setPPPDPid( pid_t pid ) { | 1063 | void Modem::setPPPDPid( pid_t pid ) { |
1064 | odebug << "Modem setting pid" << oendl; | 1064 | odebug << "Modem setting pid" << oendl; |
1065 | _pppdExitStatus = -1; | 1065 | _pppdExitStatus = -1; |
1066 | pppdPid = pid; | 1066 | pppdPid = pid; |
1067 | modemfd = -1; | 1067 | modemfd = -1; |
1068 | } | 1068 | } |
1069 | void Modem::slotModemDebug(int fd) { | 1069 | void Modem::slotModemDebug(int fd) { |
1070 | char buf[2049]; | 1070 | char buf[2049]; |
1071 | int len; | 1071 | int len; |
1072 | 1072 | ||
1073 | // read in pppd data look for Using interface | 1073 | // read in pppd data look for Using interface |
1074 | // then read the interface | 1074 | // then read the interface |
1075 | // we limit to 10 device now 0-9 | 1075 | // we limit to 10 device now 0-9 |
1076 | if((len = ::read(fd, buf, 2048)) > 0) { | 1076 | if((len = ::read(fd, buf, 2048)) > 0) { |
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp index 4294b12..d36a702 100644 --- a/noncore/settings/networksettings/wlan/wlanimp2.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp | |||
@@ -45,25 +45,25 @@ using namespace Opie::Net; | |||
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Constructor, read in the wireless.opts file for parsing later. | 47 | * Constructor, read in the wireless.opts file for parsing later. |
48 | */ | 48 | */ |
49 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { | 49 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { |
50 | interfaces = new Interfaces(); | 50 | interfaces = new Interfaces(); |
51 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); | 51 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); |
52 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); | 52 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); |
53 | 53 | ||
54 | // Check sanity - the existance of the wireless-tools if-pre-up script | 54 | // Check sanity - the existance of the wireless-tools if-pre-up script |
55 | QFile file(QString(PREUP)); | 55 | QFile file(QString(PREUP)); |
56 | if (file.exists()) { | 56 | if (file.exists()) { |
57 | owarn << QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools") << oendl; | 57 | owarn << QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools") << oendl; |
58 | } | 58 | } |
59 | 59 | ||
60 | connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) ); | 60 | connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) ); |
61 | connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) ); | 61 | connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) ); |
62 | netView->setColumnAlignment( col_chn, AlignCenter ); | 62 | netView->setColumnAlignment( col_chn, AlignCenter ); |
63 | netView->setItemMargin( 3 ); | 63 | netView->setItemMargin( 3 ); |
64 | netView->setAllColumnsShowFocus( true ); | 64 | netView->setAllColumnsShowFocus( true ); |
65 | 65 | ||
66 | } | 66 | } |
67 | 67 | ||
68 | WLANImp::~WLANImp() { | 68 | WLANImp::~WLANImp() { |
69 | //FIXME: delete interfaces; | 69 | //FIXME: delete interfaces; |
@@ -226,25 +226,25 @@ void WLANImp::accept() { | |||
226 | // Close out the dialog | 226 | // Close out the dialog |
227 | // FIXME: QDialog::accept(); | 227 | // FIXME: QDialog::accept(); |
228 | } | 228 | } |
229 | 229 | ||
230 | void WLANImp::writeOpts() { | 230 | void WLANImp::writeOpts() { |
231 | // eh can't really do anything about it other then return. :-D | 231 | // eh can't really do anything about it other then return. :-D |
232 | if(!interfaces->isInterfaceSet()){ | 232 | if(!interfaces->isInterfaceSet()){ |
233 | QMessageBox::warning(0,"Inface not set","should not happen!!!"); | 233 | QMessageBox::warning(0,"Inface not set","should not happen!!!"); |
234 | return; | 234 | return; |
235 | } | 235 | } |
236 | bool error = false; | 236 | bool error = false; |
237 | 237 | ||
238 | odebug << "setting wlan interface " << interfaces->getInterfaceName( error ).latin1() << "" << oendl; | 238 | odebug << "setting wlan interface " << interfaces->getInterfaceName( error ).latin1() << "" << oendl; |
239 | 239 | ||
240 | if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!"); | 240 | if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!"); |
241 | 241 | ||
242 | interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); | 242 | interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); |
243 | interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); | 243 | interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); |
244 | 244 | ||
245 | if (specifyAp->isChecked()) { | 245 | if (specifyAp->isChecked()) { |
246 | interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text()); | 246 | interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text()); |
247 | } else { | 247 | } else { |
248 | interfaces->removeInterfaceOption(QString("wireless_ap")); | 248 | interfaces->removeInterfaceOption(QString("wireless_ap")); |
249 | } | 249 | } |
250 | 250 | ||
@@ -300,83 +300,83 @@ void WLANImp::writeOpts() { | |||
300 | 300 | ||
301 | QDialog::accept(); | 301 | QDialog::accept(); |
302 | } | 302 | } |
303 | 303 | ||
304 | /* | 304 | /* |
305 | * Scan for possible wireless networks around... | 305 | * Scan for possible wireless networks around... |
306 | * ... powered by Wellenreiter II technology (C) Michael 'Mickey' Lauer <mickeyl@handhelds.org> | 306 | * ... powered by Wellenreiter II technology (C) Michael 'Mickey' Lauer <mickeyl@handhelds.org> |
307 | */ | 307 | */ |
308 | 308 | ||
309 | void WLANImp::rescanNeighbourhood() | 309 | void WLANImp::rescanNeighbourhood() |
310 | { | 310 | { |
311 | QString name = interface->getInterfaceName(); | 311 | QString name = interface->getInterfaceName(); |
312 | odebug << "rescanNeighbourhood via '" << name << "'" << oendl; | 312 | odebug << "rescanNeighbourhood via '" << name << "'" << oendl; |
313 | 313 | ||
314 | OWirelessNetworkInterface* wiface = static_cast<OWirelessNetworkInterface*>( ONetwork::instance()->interface( name ) ); | 314 | OWirelessNetworkInterface* wiface = static_cast<OWirelessNetworkInterface*>( ONetwork::instance()->interface( name ) ); |
315 | assert( wiface ); | 315 | assert( wiface ); |
316 | 316 | ||
317 | // try to guess device type | 317 | // try to guess device type |
318 | QString devicetype; | 318 | QString devicetype; |
319 | QFile m( "/proc/modules" ); | 319 | QFile m( "/proc/modules" ); |
320 | if ( m.open( IO_ReadOnly ) ) | 320 | if ( m.open( IO_ReadOnly ) ) |
321 | { | 321 | { |
322 | QString line; | 322 | QString line; |
323 | QTextStream modules( &m ); | 323 | QTextStream modules( &m ); |
324 | while( !modules.atEnd() && !devicetype ) | 324 | while( !modules.atEnd() && !devicetype ) |
325 | { | 325 | { |
326 | modules >> line; | 326 | modules >> line; |
327 | if ( line.contains( "cisco" ) ) devicetype = "cisco"; | 327 | if ( line.contains( "cisco" ) ) devicetype = "cisco"; |
328 | else if ( line.contains( "hostap" ) ) devicetype = "hostap"; | 328 | else if ( line.contains( "hostap" ) ) devicetype = "hostap"; |
329 | else if ( line.contains( "prism" ) ) devicetype = "wlan-ng"; /* puke */ | 329 | else if ( line.contains( "prism" ) ) devicetype = "wlan-ng"; /* puke */ |
330 | else if ( line.contains( "orinoco" ) ) devicetype = "orinoco"; | 330 | else if ( line.contains( "orinoco" ) ) devicetype = "orinoco"; |
331 | } | 331 | } |
332 | } | 332 | } |
333 | if ( devicetype.isEmpty() ) | 333 | if ( devicetype.isEmpty() ) |
334 | { | 334 | { |
335 | owarn << "rescanNeighbourhood(): couldn't guess device type :(" << oendl; | 335 | owarn << "rescanNeighbourhood(): couldn't guess device type :(" << oendl; |
336 | return; | 336 | return; |
337 | } | 337 | } |
338 | else | 338 | else |
339 | { | 339 | { |
340 | odebug << "rescanNeighbourhood(): device type seems to be '" << devicetype << "'" << oendl; | 340 | odebug << "rescanNeighbourhood(): device type seems to be '" << devicetype << "'" << oendl; |
341 | } | 341 | } |
342 | 342 | ||
343 | // configure interface to receive 802.11 management frames | 343 | // configure interface to receive 802.11 management frames |
344 | 344 | ||
345 | wiface->setUp( true ); | 345 | wiface->setUp( true ); |
346 | wiface->setPromiscuousMode( true ); | 346 | wiface->setPromiscuousMode( true ); |
347 | 347 | ||
348 | if ( devicetype == "cisco" ) wiface->setMonitoring( new OCiscoMonitoringInterface( wiface, false ) ); | 348 | if ( devicetype == "cisco" ) wiface->setMonitoring( new OCiscoMonitoringInterface( wiface, false ) ); |
349 | else if ( devicetype == "hostap" ) wiface->setMonitoring( new OHostAPMonitoringInterface( wiface, false ) ); | 349 | else if ( devicetype == "hostap" ) wiface->setMonitoring( new OHostAPMonitoringInterface( wiface, false ) ); |
350 | else if ( devicetype == "wlan-ng" ) wiface->setMonitoring( new OWlanNGMonitoringInterface( wiface, false ) ); | 350 | else if ( devicetype == "wlan-ng" ) wiface->setMonitoring( new OWlanNGMonitoringInterface( wiface, false ) ); |
351 | else if ( devicetype == "orinoco" ) wiface->setMonitoring( new OOrinocoMonitoringInterface( wiface, false ) ); | 351 | else if ( devicetype == "orinoco" ) wiface->setMonitoring( new OOrinocoMonitoringInterface( wiface, false ) ); |
352 | else | 352 | else |
353 | { | 353 | { |
354 | odebug << "rescanNeighbourhood(): unsupported device type for monitoring :(" << oendl; | 354 | odebug << "rescanNeighbourhood(): unsupported device type for monitoring :(" << oendl; |
355 | return; | 355 | return; |
356 | } | 356 | } |
357 | 357 | ||
358 | wiface->setMode( "monitor" ); | 358 | wiface->setMode( "monitor" ); |
359 | if ( wiface->mode() != "monitor" ) | 359 | if ( wiface->mode() != "monitor" ) |
360 | { | 360 | { |
361 | owarn << "rescanNeighbourhood(): Unable to bring device into monitor mode (" << strerror( errno ) << ")." << oendl; | 361 | owarn << "rescanNeighbourhood(): Unable to bring device into monitor mode (" << strerror( errno ) << ")." << oendl; |
362 | return; | 362 | return; |
363 | } | 363 | } |
364 | 364 | ||
365 | // open a packet capturer | 365 | // open a packet capturer |
366 | OPacketCapturer* cap = new OPacketCapturer(); | 366 | OPacketCapturer* cap = new OPacketCapturer(); |
367 | cap->open( name ); | 367 | cap->open( name ); |
368 | if ( !cap->isOpen() ) | 368 | if ( !cap->isOpen() ) |
369 | { | 369 | { |
370 | owarn << "rescanNeighbourhood(): Unable to open libpcap (" << strerror( errno ) << ")." << oendl; | 370 | owarn << "rescanNeighbourhood(): Unable to open libpcap (" << strerror( errno ) << ")." << oendl; |
371 | return; | 371 | return; |
372 | } | 372 | } |
373 | 373 | ||
374 | // display splash screen | 374 | // display splash screen |
375 | QFrame* splash = new QFrame( this, "splash", false, WStyle_StaysOnTop | WStyle_DialogBorder | WStyle_Customize ); | 375 | QFrame* splash = new QFrame( this, "splash", false, WStyle_StaysOnTop | WStyle_DialogBorder | WStyle_Customize ); |
376 | splash->setLineWidth( 2 ); | 376 | splash->setLineWidth( 2 ); |
377 | splash->setFrameStyle( QFrame::Panel | QFrame::Raised ); | 377 | splash->setFrameStyle( QFrame::Panel | QFrame::Raised ); |
378 | QVBoxLayout* vbox = new QVBoxLayout( splash, 4, 4 ); | 378 | QVBoxLayout* vbox = new QVBoxLayout( splash, 4, 4 ); |
379 | QLabel* lab = new QLabel( "<center><b>Scanning...</b><br>Please Wait...</center>", splash ); | 379 | QLabel* lab = new QLabel( "<center><b>Scanning...</b><br>Please Wait...</center>", splash ); |
380 | QProgressBar* pb = new QProgressBar( wiface->channels(), splash ); | 380 | QProgressBar* pb = new QProgressBar( wiface->channels(), splash ); |
381 | vbox->addWidget( lab ); | 381 | vbox->addWidget( lab ); |
382 | vbox->addWidget( pb ); | 382 | vbox->addWidget( pb ); |
@@ -391,33 +391,33 @@ void WLANImp::rescanNeighbourhood() | |||
391 | splash->show(); | 391 | splash->show(); |
392 | splash->raise(); | 392 | splash->raise(); |
393 | qApp->processEvents(); | 393 | qApp->processEvents(); |
394 | 394 | ||
395 | // set capturer to non-blocking mode | 395 | // set capturer to non-blocking mode |
396 | cap->setBlocking( false ); | 396 | cap->setBlocking( false ); |
397 | 397 | ||
398 | for ( int i = 1; i <= wiface->channels(); ++i ) | 398 | for ( int i = 1; i <= wiface->channels(); ++i ) |
399 | { | 399 | { |
400 | wiface->setChannel( i ); | 400 | wiface->setChannel( i ); |
401 | pb->setProgress( i ); | 401 | pb->setProgress( i ); |
402 | qApp->processEvents(); | 402 | qApp->processEvents(); |
403 | odebug << "rescanNeighbourhood(): listening on channel " << i << "..." << oendl; | 403 | odebug << "rescanNeighbourhood(): listening on channel " << i << "..." << oendl; |
404 | OPacket* p = cap->next( 1000 ); | 404 | OPacket* p = cap->next( 1000 ); |
405 | if ( !p ) | 405 | if ( !p ) |
406 | { | 406 | { |
407 | odebug << "rescanNeighbourhood(): nothing received on channel " << i << "" << oendl; | 407 | odebug << "rescanNeighbourhood(): nothing received on channel " << i << "" << oendl; |
408 | } | 408 | } |
409 | else | 409 | else |
410 | { | 410 | { |
411 | odebug << "rescanNeighbourhood(): TADAA - something came in on channel " << i << "" << oendl; | 411 | odebug << "rescanNeighbourhood(): TADAA - something came in on channel " << i << "" << oendl; |
412 | handlePacket( p ); | 412 | handlePacket( p ); |
413 | } | 413 | } |
414 | } | 414 | } |
415 | 415 | ||
416 | cap->close(); | 416 | cap->close(); |
417 | wiface->setMode( "managed" ); // TODO: use previous mode | 417 | wiface->setMode( "managed" ); // TODO: use previous mode |
418 | wiface->setPromiscuousMode( false ); | 418 | wiface->setPromiscuousMode( false ); |
419 | 419 | ||
420 | splash->hide(); | 420 | splash->hide(); |
421 | delete splash; | 421 | delete splash; |
422 | 422 | ||
423 | } | 423 | } |
@@ -432,44 +432,43 @@ void WLANImp::handlePacket( OPacket* p ) | |||
432 | 432 | ||
433 | QString type; | 433 | QString type; |
434 | if ( beacon->canIBSS() ) | 434 | if ( beacon->canIBSS() ) |
435 | { | 435 | { |
436 | type = "adhoc"; | 436 | type = "adhoc"; |
437 | } | 437 | } |
438 | else if ( beacon->canESS() ) | 438 | else if ( beacon->canESS() ) |
439 | { | 439 | { |
440 | type = "managed"; | 440 | type = "managed"; |
441 | } | 441 | } |
442 | else | 442 | else |
443 | { | 443 | { |
444 | owarn << "handlePacket(): invalid frame [possibly noise] detected!" << oendl; | 444 | owarn << "handlePacket(): invalid frame [possibly noise] detected!" << oendl; |
445 | return; | 445 | return; |
446 | } | 446 | } |
447 | 447 | ||
448 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 448 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
449 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); | 449 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); |
450 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 450 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
451 | int channel = ds ? ds->channel() : -1; | 451 | int channel = ds ? ds->channel() : -1; |
452 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 452 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
453 | displayFoundNetwork( type, channel, essid, header->macAddress2() ); | 453 | displayFoundNetwork( type, channel, essid, header->macAddress2() ); |
454 | } | 454 | } |
455 | } | 455 | } |
456 | 456 | ||
457 | 457 | ||
458 | void WLANImp::displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac ) | 458 | void WLANImp::displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac ) |
459 | { | 459 | { |
460 | 460 | ||
461 | qDebug( "found network: <%s>, chn %d, ssid '%s', mac '%s'", (const char*) mode, channel, | 461 | odebug << "found network: <" << (const char*) mode << ">, chn " << channel |
462 | (const char*) ssid, | 462 | << ", ssid '" << (const char*) ssid << "', mac '" << (const char*) mac.toString() << "'" << oendl; |
463 | (const char*) mac.toString() ); | ||
464 | 463 | ||
465 | QListViewItemIterator it( netView ); | 464 | QListViewItemIterator it( netView ); |
466 | while ( it.current() && it.current()->text( col_ssid ) != ssid ) ++it; | 465 | while ( it.current() && it.current()->text( col_ssid ) != ssid ) ++it; |
467 | if ( !it.current() ) // ssid didn't show up yet | 466 | if ( !it.current() ) // ssid didn't show up yet |
468 | { | 467 | { |
469 | QListViewItem* item = new QListViewItem( netView, mode.left( 1 ).upper(), ssid, QString::number( channel ), mac.toString() ); | 468 | QListViewItem* item = new QListViewItem( netView, mode.left( 1 ).upper(), ssid, QString::number( channel ), mac.toString() ); |
470 | QString name; | 469 | QString name; |
471 | name.sprintf( "networksettings/%s", (const char*) mode ); | 470 | name.sprintf( "networksettings/%s", (const char*) mode ); |
472 | item->setPixmap( col_mode, Resource::loadPixmap( name ) ); | 471 | item->setPixmap( col_mode, Resource::loadPixmap( name ) ); |
473 | qApp->processEvents(); | 472 | qApp->processEvents(); |
474 | } | 473 | } |
475 | 474 | ||