author | zecke <zecke> | 2003-08-27 12:47:27 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-08-27 12:47:27 (UTC) |
commit | ea7aa8c3779be1e5aadb550559b3a463859ba104 (patch) (side-by-side diff) | |
tree | c6d1154d284b0d79ecaf8be4985e0a50298b7fbd /core/tools/quicklauncher/dropins.h | |
parent | 81175f54968c0cd749492d3fe43b7243b71c2d5d (diff) | |
download | opie-ea7aa8c3779be1e5aadb550559b3a463859ba104.zip opie-ea7aa8c3779be1e5aadb550559b3a463859ba104.tar.gz opie-ea7aa8c3779be1e5aadb550559b3a463859ba104.tar.bz2 |
Opiefy it
Diffstat (limited to 'core/tools/quicklauncher/dropins.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/tools/quicklauncher/dropins.h | 61 |
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 @@ + +#include <qstring.h> +#include <qtopia/qcom.h> +#include <qtopia/qlibrary.h> +#include <qtopia/applicationinterface.h> +#include <qtopia/resource.h> + +#include <opie/owait.h> + +#include <qmetaobject.h> +#include <qmap.h> + +namespace Opie { + + struct PluginLoader { + PluginLoader( const char* ) { + } + + QRESULT queryInterface( const QString& app, const QUuid&, QUnknownInterface** ); + void releaseInterface( QUnknownInterface* ); + QMap<QUnknownInterface*, QLibrary*> libs; + }; + + /* + * We can skip installing a Translator here because Opies QPEApplication + * will do that in initApp for us as well + */ + QRESULT PluginLoader::queryInterface( const QString& libFile, const QUuid& uuid, QUnknownInterface** iface ) { + QRESULT res = QS_FALSE; + *iface = 0; + + // Below lines from TT then mine again + QString name = libFile; + if ( libFile.findRev(".so") == (int)libFile.length()-3 ) { + name = libFile.left( libFile.length()-3 ); + if ( name.find( "lib" ) == 0 ) + name = name.mid( 3 ); + } + QString path = QPEApplication::qpeDir() + "/plugins/applications/lib"+name+".so"; + + QLibrary *lib = new QLibrary( path ); + if ( lib->queryInterface( uuid, iface ) == QS_OK && iface ) { + libs.insert( *iface, lib ); + res = QS_OK; + } + + return res; + } + + void PluginLoader::releaseInterface( QUnknownInterface* iface ) { + if ( libs.contains( iface ) ) { + iface->release(); + delete libs[iface]; + libs.remove( iface ); // we only handle pointers so even if the object is not valid the address-space is + } + } + +} + +/* small hack ;) */ +using namespace Opie; |