-rw-r--r-- | noncore/settings/networksettings/interfaces/interface.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/noncore/settings/networksettings/interfaces/interface.cpp b/noncore/settings/networksettings/interfaces/interface.cpp index d964961..3af521c 100644 --- a/noncore/settings/networksettings/interfaces/interface.cpp +++ b/noncore/settings/networksettings/interfaces/interface.cpp | |||
@@ -1,96 +1,102 @@ | |||
1 | /** | ||
2 | * $Author$ | ||
3 | * $Date$ | ||
4 | * $Name$ | ||
5 | */ | ||
6 | |||
1 | #include "interface.h" | 7 | #include "interface.h" |
2 | #include <qdatetime.h> | 8 | #include <qdatetime.h> |
3 | #include <qfile.h> | 9 | #include <qfile.h> |
4 | #include <qdir.h> | 10 | #include <qdir.h> |
5 | #include <qfileinfo.h> | 11 | #include <qfileinfo.h> |
6 | #include <qtextstream.h> | 12 | #include <qtextstream.h> |
7 | 13 | ||
8 | #define IFCONFIG "/sbin/ifconfig" | 14 | #define IFCONFIG "/sbin/ifconfig" |
9 | #define DHCP_INFO_DIR "/etc/dhcpc" | 15 | #define DHCP_INFO_DIR "/etc/dhcpc" |
10 | 16 | ||
11 | #include <stdio.h> | 17 | #include <stdio.h> |
12 | #include <stdlib.h> | 18 | #include <stdlib.h> |
13 | 19 | ||
14 | Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), hardwareName("Unknown"), moduleOwner(NULL), status(newSatus), attached(false), dhcp(false), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"){ | 20 | Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), hardwareName("Unknown"), moduleOwner(NULL), status(newSatus), attached(false), dhcp(false), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"){ |
15 | refresh(); | 21 | refresh(); |
16 | } | 22 | } |
17 | 23 | ||
18 | /** | 24 | /** |
19 | * Set status | 25 | * Set status |
20 | * @param newStatus - the new status | 26 | * @param newStatus - the new status |
21 | * emit updateInterface | 27 | * emit updateInterface |
22 | */ | 28 | */ |
23 | void Interface::setStatus(bool newStatus){ | 29 | void Interface::setStatus(bool newStatus){ |
24 | if(status != newStatus){ | 30 | if(status != newStatus){ |
25 | status = newStatus; | 31 | status = newStatus; |
26 | refresh(); | 32 | refresh(); |
27 | } | 33 | } |
28 | }; | 34 | }; |
29 | 35 | ||
30 | /** | 36 | /** |
31 | * Set if attached or not (802.11 card pulled out for example) | 37 | * Set if attached or not (802.11 card pulled out for example) |
32 | * @param isAttached - if attached | 38 | * @param isAttached - if attached |
33 | * emit updateInterface | 39 | * emit updateInterface |
34 | */ | 40 | */ |
35 | void Interface::setAttached(bool isAttached){ | 41 | void Interface::setAttached(bool isAttached){ |
36 | attached = isAttached; | 42 | attached = isAttached; |
37 | emit(updateInterface(this)); | 43 | emit(updateInterface(this)); |
38 | }; | 44 | }; |
39 | 45 | ||
40 | /** | 46 | /** |
41 | * Set Hardware name | 47 | * Set Hardware name |
42 | * @param name - the new name | 48 | * @param name - the new name |
43 | * emit updateInterface | 49 | * emit updateInterface |
44 | */ | 50 | */ |
45 | void Interface::setHardwareName(const QString &name){ | 51 | void Interface::setHardwareName(const QString &name){ |
46 | hardwareName = name; | 52 | hardwareName = name; |
47 | emit(updateInterface(this)); | 53 | emit(updateInterface(this)); |
48 | }; | 54 | }; |
49 | 55 | ||
50 | /** | 56 | /** |
51 | * Set Module owner | 57 | * Set Module owner |
52 | * @param owner - the new owner | 58 | * @param owner - the new owner |
53 | * emit updateInterface | 59 | * emit updateInterface |
54 | */ | 60 | */ |
55 | void Interface::setModuleOwner(Module *owner){ | 61 | void Interface::setModuleOwner(Module *owner){ |
56 | moduleOwner = owner; | 62 | moduleOwner = owner; |
57 | emit(updateInterface(this)); | 63 | emit(updateInterface(this)); |
58 | }; | 64 | }; |
59 | 65 | ||
60 | 66 | ||
61 | /** | 67 | /** |
62 | * Try to start the interface. | 68 | * Try to start the interface. |
63 | */ | 69 | */ |
64 | void Interface::start(){ | 70 | void Interface::start(){ |
65 | // check to see if we are already running. | 71 | // check to see if we are already running. |
66 | if(true == status){ | 72 | if(true == status){ |
67 | emit (updateMessage("Unable to start interface,\n already started")); | 73 | emit (updateMessage("Unable to start interface,\n already started")); |
68 | return; | 74 | return; |
69 | } | 75 | } |
70 | 76 | ||
71 | int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); | 77 | int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); |
72 | // See if it was successfull... | 78 | // See if it was successfull... |
73 | if(ret != 0){ | 79 | if(ret != 0){ |
74 | emit (updateMessage("Starting interface failed")); | 80 | emit (updateMessage("Starting interface failed")); |
75 | return; | 81 | return; |
76 | } | 82 | } |
77 | 83 | ||
78 | status = true; | 84 | status = true; |
79 | refresh(); | 85 | refresh(); |
80 | emit (updateMessage("Start successfull")); | 86 | emit (updateMessage("Start successfull")); |
81 | } | 87 | } |
82 | 88 | ||
83 | /** | 89 | /** |
84 | * Try to stop the interface. | 90 | * Try to stop the interface. |
85 | */ | 91 | */ |
86 | void Interface::stop(){ | 92 | void Interface::stop(){ |
87 | // check to see if we are already stopped. | 93 | // check to see if we are already stopped. |
88 | if(false == status){ | 94 | if(false == status){ |
89 | emit (updateMessage("Unable to stop interface,\n already stopped")); | 95 | emit (updateMessage("Unable to stop interface,\n already stopped")); |
90 | return; | 96 | return; |
91 | } | 97 | } |
92 | 98 | ||
93 | int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); | 99 | int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); |
94 | if(ret != 0){ | 100 | if(ret != 0){ |
95 | emit (updateMessage("Stopping interface failed")); | 101 | emit (updateMessage("Stopping interface failed")); |
96 | return; | 102 | return; |