summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindow/mainwindowimp.cpp20
-rw-r--r--noncore/settings/networksettings/ppp/edit.cpp10
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.cpp4
3 files changed, 15 insertions, 19 deletions
diff --git a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
index a7b0bdc..650e634 100644
--- a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
@@ -1,81 +1,82 @@
1 1
2#include "mainwindowimp.h" 2#include "mainwindowimp.h"
3#include "addconnectionimp.h" 3#include "addconnectionimp.h"
4#include "interfaceinformationimp.h" 4#include "interfaceinformationimp.h"
5#include "interfacesetupimp.h" 5#include "interfacesetupimp.h"
6#include "interfaces.h" 6#include "interfaces.h"
7#include "module.h" 7#include "module.h"
8 8
9/* OPIE */ 9/* OPIE */
10#include <opie2/odebug.h> 10#include <opie2/odebug.h>
11#include <opie2/oprocess.h> 11#include <opie2/oprocess.h>
12#include <opie2/oresource.h>
13
12#include <qpe/applnk.h> 14#include <qpe/applnk.h>
13#include <qpe/qcopenvelope_qws.h> 15#include <qpe/qcopenvelope_qws.h>
14#include <qpe/qpeapplication.h> 16#include <qpe/qpeapplication.h>
15#include <qpe/config.h> 17#include <qpe/config.h>
16#include <qpe/qlibrary.h> 18#include <qpe/qlibrary.h>
17#include <qpe/resource.h>
18 19
19/* QT */ 20/* QT */
20#include <qpushbutton.h> 21#include <qpushbutton.h>
21#include <qlistbox.h> 22#include <qlistbox.h>
22#include <qlineedit.h> 23#include <qlineedit.h>
23#include <qlistview.h> 24#include <qlistview.h>
24#include <qheader.h> 25#include <qheader.h>
25#include <qlabel.h> 26#include <qlabel.h>
26#include <qtabwidget.h> // in order to disable the profiles tab 27#include <qtabwidget.h> // in order to disable the profiles tab
27#include <qmessagebox.h> 28#include <qmessagebox.h>
28#include <qtextstream.h> 29#include <qtextstream.h>
29#include <qregexp.h> 30#include <qregexp.h>
30 31
31 32
32#if QT_VERSION < 0x030000 33#if QT_VERSION < 0x030000
33#include <qlist.h> 34#include <qlist.h>
34#else 35#else
35#include <qptrlist.h> 36#include <qptrlist.h>
36#endif 37#endif
37#include <qdir.h> 38#include <qdir.h>
38#include <qfile.h> 39#include <qfile.h>
39#include <qtextstream.h> 40#include <qtextstream.h>
40#include <qregexp.h> 41#include <qregexp.h>
41 42
42/* STD */ 43/* STD */
43#include <net/if.h> 44#include <net/if.h>
44#include <sys/ioctl.h> 45#include <sys/ioctl.h>
45#include <sys/socket.h> 46#include <sys/socket.h>
46 47
47#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" 48#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
48#define _PROCNETDEV "/proc/net/dev" 49#define _PROCNETDEV "/proc/net/dev"
49 50
50// is this always right? 51// is this always right?
51#define _HOSTFILE "/etc/hostname" 52#define _HOSTFILE "/etc/hostname"
52#define _IRDANAME "/proc/sys/net/irda/devname" 53#define _IRDANAME "/proc/sys/net/irda/devname"
53 54
54using namespace Opie::Core; 55using namespace Opie::Core;
55 56
56MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME) 57MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME)
57{ 58{
58 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 59 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
59 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 60 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
60 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 61 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
61 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 62 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
62 63
63 //remove tab with no function 64 //remove tab with no function
64 tabWidget->removePage( tab ); 65 tabWidget->removePage( tab );
65 66
66 // Load connections. 67 // Load connections.
67 // /usr/local/kde/lib/libinterfaces.la 68 // /usr/local/kde/lib/libinterfaces.la
68 loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); 69 loadModules(QPEApplication::qpeDir() + "plugins/networksettings");
69 getAllInterfaces(); 70 getAllInterfaces();
70 71
71 Interfaces i; 72 Interfaces i;
72 QStringList list = i.getInterfaceList(); 73 QStringList list = i.getInterfaceList();
73 QMap<QString, Interface*>::Iterator it; 74 QMap<QString, Interface*>::Iterator it;
74 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) 75 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni )
75 { 76 {
76 /* 77 /*
77 * we skipped it in getAllInterfaces now 78 * we skipped it in getAllInterfaces now
78 * we need to ignore it as well 79 * we need to ignore it as well
79 */ 80 */
80 if (m_handledIfaces.contains( *ni) ) 81 if (m_handledIfaces.contains( *ni) )
81 { 82 {
@@ -471,157 +472,148 @@ void MainWindowImp::configureClicked()
471 */ 472 */
472void MainWindowImp::informationClicked() 473void MainWindowImp::informationClicked()
473{ 474{
474 QListViewItem *item = connectionList->currentItem(); 475 QListViewItem *item = connectionList->currentItem();
475 if(!item) 476 if(!item)
476 { 477 {
477 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); 478 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
478 return; 479 return;
479 } 480 }
480 481
481 Interface *i = interfaceItems[item]; 482 Interface *i = interfaceItems[item];
482 // if(!i->isAttached()){ 483 // if(!i->isAttached()){
483 // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); 484 // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok);
484 // return; 485 // return;
485 // } 486 // }
486 487
487 if(i->getModuleOwner()) 488 if(i->getModuleOwner())
488 { 489 {
489 QWidget *moduleInformation = i->getModuleOwner()->information(i); 490 QWidget *moduleInformation = i->getModuleOwner()->information(i);
490 if(moduleInformation != NULL) 491 if(moduleInformation != NULL)
491 { 492 {
492 QPEApplication::showWidget( moduleInformation ); 493 QPEApplication::showWidget( moduleInformation );
493#ifdef DEBUG 494#ifdef DEBUG
494 odebug << "MainWindowImp::informationClicked:: Module owner has created, we showed." << oendl; 495 odebug << "MainWindowImp::informationClicked:: Module owner has created, we showed." << oendl;
495#endif 496#endif
496 return; 497 return;
497 } 498 }
498 } 499 }
499 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp); 500 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp);
500 QPEApplication::showWidget( information ); 501 QPEApplication::showWidget( information );
501} 502}
502 503
503/** 504/**
504 * Update this interface. If no QListViewItem exists create one. 505 * Update this interface. If no QListViewItem exists create one.
505 * @param Interface* pointer to the interface that needs to be updated. 506 * @param Interface* pointer to the interface that needs to be updated.
506 */ 507 */
507void MainWindowImp::updateInterface(Interface *i) 508void MainWindowImp::updateInterface(Interface *i)
508{ 509{
509 if(!advancedUserMode) 510 if(!advancedUserMode)
510 { 511 {
511 if(i->getInterfaceName() == "lo") 512 if(i->getInterfaceName() == "lo")
512 return; 513 return;
513 } 514 }
514 515
515 QListViewItem *item = NULL; 516 QListViewItem *item = NULL;
516 517
517 // Find the interface, making it if needed. 518 // Find the interface, making it if needed.
518 if(items.find(i) == items.end()) 519 if(items.find(i) == items.end())
519 { 520 {
520 item = new QListViewItem(connectionList, "", "", ""); 521 item = new QListViewItem(connectionList, "", "", "");
521 // See if you can't find a module owner for this interface 522 // See if you can't find a module owner for this interface
522 QMap<Module*, QLibrary*>::Iterator it; 523 QMap<Module*, QLibrary*>::Iterator it;
523 for( it = libraries.begin(); it != libraries.end(); ++it ) 524 for( it = libraries.begin(); it != libraries.end(); ++it )
524 { 525 {
525 if(it.key()->isOwner(i)) 526 if(it.key()->isOwner(i))
526 i->setModuleOwner(it.key()); 527 i->setModuleOwner(it.key());
527 } 528 }
528 items.insert(i, item); 529 items.insert(i, item);
529 interfaceItems.insert(item, i); 530 interfaceItems.insert(item, i);
530 } 531 }
531 else 532 else
532 item = items[i]; 533 item = items[i];
533 534
534 // Update the icons and information 535 // Update the icons and information
535#ifdef QWS 536 item->setPixmap( 0, Opie::Core::OResource::loadPixmap( i->getStatus() ? "up" : "down", Opie::Core::OResource::SmallIcon ) );
536 QPixmap pic;
537 pic.convertFromImage( Resource::loadImage( i->getStatus() ? "up": "down" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
538 item->setPixmap(0, ( pic ));
539#else
540 item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down")));
541#endif
542 537
543 QString typeName = "lan"; 538 QString typeName = "lan";
544 if(i->getInterfaceName() == "lo") 539 if(i->getInterfaceName() == "lo")
545 typeName = "lo"; 540 typeName = "lo";
546 if(i->getInterfaceName().contains("irda")) 541 if(i->getInterfaceName().contains("irda"))
547 typeName = "irda"; 542 typeName = "irda";
548 if(i->getInterfaceName().contains("wlan")) 543 if(i->getInterfaceName().contains("wlan"))
549 typeName = "wlan"; 544 typeName = "wlan";
550 if(i->getInterfaceName().contains("usb")) 545 if(i->getInterfaceName().contains("usb"))
551 typeName = "usb"; 546 typeName = "usb";
552 547
553 if(!i->isAttached()) 548 if(!i->isAttached())
554 typeName = "connect_no"; 549 typeName = "connect_no";
555 // Actually try to use the Module 550 // Actually try to use the Module
556 if(i->getModuleOwner() != NULL) 551 if(i->getModuleOwner() != NULL)
557 typeName = i->getModuleOwner()->getPixmapName(i); 552 typeName = i->getModuleOwner()->getPixmapName(i);
558 553
559#ifdef QWS 554 item->setPixmap( 1, ( Opie::Core::OResource::loadPixmap( "networksettings/" + typeName, Opie::Core::OResource::SmallIcon ) ) );
560 item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); 555
561#else
562 item->setPixmap(1, (SmallIcon(typeName)));
563#endif
564 item->setText(2, i->getHardwareName()); 556 item->setText(2, i->getHardwareName());
565 item->setText(3, QString("(%1)").arg(i->getInterfaceName())); 557 item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
566 item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); 558 item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
567} 559}
568 560
569void MainWindowImp::newProfileChanged(const QString& newText) 561void MainWindowImp::newProfileChanged(const QString& newText)
570{ 562{
571 if(newText.length() > 0) 563 if(newText.length() > 0)
572 newProfileButton->setEnabled(true); 564 newProfileButton->setEnabled(true);
573 else 565 else
574 newProfileButton->setEnabled(false); 566 newProfileButton->setEnabled(false);
575} 567}
576 568
577/** 569/**
578 * Adds a new profile to the list of profiles. 570 * Adds a new profile to the list of profiles.
579 * Don't add profiles that already exists. 571 * Don't add profiles that already exists.
580 * Appends to the list and QStringList 572 * Appends to the list and QStringList
581 */ 573 */
582void MainWindowImp::addProfile() 574void MainWindowImp::addProfile()
583{ 575{
584 QString newProfileName = newProfile->text(); 576 QString newProfileName = newProfile->text();
585 if(profiles.grep(newProfileName).count() > 0) 577 if(profiles.grep(newProfileName).count() > 0)
586 { 578 {
587 QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); 579 QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok);
588 return; 580 return;
589 } 581 }
590 profiles.append(newProfileName); 582 profiles.append(newProfileName);
591 profilesList->insertItem(newProfileName); 583 profilesList->insertItem(newProfileName);
592} 584}
593 585
594/** 586/**
595 * Removes the currently selected profile in the combo. 587 * Removes the currently selected profile in the combo.
596 * Doesn't delete if there are less then 2 profiles. 588 * Doesn't delete if there are less then 2 profiles.
597 */ 589 */
598void MainWindowImp::removeProfile() 590void MainWindowImp::removeProfile()
599{ 591{
600 if(profilesList->count() <= 1) 592 if(profilesList->count() <= 1)
601 { 593 {
602 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); 594 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok);
603 return; 595 return;
604 } 596 }
605 QString profileToRemove = profilesList->currentText(); 597 QString profileToRemove = profilesList->currentText();
606 if(profileToRemove == "All") 598 if(profileToRemove == "All")
607 { 599 {
608 QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); 600 QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok);
609 return; 601 return;
610 } 602 }
611 // Can't remove the curent profile 603 // Can't remove the curent profile
612 if(profileToRemove == currentProfileLabel->text()) 604 if(profileToRemove == currentProfileLabel->text())
613 { 605 {
614 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); 606 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok);
615 return; 607 return;
616 608
617 } 609 }
618 610
619 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) 611 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
620 { 612 {
621 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); 613 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
622 profilesList->clear(); 614 profilesList->clear();
623 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 615 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
624 profilesList->insertItem((*it)); 616 profilesList->insertItem((*it));
625 617
626 // Remove any interface settings and mappings. 618 // Remove any interface settings and mappings.
627 Interfaces interfaces; 619 Interfaces interfaces;
@@ -721,73 +713,73 @@ void MainWindowImp::receive(const QCString &msg, const QByteArray &arg)
721 found = true; 713 found = true;
722 } 714 }
723 } 715 }
724 716
725 717
726 if (found) QPEApplication::setKeepRunning(); 718 if (found) QPEApplication::setKeepRunning();
727 else odebug << "Huh what do ya want" << oendl; 719 else odebug << "Huh what do ya want" << oendl;
728} 720}
729 721
730void MainWindowImp::setHostname() 722void MainWindowImp::setHostname()
731{ 723{
732 static QRegExp filter("[^A-Za-z0-9_\\-\\.]"); 724 static QRegExp filter("[^A-Za-z0-9_\\-\\.]");
733 if (filter.match(m_Nameinput->text())!=-1) { 725 if (filter.match(m_Nameinput->text())!=-1) {
734 odebug << "Wrong hostname" << oendl; 726 odebug << "Wrong hostname" << oendl;
735 QMessageBox::critical(0, tr("Sorry"), tr("This is a wrong name.<br>Please use A-Z, a-z, _, - or a single dot.")); 727 QMessageBox::critical(0, tr("Sorry"), tr("This is a wrong name.<br>Please use A-Z, a-z, _, - or a single dot."));
736 return; 728 return;
737 } 729 }
738 730
739 OProcess h; 731 OProcess h;
740 _procTemp=""; 732 _procTemp="";
741 h << "hostname" << m_Nameinput->text(); 733 h << "hostname" << m_Nameinput->text();
742 connect(&h,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(slotHostname(Opie::Core::OProcess*,char*,int))); 734 connect(&h,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(slotHostname(Opie::Core::OProcess*,char*,int)));
743 h.start(OProcess::Block,OProcess::Stderr); 735 h.start(OProcess::Block,OProcess::Stderr);
744 odebug << "Got " << _procTemp << " - " << h.exitStatus() << oendl; 736 odebug << "Got " << _procTemp << " - " << h.exitStatus() << oendl;
745 if (h.exitStatus()!=0) { 737 if (h.exitStatus()!=0) {
746 QMessageBox::critical(0, tr("Sorry"), QString(tr("Could not set name.\n%1")).arg(_procTemp.stripWhiteSpace())); 738 QMessageBox::critical(0, tr("Sorry"), QString(tr("Could not set name.\n%1")).arg(_procTemp.stripWhiteSpace()));
747 return; 739 return;
748 } 740 }
749 _procTemp=""; 741 _procTemp="";
750 742
751 QFile f(_HOSTFILE); 743 QFile f(_HOSTFILE);
752 if (f.open(IO_Truncate|IO_WriteOnly)) 744 if (f.open(IO_Truncate|IO_WriteOnly))
753 { 745 {
754 QTextStream s(&f); 746 QTextStream s(&f);
755 s << m_Nameinput->text(); 747 s << m_Nameinput->text();
756 } else { 748 } else {
757 QMessageBox::critical(0, tr("Sorry"), tr("Could not save name.")); 749 QMessageBox::critical(0, tr("Sorry"), tr("Could not save name."));
758 return; 750 return;
759 } 751 }
760 752
761 f.close(); 753 f.close();
762 f.setName(_IRDANAME); 754 f.setName(_IRDANAME);
763 if (f.open(IO_WriteOnly)) 755 if (f.open(IO_WriteOnly))
764 { 756 {
765 QTextStream s(&f); 757 QTextStream s(&f);
766 s << m_Nameinput->text(); 758 s << m_Nameinput->text();
767 } else { 759 } else {
768 QMessageBox::critical(0, tr("Sorry"), tr("Could not set infrared name.")); 760 QMessageBox::critical(0, tr("Sorry"), tr("Could not set infrared name."));
769 } 761 }
770} 762}
771 763
772void MainWindowImp::initHostname() 764void MainWindowImp::initHostname()
773{ 765{
774 OProcess h; 766 OProcess h;
775 _procTemp=""; 767 _procTemp="";
776 768
777 h << "hostname"; 769 h << "hostname";
778 connect(&h,SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)),this,SLOT(slotHostname(Opie::Core::OProcess*,char*,int))); 770 connect(&h,SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)),this,SLOT(slotHostname(Opie::Core::OProcess*,char*,int)));
779 h.start(OProcess::Block,OProcess::AllOutput); 771 h.start(OProcess::Block,OProcess::AllOutput);
780 odebug << "Got " << _procTemp <<oendl; 772 odebug << "Got " << _procTemp <<oendl;
781 m_Nameinput->setText(_procTemp.stripWhiteSpace()); 773 m_Nameinput->setText(_procTemp.stripWhiteSpace());
782 _procTemp=""; 774 _procTemp="";
783} 775}
784 776
785void MainWindowImp::slotHostname(Opie::Core::OProcess *proc, char *buffer, int buflen) 777void MainWindowImp::slotHostname(Opie::Core::OProcess */*proc*/, char *buffer, int buflen)
786{ 778{
787 if (buflen < 1 || buffer==0) return; 779 if (buflen < 1 || buffer==0) return;
788 char*_t = new char[buflen+1]; 780 char*_t = new char[buflen+1];
789 ::memset(_t,0,buflen+1); 781 ::memset(_t,0,buflen+1);
790 ::memcpy(_t,buffer,buflen); 782 ::memcpy(_t,buffer,buflen);
791 _procTemp+=_t; 783 _procTemp+=_t;
792 delete[]_t; 784 delete[]_t;
793} 785}
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp
index 6c9735c..0abf161 100644
--- a/noncore/settings/networksettings/ppp/edit.cpp
+++ b/noncore/settings/networksettings/ppp/edit.cpp
@@ -1,152 +1,156 @@
1/* 1/*
2 * kPPP: A pppd Front End for the KDE project 2 * kPPP: A pppd Front End for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * Copyright (C) 1997 Bernd Johannes Wuebben 5 * Copyright (C) 1997 Bernd Johannes Wuebben
6 * wuebben@math.cornell.edu 6 * wuebben@math.cornell.edu
7 * 7 *
8 * based on EzPPP: 8 * based on EzPPP:
9 * Copyright (C) 1997 Jay Painter 9 * Copyright (C) 1997 Jay Painter
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public 12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either 13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version. 14 * version 2 of the License, or (at your option) any later version.
15 * 15 *
16 * This program is distributed in the hope that it will be useful, 16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details. 19 * Library General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU Library General Public 21 * You should have received a copy of the GNU Library General Public
22 * License along with this program; if not, write to the Free 22 * License along with this program; if not, write to the Free
23 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 24 */
25 25
26#include "edit.h" 26#include "edit.h"
27#include "pppdata.h" 27#include "pppdata.h"
28#include "iplined.h" 28#include "iplined.h"
29#include "auth.h" 29#include "auth.h"
30 30
31/* OPIE */ 31/* OPIE */
32#include <qpe/resource.h> 32#include <opie2/oresource.h>
33
34#include <qpe/applnk.h>
33#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
34 36
35/* QT */ 37/* QT */
36#include <qlayout.h> 38#include <qlayout.h>
37#include <qmessagebox.h> 39#include <qmessagebox.h>
38#include <qwhatsthis.h> 40#include <qwhatsthis.h>
39#include <qregexp.h> 41#include <qregexp.h>
40#include <qapplication.h> 42#include <qapplication.h>
41#include <qbuttongroup.h> 43#include <qbuttongroup.h>
42#include <qvgroupbox.h> 44#include <qvgroupbox.h>
43#include <qhbox.h> 45#include <qhbox.h>
44#include <qdialog.h> 46#include <qdialog.h>
45 47
46/* STD */ 48/* STD */
47 49
48#include <string.h> 50#include <string.h>
49#include <termios.h> 51#include <termios.h>
50 52
51DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount 53DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount
52 , const char *name ) 54 , const char *name )
53 : QWidget(parent, name), _pppdata(pd) 55 : QWidget(parent, name), _pppdata(pd)
54{ 56{
55 const int GRIDROWS = 6; 57 const int GRIDROWS = 6;
56 58
57 QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 ); 59 QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );
58 60
59 connect_label = new QLabel(tr("Connection name:"), this); 61 connect_label = new QLabel(tr("Connection name:"), this);
60 tl->addWidget(connect_label, 0, 0); 62 tl->addWidget(connect_label, 0, 0);
61 63
62 connectname_l = new QLineEdit(this); 64 connectname_l = new QLineEdit(this);
63 // connectname_l->setMaxLength(ACCNAME_SIZE); 65 // connectname_l->setMaxLength(ACCNAME_SIZE);
64 tl->addWidget(connectname_l, 0, 1); 66 tl->addWidget(connectname_l, 0, 1);
65 QString tmp = tr("Type in a unique name for this connection"); 67 QString tmp = tr("Type in a unique name for this connection");
66 68
67 QWhatsThis::add(connect_label,tmp); 69 QWhatsThis::add(connect_label,tmp);
68 QWhatsThis::add(connectname_l,tmp); 70 QWhatsThis::add(connectname_l,tmp);
69 71
70 72
71 number_label = new QLabel(tr("Phone number:"), this); 73 number_label = new QLabel(tr("Phone number:"), this);
72 number_label->setAlignment(AlignTop|AlignLeft); 74 number_label->setAlignment(AlignTop|AlignLeft);
73 tl->addWidget(number_label, 1, 0); 75 tl->addWidget(number_label, 1, 0);
74 76
75 QHBoxLayout *lpn = new QHBoxLayout(5); 77 QHBoxLayout *lpn = new QHBoxLayout(5);
76 tl->addLayout(lpn, 1, 1); 78 tl->addLayout(lpn, 1, 1);
77 numbers = new QListBox(this); 79 numbers = new QListBox(this);
78 // numbers->setMinimumSize(120, 70); 80 // numbers->setMinimumSize(120, 70);
79 lpn->addWidget(numbers); 81 lpn->addWidget(numbers);
80 QVBoxLayout *lpn1 = new QVBoxLayout; 82 QVBoxLayout *lpn1 = new QVBoxLayout;
81 lpn->addLayout(lpn1); 83 lpn->addLayout(lpn1);
82 add = new QPushButton(tr("&Add..."), this); 84 add = new QPushButton(tr("&Add..."), this);
83 del = new QPushButton(tr("&Remove"), this); 85 del = new QPushButton(tr("&Remove"), this);
84 86
85 up = new QPushButton(this); 87 up = new QPushButton(this);
86 up->setPixmap( Resource::loadPixmap("up") ); 88 up->setPixmap( Opie::Core::OResource::loadPixmap("up", Opie::Core::OResource::SmallIcon) );
89 up->setMinimumHeight( AppLnk::smallIconSize()+4 );
87 down = new QPushButton(this); 90 down = new QPushButton(this);
88 down->setPixmap( Resource::loadPixmap("down") ); 91 down->setPixmap( Opie::Core::OResource::loadPixmap("down", Opie::Core::OResource::SmallIcon) );
92 down->setMinimumHeight( AppLnk::smallIconSize()+4 );
89 lpn1->addWidget(add); 93 lpn1->addWidget(add);
90 lpn1->addWidget(del); 94 lpn1->addWidget(del);
91 lpn1->addStretch(1); 95 lpn1->addStretch(1);
92 lpn1->addWidget(up); 96 lpn1->addWidget(up);
93 lpn1->addWidget(down); 97 lpn1->addWidget(down);
94 connect(add, SIGNAL(clicked()), 98 connect(add, SIGNAL(clicked()),
95 this, SLOT(addNumber())); 99 this, SLOT(addNumber()));
96 connect(del, SIGNAL(clicked()), 100 connect(del, SIGNAL(clicked()),
97 this, SLOT(delNumber())); 101 this, SLOT(delNumber()));
98 connect(up, SIGNAL(clicked()), 102 connect(up, SIGNAL(clicked()),
99 this, SLOT(upNumber())); 103 this, SLOT(upNumber()));
100 connect(down, SIGNAL(clicked()), 104 connect(down, SIGNAL(clicked()),
101 this, SLOT(downNumber())); 105 this, SLOT(downNumber()));
102 connect(numbers, SIGNAL(highlighted(int)), 106 connect(numbers, SIGNAL(highlighted(int)),
103 this, SLOT(selectionChanged(int))); 107 this, SLOT(selectionChanged(int)));
104 numbersChanged(); 108 numbersChanged();
105 109
106 tmp = tr("<p>Specifies the phone numbers to dial. You\n" 110 tmp = tr("<p>Specifies the phone numbers to dial. You\n"
107 "can supply multiple numbers here, simply\n" 111 "can supply multiple numbers here, simply\n"
108 "click on \"Add\". You can arrange the\n" 112 "click on \"Add\". You can arrange the\n"
109 "order the numbers are tried by using the\n" 113 "order the numbers are tried by using the\n"
110 "arrow buttons.\n\n" 114 "arrow buttons.\n\n"
111 "When a number is busy or fails, <i>kppp</i> will \n" 115 "When a number is busy or fails, <i>kppp</i> will \n"
112 "try the next number and so on"); 116 "try the next number and so on");
113 117
114 QWhatsThis::add(number_label,tmp); 118 QWhatsThis::add(number_label,tmp);
115 QWhatsThis::add(numbers,tmp); 119 QWhatsThis::add(numbers,tmp);
116 120
117 pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); 121 pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this);
118 connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); 122 connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton()));
119 tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); 123 tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter);
120 124
121 // Set defaults if editing an existing connection 125 // Set defaults if editing an existing connection
122 if(!isnewaccount) 126 if(!isnewaccount)
123 { 127 {
124 connectname_l->setText(_pppdata->accname()); 128 connectname_l->setText(_pppdata->accname());
125 129
126 // insert the phone numbers into the listbox 130 // insert the phone numbers into the listbox
127 QString n = _pppdata->phonenumber(); 131 QString n = _pppdata->phonenumber();
128 QString tmp = ""; 132 QString tmp = "";
129 uint idx = 0; 133 uint idx = 0;
130 while(idx != n.length()) 134 while(idx != n.length())
131 { 135 {
132 if(n[idx] == ':') 136 if(n[idx] == ':')
133 { 137 {
134 if(tmp.length() > 0) 138 if(tmp.length() > 0)
135 numbers->insertItem(tmp); 139 numbers->insertItem(tmp);
136 tmp = ""; 140 tmp = "";
137 } 141 }
138 else 142 else
139 tmp += n[idx]; 143 tmp += n[idx];
140 idx++; 144 idx++;
141 } 145 }
142 if(tmp.length() > 0) 146 if(tmp.length() > 0)
143 numbers->insertItem(tmp); 147 numbers->insertItem(tmp);
144 148
145 } 149 }
146 150
147 numbersChanged(); 151 numbersChanged();
148 tl->activate(); 152 tl->activate();
149} 153}
150 154
151bool DialWidget::save() 155bool DialWidget::save()
152{ 156{
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp
index 2fd97c3..0c18bcc 100644
--- a/noncore/settings/networksettings/wlan/wlanimp2.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp
@@ -1,79 +1,79 @@
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#include "../interfaces/interface.h" 4#include "../interfaces/interface.h"
5 5
6#include <assert.h> 6#include <assert.h>
7#include <errno.h> 7#include <errno.h>
8#include <string.h> 8#include <string.h>
9 9
10/* OPIE */ 10/* OPIE */
11#include <opie2/odebug.h> 11#include <opie2/odebug.h>
12#include <opie2/oprocess.h> 12#include <opie2/oprocess.h>
13#include <opie2/onetwork.h> 13#include <opie2/onetwork.h>
14#include <opie2/opcap.h> 14#include <opie2/opcap.h>
15#include <qpe/resource.h> 15#include <opie2/oresource.h>
16using namespace Opie::Core; 16using namespace Opie::Core;
17using namespace Opie::Net; 17using namespace Opie::Net;
18 18
19/* QT */ 19/* QT */
20#include <qapplication.h> 20#include <qapplication.h>
21#include <qfile.h> 21#include <qfile.h>
22#include <qdir.h> 22#include <qdir.h>
23#include <qdialog.h> 23#include <qdialog.h>
24#include <qtextstream.h> 24#include <qtextstream.h>
25#include <qmessagebox.h> 25#include <qmessagebox.h>
26#include <qlineedit.h> 26#include <qlineedit.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qspinbox.h> 28#include <qspinbox.h>
29#include <qradiobutton.h> 29#include <qradiobutton.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qcheckbox.h> 31#include <qcheckbox.h>
32#include <qtabwidget.h> 32#include <qtabwidget.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qlistview.h> 34#include <qlistview.h>
35#include <qvbox.h> 35#include <qvbox.h>
36#include <qprogressbar.h> 36#include <qprogressbar.h>
37 37
38/* STD */ 38/* STD */
39#include <assert.h> 39#include <assert.h>
40#include <errno.h> 40#include <errno.h>
41#include <string.h> 41#include <string.h>
42 42
43#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" 43#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts"
44#define PREUP "/etc/network/if-pre-up.d/wireless-tools" 44#define PREUP "/etc/network/if-pre-up.d/wireless-tools"
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 */
49WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { 49WLANImp::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
68WLANImp::~WLANImp() { 68WLANImp::~WLANImp() {
69//FIXME: delete interfaces; 69//FIXME: delete interfaces;
70} 70}
71 71
72/** 72/**
73 * Change the profile for both wireless settings and network settings. 73 * Change the profile for both wireless settings and network settings.
74 */ 74 */
75void WLANImp::setProfile(const QString &profile){ 75void WLANImp::setProfile(const QString &profile){
76 interfaceSetup->setProfile(profile); 76 interfaceSetup->setProfile(profile);
77 parseOpts(); 77 parseOpts();
78} 78}
79 79
@@ -541,87 +541,87 @@ void WLANImp::rescanNeighbourhood()
541 } 541 }
542 else 542 else
543 { 543 {
544 odebug << "rescanNeighbourhood(): TADAA - something came in on channel " << i << "" << oendl; 544 odebug << "rescanNeighbourhood(): TADAA - something came in on channel " << i << "" << oendl;
545 handlePacket( p ); 545 handlePacket( p );
546 } 546 }
547 } 547 }
548 548
549 cap->close(); 549 cap->close();
550 wiface->setMode( "managed" ); // TODO: use previous mode 550 wiface->setMode( "managed" ); // TODO: use previous mode
551 wiface->setPromiscuousMode( false ); 551 wiface->setPromiscuousMode( false );
552 552
553 // hide splash screen and reenable button 553 // hide splash screen and reenable button
554 splash->hide(); 554 splash->hide();
555 delete splash; 555 delete splash;
556 rescanButton->setEnabled( true ); 556 rescanButton->setEnabled( true );
557} 557}
558 558
559void WLANImp::handlePacket( OPacket* p ) 559void WLANImp::handlePacket( OPacket* p )
560{ 560{
561 561
562 // check if we received a beacon frame 562 // check if we received a beacon frame
563 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); 563 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) );
564 if ( beacon && beacon->managementType() == "Beacon" ) 564 if ( beacon && beacon->managementType() == "Beacon" )
565 { 565 {
566 566
567 QString type; 567 QString type;
568 if ( beacon->canIBSS() ) 568 if ( beacon->canIBSS() )
569 { 569 {
570 type = "adhoc"; 570 type = "adhoc";
571 } 571 }
572 else if ( beacon->canESS() ) 572 else if ( beacon->canESS() )
573 { 573 {
574 type = "managed"; 574 type = "managed";
575 } 575 }
576 else 576 else
577 { 577 {
578 owarn << "handlePacket(): invalid frame [possibly noise] detected!" << oendl; 578 owarn << "handlePacket(): invalid frame [possibly noise] detected!" << oendl;
579 return; 579 return;
580 } 580 }
581 581
582 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 582 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
583 QString essid = ssid ? ssid->ID() : QString("<unknown>"); 583 QString essid = ssid ? ssid->ID() : QString("<unknown>");
584 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 584 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
585 int channel = ds ? ds->channel() : -1; 585 int channel = ds ? ds->channel() : -1;
586 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 586 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
587 displayFoundNetwork( type, channel, essid, header->macAddress2() ); 587 displayFoundNetwork( type, channel, essid, header->macAddress2() );
588 } 588 }
589} 589}
590 590
591 591
592void WLANImp::displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac ) 592void WLANImp::displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac )
593{ 593{
594 594
595 odebug << "found network: <" << (const char*) mode << ">, chn " << channel 595 odebug << "found network: <" << (const char*) mode << ">, chn " << channel
596 << ", ssid '" << (const char*) ssid << "', mac '" << (const char*) mac.toString() << "'" << oendl; 596 << ", ssid '" << (const char*) ssid << "', mac '" << (const char*) mac.toString() << "'" << oendl;
597 597
598 QListViewItemIterator it( netView ); 598 QListViewItemIterator it( netView );
599 while ( it.current() && it.current()->text( col_ssid ) != ssid ) ++it; 599 while ( it.current() && it.current()->text( col_ssid ) != ssid ) ++it;
600 if ( !it.current() ) // ssid didn't show up yet 600 if ( !it.current() ) // ssid didn't show up yet
601 { 601 {
602 QListViewItem* item = new QListViewItem( netView, mode.left( 1 ).upper(), ssid, QString::number( channel ), mac.toString() ); 602 QListViewItem* item = new QListViewItem( netView, mode.left( 1 ).upper(), ssid, QString::number( channel ), mac.toString() );
603 QString name; 603 QString name;
604 name.sprintf( "networksettings/%s", (const char*) mode ); 604 name.sprintf( "networksettings/%s", (const char*) mode );
605 item->setPixmap( col_mode, Resource::loadPixmap( name ) ); 605 item->setPixmap( col_mode, Opie::Core::OResource::loadPixmap( name, Opie::Core::OResource::SmallIcon ) );
606 qApp->processEvents(); 606 qApp->processEvents();
607 } 607 }
608 608
609} 609}
610 610
611 611
612void WLANImp::selectNetwork( QListViewItem* item ) 612void WLANImp::selectNetwork( QListViewItem* item )
613{ 613{
614 bool ok; 614 bool ok;
615 if ( item ) 615 if ( item )
616 { 616 {
617 specifyAp->setChecked(true); 617 specifyAp->setChecked(true);
618 macEdit->setText( item->text( col_mac ) ); 618 macEdit->setText( item->text( col_mac ) );
619 specifyChan->setChecked( item->text( col_mode ) == "A" ); 619 specifyChan->setChecked( item->text( col_mode ) == "A" );
620 networkChannel->setValue( item->text( col_chn ).toInt( &ok ) ); 620 networkChannel->setValue( item->text( col_chn ).toInt( &ok ) );
621 essid->setEditText( item->text( col_ssid ) ); 621 essid->setEditText( item->text( col_ssid ) );
622 if ( item->text( col_mode ) == "A" ) 622 if ( item->text( col_mode ) == "A" )
623 mode->setCurrentItem( 3 ); 623 mode->setCurrentItem( 3 );
624 else 624 else
625 mode->setCurrentItem( 2 ); 625 mode->setCurrentItem( 2 );
626 } 626 }
627} 627}