[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [amarok] src: Refactoring: Use KPluginInfo property to identify vital plugins
From: Ralf Engels <ralf-engels () gmx ! de>
Date: 2015-01-17 18:12:20
Message-ID: E1YCXrA-000431-4c () scm ! kde ! org
[Download RAW message or body]
Git commit cf0cf8f6a3ea23715f48a66801f1c4f7e9976beb by Ralf Engels.
Committed on 29/12/2014 at 11:37.
Pushed by rengels into branch 'master'.
Refactoring: Use KPluginInfo property to identify vital plugins
Instead of using their name use the plugin info and a new vital
attribute to identify plugins that cannot be switched off.
M +5 -15 src/PluginManager.cpp
M +3 -0 src/amarok_plugin.desktop
M +1 -0 src/core-impl/collections/db/sql/mysqlcollection/amarok_collection-mysqlcollection.desktop
M +2 -13 src/core-impl/collections/support/CollectionManager.cpp
M +4 -1 src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorageFactory.cpp
M +1 -0 src/core-impl/storage/sql/mysqlestorage/amarok_storage-mysqlestorage.desktop
M +4 -1 src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorageFactory.cpp
M +1 -0 src/core-impl/storage/sql/mysqlserverstorage/amarok_storage-mysqlserverstorage.desktop
http://commits.kde.org/amarok/cf0cf8f6a3ea23715f48a66801f1c4f7e9976beb
diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp
index 4f19047..9148041 100644
--- a/src/PluginManager.cpp
+++ b/src/PluginManager.cpp
@@ -184,26 +184,15 @@ Plugins::PluginManager::checkPluginEnabledStates()
bool
Plugins::PluginManager::isPluginEnabled( const KPluginInfo &pluginInfo ) const
{
- const QString pluginName = pluginInfo.pluginName();
-
- // The type of storage to be used it determined by the configuration
- const bool useMySqlServer = Amarok::config( "MySQL" ).readEntry( "UseServer", \
false );
- if( pluginName == QLatin1String("amarok_storage-mysqlserverstorage") )
- {
- return useMySqlServer;
- }
- else if( pluginName == QLatin1String("amarok_storage-mysqlestorage") )
- {
- return !useMySqlServer;
- }
- // we the default collection is always enabled
- else if( pluginName == QLatin1String("amarok_collection-mysqlcollection") )
+ // mysql storage and collection are vital. They need to be loaded always
+ if( pluginInfo.property("X-KDE-Amarok-vital").toBool() )
{
return true;
}
else
{
- bool enabledByDefault = pluginInfo.isPluginEnabledByDefault();
+ const QString pluginName = pluginInfo.pluginName();
+ const bool enabledByDefault = pluginInfo.isPluginEnabledByDefault();
return Amarok::config( "Plugins" ).readEntry( pluginName + "Enabled", \
enabledByDefault ); }
}
@@ -244,6 +233,7 @@ Plugins::PluginManager::createFactory( const KPluginInfo \
&pluginInfo ) }
debug() << "created factory for plugin" << name << "type:" << \
pluginInfo.category(); + debug() << "is vital?" << \
pluginInfo.property("X-KDE-Amarok-vital").toBool(); m_factoryCreated[ \
pluginInfo.pluginName() ] = factory; return factory;
}
diff --git a/src/amarok_plugin.desktop b/src/amarok_plugin.desktop
index fbdd3f1..a2f7801 100644
--- a/src/amarok_plugin.desktop
+++ b/src/amarok_plugin.desktop
@@ -94,3 +94,6 @@ Type=int
[PropertyDef::X-KDE-Amarok-experimental]
Type=bool
+# If true, Amarok will always initialize this plugin indepenent of the configuration
+[PropertyDef::X-KDE-Amarok-vital]
+Type=bool
diff --git a/src/core-impl/collections/db/sql/mysqlcollection/amarok_collection-mysqlcollection.desktop \
b/src/core-impl/collections/db/sql/mysqlcollection/amarok_collection-mysqlcollection.desktop
index dc8fe5c..c98a27c 100644
--- a/src/core-impl/collections/db/sql/mysqlcollection/amarok_collection-mysqlcollection.desktop
+++ b/src/core-impl/collections/db/sql/mysqlcollection/amarok_collection-mysqlcollection.desktop
@@ -119,6 +119,7 @@ X-KDE-Amarok-name=mysql-collection
X-KDE-Amarok-plugintype=collection
X-KDE-Amarok-rank=100
X-KDE-Amarok-version=1
+X-KDE-Amarok-vital=true
X-KDE-PluginInfo-Author=Maximilian Kossick
X-KDE-PluginInfo-Email=maximilian.kossick@googlemail.com
diff --git a/src/core-impl/collections/support/CollectionManager.cpp \
b/src/core-impl/collections/support/CollectionManager.cpp index a3d90ff..b96f952 \
100644
--- a/src/core-impl/collections/support/CollectionManager.cpp
+++ b/src/core-impl/collections/support/CollectionManager.cpp
@@ -160,22 +160,11 @@ CollectionManager::setFactories( const \
QList<Plugins::PluginFactory*> &factories if( !factory )
continue;
- const KPluginInfo info = factory->info();
- const QString pluginName = info.pluginName();
- const bool useMySqlServer = Amarok::config( "MySQL" ).readEntry( \
"UseServer", false );
-
- // the sql collection is a core collection. It cannot be switched off
- // and should be first.
- bool primaryCollection = ( pluginName == \
QLatin1String("amarok_collection-mysqlcollection") );
-
connect( factory, SIGNAL(newCollection(Collections::Collection*)),
this, SLOT(slotNewCollection(Collections::Collection*)) );
{
- QWriteLocker locker( &d->lock );
- if( primaryCollection )
- d->factories.prepend( factory );
- else
- d->factories.append( factory );
+ QWriteLocker locker( &d->lock );
+ d->factories.append( factory );
}
}
diff --git a/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorageFactory.cpp \
b/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorageFactory.cpp index \
bb65e87..abfda86 100644
--- a/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorageFactory.cpp
+++ b/src/core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorageFactory.cpp
@@ -17,6 +17,8 @@
#include "MySqlEmbeddedStorageFactory.h"
#include "MySqlEmbeddedStorage.h"
+#include <core/support/Amarok.h>
+
AMAROK_EXPORT_STORAGE( MySqleStorageFactory, mysqlestorage )
MySqleStorageFactory::MySqleStorageFactory( QObject *parent, const QVariantList \
&args ) @@ -37,7 +39,8 @@ MySqleStorageFactory::init()
m_initialized = true;
- emit newStorage( new MySqlEmbeddedStorage() );
+ if( ! Amarok::config( "MySQL" ).readEntry( "UseServer", false ) )
+ emit newStorage( new MySqlEmbeddedStorage() );
}
#include "MySqlEmbeddedStorageFactory.moc"
diff --git a/src/core-impl/storage/sql/mysqlestorage/amarok_storage-mysqlestorage.desktop \
b/src/core-impl/storage/sql/mysqlestorage/amarok_storage-mysqlestorage.desktop index \
515e036..462381a 100644
--- a/src/core-impl/storage/sql/mysqlestorage/amarok_storage-mysqlestorage.desktop
+++ b/src/core-impl/storage/sql/mysqlestorage/amarok_storage-mysqlestorage.desktop
@@ -16,6 +16,7 @@ X-KDE-Amarok-name=mysqle-storage
X-KDE-Amarok-plugintype=storage
X-KDE-Amarok-rank=100
X-KDE-Amarok-version=1
+X-KDE-Amarok-vital=true
X-KDE-PluginInfo-Author=Ralf Engels
X-KDE-PluginInfo-Email=ralf.engels@gmx.de
diff --git a/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorageFactory.cpp \
b/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorageFactory.cpp index \
5421763..86802fe 100644
--- a/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorageFactory.cpp
+++ b/src/core-impl/storage/sql/mysqlserverstorage/MySqlServerStorageFactory.cpp
@@ -17,6 +17,8 @@
#include "MySqlServerStorageFactory.h"
#include "MySqlServerStorage.h"
+#include <core/support/Amarok.h>
+
AMAROK_EXPORT_STORAGE( MySqlServerStorageFactory, mysqlserverstorage )
MySqlServerStorageFactory::MySqlServerStorageFactory( QObject *parent, const \
QVariantList &args ) @@ -37,7 +39,8 @@ MySqlServerStorageFactory::init()
m_initialized = true;
- emit newStorage( new MySqlServerStorage() );
+ if( Amarok::config( "MySQL" ).readEntry( "UseServer", false ) )
+ emit newStorage( new MySqlServerStorage() );
}
#include "MySqlServerStorageFactory.moc"
diff --git a/src/core-impl/storage/sql/mysqlserverstorage/amarok_storage-mysqlserverstorage.desktop \
b/src/core-impl/storage/sql/mysqlserverstorage/amarok_storage-mysqlserverstorage.desktop
index 9272126..b4ae0db 100644
--- a/src/core-impl/storage/sql/mysqlserverstorage/amarok_storage-mysqlserverstorage.desktop
+++ b/src/core-impl/storage/sql/mysqlserverstorage/amarok_storage-mysqlserverstorage.desktop
@@ -16,6 +16,7 @@ X-KDE-Amarok-name=mysqlserver-storage
X-KDE-Amarok-plugintype=storage
X-KDE-Amarok-rank=100
X-KDE-Amarok-version=1
+X-KDE-Amarok-vital=true
X-KDE-PluginInfo-Author=Ralf Engels
X-KDE-PluginInfo-Email=ralf.engels@gmx.de
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic