Diffstat (limited to 'noncore/settings/networksettings/interfaces/interface.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/interfaces/interface.cpp | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/noncore/settings/networksettings/interfaces/interface.cpp b/noncore/settings/networksettings/interfaces/interface.cpp index cc45525..69b55d1 100644 --- a/noncore/settings/networksettings/interfaces/interface.cpp +++ b/noncore/settings/networksettings/interfaces/interface.cpp @@ -2,5 +2,5 @@ * $Author$ * $Date$ - */ + */ #include "interface.h" @@ -25,5 +25,5 @@ Interface::Interface(QObject * parent, const char * name, bool newSatus): QObjec * @param newStatus - the new status * emit updateInterface - */ + */ void Interface::setStatus(bool newStatus){ if(status != newStatus){ @@ -37,25 +37,25 @@ void Interface::setStatus(bool newStatus){ * @param isAttached - if attached * emit updateInterface - */ + */ void Interface::setAttached(bool isAttached){ attached = isAttached; emit(updateInterface(this)); }; - + /** * Set Hardware name * @param name - the new name * emit updateInterface - */ + */ void Interface::setHardwareName(const QString &name){ hardwareName = name; emit(updateInterface(this)); }; - + /** * Set Module owner * @param owner - the new owner * emit updateInterface - */ + */ void Interface::setModuleOwner(Module *owner){ moduleOwner = owner; @@ -66,12 +66,12 @@ void Interface::setModuleOwner(Module *owner){ /** * Try to start the interface. - */ + */ void Interface::start(){ - // check to see if we are already running. + // check to see if we are already running. if(true == status){ emit (updateMessage("Unable to start interface,\n already started")); return; } - + int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); // See if it was successfull... @@ -90,10 +90,10 @@ void Interface::start(){ */ void Interface::stop(){ - // check to see if we are already stopped. + // check to see if we are already stopped. if(false == status){ emit (updateMessage("Unable to stop interface,\n already stopped")); return; } - + int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); if(ret != 0){ @@ -109,5 +109,5 @@ void Interface::stop(){ /** * Try to restart the interface. - */ + */ void Interface::restart(){ stop(); @@ -134,12 +134,12 @@ bool Interface::refresh(){ return true; } - + QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name()); - int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1()); + 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()); return false; } - + QFile file(fileName); if (!file.open(IO_ReadOnly)){ @@ -153,5 +153,5 @@ bool Interface::refresh(){ subnetMask = "0.0.0.0"; broadcast = ""; - + QTextStream stream( &file ); QString line; @@ -186,11 +186,11 @@ bool Interface::refresh(){ leaseExpires = ""; dhcp = false; - + QString dhcpDirectory(DHCP_INFO_DIR); QDir d(dhcpDirectory); if(!d.exists(dhcpDirectory)) dhcpDirectory = "/var/run"; - - // See if we have + + // See if we have QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); // If there is no DHCP information then exit now with no errors. @@ -199,5 +199,5 @@ bool Interface::refresh(){ return true; } - + file.setName(dhcpFile); if (!file.open(IO_ReadOnly)){ @@ -205,9 +205,9 @@ bool Interface::refresh(){ return false; } - + // leaseTime and renewalTime and used if pid and deamon exe can be accessed. int leaseTime = 0; int renewalTime = 0; - + stream.setDevice( &file ); while ( !stream.eof() ) { @@ -223,5 +223,5 @@ bool Interface::refresh(){ //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); - + // Get the pid of the deamond dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name())); @@ -245,5 +245,5 @@ bool Interface::refresh(){ } - // Get the start running time of the deamon + // Get the start running time of the deamon fileName = (QString("/proc/%1/stat").arg(pid)); file.setName(fileName); @@ -258,5 +258,5 @@ bool Interface::refresh(){ file.close(); long time = 0; - // Grab the start time + // Grab the start time // pid com state ppid pgrp session tty_nr tpgid flags sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " @@ -266,5 +266,5 @@ bool Interface::refresh(){ "%*d %*d %*d %lu", (long*) &time); time = time/100; - + QDateTime datetime(QDateTime::currentDateTime()); @@ -282,17 +282,17 @@ bool Interface::refresh(){ return false; } - + datetime = datetime.addSecs(time); //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1()); - - // Calculate the start and renew times + + // Calculate the start and renew times leaseObtained = datetime.toString(); - - // Calculate the start and renew times + + // Calculate the start and renew times datetime = datetime.addSecs(leaseTime); leaseExpires = datetime.toString(); - + dhcp = true; - + emit(updateInterface(this)); return true; |