author | tille <tille> | 2003-06-21 15:34:55 (UTC) |
---|---|---|
committer | tille <tille> | 2003-06-21 15:34:55 (UTC) |
commit | 5f5accf337a109371296c6a78175734454165406 (patch) (side-by-side diff) | |
tree | 7c4334febdedcd8c0b42a2296af6875f6f990762 /noncore | |
parent | fde32755685bec14851f943be337e94675caf0c4 (diff) | |
download | opie-5f5accf337a109371296c6a78175734454165406.zip opie-5f5accf337a109371296c6a78175734454165406.tar.gz opie-5f5accf337a109371296c6a78175734454165406.tar.bz2 |
channel count for wellenreiter
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 @@ -10,17 +10,17 @@ #define MAPPING "mapping" /** * 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); if (!file.open(IO_ReadOnly)){ qDebug("Interfaces: Can't open file: %s for reading.", interfacesFile.latin1() ); @@ -35,20 +35,20 @@ Interfaces::Interfaces(QString useInterfacesFile){ line += "\n"; } file.close(); interfaces = QStringList::split("\n", line, true); - + currentIface = interfaces.end(); currentMapping = interfaces.end(); } /** * 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; for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { QString line = (*it).simplifyWhiteSpace(); @@ -66,12 +66,12 @@ 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)); QStringList awi = autoLines.grep(QRegExp(interface)); if(awi.count() > 1) @@ -83,14 +83,14 @@ bool Interfaces::isAuto(const QString &interface) const { * Attempt to set the auto option for interface to setAuto. * @param interface the interface to set * @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 ) { if((*it).contains(AUTO)){ //We know that they are not in any group so let add to this auto. @@ -124,10 +124,10 @@ bool Interfaces::setAuto(const QString &interface, bool setAuto){ * Set the current interface to interface. This needs to be done before you * can call getFamily(), getMethod, and get/setOption(). * @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(); interface = interface.replace(QRegExp(" "), ""); return setStanza(IFACE, interface, currentIface); @@ -135,9 +135,9 @@ 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); } @@ -148,9 +148,9 @@ bool Interfaces::isInterfaceSet() const { * @param family the family of this interface inet or inet, ipx or inet6 * Must of one of the families defined in interfaces.h * @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)) return false; QString newInterface = interface.simplifyWhiteSpace(); @@ -163,49 +163,49 @@ bool Interfaces::addInterface(const QString &interface, const QString &family, c /** * Copies interface with name interface to name newInterface * @param newInterface name of the new interface. * @return bool true if successfull - */ + */ bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ if(!setInterface(interface)) return false; // Store the old interface and bump past the stanza line. QStringList::Iterator it = currentIface; it++; - + // Add the new interface bool error; addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); if(!setInterface(newInterface)) return false; - + QStringList::Iterator newIface = currentIface; newIface++; - + // Copy all of the lines for ( ; it != interfaces.end(); ++it ){ if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) break; newIface = interfaces.insert(newIface, *it); } - + return true; } /** * Remove the currently selected interface and all of its options. * @return bool if successfull or not. - */ + */ bool Interfaces::removeInterface(){ return removeStanza(currentIface); } /** * Gets the hardware name of the interface that is currently selected. * @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()){ error = true; return QString(); @@ -225,9 +225,9 @@ QString Interfaces::getInterfaceName(bool &error){ /** * Gets the family name of the interface that is currently selected. * @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); if(error) return QString(); @@ -248,9 +248,9 @@ QString Interfaces::getInterfaceFamily(bool &error){ * Gets the method of the interface that is currently selected. * @return QString name of the method such as staic or dhcp. * 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); if(error) return QString(); @@ -266,49 +266,49 @@ QString Interfaces::getInterfaceMethod(bool &error){ return line; } /** - * 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()) return false; QString name = newName.simplifyWhiteSpace(); name = name.replace(QRegExp(" "), ""); 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()) return false; if(acceptedFamily.contains(newName)==0) return false; bool returnValue = false; (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); - return !returnValue; + return !returnValue; } /** * Sets the interface method to newName * @param newName the new name of the interface * @return bool true if successfull. - */ + */ bool Interfaces::setInterfaceMethod(const QString &newName){ if(currentIface == interfaces.end()) return false; bool returnValue = false; (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); - return !returnValue; + return !returnValue; } /** * Get a value for an option in the currently selected interface. For example @@ -318,9 +318,9 @@ bool Interfaces::setInterfaceMethod(const QString &newName){ * address 192.168.1.1 * @param option the options to get the value. * @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); } @@ -330,38 +330,38 @@ QString Interfaces::getInterfaceOption(const QString &option, bool &error){ * @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::setInterfaceOption(const QString &option, const QString &value){ return setOption(currentIface, option, 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); } /** - * 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); } /** * 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); } @@ -369,10 +369,10 @@ bool Interfaces::removeAllInterfaceOptions(){ * Set the current map to interface's map. This needs to be done before you * can call addMapping(), set/getMap(), and get/setScript(). * @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(); interfaceName = interfaceName.replace(QRegExp(" "), ""); return setStanza(MAPPING, interfaceName, currentMapping); @@ -380,9 +380,9 @@ 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(""); interfaces.append(QString(MAPPING " %1").arg(option)); } @@ -392,16 +392,16 @@ void Interfaces::addMapping(const QString &option){ * @return bool if successfull or not. */ bool Interfaces::removeMapping(){ return removeStanza(currentMapping); -} +} /** * Set a map option within a mapping. * @param map map to use * @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); } @@ -409,9 +409,9 @@ bool Interfaces::setMap(const QString &map, const QString &value){ * Removes a map option within a mapping. * @param map map to use * @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); } @@ -419,40 +419,40 @@ bool Interfaces::removeMap(const QString &map, const QString &value){ * Get a map value within a mapping. * @param map map to get value of * @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); } /** * Sets a script value of the current mapping to argument. * @param argument the script name. * @return true if successfull. - */ + */ bool Interfaces::setScript(const QString &argument){ return setOption(currentMapping, "script", 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); } /** - * 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. * @param option string that must be in the stanza's main line. * @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; iterator = interfaces.end(); for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { @@ -491,9 +491,9 @@ bool Interfaces::setStanza(const QString &stanza, const QString &option, QString */ bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){ if(start == interfaces.end()) return false; - + bool found = false; for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ if(!found && value != ""){ @@ -522,9 +522,9 @@ bool Interfaces::setOption(const QStringList::Iterator &start, const QString &op /** * Removes a stanza and all of its options * @param stanza the stanza to remove * @return bool true if successfull. - */ + */ bool Interfaces::removeStanza(QStringList::Iterator &stanza){ if(stanza == interfaces.end()) return false; (*stanza) = ""; @@ -539,9 +539,9 @@ bool Interfaces::removeStanza(QStringList::Iterator &stanza){ */ bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){ if(start == interfaces.end()) return false; - + bool found = false; for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ // got to the end without finding it @@ -566,9 +566,9 @@ bool Interfaces::removeOption(const QStringList::Iterator &start, const QString */ bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){ if(start == interfaces.end()) return false; - + bool found = false; for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ // got to the end without finding it @@ -592,9 +592,9 @@ bool Interfaces::removeOption(const QStringList::Iterator &start, const QString */ bool Interfaces::removeAllOptions(const QStringList::Iterator &start){ if(start == interfaces.end()) return false; - + QStringList::Iterator it = start; it = ++it; for (; it != interfaces.end(); ++it ) { if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ @@ -619,9 +619,9 @@ QString Interfaces::getOption(const QStringList::Iterator &start, const QString if(start == interfaces.end()){ error = false; return QString(); } - + QString value; bool found = false; for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ @@ -646,9 +646,9 @@ QString Interfaces::getOption(const QStringList::Iterator &start, const QString /** * Write out the interfaces file to the file passed into the constructor. * Removes any excess blank lines over 1 line long. * @return bool true if successfull, false if not. - */ + */ bool Interfaces::write(){ QFile::remove(interfacesFile); QFile file(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 @@ -186,8 +186,10 @@ void InterfaceSetupImp::setProfile(const QString &profile){ }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)); 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 @@ -131,11 +131,28 @@ void WLANModule::receive(const QCString ¶m, const QByteArray &arg) QDataStream stream(arg,IO_ReadOnly); 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()); // find interfaces Interface *ifa=0; @@ -174,9 +191,13 @@ void WLANModule::receive(const QCString ¶m, const QByteArray &arg) toShow = (QDialog*) wlanconfigWiget; } 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; bool found = false; for ( int i = 0; i < combo->count(); i++) @@ -193,10 +214,12 @@ 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 ); } }else if (action.contains("MacAddr")){ @@ -204,19 +227,26 @@ void WLANModule::receive(const QCString ¶m, const QByteArray &arg) wlanconfigWiget->macEdit->setText( value ); }else qDebug("wlan plugin has no clue"); } + qDebug("next stream"); }// while stream + qDebug("end of stream"); if (toShow) toShow->exec(); + qDebug("returning"); } QWidget *WLANModule::getInfo( Interface *i) { qDebug("WLANModule::getInfo start"); WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); 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; } |