fixed plugin loading

Conflicts:
	src/core/plugins/plugins.cpp
	src/core/plugins/plugins.h
This commit is contained in:
Patrick von Reth 2014-02-15 19:42:57 +01:00
parent 58f95602ce
commit 8522a1fd4f
3 changed files with 52 additions and 23 deletions

View File

@ -118,6 +118,26 @@ SnoreSecondaryBackend::~SnoreSecondaryBackend()
snoreDebug( SNORE_DEBUG )<<"Deleting"<<name();
}
bool SnoreSecondaryBackend::initialize(SnoreCore *snore)
{
if(!SnorePlugin::initialize(snore))
{
return false;
}
connect( snore->d(), SIGNAL(notify(Snore::Notification)), this, SLOT(slotNotify(Snore::Notification)));
return true;
}
bool SnoreSecondaryBackend::deinitialize()
{
if(SnorePlugin::deinitialize())
{
disconnect( snore()->d(), SIGNAL(notify(Snore::Notification)), this, SLOT(slotNotify(Snore::Notification)));
return true;
}
return false;
}
bool SnoreSecondaryBackend::supportsRichtext()
{
return m_supportsRichtext;

View File

@ -92,6 +92,8 @@ class SNORE_EXPORT SnoreSecondaryBackend : public SnorePlugin
public:
SnoreSecondaryBackend(const QString &name, bool supportsRhichtext);
virtual ~SnoreSecondaryBackend();
virtual bool initialize(SnoreCore *snore);
virtual bool deinitialize();
bool supportsRichtext();

View File

@ -55,32 +55,39 @@ SnoreCore::~SnoreCore()
void SnoreCore::loadPlugins( SnorePlugin::PluginTypes types )
{
Q_D(SnoreCore);
foreach( PluginContainer *info, PluginContainer::pluginCache(types).values())
{
switch(info->type())
{
case SnorePlugin::BACKEND:
break;
case SnorePlugin::SECONDARY_BACKEND:
case SnorePlugin::FRONTEND:
case SnorePlugin::PLUGIN:
if(!info->load()->initialize( this ))
{
info->unload();
break;
}
break;
default:
snoreDebug( SNORE_WARNING ) << "Plugin Cache corrupted\n" << info->file() << info->type();
continue;
}
snoreDebug( SNORE_DEBUG ) << info->name() << "is a" << info->type();
d->m_plugins[info->type()].append(info->name());
}
foreach( SnorePlugin::PluginTypes type, PluginContainer::types())
{
qSort(d->m_plugins[type]);
if(type!= SnorePlugin::ALL && types && type)
{
foreach( PluginContainer *info, PluginContainer::pluginCache(type).values())
{
switch(info->type())
{
case SnorePlugin::BACKEND:
break;
case SnorePlugin::SECONDARY_BACKEND:
case SnorePlugin::FRONTEND:
case SnorePlugin::PLUGIN:
if(!info->load()->initialize( this ))
{
info->unload();
break;
}
break;
default:
snoreDebug( SNORE_WARNING ) << "Plugin Cache corrupted\n" << info->file() << info->type();
continue;
}
snoreDebug( SNORE_DEBUG ) << info->name() << "is a" << info->type();
d->m_plugins[info->type()].append(info->name());
}
if(d->m_plugins.contains(type))
{
qSort(d->m_plugins[type]);
}
}
}
snoreDebug( SNORE_INFO ) << "Loaded Plugins:" << d->m_plugins;
}