Diffstat (limited to 'noncore/settings/networksettings/interface.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/interface.cpp | 77 |
1 files changed, 61 insertions, 16 deletions
diff --git a/noncore/settings/networksettings/interface.cpp b/noncore/settings/networksettings/interface.cpp index 1f32093..1e01da4 100644 --- a/noncore/settings/networksettings/interface.cpp +++ b/noncore/settings/networksettings/interface.cpp @@ -12,49 +12,90 @@ #include <stdlib.h> -Interface::Interface(QString name, bool newSatus): status(newSatus), attached(false), interfaceName(name), hardareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ +Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ refresh(); } /** + * Set status + * @param newStatus - the new status + * emit updateInterface + */ +void Interface::setStatus(bool newStatus){ + if(status != newStatus){ + status = newStatus; + refresh(); + } +}; + +/** + * Set if attached or not (802.11 card pulled out for example) + * @param isAttached - if attached + * emit updateInterface + */ +void Interface::setAttached(bool isAttached){ + attached = isAttached; + emit(updateInterface(this)); +}; + +/** + * Set Hardware name + * @param name - the new name + * emit updateInterface + */ +void Interface::setHardwareName(QString name){ + hardareName = 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. - * @return bool true if successfull. */ -bool Interface::start(){ +void Interface::start(){ // check to see if we are already running. - if(status) - return false; + if(true == status) + return; int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(interfaceName).latin1()); + // See if it was successfull... if(ret != 0) - return false; + return; status = true; refresh(); - return true; } /** * Try to stop the interface. - * @return bool true if successfull. */ -bool Interface::stop(){ +void Interface::stop(){ // check to see if we are already stopped. - if(status == false) - return false; + if(false == status) + return; int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(interfaceName).latin1()); if(ret != 0) - return false; + return; status = true; refresh(); - return true; } + /** * Try to restart the interface. - * @return bool true if successfull. */ -bool Interface::restart(){ - return (stop() && start()); +void Interface::restart(){ + stop(); + start(); } @@ -75,4 +116,5 @@ bool Interface::refresh(){ leaseObtained = ""; leaseExpires = ""; + emit(updateInterface(this)); return true; } @@ -139,4 +181,5 @@ bool Interface::refresh(){ // If there is no DHCP information then exit now with no errors. if(!QFile::exists(dhcpFile)){ + emit(updateInterface(this)); return true; } @@ -236,4 +279,6 @@ bool Interface::refresh(){ dhcp = true; + + emit(updateInterface(this)); return true; } |