summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/interfaces
authormickeyl <mickeyl>2004-04-04 13:54:40 (UTC)
committer mickeyl <mickeyl>2004-04-04 13:54:40 (UTC)
commit16cf79e90b5217f8d4bfce2a0fa817ae4b73db36 (patch) (side-by-side diff)
tree0701eae15aa606a0211a2fccfde0eafdac69357c /noncore/settings/networksettings/interfaces
parent8d2d2664e5f544b8292806e617deb7a0e4170dc0 (diff)
downloadopie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.zip
opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.gz
opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.bz2
convert to Opie Debugging Framework
Diffstat (limited to 'noncore/settings/networksettings/interfaces') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interface.cpp20
-rw-r--r--noncore/settings/networksettings/interfaces/interfaces.cpp42
-rw-r--r--noncore/settings/networksettings/interfaces/interfacesetupimp.cpp14
3 files changed, 38 insertions, 38 deletions
diff --git a/noncore/settings/networksettings/interfaces/interface.cpp b/noncore/settings/networksettings/interfaces/interface.cpp
index b00b899..d2b106a 100644
--- a/noncore/settings/networksettings/interfaces/interface.cpp
+++ b/noncore/settings/networksettings/interfaces/interface.cpp
@@ -134,19 +134,19 @@ bool Interface::refresh(){
return true;
}
QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name());
int ret = system(QString("LANG=C %1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1());
if(ret != 0){
- qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1());
+ odebug << QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1() << oendl;
return false;
}
QFile file(fileName);
if (!file.open(IO_ReadOnly)){
- qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
+ odebug << QString("Interface: Can't open file: %1").arg(fileName).latin1() << oendl;
return false;
}
// Set to the defaults
macAddress = "";
ip = "0.0.0.0";
@@ -198,13 +198,13 @@ bool Interface::refresh(){
emit(updateInterface(this));
return true;
}
file.setName(dhcpFile);
if (!file.open(IO_ReadOnly)){
- qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
+ odebug << QString("Interface: Can't open file: %1").arg(dhcpFile).latin1() << oendl;
return false;
}
// leaseTime and renewalTime and used if pid and deamon exe can be accessed.
int leaseTime = 0;
int renewalTime = 0;
@@ -217,42 +217,42 @@ bool Interface::refresh(){
if(line.contains("LEASETIME="))
leaseTime = line.mid(10, line.length()).toInt();
if(line.contains("RENEWALTIME="))
renewalTime = line.mid(12, line.length()).toInt();
}
file.close();
- //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1());
- //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1());
+ //odebug << QString("Interface: leaseTime: %1").arg(leaseTime).latin1() << oendl;
+ //odebug << QString("Interface: renewalTime: %1").arg(renewalTime).latin1() << oendl;
// Get the pid of the deamond
dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name()));
file.setName(dhcpFile);
if (!file.open(IO_ReadOnly)){
- qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
+ odebug << QString("Interface: Can't open file: %1").arg(dhcpFile).latin1() << oendl;
return false;
}
int pid = -1;
stream.setDevice( &file );
while ( !stream.eof() ) {
line = stream.readLine();
pid = line.toInt();
}
file.close();
if( pid == -1){
- qDebug("Interface: Could not get pid of dhcpc deamon.");
+ odebug << "Interface: Could not get pid of dhcpc deamon." << oendl;
return false;
}
// Get the start running time of the deamon
fileName = (QString("/proc/%1/stat").arg(pid));
file.setName(fileName);
stream.setDevice( &file );
if (!file.open(IO_ReadOnly)){
- qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
+ odebug << QString("Interface: Can't open file: %1").arg(fileName).latin1() << oendl;
return false;
}
while ( !stream.eof() ) {
line = stream.readLine();
}
file.close();
@@ -275,18 +275,18 @@ bool Interface::refresh(){
int sec = 0;
t >> sec;
datetime = datetime.addSecs((-1*sec));
f.close();
}
else{
- qDebug("Interface: Can't open /proc/uptime to retrive uptime.");
+ odebug << "Interface: Can't open /proc/uptime to retrive uptime." << oendl;
return false;
}
datetime = datetime.addSecs(time);
- //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1());
+ //odebug << QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1() << oendl;
// Calculate the start and renew times
leaseObtained = datetime.toString();
// Calculate the start and renew times
datetime = datetime.addSecs(leaseTime);
diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp
index 6b161ae..e283926 100644
--- a/noncore/settings/networksettings/interfaces/interfaces.cpp
+++ b/noncore/settings/networksettings/interfaces/interfaces.cpp
@@ -21,13 +21,13 @@ Interfaces::Interfaces(QString useInterfacesFile){
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() );
+ odebug << "Interfaces: Can't open file: " << interfacesFile.latin1() << " for reading." << oendl;
currentIface = interfaces.end();
currentMapping = interfaces.end();
return;
}
QTextStream stream( &file );
QString line;
@@ -73,13 +73,13 @@ QStringList Interfaces::getInterfaceList(){
* @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());
+ odebug << QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1() << oendl;
return awi.count() > 0;
}
/**
* Attempt to set the auto option for interface to setAuto.
* @param interface the interface to set
@@ -149,13 +149,13 @@ 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 successful.
*/
bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){
- qDebug("Interfaces::addInterface(%s)",interface.latin1());
+ odebug << "Interfaces::addInterface(" << interface.latin1() << ")" << oendl;
if(0 == acceptedFamily.contains(family))
return false;
QString newInterface = interface.simplifyWhiteSpace();
newInterface = newInterface.replace(QRegExp(" "), "");
interfaces.append("");
interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method));
@@ -165,13 +165,13 @@ 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 successful
*/
bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){
- qDebug("copy interface %s to %s", interface.latin1(), newInterface.latin1());
+ odebug << "copy interface " << interface.latin1() << " to " << newInterface.latin1() << "" << oendl;
if(!setInterface(interface))
return false;
// Store the old interface and bump past the stanza line.
QStringList::Iterator it = currentIface;
it++;
@@ -272,20 +272,20 @@ QString Interfaces::getInterfaceMethod(bool &error){
/**
* Sets the interface name to newName.
* @param newName the new name of the interface. All whitespace is removed.
* @return bool true if successful.
*/
bool Interfaces::setInterfaceName(const QString &newName){
- qDebug("setInterfaceName %s", newName.latin1());
+ odebug << "setInterfaceName " << newName.latin1() << "" << oendl;
if(currentIface == interfaces.end())
return false;
QString name = newName.simplifyWhiteSpace();
name = name.replace(QRegExp(" "), "");
bool returnValue = false;
QString tmp = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
- qDebug("setting %s",tmp.latin1());
+ odebug << "setting " << tmp.latin1() << "" << oendl;
(*currentIface) = tmp;
return !returnValue;
}
/**
@@ -342,13 +342,13 @@ QString Interfaces::getInterfaceOption(const QString &option, bool &error){
* @return QString the options value. QString::null if error == true
*/
bool Interfaces::setInterfaceOption(const QString &option, const QString &value){
if( value.stripWhiteSpace().isEmpty() )
return removeInterfaceOption( option );
- qDebug("iface >%s< option >%s< value >%s<", (*currentIface).latin1(), option.latin1(),value.latin1());
+ odebug << "iface >" << (*currentIface).latin1() << "< option >" << option.latin1() << "< value >" << value.latin1() << "<" << oendl;
return setOption(currentIface, option, value);
}
/**
* Removes a value for an option in the currently selected interface.
* @param option the options to set the value.
@@ -483,13 +483,13 @@ bool Interfaces::setStanza(const QString &stanza, const QString &option, QString
// There are more chars in the line. check -1
if(line.at(point) != ' ')
valid = false;
}
if(valid){
if(found == true){
- qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
+ odebug << QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1() << oendl;
}
found = true;
iterator = it;
}
}
}
@@ -502,53 +502,53 @@ bool Interfaces::setStanza(const QString &stanza, const QString &option, QString
* @param option the option to use when setting value.
* @return bool true if successful, false otherwise.
*/
bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){
if(start == interfaces.end())
return false;
- qDebug("setting option");
+ odebug << "setting option" << oendl;
bool found = false;
bool replaced = false;
QStringList::Iterator insertAt = NULL;
for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
- qDebug(" Interfaces::setOption got line >%s<",(*it).latin1());
+ odebug << " Interfaces::setOption got line >" << (*it).latin1() << "<" << oendl;
// FIXME: was not completly stupid just wrong sice all options got inserted bevore the iface line
// but since it works with an empty interfaces file I (tille) will not do anything more
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) ){
if (found) break;
// && it != start){
// if(!found && value != ""){
// // Got to the end of the stanza without finding it, so append it.
-// qDebug(" Got to the end of the stanza without finding it, so append it.");
+// odebug << " Got to the end of the stanza without finding it, so append it." << oendl;
// interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
// }
- qDebug("found 1");
+ odebug << "found 1" << oendl;
// interfaces.insert(++it, QString("\t%1 %2").arg(option).arg(value));
found = true;
insertAt = it;
}
if((*it).contains(option) && it != start && (*it).at(0) != '#'){
// Found it in stanza so replace it.
- qDebug("found 2");
+ odebug << "found 2" << oendl;
if(found)
- qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
+ odebug << QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1() << oendl;
found = true;
replaced = true;
(*it) = QString("\t%1 %2").arg(option).arg(value);
}
}
if(!found){
- qDebug("! found insert anyway");
+ odebug << "! found insert anyway" << oendl;
QStringList::Iterator p = start;
interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
found = true;
}
if(found && !replaced){
- qDebug("found iface but not the option so insert it here...");
+ odebug << "found iface but not the option so insert it here..." << oendl;
interfaces.insert(++insertAt, QString("\t%1 %2").arg(option).arg(value));
}
return found;
}
/**
@@ -579,13 +579,13 @@ bool Interfaces::removeOption(const QStringList::Iterator &start, const QString
// got to the end without finding it
break;
}
if((*it).contains(option) && it != start && (*it).at(0) != '#'){
// Found it in stanza so replace it.
if(found)
- qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
+ odebug << QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1() << oendl;
found = true;
it = interfaces.remove( it ); // we really want to remove the line
--it; // we do ++it later in the head of the for loop
}
}
return found;
@@ -607,13 +607,13 @@ bool Interfaces::removeOption(const QStringList::Iterator &start, const QString
// got to the end without finding it
break;
}
if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){
// Found it in stanza so replace it.
if(found)
- qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
+ odebug << QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1() << oendl;
found = true;
it = interfaces.remove( it ); // we really want to remove the line
--it; // we do ++it later in the head of the for loop
}
}
return found;
@@ -660,13 +660,13 @@ QString Interfaces::getOption(const QStringList::Iterator &start, const QString
for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
break;
}
if((*it).contains(option) && (*it).at(0) != '#'){
if(found)
- qDebug(QString("Interfaces: getOption found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1());
+ odebug << QString("Interfaces: getOption found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1() << oendl;
found = true;
QString line = (*it).simplifyWhiteSpace();
int space = line.find(" ", option.length());
if(space != -1){
value = line.mid(space+1, line.length());
break;
@@ -684,26 +684,26 @@ QString Interfaces::getOption(const QStringList::Iterator &start, const QString
*/
bool Interfaces::write(){
QFile::remove(interfacesFile);
QFile file(interfacesFile);
if (!file.open(IO_ReadWrite)){
- qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1());
+ odebug << QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1() << oendl;
return false;
}
QTextStream stream( &file );
int whiteSpaceCount = 0;
for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
QString line = (*it).simplifyWhiteSpace();
line = line.replace(QRegExp(" "),"");
if(line.length() == 0)
whiteSpaceCount++;
else
whiteSpaceCount = 0;
if(whiteSpaceCount < 2){
- qDebug((*it).latin1());
+ odebug << (*it).latin1() << oendl;
stream << (*it) << '\n';
}
}
file.close();
return true;
}
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
index 7c2f85c..ec3bad3 100644
--- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
+++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
@@ -43,13 +43,13 @@ InterfaceSetupImp::~InterfaceSetupImp(){
/**
* Save the current settings, then write out the interfaces file and close.
*/
bool InterfaceSetupImp::saveChanges(){
bool error;
QString iface = interfaces->getInterfaceName(error);
- qDebug("InterfaceSetupImp::saveChanges saves interface %s", iface.latin1() );
+ odebug << "InterfaceSetupImp::saveChanges saves interface " << iface.latin1() << "" << oendl;
if(!saveSettings())
return false;
interfaces->write();
if (interface->getStatus()) {
@@ -69,13 +69,13 @@ bool InterfaceSetupImp::saveChanges(){
Global::statusMessage( tr( "Restarting interface" ) );
owait->show();
qApp->processEvents();
if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) {
- qWarning("unstable to spawn ifdown/ifup");
+ owarn << "unstable to spawn ifdown/ifup" << oendl;
}
owait->hide();
delete owait;
interface->refresh();
@@ -154,23 +154,23 @@ void InterfaceSetupImp::setProfile(const QString &profile){
// 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())){
- qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface.");
+ 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)){
- qDebug("InterfaceSetupImp: Added interface, but still can't setInterface.");
+ 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.
@@ -182,13 +182,13 @@ void InterfaceSetupImp::setProfile(const QString &profile){
else
dhcpCheckBox->setChecked(false);
// IP Information
autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName()));
QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error);
- qDebug("dns >%s<",dns.latin1());
+ 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));
@@ -196,13 +196,13 @@ void InterfaceSetupImp::setProfile(const QString &profile){
if (subnetMaskEdit->text().isEmpty())
subnetMaskEdit->setText( "255.255.255.0" );
gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error));
- qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1());
- qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1());
+ owarn << "InterfaceSetupImp::setProfile(" << profile.latin1() << ")\n" << oendl;
+ owarn << "InterfaceSetupImp::setProfile: iface is " << interfaces->getInterfaceName(error).latin1() << "\n" << oendl;
}
// interfacesetup.cpp