From fd530016abd98bb6164c1ac962de0ca11d82e407 Mon Sep 17 00:00:00 2001 From: zecke Date: Mon, 20 Dec 2004 22:29:08 +0000 Subject: Restore Changes: Call ifup/ifdown INTERFACE instead of ifconfig as requested by Chris Larson --- (limited to 'noncore') 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 @@ -6,7 +6,12 @@ #include "interface.h" #include +#include +#include +#include + +#include #include #include #include @@ -14,6 +19,8 @@ #include #define IFCONFIG "/sbin/ifconfig" +#define IF_UP "/sbin/ifup" +#define IF_DOWN "/sbin/ifdown" #define DHCP_INFO_DIR "/etc/dhcpc" #include @@ -66,6 +73,29 @@ void Interface::setModuleOwner(Module *owner){ }; +bool Interface::callProcess( const QStringList& names ) { + Opie::Ui::OWait *owait = new Opie::Ui::OWait(); + Global::statusMessage( tr( "Restarting interface" ) ); + + owait->show(); + qApp->processEvents(); + + Opie::Core::OProcess restart; + restart << names; + if ( !restart.start(Opie::Core::OProcess::Block, + Opie::Core::OProcess::NoCommunication ) ) { + owarn << "unable to spawn command" << names << oendl; + return false; + } + owait->hide(); + delete owait; + + if ( restart.normalExit() || restart.exitStatus() != 0 ) + return false; + + return true; +} + /** * Try to start the interface. */ @@ -76,9 +106,11 @@ void Interface::start(){ return; } - int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); - // See if it was successful... - if(ret != 0){ + /* prepare command and call it */ + QStringList lst; + lst << IF_UP; + lst << name(); + if ( !callProcess(lst) ) { emit (updateMessage("Starting interface failed")); return; } @@ -98,8 +130,12 @@ void Interface::stop(){ return; } - int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); - if(ret != 0){ + QStringList lst; + lst << IF_DOWN; + lst << name(); + + /* prepare command and call it */ + if( !callProcess( lst ) ){ emit (updateMessage("Stopping interface failed")); return; } 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 @@ -55,6 +55,7 @@ public: virtual void restart(); protected: + bool callProcess( const QStringList& name ); // Interface information QString hardwareName; Module *moduleOwner; -- cgit v0.9.0.2