Diffstat (limited to 'noncore/settings/networksettings/interface.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/interface.cpp | 77 |
1 files changed, 61 insertions, 16 deletions
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 | |||
@@ -13,3 +13,3 @@ | |||
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(); |
@@ -18,13 +18,56 @@ Interface::Interface(QString name, bool newSatus): status(newSatus), attached(fa | |||
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 | ||
@@ -32,3 +75,2 @@ bool Interface::start(){ | |||
32 | refresh(); | 75 | refresh(); |
33 | return true; | ||
34 | } | 76 | } |
@@ -37,8 +79,7 @@ bool Interface::start(){ | |||
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 | ||
@@ -46,3 +87,3 @@ bool Interface::stop(){ | |||
46 | if(ret != 0) | 87 | if(ret != 0) |
47 | return false; | 88 | return; |
48 | 89 | ||
@@ -50,10 +91,10 @@ bool Interface::stop(){ | |||
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 | } |
@@ -76,2 +117,3 @@ bool Interface::refresh(){ | |||
76 | leaseExpires = ""; | 117 | leaseExpires = ""; |
118 | emit(updateInterface(this)); | ||
77 | return true; | 119 | return true; |
@@ -140,2 +182,3 @@ bool Interface::refresh(){ | |||
140 | if(!QFile::exists(dhcpFile)){ | 182 | if(!QFile::exists(dhcpFile)){ |
183 | emit(updateInterface(this)); | ||
141 | return true; | 184 | return true; |
@@ -237,2 +280,4 @@ bool Interface::refresh(){ | |||
237 | dhcp = true; | 280 | dhcp = true; |
281 | |||
282 | emit(updateInterface(this)); | ||
238 | return true; | 283 | return true; |