summaryrefslogtreecommitdiff
authorbenmeyer <benmeyer>2003-01-13 19:06:10 (UTC)
committer benmeyer <benmeyer>2003-01-13 19:06:10 (UTC)
commit4cd81644fb2ac8cd91e4dd79c2274656f5bfe81a (patch) (unidiff)
treeb6bf6c6dabb627d7a52691a25de50a701c088c7c
parent90706ff3edbf0c30856bb9786e69a6d3a0e0867a (diff)
downloadopie-4cd81644fb2ac8cd91e4dd79c2274656f5bfe81a.zip
opie-4cd81644fb2ac8cd91e4dd79c2274656f5bfe81a.tar.gz
opie-4cd81644fb2ac8cd91e4dd79c2274656f5bfe81a.tar.bz2
test new header
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interface.cpp6
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,128 +1,134 @@
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
14Interface::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"){ 20Interface::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 */
23void Interface::setStatus(bool newStatus){ 29void 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 */
35void Interface::setAttached(bool isAttached){ 41void 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 */
45void Interface::setHardwareName(const QString &name){ 51void 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 */
55void Interface::setModuleOwner(Module *owner){ 61void 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 */
64void Interface::start(){ 70void 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 */
86void Interface::stop(){ 92void 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;
97 } 103 }
98 104
99 status = false; 105 status = false;
100 refresh(); 106 refresh();
101 emit (updateMessage("Stop successfull")); 107 emit (updateMessage("Stop successfull"));
102} 108}
103 109
104/** 110/**
105 * Try to restart the interface. 111 * Try to restart the interface.
106 */ 112 */
107void Interface::restart(){ 113void Interface::restart(){
108 stop(); 114 stop();
109 start(); 115 start();
110} 116}
111 117
112/** 118/**
113 * Try to refresh the information about the interface. 119 * Try to refresh the information about the interface.
114 * First call ifconfig, then check the dhcp-info file 120 * First call ifconfig, then check the dhcp-info file
115 * @return bool true if successfull. 121 * @return bool true if successfull.
116 */ 122 */
117bool Interface::refresh(){ 123bool Interface::refresh(){
118 // See if we are up. 124 // See if we are up.
119 if(status == false){ 125 if(status == false){
120 macAddress = ""; 126 macAddress = "";
121 ip = "0.0.0.0"; 127 ip = "0.0.0.0";
122 subnetMask = "0.0.0.0"; 128 subnetMask = "0.0.0.0";
123 broadcast = ""; 129 broadcast = "";
124 dhcp = false; 130 dhcp = false;
125 dhcpServerIp = ""; 131 dhcpServerIp = "";
126 leaseObtained = ""; 132 leaseObtained = "";
127 leaseExpires = ""; 133 leaseExpires = "";
128 emit(updateInterface(this)); 134 emit(updateInterface(this));