summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/opluginloader.h6
1 files changed, 0 insertions, 6 deletions
diff --git a/libopie2/opiecore/opluginloader.h b/libopie2/opiecore/opluginloader.h
index 421d1f6..6166b75 100644
--- a/libopie2/opiecore/opluginloader.h
+++ b/libopie2/opiecore/opluginloader.h
@@ -1,187 +1,181 @@
1/* 1/*
2 * LGPLv2 or later 2 * LGPLv2 or later
3 * zecke@handhelds.org 3 * zecke@handhelds.org
4 */ 4 */
5#ifndef ODP_CORE_OPLUGIN_LOADER_H 5#ifndef ODP_CORE_OPLUGIN_LOADER_H
6#define ODP_CORE_OPLUGIN_LOADER_H 6#define ODP_CORE_OPLUGIN_LOADER_H
7 7
8#include <qpe/qlibrary.h> 8#include <qpe/qlibrary.h>
9 9
10#include <qptrdict.h> 10#include <qptrdict.h>
11#include <qstringlist.h> 11#include <qstringlist.h>
12 12
13namespace Opie { 13namespace Opie {
14namespace Core { 14namespace Core {
15class OConfig; 15class OConfig;
16namespace Internal { 16namespace Internal {
17class OPluginLibraryHolder; 17class OPluginLibraryHolder;
18} 18}
19 19
20template class QPtrDict<QLibrary>; 20template class QPtrDict<QLibrary>;
21 21
22/** 22/**
23 * \brief A small item representing the Plugin Information 23 * \brief A small item representing the Plugin Information
24 * This class contains the information about a Plugin. It contains 24 * This class contains the information about a Plugin. It contains
25 * a translated name if available to the system, a config key, 25 * a translated name if available to the system, a config key,
26 * and the path location. 26 * and the path location.
27 * 27 *
28 * @since 1.2 28 * @since 1.2
29 * 29 *
30 */ 30 */
31class OPluginItem { 31class OPluginItem {
32public: 32public:
33 typedef QValueList<OPluginItem> List; 33 typedef QValueList<OPluginItem> List;
34 OPluginItem(); 34 OPluginItem();
35 OPluginItem( const QString& name, const QString& path, int pos = -1 ); 35 OPluginItem( const QString& name, const QString& path, int pos = -1 );
36 ~OPluginItem(); 36 ~OPluginItem();
37 37
38 bool operator==( const OPluginItem& )const; 38 bool operator==( const OPluginItem& )const;
39 bool operator!=( const OPluginItem& )const; 39 bool operator!=( const OPluginItem& )const;
40 40
41 41
42 QString name()const; 42 QString name()const;
43 QString path()const; 43 QString path()const;
44 int position()const; 44 int position()const;
45 45
46 void setName( const QString& ); 46 void setName( const QString& );
47 void setPath( const QString& ); 47 void setPath( const QString& );
48 void setPosition( int ); 48 void setPosition( int );
49 49
50private: 50private:
51 QString m_name; 51 QString m_name;
52 QString m_path; 52 QString m_path;
53 int m_pos; 53 int m_pos;
54 struct Private; 54 struct Private;
55 Private *d; 55 Private *d;
56}; 56};
57 57
58/** 58/**
59 * \brief A generic class to easily load and manage plugins 59 * \brief A generic class to easily load and manage plugins
60 * 60 *
61 * This is the generic non sepcialised loader for plugins. Normally 61 * This is the generic non sepcialised loader for plugins. Normally
62 * you would prefer using the OPluginLoader directly. This class 62 * you would prefer using the OPluginLoader directly. This class
63 * exists to minimize the application binary size due the usage 63 * exists to minimize the application binary size due the usage
64 * of templates in the specialized API 64 * of templates in the specialized API
65 * 65 *
66 * @since 1.2 66 * @since 1.2
67 * @see OPluginLoader 67 * @see OPluginLoader
68 */ 68 */
69class OGenericPluginLoader { 69class OGenericPluginLoader {
70public: 70public:
71 typedef OPluginItem::List List; 71 typedef OPluginItem::List List;
72 OGenericPluginLoader( const QString &name, bool isSorted = false ); 72 OGenericPluginLoader( const QString &name, bool isSorted = false );
73 virtual ~OGenericPluginLoader(); 73 virtual ~OGenericPluginLoader();
74 74
75 void setAutoDelete( bool ); 75 void setAutoDelete( bool );
76 bool autoDelete()const; 76 bool autoDelete()const;
77 void clear(); 77 void clear();
78 78
79 79
80 bool isInSafeMode()const; 80 bool isInSafeMode()const;
81 81
82 82
83 List allAvailable(bool sorted = FALSE)const; 83 List allAvailable(bool sorted = FALSE)const;
84 List filtered(bool sorted = FALSE)const; 84 List filtered(bool sorted = FALSE)const;
85 85
86 86
87 virtual QUnknownInterface* load( const OPluginItem& item, const QUuid& ); 87 virtual QUnknownInterface* load( const OPluginItem& item, const QUuid& );
88 virtual void unload( QUnknownInterface* ); 88 virtual void unload( QUnknownInterface* );
89 89
90protected: 90protected:
91 void readConfig(); 91 void readConfig();
92 virtual List plugins( const QString& dir, bool sorted, bool disabled )const; 92 virtual List plugins( const QString& dir, bool sorted, bool disabled )const;
93 void setPluginDirs( const QStringList& ); 93 void setPluginDirs( const QStringList& );
94 void setPluginDir( const QString& ); 94 void setPluginDir( const QString& );
95 bool isSorted()const; 95 bool isSorted()const;
96 void setSafeMode(const QString& app = QString::null, bool b = false); 96 void setSafeMode(const QString& app = QString::null, bool b = false);
97 static QString unlibify( const QString& str ); 97 static QString unlibify( const QString& str );
98 98
99private: 99private:
100 QStringList languageList(); 100 QStringList languageList();
101 void installTranslators(const QString& type); 101 void installTranslators(const QString& type);
102 QString m_dir; 102 QString m_dir;
103 QStringList m_plugDirs; 103 QStringList m_plugDirs;
104 QStringList m_languages; 104 QStringList m_languages;
105 bool m_autoDelete : 1; 105 bool m_autoDelete : 1;
106 bool m_isSafeMode : 1; 106 bool m_isSafeMode : 1;
107 bool m_isSorted : 1; 107 bool m_isSorted : 1;
108 QPtrDict<QLibrary> m_library; 108 QPtrDict<QLibrary> m_library;
109 109
110 struct Private; 110 struct Private;
111 Private* d; 111 Private* d;
112}; 112};
113 113
114/** 114/**
115 * \brief The class to load your QCOM+ plugins 115 * \brief The class to load your QCOM+ plugins
116 * 116 *
117 * This class takes care of activation and even the order 117 * This class takes care of activation and even the order
118 * if you need it. It is normally good to place a .directory file 118 * if you need it. It is normally good to place a .directory file
119 * into your plugin directory if you need order of activation. 119 * into your plugin directory if you need order of activation.
120 * 120 *
121 * You'll create the OPluginLoader and then use it to load the filtered 121 * You'll create the OPluginLoader and then use it to load the filtered
122 * plugins. 122 * plugins.
123 * 123 *
124 * There is also a GUI for the configuration and a Manager to write the 124 * There is also a GUI for the configuration and a Manager to write the
125 * mentioned .directory file 125 * mentioned .directory file
126 * 126 *
127 * On crash the safe mode is activated for the next run. You can then decide 127 * On crash the safe mode is activated for the next run. You can then decide
128 * if you want to load plugins or come up with the Configuration on 128 * if you want to load plugins or come up with the Configuration on
129 * next start yourself then. 129 * next start yourself then.
130 * 130 *
131 * @since 1.2 131 * @since 1.2
132 */ 132 */
133class OPluginLoader : public OGenericPluginLoader { 133class OPluginLoader : public OGenericPluginLoader {
134public: 134public:
135 OPluginLoader( const QString& name, bool sorted = false ); 135 OPluginLoader( const QString& name, bool sorted = false );
136 ~OPluginLoader(); 136 ~OPluginLoader();
137 137
138 template<class IFace> 138 template<class IFace>
139 IFace* load( const QString& name, const QUuid& );
140 template<class IFace>
141 IFace* load( const OPluginItem& item, const QUuid& ); 139 IFace* load( const OPluginItem& item, const QUuid& );
142}; 140};
143 141
144/** 142/**
145 * \brief A class to manager order and activation of plugins 143 * \brief A class to manager order and activation of plugins
146 * 144 *
147 * Manage order and activation. This is used by the Opie::Ui::OPluginConfig 145 * Manage order and activation. This is used by the Opie::Ui::OPluginConfig
148 * This class controls the activation and order of plugins depending 146 * This class controls the activation and order of plugins depending
149 * on the OPluginLoader you supply. 147 * on the OPluginLoader you supply.
150 * 148 *
151 * @see OPluginConfig 149 * @see OPluginConfig
152 * 150 *
153 */ 151 */
154class OPluginManager { 152class OPluginManager {
155public: 153public:
156 OPluginManager( OGenericPluginLoader* , const QString& name); 154 OPluginManager( OGenericPluginLoader* , const QString& name);
157 OPluginManager( OConfig* conf, const QString&, 155 OPluginManager( OConfig* conf, const QString&,
158 const QCString& group, const OPluginItem::List& ); 156 const QCString& group, const OPluginItem::List& );
159 ~OPluginManager(); 157 ~OPluginManager();
160 158
161 QString name(); 159 QString name();
162 void setName( const QString& ); 160 void setName( const QString& );
163 161
164 void setPosition( const OPluginItem& ); 162 void setPosition( const OPluginItem& );
165 void enable( const OPluginItem& ); 163 void enable( const OPluginItem& );
166 void disable( const OPluginItem& ); 164 void disable( const OPluginItem& );
167 void setEnabled( const OPluginItem&, bool = true); 165 void setEnabled( const OPluginItem&, bool = true);
168 166
169 void load(); 167 void load();
170 void save(); 168 void save();
171}; 169};
172 170
173template<class IFace>
174IFace* OPluginLoader::load( const QString& name, const QUuid& uid ) {
175 return static_cast<IFace*>( OGenericPluginLoader::load( item, uid ) );
176}
177 171
178template<class IFace> 172template<class IFace>
179IFace* OPluginLoader::load( const OPluginItem& item, const QUuid& uid ) { 173IFace* OPluginLoader::load( const OPluginItem& item, const QUuid& uid ) {
180 return static_cast<IFace*>( OGenericPluginLoader::load( item, uid ) ); 174 return static_cast<IFace*>( OGenericPluginLoader::load( item, uid ) );
181} 175}
182 176
183} 177}
184} 178}
185 179
186 180
187#endif 181#endif