author | schurig <schurig> | 2003-06-13 10:49:17 (UTC) |
---|---|---|
committer | schurig <schurig> | 2003-06-13 10:49:17 (UTC) |
commit | c48af71638614aaff280178693448916e0e98102 (patch) (side-by-side diff) | |
tree | 127db502aedb7411dd68e0a49861018e1b09d262 /noncore | |
parent | 60ba51b33a060dde352caa678f2e337f5f5590f5 (diff) | |
download | opie-c48af71638614aaff280178693448916e0e98102.zip opie-c48af71638614aaff280178693448916e0e98102.tar.gz opie-c48af71638614aaff280178693448916e0e98102.tar.bz2 |
little simplificatin -> less code size
-rw-r--r-- | noncore/settings/networksettings/interfaces/interfaces.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp index 8d3e151..a62a90c 100644 --- a/noncore/settings/networksettings/interfaces/interfaces.cpp +++ b/noncore/settings/networksettings/interfaces/interfaces.cpp @@ -10,33 +10,33 @@ #define MAPPING "mapping" /** * Constructor. Reads in the interfaces file and then split the file up by * 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(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1()); + qDebug("Interfaces: Can't open file: %s for reading.", interfacesFile.latin1() ); currentIface = interfaces.end(); currentMapping = interfaces.end(); return; } QTextStream stream( &file ); QString line; while ( !stream.eof() ) { line += stream.readLine(); line += "\n"; } file.close(); interfaces = QStringList::split("\n", line, true); currentIface = interfaces.end(); currentMapping = interfaces.end(); } @@ -54,44 +54,42 @@ QStringList Interfaces::getInterfaceList(){ QString line = (*it).simplifyWhiteSpace(); if(line.contains(IFACE) && line.at(0) != '#'){ line = line.mid(QString(IFACE).length() +1, line.length()); line = line.simplifyWhiteSpace(); int findSpace = line.find(" "); if( findSpace >= 0){ line = line.mid(0, findSpace); list.append(line); } } } return list; } /** * 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) qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); - if(awi.count() < 1) - return false; - return true; + return awi.count() > 0; } /** * 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)){ |