1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-19 04:11:46 +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 )
{
m_connected = false;
loadPlugins();
loadPlugins( findPlugins() );
}
@@ -24,29 +24,57 @@ SipHandler::~SipHandler()
}
void
SipHandler::loadPlugins()
QStringList
SipHandler::findPlugins()
{
QDir pluginsDir( qApp->applicationDirPath() );
QStringList paths;
QList< QDir > pluginDirs;
#if defined(Q_OS_MAC)
if ( pluginsDir.dirName() == "MacOS" )
QDir appDir( qApp->applicationDirPath() );
#ifdef Q_OS_MAC
if ( appDir.dirName() == "MacOS" )
{
pluginsDir.cdUp();
pluginsDir.cdUp();
pluginsDir.cdUp();
// Development convenience-hack
appDir.cdUp();
appDir.cdUp();
appDir.cdUp();
}
#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 ) )
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();
if ( plugin )
{

View File

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