Diffstat (limited to 'noncore/net/networksetup/interfaces/interface.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/networksetup/interfaces/interface.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/noncore/net/networksetup/interfaces/interface.cpp b/noncore/net/networksetup/interfaces/interface.cpp index 929b3a1..e4f405e 100644 --- a/noncore/net/networksetup/interfaces/interface.cpp +++ b/noncore/net/networksetup/interfaces/interface.cpp @@ -42,74 +42,84 @@ void Interface::setAttached(bool isAttached){ * @param name - the new name * emit updateInterface */ void Interface::setHardwareName(QString name){ hardwareName = name; emit(updateInterface(this)); }; /** * Set Module owner * @param owner - the new owner * emit updateInterface */ void Interface::setModuleOwner(Module *owner){ moduleOwner = owner; emit(updateInterface(this)); }; /** * Try to start the interface. */ void Interface::start(){ // check to see if we are already running. - if(true == status) + if(true == status){ + emit (updateMessage("Unable to start interface,\n already started")); return; - + } + int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); // See if it was successfull... - if(ret != 0) + if(ret != 0){ + emit (updateMessage("Starting interface failed.")); return; - + } + status = true; refresh(); + emit (updateMessage("Start successfull")); } /** * Try to stop the interface. */ void Interface::stop(){ // check to see if we are already stopped. - if(false == status) + if(false == status){ + emit (updateMessage("Unable to stop interface,\n already stopped")); return; + } int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); - if(ret != 0) + if(ret != 0){ + emit (updateMessage("Stopping interface failed.")); return; + } - status = true; + status = false; refresh(); + emit (updateMessage("Stop successfull")); } /** * Try to restart the interface. */ void Interface::restart(){ stop(); start(); } /** * Try to refresh the information about the interface. * First call ifconfig, then check the dhcp-info file * @return bool true if successfull. */ bool Interface::refresh(){ // See if we are up. if(status == false){ macAddress = ""; ip = "0.0.0.0"; subnetMask = "0.0.0.0"; broadcast = ""; dhcp = false; dhcpServerIp = ""; |