-rw-r--r-- | noncore/net/networksetup/TODO | 2 | ||||
-rw-r--r-- | noncore/net/networksetup/interface.cpp | 77 | ||||
-rw-r--r-- | noncore/net/networksetup/interface.h | 31 | ||||
-rw-r--r-- | noncore/net/networksetup/interfaceadvanced.ui | 11 | ||||
-rw-r--r-- | noncore/net/networksetup/interfaceinformationimp.cpp | 51 | ||||
-rw-r--r-- | noncore/net/networksetup/interfaceinformationimp.h | 6 | ||||
-rw-r--r-- | noncore/net/networksetup/mainwindowimp.cpp | 43 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanmodule.cpp | 4 | ||||
-rw-r--r-- | noncore/settings/networksettings/TODO | 2 | ||||
-rw-r--r-- | noncore/settings/networksettings/interface.cpp | 77 | ||||
-rw-r--r-- | noncore/settings/networksettings/interface.h | 31 | ||||
-rw-r--r-- | noncore/settings/networksettings/interfaceadvanced.ui | 11 | ||||
-rw-r--r-- | noncore/settings/networksettings/interfaceinformationimp.cpp | 51 | ||||
-rw-r--r-- | noncore/settings/networksettings/interfaceinformationimp.h | 6 | ||||
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 43 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanmodule.cpp | 4 |
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,8 +1,10 @@ | |||
1 | Write 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 |
4 | networksetup, doesnt bring you back to the main screen. | 6 | networksetup, doesnt bring you back to the main screen. |
5 | [x] Wlanmodule isnt writing out wireless.opts | 7 | [x] Wlanmodule isnt writing out wireless.opts |
6 | [ ] Need a means of bringing an interface up and down (calling | 8 | [ ] Need a means of bringing an interface up and down (calling |
7 | out ifup/ifdown) from the gui. | 9 | out ifup/ifdown) from the gui. |
8 | -Ben- Click information, then click up or down... :-D | 10 | -Ben- Click information, then click up or down... :-D |
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 | |||
@@ -6,61 +6,102 @@ | |||
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(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){ | 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){ |
15 | refresh(); | 15 | refresh(); |
16 | } | 16 | } |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * Set status | ||
20 | * @param newStatus - the new status | ||
21 | * emit updateInterface | ||
22 | */ | ||
23 | void 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 | */ | ||
35 | void 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 | */ | ||
45 | void 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 | */ | ||
55 | void 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 | */ |
22 | bool Interface::start(){ | 64 | void 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 | */ |
40 | bool Interface::stop(){ | 81 | void 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 | */ |
57 | bool Interface::restart(){ | 97 | void Interface::restart(){ |
58 | return (stop() && start()); | 98 | stop(); |
99 | start(); | ||
59 | } | 100 | } |
60 | 101 | ||
61 | /** | 102 | /** |
62 | * Try to refresh the information about the interface. | 103 | * Try to refresh the information about the interface. |
63 | * First call ifconfig, then check the dhcp-info file | 104 | * First call ifconfig, then check the dhcp-info file |
64 | * @return bool true if successfull. | 105 | * @return bool true if successfull. |
65 | */ | 106 | */ |
66 | bool Interface::refresh(){ | 107 | bool Interface::refresh(){ |
@@ -69,16 +110,17 @@ bool Interface::refresh(){ | |||
69 | macAddress = ""; | 110 | macAddress = ""; |
70 | ip = "0.0.0.0"; | 111 | ip = "0.0.0.0"; |
71 | subnetMask = "0.0.0.0"; | 112 | subnetMask = "0.0.0.0"; |
72 | broadcast = ""; | 113 | broadcast = ""; |
73 | dhcp = false; | 114 | dhcp = false; |
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 | ||
80 | QString fileName = QString("/tmp/%1_ifconfig_info").arg(interfaceName); | 122 | QString fileName = QString("/tmp/%1_ifconfig_info").arg(interfaceName); |
81 | 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(interfaceName).arg(fileName).latin1()); |
82 | if(ret != 0){ | 124 | if(ret != 0){ |
83 | 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()); |
84 | return false; | 126 | return false; |
@@ -133,16 +175,17 @@ bool Interface::refresh(){ | |||
133 | QDir d(dhcpDirectory); | 175 | QDir d(dhcpDirectory); |
134 | if(!d.exists(dhcpDirectory)) | 176 | if(!d.exists(dhcpDirectory)) |
135 | dhcpDirectory = "/var/run"; | 177 | dhcpDirectory = "/var/run"; |
136 | 178 | ||
137 | // See if we have | 179 | // See if we have |
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 | ||
144 | file.setName(dhcpFile); | 187 | file.setName(dhcpFile); |
145 | if (!file.open(IO_ReadOnly)){ | 188 | if (!file.open(IO_ReadOnly)){ |
146 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); | 189 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); |
147 | return false; | 190 | return false; |
148 | } | 191 | } |
@@ -230,13 +273,15 @@ bool Interface::refresh(){ | |||
230 | // Calculate the start and renew times | 273 | // Calculate the start and renew times |
231 | leaseObtained= datetime.toString(); | 274 | leaseObtained= datetime.toString(); |
232 | 275 | ||
233 | // Calculate the start and renew times | 276 | // Calculate the start and renew times |
234 | datetime = datetime.addSecs(leaseTime); | 277 | datetime = datetime.addSecs(leaseTime); |
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 | ||
241 | // interface.cpp | 286 | // interface.cpp |
242 | 287 | ||
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 | |||
@@ -1,50 +1,55 @@ | |||
1 | #ifndef INTERFACE_H | 1 | #ifndef INTERFACE_H |
2 | #define INTERFACE_H | 2 | #define INTERFACE_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qobject.h> | ||
5 | 6 | ||
6 | class Module; | 7 | class Module; |
7 | 8 | ||
8 | class Interface { | 9 | class Interface : public QObject{ |
10 | Q_OBJECT | ||
9 | 11 | ||
12 | signals: | ||
13 | void updateInterface(Interface *i); | ||
14 | |||
10 | public: | 15 | public: |
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; }; |
31 | QString getIp(){ return ip; }; | 35 | QString getIp(){ return ip; }; |
32 | QString getSubnetMask(){ return subnetMask; }; | 36 | QString getSubnetMask(){ return subnetMask; }; |
33 | QString getBroadcast(){ return broadcast; }; | 37 | QString getBroadcast(){ return broadcast; }; |
34 | bool isDhcp(){ return dhcp; }; | 38 | bool isDhcp(){ return dhcp; }; |
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 | ||
43 | public 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 | ||
44 | private: | 49 | private: |
45 | // Interface information | 50 | // Interface information |
46 | bool status; | 51 | bool status; |
47 | bool attached; | 52 | bool attached; |
48 | QString interfaceName; | 53 | QString interfaceName; |
49 | QString hardareName; | 54 | QString hardareName; |
50 | Module *moduleOwner; | 55 | Module *moduleOwner; |
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 | |||
@@ -6,21 +6,28 @@ | |||
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>InterfaceAdvanced</cstring> | 7 | <cstring>InterfaceAdvanced</cstring> |
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
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> |
22 | <grid> | 29 | <grid> |
23 | <property stdset="1"> | 30 | <property stdset="1"> |
24 | <name>margin</name> | 31 | <name>margin</name> |
25 | <number>11</number> | 32 | <number>11</number> |
26 | </property> | 33 | </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 | |||
@@ -8,26 +8,32 @@ | |||
8 | /** | 8 | /** |
9 | * Constructor for the InterfaceInformationImp class. This class pretty much | 9 | * Constructor for the InterfaceInformationImp class. This class pretty much |
10 | * just display's information about the interface that is passed to it. | 10 | * just display's information about the interface that is passed to it. |
11 | */ | 11 | */ |
12 | InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f){ | 12 | InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f){ |
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 | ||
25 | void 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 | */ | ||
31 | void 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); |
29 | restartButton->setEnabled(true); | 35 | restartButton->setEnabled(true); |
30 | } | 36 | } |
31 | else{ | 37 | else{ |
32 | startButton->setEnabled(true); | 38 | startButton->setEnabled(true); |
33 | stopButton->setEnabled(false); | 39 | stopButton->setEnabled(false); |
@@ -35,49 +41,16 @@ void InterfaceInformationImp::updateInterface(){ | |||
35 | } | 41 | } |
36 | macAddressLabel->setText(interface->getMacAddress()); | 42 | macAddressLabel->setText(interface->getMacAddress()); |
37 | ipAddressLabel->setText(interface->getIp()); | 43 | ipAddressLabel->setText(interface->getIp()); |
38 | subnetMaskLabel->setText(interface->getSubnetMask()); | 44 | subnetMaskLabel->setText(interface->getSubnetMask()); |
39 | broadcastLabel->setText(interface->getBroadcast()); | 45 | broadcastLabel->setText(interface->getBroadcast()); |
40 | } | 46 | } |
41 | 47 | ||
42 | /** | 48 | /** |
43 | * Start the interface. Update the information if successfull | ||
44 | */ | ||
45 | void InterfaceInformationImp::start(){ | ||
46 | if(interface->start()){ | ||
47 | updateInterface(); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * Stop the interface. | ||
53 | */ | ||
54 | void InterfaceInformationImp::stop(){ | ||
55 | if(interface->stop()){ | ||
56 | updateInterface(); | ||
57 | } | ||
58 | } | ||
59 | |||
60 | /*** | ||
61 | * Tell the interface to refresh its information. | ||
62 | **/ | ||
63 | void InterfaceInformationImp::refresh(){ | ||
64 | if(interface->refresh()) | ||
65 | updateInterface(); | ||
66 | } | ||
67 | |||
68 | void 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 | */ |
79 | void InterfaceInformationImp::advanced(){ | 52 | void InterfaceInformationImp::advanced(){ |
80 | InterfaceAdvanced *a = new InterfaceAdvanced(0, "InterfaceAdvanced"); | 53 | InterfaceAdvanced *a = new InterfaceAdvanced(0, "InterfaceAdvanced"); |
81 | a->interfaceName->setText(interface->getInterfaceName()); | 54 | a->interfaceName->setText(interface->getInterfaceName()); |
82 | a->macAddressLabel->setText(interface->getMacAddress()); | 55 | a->macAddressLabel->setText(interface->getMacAddress()); |
83 | a->ipAddressLabel->setText(interface->getIp()); | 56 | a->ipAddressLabel->setText(interface->getIp()); |
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 | |||
@@ -8,24 +8,20 @@ class InterfaceInformationImp : public InterfaceInformation { | |||
8 | 8 | ||
9 | Q_OBJECT | 9 | Q_OBJECT |
10 | 10 | ||
11 | public: | 11 | public: |
12 | InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); | 12 | InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); |
13 | ~InterfaceInformationImp(){}; | 13 | ~InterfaceInformationImp(){}; |
14 | 14 | ||
15 | private slots: | 15 | private 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 | ||
22 | private: | 19 | private: |
23 | Interface *interface; | 20 | Interface *interface; |
24 | void updateInterface(); | ||
25 | 21 | ||
26 | }; | 22 | }; |
27 | 23 | ||
28 | #endif | 24 | #endif |
29 | 25 | ||
30 | // addserviceimp.h | 26 | // addserviceimp.h |
31 | 27 | ||
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 | |||
@@ -299,65 +299,66 @@ void MainWindowImp::jobDone(KProcess *process){ | |||
299 | QString line; | 299 | QString line; |
300 | while ( !stream.eof() ) { | 300 | while ( !stream.eof() ) { |
301 | line = stream.readLine(); | 301 | line = stream.readLine(); |
302 | int space = line.find(" "); | 302 | int space = line.find(" "); |
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 | ||
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(); |
337 | QFile::remove(fileName); | 338 | QFile::remove(fileName); |
338 | 339 | ||
339 | if(threads.count() == 0){ | 340 | if(threads.count() == 0){ |
340 | Interfaces i; | 341 | Interfaces i; |
341 | QStringList list = i.getInterfaceList(); | 342 | QStringList list = i.getInterfaceList(); |
342 | QMap<QString, Interface*>::Iterator it; | 343 | QMap<QString, Interface*>::Iterator it; |
343 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { | 344 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { |
344 | bool found = false; | 345 | bool found = false; |
345 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ | 346 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ |
346 | if(it.key() == (*ni)) | 347 | if(it.key() == (*ni)) |
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 | } |
359 | } | 360 | } |
360 | 361 | ||
361 | /** | 362 | /** |
362 | * Update this interface. If no QListViewItem exists create one. | 363 | * Update this interface. If no QListViewItem exists create one. |
363 | * @param Interface* pointer to the interface that needs to be updated. | 364 | * @param Interface* pointer to the interface that needs to be updated. |
@@ -390,17 +391,19 @@ void MainWindowImp::updateInterface(Interface *i){ | |||
390 | 391 | ||
391 | QString typeName = "lan"; | 392 | QString typeName = "lan"; |
392 | if(i->getHardwareName().contains("Local Loopback")) | 393 | if(i->getHardwareName().contains("Local Loopback")) |
393 | typeName = "lo"; | 394 | typeName = "lo"; |
394 | if(i->getInterfaceName().contains("irda")) | 395 | if(i->getInterfaceName().contains("irda")) |
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 |
402 | if(i->getModuleOwner() != NULL) | 405 | if(i->getModuleOwner() != NULL) |
403 | typeName = i->getModuleOwner()->getPixmapName(i); | 406 | typeName = i->getModuleOwner()->getPixmapName(i); |
404 | 407 | ||
405 | item->setPixmap(1, (Resource::loadPixmap(typeName))); | 408 | item->setPixmap(1, (Resource::loadPixmap(typeName))); |
406 | item->setText(2, i->getHardwareName()); | 409 | item->setText(2, i->getHardwareName()); |
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 | |||
@@ -19,18 +19,20 @@ QString WLANModule::getPixmapName(Interface* ){ | |||
19 | } | 19 | } |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * Check to see if the interface i is owned by this module. | 22 | * Check to see if the interface i is owned by this module. |
23 | * @param Interface* interface to check against | 23 | * @param Interface* interface to check against |
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 | */ |
26 | bool WLANModule::isOwner(Interface *i){ | 26 | bool 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 | ||
32 | /** | 34 | /** |
33 | * Create, set tabWiget and return the WLANConfigure Module | 35 | * Create, set tabWiget and return the WLANConfigure Module |
34 | * @param tabWidget a pointer to the tab widget that this configure has. | 36 | * @param tabWidget a pointer to the tab widget that this configure has. |
35 | * @return QWidget* pointer to the tab widget in this modules configure. | 37 | * @return QWidget* pointer to the tab widget in this modules configure. |
36 | */ | 38 | */ |
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,8 +1,10 @@ | |||
1 | Write 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 |
4 | networksetup, doesnt bring you back to the main screen. | 6 | networksetup, doesnt bring you back to the main screen. |
5 | [x] Wlanmodule isnt writing out wireless.opts | 7 | [x] Wlanmodule isnt writing out wireless.opts |
6 | [ ] Need a means of bringing an interface up and down (calling | 8 | [ ] Need a means of bringing an interface up and down (calling |
7 | out ifup/ifdown) from the gui. | 9 | out ifup/ifdown) from the gui. |
8 | -Ben- Click information, then click up or down... :-D | 10 | -Ben- Click information, then click up or down... :-D |
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 | |||
@@ -6,61 +6,102 @@ | |||
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(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){ | 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){ |
15 | refresh(); | 15 | refresh(); |
16 | } | 16 | } |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * Set status | ||
20 | * @param newStatus - the new status | ||
21 | * emit updateInterface | ||
22 | */ | ||
23 | void 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 | */ | ||
35 | void 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 | */ | ||
45 | void 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 | */ | ||
55 | void 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 | */ |
22 | bool Interface::start(){ | 64 | void 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 | */ |
40 | bool Interface::stop(){ | 81 | void 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 | */ |
57 | bool Interface::restart(){ | 97 | void Interface::restart(){ |
58 | return (stop() && start()); | 98 | stop(); |
99 | start(); | ||
59 | } | 100 | } |
60 | 101 | ||
61 | /** | 102 | /** |
62 | * Try to refresh the information about the interface. | 103 | * Try to refresh the information about the interface. |
63 | * First call ifconfig, then check the dhcp-info file | 104 | * First call ifconfig, then check the dhcp-info file |
64 | * @return bool true if successfull. | 105 | * @return bool true if successfull. |
65 | */ | 106 | */ |
66 | bool Interface::refresh(){ | 107 | bool Interface::refresh(){ |
@@ -69,16 +110,17 @@ bool Interface::refresh(){ | |||
69 | macAddress = ""; | 110 | macAddress = ""; |
70 | ip = "0.0.0.0"; | 111 | ip = "0.0.0.0"; |
71 | subnetMask = "0.0.0.0"; | 112 | subnetMask = "0.0.0.0"; |
72 | broadcast = ""; | 113 | broadcast = ""; |
73 | dhcp = false; | 114 | dhcp = false; |
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 | ||
80 | QString fileName = QString("/tmp/%1_ifconfig_info").arg(interfaceName); | 122 | QString fileName = QString("/tmp/%1_ifconfig_info").arg(interfaceName); |
81 | 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(interfaceName).arg(fileName).latin1()); |
82 | if(ret != 0){ | 124 | if(ret != 0){ |
83 | 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()); |
84 | return false; | 126 | return false; |
@@ -133,16 +175,17 @@ bool Interface::refresh(){ | |||
133 | QDir d(dhcpDirectory); | 175 | QDir d(dhcpDirectory); |
134 | if(!d.exists(dhcpDirectory)) | 176 | if(!d.exists(dhcpDirectory)) |
135 | dhcpDirectory = "/var/run"; | 177 | dhcpDirectory = "/var/run"; |
136 | 178 | ||
137 | // See if we have | 179 | // See if we have |
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 | ||
144 | file.setName(dhcpFile); | 187 | file.setName(dhcpFile); |
145 | if (!file.open(IO_ReadOnly)){ | 188 | if (!file.open(IO_ReadOnly)){ |
146 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); | 189 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); |
147 | return false; | 190 | return false; |
148 | } | 191 | } |
@@ -230,13 +273,15 @@ bool Interface::refresh(){ | |||
230 | // Calculate the start and renew times | 273 | // Calculate the start and renew times |
231 | leaseObtained= datetime.toString(); | 274 | leaseObtained= datetime.toString(); |
232 | 275 | ||
233 | // Calculate the start and renew times | 276 | // Calculate the start and renew times |
234 | datetime = datetime.addSecs(leaseTime); | 277 | datetime = datetime.addSecs(leaseTime); |
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 | ||
241 | // interface.cpp | 286 | // interface.cpp |
242 | 287 | ||
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 | |||
@@ -1,50 +1,55 @@ | |||
1 | #ifndef INTERFACE_H | 1 | #ifndef INTERFACE_H |
2 | #define INTERFACE_H | 2 | #define INTERFACE_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qobject.h> | ||
5 | 6 | ||
6 | class Module; | 7 | class Module; |
7 | 8 | ||
8 | class Interface { | 9 | class Interface : public QObject{ |
10 | Q_OBJECT | ||
9 | 11 | ||
12 | signals: | ||
13 | void updateInterface(Interface *i); | ||
14 | |||
10 | public: | 15 | public: |
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; }; |
31 | QString getIp(){ return ip; }; | 35 | QString getIp(){ return ip; }; |
32 | QString getSubnetMask(){ return subnetMask; }; | 36 | QString getSubnetMask(){ return subnetMask; }; |
33 | QString getBroadcast(){ return broadcast; }; | 37 | QString getBroadcast(){ return broadcast; }; |
34 | bool isDhcp(){ return dhcp; }; | 38 | bool isDhcp(){ return dhcp; }; |
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 | ||
43 | public 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 | ||
44 | private: | 49 | private: |
45 | // Interface information | 50 | // Interface information |
46 | bool status; | 51 | bool status; |
47 | bool attached; | 52 | bool attached; |
48 | QString interfaceName; | 53 | QString interfaceName; |
49 | QString hardareName; | 54 | QString hardareName; |
50 | Module *moduleOwner; | 55 | Module *moduleOwner; |
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 | |||
@@ -6,21 +6,28 @@ | |||
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>InterfaceAdvanced</cstring> | 7 | <cstring>InterfaceAdvanced</cstring> |
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
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> |
22 | <grid> | 29 | <grid> |
23 | <property stdset="1"> | 30 | <property stdset="1"> |
24 | <name>margin</name> | 31 | <name>margin</name> |
25 | <number>11</number> | 32 | <number>11</number> |
26 | </property> | 33 | </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 | |||
@@ -8,26 +8,32 @@ | |||
8 | /** | 8 | /** |
9 | * Constructor for the InterfaceInformationImp class. This class pretty much | 9 | * Constructor for the InterfaceInformationImp class. This class pretty much |
10 | * just display's information about the interface that is passed to it. | 10 | * just display's information about the interface that is passed to it. |
11 | */ | 11 | */ |
12 | InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f){ | 12 | InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f){ |
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 | ||
25 | void 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 | */ | ||
31 | void 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); |
29 | restartButton->setEnabled(true); | 35 | restartButton->setEnabled(true); |
30 | } | 36 | } |
31 | else{ | 37 | else{ |
32 | startButton->setEnabled(true); | 38 | startButton->setEnabled(true); |
33 | stopButton->setEnabled(false); | 39 | stopButton->setEnabled(false); |
@@ -35,49 +41,16 @@ void InterfaceInformationImp::updateInterface(){ | |||
35 | } | 41 | } |
36 | macAddressLabel->setText(interface->getMacAddress()); | 42 | macAddressLabel->setText(interface->getMacAddress()); |
37 | ipAddressLabel->setText(interface->getIp()); | 43 | ipAddressLabel->setText(interface->getIp()); |
38 | subnetMaskLabel->setText(interface->getSubnetMask()); | 44 | subnetMaskLabel->setText(interface->getSubnetMask()); |
39 | broadcastLabel->setText(interface->getBroadcast()); | 45 | broadcastLabel->setText(interface->getBroadcast()); |
40 | } | 46 | } |
41 | 47 | ||
42 | /** | 48 | /** |
43 | * Start the interface. Update the information if successfull | ||
44 | */ | ||
45 | void InterfaceInformationImp::start(){ | ||
46 | if(interface->start()){ | ||
47 | updateInterface(); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * Stop the interface. | ||
53 | */ | ||
54 | void InterfaceInformationImp::stop(){ | ||
55 | if(interface->stop()){ | ||
56 | updateInterface(); | ||
57 | } | ||
58 | } | ||
59 | |||
60 | /*** | ||
61 | * Tell the interface to refresh its information. | ||
62 | **/ | ||
63 | void InterfaceInformationImp::refresh(){ | ||
64 | if(interface->refresh()) | ||
65 | updateInterface(); | ||
66 | } | ||
67 | |||
68 | void 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 | */ |
79 | void InterfaceInformationImp::advanced(){ | 52 | void InterfaceInformationImp::advanced(){ |
80 | InterfaceAdvanced *a = new InterfaceAdvanced(0, "InterfaceAdvanced"); | 53 | InterfaceAdvanced *a = new InterfaceAdvanced(0, "InterfaceAdvanced"); |
81 | a->interfaceName->setText(interface->getInterfaceName()); | 54 | a->interfaceName->setText(interface->getInterfaceName()); |
82 | a->macAddressLabel->setText(interface->getMacAddress()); | 55 | a->macAddressLabel->setText(interface->getMacAddress()); |
83 | a->ipAddressLabel->setText(interface->getIp()); | 56 | a->ipAddressLabel->setText(interface->getIp()); |
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 | |||
@@ -8,24 +8,20 @@ class InterfaceInformationImp : public InterfaceInformation { | |||
8 | 8 | ||
9 | Q_OBJECT | 9 | Q_OBJECT |
10 | 10 | ||
11 | public: | 11 | public: |
12 | InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); | 12 | InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); |
13 | ~InterfaceInformationImp(){}; | 13 | ~InterfaceInformationImp(){}; |
14 | 14 | ||
15 | private slots: | 15 | private 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 | ||
22 | private: | 19 | private: |
23 | Interface *interface; | 20 | Interface *interface; |
24 | void updateInterface(); | ||
25 | 21 | ||
26 | }; | 22 | }; |
27 | 23 | ||
28 | #endif | 24 | #endif |
29 | 25 | ||
30 | // addserviceimp.h | 26 | // addserviceimp.h |
31 | 27 | ||
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 | |||
@@ -299,65 +299,66 @@ void MainWindowImp::jobDone(KProcess *process){ | |||
299 | QString line; | 299 | QString line; |
300 | while ( !stream.eof() ) { | 300 | while ( !stream.eof() ) { |
301 | line = stream.readLine(); | 301 | line = stream.readLine(); |
302 | int space = line.find(" "); | 302 | int space = line.find(" "); |
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 | ||
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(); |
337 | QFile::remove(fileName); | 338 | QFile::remove(fileName); |
338 | 339 | ||
339 | if(threads.count() == 0){ | 340 | if(threads.count() == 0){ |
340 | Interfaces i; | 341 | Interfaces i; |
341 | QStringList list = i.getInterfaceList(); | 342 | QStringList list = i.getInterfaceList(); |
342 | QMap<QString, Interface*>::Iterator it; | 343 | QMap<QString, Interface*>::Iterator it; |
343 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { | 344 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { |
344 | bool found = false; | 345 | bool found = false; |
345 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ | 346 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ |
346 | if(it.key() == (*ni)) | 347 | if(it.key() == (*ni)) |
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 | } |
359 | } | 360 | } |
360 | 361 | ||
361 | /** | 362 | /** |
362 | * Update this interface. If no QListViewItem exists create one. | 363 | * Update this interface. If no QListViewItem exists create one. |
363 | * @param Interface* pointer to the interface that needs to be updated. | 364 | * @param Interface* pointer to the interface that needs to be updated. |
@@ -390,17 +391,19 @@ void MainWindowImp::updateInterface(Interface *i){ | |||
390 | 391 | ||
391 | QString typeName = "lan"; | 392 | QString typeName = "lan"; |
392 | if(i->getHardwareName().contains("Local Loopback")) | 393 | if(i->getHardwareName().contains("Local Loopback")) |
393 | typeName = "lo"; | 394 | typeName = "lo"; |
394 | if(i->getInterfaceName().contains("irda")) | 395 | if(i->getInterfaceName().contains("irda")) |
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 |
402 | if(i->getModuleOwner() != NULL) | 405 | if(i->getModuleOwner() != NULL) |
403 | typeName = i->getModuleOwner()->getPixmapName(i); | 406 | typeName = i->getModuleOwner()->getPixmapName(i); |
404 | 407 | ||
405 | item->setPixmap(1, (Resource::loadPixmap(typeName))); | 408 | item->setPixmap(1, (Resource::loadPixmap(typeName))); |
406 | item->setText(2, i->getHardwareName()); | 409 | item->setText(2, i->getHardwareName()); |
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 | |||
@@ -19,18 +19,20 @@ QString WLANModule::getPixmapName(Interface* ){ | |||
19 | } | 19 | } |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * Check to see if the interface i is owned by this module. | 22 | * Check to see if the interface i is owned by this module. |
23 | * @param Interface* interface to check against | 23 | * @param Interface* interface to check against |
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 | */ |
26 | bool WLANModule::isOwner(Interface *i){ | 26 | bool 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 | ||
32 | /** | 34 | /** |
33 | * Create, set tabWiget and return the WLANConfigure Module | 35 | * Create, set tabWiget and return the WLANConfigure Module |
34 | * @param tabWidget a pointer to the tab widget that this configure has. | 36 | * @param tabWidget a pointer to the tab widget that this configure has. |
35 | * @return QWidget* pointer to the tab widget in this modules configure. | 37 | * @return QWidget* pointer to the tab widget in this modules configure. |
36 | */ | 38 | */ |