summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/interfaces/interface.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/interfaces/interface.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interface.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/noncore/settings/networksettings/interfaces/interface.cpp b/noncore/settings/networksettings/interfaces/interface.cpp
index 929b3a1..e4f405e 100644
--- a/noncore/settings/networksettings/interfaces/interface.cpp
+++ b/noncore/settings/networksettings/interfaces/interface.cpp
@@ -42,74 +42,84 @@ void Interface::setAttached(bool isAttached){
42 * @param name - the new name 42 * @param name - the new name
43 * emit updateInterface 43 * emit updateInterface
44 */ 44 */
45void Interface::setHardwareName(QString name){ 45void Interface::setHardwareName(QString name){
46 hardwareName = name; 46 hardwareName = name;
47 emit(updateInterface(this)); 47 emit(updateInterface(this));
48}; 48};
49 49
50/** 50/**
51 * Set Module owner 51 * Set Module owner
52 * @param owner - the new owner 52 * @param owner - the new owner
53 * emit updateInterface 53 * emit updateInterface
54 */ 54 */
55void Interface::setModuleOwner(Module *owner){ 55void Interface::setModuleOwner(Module *owner){
56 moduleOwner = owner; 56 moduleOwner = owner;
57 emit(updateInterface(this)); 57 emit(updateInterface(this));
58}; 58};
59 59
60 60
61/** 61/**
62 * Try to start the interface. 62 * Try to start the interface.
63 */ 63 */
64void Interface::start(){ 64void Interface::start(){
65 // check to see if we are already running. 65 // check to see if we are already running.
66 if(true == status) 66 if(true == status){
67 emit (updateMessage("Unable to start interface,\n already started"));
67 return; 68 return;
68 69 }
70
69 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); 71 int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1());
70 // See if it was successfull... 72 // See if it was successfull...
71 if(ret != 0) 73 if(ret != 0){
74 emit (updateMessage("Starting interface failed."));
72 return; 75 return;
73 76 }
77
74 status = true; 78 status = true;
75 refresh(); 79 refresh();
80 emit (updateMessage("Start successfull"));
76} 81}
77 82
78/** 83/**
79 * Try to stop the interface. 84 * Try to stop the interface.
80 */ 85 */
81void Interface::stop(){ 86void Interface::stop(){
82 // check to see if we are already stopped. 87 // check to see if we are already stopped.
83 if(false == status) 88 if(false == status){
89 emit (updateMessage("Unable to stop interface,\n already stopped"));
84 return; 90 return;
91 }
85 92
86 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); 93 int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1());
87 if(ret != 0) 94 if(ret != 0){
95 emit (updateMessage("Stopping interface failed."));
88 return; 96 return;
97 }
89 98
90 status = true; 99 status = false;
91 refresh(); 100 refresh();
101 emit (updateMessage("Stop successfull"));
92} 102}
93 103
94/** 104/**
95 * Try to restart the interface. 105 * Try to restart the interface.
96 */ 106 */
97void Interface::restart(){ 107void Interface::restart(){
98 stop(); 108 stop();
99 start(); 109 start();
100} 110}
101 111
102/** 112/**
103 * Try to refresh the information about the interface. 113 * Try to refresh the information about the interface.
104 * First call ifconfig, then check the dhcp-info file 114 * First call ifconfig, then check the dhcp-info file
105 * @return bool true if successfull. 115 * @return bool true if successfull.
106 */ 116 */
107bool Interface::refresh(){ 117bool Interface::refresh(){
108 // See if we are up. 118 // See if we are up.
109 if(status == false){ 119 if(status == false){
110 macAddress = ""; 120 macAddress = "";
111 ip = "0.0.0.0"; 121 ip = "0.0.0.0";
112 subnetMask = "0.0.0.0"; 122 subnetMask = "0.0.0.0";
113 broadcast = ""; 123 broadcast = "";
114 dhcp = false; 124 dhcp = false;
115 dhcpServerIp = ""; 125 dhcpServerIp = "";