summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/networksettings2/system.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings2/networksettings2/system.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.cpp53
1 files changed, 33 insertions, 20 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
@@ -41,21 +41,27 @@ static char Dig2Hex[] = {
// get HIGH nibble of byte
#define HN(x) Dig2Hex[(((x)&0xf0)>>4)]
// get LOW nibble of byte
#define LN(x) Dig2Hex[((x)&0x0f)]
System::System( void ) : QObject(), ProbedInterfaces() {
- probeInterfaces();
}
System::~System( void ) {
if( ProcDevNet )
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 ) {
// loophole to start shell
return 8888;
}
@@ -66,38 +72,45 @@ int System::runAsRoot( QStringList & S ) {
if( getenv( "NS2TESTMODE" ) ) {
owarn << "TESTMODE !!! execute "
<< 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;
}
owarn << "Started " << S << oendl;
}