1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-20 04:41:36 +02:00

* When loading plugins, Tomahawk will now try to find them in ../lib as well.

This commit is contained in:
Christian Muehlhaeuser
2011-02-10 14:25:42 +01:00
parent 0f0c0d9026
commit baf527cacf
2 changed files with 43 additions and 14 deletions

View File

@@ -15,7 +15,7 @@ SipHandler::SipHandler( QObject* parent )
: QObject( parent ) : QObject( parent )
{ {
m_connected = false; m_connected = false;
loadPlugins(); loadPlugins( findPlugins() );
} }
@@ -24,29 +24,57 @@ SipHandler::~SipHandler()
} }
void QStringList
SipHandler::loadPlugins() SipHandler::findPlugins()
{ {
QDir pluginsDir( qApp->applicationDirPath() ); QStringList paths;
QList< QDir > pluginDirs;
#if defined(Q_OS_MAC) QDir appDir( qApp->applicationDirPath() );
if ( pluginsDir.dirName() == "MacOS" ) #ifdef Q_OS_MAC
if ( appDir.dirName() == "MacOS" )
{ {
pluginsDir.cdUp(); // Development convenience-hack
pluginsDir.cdUp(); appDir.cdUp();
pluginsDir.cdUp(); appDir.cdUp();
appDir.cdUp();
} }
#endif #endif
// pluginsDir.cd( "plugins" );
foreach ( QString fileName, pluginsDir.entryList( QDir::Files ) ) QDir libDir( appDir );
libDir.cdUp();
libDir.cd( "lib" );
pluginDirs << appDir << libDir << QDir( qApp->applicationDirPath() );
foreach ( const QDir& pluginDir, pluginDirs )
{
qDebug() << "Checking directory for plugins:" << pluginDir;
foreach ( QString fileName, pluginDir.entryList( QDir::Files ) )
{
if ( fileName.startsWith( "libsip_" ) )
{
const QString path = pluginDir.absoluteFilePath( fileName );
if ( !paths.contains( path ) )
paths << path;
}
}
}
return paths;
}
void
SipHandler::loadPlugins( const QStringList& paths )
{
foreach ( QString fileName, paths )
{ {
if ( !QLibrary::isLibrary( fileName ) ) if ( !QLibrary::isLibrary( fileName ) )
continue; continue;
qDebug() << "Trying to load plugin:" << pluginsDir.absoluteFilePath( fileName ); qDebug() << "Trying to load plugin:" << fileName;
QPluginLoader loader( pluginsDir.absoluteFilePath( fileName ) ); QPluginLoader loader( fileName );
QObject* plugin = loader.instance(); QObject* plugin = loader.instance();
if ( plugin ) if ( plugin )
{ {

View File

@@ -35,7 +35,8 @@ private slots:
void onError( int code, const QString& msg ); void onError( int code, const QString& msg );
private: private:
void loadPlugins(); QStringList findPlugins();
void loadPlugins( const QStringList& paths );
void loadPlugin( QObject* plugin ); void loadPlugin( QObject* plugin );
QList< SipPlugin* > m_plugins; QList< SipPlugin* > m_plugins;