00001 /* OPIE */ 00002 #include <opie2/owait.h> 00003 using namespace Opie::Ui; 00004 00005 #include <qtopia/qcom.h> 00006 #include <qtopia/qlibrary.h> 00007 #include <qtopia/qpeapplication.h> 00008 #include <qtopia/applicationinterface.h> 00009 #include <qtopia/resource.h> 00010 00011 /* QT */ 00012 #include <qmetaobject.h> 00013 #include <qmap.h> 00014 #include <qstring.h> 00015 00016 namespace QuickPrivate { 00017 00018 struct PluginLoader { 00019 PluginLoader( const char* ) { 00020 } 00021 00022 QRESULT queryInterface( const QString& app, const QUuid&, QUnknownInterface** ); 00023 void releaseInterface( QUnknownInterface* ); 00024 QMap<QUnknownInterface*, QLibrary*> libs; 00025 }; 00026 00027 /* 00028 * We can skip installing a Translator here because Opies QPEApplication 00029 * will do that in initApp for us as well 00030 */ 00031 QRESULT PluginLoader::queryInterface( const QString& libFile, const QUuid& uuid, QUnknownInterface** iface ) { 00032 QRESULT res = QS_FALSE; 00033 *iface = 0; 00034 00035 // This code is very platform specific.. We should find better 00036 // solutions to handle names.. Maybe one central function would be 00037 // better than checking this ".so" stuff all around in the sources.. 00038 // (eilers) 00039 00040 // Below lines from TT then mine again 00041 QString name = libFile; 00042 if ( libFile.findRev(".so") == (int)libFile.length()-3 ) { 00043 name = libFile.left( libFile.length()-3 ); 00044 if ( name.find( "lib" ) == 0 ) 00045 name = name.mid( 3 ); 00046 } 00047 #ifdef Q_OS_MACX 00048 QString path = QPEApplication::qpeDir() + "plugins/application/lib"+name+".dylib"; 00049 #else 00050 QString path = QPEApplication::qpeDir() + "plugins/application/lib"+name+".so"; 00051 #endif 00052 00053 QLibrary *lib = new QLibrary( path ); 00054 if ( lib->queryInterface( uuid, iface ) == QS_OK && iface ) { 00055 libs.insert( *iface, lib ); 00056 res = QS_OK; 00057 } 00058 00059 return res; 00060 } 00061 00062 void PluginLoader::releaseInterface( QUnknownInterface* iface ) { 00063 if ( libs.contains( iface ) ) { 00064 iface->release(); 00065 delete libs[iface]; 00066 libs.remove( iface ); // we only handle pointers so even if the object is not valid the address-space is 00067 } 00068 } 00069 00070 } 00071
1.4.2