Plugin: cleanup & coding style fixes
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
#ifndef SINGLE_SOURCE_COMPILE
|
||||
|
||||
/*
|
||||
* Plugin.cpp - implementation of plugin-class including plugin-loader
|
||||
*
|
||||
* Copyright (c) 2005-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
* Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -55,9 +53,9 @@ static Plugin::Descriptor dummy_plugin_descriptor =
|
||||
|
||||
|
||||
|
||||
Plugin::Plugin( const Descriptor * _descriptor, Model * _parent ) :
|
||||
Plugin::Plugin( const Descriptor * _descriptor, Model * parent ) :
|
||||
JournallingObject(),
|
||||
Model( _parent ),
|
||||
Model( parent ),
|
||||
m_descriptor( _descriptor )
|
||||
{
|
||||
if( m_descriptor == NULL )
|
||||
@@ -92,86 +90,80 @@ AutomatableModel * Plugin::childModel( const QString & )
|
||||
|
||||
|
||||
|
||||
Plugin * Plugin::instantiate( const QString & _plugin_name, Model * _parent,
|
||||
void * _data )
|
||||
Plugin * Plugin::instantiate( const QString & pluginName, Model * parent,
|
||||
void * data )
|
||||
{
|
||||
QLibrary plugin_lib( configManager::inst()->pluginDir() +
|
||||
_plugin_name );
|
||||
if( plugin_lib.load() == false )
|
||||
QLibrary pluginLibrary( configManager::inst()->pluginDir() + pluginName );
|
||||
if( pluginLibrary.load() == false )
|
||||
{
|
||||
if( engine::hasGUI() )
|
||||
{
|
||||
QMessageBox::information( NULL,
|
||||
tr( "Plugin not found" ),
|
||||
tr( "The plugin \"%1\" wasn't found "
|
||||
"or could not be loaded!\n"
|
||||
"Reason: \"%2\"" ).arg( _plugin_name ).
|
||||
arg( plugin_lib.errorString() ),
|
||||
QMessageBox::Ok |
|
||||
QMessageBox::Default );
|
||||
tr( "The plugin \"%1\" wasn't found or could not be loaded!\nReason: \"%2\"" ).
|
||||
arg( pluginName ).arg( pluginLibrary.errorString() ),
|
||||
QMessageBox::Ok | QMessageBox::Default );
|
||||
}
|
||||
return new DummyPlugin();
|
||||
}
|
||||
instantiationHook inst_hook = ( instantiationHook ) plugin_lib.resolve(
|
||||
"lmms_plugin_main" );
|
||||
if( inst_hook == NULL )
|
||||
|
||||
InstantiationHook instantiationHook = ( InstantiationHook ) pluginLibrary.resolve( "lmms_plugin_main" );
|
||||
if( instantiationHook == NULL )
|
||||
{
|
||||
if( engine::hasGUI() )
|
||||
{
|
||||
QMessageBox::information( NULL,
|
||||
tr( "Error while loading plugin" ),
|
||||
tr( "Failed to load plugin \"%1\"!"
|
||||
).arg( _plugin_name ),
|
||||
QMessageBox::Ok |
|
||||
QMessageBox::Default );
|
||||
tr( "Failed to load plugin \"%1\"!").arg( pluginName ),
|
||||
QMessageBox::Ok | QMessageBox::Default );
|
||||
}
|
||||
return new DummyPlugin();
|
||||
}
|
||||
Plugin * inst = inst_hook( _parent, _data );
|
||||
|
||||
Plugin * inst = instantiationHook( parent, data );
|
||||
return inst;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Plugin::getDescriptorsOfAvailPlugins( DescriptorList & _plugin_descs )
|
||||
void Plugin::getDescriptorsOfAvailPlugins( DescriptorList& pluginDescriptors )
|
||||
{
|
||||
QDir directory( configManager::inst()->pluginDir() );
|
||||
#ifdef LMMS_BUILD_WIN32
|
||||
QFileInfoList list = directory.entryInfoList(
|
||||
QStringList( "*.dll" ) );
|
||||
QFileInfoList list = directory.entryInfoList( QStringList( "*.dll" ) );
|
||||
#else
|
||||
QFileInfoList list = directory.entryInfoList(
|
||||
QStringList( "lib*.so" ) );
|
||||
QFileInfoList list = directory.entryInfoList( QStringList( "lib*.so" ) );
|
||||
#endif
|
||||
foreach( const QFileInfo & f, list )
|
||||
foreach( const QFileInfo& f, list )
|
||||
{
|
||||
QLibrary( f.absoluteFilePath() ).load();
|
||||
}
|
||||
|
||||
foreach( const QFileInfo & f, list )
|
||||
foreach( const QFileInfo& f, list )
|
||||
{
|
||||
QLibrary plugin_lib( f.absoluteFilePath() );
|
||||
if( plugin_lib.load() == false ||
|
||||
plugin_lib.resolve( "lmms_plugin_main" ) == NULL )
|
||||
QLibrary pluginLibrary( f.absoluteFilePath() );
|
||||
if( pluginLibrary.load() == false ||
|
||||
pluginLibrary.resolve( "lmms_plugin_main" ) == NULL )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QString desc_name = f.baseName() + "_plugin_descriptor";
|
||||
if( desc_name.left( 3 ) == "lib" )
|
||||
|
||||
QString descriptorName = f.baseName() + "_plugin_descriptor";
|
||||
if( descriptorName.left( 3 ) == "lib" )
|
||||
{
|
||||
desc_name = desc_name.mid( 3 );
|
||||
descriptorName = descriptorName.mid( 3 );
|
||||
}
|
||||
Descriptor * plugin_desc =
|
||||
(Descriptor *) plugin_lib.resolve(
|
||||
desc_name.toUtf8().constData() );
|
||||
if( plugin_desc == NULL )
|
||||
|
||||
Descriptor* pluginDescriptor = (Descriptor *) pluginLibrary.resolve( descriptorName.toUtf8().constData() );
|
||||
if( pluginDescriptor == NULL )
|
||||
{
|
||||
qWarning() << tr( "LMMS plugin %1 does not have a plugin descriptor named %2!" ).
|
||||
arg( f.absoluteFilePath() ).arg( desc_name );
|
||||
arg( f.absoluteFilePath() ).arg( descriptorName );
|
||||
continue;
|
||||
}
|
||||
_plugin_descs.push_back( *plugin_desc );
|
||||
|
||||
pluginDescriptors += *pluginDescriptor;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -179,9 +171,9 @@ void Plugin::getDescriptorsOfAvailPlugins( DescriptorList & _plugin_descs )
|
||||
|
||||
|
||||
|
||||
PluginView * Plugin::createView( QWidget * _parent )
|
||||
PluginView * Plugin::createView( QWidget * parent )
|
||||
{
|
||||
PluginView * pv = instantiateView( _parent );
|
||||
PluginView * pv = instantiateView( parent );
|
||||
if( pv != NULL )
|
||||
{
|
||||
pv->setModel( this );
|
||||
@@ -225,4 +217,3 @@ QDomElement Plugin::Descriptor::SubPluginFeatures::Key::saveXML(
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user