Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

resources.h

Go to the documentation of this file.
00001 #ifndef __RESOURCES__H
00002 #define __RESOURCES__H
00003 
00004 #include <qstring.h>
00005 #include <qdict.h>
00006 #include <qmap.h>
00007 #include <qlist.h>
00008 #include "netnode.h"
00009 #include "systemfile.h"
00010 #include "system.h"
00011 
00012 class QLibrary;
00013 class QPixmap;
00014 class ANetNode;
00015 class ANetNodeInstance;
00016 
00017 namespace Opie {
00018     namespace Core {
00019         class OPluginLoader;
00020         class OPluginManager;
00021     }
00022 }
00023 
00024 typedef void (*GetNetNodeListFt_t)(QList<ANetNode>& PNN );
00025 
00026 class CurrentQPEUser {
00027 
00028 public :
00029         CurrentQPEUser() : UserName(), HomeDir(), EnvList() {}
00030 
00031         inline bool known( void )
00032           { return ! HomeDir.isEmpty() && ! UserName.isEmpty(); }
00033 
00034         QString        UserName;
00035         QString        HomeDir;
00036         int            Uid;
00037         int            Gid;
00038         QArray<char *> EnvList;
00039 };
00040 
00041 typedef QDict<ANetNode>  Name2NetNode_t;
00042 typedef QDict<ANetNodeInstance > Name2Instance_t;
00043 typedef QDict<NetworkSetup> Name2NetworkSetup_t;
00044 typedef QDict<SystemFile> Name2SystemFile_t;
00045 
00046 class TheNSResources {
00047 
00048 public :
00049 
00050     TheNSResources( void );
00051     ~TheNSResources( );
00052 
00053     // give busy feedback
00054     void busy( bool B );
00055 
00056     System & system()
00057       { return *TheSystem; }
00058 
00059     int assignNetworkSetupNumber(void);
00060     QPixmap getPixmap( const QString & Name );
00061 
00062     Name2NetNode_t & netNodes( void ) 
00063       { return AllNodeTypes; }
00064     bool netNodeExists( const QString & X )
00065       { return AllNodeTypes.find(X)!=0; }
00066     ANetNode * findNetNode( const QString & N )
00067       { return AllNodeTypes.find(N);
00068       }
00069     // define new plugin (=node)
00070     void addNodeType( const QString & ID,
00071                       const QString & LongName,
00072                       const QString & Description );
00073 
00074     Name2SystemFile_t & systemFiles( void )
00075       { return SystemFiles; }
00076     void addSystemFile( const QString & ID, 
00077                         const QString & P,
00078                         bool KDI );
00079 
00080     ANetNodeInstance * createNodeInstance( const QString & S )
00081       { ANetNode * NN = findNetNode( S );
00082 
00083         Log(( "Find node type %s : %p\n", S.latin1(), NN ));
00084 
00085         if( NN == 0 ) 
00086           // type of this instance not found
00087           return 0;
00088 
00089         ANetNodeInstance * NNI = NN->createInstance();
00090         NNI->initialize();
00091         return NNI;
00092       }
00093 
00094     Name2Instance_t & netNodeInstances( void ) 
00095       { return AllNodes; }
00096     void addNodeInstance( ANetNodeInstance * I )
00097       { AllNodes.insert( I->name(), I ); }
00098     void removeNodeInstance( const QString & N )
00099       { AllNodes.remove( N );}
00100     ANetNodeInstance * findNodeInstance( const QString & S )
00101       { return AllNodes[S]; }
00102 
00103     const QString & netNode2Name( const char * Type );
00104     const QString & netNode2Description( const char * Type );
00105 
00106     void addNetworkSetup( NetworkSetup * NC, bool Dangling );
00107     void removeNetworkSetup( const QString & N );
00108     NetworkSetup * findNetworkSetup( const QString & N );
00109     NetworkSetup * getNetworkSetup( int nr );
00110     Name2NetworkSetup_t & networkSetups( void )
00111       { return NetworkSetupsMap; }
00112     Name2NetworkSetup_t & danglingNetworkSetups( void )
00113       { return DanglingNetworkSetupsMap; }
00114 
00115     inline bool userKnown( void )
00116       { return CurrentUser.known(); }
00117     CurrentQPEUser & currentUser( void )
00118       { return CurrentUser; }
00119 
00120 private :
00121 
00122     void detectCurrentUser( void );
00123     QString tr( const char * path );
00124 
00125     void findAvailableNetNodes( void );
00126 
00127     QMap< QString, QString>   NodeTypeNameMap;
00128     QMap< QString, QString>   NodeTypeDescriptionMap;
00129     // list of networkSetups that are valid
00130     Name2NetworkSetup_t         NetworkSetupsMap;
00131     // list of networkSetup configurations that are not valid
00132     // e.g. because plugins are missing
00133     Name2NetworkSetup_t         DanglingNetworkSetupsMap;
00134     System *                  TheSystem;
00135     Name2SystemFile_t         SystemFiles;
00136 
00137     // all node type classes 
00138     Name2NetNode_t            AllNodeTypes;
00139 
00140     // all nodes
00141     Name2Instance_t           AllNodes;
00142 
00143     CurrentQPEUser            CurrentUser;
00144 
00145     Opie::Core::OPluginLoader *  Plugins;
00146     Opie::Core::OPluginManager * PluginManager;
00147 
00148 };
00149 
00150 extern TheNSResources * _NSResources;
00151 #define NSResources _NSResources
00152 
00153 #endif

Generated on Sat Nov 5 16:17:54 2005 for OPIE by  doxygen 1.4.2