summaryrefslogtreecommitdiff
path: root/core/tools/quicklauncher/dropins.h
Unidiff
Diffstat (limited to 'core/tools/quicklauncher/dropins.h') (more/less context) (ignore whitespace changes)
-rw-r--r--core/tools/quicklauncher/dropins.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/core/tools/quicklauncher/dropins.h b/core/tools/quicklauncher/dropins.h
new file mode 100644
index 0000000..ac8d8cc
--- a/dev/null
+++ b/core/tools/quicklauncher/dropins.h
@@ -0,0 +1,61 @@
1
2#include <qstring.h>
3#include <qtopia/qcom.h>
4#include <qtopia/qlibrary.h>
5#include <qtopia/applicationinterface.h>
6#include <qtopia/resource.h>
7
8#include <opie/owait.h>
9
10#include <qmetaobject.h>
11#include <qmap.h>
12
13namespace Opie {
14
15 struct PluginLoader {
16 PluginLoader( const char* ) {
17 }
18
19 QRESULT queryInterface( const QString& app, const QUuid&, QUnknownInterface** );
20 void releaseInterface( QUnknownInterface* );
21 QMap<QUnknownInterface*, QLibrary*> libs;
22 };
23
24 /*
25 * We can skip installing a Translator here because Opies QPEApplication
26 * will do that in initApp for us as well
27 */
28 QRESULT PluginLoader::queryInterface( const QString& libFile, const QUuid& uuid, QUnknownInterface** iface ) {
29 QRESULT res = QS_FALSE;
30 *iface = 0;
31
32 // Below lines from TT then mine again
33 QString name = libFile;
34 if ( libFile.findRev(".so") == (int)libFile.length()-3 ) {
35 name = libFile.left( libFile.length()-3 );
36 if ( name.find( "lib" ) == 0 )
37 name = name.mid( 3 );
38 }
39 QString path = QPEApplication::qpeDir() + "/plugins/applications/lib"+name+".so";
40
41 QLibrary *lib = new QLibrary( path );
42 if ( lib->queryInterface( uuid, iface ) == QS_OK && iface ) {
43 libs.insert( *iface, lib );
44 res = QS_OK;
45 }
46
47 return res;
48 }
49
50 void PluginLoader::releaseInterface( QUnknownInterface* iface ) {
51 if ( libs.contains( iface ) ) {
52 iface->release();
53 delete libs[iface];
54 libs.remove( iface ); // we only handle pointers so even if the object is not valid the address-space is
55 }
56 }
57
58}
59
60/* small hack ;) */
61using namespace Opie;