author | benmeyer <benmeyer> | 2003-01-13 19:07:40 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2003-01-13 19:07:40 (UTC) |
commit | b5e3438b22606a00e17afd14674aa685739237c1 (patch) (unidiff) | |
tree | 4359f55ade82e06316b3b496db82fbafbdf29a15 | |
parent | 4cd81644fb2ac8cd91e4dd79c2274656f5bfe81a (diff) | |
download | opie-b5e3438b22606a00e17afd14674aa685739237c1.zip opie-b5e3438b22606a00e17afd14674aa685739237c1.tar.gz opie-b5e3438b22606a00e17afd14674aa685739237c1.tar.bz2 |
test
-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,128 +1,130 @@ | |||
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; |
97 | } | 99 | } |
98 | 100 | ||
99 | int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); | 101 | int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); |
100 | if(ret != 0){ | 102 | if(ret != 0){ |
101 | emit (updateMessage("Stopping interface failed")); | 103 | emit (updateMessage("Stopping interface failed")); |
102 | return; | 104 | return; |
103 | } | 105 | } |
104 | 106 | ||
105 | status = false; | 107 | status = false; |
106 | refresh(); | 108 | refresh(); |
107 | emit (updateMessage("Stop successfull")); | 109 | emit (updateMessage("Stop successfull")); |
108 | } | 110 | } |
109 | 111 | ||
110 | /** | 112 | /** |
111 | * Try to restart the interface. | 113 | * Try to restart the interface. |
112 | */ | 114 | */ |
113 | void Interface::restart(){ | 115 | void Interface::restart(){ |
114 | stop(); | 116 | stop(); |
115 | start(); | 117 | start(); |
116 | } | 118 | } |
117 | 119 | ||
118 | /** | 120 | /** |
119 | * Try to refresh the information about the interface. | 121 | * Try to refresh the information about the interface. |
120 | * First call ifconfig, then check the dhcp-info file | 122 | * First call ifconfig, then check the dhcp-info file |
121 | * @return bool true if successfull. | 123 | * @return bool true if successfull. |
122 | */ | 124 | */ |
123 | bool Interface::refresh(){ | 125 | bool Interface::refresh(){ |
124 | // See if we are up. | 126 | // See if we are up. |
125 | if(status == false){ | 127 | if(status == false){ |
126 | macAddress = ""; | 128 | macAddress = ""; |
127 | ip = "0.0.0.0"; | 129 | ip = "0.0.0.0"; |
128 | subnetMask = "0.0.0.0"; | 130 | subnetMask = "0.0.0.0"; |