-rw-r--r-- | noncore/net/networksetup/interface.cpp | 16 | ||||
-rw-r--r-- | noncore/net/networksetup/interface.h | 4 | ||||
-rw-r--r-- | noncore/net/networksetup/mainwindowimp.cpp | 7 | ||||
-rw-r--r-- | noncore/settings/networksettings/interface.cpp | 16 | ||||
-rw-r--r-- | noncore/settings/networksettings/interface.h | 4 | ||||
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 7 |
6 files changed, 26 insertions, 28 deletions
diff --git a/noncore/net/networksetup/interface.cpp b/noncore/net/networksetup/interface.cpp index 1e01da4..a84b91f 100644 --- a/noncore/net/networksetup/interface.cpp +++ b/noncore/net/networksetup/interface.cpp | |||
@@ -6,17 +6,17 @@ | |||
6 | #include <qtextstream.h> | 6 | #include <qtextstream.h> |
7 | 7 | ||
8 | #define IFCONFIG "/sbin/ifconfig" | 8 | #define IFCONFIG "/sbin/ifconfig" |
9 | #define HDCP_INFO_DIR "/etc/dhcpc" | 9 | #define HDCP_INFO_DIR "/etc/dhcpc" |
10 | 10 | ||
11 | #include <stdio.h> | 11 | #include <stdio.h> |
12 | #include <stdlib.h> | 12 | #include <stdlib.h> |
13 | 13 | ||
14 | Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ | 14 | Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ |
15 | refresh(); | 15 | refresh(); |
16 | } | 16 | } |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * Set status | 19 | * Set status |
20 | * @param newStatus - the new status | 20 | * @param newStatus - the new status |
21 | * emit updateInterface | 21 | * emit updateInterface |
22 | */ | 22 | */ |
@@ -38,17 +38,17 @@ void Interface::setAttached(bool isAttached){ | |||
38 | }; | 38 | }; |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * Set Hardware name | 41 | * Set Hardware name |
42 | * @param name - the new name | 42 | * @param name - the new name |
43 | * emit updateInterface | 43 | * emit updateInterface |
44 | */ | 44 | */ |
45 | void Interface::setHardwareName(QString name){ | 45 | void Interface::setHardwareName(QString name){ |
46 | hardareName = name; | 46 | hardwareName = name; |
47 | emit(updateInterface(this)); | 47 | emit(updateInterface(this)); |
48 | }; | 48 | }; |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * Set Module owner | 51 | * Set Module owner |
52 | * @param owner - the new owner | 52 | * @param owner - the new owner |
53 | * emit updateInterface | 53 | * emit updateInterface |
54 | */ | 54 | */ |
@@ -61,34 +61,34 @@ void Interface::setModuleOwner(Module *owner){ | |||
61 | /** | 61 | /** |
62 | * Try to start the interface. | 62 | * Try to start the interface. |
63 | */ | 63 | */ |
64 | void Interface::start(){ | 64 | void Interface::start(){ |
65 | // check to see if we are already running. | 65 | // check to see if we are already running. |
66 | if(true == status) | 66 | if(true == status) |
67 | return; | 67 | return; |
68 | 68 | ||
69 | int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(interfaceName).latin1()); | 69 | int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); |
70 | // See if it was successfull... | 70 | // See if it was successfull... |
71 | if(ret != 0) | 71 | if(ret != 0) |
72 | return; | 72 | return; |
73 | 73 | ||
74 | status = true; | 74 | status = true; |
75 | refresh(); | 75 | refresh(); |
76 | } | 76 | } |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Try to stop the interface. | 79 | * Try to stop the interface. |
80 | */ | 80 | */ |
81 | void Interface::stop(){ | 81 | void Interface::stop(){ |
82 | // check to see if we are already stopped. | 82 | // check to see if we are already stopped. |
83 | if(false == status) | 83 | if(false == status) |
84 | return; | 84 | return; |
85 | 85 | ||
86 | int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(interfaceName).latin1()); | 86 | int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); |
87 | if(ret != 0) | 87 | if(ret != 0) |
88 | return; | 88 | return; |
89 | 89 | ||
90 | status = true; | 90 | status = true; |
91 | refresh(); | 91 | refresh(); |
92 | } | 92 | } |
93 | 93 | ||
94 | /** | 94 | /** |
@@ -114,18 +114,18 @@ bool Interface::refresh(){ | |||
114 | dhcp = false; | 114 | dhcp = false; |
115 | dhcpServerIp = ""; | 115 | dhcpServerIp = ""; |
116 | leaseObtained = ""; | 116 | leaseObtained = ""; |
117 | leaseExpires = ""; | 117 | leaseExpires = ""; |
118 | emit(updateInterface(this)); | 118 | emit(updateInterface(this)); |
119 | return true; | 119 | return true; |
120 | } | 120 | } |
121 | 121 | ||
122 | QString fileName = QString("/tmp/%1_ifconfig_info").arg(interfaceName); | 122 | QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name()); |
123 | int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(interfaceName).arg(fileName).latin1()); | 123 | int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1()); |
124 | if(ret != 0){ | 124 | if(ret != 0){ |
125 | qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); | 125 | qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); |
126 | return false; | 126 | return false; |
127 | } | 127 | } |
128 | 128 | ||
129 | QFile file(fileName); | 129 | QFile file(fileName); |
130 | if (!file.open(IO_ReadOnly)){ | 130 | if (!file.open(IO_ReadOnly)){ |
131 | qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); | 131 | qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); |
@@ -172,17 +172,17 @@ bool Interface::refresh(){ | |||
172 | dhcp = false; | 172 | dhcp = false; |
173 | 173 | ||
174 | QString dhcpDirectory(HDCP_INFO_DIR); | 174 | QString dhcpDirectory(HDCP_INFO_DIR); |
175 | QDir d(dhcpDirectory); | 175 | QDir d(dhcpDirectory); |
176 | if(!d.exists(dhcpDirectory)) | 176 | if(!d.exists(dhcpDirectory)) |
177 | dhcpDirectory = "/var/run"; | 177 | dhcpDirectory = "/var/run"; |
178 | 178 | ||
179 | // See if we have | 179 | // See if we have |
180 | QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName)); | 180 | QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); |
181 | // If there is no DHCP information then exit now with no errors. | 181 | // If there is no DHCP information then exit now with no errors. |
182 | if(!QFile::exists(dhcpFile)){ | 182 | if(!QFile::exists(dhcpFile)){ |
183 | emit(updateInterface(this)); | 183 | emit(updateInterface(this)); |
184 | return true; | 184 | return true; |
185 | } | 185 | } |
186 | 186 | ||
187 | file.setName(dhcpFile); | 187 | file.setName(dhcpFile); |
188 | if (!file.open(IO_ReadOnly)){ | 188 | if (!file.open(IO_ReadOnly)){ |
@@ -204,17 +204,17 @@ bool Interface::refresh(){ | |||
204 | if(line.contains("RENEWALTIME=")) | 204 | if(line.contains("RENEWALTIME=")) |
205 | renewalTime = line.mid(12, line.length()).toInt(); | 205 | renewalTime = line.mid(12, line.length()).toInt(); |
206 | } | 206 | } |
207 | file.close(); | 207 | file.close(); |
208 | //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); | 208 | //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); |
209 | //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); | 209 | //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); |
210 | 210 | ||
211 | // Get the pid of the deamond | 211 | // Get the pid of the deamond |
212 | dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(interfaceName)); | 212 | dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name())); |
213 | file.setName(dhcpFile); | 213 | file.setName(dhcpFile); |
214 | if (!file.open(IO_ReadOnly)){ | 214 | if (!file.open(IO_ReadOnly)){ |
215 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); | 215 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); |
216 | return false; | 216 | return false; |
217 | } | 217 | } |
218 | 218 | ||
219 | int pid = -1; | 219 | int pid = -1; |
220 | stream.setDevice( &file ); | 220 | stream.setDevice( &file ); |
diff --git a/noncore/net/networksetup/interface.h b/noncore/net/networksetup/interface.h index 980171a..7943fd6 100644 --- a/noncore/net/networksetup/interface.h +++ b/noncore/net/networksetup/interface.h | |||
@@ -19,17 +19,17 @@ public: | |||
19 | virtual QString getInterfaceName(){ QString n(this->name()); return n; }; | 19 | virtual QString getInterfaceName(){ QString n(this->name()); return n; }; |
20 | 20 | ||
21 | virtual bool getStatus(){ return status; }; | 21 | virtual bool getStatus(){ return status; }; |
22 | virtual void setStatus(bool newStatus); | 22 | virtual void setStatus(bool newStatus); |
23 | 23 | ||
24 | virtual bool isAttached(){ return attached; }; | 24 | virtual bool isAttached(){ return attached; }; |
25 | virtual void setAttached(bool isAttached=false); | 25 | virtual void setAttached(bool isAttached=false); |
26 | 26 | ||
27 | virtual QString getHardwareName(){ return hardareName; }; | 27 | virtual QString getHardwareName(){ return hardwareName; }; |
28 | virtual void setHardwareName(QString name="Unknown"); | 28 | virtual void setHardwareName(QString name="Unknown"); |
29 | 29 | ||
30 | virtual Module* getModuleOwner(){ return moduleOwner; }; | 30 | virtual Module* getModuleOwner(){ return moduleOwner; }; |
31 | virtual void setModuleOwner(Module *owner=NULL); | 31 | virtual void setModuleOwner(Module *owner=NULL); |
32 | 32 | ||
33 | // inet information. | 33 | // inet information. |
34 | QString getMacAddress(){ return macAddress; }; | 34 | QString getMacAddress(){ return macAddress; }; |
35 | QString getIp(){ return ip; }; | 35 | QString getIp(){ return ip; }; |
@@ -46,17 +46,17 @@ public slots: | |||
46 | void stop(); | 46 | void stop(); |
47 | void restart(); | 47 | void restart(); |
48 | 48 | ||
49 | private: | 49 | private: |
50 | // Interface information | 50 | // Interface information |
51 | bool status; | 51 | bool status; |
52 | bool attached; | 52 | bool attached; |
53 | QString interfaceName; | 53 | QString interfaceName; |
54 | QString hardareName; | 54 | QString hardwareName; |
55 | Module *moduleOwner; | 55 | Module *moduleOwner; |
56 | 56 | ||
57 | // Network information | 57 | // Network information |
58 | QString macAddress; | 58 | QString macAddress; |
59 | QString ip; | 59 | QString ip; |
60 | QString broadcast; | 60 | QString broadcast; |
61 | QString subnetMask; | 61 | QString subnetMask; |
62 | bool dhcp; | 62 | bool dhcp; |
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp index 117bac1..a446d29 100644 --- a/noncore/net/networksetup/mainwindowimp.cpp +++ b/noncore/net/networksetup/mainwindowimp.cpp | |||
@@ -303,17 +303,17 @@ void MainWindowImp::jobDone(KProcess *process){ | |||
303 | if(space > 1){ | 303 | if(space > 1){ |
304 | // We have found an interface | 304 | // We have found an interface |
305 | QString interfaceName = line.mid(0, space); | 305 | QString interfaceName = line.mid(0, space); |
306 | Interface *i; | 306 | Interface *i; |
307 | // We have found an interface | 307 | // We have found an interface |
308 | //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); | 308 | //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); |
309 | // See if we already have it | 309 | // See if we already have it |
310 | if(interfaceNames.find(interfaceName) == interfaceNames.end()){ | 310 | if(interfaceNames.find(interfaceName) == interfaceNames.end()){ |
311 | if(fileName == TEMP_ALL) | 311 | if(fileName == TEMP_ALL) |
312 | i = new Interface(this, interfaceName, false); | 312 | i = new Interface(this, interfaceName, false); |
313 | else | 313 | else |
314 | i = new Interface(this, interfaceName, true); | 314 | i = new Interface(this, interfaceName, true); |
315 | i->setAttached(true); | 315 | i->setAttached(true); |
316 | 316 | ||
317 | QString hardName = "Ethernet"; | 317 | QString hardName = "Ethernet"; |
318 | int hardwareName = line.find("Link encap:"); | 318 | int hardwareName = line.find("Link encap:"); |
319 | int macAddress = line.find("HWaddr"); | 319 | int macAddress = line.find("HWaddr"); |
@@ -323,19 +323,18 @@ void MainWindowImp::jobDone(KProcess *process){ | |||
323 | i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName())); | 323 | i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName())); |
324 | 324 | ||
325 | interfaceNames.insert(i->getInterfaceName(), i); | 325 | interfaceNames.insert(i->getInterfaceName(), i); |
326 | updateInterface(i); | 326 | updateInterface(i); |
327 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 327 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
328 | } | 328 | } |
329 | // It was an interface we already had. | 329 | // It was an interface we already had. |
330 | else{ | 330 | else{ |
331 | i = interfaceNames[interfaceName]; | ||
332 | if(fileName != TEMP_ALL) | 331 | if(fileName != TEMP_ALL) |
333 | i->setStatus(true); | 332 | (interfaceNames[interfaceName])->setStatus(true); |
334 | } | 333 | } |
335 | } | 334 | } |
336 | } | 335 | } |
337 | file.close(); | 336 | file.close(); |
338 | QFile::remove(fileName); | 337 | QFile::remove(fileName); |
339 | 338 | ||
340 | if(threads.count() == 0){ | 339 | if(threads.count() == 0){ |
341 | Interfaces i; | 340 | Interfaces i; |
@@ -393,17 +392,17 @@ void MainWindowImp::updateInterface(Interface *i){ | |||
393 | if(i->getHardwareName().contains("Local Loopback")) | 392 | if(i->getHardwareName().contains("Local Loopback")) |
394 | typeName = "lo"; | 393 | typeName = "lo"; |
395 | if(i->getInterfaceName().contains("irda")) | 394 | if(i->getInterfaceName().contains("irda")) |
396 | typeName = "irda"; | 395 | typeName = "irda"; |
397 | if(i->getInterfaceName().contains("wlan")) | 396 | if(i->getInterfaceName().contains("wlan")) |
398 | typeName = "wlan"; | 397 | typeName = "wlan"; |
399 | if(i->getInterfaceName().contains("usb")) | 398 | if(i->getInterfaceName().contains("usb")) |
400 | typeName = "usb"; | 399 | typeName = "usb"; |
401 | 400 | ||
402 | if(!i->isAttached()) | 401 | if(!i->isAttached()) |
403 | typeName = "connect_no"; | 402 | typeName = "connect_no"; |
404 | // Actually try to use the Module | 403 | // Actually try to use the Module |
405 | if(i->getModuleOwner() != NULL) | 404 | if(i->getModuleOwner() != NULL) |
406 | typeName = i->getModuleOwner()->getPixmapName(i); | 405 | typeName = i->getModuleOwner()->getPixmapName(i); |
407 | 406 | ||
408 | item->setPixmap(1, (Resource::loadPixmap(typeName))); | 407 | item->setPixmap(1, (Resource::loadPixmap(typeName))); |
409 | item->setText(2, i->getHardwareName()); | 408 | item->setText(2, i->getHardwareName()); |
diff --git a/noncore/settings/networksettings/interface.cpp b/noncore/settings/networksettings/interface.cpp index 1e01da4..a84b91f 100644 --- a/noncore/settings/networksettings/interface.cpp +++ b/noncore/settings/networksettings/interface.cpp | |||
@@ -6,17 +6,17 @@ | |||
6 | #include <qtextstream.h> | 6 | #include <qtextstream.h> |
7 | 7 | ||
8 | #define IFCONFIG "/sbin/ifconfig" | 8 | #define IFCONFIG "/sbin/ifconfig" |
9 | #define HDCP_INFO_DIR "/etc/dhcpc" | 9 | #define HDCP_INFO_DIR "/etc/dhcpc" |
10 | 10 | ||
11 | #include <stdio.h> | 11 | #include <stdio.h> |
12 | #include <stdlib.h> | 12 | #include <stdlib.h> |
13 | 13 | ||
14 | Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ | 14 | Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ |
15 | refresh(); | 15 | refresh(); |
16 | } | 16 | } |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * Set status | 19 | * Set status |
20 | * @param newStatus - the new status | 20 | * @param newStatus - the new status |
21 | * emit updateInterface | 21 | * emit updateInterface |
22 | */ | 22 | */ |
@@ -38,17 +38,17 @@ void Interface::setAttached(bool isAttached){ | |||
38 | }; | 38 | }; |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * Set Hardware name | 41 | * Set Hardware name |
42 | * @param name - the new name | 42 | * @param name - the new name |
43 | * emit updateInterface | 43 | * emit updateInterface |
44 | */ | 44 | */ |
45 | void Interface::setHardwareName(QString name){ | 45 | void Interface::setHardwareName(QString name){ |
46 | hardareName = name; | 46 | hardwareName = name; |
47 | emit(updateInterface(this)); | 47 | emit(updateInterface(this)); |
48 | }; | 48 | }; |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * Set Module owner | 51 | * Set Module owner |
52 | * @param owner - the new owner | 52 | * @param owner - the new owner |
53 | * emit updateInterface | 53 | * emit updateInterface |
54 | */ | 54 | */ |
@@ -61,34 +61,34 @@ void Interface::setModuleOwner(Module *owner){ | |||
61 | /** | 61 | /** |
62 | * Try to start the interface. | 62 | * Try to start the interface. |
63 | */ | 63 | */ |
64 | void Interface::start(){ | 64 | void Interface::start(){ |
65 | // check to see if we are already running. | 65 | // check to see if we are already running. |
66 | if(true == status) | 66 | if(true == status) |
67 | return; | 67 | return; |
68 | 68 | ||
69 | int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(interfaceName).latin1()); | 69 | int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); |
70 | // See if it was successfull... | 70 | // See if it was successfull... |
71 | if(ret != 0) | 71 | if(ret != 0) |
72 | return; | 72 | return; |
73 | 73 | ||
74 | status = true; | 74 | status = true; |
75 | refresh(); | 75 | refresh(); |
76 | } | 76 | } |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Try to stop the interface. | 79 | * Try to stop the interface. |
80 | */ | 80 | */ |
81 | void Interface::stop(){ | 81 | void Interface::stop(){ |
82 | // check to see if we are already stopped. | 82 | // check to see if we are already stopped. |
83 | if(false == status) | 83 | if(false == status) |
84 | return; | 84 | return; |
85 | 85 | ||
86 | int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(interfaceName).latin1()); | 86 | int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); |
87 | if(ret != 0) | 87 | if(ret != 0) |
88 | return; | 88 | return; |
89 | 89 | ||
90 | status = true; | 90 | status = true; |
91 | refresh(); | 91 | refresh(); |
92 | } | 92 | } |
93 | 93 | ||
94 | /** | 94 | /** |
@@ -114,18 +114,18 @@ bool Interface::refresh(){ | |||
114 | dhcp = false; | 114 | dhcp = false; |
115 | dhcpServerIp = ""; | 115 | dhcpServerIp = ""; |
116 | leaseObtained = ""; | 116 | leaseObtained = ""; |
117 | leaseExpires = ""; | 117 | leaseExpires = ""; |
118 | emit(updateInterface(this)); | 118 | emit(updateInterface(this)); |
119 | return true; | 119 | return true; |
120 | } | 120 | } |
121 | 121 | ||
122 | QString fileName = QString("/tmp/%1_ifconfig_info").arg(interfaceName); | 122 | QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name()); |
123 | int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(interfaceName).arg(fileName).latin1()); | 123 | int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1()); |
124 | if(ret != 0){ | 124 | if(ret != 0){ |
125 | qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); | 125 | qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); |
126 | return false; | 126 | return false; |
127 | } | 127 | } |
128 | 128 | ||
129 | QFile file(fileName); | 129 | QFile file(fileName); |
130 | if (!file.open(IO_ReadOnly)){ | 130 | if (!file.open(IO_ReadOnly)){ |
131 | qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); | 131 | qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); |
@@ -172,17 +172,17 @@ bool Interface::refresh(){ | |||
172 | dhcp = false; | 172 | dhcp = false; |
173 | 173 | ||
174 | QString dhcpDirectory(HDCP_INFO_DIR); | 174 | QString dhcpDirectory(HDCP_INFO_DIR); |
175 | QDir d(dhcpDirectory); | 175 | QDir d(dhcpDirectory); |
176 | if(!d.exists(dhcpDirectory)) | 176 | if(!d.exists(dhcpDirectory)) |
177 | dhcpDirectory = "/var/run"; | 177 | dhcpDirectory = "/var/run"; |
178 | 178 | ||
179 | // See if we have | 179 | // See if we have |
180 | QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName)); | 180 | QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); |
181 | // If there is no DHCP information then exit now with no errors. | 181 | // If there is no DHCP information then exit now with no errors. |
182 | if(!QFile::exists(dhcpFile)){ | 182 | if(!QFile::exists(dhcpFile)){ |
183 | emit(updateInterface(this)); | 183 | emit(updateInterface(this)); |
184 | return true; | 184 | return true; |
185 | } | 185 | } |
186 | 186 | ||
187 | file.setName(dhcpFile); | 187 | file.setName(dhcpFile); |
188 | if (!file.open(IO_ReadOnly)){ | 188 | if (!file.open(IO_ReadOnly)){ |
@@ -204,17 +204,17 @@ bool Interface::refresh(){ | |||
204 | if(line.contains("RENEWALTIME=")) | 204 | if(line.contains("RENEWALTIME=")) |
205 | renewalTime = line.mid(12, line.length()).toInt(); | 205 | renewalTime = line.mid(12, line.length()).toInt(); |
206 | } | 206 | } |
207 | file.close(); | 207 | file.close(); |
208 | //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); | 208 | //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); |
209 | //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); | 209 | //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); |
210 | 210 | ||
211 | // Get the pid of the deamond | 211 | // Get the pid of the deamond |
212 | dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(interfaceName)); | 212 | dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name())); |
213 | file.setName(dhcpFile); | 213 | file.setName(dhcpFile); |
214 | if (!file.open(IO_ReadOnly)){ | 214 | if (!file.open(IO_ReadOnly)){ |
215 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); | 215 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); |
216 | return false; | 216 | return false; |
217 | } | 217 | } |
218 | 218 | ||
219 | int pid = -1; | 219 | int pid = -1; |
220 | stream.setDevice( &file ); | 220 | stream.setDevice( &file ); |
diff --git a/noncore/settings/networksettings/interface.h b/noncore/settings/networksettings/interface.h index 980171a..7943fd6 100644 --- a/noncore/settings/networksettings/interface.h +++ b/noncore/settings/networksettings/interface.h | |||
@@ -19,17 +19,17 @@ public: | |||
19 | virtual QString getInterfaceName(){ QString n(this->name()); return n; }; | 19 | virtual QString getInterfaceName(){ QString n(this->name()); return n; }; |
20 | 20 | ||
21 | virtual bool getStatus(){ return status; }; | 21 | virtual bool getStatus(){ return status; }; |
22 | virtual void setStatus(bool newStatus); | 22 | virtual void setStatus(bool newStatus); |
23 | 23 | ||
24 | virtual bool isAttached(){ return attached; }; | 24 | virtual bool isAttached(){ return attached; }; |
25 | virtual void setAttached(bool isAttached=false); | 25 | virtual void setAttached(bool isAttached=false); |
26 | 26 | ||
27 | virtual QString getHardwareName(){ return hardareName; }; | 27 | virtual QString getHardwareName(){ return hardwareName; }; |
28 | virtual void setHardwareName(QString name="Unknown"); | 28 | virtual void setHardwareName(QString name="Unknown"); |
29 | 29 | ||
30 | virtual Module* getModuleOwner(){ return moduleOwner; }; | 30 | virtual Module* getModuleOwner(){ return moduleOwner; }; |
31 | virtual void setModuleOwner(Module *owner=NULL); | 31 | virtual void setModuleOwner(Module *owner=NULL); |
32 | 32 | ||
33 | // inet information. | 33 | // inet information. |
34 | QString getMacAddress(){ return macAddress; }; | 34 | QString getMacAddress(){ return macAddress; }; |
35 | QString getIp(){ return ip; }; | 35 | QString getIp(){ return ip; }; |
@@ -46,17 +46,17 @@ public slots: | |||
46 | void stop(); | 46 | void stop(); |
47 | void restart(); | 47 | void restart(); |
48 | 48 | ||
49 | private: | 49 | private: |
50 | // Interface information | 50 | // Interface information |
51 | bool status; | 51 | bool status; |
52 | bool attached; | 52 | bool attached; |
53 | QString interfaceName; | 53 | QString interfaceName; |
54 | QString hardareName; | 54 | QString hardwareName; |
55 | Module *moduleOwner; | 55 | Module *moduleOwner; |
56 | 56 | ||
57 | // Network information | 57 | // Network information |
58 | QString macAddress; | 58 | QString macAddress; |
59 | QString ip; | 59 | QString ip; |
60 | QString broadcast; | 60 | QString broadcast; |
61 | QString subnetMask; | 61 | QString subnetMask; |
62 | bool dhcp; | 62 | bool dhcp; |
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index 117bac1..a446d29 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -303,17 +303,17 @@ void MainWindowImp::jobDone(KProcess *process){ | |||
303 | if(space > 1){ | 303 | if(space > 1){ |
304 | // We have found an interface | 304 | // We have found an interface |
305 | QString interfaceName = line.mid(0, space); | 305 | QString interfaceName = line.mid(0, space); |
306 | Interface *i; | 306 | Interface *i; |
307 | // We have found an interface | 307 | // We have found an interface |
308 | //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); | 308 | //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); |
309 | // See if we already have it | 309 | // See if we already have it |
310 | if(interfaceNames.find(interfaceName) == interfaceNames.end()){ | 310 | if(interfaceNames.find(interfaceName) == interfaceNames.end()){ |
311 | if(fileName == TEMP_ALL) | 311 | if(fileName == TEMP_ALL) |
312 | i = new Interface(this, interfaceName, false); | 312 | i = new Interface(this, interfaceName, false); |
313 | else | 313 | else |
314 | i = new Interface(this, interfaceName, true); | 314 | i = new Interface(this, interfaceName, true); |
315 | i->setAttached(true); | 315 | i->setAttached(true); |
316 | 316 | ||
317 | QString hardName = "Ethernet"; | 317 | QString hardName = "Ethernet"; |
318 | int hardwareName = line.find("Link encap:"); | 318 | int hardwareName = line.find("Link encap:"); |
319 | int macAddress = line.find("HWaddr"); | 319 | int macAddress = line.find("HWaddr"); |
@@ -323,19 +323,18 @@ void MainWindowImp::jobDone(KProcess *process){ | |||
323 | i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName())); | 323 | i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName())); |
324 | 324 | ||
325 | interfaceNames.insert(i->getInterfaceName(), i); | 325 | interfaceNames.insert(i->getInterfaceName(), i); |
326 | updateInterface(i); | 326 | updateInterface(i); |
327 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 327 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
328 | } | 328 | } |
329 | // It was an interface we already had. | 329 | // It was an interface we already had. |
330 | else{ | 330 | else{ |
331 | i = interfaceNames[interfaceName]; | ||
332 | if(fileName != TEMP_ALL) | 331 | if(fileName != TEMP_ALL) |
333 | i->setStatus(true); | 332 | (interfaceNames[interfaceName])->setStatus(true); |
334 | } | 333 | } |
335 | } | 334 | } |
336 | } | 335 | } |
337 | file.close(); | 336 | file.close(); |
338 | QFile::remove(fileName); | 337 | QFile::remove(fileName); |
339 | 338 | ||
340 | if(threads.count() == 0){ | 339 | if(threads.count() == 0){ |
341 | Interfaces i; | 340 | Interfaces i; |
@@ -393,17 +392,17 @@ void MainWindowImp::updateInterface(Interface *i){ | |||
393 | if(i->getHardwareName().contains("Local Loopback")) | 392 | if(i->getHardwareName().contains("Local Loopback")) |
394 | typeName = "lo"; | 393 | typeName = "lo"; |
395 | if(i->getInterfaceName().contains("irda")) | 394 | if(i->getInterfaceName().contains("irda")) |
396 | typeName = "irda"; | 395 | typeName = "irda"; |
397 | if(i->getInterfaceName().contains("wlan")) | 396 | if(i->getInterfaceName().contains("wlan")) |
398 | typeName = "wlan"; | 397 | typeName = "wlan"; |
399 | if(i->getInterfaceName().contains("usb")) | 398 | if(i->getInterfaceName().contains("usb")) |
400 | typeName = "usb"; | 399 | typeName = "usb"; |
401 | 400 | ||
402 | if(!i->isAttached()) | 401 | if(!i->isAttached()) |
403 | typeName = "connect_no"; | 402 | typeName = "connect_no"; |
404 | // Actually try to use the Module | 403 | // Actually try to use the Module |
405 | if(i->getModuleOwner() != NULL) | 404 | if(i->getModuleOwner() != NULL) |
406 | typeName = i->getModuleOwner()->getPixmapName(i); | 405 | typeName = i->getModuleOwner()->getPixmapName(i); |
407 | 406 | ||
408 | item->setPixmap(1, (Resource::loadPixmap(typeName))); | 407 | item->setPixmap(1, (Resource::loadPixmap(typeName))); |
409 | item->setText(2, i->getHardwareName()); | 408 | item->setText(2, i->getHardwareName()); |