10 files changed, 12 insertions, 11 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp index 8498759..62b1b7a 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp @@ -1,209 +1,209 @@ #include "interfacesetupimp.h" #include "interface.h" #include <qcheckbox.h> #include <qlineedit.h> #include <qspinbox.h> #include <qgroupbox.h> #include <qlabel.h> #include <qmessagebox.h> #include <opie2/oprocess.h> #ifdef QWS #include <opie2/owait.h> #include <opie2/odebug.h> #include <qpe/global.h> #include <qapplication.h> #endif #define DNSSCRIPT "changedns" /** * Constuctor. Set up the connection. A profile must be set. */ using namespace Opie::Ui; using namespace Opie::Core; -InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){ +InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interfaces(j), interface(i), delInterfaces(false){ if (j == 0) { delInterfaces = true; interfaces = new Interfaces; } } /** * Destructor */ InterfaceSetupImp::~InterfaceSetupImp(){ if(delInterfaces) { delete interfaces; } } /** * Save the current settings, then write out the interfaces file and close. */ bool InterfaceSetupImp::saveChanges(){ bool error; QString iface = interfaces->getInterfaceName(error); odebug << "InterfaceSetupImp::saveChanges saves interface " << iface.latin1() << "" << oendl; if(!saveSettings()) return false; interfaces->write(); if (interface->getStatus()) { QString ifup; ifup += "ifdown "; ifup += iface; ifup += "; ifup "; ifup += iface; ifup += ";"; OProcess restart; restart << "sh"; restart << "-c"; restart << ifup; OWait *owait = new OWait(); Global::statusMessage( tr( "Restarting interface" ) ); owait->show(); qApp->processEvents(); if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) { owarn << "unstable to spawn ifdown/ifup" << oendl; } owait->hide(); delete owait; interface->refresh(); } return true; } /** * Save the settings for the current Interface. * @return bool true if successful, false otherwise */ bool InterfaceSetupImp::saveSettings(){ // eh can't really do anything about it other then return. :-D if(!interfaces->isInterfaceSet()) return true; bool error = false; // Loopback case if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); return true; } if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); return false; } // DHCP if(dhcpCheckBox->isChecked()) { interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); interfaces->removeInterfaceOption("address"); interfaces->removeInterfaceOption("netmask"); interfaces->removeInterfaceOption("gateway"); interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); interfaces->removeInterfaceOption("down "DNSSCRIPT" -r "); } else{ interfaces->setInterfaceMethod("static"); interfaces->setInterfaceOption("address", ipAddressEdit->text()); interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); interfaces->setInterfaceOption("gateway", gatewayEdit->text()); if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); }else{ interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); interfaces->removeInterfaceOption("down "DNSSCRIPT" -r"); } } // IP Information interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); return true; } /** * The Profile has changed. * @param QString profile the new profile. */ void InterfaceSetupImp::setProfile(const QString &profile){ /* bool error = false; if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ staticGroupBox->hide(); dhcpCheckBox->hide(); leaseTime->hide(); leaseHoursLabel->hide(); } */ QString newInterfaceName = interface->getInterfaceName(); if(profile.length() > 0) newInterfaceName += "_" + profile; // See if we have to make a interface. if(!interfaces->setInterface(newInterfaceName)){ // Add making for this new interface if need too if(profile != ""){ interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); if(!interfaces->setMapping(interface->getInterfaceName())){ interfaces->addMapping(interface->getInterfaceName()); if(!interfaces->setMapping(interface->getInterfaceName())){ odebug << "InterfaceSetupImp: Added Mapping, but still can't setInterface." << oendl; return; } } interfaces->setMap("map", newInterfaceName); interfaces->setScript("getprofile.sh"); } else{ interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); if(!interfaces->setInterface(newInterfaceName)){ odebug << "InterfaceSetupImp: Added interface, but still can't setInterface." << oendl; return; } } } // We must have a valid interface to get this far so read some settings. // DHCP bool error = false; if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) dhcpCheckBox->setChecked(true); else dhcpCheckBox->setChecked(false); // IP Information autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); odebug << "dns >" << dns.latin1() << "<" << oendl; if(dns.contains(" ")){ firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); }else firstDNSLineEdit->setText(dns); ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); if (subnetMaskEdit->text().isEmpty()) subnetMaskEdit->setText( "255.255.255.0" ); gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); owarn << "InterfaceSetupImp::setProfile(" << profile.latin1() << ")\n" << oendl; owarn << "InterfaceSetupImp::setProfile: iface is " << interfaces->getInterfaceName(error).latin1() << "\n" << oendl; } // interfacesetup.cpp diff --git a/noncore/settings/networksettings/mainwindow/addconnectionimp.cpp b/noncore/settings/networksettings/mainwindow/addconnectionimp.cpp index f18d8d1..84f1cf6 100644 --- a/noncore/settings/networksettings/mainwindow/addconnectionimp.cpp +++ b/noncore/settings/networksettings/mainwindow/addconnectionimp.cpp @@ -1,41 +1,41 @@ #include "addconnectionimp.h" #include <qlistview.h> #if QT_VERSION < 300 #include <qlist.h> #else #include <qptrlist.h> #endif #include <qlabel.h> #include <qheader.h> /** * Constructor */ AddConnectionImp::AddConnectionImp(QWidget *parent, const char *name, WFlags f):AddConnection(parent, name, f){ connect(registeredServicesList, SIGNAL(selectionChanged()), this, SLOT(changed())); registeredServicesList->header()->hide(); }; /** * The current item changed, update the discription. */ void AddConnectionImp::changed(){ QListViewItem *item = registeredServicesList->currentItem(); if(item) help->setText(list[item->text(0)]); } /** * Save a copy of newList for the discriptions and append them all to the view * @param newList the new list of possible interfaces */ void AddConnectionImp::addConnections(const QMap<QString, QString> &newList){ list = newList; QMap<QString, QString>::Iterator it; for( it = list.begin(); it != list.end(); ++it ) - QListViewItem *item = new QListViewItem(registeredServicesList, it.key()); + (void)new QListViewItem(registeredServicesList, it.key()); registeredServicesList->setCurrentItem(registeredServicesList->firstChild()); } // addserviceimp.cpp diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp index 24d33f4..128877a 100644 --- a/noncore/settings/networksettings/ppp/connect.cpp +++ b/noncore/settings/networksettings/ppp/connect.cpp @@ -1,472 +1,473 @@ /* * kPPP: A pppd front end for the KDE project * * * Copyright (C) 1997 Bernd Johannes Wuebben * wuebben@math.cornell.edu * Copyright (C) 1998-2001 Harri Porten <porten@kde.org> * * based on EzPPP: * Copyright (C) 1997 Jay Painter * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* OPIE */ #include <opie2/odebug.h> using namespace Opie::Core; /* QT */ #include <qlayout.h> #include <qregexp.h> #include <qapplication.h> #include <qmessagebox.h> #include <qpushbutton.h> /* STD */ #include <unistd.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <netdb.h> #include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> #include <netinet/in.h> #include <sys/ioctl.h> #include <assert.h> #ifdef _XPG4_2 #define __xnet_connect connect #endif #include <errno.h> #ifdef HAVE_SYS_PARAM_H #include <sys/param.h> #endif #ifdef __linux__ #include "runtests.h" #endif #include "auth.h" #include "connect.h" //#include "docking.h" #include "interfaceppp.h" #include "modem.h" #include "kpppconfig.h" #include "pppdata.h" #include "kpppwidget.h" //#include "requester.h" //#include "utils.h" #define execute_command system QString old_hostname; bool modified_hostname; ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name) : QWidget(parent, name), myreadbuffer(""), main_timer_ID(0), vmain(0), substate(-1), scriptindex(0), loopnest(0), loopend(false), semaphore(false), expecting(false), readbuffer(""), scanvar(""), scanning(false), pausing(false), dialnumber(0), _ifaceppp(ifp) { modified_hostname = false; QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); QString tit = QObject::tr("Connecting to: "); setCaption(tit); QHBoxLayout *l0 = new QHBoxLayout(10); tl->addLayout(l0); l0->addSpacing(10); messg = new QLabel(this, "messg"); messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); messg->setAlignment(AlignCenter); messg->setText(QObject::tr("Unable to create modem lock file.")); messg->setMinimumHeight(messg->sizeHint().height() + 5); // int messw = (messg->sizeHint().width() * 12) / 10; // messw = QMAX(messw,280); // messg->setMinimumWidth(messw); if (_ifaceppp->getStatus()) messg->setText(QObject::tr("Online")); else messg->setText(QObject::tr("Offline")); l0->addSpacing(10); l0->addWidget(messg); l0->addSpacing(10); QHBoxLayout *l1 = new QHBoxLayout(10); tl->addLayout(l1); l1->addStretch(1); debug = new QPushButton(QObject::tr("Log"), this); debug->setToggleButton(true); debug->setEnabled( false ); // FIXME: disable the log button connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); cancel = new QPushButton(QObject::tr("Cancel"), this); cancel->setFocus(); connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); // int maxw = QMAX(cancel->sizeHint().width(), // debug->sizeHint().width()); // maxw = QMAX(maxw,65); // debug->setFixedWidth(maxw); // cancel->setFixedWidth(maxw); l1->addWidget(debug); l1->addWidget(cancel); // setFixedSize(sizeHint()); pausetimer = new QTimer(this); connect(pausetimer, SIGNAL(timeout()), SLOT(pause())); qApp->processEvents(); timeout_timer = new QTimer(this); connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out())); inittimer = new QTimer(this); connect(inittimer, SIGNAL(timeout()), SLOT(init())); if_timeout_timer = new QTimer(this); connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out())); connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot())); prompt = new PWEntry( this, "pw" ); if_timer = new QTimer(this); connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); } ConnectWidget::~ConnectWidget() { } void ConnectWidget::preinit() { // this is all just to keep the GUI nice and snappy .... // you have to see to believe ... messg->setText(QObject::tr("Looking for modem...")); inittimer->start(100); } void ConnectWidget::init() { _ifaceppp->data()->setpppdError(0); inittimer->stop(); vmain = 0; substate = -1; expecting = false; pausing = false; scriptindex = 0; myreadbuffer = ""; scanning = false; scanvar = ""; firstrunID = true; firstrunPW = true; // stats->totalbytes = 0; dialnumber = 0; // p_kppp->con_speed = ""; // p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect()); comlist = &_ifaceppp->data()->scriptType(); arglist = &_ifaceppp->data()->script(); QString tit = QObject::tr("Connecting to: %1").arg(_ifaceppp->data()->accname()); setCaption(tit); qApp->processEvents(); // run the "before-connect" command if (!_ifaceppp->data()->command_before_connect().isEmpty()) { messg->setText(QObject::tr("Running pre-startup command...")); emit debugMessage(QObject::tr("Running pre-startup command...")); qApp->processEvents(); QApplication::flushX(); - pid_t id = execute_command(_ifaceppp->data()->command_before_connect()); + (void)execute_command(_ifaceppp->data()->command_before_connect()); + // int i, status; // do { // qApp->processEvents(); // i = waitpid(id, &status, WNOHANG); // usleep(100000); // } while (i == 0 && errno == 0); } int lock = _ifaceppp->modem()->lockdevice(); if (lock == 1) { messg->setText(QObject::tr("Modem device is locked.")); vmain = 20; // wait until cancel is pressed return; } if (lock == -1) { messg->setText(QObject::tr("Unable to create modem lock file.")); vmain = 20; // wait until cancel is pressed return; } if(_ifaceppp->modem()->opentty()) { messg->setText(_ifaceppp->modem()->modemMessage()); qApp->processEvents(); if(_ifaceppp->modem()->hangup()) { qApp->processEvents(); semaphore = false; _ifaceppp->modem()->stop(); _ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char))); // if we are stuck anywhere we will time out timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); // this timer will run the script etc. main_timer_ID = startTimer(10); return; } } // initialization failed messg->setText(_ifaceppp->modem()->modemMessage()); vmain = 20; // wait until cancel is pressed _ifaceppp->modem()->unlockdevice(); } void ConnectWidget::timerEvent(QTimerEvent *) { if (semaphore || pausing) return; if(vmain == 0) { #ifdef DEBUG_WO_DIALING vmain = 10; return; #endif assert(PPPData::NumInitStrings > 0); // first init string ? if(substate == -1) { messg->setText(QObject::tr("Initializing modem...")); emit debugMessage(QObject::tr("Initializing modem...")); substate = 0; } QString initStr = _ifaceppp->data()->modemInitStr(substate); if (!initStr.isEmpty()) { // send a carriage return and then wait a bit so that the modem will // let us issue commands. if(_ifaceppp->data()->modemPreInitDelay() > 0) { usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); writeline(""); usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); } setExpect(_ifaceppp->data()->modemInitResp()); writeline(initStr); usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec } substate++; /* * FIXME after 3.0: Make it possible to disable ATS11 since it * seems to be incompatible with some ISDN adapters (e.g. DataBox * Speed Dragon). Even better would be to detect this when doing * a "Modem Query" */ if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration()) vmain = 5; else vmain = 3; return; } if (vmain == 5) { if(!expecting) { QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration()); QString msg = QObject::tr("Setting ") + sToneDuration; messg->setText(msg); emit debugMessage(msg); setExpect(_ifaceppp->data()->modemInitResp()); writeline(sToneDuration); } vmain = 3; return; } if(vmain == 3) { if(!expecting) { // done with all init strings ? if(substate < PPPData::NumInitStrings) { vmain = 0; return; } substate = -1; // skip setting the volume if command is empty if(_ifaceppp->data()->volumeInitString().isEmpty()) { vmain = 4; return; } messg->setText(QObject::tr("Setting speaker volume...")); emit debugMessage(QObject::tr("Setting speaker volume...")); setExpect(_ifaceppp->data()->modemInitResp()); QString vol("AT"); vol += _ifaceppp->data()->volumeInitString(); writeline(vol); usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec vmain = 4; return; } } if(vmain == 4) { if(!expecting) { if(!_ifaceppp->data()->waitForDialTone()) { QString msg = QObject::tr("Turning off dial tone waiting..."); messg->setText(msg); emit debugMessage(msg); setExpect(_ifaceppp->data()->modemInitResp()); writeline(_ifaceppp->data()->modemNoDialToneDetectionStr()); } vmain = 1; return; } } // dial the number and wait to connect if(vmain == 1) { if(!expecting) { timeout_timer->stop(); timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); QStringList &plist = _ifaceppp->data()->phonenumbers(); QString bmarg= _ifaceppp->data()->dialPrefix(); bmarg += *plist.at(dialnumber); QString bm = QObject::tr("Dialing %1").arg(bmarg); messg->setText(bm); emit debugMessage(bm); QString pn = _ifaceppp->data()->modemDialStr(); pn += _ifaceppp->data()->dialPrefix(); pn += *plist.at(dialnumber); if(++dialnumber >= plist.count()) dialnumber = 0; writeline(pn); setExpect(_ifaceppp->data()->modemConnectResp()); vmain = 100; return; } } // wait for connect, but redial if BUSY or wait for user cancel // if NO CARRIER or NO DIALTONE if(vmain == 100) { if(!expecting) { myreadbuffer = _ifaceppp->data()->modemConnectResp(); setExpect("\n"); vmain = 101; return; } if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) { timeout_timer->stop(); timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); messg->setText(QObject::tr("Line busy. Hanging up...")); emit debugPutChar('\n'); _ifaceppp->modem()->hangup(); if(_ifaceppp->data()->busyWait() > 0) { QString bm = QObject::tr("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait()); messg->setText(bm); emit debugMessage(bm); pausing = true; pausetimer->start(_ifaceppp->data()->busyWait()*1000, true); timeout_timer->stop(); } _ifaceppp->modem()->setDataMode(false); vmain = 0; substate = -1; return; } if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) { timeout_timer->stop(); messg->setText(QObject::tr("No Dialtone")); vmain = 20; _ifaceppp->modem()->unlockdevice(); return; } if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) { timeout_timer->stop(); messg->setText(QObject::tr("No Carrier")); vmain = 20; _ifaceppp->modem()->unlockdevice(); return; } } // wait for newline after CONNECT response (so we get the speed) if(vmain == 101) { if(!expecting) { _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands emit startAccounting(); // p_kppp->con_win->startClock(); vmain = 2; scriptTimeout=_ifaceppp->data()->modemTimeout()*1000; return; } } // execute the script if(vmain == 2) { if(!expecting && !pausing && !scanning) { timeout_timer->stop(); timeout_timer->start(scriptTimeout); if((unsigned) scriptindex < comlist->count()) { diff --git a/noncore/settings/networksettings/ppp/devices.cpp b/noncore/settings/networksettings/ppp/devices.cpp index 42de44c..e2c67d8 100644 --- a/noncore/settings/networksettings/ppp/devices.cpp +++ b/noncore/settings/networksettings/ppp/devices.cpp @@ -1,219 +1,219 @@ /* * kPPP: A pppd front end for the KDE project * * $Id$ * * Copyright (C) 1997 Bernd Johannes Wuebben * wuebben@math.cornell.edu * * based on EzPPP: * Copyright (C) 1997 Jay Painter * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "interfaceppp.h" #include "devices.h" #include "authwidget.h" #include "pppdata.h" #include "edit.h" #include "general.h" /* OPIE */ #include <opie2/odebug.h> #include <qpe/qpeapplication.h> using namespace Opie::Core; /* QT */ #include <qdir.h> #include <qlayout.h> #include <qtabwidget.h> #include <qtabdialog.h> #include <qwhatsthis.h> #include <qmessagebox.h> #include <qapplication.h> #include <qbuttongroup.h> #include <qmessagebox.h> #include <qvgroupbox.h> /* STD */ #include <stdlib.h> void parseargs(char* buf, char** args); DevicesWidget::DevicesWidget( InterfacePPP* ip, QWidget *parent, const char *name, WFlags f ) : ChooserWidget(ip->data(), parent, name, f) { _ifaceppp = ip; QWhatsThis::add(edit_b, tr("Allows you to modify the selected device")); QWhatsThis::add(new_b, tr("Create a new device") ); QWhatsThis::add(copy_b, tr("Makes a copy of the selected device. All\n" "settings of the selected device are copied\n" "to a new device, that you can modify to fit your\n" "needs")); QWhatsThis::add(delete_b, tr("<p>Deletes the selected device\n\n" "<font color=\"red\"><b>Use with care!</b></font>")); copy_b->setEnabled( false ); //FIXME // delete_b->setEnabled( false ); //FIXME QStringList tmp = _pppdata->getDevicesNamesList(); odebug << "DevicesWidget::DevicesWidget got devices " << tmp.join("--").latin1() << "" << oendl; listListbox->insertStringList(tmp); for (uint i = 0; i < listListbox->count(); i++){ odebug << "listListbox->text(i) " << listListbox->text(i).latin1() << " == _pppdata->devname() " << _pppdata->devname().latin1() << "" << oendl; if ( listListbox->text(i) == _pppdata->devname() ) listListbox->setCurrentItem( i ); } } void DevicesWidget::slotListBoxSelect(int idx) { - bool ok = _pppdata->setDevice( listListbox->text(idx) ); + _pppdata->setDevice( listListbox->text(idx) ); delete_b->setEnabled((bool)(idx != -1)); edit_b->setEnabled((bool)(idx != -1)); //FIXME copy_b->setEnabled((bool)(idx != -1)); } void DevicesWidget::edit() { _pppdata->setDevice(listListbox->text(listListbox->currentItem())); int result = doTab(); if(result == QDialog::Accepted) { listListbox->changeItem(_pppdata->devname(),listListbox->currentItem()); _pppdata->save(); } } void DevicesWidget::create() { // if(listListbox->count() == MAX_ACCOUNTS) { // QMessageBox::information(this, "sorry", // tr("Maximum number of accounts reached.")); // return; // } int result; if (_pppdata->newdevice() == -1){ return; } result = doTab(); if(result == QDialog::Accepted) { listListbox->insertItem(_pppdata->devname()); listListbox->setSelected(listListbox->findItem(_pppdata->devname()),true ); _pppdata->save(); } else _pppdata->deleteDevice(); } void DevicesWidget::copy() { // if(listListbox->count() == MAX_ACCOUNTS) { // QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); // return; // } if(listListbox->currentItem()<0) { QMessageBox::information(this, "sorry", tr("No devices selected.")); return; } _pppdata->copydevice(listListbox->currentText()); listListbox->insertItem(_pppdata->devname()); _pppdata->save(); } void DevicesWidget::remove() { QString s = tr("Are you sure you want to delete\nthe device \"%1\"?") .arg(listListbox->text(listListbox->currentItem())); if(QMessageBox::warning(this,tr("Confirm"),s, QMessageBox::Yes,QMessageBox::No ) != QMessageBox::Yes) return; if(_pppdata->deleteDevice(listListbox->text(listListbox->currentItem()))) listListbox->removeItem(listListbox->currentItem()); // _pppdata->save(); slotListBoxSelect(listListbox->currentItem()); } int DevicesWidget::doTab(){ QDialog *dlg = new QDialog( 0, "newDevice", true, Qt::WStyle_ContextHelp ); QVBoxLayout *layout = new QVBoxLayout( dlg ); layout->setSpacing( 0 ); layout->setMargin( 1 ); QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" ); layout->addWidget( tabWindow ); bool isnew; if(_pppdata->devname().isEmpty()) { dlg->setCaption(tr("New Device")); isnew = true; } else { QString tit = tr("Edit Device: "); tit += _pppdata->devname(); dlg->setCaption(tit); isnew = false; } modem1 = new ModemWidget( _pppdata, tabWindow, "modem1" ); tabWindow->addTab( modem1, tr("&Device") ); modem2 = new ModemWidget2( _pppdata, _ifaceppp, tabWindow, "modem2" ); tabWindow->addTab( modem2, tr("&Modem") ); int result = 0; bool ok = false; while (!ok){ result = QPEApplication::execDialog( dlg ); ok = true; if(result == QDialog::Accepted) { if (!modem1->save()){ QMessageBox::critical(this, "error", tr( "You must enter a unique device name")); ok = false; }else{ modem2->save(); } } } delete dlg; return result; } diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp index 3b2393c..6c9735c 100644 --- a/noncore/settings/networksettings/ppp/edit.cpp +++ b/noncore/settings/networksettings/ppp/edit.cpp @@ -949,263 +949,263 @@ void ScriptWidget::slhighlighted(int i) void ScriptWidget::stlhighlighted(int i) { insert->setEnabled(true); remove->setEnabled(true); sl->setCurrentItem(i); } void ScriptWidget::addButton() { //don't allow more than the maximum script entries if(sl->count() == MAX_SCRIPT_ENTRIES-1) return; switch(se->type()) { case ScriptEdit::Expect: stl->insertItem("Expect"); sl->insertItem(se->text()); break; case ScriptEdit::Send: stl->insertItem("Send"); sl->insertItem(se->text()); break; case ScriptEdit::SendNoEcho: stl->insertItem("SendNoEcho"); sl->insertItem(se->text()); break; case ScriptEdit::Pause: stl->insertItem("Pause"); sl->insertItem(se->text()); break; case ScriptEdit::Hangup: stl->insertItem("Hangup"); sl->insertItem(""); break; case ScriptEdit::Answer: stl->insertItem("Answer"); sl->insertItem(""); break; case ScriptEdit::Timeout: stl->insertItem("Timeout"); sl->insertItem(se->text()); break; case ScriptEdit::Password: stl->insertItem("Password"); sl->insertItem(se->text()); break; case ScriptEdit::ID: stl->insertItem("ID"); sl->insertItem(se->text()); break; case ScriptEdit::Prompt: stl->insertItem("Prompt"); sl->insertItem(se->text()); break; case ScriptEdit::PWPrompt: stl->insertItem("PWPrompt"); sl->insertItem(se->text()); break; case ScriptEdit::LoopStart: stl->insertItem("LoopStart"); sl->insertItem(se->text()); break; case ScriptEdit::LoopEnd: stl->insertItem("LoopEnd"); sl->insertItem(se->text()); break; case ScriptEdit::Scan: stl->insertItem("Scan"); sl->insertItem(se->text()); break; case ScriptEdit::Save: stl->insertItem("Save"); sl->insertItem(se->text()); break; default: break; } //get the scrollbar adjusted, and scroll the list so we can see what //we're adding to adjustScrollBar(); slb->setValue(slb->maxValue()); //clear the text in the entry box se->setText(""); } void ScriptWidget::insertButton() { //exit if there is no highlighted item, or we've reached the //maximum entries in the script list if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) return; switch(se->type()) { case ScriptEdit::Expect: stl->insertItem("Expect", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Send: stl->insertItem("Send", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::SendNoEcho: stl->insertItem("SendNoEcho", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Pause: stl->insertItem("Pause", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Hangup: stl->insertItem("Hangup", stl->currentItem()); sl->insertItem("", sl->currentItem()); break; case ScriptEdit::Answer: stl->insertItem("Answer", stl->currentItem()); sl->insertItem("", sl->currentItem()); break; case ScriptEdit::Timeout: stl->insertItem("Timeout", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Password: stl->insertItem("Password", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::ID: stl->insertItem("ID", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Prompt: stl->insertItem("Prompt", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::PWPrompt: stl->insertItem("PWPrompt", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::LoopStart: stl->insertItem("LoopStart", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::LoopEnd: stl->insertItem("LoopEnd", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Scan: stl->insertItem("Scan", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Save: stl->insertItem("Save", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; default: break; } adjustScrollBar(); se->setText(""); } void ScriptWidget::removeButton() { if(sl->currentItem() >= 0) { int stlc = stl->currentItem(); sl->removeItem(sl->currentItem()); stl->removeItem(stlc); adjustScrollBar(); insert->setEnabled(sl->currentItem() != -1); remove->setEnabled(sl->currentItem() != -1); } } ///////////////////////////////////////////////////////////////////////////// // // Used to specify a new phone number // ///////////////////////////////////////////////////////////////////////////// PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) : QDialog(parent,"PhoneNumberDialog",true) { setCaption( tr("Add Phone Number") ); QVBoxLayout *layout = new QVBoxLayout( this ); layout->setSpacing( 3 ); layout->setMargin( 3 ); // QHBox *hbox = new QHBox(this); // setMainWidget(hbox); // hbox->setSpacing( 2 );//KDialog::spacingHint()); QLabel *label = new QLabel(this, tr("Enter a phone number:")); layout->addWidget( label ); le = new QLineEdit(this, "lineEdit"); layout->addWidget( le ); connect(le, SIGNAL(textChanged(const QString&)), this, SLOT(textChanged(const QString&))); le->setFocus(); textChanged(""); } QString PhoneNumberDialog::phoneNumber() { QString s = le->text(); return s; } -void PhoneNumberDialog::textChanged(const QString &s) +void PhoneNumberDialog::textChanged(const QString &) { // enableButtonOK(s.length() > 0); } //#include "edit.moc" diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp index 4755aed..56e1c1f 100644 --- a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp +++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp @@ -1,45 +1,45 @@ #include "interfaceinformationppp.h" #include "connect.h" #include "conwindow.h" /* OPIE */ #include <opie2/odebug.h> using namespace Opie::Core; /* QT */ #include <qpushbutton.h> #include <qlabel.h> #include <qmessagebox.h> #include <qabstractlayout.h> #ifdef QWS #else #define showMaximized show #endif /** * Constructor for the InterfaceInformationImp class. This class pretty much * just display's information about the interface that is passed to it. */ -InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f) +InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags ) :InterfaceInformationImp(parent, name, i, Qt::WStyle_ContextHelp) { odebug << "InterfaceInformationPPP::InterfaceInformationPPP " << name << "" << oendl; con = new ConnectWidget( (InterfacePPP*)i, this, "con" ); con->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed) ); macAddressLabel->hide(); subnetMaskLabel->hide(); broadcastLabel->hide(); TextLabel23->hide(); TextLabel21->hide(); TextLabel24->hide(); InterfaceInformationLayout->addWidget( con, 1, 0 ); connect(i, SIGNAL(begin_connect()),con, SLOT(preinit())); connect(i, SIGNAL(hangup_now() ), con, SLOT(cancelbutton() ) ); } diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp index fb279ee..dec0177 100644 --- a/noncore/settings/networksettings/ppp/pppmodule.cpp +++ b/noncore/settings/networksettings/ppp/pppmodule.cpp @@ -1,286 +1,287 @@ #include "modem.h" #include "pppconfig.h" #include "pppmodule.h" #include "pppdata.h" #include "interfaceinformationppp.h" #include "interfaceppp.h" /* OPIE */ #include <opie2/odebug.h> #include <qpe/config.h> #include <qpe/qpeapplication.h> using namespace Opie::Core; /* QT */ #include <qt.h> /* STD */ #include <errno.h> #include <signal.h> // don't polute global namespace namespace { /* * If network settings is qutting and we've ppp * devices open we need to save the pid_t the PPData * and the interface number */ struct Connection { pid_t pid; QString device; QString name; }; class InterfaceKeeper { public: InterfaceKeeper(); ~InterfaceKeeper(); void addInterface( pid_t, const QString& pppDev, const QString& name ); QMap<QString, Connection> interfaces()const; // will check if still available private: bool isAvailable( pid_t )const; QMap<QString, Connection> m_interfaces; }; } /** * Constructor, find all of the possible interfaces * We also need to restore the state.. it could be that * an interface was up while closing the application * we need to be able to shut it down... */ PPPModule::PPPModule() : Module() { InterfaceKeeper inFace; QMap<QString,Connection> running = inFace.interfaces(); QStringList handledInterfaceNames; QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); QMap<QString,QString>::Iterator it; InterfacePPP *iface; odebug << "getting interfaces" << oendl; for( it = ifaces.begin(); it != ifaces.end(); ++it ) { odebug << "ifaces " << it.key().latin1() << " " << it.data().latin1() << "" << oendl; iface = new InterfacePPP( 0, it.key() ); iface->setHardwareName( it.data() ); list.append( (Interface*)iface ); // check if (*it) is one of the running ifaces if ( running.contains( it.data() ) ) { odebug << "iface is running " << it.key().latin1() << "" << oendl; handledInterfaceNames << running[it.data()].device; iface->setStatus( true ); iface->setPPPDpid( running[it.data()].pid ); iface->modem()->setPPPDevice( running[it.data()].device ); iface->refresh(); } } setHandledInterfaceNames( handledInterfaceNames ); } /** * Delete any interfaces that we own. */ PPPModule::~PPPModule() { odebug << "PPPModule::~PPPModule() " << oendl; QMap<QString,QString> ifaces; InterfaceKeeper keeper; Interface *i; for ( i=list.first(); i != 0; i=list.next() ) { /* if online save the state */ if ( i->getStatus() ) { odebug << "Iface " << i->getHardwareName().latin1() << " is still up" << oendl; InterfacePPP* ppp = static_cast<InterfacePPP*>(i); keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() ); } ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); delete i; } PPPData::setConfiguredInterfaces( ifaces ); } /** * Change the current profile */ void PPPModule::setProfile(const QString &newProfile) { profile = newProfile; } /** * get the icon name for this device. * @param Interface* can be used in determining the icon. * @return QString the icon name (minus .png, .gif etc) */ QString PPPModule::getPixmapName(Interface* ) { return "ppp"; } /** * Check to see if the interface i is owned by this module. * @param Interface* interface to check against * @return bool true if i is owned by this module, false otherwise. */ bool PPPModule::isOwner(Interface *i) { return list.find( i ) != -1; } /** * Create, and return the WLANConfigure Module * @return QWidget* pointer to this modules configure. */ QWidget *PPPModule::configure(Interface *i) { odebug << "return ModemWidget" << oendl; PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, 0, "PPPConfig", false, ::Qt::WDestructiveClose | ::Qt::WStyle_ContextHelp); return pppconfig; } /** * Create, and return the Information Module * @return QWidget* pointer to this modules info. */ QWidget *PPPModule::information(Interface *i) { // We don't have any advanced pppd information widget yet :-D // TODO ^ return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); } /** * Get all active (up or down) interfaces * @return QList<Interface> A list of interfaces that exsist that havn't * been called by isOwner() */ QList<Interface> PPPModule::getInterfaces() { // List all of the files in the peer directory odebug << "PPPModule::getInterfaces" << oendl; return list; } /** * Attempt to add a new interface as defined by name - * @param name the name of the type of interface that should be created given + * @param newInterface the name of the type of interface that should be created given * by possibleNewInterfaces(); * @return Interface* NULL if it was unable to be created. */ Interface *PPPModule::addNewInterface(const QString &newInterface) { + Q_CONST_UNUSED( newInterface ) InterfacePPP *ifaceppp; Interface *iface; ifaceppp = new InterfacePPP(); PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); if( QPEApplication::execDialog( &imp ) == QDialog::Accepted ) { iface = (InterfacePPP*) ifaceppp; iface->setModuleOwner( this ); list.append( iface ); return iface; } else { delete ifaceppp; iface = NULL; } return iface; } /** * Attempts to remove the interface, doesn't delete i * @return bool true if successful, false otherwise. */ bool PPPModule::remove(Interface *i) { return list.remove(i); } void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) { newIfaces.insert(::QObject::tr("PPP") , ::QObject::tr("generic ppp device")); } namespace { InterfaceKeeper::InterfaceKeeper( ) {} InterfaceKeeper::~InterfaceKeeper() { Config cfg("ppp_plugin_keeper"); QStringList lst = cfg.groupList(); for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { Connection con; cfg.setGroup( (*it) ); cfg.clearGroup(); } for (QMap<QString, Connection>::Iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it ) { Connection con = it.data(); cfg.setGroup( con.name ); cfg.writeEntry( "pid", con.pid ); cfg.writeEntry( "device", con.device ); } } void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name ) { Connection con; con.pid = pid; con.device = dev; con.name = name; m_interfaces.insert( name, con ); } QMap<QString, Connection> InterfaceKeeper::interfaces()const { Config cfg("ppp_plugin_keeper"); QMap<QString, Connection> ifaces; QStringList lst = cfg.groupList(); for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { Connection con; cfg.setGroup( (*it) ); con.name = (*it); con.pid = cfg.readNumEntry("pid"); con.device = cfg.readEntry("device"); odebug << " " << con.name.latin1() << " " << con.device.latin1() << " " << con.pid << "" << oendl; if ( con.pid != -1 && isAvailable( con.pid ) ) ifaces.insert( con.name, con ); } return ifaces; } bool InterfaceKeeper::isAvailable( pid_t p)const { if (::kill(p, 0 ) == 0 || errno != ESRCH ) { odebug << "isAvailable " << p << "" << oendl; return true; } odebug << "notAvailable " << p << "" << oendl; return false; } } diff --git a/noncore/settings/networksettings/ppp/pppmodule.h b/noncore/settings/networksettings/ppp/pppmodule.h index de649e4..1ecbf7a 100644 --- a/noncore/settings/networksettings/ppp/pppmodule.h +++ b/noncore/settings/networksettings/ppp/pppmodule.h @@ -1,43 +1,43 @@ #ifndef PPP_MODULE_H #define PPP_MODULE_H #include "module.h" class PPPModule : Module { signals: void updateInterface(Interface *i); public: PPPModule(); ~PPPModule(); virtual const QString type() {return "ppp";}; virtual void setProfile(const QString &newProfile); virtual bool isOwner(Interface *); virtual QWidget *configure(Interface *i); virtual QWidget *information(Interface *i); virtual QList<Interface> getInterfaces(); virtual void possibleNewInterfaces(QMap<QString, QString> &); virtual Interface *addNewInterface(const QString &name); virtual bool remove(Interface* i); virtual QString getPixmapName(Interface* i); - virtual void receive(const QCString &msg, const QByteArray &arg) {}; + virtual void receive(const QCString &, const QByteArray &) {}; private: QList<Interface> list; QString profile; }; extern "C" { void* create_plugin() { return new PPPModule(); } }; #endif // pppmodule.h diff --git a/noncore/settings/networksettings/wlan/keyedit.cpp b/noncore/settings/networksettings/wlan/keyedit.cpp index 13a1c3b..62f8960 100644 --- a/noncore/settings/networksettings/wlan/keyedit.cpp +++ b/noncore/settings/networksettings/wlan/keyedit.cpp @@ -1,22 +1,22 @@ #include "keyedit.h" #include <qlineedit.h> KeyEdit::KeyEdit(QWidget* parent, const char* name) : QLineEdit(parent, name) { setEchoMode(Password); } KeyEdit::~KeyEdit() { } -void KeyEdit::focusInEvent(QFocusEvent *event) +void KeyEdit::focusInEvent(QFocusEvent *) { setEchoMode(Normal); } -void KeyEdit::focusOutEvent(QFocusEvent *event) +void KeyEdit::focusOutEvent(QFocusEvent *) { setEchoMode(Password); } diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp index d36a702..5cb78cf 100644 --- a/noncore/settings/networksettings/wlan/wlanimp2.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp @@ -1,375 +1,374 @@ #include "wlanimp2.h" #include "keyedit.h" #include "interfacesetupimp.h" #include "../interfaces/interface.h" #include <assert.h> #include <errno.h> #include <string.h> /* OPIE */ #include <opie2/odebug.h> #include <opie2/oprocess.h> #include <opie2/onetwork.h> #include <opie2/opcap.h> #include <qpe/resource.h> using namespace Opie::Core; using namespace Opie::Net; /* QT */ #include <qapplication.h> #include <qfile.h> #include <qdir.h> #include <qdialog.h> #include <qtextstream.h> #include <qmessagebox.h> #include <qlineedit.h> #include <qlabel.h> #include <qspinbox.h> #include <qradiobutton.h> #include <qpushbutton.h> #include <qcheckbox.h> #include <qtabwidget.h> #include <qcombobox.h> #include <qlistview.h> #include <qvbox.h> #include <qprogressbar.h> /* STD */ #include <assert.h> #include <errno.h> #include <string.h> #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" #define PREUP "/etc/network/if-pre-up.d/wireless-tools" /** * Constructor, read in the wireless.opts file for parsing later. */ WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { interfaces = new Interfaces(); interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); tabWidget->insertTab(interfaceSetup, "TCP/IP"); // Check sanity - the existance of the wireless-tools if-pre-up script QFile file(QString(PREUP)); if (file.exists()) { owarn << QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools") << oendl; } connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) ); connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) ); netView->setColumnAlignment( col_chn, AlignCenter ); netView->setItemMargin( 3 ); netView->setAllColumnsShowFocus( true ); } WLANImp::~WLANImp() { //FIXME: delete interfaces; } /** * Change the profile for both wireless settings and network settings. */ void WLANImp::setProfile(const QString &profile){ interfaceSetup->setProfile(profile); parseOpts(); } void WLANImp::parseOpts() { bool error; QString opt; if (! interfaces->isInterfaceSet()) return; opt = interfaces->getInterfaceOption("wireless_essid", error); if(opt == "any" || opt == "off" || opt.isNull()){ essid->setEditText("any"); } else { essid->setEditText(opt); } opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); for ( int i = 0; i < mode->count(); i++) if ( mode->text( i ) == opt ) mode->setCurrentItem( i ); opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); if (! opt.isNull()) { specifyAp->setChecked(true); macEdit->setText(opt); } opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); if (! opt.isNull()) { specifyChan->setChecked(true); networkChannel->setValue(opt.toInt()); } opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); if (opt.isNull()) opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); parseKeyStr(opt); } void WLANImp::parseKeyStr(QString keystr) { - int loc = 0; int index = 1; QString key; QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); int enc = -1; // encryption state for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { if ((*it).left(3) == "off") { // encryption disabled enc = 0; } else if ((*it).left(2) == "on") { // encryption enabled enc = 1; } else if ((*it).left(4) == "open") { // open mode, accept non encrypted packets acceptNonEnc->setChecked(true); } else if ((*it).left(10) == "restricted") { // restricted mode, only accept encrypted packets rejectNonEnc->setChecked(true); } else if ((*it).left(3) == "key") { // new set of options } else if ((*it).left(1) == "[") { index = (*it).mid(1, 1).toInt(); // switch current key to index switch (index) { case 1: keyRadio0->setChecked(true); break; case 2: keyRadio1->setChecked(true); break; case 3: keyRadio2->setChecked(true); break; case 4: keyRadio3->setChecked(true); break; } } else { // key key = (*it); } if (! key.isNull()) { if (enc == -1) enc = 1; QStringList::Iterator next = ++it; if (it == keys.end()) { break; } if ((*(next)).left(1) == "[") { // set key at index index = (*(next)).mid(1, 1).toInt(); } else { index = 1; } switch (index) { case 1: keyLineEdit0->setText(key); break; case 2: keyLineEdit1->setText(key); break; case 3: keyLineEdit2->setText(key); break; case 4: keyLineEdit3->setText(key); break; } key = QString::null; } } if (enc == 1) { wepEnabled->setChecked(true); } else { wepEnabled->setChecked(false); } } /** * Check to see if the current config is valid * Save interfaces */ void WLANImp::accept() { if (wepEnabled->isChecked()) { if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) || (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) || (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) || (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); return; } } if (essid->currentText().isEmpty()) { QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); return; } if (specifyAp->isChecked() && macEdit->text().isEmpty()) { QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok); return; } // Try to save the interfaces settings. writeOpts(); // Close out the dialog // FIXME: QDialog::accept(); } void WLANImp::writeOpts() { // eh can't really do anything about it other then return. :-D if(!interfaces->isInterfaceSet()){ QMessageBox::warning(0,"Inface not set","should not happen!!!"); return; } bool error = false; odebug << "setting wlan interface " << interfaces->getInterfaceName( error ).latin1() << "" << oendl; if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!"); interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); if (specifyAp->isChecked()) { interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text()); } else { interfaces->removeInterfaceOption(QString("wireless_ap")); } if (specifyChan->isChecked()) { interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text()); } else { interfaces->removeInterfaceOption(QString("wireless_channel")); } if (wepEnabled->isChecked()) { QStringList keyList; if (! keyLineEdit0->text().isNull()) { keyList += keyLineEdit0->text(); keyList += "[1]"; } //else if (! keyLineEdit1->text().isNull()) { keyList += keyLineEdit1->text(); keyList += "[2]"; } //else if (! keyLineEdit2->text().isNull()) { keyList += keyLineEdit2->text(); keyList += "[3]"; } //else if (! keyLineEdit3->text().isNull()) { keyList += keyLineEdit3->text(); keyList += "[4]"; } if (acceptNonEnc->isChecked()) { keyList += "open"; } else { keyList += "restricted"; } keyList += "key"; if (keyRadio0->isChecked()) { keyList += "[1]"; } else if (keyRadio1->isChecked()) { keyList += "[2]"; } else if (keyRadio2->isChecked()) { keyList += "[3]"; } else if (keyRadio3->isChecked()) { keyList += "[4]"; } interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" "))); } else { interfaces->removeInterfaceOption(QString("wireless_key")); } interfaces->removeInterfaceOption(QString("wireless_enc")); if(!interfaceSetup->saveChanges()) return; QDialog::accept(); } /* * Scan for possible wireless networks around... * ... powered by Wellenreiter II technology (C) Michael 'Mickey' Lauer <mickeyl@handhelds.org> */ void WLANImp::rescanNeighbourhood() { QString name = interface->getInterfaceName(); odebug << "rescanNeighbourhood via '" << name << "'" << oendl; OWirelessNetworkInterface* wiface = static_cast<OWirelessNetworkInterface*>( ONetwork::instance()->interface( name ) ); assert( wiface ); // try to guess device type QString devicetype; QFile m( "/proc/modules" ); if ( m.open( IO_ReadOnly ) ) { QString line; QTextStream modules( &m ); while( !modules.atEnd() && !devicetype ) { modules >> line; if ( line.contains( "cisco" ) ) devicetype = "cisco"; else if ( line.contains( "hostap" ) ) devicetype = "hostap"; else if ( line.contains( "prism" ) ) devicetype = "wlan-ng"; /* puke */ else if ( line.contains( "orinoco" ) ) devicetype = "orinoco"; } } if ( devicetype.isEmpty() ) { owarn << "rescanNeighbourhood(): couldn't guess device type :(" << oendl; return; } else { odebug << "rescanNeighbourhood(): device type seems to be '" << devicetype << "'" << oendl; } // configure interface to receive 802.11 management frames wiface->setUp( true ); wiface->setPromiscuousMode( true ); if ( devicetype == "cisco" ) wiface->setMonitoring( new OCiscoMonitoringInterface( wiface, false ) ); else if ( devicetype == "hostap" ) wiface->setMonitoring( new OHostAPMonitoringInterface( wiface, false ) ); else if ( devicetype == "wlan-ng" ) wiface->setMonitoring( new OWlanNGMonitoringInterface( wiface, false ) ); else if ( devicetype == "orinoco" ) wiface->setMonitoring( new OOrinocoMonitoringInterface( wiface, false ) ); else { odebug << "rescanNeighbourhood(): unsupported device type for monitoring :(" << oendl; return; } wiface->setMode( "monitor" ); if ( wiface->mode() != "monitor" ) { owarn << "rescanNeighbourhood(): Unable to bring device into monitor mode (" << strerror( errno ) << ")." << oendl; return; } // open a packet capturer OPacketCapturer* cap = new OPacketCapturer(); cap->open( name ); if ( !cap->isOpen() ) { owarn << "rescanNeighbourhood(): Unable to open libpcap (" << strerror( errno ) << ")." << oendl; return; } // display splash screen QFrame* splash = new QFrame( this, "splash", false, WStyle_StaysOnTop | WStyle_DialogBorder | WStyle_Customize ); |