summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.cpp5
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.cpp3
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.h3
3 files changed, 8 insertions, 3 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp
index 17653bd..f8f2d1e 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.cpp
+++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp
@@ -135,107 +135,108 @@ ANetNodeInstance * ANetNodeInstance::nextNode( void ) {
//
NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() {
IsModified = 0;
Index = -1;
Name="";
IsNew = 1;
CurrentState = Unchecked;
AssignedInterface = 0;
}
NodeCollection::NodeCollection( QTextStream & TS ) :
QList<ANetNodeInstance>() {
long idx;
bool InError = 0;
QString S, A, N;
IsModified = 0;
Index = -1;
Name="";
IsNew = 0;
AssignedInterface = 0;
CurrentState = Unchecked;
do {
S = TS.readLine();
if( S.isEmpty() ) {
if( InError ) {
// remove all nodes
clear();
}
// empty line
break;
}
idx = S.find('=');
S.stripWhiteSpace();
A = S.left( idx );
A.lower();
N = S.mid( idx+1, S.length() );
N.stripWhiteSpace();
N = deQuote( N );
if( A == "name" ) {
Name = N;
} else if( A == "number" ) {
setNumber( N.toLong() );
} else if( A == "node" ) {
ANetNodeInstance * NNI = NSResources->findNodeInstance( N );
+ Log(( "Find node %s : %p\n", N.latin1(), NNI ));
if( NNI && ! InError ) {
- append( NSResources->findNodeInstance( N ) );
+ append( NNI );
} else {
// could not find a node type -> collection invalid
InError = 1;
}
}
} while( 1 );
Log(( "Profile number %s : %d nodes\n",
- N.latin1(), count() ));
+ Name.latin1(), count() ));
}
NodeCollection::~NodeCollection( void ) {
}
const QString & NodeCollection::description( void ) {
ANetNodeInstance * NNI = getToplevel();
return (NNI) ? NNI->runtime()->description() : Name;
}
void NodeCollection::append( ANetNodeInstance * NNI ) {
NNI->setConnection( this );
QList<ANetNodeInstance>::append( NNI );
}
void NodeCollection::save( QTextStream & TS ) {
TS << "name=" << quote( Name ) << endl;
TS << "number=" << number() << endl;
ANetNodeInstance * NNI;
for( QListIterator<ANetNodeInstance> it(*this);
it.current();
++it ) {
NNI = it.current();
TS << "node=" << NNI->name() << endl;
}
TS << endl;
IsNew = 0;
}
ANetNodeInstance * NodeCollection::getToplevel( void ) {
ANetNodeInstance * NNI = 0;
for( QListIterator<ANetNodeInstance> it(*this);
it.current();
++it ) {
NNI = it.current();
if( NNI->nodeClass()->isToplevel() )
break;
}
return NNI;
}
ANetNodeInstance * NodeCollection::findByName( const QString & S ) {
ANetNodeInstance * NNI = 0;
for( QListIterator<ANetNodeInstance> it(*this);
it.current();
++it ) {
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp
index 8b3b4fe..50fb15a 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.cpp
+++ b/noncore/settings/networksettings2/networksettings2/resources.cpp
@@ -96,106 +96,109 @@ void TheNSResources::addNodeType( const QString & ID,
}
}
void TheNSResources::addSystemFile( const QString & ID,
const QString & P,
bool KDI ) {
if( ! SystemFiles.find( ID ) ) {
// new system file
SystemFiles.insert( ID, new SystemFile( ID, P, KDI ) );
} // else existed
}
void TheNSResources::busy( bool ) {
/*
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
* and attempts to load them
*/
void TheNSResources::findAvailableNetNodes(const QString &path){
Log(("Locate plugins in %s\n", path.latin1() ));
QDir d(path);
if(!d.exists())
return;
QString lang = ::getenv("LANG");
// Don't want sym links
d.setFilter( QDir::Files | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
while ( (fi=it.current()) ) {
if( fi->fileName().contains(".so")){
/* if loaded install translation */
if( loadNetNode(path + "/" + fi->fileName()) ) {
+ Log(( "Loading plugin %s\n", fi->fileName().latin1()));
QTranslator *trans = new QTranslator(qApp);
QString fn = QPEApplication::qpeDir()+
"/i18n/"+lang+"/"+
fi->fileName().left( fi->fileName().find(".") )+
".qm";
if( trans->load( fn ) )
qApp->installTranslator( trans );
else
delete trans;
+ } else {
+ Log(( "Error loading plugin %s\n", fi->fileName().latin1()));
}
}
++it;
}
}
// 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
* @param resolveString - function pointer to resolve
* @return true of loading is successful
*/
bool TheNSResources::loadNetNode(
const QString &pluginFileName, const QString &resolveString){
QLibrary *lib = new QLibrary(pluginFileName);
void * res = lib->resolve(resolveString);
if( ! res ){
delete lib;
return 0;
}
GetNetNodeListFt_t getNetNodeList = (GetNetNodeListFt_t)res;
// Try to get an object.
QList<ANetNode> PNN;
diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h
index 634cd39..5d90286 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.h
+++ b/noncore/settings/networksettings2/networksettings2/resources.h
@@ -35,109 +35,110 @@ public :
int Uid;
int Gid;
QArray<char *> EnvList;
};
typedef QDict<NetNode_t> Name2NetNode_t;
typedef QDict<ANetNodeInstance > Name2Instance_t;
typedef QDict<NodeCollection> Name2Connection_t;
typedef QDict<SystemFile> Name2SystemFile_t;
class TheNSResources {
public :
TheNSResources( void );
~TheNSResources( );
// give busy feedback
void busy( bool B );
System & system()
{ return *TheSystem; }
int assignConnectionNumber(void);
QPixmap getPixmap( const QString & Name );
Name2NetNode_t & netNodes( void )
{ return AllNodeTypes; }
bool netNodeExists( const QString & X )
{ return AllNodeTypes.find(X)!=0; }
ANetNode * findNetNode( const QString & N )
{ NetNode_t * NNT = AllNodeTypes.find(N);
return (NNT) ? NNT->NetNode : 0;
}
// define new plugin (=node)
void addNodeType( const QString & ID,
const QString & LongName,
const QString & Description );
Name2SystemFile_t & systemFiles( void )
{ return SystemFiles; }
void addSystemFile( const QString & ID,
const QString & P,
bool KDI );
ANetNodeInstance * createNodeInstance( const QString & S )
{ ANetNodeInstance * NNI = 0;
+ printf( "Find node type %s\n", S.latin1() );
NetNode_t * NNT = AllNodeTypes[S];
if( ! NNT ) {
return 0;
}
NNI = NNT->NetNode->createInstance();
NNI->initialize();
return NNI;
}
Name2Instance_t & netNodeInstances( void )
{ return AllNodes; }
void addNodeInstance( ANetNodeInstance * I )
{ AllNodes.insert( I->name(), I ); }
void removeNodeInstance( const QString & N )
{ AllNodes.remove( N );}
ANetNodeInstance * findNodeInstance( const QString & S )
- { return (AllNodes.find(S)!=0) ? AllNodes[S] : 0; }
+ { return AllNodes[S]; }
const QString & netNode2Name( const char * Type );
const QString & netNode2Description( const char * Type );
void addConnection( NodeCollection * NC );
void removeConnection( const QString & N );
NodeCollection * findConnection( const QString & N );
NodeCollection * getConnection( int nr );
Name2Connection_t & connections( void )
{ return ConnectionsMap; }
inline bool userKnown( void )
{ return CurrentUser.known(); }
CurrentQPEUser & currentUser( void )
{ return CurrentUser; }
private :
void detectCurrentUser( void );
QString tr( const char * path );
void findAvailableNetNodes( const QString &path );
bool loadNetNode(
const QString &pluginFileName,
const QString &resolveString = "create_plugin");
QMap< QString, QString> NodeTypeNameMap;
QMap< QString, QString> NodeTypeDescriptionMap;
Name2Connection_t ConnectionsMap;
System * TheSystem;
Name2SystemFile_t SystemFiles;
// all node type classes
Name2NetNode_t AllNodeTypes;
// all nodes
Name2Instance_t AllNodes;
CurrentQPEUser CurrentUser;
};
extern TheNSResources * _NSResources;
#define NSResources _NSResources
#endif