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