1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-31 01:30:02 +02:00

* Prevented loading a dupe SIP plugin.

This commit is contained in:
Christian Muehlhaeuser
2011-03-19 03:05:43 +01:00
parent feed05463f
commit 64846c1abd
4 changed files with 36 additions and 19 deletions

View File

@@ -123,7 +123,7 @@ ControlConnection::registerSource()
void
ControlConnection::setupDbSyncConnection( bool ondemand )
{
qDebug() << Q_FUNC_INFO << ondemand << m_source->id() << ondemand << m_dbconnkey << m_dbsyncconn << m_registered;
qDebug() << Q_FUNC_INFO << ondemand << m_source->id() << m_dbconnkey << m_dbsyncconn << m_registered;
if ( m_dbsyncconn || !m_registered )
return;

View File

@@ -31,6 +31,7 @@
#include "config.h"
SipHandler::SipHandler( QObject* parent )
: QObject( parent )
, m_connected( false )
@@ -80,11 +81,11 @@ SipHandler::findPlugins()
#endif
QDir libDir( CMAKE_INSTALL_PREFIX "/lib" );
QDir lib64Dir( appDir );
lib64Dir.cdUp();
lib64Dir.cd( "lib64" );
pluginDirs << appDir << libDir << lib64Dir << QDir( qApp->applicationDirPath() );
foreach ( const QDir& pluginDir, pluginDirs )
{
@@ -113,29 +114,31 @@ SipHandler::loadPlugins( const QStringList& paths )
continue;
qDebug() << "Trying to load plugin:" << fileName;
QPluginLoader loader( fileName );
QObject* plugin = loader.instance();
if ( plugin )
{
// Connect via that plugin
qDebug() << "Loaded plugin:" << loader.fileName();
loadPlugin( plugin );
}
else
{
qDebug() << "Error loading library:" << loader.errorString();
}
loadPlugin( fileName );
}
}
void
SipHandler::loadPlugin( QObject* plugin )
SipHandler::loadPlugin( const QString& path )
{
QPluginLoader loader( path );
QObject* plugin = loader.instance();
if ( !plugin )
{
qDebug() << "Error loading plugin:" << loader.errorString();
}
SipPlugin* sip = qobject_cast<SipPlugin*>(plugin);
if ( sip )
{
if ( pluginLoaded( sip->name() ) )
{
qDebug() << "Plugin" << sip->name() << "already loaded! Not loading:" << loader.fileName();
return;
}
qDebug() << "Loaded plugin:" << loader.fileName();
QObject::connect( sip, SIGNAL( peerOnline( QString ) ), SLOT( onPeerOnline( QString ) ) );
QObject::connect( sip, SIGNAL( peerOffline( QString ) ), SLOT( onPeerOffline( QString ) ) );
QObject::connect( sip, SIGNAL( msgReceived( QString, QString ) ), SLOT( onMessage( QString, QString ) ) );
@@ -149,6 +152,19 @@ SipHandler::loadPlugin( QObject* plugin )
}
bool
SipHandler::pluginLoaded( const QString& name ) const
{
foreach( SipPlugin* plugin, m_plugins )
{
if ( plugin->name() == name )
return true;
}
return false;
}
void
SipHandler::connectPlugins( bool startup, const QString &pluginName )
{

View File

@@ -58,8 +58,10 @@ private slots:
private:
QStringList findPlugins();
bool pluginLoaded( const QString& name ) const;
void loadPlugins( const QStringList& paths );
void loadPlugin( QObject* plugin );
void loadPlugin( const QString& path );
QList< SipPlugin* > m_plugins;
bool m_connected;

View File

@@ -70,7 +70,6 @@ TwitterPlugin::isValid()
const QString
TwitterPlugin::name()
{
qDebug() << "TwitterPlugin returning plugin name " << QString( MYNAME );
return QString( MYNAME );
}