4 files changed, 42 insertions, 20 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index 0ef1e68..5029525 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -409,258 +409,259 @@ void MainWindowImp::configureClicked(){ | |||
409 | if(!item){ | 409 | if(!item){ |
410 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); | 410 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); |
411 | return; | 411 | return; |
412 | } | 412 | } |
413 | 413 | ||
414 | QString currentProfileText = currentProfileLabel->text(); | 414 | QString currentProfileText = currentProfileLabel->text(); |
415 | if(currentProfileText.upper() == "ALL"); | 415 | if(currentProfileText.upper() == "ALL"); |
416 | currentProfileText = ""; | 416 | currentProfileText = ""; |
417 | 417 | ||
418 | Interface *i = interfaceItems[item]; | 418 | Interface *i = interfaceItems[item]; |
419 | 419 | ||
420 | if(i->getModuleOwner()){ | 420 | if(i->getModuleOwner()){ |
421 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); | 421 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); |
422 | if(moduleConfigure != NULL){ | 422 | if(moduleConfigure != NULL){ |
423 | i->getModuleOwner()->setProfile(currentProfileText); | 423 | i->getModuleOwner()->setProfile(currentProfileText); |
424 | moduleConfigure->showMaximized(); | 424 | moduleConfigure->showMaximized(); |
425 | return; | 425 | return; |
426 | } | 426 | } |
427 | } | 427 | } |
428 | 428 | ||
429 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose ); | 429 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose ); |
430 | configure->setProfile(currentProfileText); | 430 | configure->setProfile(currentProfileText); |
431 | configure->showMaximized(); | 431 | configure->showMaximized(); |
432 | } | 432 | } |
433 | 433 | ||
434 | /** | 434 | /** |
435 | * Pull up the information about the currently selected interface. | 435 | * Pull up the information about the currently selected interface. |
436 | * Report an error if no interface is selected. | 436 | * Report an error if no interface is selected. |
437 | * If the interface has a module owner then request its configure. | 437 | * If the interface has a module owner then request its configure. |
438 | */ | 438 | */ |
439 | void MainWindowImp::informationClicked(){ | 439 | void MainWindowImp::informationClicked(){ |
440 | QListViewItem *item = connectionList->currentItem(); | 440 | QListViewItem *item = connectionList->currentItem(); |
441 | if(!item){ | 441 | if(!item){ |
442 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 442 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
443 | return; | 443 | return; |
444 | } | 444 | } |
445 | 445 | ||
446 | Interface *i = interfaceItems[item]; | 446 | Interface *i = interfaceItems[item]; |
447 | // if(!i->isAttached()){ | 447 | // if(!i->isAttached()){ |
448 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); | 448 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); |
449 | // return; | 449 | // return; |
450 | // } | 450 | // } |
451 | 451 | ||
452 | if(i->getModuleOwner()){ | 452 | if(i->getModuleOwner()){ |
453 | QWidget *moduleInformation = i->getModuleOwner()->information(i); | 453 | QWidget *moduleInformation = i->getModuleOwner()->information(i); |
454 | if(moduleInformation != NULL){ | 454 | if(moduleInformation != NULL){ |
455 | moduleInformation->showMaximized(); | 455 | moduleInformation->showMaximized(); |
456 | #ifdef DEBUG | 456 | #ifdef DEBUG |
457 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); | 457 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); |
458 | #endif | 458 | #endif |
459 | return; | 459 | return; |
460 | } | 460 | } |
461 | } | 461 | } |
462 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); | 462 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); |
463 | information->showMaximized(); | 463 | information->showMaximized(); |
464 | } | 464 | } |
465 | 465 | ||
466 | /** | 466 | /** |
467 | * Update this interface. If no QListViewItem exists create one. | 467 | * Update this interface. If no QListViewItem exists create one. |
468 | * @param Interface* pointer to the interface that needs to be updated. | 468 | * @param Interface* pointer to the interface that needs to be updated. |
469 | */ | 469 | */ |
470 | void MainWindowImp::updateInterface(Interface *i){ | 470 | void MainWindowImp::updateInterface(Interface *i){ |
471 | if(!advancedUserMode){ | 471 | if(!advancedUserMode){ |
472 | if(i->getInterfaceName() == "lo") | 472 | if(i->getInterfaceName() == "lo") |
473 | return; | 473 | return; |
474 | } | 474 | } |
475 | 475 | ||
476 | QListViewItem *item = NULL; | 476 | QListViewItem *item = NULL; |
477 | 477 | ||
478 | // Find the interface, making it if needed. | 478 | // Find the interface, making it if needed. |
479 | if(items.find(i) == items.end()){ | 479 | if(items.find(i) == items.end()){ |
480 | item = new QListViewItem(connectionList, "", "", ""); | 480 | item = new QListViewItem(connectionList, "", "", ""); |
481 | // See if you can't find a module owner for this interface | 481 | // See if you can't find a module owner for this interface |
482 | QMap<Module*, QLibrary*>::Iterator it; | 482 | QMap<Module*, QLibrary*>::Iterator it; |
483 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 483 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
484 | if(it.key()->isOwner(i)) | 484 | if(it.key()->isOwner(i)) |
485 | i->setModuleOwner(it.key()); | 485 | i->setModuleOwner(it.key()); |
486 | } | 486 | } |
487 | items.insert(i, item); | 487 | items.insert(i, item); |
488 | interfaceItems.insert(item, i); | 488 | interfaceItems.insert(item, i); |
489 | } | 489 | } |
490 | else | 490 | else |
491 | item = items[i]; | 491 | item = items[i]; |
492 | 492 | ||
493 | // Update the icons and information | 493 | // Update the icons and information |
494 | #ifdef QWS | 494 | #ifdef QWS |
495 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); | 495 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); |
496 | #else | 496 | #else |
497 | item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); | 497 | item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); |
498 | #endif | 498 | #endif |
499 | 499 | ||
500 | QString typeName = "lan"; | 500 | QString typeName = "lan"; |
501 | if(i->getInterfaceName() == "lo") | 501 | if(i->getInterfaceName() == "lo") |
502 | typeName = "lo"; | 502 | typeName = "lo"; |
503 | if(i->getInterfaceName().contains("irda")) | 503 | if(i->getInterfaceName().contains("irda")) |
504 | typeName = "irda"; | 504 | typeName = "irda"; |
505 | if(i->getInterfaceName().contains("wlan")) | 505 | if(i->getInterfaceName().contains("wlan")) |
506 | typeName = "wlan"; | 506 | typeName = "wlan"; |
507 | if(i->getInterfaceName().contains("usb")) | 507 | if(i->getInterfaceName().contains("usb")) |
508 | typeName = "usb"; | 508 | typeName = "usb"; |
509 | 509 | ||
510 | if(!i->isAttached()) | 510 | if(!i->isAttached()) |
511 | typeName = "connect_no"; | 511 | typeName = "connect_no"; |
512 | // Actually try to use the Module | 512 | // Actually try to use the Module |
513 | if(i->getModuleOwner() != NULL) | 513 | if(i->getModuleOwner() != NULL) |
514 | typeName = i->getModuleOwner()->getPixmapName(i); | 514 | typeName = i->getModuleOwner()->getPixmapName(i); |
515 | 515 | ||
516 | #ifdef QWS | 516 | #ifdef QWS |
517 | item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); | 517 | item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); |
518 | #else | 518 | #else |
519 | item->setPixmap(1, (SmallIcon(typeName))); | 519 | item->setPixmap(1, (SmallIcon(typeName))); |
520 | #endif | 520 | #endif |
521 | item->setText(2, i->getHardwareName()); | 521 | item->setText(2, i->getHardwareName()); |
522 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); | 522 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); |
523 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); | 523 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); |
524 | } | 524 | } |
525 | 525 | ||
526 | void MainWindowImp::newProfileChanged(const QString& newText){ | 526 | void MainWindowImp::newProfileChanged(const QString& newText){ |
527 | if(newText.length() > 0) | 527 | if(newText.length() > 0) |
528 | newProfileButton->setEnabled(true); | 528 | newProfileButton->setEnabled(true); |
529 | else | 529 | else |
530 | newProfileButton->setEnabled(false); | 530 | newProfileButton->setEnabled(false); |
531 | } | 531 | } |
532 | 532 | ||
533 | /** | 533 | /** |
534 | * Adds a new profile to the list of profiles. | 534 | * Adds a new profile to the list of profiles. |
535 | * Don't add profiles that already exists. | 535 | * Don't add profiles that already exists. |
536 | * Appends to the list and QStringList | 536 | * Appends to the list and QStringList |
537 | */ | 537 | */ |
538 | void MainWindowImp::addProfile(){ | 538 | void MainWindowImp::addProfile(){ |
539 | QString newProfileName = newProfile->text(); | 539 | QString newProfileName = newProfile->text(); |
540 | if(profiles.grep(newProfileName).count() > 0){ | 540 | if(profiles.grep(newProfileName).count() > 0){ |
541 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); | 541 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); |
542 | return; | 542 | return; |
543 | } | 543 | } |
544 | profiles.append(newProfileName); | 544 | profiles.append(newProfileName); |
545 | profilesList->insertItem(newProfileName); | 545 | profilesList->insertItem(newProfileName); |
546 | } | 546 | } |
547 | 547 | ||
548 | /** | 548 | /** |
549 | * Removes the currently selected profile in the combo. | 549 | * Removes the currently selected profile in the combo. |
550 | * Doesn't delete if there are less then 2 profiles. | 550 | * Doesn't delete if there are less then 2 profiles. |
551 | */ | 551 | */ |
552 | void MainWindowImp::removeProfile(){ | 552 | void MainWindowImp::removeProfile(){ |
553 | if(profilesList->count() <= 1){ | 553 | if(profilesList->count() <= 1){ |
554 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); | 554 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); |
555 | return; | 555 | return; |
556 | } | 556 | } |
557 | QString profileToRemove = profilesList->currentText(); | 557 | QString profileToRemove = profilesList->currentText(); |
558 | if(profileToRemove == "All"){ | 558 | if(profileToRemove == "All"){ |
559 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); | 559 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); |
560 | return; | 560 | return; |
561 | } | 561 | } |
562 | // Can't remove the curent profile | 562 | // Can't remove the curent profile |
563 | if(profileToRemove == currentProfileLabel->text()){ | 563 | if(profileToRemove == currentProfileLabel->text()){ |
564 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); | 564 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); |
565 | return; | 565 | return; |
566 | 566 | ||
567 | } | 567 | } |
568 | 568 | ||
569 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ | 569 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ |
570 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); | 570 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); |
571 | profilesList->clear(); | 571 | profilesList->clear(); |
572 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 572 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
573 | profilesList->insertItem((*it)); | 573 | profilesList->insertItem((*it)); |
574 | 574 | ||
575 | // Remove any interface settings and mappings. | 575 | // Remove any interface settings and mappings. |
576 | Interfaces interfaces; | 576 | Interfaces interfaces; |
577 | // Go through them one by one | 577 | // Go through them one by one |
578 | QMap<Interface*, QListViewItem*>::Iterator it; | 578 | QMap<Interface*, QListViewItem*>::Iterator it; |
579 | for( it = items.begin(); it != items.end(); ++it ){ | 579 | for( it = items.begin(); it != items.end(); ++it ){ |
580 | QString interfaceName = it.key()->getInterfaceName(); | 580 | QString interfaceName = it.key()->getInterfaceName(); |
581 | qDebug(interfaceName.latin1()); | 581 | qDebug(interfaceName.latin1()); |
582 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ | 582 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ |
583 | interfaces.removeInterface(); | 583 | interfaces.removeInterface(); |
584 | if(interfaces.setMapping(interfaceName)){ | 584 | if(interfaces.setMapping(interfaceName)){ |
585 | if(profilesList->count() == 1) | 585 | if(profilesList->count() == 1) |
586 | interfaces.removeMapping(); | 586 | interfaces.removeMapping(); |
587 | else{ | 587 | else{ |
588 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); | 588 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); |
589 | } | 589 | } |
590 | } | 590 | } |
591 | interfaces.write(); | 591 | interfaces.write(); |
592 | break; | 592 | break; |
593 | } | 593 | } |
594 | } | 594 | } |
595 | } | 595 | } |
596 | } | 596 | } |
597 | 597 | ||
598 | /** | 598 | /** |
599 | * A new profile has been selected, change. | 599 | * A new profile has been selected, change. |
600 | * @param newProfile the new profile. | 600 | * @param newProfile the new profile. |
601 | */ | 601 | */ |
602 | void MainWindowImp::changeProfile(){ | 602 | void MainWindowImp::changeProfile(){ |
603 | if(profilesList->currentItem() == -1){ | 603 | if(profilesList->currentItem() == -1){ |
604 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); | 604 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); |
605 | return; | 605 | return; |
606 | } | 606 | } |
607 | QString newProfile = profilesList->text(profilesList->currentItem()); | 607 | QString newProfile = profilesList->text(profilesList->currentItem()); |
608 | if(newProfile != currentProfileLabel->text()){ | 608 | if(newProfile != currentProfileLabel->text()){ |
609 | currentProfileLabel->setText(newProfile); | 609 | currentProfileLabel->setText(newProfile); |
610 | QFile::remove(scheme); | 610 | QFile::remove(scheme); |
611 | QFile file(scheme); | 611 | QFile file(scheme); |
612 | if ( file.open(IO_ReadWrite) ) { | 612 | if ( file.open(IO_ReadWrite) ) { |
613 | QTextStream stream( &file ); | 613 | QTextStream stream( &file ); |
614 | stream << QString("SCHEME=%1").arg(newProfile); | 614 | stream << QString("SCHEME=%1").arg(newProfile); |
615 | file.close(); | 615 | file.close(); |
616 | } | 616 | } |
617 | // restart all up devices? | 617 | // restart all up devices? |
618 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ | 618 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ |
619 | // Go through them one by one | 619 | // Go through them one by one |
620 | QMap<Interface*, QListViewItem*>::Iterator it; | 620 | QMap<Interface*, QListViewItem*>::Iterator it; |
621 | for( it = items.begin(); it != items.end(); ++it ){ | 621 | for( it = items.begin(); it != items.end(); ++it ){ |
622 | if(it.key()->getStatus() == true) | 622 | if(it.key()->getStatus() == true) |
623 | it.key()->restart(); | 623 | it.key()->restart(); |
624 | } | 624 | } |
625 | } | 625 | } |
626 | } | 626 | } |
627 | // TODO change the profile in the modules | 627 | // TODO change the profile in the modules |
628 | } | 628 | } |
629 | 629 | ||
630 | 630 | ||
631 | void MainWindowImp::makeChannel() | 631 | void MainWindowImp::makeChannel() |
632 | { | 632 | { |
633 | channel = new QCopChannel( "QPE/Application/networksettings", this ); | 633 | channel = new QCopChannel( "QPE/Application/networksettings", this ); |
634 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 634 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
635 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 635 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
636 | } | 636 | } |
637 | 637 | ||
638 | void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) | 638 | void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) |
639 | { | 639 | { |
640 | bool found = false; | 640 | bool found = false; |
641 | qDebug("MainWindowImp::receive QCop msg >"+msg+"<"); | 641 | qDebug("MainWindowImp::receive QCop msg >"+msg+"<"); |
642 | 642 | ||
643 | QString dest = msg.left(msg.find("(")); | 643 | QString dest = msg.left(msg.find("(")); |
644 | QCString param = msg.right(msg.length() - msg.find("(") - 1); | 644 | QCString param = msg.right(msg.length() - msg.find("(") - 1); |
645 | param = param.left( param.length() - 1 ); | 645 | param = param.left( param.length() - 1 ); |
646 | qDebug("dest >%s< param >"+param+"<",dest.latin1()); | 646 | qDebug("dest >%s< param >"+param+"<",dest.latin1()); |
647 | 647 | ||
648 | // if (param.contains("QString,QString,QString")) { | 648 | // if (param.contains("QString,QString,QString")) { |
649 | // QDataStream stream(arg,IO_ReadOnly); | 649 | // QDataStream stream(arg,IO_ReadOnly); |
650 | // QString arg1, arg2, arg3; | 650 | // QString arg1, arg2, arg3; |
651 | // stream >> arg1 >> arg2 >> arg3 ; | 651 | // stream >> arg1 >> arg2 >> arg3 ; |
652 | // qDebug("args: >%s< >%s< >%s<",arg1.latin1(),arg2.latin1(),arg3.latin1()); | 652 | // qDebug("args: >%s< >%s< >%s<",arg1.latin1(),arg2.latin1(),arg3.latin1()); |
653 | // } | 653 | // } |
654 | 654 | ||
655 | QMap<Module*, QLibrary*>::Iterator it; | 655 | QMap<Module*, QLibrary*>::Iterator it; |
656 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 656 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
657 | qDebug("plugin >%s<", it.key()->type().latin1() ); | 657 | qDebug("plugin >%s<", it.key()->type().latin1() ); |
658 | if(it.key()->type() == dest){ | 658 | if(it.key()->type() == dest){ |
659 | it.key()->receive( param, arg ); | 659 | it.key()->receive( param, arg ); |
660 | found = true; | 660 | found = true; |
661 | } | 661 | } |
662 | } | 662 | } |
663 | 663 | ||
664 | 664 | ||
665 | if (!found) qDebug("Huh what do ya want"); | 665 | if (found) QPEApplication::setKeepRunning(); |
666 | else qDebug("Huh what do ya want"); | ||
666 | } | 667 | } |
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp index b988822..cdafb4d 100644 --- a/noncore/settings/networksettings/wlan/wlanimp2.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp | |||
@@ -1,269 +1,269 @@ | |||
1 | #include "wlanimp2.h" | 1 | #include "wlanimp2.h" |
2 | #include "keyedit.h" | 2 | #include "keyedit.h" |
3 | #include "interfacesetupimp.h" | 3 | #include "interfacesetupimp.h" |
4 | 4 | ||
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | #include <qdir.h> | 6 | #include <qdir.h> |
7 | #include <qtextstream.h> | 7 | #include <qtextstream.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qlabel.h> | 10 | #include <qlabel.h> |
11 | #include <qspinbox.h> | 11 | #include <qspinbox.h> |
12 | #include <qradiobutton.h> | 12 | #include <qradiobutton.h> |
13 | #include <qcheckbox.h> | 13 | #include <qcheckbox.h> |
14 | #include <qtabwidget.h> | 14 | #include <qtabwidget.h> |
15 | #include <qcombobox.h> | 15 | #include <qcombobox.h> |
16 | 16 | ||
17 | #ifdef QWS | 17 | #ifdef QWS |
18 | #include <opie/oprocess.h> | 18 | #include <opie/oprocess.h> |
19 | #else | 19 | #else |
20 | #define OProcess KProcess | 20 | #define OProcess KProcess |
21 | #include <kprocess.h> | 21 | #include <kprocess.h> |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" | 24 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" |
25 | #define PREUP "/etc/netwrok/if-pre-up.d/wireless-tools" | 25 | #define PREUP "/etc/netwrok/if-pre-up.d/wireless-tools" |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * Constructor, read in the wireless.opts file for parsing later. | 28 | * Constructor, read in the wireless.opts file for parsing later. |
29 | */ | 29 | */ |
30 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), currentProfile("*"), interface(i) { | 30 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), currentProfile("*"), interface(i) { |
31 | interfaces = new Interfaces; | 31 | interfaces = new Interfaces(); |
32 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); | 32 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); |
33 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); | 33 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); |
34 | 34 | ||
35 | // Check sanity - the existance of the wireless-tools if-pre-up script | 35 | // Check sanity - the existance of the wireless-tools if-pre-up script |
36 | QFile file(QString(PREUP)); | 36 | QFile file(QString(PREUP)); |
37 | if (file.exists()) { | 37 | if (file.exists()) { |
38 | qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools")); | 38 | qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools")); |
39 | } | 39 | } |
40 | } | 40 | } |
41 | 41 | ||
42 | WLANImp::~WLANImp() { | 42 | WLANImp::~WLANImp() { |
43 | //FIXME: delete interfaces; | 43 | //FIXME: delete interfaces; |
44 | } | 44 | } |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Change the profile for both wireless settings and network settings. | 47 | * Change the profile for both wireless settings and network settings. |
48 | */ | 48 | */ |
49 | void WLANImp::setProfile(const QString &profile){ | 49 | void WLANImp::setProfile(const QString &profile){ |
50 | interfaceSetup->setProfile(profile); | 50 | interfaceSetup->setProfile(profile); |
51 | parseOpts(); | 51 | parseOpts(); |
52 | } | 52 | } |
53 | 53 | ||
54 | void WLANImp::parseOpts() { | 54 | void WLANImp::parseOpts() { |
55 | bool error; | 55 | bool error; |
56 | QString opt; | 56 | QString opt; |
57 | 57 | ||
58 | if (! interfaces->isInterfaceSet()) | 58 | if (! interfaces->isInterfaceSet()) |
59 | return; | 59 | return; |
60 | 60 | ||
61 | 61 | ||
62 | opt = interfaces->getInterfaceOption("wireless_essid", error); | 62 | opt = interfaces->getInterfaceOption("wireless_essid", error); |
63 | if(opt == "any" || opt == "off" || opt.isNull()){ | 63 | if(opt == "any" || opt == "off" || opt.isNull()){ |
64 | essid->setEditText("any"); | 64 | essid->setEditText("any"); |
65 | } else { | 65 | } else { |
66 | essid->setEditText(opt); | 66 | essid->setEditText(opt); |
67 | } | 67 | } |
68 | 68 | ||
69 | opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); | 69 | opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); |
70 | if (opt == "Auto") { | 70 | if (opt == "Auto") { |
71 | mode->setCurrentItem(0); | 71 | mode->setCurrentItem(0); |
72 | } else if (opt == "Ad-Hoc") { | 72 | } else if (opt == "Ad-Hoc") { |
73 | mode->setCurrentItem(2); | 73 | mode->setCurrentItem(2); |
74 | } else { | 74 | } else { |
75 | // Managed/Infrastructure mode | 75 | // Managed/Infrastructure mode |
76 | mode->setCurrentItem(1); | 76 | mode->setCurrentItem(1); |
77 | } | 77 | } |
78 | 78 | ||
79 | opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); | 79 | opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); |
80 | if (! opt.isNull()) { | 80 | if (! opt.isNull()) { |
81 | specifyAp->setChecked(true); | 81 | specifyAp->setChecked(true); |
82 | macEdit->setText(opt); | 82 | macEdit->setText(opt); |
83 | } | 83 | } |
84 | 84 | ||
85 | opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); | 85 | opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); |
86 | if (! opt.isNull()) { | 86 | if (! opt.isNull()) { |
87 | specifyChan->setChecked(true); | 87 | specifyChan->setChecked(true); |
88 | networkChannel->setValue(opt.toInt()); | 88 | networkChannel->setValue(opt.toInt()); |
89 | } | 89 | } |
90 | 90 | ||
91 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); | 91 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); |
92 | if (opt.isNull()) | 92 | if (opt.isNull()) |
93 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); | 93 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); |
94 | parseKeyStr(opt); | 94 | parseKeyStr(opt); |
95 | } | 95 | } |
96 | 96 | ||
97 | void WLANImp::parseKeyStr(QString keystr) { | 97 | void WLANImp::parseKeyStr(QString keystr) { |
98 | int loc = 0; | 98 | int loc = 0; |
99 | int index = 1; | 99 | int index = 1; |
100 | QString key; | 100 | QString key; |
101 | QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); | 101 | QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); |
102 | int enc = -1; // encryption state | 102 | int enc = -1; // encryption state |
103 | 103 | ||
104 | for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { | 104 | for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { |
105 | if ((*it).left(3) == "off") { | 105 | if ((*it).left(3) == "off") { |
106 | // encryption disabled | 106 | // encryption disabled |
107 | enc = 0; | 107 | enc = 0; |
108 | } else if ((*it).left(2) == "on") { | 108 | } else if ((*it).left(2) == "on") { |
109 | // encryption enabled | 109 | // encryption enabled |
110 | enc = 1; | 110 | enc = 1; |
111 | } else if ((*it).left(4) == "open") { | 111 | } else if ((*it).left(4) == "open") { |
112 | // open mode, accept non encrypted packets | 112 | // open mode, accept non encrypted packets |
113 | acceptNonEnc->setChecked(true); | 113 | acceptNonEnc->setChecked(true); |
114 | } else if ((*it).left(10) == "restricted") { | 114 | } else if ((*it).left(10) == "restricted") { |
115 | // restricted mode, only accept encrypted packets | 115 | // restricted mode, only accept encrypted packets |
116 | rejectNonEnc->setChecked(true); | 116 | rejectNonEnc->setChecked(true); |
117 | } else if ((*it).left(3) == "key") { | 117 | } else if ((*it).left(3) == "key") { |
118 | // new set of options | 118 | // new set of options |
119 | } else if ((*it).left(1) == "[") { | 119 | } else if ((*it).left(1) == "[") { |
120 | index = (*it).mid(1, 1).toInt(); | 120 | index = (*it).mid(1, 1).toInt(); |
121 | // switch current key to index | 121 | // switch current key to index |
122 | switch (index) { | 122 | switch (index) { |
123 | case 1: | 123 | case 1: |
124 | keyRadio0->setChecked(true); | 124 | keyRadio0->setChecked(true); |
125 | break; | 125 | break; |
126 | case 2: | 126 | case 2: |
127 | keyRadio1->setChecked(true); | 127 | keyRadio1->setChecked(true); |
128 | break; | 128 | break; |
129 | case 3: | 129 | case 3: |
130 | keyRadio2->setChecked(true); | 130 | keyRadio2->setChecked(true); |
131 | break; | 131 | break; |
132 | case 4: | 132 | case 4: |
133 | keyRadio3->setChecked(true); | 133 | keyRadio3->setChecked(true); |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | } else { | 136 | } else { |
137 | // key | 137 | // key |
138 | key = (*it); | 138 | key = (*it); |
139 | } | 139 | } |
140 | if (! key.isNull()) { | 140 | if (! key.isNull()) { |
141 | if (enc == -1) | 141 | if (enc == -1) |
142 | enc = 1; | 142 | enc = 1; |
143 | QStringList::Iterator next = ++it; | 143 | QStringList::Iterator next = ++it; |
144 | if (it == keys.end()) { | 144 | if (it == keys.end()) { |
145 | break; | 145 | break; |
146 | } | 146 | } |
147 | if ((*(next)).left(1) == "[") { | 147 | if ((*(next)).left(1) == "[") { |
148 | // set key at index | 148 | // set key at index |
149 | index = (*(next)).mid(1, 1).toInt(); | 149 | index = (*(next)).mid(1, 1).toInt(); |
150 | } else { | 150 | } else { |
151 | index = 1; | 151 | index = 1; |
152 | } | 152 | } |
153 | switch (index) { | 153 | switch (index) { |
154 | case 1: | 154 | case 1: |
155 | keyLineEdit0->setText(key); | 155 | keyLineEdit0->setText(key); |
156 | break; | 156 | break; |
157 | case 2: | 157 | case 2: |
158 | keyLineEdit1->setText(key); | 158 | keyLineEdit1->setText(key); |
159 | break; | 159 | break; |
160 | case 3: | 160 | case 3: |
161 | keyLineEdit2->setText(key); | 161 | keyLineEdit2->setText(key); |
162 | break; | 162 | break; |
163 | case 4: | 163 | case 4: |
164 | keyLineEdit3->setText(key); | 164 | keyLineEdit3->setText(key); |
165 | break; | 165 | break; |
166 | } | 166 | } |
167 | key = QString::null; | 167 | key = QString::null; |
168 | } | 168 | } |
169 | } | 169 | } |
170 | if (enc == 1) { | 170 | if (enc == 1) { |
171 | wepEnabled->setChecked(true); | 171 | wepEnabled->setChecked(true); |
172 | } else { | 172 | } else { |
173 | wepEnabled->setChecked(false); | 173 | wepEnabled->setChecked(false); |
174 | } | 174 | } |
175 | } | 175 | } |
176 | 176 | ||
177 | /** | 177 | /** |
178 | * Check to see if the current config is valid | 178 | * Check to see if the current config is valid |
179 | * Save interfaces | 179 | * Save interfaces |
180 | */ | 180 | */ |
181 | void WLANImp::accept() { | 181 | void WLANImp::accept() { |
182 | if (wepEnabled->isChecked()) { | 182 | if (wepEnabled->isChecked()) { |
183 | if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) || | 183 | if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) || |
184 | (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) || | 184 | (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) || |
185 | (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) || | 185 | (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) || |
186 | (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { | 186 | (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { |
187 | QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); | 187 | QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); |
188 | return; | 188 | return; |
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
192 | if (essid->currentText().isEmpty()) { | 192 | if (essid->currentText().isEmpty()) { |
193 | QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); | 193 | QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); |
194 | return; | 194 | return; |
195 | } | 195 | } |
196 | 196 | ||
197 | if (specifyAp->isChecked() && macEdit->text().isEmpty()) { | 197 | if (specifyAp->isChecked() && macEdit->text().isEmpty()) { |
198 | QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok); | 198 | QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok); |
199 | return; | 199 | return; |
200 | } | 200 | } |
201 | 201 | ||
202 | // Try to save the interfaces settings. | 202 | // Try to save the interfaces settings. |
203 | writeOpts(); | 203 | writeOpts(); |
204 | 204 | ||
205 | // Close out the dialog | 205 | // Close out the dialog |
206 | QDialog::accept(); | 206 | QDialog::accept(); |
207 | } | 207 | } |
208 | 208 | ||
209 | void WLANImp::writeOpts() { | 209 | void WLANImp::writeOpts() { |
210 | bool error = false; | 210 | bool error = false; |
211 | 211 | ||
212 | interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); | 212 | interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); |
213 | interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); | 213 | interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); |
214 | 214 | ||
215 | if (specifyAp->isChecked()) { | 215 | if (specifyAp->isChecked()) { |
216 | interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text()); | 216 | interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text()); |
217 | } else { | 217 | } else { |
218 | interfaces->removeInterfaceOption(QString("wireless_ap")); | 218 | interfaces->removeInterfaceOption(QString("wireless_ap")); |
219 | } | 219 | } |
220 | 220 | ||
221 | if (specifyChan->isChecked()) { | 221 | if (specifyChan->isChecked()) { |
222 | interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text()); | 222 | interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text()); |
223 | } else { | 223 | } else { |
224 | interfaces->removeInterfaceOption(QString("wireless_channel")); | 224 | interfaces->removeInterfaceOption(QString("wireless_channel")); |
225 | } | 225 | } |
226 | 226 | ||
227 | if (wepEnabled->isChecked()) { | 227 | if (wepEnabled->isChecked()) { |
228 | QStringList keyList; | 228 | QStringList keyList; |
229 | 229 | ||
230 | if (! keyLineEdit0->text().isNull()) { | 230 | if (! keyLineEdit0->text().isNull()) { |
231 | keyList += keyLineEdit0->text(); | 231 | keyList += keyLineEdit0->text(); |
232 | keyList += "[1]"; | 232 | keyList += "[1]"; |
233 | } else if (! keyLineEdit1->text().isNull()) { | 233 | } else if (! keyLineEdit1->text().isNull()) { |
234 | keyList += keyLineEdit1->text(); | 234 | keyList += keyLineEdit1->text(); |
235 | keyList += "[2]"; | 235 | keyList += "[2]"; |
236 | } else if (! keyLineEdit2->text().isNull()) { | 236 | } else if (! keyLineEdit2->text().isNull()) { |
237 | keyList += keyLineEdit2->text(); | 237 | keyList += keyLineEdit2->text(); |
238 | keyList += "[3]"; | 238 | keyList += "[3]"; |
239 | } else if (! keyLineEdit3->text().isNull()) { | 239 | } else if (! keyLineEdit3->text().isNull()) { |
240 | keyList += keyLineEdit3->text(); | 240 | keyList += keyLineEdit3->text(); |
241 | keyList += "[4]"; | 241 | keyList += "[4]"; |
242 | } | 242 | } |
243 | if (acceptNonEnc->isChecked()) { | 243 | if (acceptNonEnc->isChecked()) { |
244 | keyList += "open"; | 244 | keyList += "open"; |
245 | } else { | 245 | } else { |
246 | keyList += "restricted"; | 246 | keyList += "restricted"; |
247 | } | 247 | } |
248 | 248 | ||
249 | keyList += "key"; | 249 | keyList += "key"; |
250 | if (keyRadio0->isChecked()) { | 250 | if (keyRadio0->isChecked()) { |
251 | keyList += "[1]"; | 251 | keyList += "[1]"; |
252 | } else if (keyRadio1->isChecked()) { | 252 | } else if (keyRadio1->isChecked()) { |
253 | keyList += "[2]"; | 253 | keyList += "[2]"; |
254 | } else if (keyRadio2->isChecked()) { | 254 | } else if (keyRadio2->isChecked()) { |
255 | keyList += "[3]"; | 255 | keyList += "[3]"; |
256 | } else if (keyRadio3->isChecked()) { | 256 | } else if (keyRadio3->isChecked()) { |
257 | keyList += "[4]"; | 257 | keyList += "[4]"; |
258 | } | 258 | } |
259 | interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" "))); | 259 | interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" "))); |
260 | } else { | 260 | } else { |
261 | interfaces->removeInterfaceOption(QString("wireless_key")); | 261 | interfaces->removeInterfaceOption(QString("wireless_key")); |
262 | } | 262 | } |
263 | interfaces->removeInterfaceOption(QString("wireless_enc")); | 263 | interfaces->removeInterfaceOption(QString("wireless_enc")); |
264 | 264 | ||
265 | if(!interfaceSetup->saveChanges()) | 265 | if(!interfaceSetup->saveChanges()) |
266 | return; | 266 | return; |
267 | 267 | ||
268 | QDialog::accept(); | 268 | QDialog::accept(); |
269 | } | 269 | } |
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp index e6f082c..bc467bb 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.cpp +++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp | |||
@@ -1,187 +1,209 @@ | |||
1 | #include "wlanmodule.h" | 1 | #include "wlanmodule.h" |
2 | #include "wlanimp.h" | 2 | #include "wlanimp.h" |
3 | #include "infoimp.h" | 3 | #include "infoimp.h" |
4 | #include "wextensions.h" | 4 | #include "wextensions.h" |
5 | #include "interfaceinformationimp.h" | 5 | #include "interfaceinformationimp.h" |
6 | 6 | ||
7 | #include <qcheckbox.h> | ||
8 | #include <qcombobox.h> | ||
7 | #include <qlabel.h> | 9 | #include <qlabel.h> |
8 | #include <qprogressbar.h> | 10 | #include <qprogressbar.h> |
11 | #include <qspinbox.h> | ||
9 | #include <qtabwidget.h> | 12 | #include <qtabwidget.h> |
10 | 13 | ||
11 | 14 | ||
12 | 15 | ||
13 | 16 | ||
14 | /** | 17 | /** |
15 | * Constructor, find all of the possible interfaces | 18 | * Constructor, find all of the possible interfaces |
16 | */ | 19 | */ |
17 | WLANModule::WLANModule() : Module() { | 20 | WLANModule::WLANModule() |
21 | : Module(), | ||
22 | wlanconfigWiget(0) | ||
23 | { | ||
18 | } | 24 | } |
19 | 25 | ||
20 | /** | 26 | /** |
21 | * Delete any interfaces that we own. | 27 | * Delete any interfaces that we own. |
22 | */ | 28 | */ |
23 | WLANModule::~WLANModule(){ | 29 | WLANModule::~WLANModule(){ |
24 | Interface *i; | 30 | Interface *i; |
25 | for ( i=list.first(); i != 0; i=list.next() ) | 31 | for ( i=list.first(); i != 0; i=list.next() ) |
26 | delete i; | 32 | delete i; |
27 | 33 | ||
28 | } | 34 | } |
29 | 35 | ||
30 | /** | 36 | /** |
31 | * Change the current profile | 37 | * Change the current profile |
32 | */ | 38 | */ |
33 | void WLANModule::setProfile(const QString &newProfile){ | 39 | void WLANModule::setProfile(const QString &newProfile){ |
34 | profile = newProfile; | 40 | profile = newProfile; |
35 | } | 41 | } |
36 | 42 | ||
37 | /** | 43 | /** |
38 | * get the icon name for this device. | 44 | * get the icon name for this device. |
39 | * @param Interface* can be used in determining the icon. | 45 | * @param Interface* can be used in determining the icon. |
40 | * @return QString the icon name (minus .png, .gif etc) | 46 | * @return QString the icon name (minus .png, .gif etc) |
41 | */ | 47 | */ |
42 | QString WLANModule::getPixmapName(Interface* ){ | 48 | QString WLANModule::getPixmapName(Interface* ){ |
43 | return "wlan"; | 49 | return "wlan"; |
44 | } | 50 | } |
45 | 51 | ||
46 | /** | 52 | /** |
47 | * Check to see if the interface i is owned by this module. | 53 | * Check to see if the interface i is owned by this module. |
48 | * @param Interface* interface to check against | 54 | * @param Interface* interface to check against |
49 | * @return bool true if i is owned by this module, false otherwise. | 55 | * @return bool true if i is owned by this module, false otherwise. |
50 | */ | 56 | */ |
51 | bool WLANModule::isOwner(Interface *i){ | 57 | bool WLANModule::isOwner(Interface *i){ |
52 | WExtensions we(i->getInterfaceName()); | 58 | WExtensions we(i->getInterfaceName()); |
53 | if(!we.doesHaveWirelessExtensions()) | 59 | if(!we.doesHaveWirelessExtensions()) |
54 | return false; | 60 | return false; |
55 | 61 | ||
56 | i->setHardwareName("802.11b"); | 62 | i->setHardwareName("802.11b"); |
57 | list.append(i); | 63 | list.append(i); |
58 | return true; | 64 | return true; |
59 | } | 65 | } |
60 | 66 | ||
61 | /** | 67 | /** |
62 | * Create, and return the WLANConfigure Module | 68 | * Create, and return the WLANConfigure Module |
63 | * @return QWidget* pointer to this modules configure. | 69 | * @return QWidget* pointer to this modules configure. |
64 | */ | 70 | */ |
65 | QWidget *WLANModule::configure(Interface *i){ | 71 | QWidget *WLANModule::configure(Interface *i){ |
66 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose); | 72 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose); |
67 | wlanconfig->setProfile(profile); | 73 | wlanconfig->setProfile(profile); |
68 | return wlanconfig; | 74 | return wlanconfig; |
69 | } | 75 | } |
70 | 76 | ||
71 | /** | 77 | /** |
72 | * Create, and return the Information Module | 78 | * Create, and return the Information Module |
73 | * @return QWidget* pointer to this modules info. | 79 | * @return QWidget* pointer to this modules info. |
74 | */ | 80 | */ |
75 | QWidget *WLANModule::information(Interface *i){ | 81 | QWidget *WLANModule::information(Interface *i){ |
76 | WExtensions we(i->getInterfaceName()); | 82 | WExtensions we(i->getInterfaceName()); |
77 | if(!we.doesHaveWirelessExtensions()) | 83 | if(!we.doesHaveWirelessExtensions()) |
78 | return NULL; | 84 | return NULL; |
79 | 85 | ||
80 | return getInfo( i ); | 86 | return getInfo( i ); |
81 | } | 87 | } |
82 | 88 | ||
83 | /** | 89 | /** |
84 | * Get all active (up or down) interfaces | 90 | * Get all active (up or down) interfaces |
85 | * @return QList<Interface> A list of interfaces that exsist that havn't | 91 | * @return QList<Interface> A list of interfaces that exsist that havn't |
86 | * been called by isOwner() | 92 | * been called by isOwner() |
87 | */ | 93 | */ |
88 | QList<Interface> WLANModule::getInterfaces(){ | 94 | QList<Interface> WLANModule::getInterfaces(){ |
89 | return list; | 95 | return list; |
90 | } | 96 | } |
91 | 97 | ||
92 | /** | 98 | /** |
93 | * Attempt to add a new interface as defined by name | 99 | * Attempt to add a new interface as defined by name |
94 | * @param name the name of the type of interface that should be created given | 100 | * @param name the name of the type of interface that should be created given |
95 | * by possibleNewInterfaces(); | 101 | * by possibleNewInterfaces(); |
96 | * @return Interface* NULL if it was unable to be created. | 102 | * @return Interface* NULL if it was unable to be created. |
97 | */ | 103 | */ |
98 | Interface *WLANModule::addNewInterface(const QString &){ | 104 | Interface *WLANModule::addNewInterface(const QString &){ |
99 | // We can't add a 802.11 interface, either the hardware will be there | 105 | // We can't add a 802.11 interface, either the hardware will be there |
100 | // or it wont. | 106 | // or it wont. |
101 | return NULL; | 107 | return NULL; |
102 | } | 108 | } |
103 | 109 | ||
104 | /** | 110 | /** |
105 | * Attempts to remove the interface, doesn't delete i | 111 | * Attempts to remove the interface, doesn't delete i |
106 | * @return bool true if successfull, false otherwise. | 112 | * @return bool true if successfull, false otherwise. |
107 | */ | 113 | */ |
108 | bool WLANModule::remove(Interface*){ | 114 | bool WLANModule::remove(Interface*){ |
109 | // Can't remove a hardware device, you can stop it though. | 115 | // Can't remove a hardware device, you can stop it though. |
110 | return false; | 116 | return false; |
111 | } | 117 | } |
112 | 118 | ||
113 | void WLANModule::receive(const QCString ¶m, const QByteArray &arg) | 119 | void WLANModule::receive(const QCString ¶m, const QByteArray &arg) |
114 | { | 120 | { |
115 | qDebug("WLANModule::receive "+param); | 121 | qDebug("WLANModule::receive "+param); |
116 | QStringList params = QStringList::split(",",param); | 122 | QStringList params = QStringList::split(",",param); |
117 | int count = params.count(); | 123 | int count = params.count(); |
118 | qDebug("got %i params", count ); | 124 | qDebug("WLANModule got %i params", count ); |
119 | if (count < 2){ | 125 | if (count < 2){ |
120 | qDebug("Erorr less than 2 parameter"); | 126 | qDebug("Erorr less than 2 parameter"); |
121 | qDebug("RETURNING"); | 127 | qDebug("RETURNING"); |
122 | return; | 128 | return; |
123 | } | 129 | } |
124 | 130 | ||
125 | QDataStream stream(arg,IO_ReadOnly); | 131 | QDataStream stream(arg,IO_ReadOnly); |
126 | QString interface; | 132 | QString interface; |
127 | QString action; | 133 | QString action; |
128 | 134 | ||
129 | stream >> interface; | 135 | stream >> interface; |
130 | stream >> action; | 136 | stream >> action; |
131 | qDebug("got interface %s and acion %s", interface.latin1(), action.latin1()); | 137 | qDebug("WLANModule got interface %s and acion %s", interface.latin1(), action.latin1()); |
132 | // find interfaces | 138 | // find interfaces |
133 | Interface *ifa=0; | 139 | Interface *ifa=0; |
134 | for ( Interface *i=list.first(); i != 0; i=list.next() ){ | 140 | for ( Interface *i=list.first(); i != 0; i=list.next() ){ |
135 | if (i->getInterfaceName() == interface){ | 141 | if (i->getInterfaceName() == interface){ |
136 | qDebug("found interface %s",interface.latin1()); | 142 | qDebug("WLANModule found interface %s",interface.latin1()); |
137 | ifa = i; | 143 | ifa = i; |
138 | } | 144 | } |
139 | } | 145 | } |
140 | 146 | ||
141 | if (ifa == 0){ | 147 | if (ifa == 0){ |
142 | qFatal("Did not find %s",interface.latin1()); | 148 | qFatal("WLANModule Did not find %s",interface.latin1()); |
143 | } | 149 | } |
144 | 150 | ||
145 | if (count == 2){ | 151 | if (count == 2){ |
146 | // those should call the interface directly | 152 | // those should call the interface directly |
147 | QWidget *info = getInfo( ifa ); | 153 | QWidget *info = getInfo( ifa ); |
148 | info->showMaximized(); | 154 | info->showMaximized(); |
149 | 155 | ||
150 | if ( action.contains("start" ) ){ | 156 | if ( action.contains("start" ) ){ |
151 | ifa->start(); | 157 | ifa->start(); |
152 | } else if ( action.contains("restart" ) ){ | 158 | } else if ( action.contains("restart" ) ){ |
153 | ifa->restart(); | 159 | ifa->restart(); |
154 | } else if ( action.contains("stop" ) ){ | 160 | } else if ( action.contains("stop" ) ){ |
155 | ifa->stop(); | 161 | ifa->stop(); |
156 | }else if ( action.contains("refresh" ) ){ | 162 | }else if ( action.contains("refresh" ) ){ |
157 | ifa->refresh(); | 163 | ifa->refresh(); |
158 | } | 164 | } |
159 | }else if (count == 3){ | 165 | }else if (count == 3){ |
160 | QString value; | 166 | QString value; |
167 | if (!wlanconfigWiget){ | ||
168 | //FIXME: what if it got closed meanwhile? | ||
169 | wlanconfigWiget = (WLANImp*) configure(ifa); | ||
170 | } | ||
171 | wlanconfigWiget->showMaximized(); | ||
161 | stream >> value; | 172 | stream >> value; |
162 | qDebug("setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() ); | 173 | qDebug("WLANModule is setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() ); |
163 | if ( action.contains("ESSID") ){ | 174 | if ( action.contains("ESSID") ){ |
164 | qDebug("Setting ESSID not yet impl"); | 175 | QComboBox *combo = wlanconfigWiget->essid; |
176 | bool found = false; | ||
177 | for ( int i = 0; i < combo->count(); i++) | ||
178 | if ( combo->text( i ) == value ){ | ||
179 | combo->setCurrentItem( i ); | ||
180 | found = true; | ||
181 | } | ||
182 | if (!found) combo->insertItem( value, 0 ); | ||
183 | }else if ( action.contains("Mode") ){ | ||
184 | QComboBox *combo = wlanconfigWiget->mode; | ||
185 | for ( int i = 0; i < combo->count(); i++) | ||
186 | if ( combo->text( i ) == value ){ | ||
187 | combo->setCurrentItem( i ); | ||
188 | } | ||
189 | |||
165 | }else if (action.contains("Channel")){ | 190 | }else if (action.contains("Channel")){ |
166 | qDebug("Setting Channel not yet impl"); | 191 | wlanconfigWiget->specifyChan->setChecked( true ); |
192 | wlanconfigWiget->networkChannel->setValue( value.toInt() ); | ||
167 | }else | 193 | }else |
168 | qDebug("wlan plugin has no clue"); | 194 | qDebug("wlan plugin has no clue"); |
169 | } | 195 | } |
170 | // if (param.contains("QString,QString,QString")) { | 196 | |
171 | // QDataStream stream(arg,IO_ReadOnly); | ||
172 | // QString arg1, arg2, arg3; | ||
173 | // stream >> arg1 >> arg2 >> arg3 ; | ||
174 | // qDebug("interface >%s< setting >%s< value >%s<",arg1.latin1(),arg2.latin1(),arg3.latin1()); | ||
175 | // } | ||
176 | } | 197 | } |
177 | 198 | ||
178 | QWidget *WLANModule::getInfo( Interface *i) | 199 | QWidget *WLANModule::getInfo( Interface *i) |
179 | { | 200 | { |
180 | qDebug("WLANModule::getInfo start"); | 201 | qDebug("WLANModule::getInfo start"); |
181 | WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); | 202 | WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); |
182 | InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); | 203 | InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); |
183 | info->tabWidget->insertTab(information, "TCP/IP", 0); | 204 | info->tabWidget->insertTab(information, "TCP/IP", 0); |
184 | 205 | ||
185 | qDebug("WLANModule::getInfo return"); | 206 | qDebug("WLANModule::getInfo return"); |
186 | return info; | 207 | return info; |
187 | } | 208 | } |
209 | |||
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.h b/noncore/settings/networksettings/wlan/wlanmodule.h index 0963137..027ecec 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.h +++ b/noncore/settings/networksettings/wlan/wlanmodule.h | |||
@@ -1,49 +1,48 @@ | |||
1 | #ifndef WLAN_MODULE_H | 1 | #ifndef WLAN_MODULE_H |
2 | #define WLAN_MODULE_H | 2 | #define WLAN_MODULE_H |
3 | 3 | ||
4 | #include "module.h" | 4 | #include "module.h" |
5 | 5 | ||
6 | //class WlanInfoImp; | 6 | class WLANImp; |
7 | 7 | ||
8 | class WLANModule : Module{ | 8 | class WLANModule : Module{ |
9 | 9 | ||
10 | signals: | 10 | signals: |
11 | void updateInterface(Interface *i); | 11 | void updateInterface(Interface *i); |
12 | 12 | ||
13 | public: | 13 | public: |
14 | WLANModule(); | 14 | WLANModule(); |
15 | ~WLANModule(); | 15 | ~WLANModule(); |
16 | 16 | ||
17 | 17 | ||
18 | virtual const QString type() {return "wlan";}; | 18 | virtual const QString type() {return "wlan";}; |
19 | void setProfile(const QString &newProfile); | 19 | void setProfile(const QString &newProfile); |
20 | bool isOwner(Interface *); | 20 | bool isOwner(Interface *); |
21 | QWidget *configure(Interface *i); | 21 | QWidget *configure(Interface *i); |
22 | QWidget *information(Interface *i); | 22 | QWidget *information(Interface *i); |
23 | QList<Interface> getInterfaces(); | 23 | QList<Interface> getInterfaces(); |
24 | void possibleNewInterfaces(QMap<QString, QString> &){}; | 24 | void possibleNewInterfaces(QMap<QString, QString> &){}; |
25 | Interface *addNewInterface(const QString &name); | 25 | Interface *addNewInterface(const QString &name); |
26 | bool remove(Interface* i); | 26 | bool remove(Interface* i); |
27 | QString getPixmapName(Interface* i); | 27 | QString getPixmapName(Interface* i); |
28 | virtual void receive(const QCString&, const QByteArray&); | 28 | virtual void receive(const QCString&, const QByteArray&); |
29 | 29 | ||
30 | private: | 30 | private: |
31 | QWidget *getInfo(Interface*); | 31 | QWidget *getInfo(Interface*); |
32 | 32 | WLANImp *wlanconfigWiget; | |
33 | QList<Interface> list; | 33 | QList<Interface> list; |
34 | QString profile; | 34 | QString profile; |
35 | // WlanInfoImp *info; | 35 | |
36 | // Interface *iface; | ||
37 | }; | 36 | }; |
38 | 37 | ||
39 | extern "C" | 38 | extern "C" |
40 | { | 39 | { |
41 | void* create_plugin() { | 40 | void* create_plugin() { |
42 | return new WLANModule(); | 41 | return new WLANModule(); |
43 | } | 42 | } |
44 | }; | 43 | }; |
45 | 44 | ||
46 | #endif | 45 | #endif |
47 | 46 | ||
48 | // wlanmodule.h | 47 | // wlanmodule.h |
49 | 48 | ||