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 @@ | |||
1 | #include "interface.h" | 1 | #include "interface.h" |
2 | #include <qdatetime.h> | 2 | #include <qdatetime.h> |
3 | #include <qfile.h> | 3 | #include <qfile.h> |
4 | #include <qdir.h> | ||
4 | #include <qfileinfo.h> | 5 | #include <qfileinfo.h> |
5 | #include <qtextstream.h> | 6 | #include <qtextstream.h> |
6 | 7 | ||
7 | #define IFCONFIG "/sbin/ifconfig" | 8 | #define IFCONFIG "/sbin/ifconfig" |
8 | #define HDCP_INFO_DIR "/etc/dhcpc" | 9 | #define HDCP_INFO_DIR "/etc/dhcpc" |
9 | 10 | ||
@@ -124,15 +125,20 @@ bool Interface::refresh(){ | |||
124 | // DHCP TESTING | 125 | // DHCP TESTING |
125 | // reset DHCP info | 126 | // reset DHCP info |
126 | dhcpServerIp = ""; | 127 | dhcpServerIp = ""; |
127 | leaseObtained = ""; | 128 | leaseObtained = ""; |
128 | leaseExpires = ""; | 129 | leaseExpires = ""; |
129 | dhcp = false; | 130 | dhcp = false; |
130 | 131 | ||
132 | QString dhcpDirectory(HDCP_INFO_DIR); | ||
133 | QDir d(dhcpDirectory); | ||
134 | if(!d.exists(dhcpDirectory)) | ||
135 | dhcpDirectory = "/var/run"; | ||
136 | |||
131 | // See if we have | 137 | // See if we have |
132 | QString dhcpFile(QString(HDCP_INFO_DIR "/dhcpcd-%1.info").arg(interfaceName)); | 138 | QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName)); |
133 | // If there is no DHCP information then exit now with no errors. | 139 | // If there is no DHCP information then exit now with no errors. |
134 | if(!QFile::exists(dhcpFile)){ | 140 | if(!QFile::exists(dhcpFile)){ |
135 | return true; | 141 | return true; |
136 | } | 142 | } |
137 | 143 | ||
138 | file.setName(dhcpFile); | 144 | file.setName(dhcpFile); |
@@ -145,25 +151,25 @@ bool Interface::refresh(){ | |||
145 | int leaseTime = 0; | 151 | int leaseTime = 0; |
146 | int renewalTime = 0; | 152 | int renewalTime = 0; |
147 | 153 | ||
148 | stream.setDevice( &file ); | 154 | stream.setDevice( &file ); |
149 | while ( !stream.eof() ) { | 155 | while ( !stream.eof() ) { |
150 | line = stream.readLine(); | 156 | line = stream.readLine(); |
151 | if(line.contains("DHCPSID=")) | 157 | if(line.contains("DHCPSIADDR=")) |
152 | dhcpServerIp = line.mid(8, line.length()); | 158 | dhcpServerIp = line.mid(11, line.length()); |
153 | if(line.contains("LEASETIME=")) | 159 | if(line.contains("LEASETIME=")) |
154 | leaseTime = line.mid(10, line.length()).toInt(); | 160 | leaseTime = line.mid(10, line.length()).toInt(); |
155 | if(line.contains("RENEWALTIME=")) | 161 | if(line.contains("RENEWALTIME=")) |
156 | renewalTime = line.mid(12, line.length()).toInt(); | 162 | renewalTime = line.mid(12, line.length()).toInt(); |
157 | } | 163 | } |
158 | file.close(); | 164 | file.close(); |
159 | //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); | 165 | //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); |
160 | //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); | 166 | //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); |
161 | 167 | ||
162 | // Get the pid of the deamond | 168 | // Get the pid of the deamond |
163 | dhcpFile = (QString(HDCP_INFO_DIR "/dhcpcd-%1.pid").arg(interfaceName)); | 169 | dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(interfaceName)); |
164 | file.setName(dhcpFile); | 170 | file.setName(dhcpFile); |
165 | if (!file.open(IO_ReadOnly)){ | 171 | if (!file.open(IO_ReadOnly)){ |
166 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); | 172 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); |
167 | return false; | 173 | return false; |
168 | } | 174 | } |
169 | 175 | ||