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

opluginloader.h

Go to the documentation of this file.
00001 /*
00002  * LGPLv2 or later
00003  * zecke@handhelds.org
00004  */
00005 #ifndef ODP_CORE_OPLUGIN_LOADER_H
00006 #define ODP_CORE_OPLUGIN_LOADER_H
00007 
00008 #include <qpe/qlibrary.h>
00009 
00010 #include <qptrdict.h>
00011 #include <qstringlist.h>
00012 
00013 namespace Opie {
00014 namespace Core {
00015 class OConfig;
00016 namespace Internal {
00017 class OPluginLibraryHolder;
00018 }
00019 
00029 class OPluginItem {
00030 public:
00031     typedef QValueList<OPluginItem> List;
00032     OPluginItem();
00033     OPluginItem( const QString& name, const QString& path, bool enabled = true, int pos = -1 );
00034     ~OPluginItem();
00035 
00036     bool isEmpty()const;
00037 
00038     bool operator==( const OPluginItem& )const;
00039     bool operator!=( const OPluginItem& )const;
00040 
00041 
00042     QString  name()const;
00043     QString  path()const;
00044     bool isEnabled()const;
00045     int position()const;
00046 
00047     void setName( const QString& );
00048     void setPath( const QString& );
00049     void setEnabled(  bool );
00050     void setPosition( int );
00051 
00052 private:
00053     QString m_name;
00054     QString m_path;
00055     bool  m_enabled : 1;
00056     int m_pos;
00057     struct Private;
00058     Private *d;
00059 };
00060 
00073 class OGenericPluginLoader {
00074 public:
00075     typedef OPluginItem::List List;
00076     OGenericPluginLoader( const QString &name, bool isSorted = false );
00077     virtual ~OGenericPluginLoader();
00078 
00079     void setAutoDelete( bool );
00080     bool autoDelete()const;
00081     void clear();
00082 
00083     QString name()const;
00084     bool isSorted()const;
00085     bool isInSafeMode()const;
00086 
00087 
00088     List  allAvailable(bool sorted = false )const;
00089     List  filtered(bool sorted = false )const;
00090 
00091 
00092     virtual QUnknownInterface* load( const OPluginItem& item, const QUuid& );
00093     virtual void unload( QUnknownInterface* );
00094 
00095 protected:
00096     friend class OPluginManager; // we need the static unlibify
00097     void readConfig();
00098     virtual List plugins( const QString& dir, bool sorted, bool disabled )const;
00099     void setPluginDirs( const QStringList& );
00100     void setPluginDir( const QString& );
00101     void setSafeMode(const QString& app = QString::null,  bool b = false);
00102     static QString unlibify( const QString& str );
00103 private:
00104     QStringList languageList();
00105     void installTranslators(const QString& type);
00106     QString m_dir;
00107     QStringList m_plugDirs;
00108     QStringList m_languages;
00109     bool m_autoDelete : 1;
00110     bool m_isSafeMode : 1;
00111     bool m_isSorted   : 1;
00112     QPtrDict<QLibrary> m_library;
00113 
00114     struct Private;
00115     Private* d;
00116 };
00117 
00137 class OPluginLoader : public OGenericPluginLoader {
00138 public:
00139     OPluginLoader( const QString& name, bool sorted = false );
00140     virtual ~OPluginLoader();
00141 
00142     template<class IFace>
00143     IFace* load( const OPluginItem& item, const QUuid& );
00144 };
00145 
00157 class OPluginManager {
00158 public:
00159     typedef QValueList<OPluginManager*> List;
00160     OPluginManager( OGenericPluginLoader* );
00161     OPluginManager( const QString& name, const OPluginItem::List&, bool isSorted = false );
00162     virtual ~OPluginManager();
00163 
00164     OPluginItem crashedPlugin()const;
00165 
00166     OPluginItem::List managedPlugins()const;
00167 
00168     void setPosition( const OPluginItem& );
00169     void enable( const OPluginItem& );
00170     void disable( const OPluginItem& );
00171     void setEnabled( const OPluginItem&, bool = true);
00172 
00173     virtual void load();
00174     virtual void save();
00175 
00176 protected:
00177     QString configName()const;
00178     void replace( const OPluginItem& );
00179 private:
00180     OGenericPluginLoader *m_loader;
00181     QString m_cfgName;
00182     OPluginItem::List m_plugins;
00183     OPluginItem m_crashed;
00184     bool m_isSorted : 1;
00185 };
00186 
00187 
00197 template<class IFace>
00198 IFace* OPluginLoader::load( const OPluginItem& item, const QUuid& uid ) {
00199     return static_cast<IFace*>( OGenericPluginLoader::load( item, uid ) );
00200 }
00201 
00202 }
00203 }
00204 
00205 
00206 #endif

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