author | zecke <zecke> | 2004-09-10 11:16:54 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-10 11:16:54 (UTC) |
commit | 59dbb076579e0387f960525b415511946eb83b17 (patch) (side-by-side diff) | |
tree | dc8caeebf7e5a1968a399838b53cb09a1537d9ec | |
parent | b8baf551919868737c6f56a05e6efa1bad4d97ac (diff) | |
download | opie-59dbb076579e0387f960525b415511946eb83b17.zip opie-59dbb076579e0387f960525b415511946eb83b17.tar.gz opie-59dbb076579e0387f960525b415511946eb83b17.tar.bz2 |
Fix the issues the compilers bothers
remove unused parameters, give return values on return
10 files changed, 40 insertions, 39 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; + 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; + 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; + 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; + 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; + 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; + 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 @@ -120,193 +120,194 @@ ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *nam 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; @@ -380,193 +381,193 @@ void ConnectWidget::timerEvent(QTimerEvent *) { 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()) { scriptCommand = *(comlist->at(scriptindex)); scriptArgument = *(arglist->at(scriptindex)); } else { - odebug << "End of script" << oendl; + odebug << "End of script" << oendl; vmain = 10; return; } if (scriptCommand == "Scan") { QString bm = QObject::tr("Scanning %1").arg(scriptArgument); messg->setText(bm); emit debugMessage(bm); setScan(scriptArgument); scriptindex++; return; } if (scriptCommand == "Save") { QString bm = QObject::tr("Saving %1").arg(scriptArgument); messg->setText(bm); emit debugMessage(bm); if (scriptArgument.lower() == "password") { _ifaceppp->data()->setPassword(scanvar); // p_kppp->setPW_Edit(scanvar); if(_ifaceppp->data()->storePassword()) _ifaceppp->data()->setStoredPassword(scanvar); firstrunPW = true; } scriptindex++; return; } if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { QString bm = QObject::tr("Sending %1"); // replace %USERNAME% and %PASSWORD% QString arg = scriptArgument; QRegExp re1("%USERNAME%"); QRegExp re2("%PASSWORD%"); arg = arg.replace(re1, _ifaceppp->data()->storedUsername()); arg = arg.replace(re2, _ifaceppp->data()->storedPassword()); if (scriptCommand == "Send") bm = bm.arg(scriptArgument); else { for(uint i = 0; i < scriptArgument.length(); i++) bm = bm.arg("*"); } messg->setText(bm); emit debugMessage(bm); writeline(scriptArgument); scriptindex++; return; } if (scriptCommand == "Expect") { QString bm = QObject::tr("Expecting %1").arg(scriptArgument); messg->setText(bm); emit debugMessage(bm); // The incrementing of the scriptindex MUST be before the // call to setExpect otherwise the expect will miss a string that is // already in the buffer. scriptindex++; setExpect(scriptArgument); return; } if (scriptCommand == "Pause") { QString bm = QObject::tr("Pause %1 seconds").arg(scriptArgument); messg->setText(bm); emit debugMessage(bm); pausing = true; pausetimer->start(scriptArgument.toInt()*1000, true); timeout_timer->stop(); scriptindex++; return; } if (scriptCommand == "Timeout") { timeout_timer->stop(); QString bm = QObject::tr("Timeout %1 seconds").arg(scriptArgument); messg->setText(bm); emit debugMessage(bm); scriptTimeout=scriptArgument.toInt()*1000; timeout_timer->start(scriptTimeout); @@ -746,203 +747,203 @@ void ConnectWidget::timerEvent(QTimerEvent *) { cancelbutton(); QMessageBox::critical(0, "error", QObject::tr("Loops nested too deeply!")); } else { setExpect(scriptArgument); loopstartindex[loopnest] = scriptindex; loopstr[loopnest] = scriptArgument; loopend = false; loopnest++; } messg->setText(bm); emit debugMessage(bm); } if (scriptCommand == "LoopEnd") { QString bm = QObject::tr("Loop End %1").arg(scriptArgument); if ( loopnest <= 0 ) { bm = QObject::tr("LoopEnd without matching Start! Line: %1").arg(bm); vmain=20; cancelbutton(); QMessageBox::critical(0, "error", bm); return; } else { // NB! The incrementing of the scriptindex MUST be before the // call to setExpect otherwise the expect will miss a string // that is already in the buffer. scriptindex++; setExpect(scriptArgument); loopnest--; loopend = true; } messg->setText(bm); emit debugMessage(bm); } } } // this is a subroutine for the "Answer" script option if(vmain == 150) { if(!expecting) { writeline(_ifaceppp->data()->modemAnswerStr()); setExpect(_ifaceppp->data()->modemAnswerResp()); vmain = 2; scriptindex++; return; } } if(vmain == 30) { // if (termwindow->isVisible()) // return; // if (termwindow->pressedContinue()) // vmain = 10; // else cancelbutton(); } if(vmain == 10) { if(!expecting) { int result; timeout_timer->stop(); if_timeout_timer->stop(); // better be sure. // stop reading of data _ifaceppp->modem()->stop(); if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) { // if (termwindow) { // delete termwindow; // termwindow = 0L; // this->show(); // } else { // termwindow = new LoginTerm(0L, 0L); // hide(); // termwindow->show(); // vmain = 30; // return; // } } // Close the tty. This prevents the QTimer::singleShot() in // Modem::readtty() from re-enabling the socket notifier. // The port is still held open by the helper process. /* Er, there _is_ not QTimer::singleShot() in Modem::readtty(), and closing the thing prevents pppd from using it later. */ //_ifaceppp->modem()->closetty(); killTimer( main_timer_ID ); if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); - odebug << "started if timeout timer with " << _ifaceppp->data()->pppdTimeout()*1000 << "" << oendl; + odebug << "started if timeout timer with " << _ifaceppp->data()->pppdTimeout()*1000 << "" << oendl; // find out PPP interface and notify the stats module // stats->setUnit(pppInterfaceNumber()); qApp->flushX(); semaphore = true; result = execppp(); emit debugMessage(QObject::tr("Starting pppd...")); - odebug << "execppp() returned with return-code " << result << "" << oendl; + odebug << "execppp() returned with return-code " << result << "" << oendl; if(result) { if(!_ifaceppp->data()->autoDNS()) adddns( _ifaceppp ); // O.K we are done here, let's change over to the if_waiting loop // where we wait for the ppp if (interface) to come up. emit if_waiting_signal(); } else { // starting pppd wasn't successful. Error messages were // handled by execppp(); if_timeout_timer->stop(); this->hide(); messg->setText(""); // p_kppp->quit_b->setFocus(); // p_kppp->show(); qApp->processEvents(); _ifaceppp->modem()->hangup(); emit stopAccounting(); // p_kppp->con_win->stopClock(); _ifaceppp->modem()->closetty(); _ifaceppp->modem()->unlockdevice(); } return; } } // this is a "wait until cancel" entry if(vmain == 20) { } } void ConnectWidget::set_con_speed_string() { // Here we are trying to determine the speed at which we are connected. // Usually the modem responds after connect with something like // CONNECT 115200, so all we need to do is find the number after CONNECT // or whatever the modemConnectResp() is. // p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer); } void ConnectWidget::readChar(unsigned char c) { if(semaphore) return; readbuffer += c; myreadbuffer += c; // While in scanning mode store each char to the scan buffer // for use in the prompt command if( scanning ) scanbuffer += c; // add to debug window emit debugPutChar(c); checkBuffers(); } void ConnectWidget::checkBuffers() { // Let's check if we are finished with scanning: // The scanstring have to be in the buffer and the latest character // was a carriage return or an linefeed (depending on modem setup) if( scanning && scanbuffer.contains(scanstr) && ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { scanning = false; int vstart = scanbuffer.find( scanstr ) + scanstr.length(); scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); scanvar = scanvar.stripWhiteSpace(); // Show the Variabel content in the debug window QString sv = QObject::tr("Scan Var: %1").arg(scanvar); emit debugMessage(sv); } if(expecting) { if(readbuffer.contains(expectstr)) { expecting = false; // keep everything after the expected string readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); QString ts = QObject::tr("Found: %1").arg(expectstr); emit debugMessage(ts); if (loopend) { loopend=false; } @@ -972,193 +973,193 @@ void ConnectWidget::pause() { void ConnectWidget::cancelbutton() { _ifaceppp->modem()->stop(); killTimer(main_timer_ID); timeout_timer->stop(); if_timer->stop(); if_timeout_timer->stop(); // if (termwindow) { // delete termwindow; // termwindow = 0L; // this->show(); // } messg->setText(QObject::tr("One moment please...")); // just to be sure _ifaceppp->modem()->removeSecret(AUTH_PAP); _ifaceppp->modem()->removeSecret(AUTH_CHAP); removedns(_ifaceppp); qApp->processEvents(); _ifaceppp->modem()->killPPPDaemon(); _ifaceppp->modem()->hangup(); // p_kppp->quit_b->setFocus(); // p_kppp->show(); // emit stopAccounting(); // just to be sure // p_kppp->con_win->stopClock(); _ifaceppp->modem()->closetty(); _ifaceppp->modem()->unlockdevice(); //abort prompt window... if (prompt->isVisible()) { prompt->hide(); } prompt->setConsumed(); _ifaceppp->setStatus( false ); _ifaceppp->refresh(); // messg->setText(tr("offline")); refresh(); } void ConnectWidget::script_timed_out() { if(vmain == 20) { // we are in the 'wait for the user to cancel' state timeout_timer->stop(); emit stopAccounting(); // p_kppp->con_win->stopClock(); return; } if (prompt->isVisible()) prompt->hide(); prompt->setConsumed(); messg->setText(QObject::tr("Script timed out!")); _ifaceppp->modem()->hangup(); emit stopAccounting(); // p_kppp->con_win->stopClock(); vmain = 0; // let's try again. substate = -1; } void ConnectWidget::setScan(const QString &n) { scanning = true; scanstr = n; scanbuffer = ""; QString ts = QObject::tr("Scanning: %1").arg(n); emit debugMessage(ts); } void ConnectWidget::setExpect(const QString &n) { expecting = true; expectstr = n; QString ts = QObject::tr("Expecting: %1").arg(n); ts.replace(QRegExp("\n"), "<LF>"); emit debugMessage(ts); // check if the expected string is in the read buffer already. checkBuffers(); } void ConnectWidget::if_waiting_timed_out() { if_timer->stop(); if_timeout_timer->stop(); - odebug << "if_waiting_timed_out()" << oendl; + odebug << "if_waiting_timed_out()" << oendl; _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); // let's kill the stuck pppd _ifaceppp->modem()->killPPPDaemon(); emit stopAccounting(); // p_kppp->con_win->stopClock(); // killing ppp will generate a SIGCHLD which will be caught in pppdie() // in main.cpp what happens next will depend on the boolean // reconnect_on_disconnect which is set in ConnectWidget::init(); } void ConnectWidget::pppdDied() { if_timer->stop(); if_timeout_timer->stop(); } void ConnectWidget::if_waiting_slot() { messg->setText(QObject::tr("Logging on to network...")); // if(!stats->ifIsUp()) { // if(_ifaceppp->data()->pppdError() != 0) { // // we are here if pppd died immediately after starting it. // pppdDied(); // // error message handled in main.cpp: sigPPPDDied() // return; // } // if_timer->start(100, TRUE); // single shot // return; // } // O.K the ppp interface is up and running // give it a few time to come up completly (0.2 seconds) if_timeout_timer->stop(); if_timer->stop(); usleep(200000); if(_ifaceppp->data()->autoDNS()) addpeerdns( _ifaceppp ); // Close the debugging window. If we are connected, we // are not really interested in debug output emit closeDebugWindow(); // p_kppp->statdlg->take_stats(); // start taking ppp statistics auto_hostname(_ifaceppp); if(!_ifaceppp->data()->command_on_connect().isEmpty()) { messg->setText(QObject::tr("Running startup command...")); // make sure that we don't get any async errors qApp->flushX(); execute_command(_ifaceppp->data()->command_on_connect()); messg->setText(QObject::tr("Done")); } // remove the authentication file _ifaceppp->modem()->removeSecret(AUTH_PAP); _ifaceppp->modem()->removeSecret(AUTH_CHAP); emit debugMessage(QObject::tr("Done")); set_con_speed_string(); // p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); // this->hide(); // messg->setText(""); _ifaceppp->setStatus( true ); m_refreshTimer = new QTimer( this ); connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); m_refreshTimer->start( 3000 ); //_ifaceppp->refresh(); // emit _ifaceppp->updateInterface(_ifaceppp); // prepare the con_win so as to have the right size for // accounting / non-accounting mode // if(p_kppp->acct != 0) // p_kppp->con_win->accounting(p_kppp->acct->running()); // else // p_kppp->con_win->accounting(false); // if (_ifaceppp->data()->get_dock_into_panel()) { // // DockWidget::dock_widget->show(); // // DockWidget::dock_widget->take_stats(); // // this->hide(); // } // else { // // p_kppp->con_win->show(); // if(_ifaceppp->data()->get_iconify_on_connect()) { @@ -1179,193 +1180,193 @@ void ConnectWidget::refresh() { } bool ConnectWidget::execppp() { QString command; command = "pppd"; // as of version 2.3.6 pppd falls back to the real user rights when // opening a device given in a command line. To avoid permission conflicts // we'll simply leave this argument away. pppd will then use the default tty // which is the serial port we connected stdin/stdout to in opener.cpp. // command += " "; // command += _ifaceppp->data()->modemDevice(); command += " " + _ifaceppp->data()->speed(); command += " -detach"; if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || _ifaceppp->data()->gateway() != "0.0.0.0") { if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { command += " "; command += _ifaceppp->data()->ipaddr(); command += ":"; } else { command += " "; command += ":"; } if(_ifaceppp->data()->gateway() != "0.0.0.0") command += _ifaceppp->data()->gateway(); } if(_ifaceppp->data()->subnetmask() != "0.0.0.0") command += " netmask " + _ifaceppp->data()->subnetmask(); if(_ifaceppp->data()->flowcontrol() != "None") { if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") command += " crtscts"; else command += " xonxoff"; } if(_ifaceppp->data()->defaultroute()) command += " defaultroute"; if(_ifaceppp->data()->autoDNS()) command += " usepeerdns"; // PAP settings if(_ifaceppp->data()->authMethod() == AUTH_PAP) { command += " -chap user "; command = command + _ifaceppp->data()->storedUsername(); } // CHAP settings if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { command += " -pap user "; command = command + _ifaceppp->data()->storedUsername(); } // PAP/CHAP settings if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { QString tmpName = _ifaceppp->data()->storedUsername(); if ( !tmpName.isEmpty() ) { command += " user "; command = command + tmpName; } } // check for debug if(_ifaceppp->data()->getPPPDebug()) command += " debug"; QStringList &arglist = _ifaceppp->data()->pppdArgument(); for ( QStringList::Iterator it = arglist.begin(); it != arglist.end(); ++it ) { command += " " + *it; } command += " call opie-kppp logfd 11"; if (command.length() > MAX_CMDLEN) { QMessageBox::critical(this, "error", QObject::tr( "pppd command + command-line arguments exceed " "2024 characters in length." )); return false; // nonsensically long command which would bust my buffer buf. } - owarn << "Command IS: " << command.latin1() << "" << oendl; + owarn << "Command IS: " << command.latin1() << "" << oendl; qApp->flushX(); return _ifaceppp->modem()->execPPPDaemon(command); } void ConnectWidget::closeEvent( QCloseEvent *e ) { e->ignore(); emit cancelbutton(); } void ConnectWidget::setMsg(const QString &msg) { messg->setText(msg); } void ConnectWidget::writeline(const QString &s) { _ifaceppp->modem()->writeLine(s.local8Bit()); } // Set the hostname and domain from DNS Server void auto_hostname(InterfacePPP *_ifaceppp) { struct in_addr local_ip; struct hostent *hostname_entry; QString new_hostname; int dot; char tmp_str[100]; // buffer overflow safe gethostname(tmp_str, sizeof(tmp_str)); tmp_str[sizeof(tmp_str)-1]=0; // panic old_hostname=tmp_str; // copy to QString // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) { if ( _ifaceppp->data()->autoname()) { // local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii()); hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET); if (hostname_entry != 0L) { new_hostname=hostname_entry->h_name; dot=new_hostname.find('.'); new_hostname=new_hostname.remove(dot,new_hostname.length()-dot); _ifaceppp->modem()->setHostname(new_hostname); modified_hostname = TRUE; new_hostname=hostname_entry->h_name; new_hostname.remove(0,dot+1); add_domain(new_hostname, _ifaceppp); } } } // Replace the DNS domain entry in the /etc/resolv.conf file and // disable the nameserver entries if option is enabled void add_domain(const QString &domain, InterfacePPP *_ifaceppp) { int fd; char c; QString resolv[MAX_RESOLVCONF_LINES]; if (domain.isEmpty()) return; if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) { int i=0; while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) { if(c == '\n') { i++; } else { resolv[i] += c; } } close(fd); if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++; if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) { QCString tmp = "domain " + domain.local8Bit() + " \t\t#kppp temp entry\n"; write(fd, tmp.data(), tmp.length()); for(int j=0; j < i; j++) { if((resolv[j].contains("domain") || ( resolv[j].contains("nameserver") && !resolv[j].contains("#kppp temp entry") && _ifaceppp->data()->exDNSDisabled())) && !resolv[j].contains("#entry disabled by kppp")) { QCString tmp = "# " + resolv[j].local8Bit() + " \t#entry disabled by kppp\n"; write(fd, tmp, tmp.length()); } else { QCString tmp = resolv[j].local8Bit() + "\n"; 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,186 +1,186 @@ /* * 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; + 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; + 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 { 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 @@ -1109,103 +1109,103 @@ void ScriptWidget::insertButton() 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; + 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; + odebug << "getting interfaces" << oendl; for( it = ifaces.begin(); it != ifaces.end(); ++it ) { - odebug << "ifaces " << it.key().latin1() << " " << it.data().latin1() << "" << oendl; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + odebug << "isAvailable " << p << "" << oendl; return true; } - odebug << "notAvailable " << p << "" << oendl; + 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 @@ -23,193 +23,192 @@ using namespace Opie::Net; #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; |