Diffstat (limited to 'noncore/settings/networksettings2/networksettings2') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/networksettings2/system.cpp | 53 | ||||
-rw-r--r-- | noncore/settings/networksettings2/networksettings2/system.h | 7 |
2 files changed, 36 insertions, 24 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp index 141484c..9512579 100644 --- a/noncore/settings/networksettings2/networksettings2/system.cpp +++ b/noncore/settings/networksettings2/networksettings2/system.cpp @@ -44,7 +44,6 @@ static char Dig2Hex[] = { #define LN(x) Dig2Hex[((x)&0x0f)] System::System( void ) : QObject(), ProbedInterfaces() { - probeInterfaces(); } System::~System( void ) { @@ -52,7 +51,14 @@ System::~System( void ) { delete ProcDevNet; } -int System::runAsRoot( QStringList & S ) { +QDict<InterfaceInfo> & System::interfaces( void ) { + if( ProbedInterfaces.count() == 0 ) { + probeInterfaces(); + } + return ProbedInterfaces; +} + +int System::runAsRoot( QStringList & S, MyProcess * Prc ) { char * usr = getenv("USER"); if( S.count() == 0 ) { @@ -69,32 +75,39 @@ int System::runAsRoot( QStringList & S ) { << S.join( " ") << oendl; } else { - MyProcess * P = new MyProcess(); - emit processEvent( tr("Command : ") + S.join( " " ) ); + MyProcess * P; - P->process() << S; - - connect( P, - SIGNAL( stdoutLine( const QString & ) ), - this, - SIGNAL( stdoutLine( const QString & ) ) ); - - connect( P, - SIGNAL( stderrLine( const QString & ) ), - this, - SIGNAL( stderrLine( const QString & ) ) ); + if( Prc ) { + P = Prc; + } else { + P = new MyProcess(); + emit processEvent( tr("Command : ") + S.join( " " ) ); + + connect( P, + SIGNAL( stdoutLine( const QString & ) ), + this, + SIGNAL( stdoutLine( const QString & ) ) ); + + connect( P, + SIGNAL( stderrLine( const QString & ) ), + this, + SIGNAL( stderrLine( const QString & ) ) ); + + connect( P, + SIGNAL(processExited(MyProcess*) ), + this, SLOT + (SLOT_ProcessExited(MyProcess*) ) ); + } - connect( P, - SIGNAL(processExited(MyProcess*) ), - this, SLOT - (SLOT_ProcessExited(MyProcess*) ) ); + P->process() << S; Log(("Executing %s\n", S.join( " " ).latin1() )); if( ! P->process().start( OProcess::DontCare, OProcess::AllOutput ) ) { owarn << "Error starting " << S << oendl; - delete P; + if( ! Prc ) + delete P; // error starting app return 1; } diff --git a/noncore/settings/networksettings2/networksettings2/system.h b/noncore/settings/networksettings2/networksettings2/system.h index e67d695..f7a7274 100644 --- a/noncore/settings/networksettings2/networksettings2/system.h +++ b/noncore/settings/networksettings2/networksettings2/system.h @@ -96,13 +96,12 @@ public : System( void ); ~System( void ); - QDict<InterfaceInfo> & interfaces( void ) - { return ProbedInterfaces; } + QDict<InterfaceInfo> & interfaces( void ); InterfaceInfo * interface( const QString& N ) - { return ProbedInterfaces[N]; } + { return interfaces()[N]; } // exec command as root - int runAsRoot( QStringList & S ); + int runAsRoot( QStringList & S, MyProcess * Prc = 0 ); // exec command as user int execAsUser( QStringList & Cmd ); |