summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/TODO2
-rw-r--r--noncore/net/networksetup/interface.cpp77
-rw-r--r--noncore/net/networksetup/interface.h31
-rw-r--r--noncore/net/networksetup/interfaceadvanced.ui11
-rw-r--r--noncore/net/networksetup/interfaceinformationimp.cpp51
-rw-r--r--noncore/net/networksetup/interfaceinformationimp.h6
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp43
-rw-r--r--noncore/net/networksetup/wlan/wlanmodule.cpp4
-rw-r--r--noncore/settings/networksettings/TODO2
-rw-r--r--noncore/settings/networksettings/interface.cpp77
-rw-r--r--noncore/settings/networksettings/interface.h31
-rw-r--r--noncore/settings/networksettings/interfaceadvanced.ui11
-rw-r--r--noncore/settings/networksettings/interfaceinformationimp.cpp51
-rw-r--r--noncore/settings/networksettings/interfaceinformationimp.h6
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp43
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp4
16 files changed, 258 insertions, 192 deletions
diff --git a/noncore/net/networksetup/TODO b/noncore/net/networksetup/TODO
index 7386646..c8e2989 100644
--- a/noncore/net/networksetup/TODO
+++ b/noncore/net/networksetup/TODO
@@ -1,3 +1,5 @@
1Write a class that parses /proc and not ifconfig
2
1[ ] Wlanmodule needs to check if an interface supports wireless 3[ ] Wlanmodule needs to check if an interface supports wireless
2 extensions. 4 extensions.
3[x] When you set options in wlanmodule, hit OK, it exits all of 5[x] When you set options in wlanmodule, hit OK, it exits all of
diff --git a/noncore/net/networksetup/interface.cpp b/noncore/net/networksetup/interface.cpp
index 1f32093..1e01da4 100644
--- a/noncore/net/networksetup/interface.cpp
+++ b/noncore/net/networksetup/interface.cpp
@@ -11,51 +11,92 @@
11#include <stdio.h> 11#include <stdio.h>
12#include <stdlib.h> 12#include <stdlib.h>
13 13
14Interface::Interface(QString name, bool newSatus): status(newSatus), attached(false), interfaceName(name), hardareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ 14Interface::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){
15 refresh(); 15 refresh();
16} 16}
17 17
18/** 18/**
19 * Set status
20 * @param newStatus - the new status
21 * emit updateInterface
22 */
23void Interface::setStatus(bool newStatus){
24 if(status != newStatus){
25 status = newStatus;
26 refresh();
27 }
28};
29
30/**
31 * Set if attached or not (802.11 card pulled out for example)
32 * @param isAttached - if attached
33 * emit updateInterface
34 */
35void Interface::setAttached(bool isAttached){
36 attached = isAttached;
37 emit(updateInterface(this));
38};
39
40/**
41 * Set Hardware name
42 * @param name - the new name
43 * emit updateInterface
44 */
45void Interface::setHardwareName(QString name){
46 hardareName = name;
47 emit(updateInterface(this));
48};
49
50/**
51 * Set Module owner
52 * @param owner - the new owner
53 * emit updateInterface
54 */
55void Interface::setModuleOwner(Module *owner){
56 moduleOwner = owner;
57 emit(updateInterface(this));
58};
59
60
61/**
19 * Try to start the interface. 62 * Try to start the interface.
20 * @return bool true if successfull.
21 */ 63 */
22bool Interface::start(){ 64void Interface::start(){
23 // check to see if we are already running. 65 // check to see if we are already running.
24 if(status) 66 if(true == status)
25 return false; 67 return;
26 68
27 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(interfaceName).latin1()); 69 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(interfaceName).latin1());
70 // See if it was successfull...
28 if(ret != 0) 71 if(ret != 0)
29 return false; 72 return;
30 73
31 status = true; 74 status = true;
32 refresh(); 75 refresh();
33 return true;
34} 76}
35 77
36/** 78/**
37 * Try to stop the interface. 79 * Try to stop the interface.
38 * @return bool true if successfull.
39 */ 80 */
40bool Interface::stop(){ 81void Interface::stop(){
41 // check to see if we are already stopped. 82 // check to see if we are already stopped.
42 if(status == false) 83 if(false == status)
43 return false; 84 return;
44 85
45 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(interfaceName).latin1()); 86 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(interfaceName).latin1());
46 if(ret != 0) 87 if(ret != 0)
47 return false; 88 return;
48 89
49 status = true; 90 status = true;
50 refresh(); 91 refresh();
51 return true;
52} 92}
93
53/** 94/**
54 * Try to restart the interface. 95 * Try to restart the interface.
55 * @return bool true if successfull.
56 */ 96 */
57bool Interface::restart(){ 97void Interface::restart(){
58 return (stop() && start()); 98 stop();
99 start();
59} 100}
60 101
61/** 102/**
@@ -74,6 +115,7 @@ bool Interface::refresh(){
74 dhcpServerIp = ""; 115 dhcpServerIp = "";
75 leaseObtained = ""; 116 leaseObtained = "";
76 leaseExpires = ""; 117 leaseExpires = "";
118 emit(updateInterface(this));
77 return true; 119 return true;
78 } 120 }
79 121
@@ -138,6 +180,7 @@ bool Interface::refresh(){
138 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName)); 180 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName));
139 // 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.
140 if(!QFile::exists(dhcpFile)){ 182 if(!QFile::exists(dhcpFile)){
183 emit(updateInterface(this));
141 return true; 184 return true;
142 } 185 }
143 186
@@ -235,6 +278,8 @@ bool Interface::refresh(){
235 leaseExpires = datetime.toString(); 278 leaseExpires = datetime.toString();
236 279
237 dhcp = true; 280 dhcp = true;
281
282 emit(updateInterface(this));
238 return true; 283 return true;
239} 284}
240 285
diff --git a/noncore/net/networksetup/interface.h b/noncore/net/networksetup/interface.h
index 1406e99..980171a 100644
--- a/noncore/net/networksetup/interface.h
+++ b/noncore/net/networksetup/interface.h
@@ -2,29 +2,33 @@
2#define INTERFACE_H 2#define INTERFACE_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qobject.h>
5 6
6class Module; 7class Module;
7 8
8class Interface { 9class Interface : public QObject{
10 Q_OBJECT
9 11
12signals:
13 void updateInterface(Interface *i);
14
10public: 15public:
11 Interface(QString name = "unknown", bool status = false); 16 Interface(QObject * parent=0, const char * name= "unknown", bool status = false);
12 virtual ~Interface(){}; 17 virtual ~Interface(){};
13 18
19 virtual QString getInterfaceName(){ QString n(this->name()); return n; };
20
14 virtual bool getStatus(){ return status; }; 21 virtual bool getStatus(){ return status; };
15 virtual void setStatus(bool newSatus){ status = newSatus; refresh(); }; 22 virtual void setStatus(bool newStatus);
16 23
17 virtual bool isAttached(){ return attached; }; 24 virtual bool isAttached(){ return attached; };
18 virtual void setAttached(bool isAttached=false){ attached = isAttached; }; 25 virtual void setAttached(bool isAttached=false);
19
20 virtual QString getInterfaceName(){ return interfaceName; };
21 virtual void setInterfaceName(QString name="unknown"){ interfaceName = name; };
22 26
23 virtual QString getHardwareName(){ return hardareName; }; 27 virtual QString getHardwareName(){ return hardareName; };
24 virtual void setHardwareName(QString name="Unknown"){ hardareName = name; }; 28 virtual void setHardwareName(QString name="Unknown");
25 29
26 virtual Module* getModuleOwner(){ return moduleOwner; }; 30 virtual Module* getModuleOwner(){ return moduleOwner; };
27 virtual void setModuleOwner(Module *owner=NULL){ moduleOwner = owner; }; 31 virtual void setModuleOwner(Module *owner=NULL);
28 32
29 // inet information. 33 // inet information.
30 QString getMacAddress(){ return macAddress; }; 34 QString getMacAddress(){ return macAddress; };
@@ -35,11 +39,12 @@ public:
35 QString getDhcpServerIp(){ return dhcpServerIp; }; 39 QString getDhcpServerIp(){ return dhcpServerIp; };
36 QString getLeaseObtained(){ return leaseObtained; }; 40 QString getLeaseObtained(){ return leaseObtained; };
37 QString getLeaseExpires(){ return leaseExpires; }; 41 QString getLeaseExpires(){ return leaseExpires; };
38 42
43public slots:
39 bool refresh(); 44 bool refresh();
40 bool start(); 45 void start();
41 bool stop(); 46 void stop();
42 bool restart(); 47 void restart();
43 48
44private: 49private:
45 // Interface information 50 // Interface information
diff --git a/noncore/net/networksetup/interfaceadvanced.ui b/noncore/net/networksetup/interfaceadvanced.ui
index 7520abe..efe67b0 100644
--- a/noncore/net/networksetup/interfaceadvanced.ui
+++ b/noncore/net/networksetup/interfaceadvanced.ui
@@ -11,11 +11,18 @@
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>188</width> 14 <width>214</width>
15 <height>277</height> 15 <height>286</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>maximumSize</name>
20 <size>
21 <width>320</width>
22 <height>32767</height>
23 </size>
24 </property>
25 <property stdset="1">
19 <name>caption</name> 26 <name>caption</name>
20 <string>Advanced Interface Information</string> 27 <string>Advanced Interface Information</string>
21 </property> 28 </property>
diff --git a/noncore/net/networksetup/interfaceinformationimp.cpp b/noncore/net/networksetup/interfaceinformationimp.cpp
index e37e0f8..59a6400 100644
--- a/noncore/net/networksetup/interfaceinformationimp.cpp
+++ b/noncore/net/networksetup/interfaceinformationimp.cpp
@@ -13,16 +13,22 @@ InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *na
13 assert(i); 13 assert(i);
14 14
15 interface = i; 15 interface = i;
16 updateInterface(); 16 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
17 connect(startButton, SIGNAL(clicked()), this, SLOT(start())); 17 updateInterface(interface);
18 connect(stopButton, SIGNAL(clicked()), this, SLOT(stop())); 18 connect(startButton, SIGNAL(clicked()), interface, SLOT(start()));
19 connect(restartButton, SIGNAL(clicked()), this, SLOT(restart())); 19 connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop()));
20 connect(refreshButton, SIGNAL(clicked()), this, SLOT(refresh())); 20 connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart()));
21 connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh()));
21 connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); 22 connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced()));
22 23
23} 24}
24 25
25void InterfaceInformationImp::updateInterface(){ 26/**
27 * Update the interface information and buttons.
28 * @param Intarface *i the interface to update (should be the one we already
29 * know about).
30 */
31void InterfaceInformationImp::updateInterface(Interface *i){
26 if(interface->getStatus()){ 32 if(interface->getStatus()){
27 startButton->setEnabled(false); 33 startButton->setEnabled(false);
28 stopButton->setEnabled(true); 34 stopButton->setEnabled(true);
@@ -40,39 +46,6 @@ void InterfaceInformationImp::updateInterface(){
40} 46}
41 47
42/** 48/**
43 * Start the interface. Update the information if successfull
44 */
45void InterfaceInformationImp::start(){
46 if(interface->start()){
47 updateInterface();
48 }
49}
50
51/**
52 * Stop the interface.
53 */
54void InterfaceInformationImp::stop(){
55 if(interface->stop()){
56 updateInterface();
57 }
58}
59
60/***
61 * Tell the interface to refresh its information.
62 **/
63void InterfaceInformationImp::refresh(){
64 if(interface->refresh())
65 updateInterface();
66}
67
68void InterfaceInformationImp::restart(){
69 if(interface->restart()){
70 updateInterface();
71 }
72}
73
74
75/**
76 * Create the advanced widget. Fill it with the current interface's information. 49 * Create the advanced widget. Fill it with the current interface's information.
77 * Display it. 50 * Display it.
78 */ 51 */
diff --git a/noncore/net/networksetup/interfaceinformationimp.h b/noncore/net/networksetup/interfaceinformationimp.h
index c8a478e..42213cc 100644
--- a/noncore/net/networksetup/interfaceinformationimp.h
+++ b/noncore/net/networksetup/interfaceinformationimp.h
@@ -13,15 +13,11 @@ public:
13 ~InterfaceInformationImp(){}; 13 ~InterfaceInformationImp(){};
14 14
15private slots: 15private slots:
16 void start();
17 void stop();
18 void refresh();
19 void restart();
20 void advanced(); 16 void advanced();
17 void updateInterface(Interface *i);
21 18
22private: 19private:
23 Interface *interface; 20 Interface *interface;
24 void updateInterface();
25 21
26}; 22};
27 23
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index b46362f..117bac1 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -304,33 +304,34 @@ void MainWindowImp::jobDone(KProcess *process){
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
308 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
307 // See if we already have it 309 // See if we already have it
308 if(interfaceNames.find(interfaceName) == interfaceNames.end()){ 310 if(interfaceNames.find(interfaceName) == interfaceNames.end()){
309 if(fileName == TEMP_ALL) 311 if(fileName == TEMP_ALL)
310 i = new Interface(interfaceName, false); 312 i = new Interface(this, interfaceName, false);
311 else 313 else
312 i = new Interface(interfaceName, true); 314 i = new Interface(this, interfaceName, true);
315 i->setAttached(true);
316
317 QString hardName = "Ethernet";
318 int hardwareName = line.find("Link encap:");
319 int macAddress = line.find("HWaddr");
320 if(macAddress == -1)
321 macAddress = line.length();
322 if(hardwareName != -1)
323 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
324
325 interfaceNames.insert(i->getInterfaceName(), i);
326 updateInterface(i);
327 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
313 } 328 }
329 // It was an interface we already had.
314 else{ 330 else{
315 i = interfaceNames[interfaceName]; 331 i = interfaceNames[interfaceName];
316 if(fileName != TEMP_ALL) 332 if(fileName != TEMP_ALL)
317 i->setStatus(true); 333 i->setStatus(true);
318 } 334 }
319
320 i->setAttached(true);
321 i->setInterfaceName(interfaceName);
322
323 QString hardName = "Ethernet";
324 int hardwareName = line.find("Link encap:");
325 int macAddress = line.find("HWaddr");
326 if(macAddress == -1)
327 macAddress = line.length();
328 if(hardwareName != -1)
329 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
330 // We have found an interface
331 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
332 interfaceNames.insert(i->getInterfaceName(), i);
333 updateInterface(i);
334 } 335 }
335 } 336 }
336 file.close(); 337 file.close();
@@ -347,12 +348,12 @@ void MainWindowImp::jobDone(KProcess *process){
347 found = true; 348 found = true;
348 } 349 }
349 if(!found){ 350 if(!found){
350 Interface *i = new Interface(*ni, false); 351 Interface *i = new Interface(this, *ni, false);
351 i->setAttached(false); 352 i->setAttached(false);
352 i->setHardwareName(QString("Disconnected (%1)").arg(*ni)); 353 i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
353 i->setInterfaceName(*ni);
354 interfaceNames.insert(i->getInterfaceName(), i); 354 interfaceNames.insert(i->getInterfaceName(), i);
355 updateInterface(i); 355 updateInterface(i);
356 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
356 } 357 }
357 } 358 }
358 } 359 }
@@ -395,7 +396,9 @@ void MainWindowImp::updateInterface(Interface *i){
395 typeName = "irda"; 396 typeName = "irda";
396 if(i->getInterfaceName().contains("wlan")) 397 if(i->getInterfaceName().contains("wlan"))
397 typeName = "wlan"; 398 typeName = "wlan";
398 399 if(i->getInterfaceName().contains("usb"))
400 typeName = "usb";
401
399 if(!i->isAttached()) 402 if(!i->isAttached())
400 typeName = "connect_no"; 403 typeName = "connect_no";
401 // Actually try to use the Module 404 // Actually try to use the Module
diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp
index 98d2eb6..f0394b4 100644
--- a/noncore/net/networksetup/wlan/wlanmodule.cpp
+++ b/noncore/net/networksetup/wlan/wlanmodule.cpp
@@ -24,8 +24,10 @@ QString WLANModule::getPixmapName(Interface* ){
24 * @return bool true if i is owned by this module, false otherwise. 24 * @return bool true if i is owned by this module, false otherwise.
25 */ 25 */
26bool WLANModule::isOwner(Interface *i){ 26bool WLANModule::isOwner(Interface *i){
27 if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0") 27 if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){
28 i->setHardwareName(QString("802.11b (%1)").arg(i->getInterfaceName()));
28 return true; 29 return true;
30 }
29 return false; 31 return false;
30} 32}
31 33
diff --git a/noncore/settings/networksettings/TODO b/noncore/settings/networksettings/TODO
index 7386646..c8e2989 100644
--- a/noncore/settings/networksettings/TODO
+++ b/noncore/settings/networksettings/TODO
@@ -1,3 +1,5 @@
1Write a class that parses /proc and not ifconfig
2
1[ ] Wlanmodule needs to check if an interface supports wireless 3[ ] Wlanmodule needs to check if an interface supports wireless
2 extensions. 4 extensions.
3[x] When you set options in wlanmodule, hit OK, it exits all of 5[x] When you set options in wlanmodule, hit OK, it exits all of
diff --git a/noncore/settings/networksettings/interface.cpp b/noncore/settings/networksettings/interface.cpp
index 1f32093..1e01da4 100644
--- a/noncore/settings/networksettings/interface.cpp
+++ b/noncore/settings/networksettings/interface.cpp
@@ -11,51 +11,92 @@
11#include <stdio.h> 11#include <stdio.h>
12#include <stdlib.h> 12#include <stdlib.h>
13 13
14Interface::Interface(QString name, bool newSatus): status(newSatus), attached(false), interfaceName(name), hardareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ 14Interface::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){
15 refresh(); 15 refresh();
16} 16}
17 17
18/** 18/**
19 * Set status
20 * @param newStatus - the new status
21 * emit updateInterface
22 */
23void Interface::setStatus(bool newStatus){
24 if(status != newStatus){
25 status = newStatus;
26 refresh();
27 }
28};
29
30/**
31 * Set if attached or not (802.11 card pulled out for example)
32 * @param isAttached - if attached
33 * emit updateInterface
34 */
35void Interface::setAttached(bool isAttached){
36 attached = isAttached;
37 emit(updateInterface(this));
38};
39
40/**
41 * Set Hardware name
42 * @param name - the new name
43 * emit updateInterface
44 */
45void Interface::setHardwareName(QString name){
46 hardareName = name;
47 emit(updateInterface(this));
48};
49
50/**
51 * Set Module owner
52 * @param owner - the new owner
53 * emit updateInterface
54 */
55void Interface::setModuleOwner(Module *owner){
56 moduleOwner = owner;
57 emit(updateInterface(this));
58};
59
60
61/**
19 * Try to start the interface. 62 * Try to start the interface.
20 * @return bool true if successfull.
21 */ 63 */
22bool Interface::start(){ 64void Interface::start(){
23 // check to see if we are already running. 65 // check to see if we are already running.
24 if(status) 66 if(true == status)
25 return false; 67 return;
26 68
27 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(interfaceName).latin1()); 69 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(interfaceName).latin1());
70 // See if it was successfull...
28 if(ret != 0) 71 if(ret != 0)
29 return false; 72 return;
30 73
31 status = true; 74 status = true;
32 refresh(); 75 refresh();
33 return true;
34} 76}
35 77
36/** 78/**
37 * Try to stop the interface. 79 * Try to stop the interface.
38 * @return bool true if successfull.
39 */ 80 */
40bool Interface::stop(){ 81void Interface::stop(){
41 // check to see if we are already stopped. 82 // check to see if we are already stopped.
42 if(status == false) 83 if(false == status)
43 return false; 84 return;
44 85
45 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(interfaceName).latin1()); 86 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(interfaceName).latin1());
46 if(ret != 0) 87 if(ret != 0)
47 return false; 88 return;
48 89
49 status = true; 90 status = true;
50 refresh(); 91 refresh();
51 return true;
52} 92}
93
53/** 94/**
54 * Try to restart the interface. 95 * Try to restart the interface.
55 * @return bool true if successfull.
56 */ 96 */
57bool Interface::restart(){ 97void Interface::restart(){
58 return (stop() && start()); 98 stop();
99 start();
59} 100}
60 101
61/** 102/**
@@ -74,6 +115,7 @@ bool Interface::refresh(){
74 dhcpServerIp = ""; 115 dhcpServerIp = "";
75 leaseObtained = ""; 116 leaseObtained = "";
76 leaseExpires = ""; 117 leaseExpires = "";
118 emit(updateInterface(this));
77 return true; 119 return true;
78 } 120 }
79 121
@@ -138,6 +180,7 @@ bool Interface::refresh(){
138 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName)); 180 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName));
139 // 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.
140 if(!QFile::exists(dhcpFile)){ 182 if(!QFile::exists(dhcpFile)){
183 emit(updateInterface(this));
141 return true; 184 return true;
142 } 185 }
143 186
@@ -235,6 +278,8 @@ bool Interface::refresh(){
235 leaseExpires = datetime.toString(); 278 leaseExpires = datetime.toString();
236 279
237 dhcp = true; 280 dhcp = true;
281
282 emit(updateInterface(this));
238 return true; 283 return true;
239} 284}
240 285
diff --git a/noncore/settings/networksettings/interface.h b/noncore/settings/networksettings/interface.h
index 1406e99..980171a 100644
--- a/noncore/settings/networksettings/interface.h
+++ b/noncore/settings/networksettings/interface.h
@@ -2,29 +2,33 @@
2#define INTERFACE_H 2#define INTERFACE_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qobject.h>
5 6
6class Module; 7class Module;
7 8
8class Interface { 9class Interface : public QObject{
10 Q_OBJECT
9 11
12signals:
13 void updateInterface(Interface *i);
14
10public: 15public:
11 Interface(QString name = "unknown", bool status = false); 16 Interface(QObject * parent=0, const char * name= "unknown", bool status = false);
12 virtual ~Interface(){}; 17 virtual ~Interface(){};
13 18
19 virtual QString getInterfaceName(){ QString n(this->name()); return n; };
20
14 virtual bool getStatus(){ return status; }; 21 virtual bool getStatus(){ return status; };
15 virtual void setStatus(bool newSatus){ status = newSatus; refresh(); }; 22 virtual void setStatus(bool newStatus);
16 23
17 virtual bool isAttached(){ return attached; }; 24 virtual bool isAttached(){ return attached; };
18 virtual void setAttached(bool isAttached=false){ attached = isAttached; }; 25 virtual void setAttached(bool isAttached=false);
19
20 virtual QString getInterfaceName(){ return interfaceName; };
21 virtual void setInterfaceName(QString name="unknown"){ interfaceName = name; };
22 26
23 virtual QString getHardwareName(){ return hardareName; }; 27 virtual QString getHardwareName(){ return hardareName; };
24 virtual void setHardwareName(QString name="Unknown"){ hardareName = name; }; 28 virtual void setHardwareName(QString name="Unknown");
25 29
26 virtual Module* getModuleOwner(){ return moduleOwner; }; 30 virtual Module* getModuleOwner(){ return moduleOwner; };
27 virtual void setModuleOwner(Module *owner=NULL){ moduleOwner = owner; }; 31 virtual void setModuleOwner(Module *owner=NULL);
28 32
29 // inet information. 33 // inet information.
30 QString getMacAddress(){ return macAddress; }; 34 QString getMacAddress(){ return macAddress; };
@@ -35,11 +39,12 @@ public:
35 QString getDhcpServerIp(){ return dhcpServerIp; }; 39 QString getDhcpServerIp(){ return dhcpServerIp; };
36 QString getLeaseObtained(){ return leaseObtained; }; 40 QString getLeaseObtained(){ return leaseObtained; };
37 QString getLeaseExpires(){ return leaseExpires; }; 41 QString getLeaseExpires(){ return leaseExpires; };
38 42
43public slots:
39 bool refresh(); 44 bool refresh();
40 bool start(); 45 void start();
41 bool stop(); 46 void stop();
42 bool restart(); 47 void restart();
43 48
44private: 49private:
45 // Interface information 50 // Interface information
diff --git a/noncore/settings/networksettings/interfaceadvanced.ui b/noncore/settings/networksettings/interfaceadvanced.ui
index 7520abe..efe67b0 100644
--- a/noncore/settings/networksettings/interfaceadvanced.ui
+++ b/noncore/settings/networksettings/interfaceadvanced.ui
@@ -11,11 +11,18 @@
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>188</width> 14 <width>214</width>
15 <height>277</height> 15 <height>286</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>maximumSize</name>
20 <size>
21 <width>320</width>
22 <height>32767</height>
23 </size>
24 </property>
25 <property stdset="1">
19 <name>caption</name> 26 <name>caption</name>
20 <string>Advanced Interface Information</string> 27 <string>Advanced Interface Information</string>
21 </property> 28 </property>
diff --git a/noncore/settings/networksettings/interfaceinformationimp.cpp b/noncore/settings/networksettings/interfaceinformationimp.cpp
index e37e0f8..59a6400 100644
--- a/noncore/settings/networksettings/interfaceinformationimp.cpp
+++ b/noncore/settings/networksettings/interfaceinformationimp.cpp
@@ -13,16 +13,22 @@ InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *na
13 assert(i); 13 assert(i);
14 14
15 interface = i; 15 interface = i;
16 updateInterface(); 16 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
17 connect(startButton, SIGNAL(clicked()), this, SLOT(start())); 17 updateInterface(interface);
18 connect(stopButton, SIGNAL(clicked()), this, SLOT(stop())); 18 connect(startButton, SIGNAL(clicked()), interface, SLOT(start()));
19 connect(restartButton, SIGNAL(clicked()), this, SLOT(restart())); 19 connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop()));
20 connect(refreshButton, SIGNAL(clicked()), this, SLOT(refresh())); 20 connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart()));
21 connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh()));
21 connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); 22 connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced()));
22 23
23} 24}
24 25
25void InterfaceInformationImp::updateInterface(){ 26/**
27 * Update the interface information and buttons.
28 * @param Intarface *i the interface to update (should be the one we already
29 * know about).
30 */
31void InterfaceInformationImp::updateInterface(Interface *i){
26 if(interface->getStatus()){ 32 if(interface->getStatus()){
27 startButton->setEnabled(false); 33 startButton->setEnabled(false);
28 stopButton->setEnabled(true); 34 stopButton->setEnabled(true);
@@ -40,39 +46,6 @@ void InterfaceInformationImp::updateInterface(){
40} 46}
41 47
42/** 48/**
43 * Start the interface. Update the information if successfull
44 */
45void InterfaceInformationImp::start(){
46 if(interface->start()){
47 updateInterface();
48 }
49}
50
51/**
52 * Stop the interface.
53 */
54void InterfaceInformationImp::stop(){
55 if(interface->stop()){
56 updateInterface();
57 }
58}
59
60/***
61 * Tell the interface to refresh its information.
62 **/
63void InterfaceInformationImp::refresh(){
64 if(interface->refresh())
65 updateInterface();
66}
67
68void InterfaceInformationImp::restart(){
69 if(interface->restart()){
70 updateInterface();
71 }
72}
73
74
75/**
76 * Create the advanced widget. Fill it with the current interface's information. 49 * Create the advanced widget. Fill it with the current interface's information.
77 * Display it. 50 * Display it.
78 */ 51 */
diff --git a/noncore/settings/networksettings/interfaceinformationimp.h b/noncore/settings/networksettings/interfaceinformationimp.h
index c8a478e..42213cc 100644
--- a/noncore/settings/networksettings/interfaceinformationimp.h
+++ b/noncore/settings/networksettings/interfaceinformationimp.h
@@ -13,15 +13,11 @@ public:
13 ~InterfaceInformationImp(){}; 13 ~InterfaceInformationImp(){};
14 14
15private slots: 15private slots:
16 void start();
17 void stop();
18 void refresh();
19 void restart();
20 void advanced(); 16 void advanced();
17 void updateInterface(Interface *i);
21 18
22private: 19private:
23 Interface *interface; 20 Interface *interface;
24 void updateInterface();
25 21
26}; 22};
27 23
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index b46362f..117bac1 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -304,33 +304,34 @@ void MainWindowImp::jobDone(KProcess *process){
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
308 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
307 // See if we already have it 309 // See if we already have it
308 if(interfaceNames.find(interfaceName) == interfaceNames.end()){ 310 if(interfaceNames.find(interfaceName) == interfaceNames.end()){
309 if(fileName == TEMP_ALL) 311 if(fileName == TEMP_ALL)
310 i = new Interface(interfaceName, false); 312 i = new Interface(this, interfaceName, false);
311 else 313 else
312 i = new Interface(interfaceName, true); 314 i = new Interface(this, interfaceName, true);
315 i->setAttached(true);
316
317 QString hardName = "Ethernet";
318 int hardwareName = line.find("Link encap:");
319 int macAddress = line.find("HWaddr");
320 if(macAddress == -1)
321 macAddress = line.length();
322 if(hardwareName != -1)
323 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
324
325 interfaceNames.insert(i->getInterfaceName(), i);
326 updateInterface(i);
327 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
313 } 328 }
329 // It was an interface we already had.
314 else{ 330 else{
315 i = interfaceNames[interfaceName]; 331 i = interfaceNames[interfaceName];
316 if(fileName != TEMP_ALL) 332 if(fileName != TEMP_ALL)
317 i->setStatus(true); 333 i->setStatus(true);
318 } 334 }
319
320 i->setAttached(true);
321 i->setInterfaceName(interfaceName);
322
323 QString hardName = "Ethernet";
324 int hardwareName = line.find("Link encap:");
325 int macAddress = line.find("HWaddr");
326 if(macAddress == -1)
327 macAddress = line.length();
328 if(hardwareName != -1)
329 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
330 // We have found an interface
331 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
332 interfaceNames.insert(i->getInterfaceName(), i);
333 updateInterface(i);
334 } 335 }
335 } 336 }
336 file.close(); 337 file.close();
@@ -347,12 +348,12 @@ void MainWindowImp::jobDone(KProcess *process){
347 found = true; 348 found = true;
348 } 349 }
349 if(!found){ 350 if(!found){
350 Interface *i = new Interface(*ni, false); 351 Interface *i = new Interface(this, *ni, false);
351 i->setAttached(false); 352 i->setAttached(false);
352 i->setHardwareName(QString("Disconnected (%1)").arg(*ni)); 353 i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
353 i->setInterfaceName(*ni);
354 interfaceNames.insert(i->getInterfaceName(), i); 354 interfaceNames.insert(i->getInterfaceName(), i);
355 updateInterface(i); 355 updateInterface(i);
356 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
356 } 357 }
357 } 358 }
358 } 359 }
@@ -395,7 +396,9 @@ void MainWindowImp::updateInterface(Interface *i){
395 typeName = "irda"; 396 typeName = "irda";
396 if(i->getInterfaceName().contains("wlan")) 397 if(i->getInterfaceName().contains("wlan"))
397 typeName = "wlan"; 398 typeName = "wlan";
398 399 if(i->getInterfaceName().contains("usb"))
400 typeName = "usb";
401
399 if(!i->isAttached()) 402 if(!i->isAttached())
400 typeName = "connect_no"; 403 typeName = "connect_no";
401 // Actually try to use the Module 404 // Actually try to use the Module
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index 98d2eb6..f0394b4 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -24,8 +24,10 @@ QString WLANModule::getPixmapName(Interface* ){
24 * @return bool true if i is owned by this module, false otherwise. 24 * @return bool true if i is owned by this module, false otherwise.
25 */ 25 */
26bool WLANModule::isOwner(Interface *i){ 26bool WLANModule::isOwner(Interface *i){
27 if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0") 27 if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){
28 i->setHardwareName(QString("802.11b (%1)").arg(i->getInterfaceName()));
28 return true; 29 return true;
30 }
29 return false; 31 return false;
30} 32}
31 33