Diffstat (limited to 'noncore/net/networksetup/interface.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/networksetup/interface.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/noncore/net/networksetup/interface.cpp b/noncore/net/networksetup/interface.cpp index 5b21364..1f32093 100644 --- a/noncore/net/networksetup/interface.cpp +++ b/noncore/net/networksetup/interface.cpp @@ -1,9 +1,10 @@ #include "interface.h" #include <qdatetime.h> #include <qfile.h> +#include <qdir.h> #include <qfileinfo.h> #include <qtextstream.h> #define IFCONFIG "/sbin/ifconfig" #define HDCP_INFO_DIR "/etc/dhcpc" @@ -124,15 +125,20 @@ bool Interface::refresh(){ // DHCP TESTING // reset DHCP info dhcpServerIp = ""; leaseObtained = ""; leaseExpires = ""; dhcp = false; - + + QString dhcpDirectory(HDCP_INFO_DIR); + QDir d(dhcpDirectory); + if(!d.exists(dhcpDirectory)) + dhcpDirectory = "/var/run"; + // See if we have - QString dhcpFile(QString(HDCP_INFO_DIR "/dhcpcd-%1.info").arg(interfaceName)); + QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName)); // If there is no DHCP information then exit now with no errors. if(!QFile::exists(dhcpFile)){ return true; } file.setName(dhcpFile); @@ -145,25 +151,25 @@ bool Interface::refresh(){ int leaseTime = 0; int renewalTime = 0; stream.setDevice( &file ); while ( !stream.eof() ) { line = stream.readLine(); - if(line.contains("DHCPSID=")) - dhcpServerIp = line.mid(8, line.length()); + if(line.contains("DHCPSIADDR=")) + dhcpServerIp = line.mid(11, line.length()); 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()); // Get the pid of the deamond - dhcpFile = (QString(HDCP_INFO_DIR "/dhcpcd-%1.pid").arg(interfaceName)); + dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(interfaceName)); file.setName(dhcpFile); if (!file.open(IO_ReadOnly)){ qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); return false; } |