Diffstat (limited to 'noncore/settings/networksettings2/networksettings2/resources.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/networksettings2/resources.cpp | 102 |
1 files changed, 88 insertions, 14 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp index c95ac7f..71e84cd 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.cpp +++ b/noncore/settings/networksettings2/networksettings2/resources.cpp @@ -23,6 +23,8 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), _NSResources = this; + detectCurrentUser(); + // load available netnodes findAvailableNetNodes(QPEApplication::qpeDir() + PLUGINDIR ); @@ -80,13 +82,23 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), // get access to the system TheSystem = new System(); - detectCurrentUser(); } TheNSResources::~TheNSResources( void ) { delete TheSystem; } +void TheNSResources::busy( bool B ) { +/* + if( B ) { + ShowWait->show(); + qApp->process + } else { + ShowWait->hide(); + } +*/ +} + /** * Load all modules that are found in the path * @param path a directory that is scaned for any plugins that can be loaded @@ -94,6 +106,7 @@ TheNSResources::~TheNSResources( void ) { */ void TheNSResources::findAvailableNetNodes(const QString &path){ + Log(("Locate plugins in %s\n", path.latin1() )); QDir d(path); if(!d.exists()) return; @@ -127,6 +140,27 @@ void TheNSResources::findAvailableNetNodes(const QString &path){ } } +// used to find unique connection number +int TheNSResources::assignConnectionNumber( void ) { + bool found = 1; + for( int trial = 0; ; trial ++ ) { + found = 1; + for( QDictIterator<NodeCollection> it(ConnectionsMap); + it.current(); + ++it ) { + if( it.current()->number() == trial ) { + found = 0; + break; + } + } + + if( found ) { + Log(("Assign profile number %d\n", trial )); + return trial; + } + } +} + /** * Attempt to load a function and resolve a function. * @param pluginFileName - the name of the file in which to attempt to load @@ -167,7 +201,6 @@ bool TheNSResources::loadNetNode( NN->NodeCountInLib = PNN.count(); // store mapping - printf( "Store %s\n", NN->NetNode->name() ); AllNodeTypes.insert( NN->NetNode->name(), NN ); } @@ -175,10 +208,12 @@ bool TheNSResources::loadNetNode( } QPixmap TheNSResources::getPixmap( const QString & QS ) { + QPixmap P; QString S("networksettings2/"); S += QS; - fprintf( stderr, "%s\n", S.latin1() ); - return Resource::loadPixmap( S ); + Log(("%s\n", S.latin1() )); + P = Resource::loadPixmap( S ); + return ( P.isNull() ) ? QPixmap() : P; } QString TheNSResources::tr( const char * s ) { @@ -225,6 +260,7 @@ NodeCollection * TheNSResources::findConnection( const QString & S ) { return ConnectionsMap[ S ]; } +/* void TheNSResources::renumberConnections( void ) { Name2Connection_t & M = NSResources->connections(); NodeCollection * NC; @@ -239,6 +275,7 @@ void TheNSResources::renumberConnections( void ) { NC->setModified( 1 ); } } +*/ typedef struct EnvVars { char * Name; @@ -263,10 +300,11 @@ void TheNSResources::detectCurrentUser( void ) { // find current running qpe QString QPEEnvFile = ""; - // open proc dir and find all dirs in it - { QRegExp R("[0-9]+"); + if( getenv( "OPIEDIR" ) == 0 ) { + // nothing known + { // open proc dir and find all dirs in it + QRegExp R("[0-9]+"); QDir ProcDir( "/proc" ); - QString QPELoc = QPEApplication::qpeDir() + "bin/qpe"; QFileInfo FI; QStringList EL = ProcDir.entryList( QDir::Dirs ); @@ -278,9 +316,9 @@ void TheNSResources::detectCurrentUser( void ) { QString S = ProcDir.path()+"/"+ (*it); S.append( "/exe" ); FI.setFile( S ); - // get the linke + // get the link S = FI.readLink(); - if( S == QPELoc ) { + if( S.right( 8 ) == "/bin/qpe" ) { // found running qpe QPEEnvFile.sprintf( ProcDir.path()+ "/" + (*it) + "/environ" ); break; @@ -291,7 +329,7 @@ void TheNSResources::detectCurrentUser( void ) { if( QPEEnvFile.isEmpty() ) { // could not find qpe - fprintf( stderr, "Could not find qpe\n" ); + Log(("Could not find qpe\n" )); return; } @@ -304,8 +342,8 @@ void TheNSResources::detectCurrentUser( void ) { fd = open( QPEEnvFile.latin1(), O_RDONLY ); if( fd < 0 ) { - fprintf( stderr, "Could not open %s : %d\n", - QPEEnvFile.latin1(), errno ); + Log(("Could not open %s : %d\n", + QPEEnvFile.latin1(), errno )); return; } @@ -337,6 +375,11 @@ void TheNSResources::detectCurrentUser( void ) { CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = strdup( Data ); + // put OPIEDIR in env + if( strcmp( Run->Name, "OPIEDIR=" ) == 0 ) { + putenv( CurrentUser.EnvList[CurrentUser.EnvList.size()-1] ); + + } break; } Run ++; @@ -356,8 +399,8 @@ void TheNSResources::detectCurrentUser( void ) { if( getpwnam_r( CurrentUser.UserName.latin1(), &pwd, TB, sizeof(TB), &pwdres ) || pwdres == 0 ) { - fprintf( stderr, "Could not determine user %s : %d\n", - CurrentUser.UserName.latin1(), errno ); + Log(("Could not determine user %s : %d\n", + CurrentUser.UserName.latin1(), errno )); return; } CurrentUser.Uid = pwd.pw_uid; @@ -367,4 +410,35 @@ void TheNSResources::detectCurrentUser( void ) { CurrentUser.Gid = -1; } } + + } else { + CurrentUser.UserName = getenv( "LOGNAME" ); + CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); + CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = + strdup( CurrentUser.UserName ); + + CurrentUser.HomeDir = getenv( "HOME" ); + CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); + CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = + strdup( CurrentUser.HomeDir ); + + CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); + CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("USER"); + CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); + CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("LD_LIBRARY_PATH"); + + CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); + CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("PATH"); + + CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); + CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("QTDIR"); + + CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); + CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("OPIEDIR"); + CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); + CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("SHELL"); + + CurrentUser.Uid = getuid(); + CurrentUser.Gid = getgid(); + } } |