author | zecke <zecke> | 2004-12-20 22:29:08 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-12-20 22:29:08 (UTC) |
commit | fd530016abd98bb6164c1ac962de0ca11d82e407 (patch) (unidiff) | |
tree | ed352181c3c490ddf300665699a096a494028ef6 | |
parent | 89b3fd61bdd13e62ff64bd7ab0b15c10a964b867 (diff) | |
download | opie-fd530016abd98bb6164c1ac962de0ca11d82e407.zip opie-fd530016abd98bb6164c1ac962de0ca11d82e407.tar.gz opie-fd530016abd98bb6164c1ac962de0ca11d82e407.tar.bz2 |
Restore Changes:
Call ifup/ifdown INTERFACE instead of ifconfig as requested
by Chris Larson
-rw-r--r-- | noncore/settings/networksettings/interfaces/interface.cpp | 46 | ||||
-rw-r--r-- | noncore/settings/networksettings/interfaces/interface.h | 1 |
2 files changed, 42 insertions, 5 deletions
diff --git a/noncore/settings/networksettings/interfaces/interface.cpp b/noncore/settings/networksettings/interfaces/interface.cpp index 46f3e19..44c0264 100644 --- a/noncore/settings/networksettings/interfaces/interface.cpp +++ b/noncore/settings/networksettings/interfaces/interface.cpp | |||
@@ -1,294 +1,330 @@ | |||
1 | /** | 1 | /** |
2 | * $Author$ | 2 | * $Author$ |
3 | * $Date$ | 3 | * $Date$ |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "interface.h" | 6 | #include "interface.h" |
7 | 7 | ||
8 | #include <opie2/odebug.h> | 8 | #include <opie2/odebug.h> |
9 | #include <opie2/oprocess.h> | ||
10 | #include <opie2/owait.h> | ||
9 | 11 | ||
12 | #include <qpe/global.h> | ||
13 | |||
14 | #include <qapplication.h> | ||
10 | #include <qdatetime.h> | 15 | #include <qdatetime.h> |
11 | #include <qfile.h> | 16 | #include <qfile.h> |
12 | #include <qdir.h> | 17 | #include <qdir.h> |
13 | #include <qfileinfo.h> | 18 | #include <qfileinfo.h> |
14 | #include <qtextstream.h> | 19 | #include <qtextstream.h> |
15 | 20 | ||
16 | #define IFCONFIG "/sbin/ifconfig" | 21 | #define IFCONFIG "/sbin/ifconfig" |
22 | #define IF_UP "/sbin/ifup" | ||
23 | #define IF_DOWN "/sbin/ifdown" | ||
17 | #define DHCP_INFO_DIR "/etc/dhcpc" | 24 | #define DHCP_INFO_DIR "/etc/dhcpc" |
18 | 25 | ||
19 | #include <stdio.h> | 26 | #include <stdio.h> |
20 | #include <stdlib.h> | 27 | #include <stdlib.h> |
21 | 28 | ||
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"){ | 29 | 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"){ |
23 | refresh(); | 30 | refresh(); |
24 | } | 31 | } |
25 | 32 | ||
26 | /** | 33 | /** |
27 | * Set status | 34 | * Set status |
28 | * @param newStatus - the new status | 35 | * @param newStatus - the new status |
29 | * emit updateInterface | 36 | * emit updateInterface |
30 | */ | 37 | */ |
31 | void Interface::setStatus(bool newStatus){ | 38 | void Interface::setStatus(bool newStatus){ |
32 | if(status != newStatus){ | 39 | if(status != newStatus){ |
33 | status = newStatus; | 40 | status = newStatus; |
34 | refresh(); | 41 | refresh(); |
35 | } | 42 | } |
36 | }; | 43 | }; |
37 | 44 | ||
38 | /** | 45 | /** |
39 | * Set if attached or not (802.11 card pulled out for example) | 46 | * Set if attached or not (802.11 card pulled out for example) |
40 | * @param isAttached - if attached | 47 | * @param isAttached - if attached |
41 | * emit updateInterface | 48 | * emit updateInterface |
42 | */ | 49 | */ |
43 | void Interface::setAttached(bool isAttached){ | 50 | void Interface::setAttached(bool isAttached){ |
44 | attached = isAttached; | 51 | attached = isAttached; |
45 | emit(updateInterface(this)); | 52 | emit(updateInterface(this)); |
46 | }; | 53 | }; |
47 | 54 | ||
48 | /** | 55 | /** |
49 | * Set Hardware name | 56 | * Set Hardware name |
50 | * @param name - the new name | 57 | * @param name - the new name |
51 | * emit updateInterface | 58 | * emit updateInterface |
52 | */ | 59 | */ |
53 | void Interface::setHardwareName(const QString &name){ | 60 | void Interface::setHardwareName(const QString &name){ |
54 | hardwareName = name; | 61 | hardwareName = name; |
55 | emit(updateInterface(this)); | 62 | emit(updateInterface(this)); |
56 | }; | 63 | }; |
57 | 64 | ||
58 | /** | 65 | /** |
59 | * Set Module owner | 66 | * Set Module owner |
60 | * @param owner - the new owner | 67 | * @param owner - the new owner |
61 | * emit updateInterface | 68 | * emit updateInterface |
62 | */ | 69 | */ |
63 | void Interface::setModuleOwner(Module *owner){ | 70 | void Interface::setModuleOwner(Module *owner){ |
64 | moduleOwner = owner; | 71 | moduleOwner = owner; |
65 | emit(updateInterface(this)); | 72 | emit(updateInterface(this)); |
66 | }; | 73 | }; |
67 | 74 | ||
68 | 75 | ||
76 | bool Interface::callProcess( const QStringList& names ) { | ||
77 | Opie::Ui::OWait *owait = new Opie::Ui::OWait(); | ||
78 | Global::statusMessage( tr( "Restarting interface" ) ); | ||
79 | |||
80 | owait->show(); | ||
81 | qApp->processEvents(); | ||
82 | |||
83 | Opie::Core::OProcess restart; | ||
84 | restart << names; | ||
85 | if ( !restart.start(Opie::Core::OProcess::Block, | ||
86 | Opie::Core::OProcess::NoCommunication ) ) { | ||
87 | owarn << "unable to spawn command" << names << oendl; | ||
88 | return false; | ||
89 | } | ||
90 | owait->hide(); | ||
91 | delete owait; | ||
92 | |||
93 | if ( restart.normalExit() || restart.exitStatus() != 0 ) | ||
94 | return false; | ||
95 | |||
96 | return true; | ||
97 | } | ||
98 | |||
69 | /** | 99 | /** |
70 | * Try to start the interface. | 100 | * Try to start the interface. |
71 | */ | 101 | */ |
72 | void Interface::start(){ | 102 | void Interface::start(){ |
73 | // check to see if we are already running. | 103 | // check to see if we are already running. |
74 | if(true == status){ | 104 | if(true == status){ |
75 | emit (updateMessage("Unable to start interface,\n already started")); | 105 | emit (updateMessage("Unable to start interface,\n already started")); |
76 | return; | 106 | return; |
77 | } | 107 | } |
78 | 108 | ||
79 | int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); | 109 | /* prepare command and call it */ |
80 | // See if it was successful... | 110 | QStringList lst; |
81 | if(ret != 0){ | 111 | lst << IF_UP; |
112 | lst << name(); | ||
113 | if ( !callProcess(lst) ) { | ||
82 | emit (updateMessage("Starting interface failed")); | 114 | emit (updateMessage("Starting interface failed")); |
83 | return; | 115 | return; |
84 | } | 116 | } |
85 | 117 | ||
86 | status = true; | 118 | status = true; |
87 | refresh(); | 119 | refresh(); |
88 | emit (updateMessage("Start successful")); | 120 | emit (updateMessage("Start successful")); |
89 | } | 121 | } |
90 | 122 | ||
91 | /** | 123 | /** |
92 | * Try to stop the interface. | 124 | * Try to stop the interface. |
93 | */ | 125 | */ |
94 | void Interface::stop(){ | 126 | void Interface::stop(){ |
95 | // check to see if we are already stopped. | 127 | // check to see if we are already stopped. |
96 | if(false == status){ | 128 | if(false == status){ |
97 | emit (updateMessage("Unable to stop interface,\n already stopped")); | 129 | emit (updateMessage("Unable to stop interface,\n already stopped")); |
98 | return; | 130 | return; |
99 | } | 131 | } |
100 | 132 | ||
101 | int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); | 133 | QStringList lst; |
102 | if(ret != 0){ | 134 | lst << IF_DOWN; |
135 | lst << name(); | ||
136 | |||
137 | /* prepare command and call it */ | ||
138 | if( !callProcess( lst ) ){ | ||
103 | emit (updateMessage("Stopping interface failed")); | 139 | emit (updateMessage("Stopping interface failed")); |
104 | return; | 140 | return; |
105 | } | 141 | } |
106 | 142 | ||
107 | status = false; | 143 | status = false; |
108 | refresh(); | 144 | refresh(); |
109 | emit (updateMessage("Stop successful")); | 145 | emit (updateMessage("Stop successful")); |
110 | } | 146 | } |
111 | 147 | ||
112 | /** | 148 | /** |
113 | * Try to restart the interface. | 149 | * Try to restart the interface. |
114 | */ | 150 | */ |
115 | void Interface::restart(){ | 151 | void Interface::restart(){ |
116 | stop(); | 152 | stop(); |
117 | start(); | 153 | start(); |
118 | } | 154 | } |
119 | 155 | ||
120 | /** | 156 | /** |
121 | * Try to refresh the information about the interface. | 157 | * Try to refresh the information about the interface. |
122 | * First call ifconfig, then check the dhcp-info file | 158 | * First call ifconfig, then check the dhcp-info file |
123 | * @return bool true if successful. | 159 | * @return bool true if successful. |
124 | */ | 160 | */ |
125 | bool Interface::refresh(){ | 161 | bool Interface::refresh(){ |
126 | // See if we are up. | 162 | // See if we are up. |
127 | if(status == false){ | 163 | if(status == false){ |
128 | macAddress = ""; | 164 | macAddress = ""; |
129 | ip = "0.0.0.0"; | 165 | ip = "0.0.0.0"; |
130 | subnetMask = "0.0.0.0"; | 166 | subnetMask = "0.0.0.0"; |
131 | broadcast = ""; | 167 | broadcast = ""; |
132 | dhcp = false; | 168 | dhcp = false; |
133 | dhcpServerIp = ""; | 169 | dhcpServerIp = ""; |
134 | leaseObtained = ""; | 170 | leaseObtained = ""; |
135 | leaseExpires = ""; | 171 | leaseExpires = ""; |
136 | emit(updateInterface(this)); | 172 | emit(updateInterface(this)); |
137 | return true; | 173 | return true; |
138 | } | 174 | } |
139 | 175 | ||
140 | QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name()); | 176 | QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name()); |
141 | int ret = system(QString("LANG=C %1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1()); | 177 | int ret = system(QString("LANG=C %1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1()); |
142 | if(ret != 0){ | 178 | if(ret != 0){ |
143 | odebug << QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1() << oendl; | 179 | odebug << QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1() << oendl; |
144 | return false; | 180 | return false; |
145 | } | 181 | } |
146 | 182 | ||
147 | QFile file(fileName); | 183 | QFile file(fileName); |
148 | if (!file.open(IO_ReadOnly)){ | 184 | if (!file.open(IO_ReadOnly)){ |
149 | odebug << QString("Interface: Can't open file: %1").arg(fileName).latin1() << oendl; | 185 | odebug << QString("Interface: Can't open file: %1").arg(fileName).latin1() << oendl; |
150 | return false; | 186 | return false; |
151 | } | 187 | } |
152 | 188 | ||
153 | // Set to the defaults | 189 | // Set to the defaults |
154 | macAddress = ""; | 190 | macAddress = ""; |
155 | ip = "0.0.0.0"; | 191 | ip = "0.0.0.0"; |
156 | subnetMask = "0.0.0.0"; | 192 | subnetMask = "0.0.0.0"; |
157 | broadcast = ""; | 193 | broadcast = ""; |
158 | 194 | ||
159 | QTextStream stream( &file ); | 195 | QTextStream stream( &file ); |
160 | QString line; | 196 | QString line; |
161 | while ( !stream.eof() ) { | 197 | while ( !stream.eof() ) { |
162 | line = stream.readLine(); | 198 | line = stream.readLine(); |
163 | if(line.contains("HWaddr")){ | 199 | if(line.contains("HWaddr")){ |
164 | int mac = line.find("HWaddr"); | 200 | int mac = line.find("HWaddr"); |
165 | macAddress = line.mid(mac+7, line.length()); | 201 | macAddress = line.mid(mac+7, line.length()); |
166 | } | 202 | } |
167 | if(line.contains("inet addr")){ | 203 | if(line.contains("inet addr")){ |
168 | int ipl = line.find("inet addr"); | 204 | int ipl = line.find("inet addr"); |
169 | int space = line.find(" ", ipl+10); | 205 | int space = line.find(" ", ipl+10); |
170 | ip = line.mid(ipl+10, space-ipl-10); | 206 | ip = line.mid(ipl+10, space-ipl-10); |
171 | } | 207 | } |
172 | if(line.contains("Mask")){ | 208 | if(line.contains("Mask")){ |
173 | int mask = line.find("Mask"); | 209 | int mask = line.find("Mask"); |
174 | subnetMask = line.mid(mask+5, line.length()); | 210 | subnetMask = line.mid(mask+5, line.length()); |
175 | } | 211 | } |
176 | if(line.contains("Bcast")){ | 212 | if(line.contains("Bcast")){ |
177 | int mask = line.find("Bcast"); | 213 | int mask = line.find("Bcast"); |
178 | int space = line.find(" ", mask+6); | 214 | int space = line.find(" ", mask+6); |
179 | broadcast = line.mid(mask+6, space-mask-6); | 215 | broadcast = line.mid(mask+6, space-mask-6); |
180 | } | 216 | } |
181 | } | 217 | } |
182 | file.close(); | 218 | file.close(); |
183 | QFile::remove(fileName); | 219 | QFile::remove(fileName); |
184 | 220 | ||
185 | // DHCP TESTING | 221 | // DHCP TESTING |
186 | // reset DHCP info | 222 | // reset DHCP info |
187 | dhcpServerIp = ""; | 223 | dhcpServerIp = ""; |
188 | leaseObtained = ""; | 224 | leaseObtained = ""; |
189 | leaseExpires = ""; | 225 | leaseExpires = ""; |
190 | dhcp = false; | 226 | dhcp = false; |
191 | 227 | ||
192 | QString dhcpDirectory(DHCP_INFO_DIR); | 228 | QString dhcpDirectory(DHCP_INFO_DIR); |
193 | QDir d(dhcpDirectory); | 229 | QDir d(dhcpDirectory); |
194 | if(!d.exists(dhcpDirectory)) | 230 | if(!d.exists(dhcpDirectory)) |
195 | dhcpDirectory = "/var/run"; | 231 | dhcpDirectory = "/var/run"; |
196 | 232 | ||
197 | // See if we have | 233 | // See if we have |
198 | QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); | 234 | QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); |
199 | // If there is no DHCP information then exit now with no errors. | 235 | // If there is no DHCP information then exit now with no errors. |
200 | if(!QFile::exists(dhcpFile)){ | 236 | if(!QFile::exists(dhcpFile)){ |
201 | emit(updateInterface(this)); | 237 | emit(updateInterface(this)); |
202 | return true; | 238 | return true; |
203 | } | 239 | } |
204 | 240 | ||
205 | file.setName(dhcpFile); | 241 | file.setName(dhcpFile); |
206 | if (!file.open(IO_ReadOnly)){ | 242 | if (!file.open(IO_ReadOnly)){ |
207 | odebug << QString("Interface: Can't open file: %1").arg(dhcpFile).latin1() << oendl; | 243 | odebug << QString("Interface: Can't open file: %1").arg(dhcpFile).latin1() << oendl; |
208 | return false; | 244 | return false; |
209 | } | 245 | } |
210 | 246 | ||
211 | // leaseTime and renewalTime and used if pid and deamon exe can be accessed. | 247 | // leaseTime and renewalTime and used if pid and deamon exe can be accessed. |
212 | int leaseTime = 0; | 248 | int leaseTime = 0; |
213 | int renewalTime = 0; | 249 | int renewalTime = 0; |
214 | 250 | ||
215 | stream.setDevice( &file ); | 251 | stream.setDevice( &file ); |
216 | while ( !stream.eof() ) { | 252 | while ( !stream.eof() ) { |
217 | line = stream.readLine(); | 253 | line = stream.readLine(); |
218 | if(line.contains("DHCPSIADDR=")) | 254 | if(line.contains("DHCPSIADDR=")) |
219 | dhcpServerIp = line.mid(11, line.length()); | 255 | dhcpServerIp = line.mid(11, line.length()); |
220 | if(line.contains("LEASETIME=")) | 256 | if(line.contains("LEASETIME=")) |
221 | leaseTime = line.mid(10, line.length()).toInt(); | 257 | leaseTime = line.mid(10, line.length()).toInt(); |
222 | if(line.contains("RENEWALTIME=")) | 258 | if(line.contains("RENEWALTIME=")) |
223 | renewalTime = line.mid(12, line.length()).toInt(); | 259 | renewalTime = line.mid(12, line.length()).toInt(); |
224 | } | 260 | } |
225 | file.close(); | 261 | file.close(); |
226 | //odebug << QString("Interface: leaseTime: %1").arg(leaseTime).latin1() << oendl; | 262 | //odebug << QString("Interface: leaseTime: %1").arg(leaseTime).latin1() << oendl; |
227 | //odebug << QString("Interface: renewalTime: %1").arg(renewalTime).latin1() << oendl; | 263 | //odebug << QString("Interface: renewalTime: %1").arg(renewalTime).latin1() << oendl; |
228 | 264 | ||
229 | // Get the pid of the deamond | 265 | // Get the pid of the deamond |
230 | dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name())); | 266 | dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name())); |
231 | file.setName(dhcpFile); | 267 | file.setName(dhcpFile); |
232 | if (!file.open(IO_ReadOnly)){ | 268 | if (!file.open(IO_ReadOnly)){ |
233 | odebug << QString("Interface: Can't open file: %1").arg(dhcpFile).latin1() << oendl; | 269 | odebug << QString("Interface: Can't open file: %1").arg(dhcpFile).latin1() << oendl; |
234 | return false; | 270 | return false; |
235 | } | 271 | } |
236 | 272 | ||
237 | int pid = -1; | 273 | int pid = -1; |
238 | stream.setDevice( &file ); | 274 | stream.setDevice( &file ); |
239 | while ( !stream.eof() ) { | 275 | while ( !stream.eof() ) { |
240 | line = stream.readLine(); | 276 | line = stream.readLine(); |
241 | pid = line.toInt(); | 277 | pid = line.toInt(); |
242 | } | 278 | } |
243 | file.close(); | 279 | file.close(); |
244 | 280 | ||
245 | if( pid == -1){ | 281 | if( pid == -1){ |
246 | odebug << "Interface: Could not get pid of dhcpc deamon." << oendl; | 282 | odebug << "Interface: Could not get pid of dhcpc deamon." << oendl; |
247 | return false; | 283 | return false; |
248 | } | 284 | } |
249 | 285 | ||
250 | // Get the start running time of the deamon | 286 | // Get the start running time of the deamon |
251 | fileName = (QString("/proc/%1/stat").arg(pid)); | 287 | fileName = (QString("/proc/%1/stat").arg(pid)); |
252 | file.setName(fileName); | 288 | file.setName(fileName); |
253 | stream.setDevice( &file ); | 289 | stream.setDevice( &file ); |
254 | if (!file.open(IO_ReadOnly)){ | 290 | if (!file.open(IO_ReadOnly)){ |
255 | odebug << QString("Interface: Can't open file: %1").arg(fileName).latin1() << oendl; | 291 | odebug << QString("Interface: Can't open file: %1").arg(fileName).latin1() << oendl; |
256 | return false; | 292 | return false; |
257 | } | 293 | } |
258 | while ( !stream.eof() ) { | 294 | while ( !stream.eof() ) { |
259 | line = stream.readLine(); | 295 | line = stream.readLine(); |
260 | } | 296 | } |
261 | file.close(); | 297 | file.close(); |
262 | long time = 0; | 298 | long time = 0; |
263 | // Grab the start time | 299 | // Grab the start time |
264 | // pid com state ppid pgrp session tty_nr tpgid flags | 300 | // pid com state ppid pgrp session tty_nr tpgid flags |
265 | sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " | 301 | sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " |
266 | // minflt cminflt majflt cmajflt utime stime cutime cstime priority | 302 | // minflt cminflt majflt cmajflt utime stime cutime cstime priority |
267 | "%*u %*u %*u %*u %*u %*u %*d %*d %*d " | 303 | "%*u %*u %*u %*u %*u %*u %*d %*d %*d " |
268 | // nice 0 itrealvalue starttime | 304 | // nice 0 itrealvalue starttime |
269 | "%*d %*d %*d %lu", (long*) &time); | 305 | "%*d %*d %*d %lu", (long*) &time); |
270 | time = time/100; | 306 | time = time/100; |
271 | 307 | ||
272 | QDateTime datetime(QDateTime::currentDateTime()); | 308 | QDateTime datetime(QDateTime::currentDateTime()); |
273 | 309 | ||
274 | // Get the uptime of the computer. | 310 | // Get the uptime of the computer. |
275 | QFile f("/proc/uptime"); | 311 | QFile f("/proc/uptime"); |
276 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 312 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
277 | QTextStream t( &f ); // use a text stream | 313 | QTextStream t( &f ); // use a text stream |
278 | int sec = 0; | 314 | int sec = 0; |
279 | t >> sec; | 315 | t >> sec; |
280 | datetime = datetime.addSecs((-1*sec)); | 316 | datetime = datetime.addSecs((-1*sec)); |
281 | f.close(); | 317 | f.close(); |
282 | } | 318 | } |
283 | else{ | 319 | else{ |
284 | odebug << "Interface: Can't open /proc/uptime to retrive uptime." << oendl; | 320 | odebug << "Interface: Can't open /proc/uptime to retrive uptime." << oendl; |
285 | return false; | 321 | return false; |
286 | } | 322 | } |
287 | 323 | ||
288 | datetime = datetime.addSecs(time); | 324 | datetime = datetime.addSecs(time); |
289 | //odebug << QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1() << oendl; | 325 | //odebug << QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1() << oendl; |
290 | 326 | ||
291 | // Calculate the start and renew times | 327 | // Calculate the start and renew times |
292 | leaseObtained= datetime.toString(); | 328 | leaseObtained= datetime.toString(); |
293 | 329 | ||
294 | // Calculate the start and renew times | 330 | // Calculate the start and renew times |
diff --git a/noncore/settings/networksettings/interfaces/interface.h b/noncore/settings/networksettings/interfaces/interface.h index 83ab088..e9ab0c2 100644 --- a/noncore/settings/networksettings/interfaces/interface.h +++ b/noncore/settings/networksettings/interfaces/interface.h | |||
@@ -1,80 +1,81 @@ | |||
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 | #include <qobject.h> |
6 | 6 | ||
7 | class Module; | 7 | class Module; |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * A Interface represents a physical device. You can | 10 | * A Interface represents a physical device. You can |
11 | * inherit it and create also virtual devices. Like saved | 11 | * inherit it and create also virtual devices. Like saved |
12 | * ppp dial ups or vpn. Interface is used for representing | 12 | * ppp dial ups or vpn. Interface is used for representing |
13 | * your interface to the User and its actions. | 13 | * your interface to the User and its actions. |
14 | * | 14 | * |
15 | */ | 15 | */ |
16 | class Interface : public QObject{ | 16 | class Interface : public QObject{ |
17 | Q_OBJECT | 17 | Q_OBJECT |
18 | 18 | ||
19 | signals: | 19 | signals: |
20 | void updateInterface(Interface *i); | 20 | void updateInterface(Interface *i); |
21 | void updateMessage(const QString &message); | 21 | void updateMessage(const QString &message); |
22 | 22 | ||
23 | public: | 23 | public: |
24 | Interface(QObject * parent=0, const char * name= "unknown", bool status = false); | 24 | Interface(QObject * parent=0, const char * name= "unknown", bool status = false); |
25 | 25 | ||
26 | QString getInterfaceName() const { QString n(this->name()); return n; }; | 26 | QString getInterfaceName() const { QString n(this->name()); return n; }; |
27 | void setInterfaceName( const QString &n ) { this->setName(n); }; | 27 | void setInterfaceName( const QString &n ) { this->setName(n); }; |
28 | 28 | ||
29 | bool getStatus() const { return status; }; | 29 | bool getStatus() const { return status; }; |
30 | void setStatus(bool newStatus); | 30 | void setStatus(bool newStatus); |
31 | 31 | ||
32 | bool isAttached() const { return attached; }; | 32 | bool isAttached() const { return attached; }; |
33 | void setAttached(bool isAttached=false); | 33 | void setAttached(bool isAttached=false); |
34 | 34 | ||
35 | QString getHardwareName() const { return hardwareName; }; | 35 | QString getHardwareName() const { return hardwareName; }; |
36 | void setHardwareName(const QString &name="Unknown"); | 36 | void setHardwareName(const QString &name="Unknown"); |
37 | 37 | ||
38 | Module* getModuleOwner() const { return moduleOwner; }; | 38 | Module* getModuleOwner() const { return moduleOwner; }; |
39 | void setModuleOwner(Module *owner=NULL); | 39 | void setModuleOwner(Module *owner=NULL); |
40 | 40 | ||
41 | // inet information. | 41 | // inet information. |
42 | QString getMacAddress() const { return macAddress; }; | 42 | QString getMacAddress() const { return macAddress; }; |
43 | QString getIp() const { return ip; }; | 43 | QString getIp() const { return ip; }; |
44 | QString getSubnetMask() const { return subnetMask; }; | 44 | QString getSubnetMask() const { return subnetMask; }; |
45 | QString getBroadcast() const { return broadcast; }; | 45 | QString getBroadcast() const { return broadcast; }; |
46 | bool isDhcp() const { return dhcp; }; | 46 | bool isDhcp() const { return dhcp; }; |
47 | QString getDhcpServerIp() const { return dhcpServerIp; }; | 47 | QString getDhcpServerIp() const { return dhcpServerIp; }; |
48 | QString getLeaseObtained() const { return leaseObtained; }; | 48 | QString getLeaseObtained() const { return leaseObtained; }; |
49 | QString getLeaseExpires() const { return leaseExpires; }; | 49 | QString getLeaseExpires() const { return leaseExpires; }; |
50 | 50 | ||
51 | public slots: | 51 | public slots: |
52 | virtual bool refresh(); | 52 | virtual bool refresh(); |
53 | virtual void start(); | 53 | virtual void start(); |
54 | virtual void stop(); | 54 | virtual void stop(); |
55 | virtual void restart(); | 55 | virtual void restart(); |
56 | 56 | ||
57 | protected: | 57 | protected: |
58 | bool callProcess( const QStringList& name ); | ||
58 | // Interface information | 59 | // Interface information |
59 | QString hardwareName; | 60 | QString hardwareName; |
60 | Module *moduleOwner; | 61 | Module *moduleOwner; |
61 | bool status; | 62 | bool status; |
62 | bool attached; | 63 | bool attached; |
63 | 64 | ||
64 | // Network information | 65 | // Network information |
65 | bool dhcp; | 66 | bool dhcp; |
66 | QString dhcpServerIp; | 67 | QString dhcpServerIp; |
67 | QString leaseObtained; | 68 | QString leaseObtained; |
68 | QString leaseExpires; | 69 | QString leaseExpires; |
69 | 70 | ||
70 | QString macAddress; | 71 | QString macAddress; |
71 | QString ip; | 72 | QString ip; |
72 | QString broadcast; | 73 | QString broadcast; |
73 | QString subnetMask; | 74 | QString subnetMask; |
74 | 75 | ||
75 | }; | 76 | }; |
76 | 77 | ||
77 | #endif | 78 | #endif |
78 | 79 | ||
79 | // interface.h | 80 | // interface.h |
80 | 81 | ||