3 files changed, 92 insertions, 60 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp index a62a90c..71d0cf5 100644 --- a/noncore/settings/networksettings/interfaces/interfaces.cpp +++ b/noncore/settings/networksettings/interfaces/interfaces.cpp @@ -12,13 +12,13 @@ /** * Constructor. Reads in the interfaces file and then split the file up by - * the \n for interfaces variable. + * the \n for interfaces variable. * @param useInterfacesFile if an interface file other then the default is * desired to be used it should be passed in. - */ + */ Interfaces::Interfaces(QString useInterfacesFile){ acceptedFamily.append(INTERFACES_FAMILY_INET); acceptedFamily.append(INTERFACES_FAMILY_IPX); acceptedFamily.append(INTERFACES_FAMILY_INET6); - + interfacesFile = useInterfacesFile; QFile file(interfacesFile); @@ -37,5 +37,5 @@ Interfaces::Interfaces(QString useInterfacesFile){ file.close(); interfaces = QStringList::split("\n", line, true); - + currentIface = interfaces.end(); currentMapping = interfaces.end(); @@ -45,8 +45,8 @@ Interfaces::Interfaces(QString useInterfacesFile){ /** * Get a list of all interfaces in the interface file. Usefull for - * hardware that is not currently connected such as an 802.11b card + * hardware that is not currently connected such as an 802.11b card * not plugged in, but configured for when it is plugged in. * @return Return string list of interfaces. - **/ + **/ QStringList Interfaces::getInterfaceList(){ QStringList list; @@ -68,8 +68,8 @@ QStringList Interfaces::getInterfaceList(){ /** * Find out if interface is in an "auto" group or not. - * Report any duplicates such as eth0 being in two differnt auto's + * Report any duplicates such as eth0 being in two differnt auto's * @param interface interface to check to see if it is on or not. * @return true is interface is in auto - */ + */ bool Interfaces::isAuto(const QString &interface) const { QStringList autoLines = interfaces.grep(QRegExp(AUTO)); @@ -85,10 +85,10 @@ bool Interfaces::isAuto(const QString &interface) const { * @param setAuto the value to set interface to. * @return false if already set to setAuto. - * */ + * */ bool Interfaces::setAuto(const QString &interface, bool setAuto){ // Don't need to set it if it is already set. if(isAuto(interface) == setAuto) return false; - + bool changed = false; for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { @@ -126,6 +126,6 @@ bool Interfaces::setAuto(const QString &interface, bool setAuto){ * @param interface the name of the interface to set. All whitespace is * removed from the interface name. - * @return bool true if it is successfull. - */ + * @return bool true if it is successfull. + */ bool Interfaces::setInterface(QString interface){ interface = interface.simplifyWhiteSpace(); @@ -137,5 +137,5 @@ bool Interfaces::setInterface(QString interface){ * A quick helper funtion to see if the current interface is set. * @return bool true if set, false otherwise. - */ + */ bool Interfaces::isInterfaceSet() const { return (interfaces.end() != currentIface); @@ -150,5 +150,5 @@ bool Interfaces::isInterfaceSet() const { * @param method for the family. see interfaces man page for family methods. * @return true if successfull. - */ + */ bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ if(0 == acceptedFamily.contains(family)) @@ -165,5 +165,5 @@ bool Interfaces::addInterface(const QString &interface, const QString &family, c * @param newInterface name of the new interface. * @return bool true if successfull - */ + */ bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ if(!setInterface(interface)) @@ -173,5 +173,5 @@ bool Interfaces::copyInterface(const QString &interface, const QString &newInter QStringList::Iterator it = currentIface; it++; - + // Add the new interface bool error; @@ -179,8 +179,8 @@ bool Interfaces::copyInterface(const QString &interface, const QString &newInter if(!setInterface(newInterface)) return false; - + QStringList::Iterator newIface = currentIface; newIface++; - + // Copy all of the lines for ( ; it != interfaces.end(); ++it ){ @@ -189,5 +189,5 @@ bool Interfaces::copyInterface(const QString &interface, const QString &newInter newIface = interfaces.insert(newIface, *it); } - + return true; } @@ -196,5 +196,5 @@ bool Interfaces::copyInterface(const QString &interface, const QString &newInter * Remove the currently selected interface and all of its options. * @return bool if successfull or not. - */ + */ bool Interfaces::removeInterface(){ return removeStanza(currentIface); @@ -205,5 +205,5 @@ bool Interfaces::removeInterface(){ * @return QString name of the hardware interface (eth0, usb2, wlan1...). * @param error set to true if any error occurs, false otherwise. - */ + */ QString Interfaces::getInterfaceName(bool &error){ if(currentIface == interfaces.end()){ @@ -227,5 +227,5 @@ QString Interfaces::getInterfaceName(bool &error){ * @return QString name of the family (inet, inet6, ipx). * @param error set to true if any error occurs, false otherwise. - */ + */ QString Interfaces::getInterfaceFamily(bool &error){ QString name = getInterfaceName(error); @@ -250,5 +250,5 @@ QString Interfaces::getInterfaceFamily(bool &error){ * See the man page of interfaces for possible methods depending on the family. * @param error set to true if any error occurs, false otherwise. - */ + */ QString Interfaces::getInterfaceMethod(bool &error){ QString name = getInterfaceName(error); @@ -268,8 +268,8 @@ QString Interfaces::getInterfaceMethod(bool &error){ /** - * Sets the interface name to newName. + * Sets the interface name to newName. * @param newName the new name of the interface. All whitespace is removed. * @return bool true if successfull. - */ + */ bool Interfaces::setInterfaceName(const QString &newName){ if(currentIface == interfaces.end()) @@ -279,13 +279,13 @@ bool Interfaces::setInterfaceName(const QString &newName){ bool returnValue = false; (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); - return !returnValue; + return !returnValue; } /** - * Sets the interface family to newName. + * Sets the interface family to newName. * @param newName the new name of the interface. Must be one of the families * defined in the interfaces.h file. * @return bool true if successfull. - */ + */ bool Interfaces::setInterfaceFamily(const QString &newName){ if(currentIface == interfaces.end()) @@ -295,5 +295,5 @@ bool Interfaces::setInterfaceFamily(const QString &newName){ bool returnValue = false; (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); - return !returnValue; + return !returnValue; } @@ -302,5 +302,5 @@ bool Interfaces::setInterfaceFamily(const QString &newName){ * @param newName the new name of the interface * @return bool true if successfull. - */ + */ bool Interfaces::setInterfaceMethod(const QString &newName){ if(currentIface == interfaces.end()) @@ -308,5 +308,5 @@ bool Interfaces::setInterfaceMethod(const QString &newName){ bool returnValue = false; (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); - return !returnValue; + return !returnValue; } @@ -320,5 +320,5 @@ bool Interfaces::setInterfaceMethod(const QString &newName){ * @param error set to true if any error occurs, false otherwise. * @return QString the options value. QString::null if error == true - */ + */ QString Interfaces::getInterfaceOption(const QString &option, bool &error){ return getOption(currentIface, option, error); @@ -332,5 +332,5 @@ QString Interfaces::getInterfaceOption(const QString &option, bool &error){ * @param error set to true if any error occurs, false otherwise. * @return QString the options value. QString::null if error == true - */ + */ bool Interfaces::setInterfaceOption(const QString &option, const QString &value){ return setOption(currentIface, option, value); @@ -338,9 +338,9 @@ bool Interfaces::setInterfaceOption(const QString &option, const QString &value) /** - * Removes a value for an option in the currently selected interface. + * Removes a value for an option in the currently selected interface. * @param option the options to set the value. * @param error set to true if any error occurs, false otherwise. * @return QString the options value. QString::null if error == true - */ + */ bool Interfaces::removeInterfaceOption(const QString &option){ return removeOption(currentIface, option); @@ -348,10 +348,10 @@ bool Interfaces::removeInterfaceOption(const QString &option){ /** - * Removes a value for an option in the currently selected interface. + * Removes a value for an option in the currently selected interface. * @param option the options to set the value. * @param value the value that option should be set to. * @param error set to true if any error occurs, false otherwise. * @return QString the options value. QString::null if error == true - */ + */ bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ return removeOption(currentIface, option, value); @@ -360,6 +360,6 @@ bool Interfaces::removeInterfaceOption(const QString &option, const QString &val /** * Removes all of the options from the currently selected interface. - * @return bool error if if successfull - */ + * @return bool error if if successfull + */ bool Interfaces::removeAllInterfaceOptions(){ return removeAllOptions(currentIface); @@ -371,6 +371,6 @@ bool Interfaces::removeAllInterfaceOptions(){ * @param interface the name of the interface to set. All whitespace is * removed from the interface name. - * @return bool true if it is successfull. - */ + * @return bool true if it is successfull. + */ bool Interfaces::setMapping(const QString &interface){ QString interfaceName = interface.simplifyWhiteSpace(); @@ -382,5 +382,5 @@ bool Interfaces::setMapping(const QString &interface){ * Adds a new Mapping to the interfaces file with interfaces. * @param interface the name(s) of the interfaces to set to this mapping - */ + */ void Interfaces::addMapping(const QString &option){ interfaces.append(""); @@ -394,5 +394,5 @@ void Interfaces::addMapping(const QString &option){ bool Interfaces::removeMapping(){ return removeStanza(currentMapping); -} +} /** @@ -401,5 +401,5 @@ bool Interfaces::removeMapping(){ * @param value value to go with map * @return bool true if it is successfull. - */ + */ bool Interfaces::setMap(const QString &map, const QString &value){ return setOption(currentMapping, map, value); @@ -411,5 +411,5 @@ bool Interfaces::setMap(const QString &map, const QString &value){ * @param value value to go with map * @return bool true if it is successfull. - */ + */ bool Interfaces::removeMap(const QString &map, const QString &value){ return removeOption(currentMapping, map, value); @@ -421,5 +421,5 @@ bool Interfaces::removeMap(const QString &map, const QString &value){ * @param bool true if it is successfull. * @return value that goes to the map - */ + */ QString Interfaces::getMap(const QString &map, bool &error){ return getOption(currentMapping, map, error); @@ -430,5 +430,5 @@ QString Interfaces::getMap(const QString &map, bool &error){ * @param argument the script name. * @return true if successfull. - */ + */ bool Interfaces::setScript(const QString &argument){ return setOption(currentMapping, "script", argument); @@ -438,5 +438,5 @@ bool Interfaces::setScript(const QString &argument){ * @param error true if could not retrieve the current script argument. * @return QString the argument of the script for the current mapping. - */ + */ QString Interfaces::getScript(bool &error){ return getOption(currentMapping, "script", error); @@ -446,5 +446,5 @@ QString Interfaces::getScript(bool &error){ /** - * Helper function used to parse through the QStringList and put pointers in + * Helper function used to parse through the QStringList and put pointers in * the correct place. * @param stanza The stanza (auto, iface, mapping) to look for. @@ -452,5 +452,5 @@ QString Interfaces::getScript(bool &error){ * @param interator interator to place at location of stanza if successfull. * @return bool true if the stanza is found. - */ + */ bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){ bool found = false; @@ -493,5 +493,5 @@ bool Interfaces::setOption(const QStringList::Iterator &start, const QString &op if(start == interfaces.end()) return false; - + bool found = false; for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { @@ -524,5 +524,5 @@ bool Interfaces::setOption(const QStringList::Iterator &start, const QString &op * @param stanza the stanza to remove * @return bool true if successfull. - */ + */ bool Interfaces::removeStanza(QStringList::Iterator &stanza){ if(stanza == interfaces.end()) @@ -541,5 +541,5 @@ bool Interfaces::removeOption(const QStringList::Iterator &start, const QString if(start == interfaces.end()) return false; - + bool found = false; for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { @@ -568,5 +568,5 @@ bool Interfaces::removeOption(const QStringList::Iterator &start, const QString if(start == interfaces.end()) return false; - + bool found = false; for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { @@ -594,5 +594,5 @@ bool Interfaces::removeAllOptions(const QStringList::Iterator &start){ if(start == interfaces.end()) return false; - + QStringList::Iterator it = start; it = ++it; @@ -621,5 +621,5 @@ QString Interfaces::getOption(const QStringList::Iterator &start, const QString return QString(); } - + QString value; bool found = false; @@ -648,5 +648,5 @@ QString Interfaces::getOption(const QStringList::Iterator &start, const QString * Removes any excess blank lines over 1 line long. * @return bool true if successfull, false if not. - */ + */ bool Interfaces::write(){ QFile::remove(interfacesFile); diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp index f19cbdd..b40d101 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp @@ -188,4 +188,6 @@ void InterfaceSetupImp::setProfile(const QString &profile){ 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)); diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp index 7bded85..a4488f9 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.cpp +++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp @@ -133,7 +133,24 @@ void WLANModule::receive(const QCString ¶m, const QByteArray &arg) QString interface; QString action; + int countMsgs = 0; + stream >> interface; + qDebug("got count? >%s<",interface.latin1()); + if (interface == "count"){ + qDebug("got count"); + stream >> action; + qDebug("Got count num >%s<", action.latin1()); + countMsgs = action.toInt(); + } + QDialog *toShow; - while (! stream.atEnd() ){ + //while (! stream.atEnd() ){ + for (int i = 0; i < countMsgs; i++){ + qDebug("start stream %d/%d",i,countMsgs); + if (stream.atEnd()){ + qDebug("end of stream"); + return; + } stream >> interface; + qDebug("got iface"); stream >> action; qDebug("WLANModule got interface %s and acion %s", interface.latin1(), action.latin1()); @@ -176,5 +193,9 @@ void WLANModule::receive(const QCString ¶m, const QByteArray &arg) wlanconfigWiget->showMaximized(); stream >> value; - qDebug("WLANModule is setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() ); + qDebug("WLANModule (build 4) is setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() ); + if (value.isEmpty()){ + qDebug("value is empty!!!\nreturning"); + return; + } if ( action.contains("ESSID") ){ QComboBox *combo = wlanconfigWiget->essid; @@ -195,6 +216,8 @@ void WLANModule::receive(const QCString ¶m, const QByteArray &arg) }else if (action.contains("Channel")){ bool ok; + qDebug("converting channel"); int chan = value.toInt( &ok ); if (ok){ + qDebug("ok setting channel"); wlanconfigWiget->specifyChan->setChecked( true ); wlanconfigWiget->networkChannel->setValue( chan ); @@ -206,6 +229,9 @@ void WLANModule::receive(const QCString ¶m, const QByteArray &arg) qDebug("wlan plugin has no clue"); } + qDebug("next stream"); }// while stream + qDebug("end of stream"); if (toShow) toShow->exec(); + qDebug("returning"); } @@ -216,5 +242,9 @@ QWidget *WLANModule::getInfo( Interface *i) InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); info->tabWidget->insertTab(information, "TCP/IP", 0); - + info->tabWidget->setCurrentPage( 0 ); + info->tabWidget->showPage( information ); + if (info->tabWidget->currentPage() == information ) qDebug("infotab OK"); + else qDebug("infotab NOT OK"); + qDebug("current idx %d", info->tabWidget->currentPageIndex()); qDebug("WLANModule::getInfo return"); return info; |