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 | |
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 @@ -11,15 +11,15 @@ /** * 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)){ @@ -36,7 +36,7 @@ Interfaces::Interfaces(QString useInterfacesFile){ } file.close(); interfaces = QStringList::split("\n", line, true); - + currentIface = interfaces.end(); currentMapping = interfaces.end(); } @@ -44,10 +44,10 @@ 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; for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { @@ -67,10 +67,10 @@ 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)); @@ -84,12 +84,12 @@ bool Interfaces::isAuto(const QString &interface) const { * @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)){ @@ -125,8 +125,8 @@ bool Interfaces::setAuto(const QString &interface, bool setAuto){ * 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(" "), ""); @@ -136,7 +136,7 @@ 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); } @@ -149,7 +149,7 @@ bool Interfaces::isInterfaceSet() const { * 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; @@ -164,7 +164,7 @@ 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; @@ -172,30 +172,30 @@ bool Interfaces::copyInterface(const QString &interface, const QString &newInter // 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); } @@ -204,7 +204,7 @@ bool Interfaces::removeInterface(){ * 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; @@ -226,7 +226,7 @@ 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) @@ -249,7 +249,7 @@ QString Interfaces::getInterfaceFamily(bool &error){ * @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) @@ -267,10 +267,10 @@ 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()) return false; @@ -278,15 +278,15 @@ bool Interfaces::setInterfaceName(const QString &newName){ 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; @@ -294,20 +294,20 @@ bool Interfaces::setInterfaceFamily(const QString &newName){ 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; } /** @@ -319,7 +319,7 @@ bool Interfaces::setInterfaceMethod(const QString &newName){ * @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); } @@ -331,36 +331,36 @@ QString Interfaces::getInterfaceOption(const QString &option, bool &error){ * @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); } @@ -370,8 +370,8 @@ bool Interfaces::removeAllInterfaceOptions(){ * 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(" "), ""); @@ -381,7 +381,7 @@ 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)); @@ -393,14 +393,14 @@ void Interfaces::addMapping(const QString &option){ */ 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); } @@ -410,7 +410,7 @@ bool Interfaces::setMap(const QString &map, const QString &value){ * @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); } @@ -420,7 +420,7 @@ bool Interfaces::removeMap(const QString &map, const QString &value){ * @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); } @@ -429,7 +429,7 @@ QString Interfaces::getMap(const QString &map, bool &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); } @@ -437,7 +437,7 @@ 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); } @@ -445,13 +445,13 @@ 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. * @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(); @@ -492,7 +492,7 @@ 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){ @@ -523,7 +523,7 @@ 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; @@ -540,7 +540,7 @@ 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){ @@ -567,7 +567,7 @@ 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){ @@ -593,7 +593,7 @@ 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 ) { @@ -620,7 +620,7 @@ QString Interfaces::getOption(const QStringList::Iterator &start, const QString error = false; return QString(); } - + QString value; bool found = false; for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { @@ -647,7 +647,7 @@ 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 @@ -187,6 +187,8 @@ 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 @@ -132,9 +132,26 @@ 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 @@ -175,7 +192,11 @@ 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; bool found = false; @@ -194,8 +215,10 @@ 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 ); } @@ -205,8 +228,11 @@ void WLANModule::receive(const QCString ¶m, const QByteArray &arg) }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) @@ -215,7 +241,11 @@ QWidget *WLANModule::getInfo( Interface *i) 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; } |