1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-05 21:57:41 +02:00

Rename JSInfoPlugin to ScriptInfoPlugin

This commit is contained in:
Dominik Schmidt
2015-01-04 15:08:13 +01:00
parent df4abb1ef1
commit 5e5ff7938a
8 changed files with 54 additions and 54 deletions

View File

@@ -84,7 +84,7 @@ set( libGuiSources
resolvers/ExternalResolverGui.cpp resolvers/ExternalResolverGui.cpp
resolvers/ScriptResolver.cpp resolvers/ScriptResolver.cpp
resolvers/JSInfoPlugin.cpp resolvers/ScriptInfoPlugin.cpp
resolvers/JSInfoSystemHelper.cpp resolvers/JSInfoSystemHelper.cpp
resolvers/JSResolver.cpp resolvers/JSResolver.cpp
resolvers/JSResolverHelper.cpp resolvers/JSResolverHelper.cpp

View File

@@ -17,7 +17,7 @@
*/ */
#include "JSInfoSystemHelper_p.h" #include "JSInfoSystemHelper_p.h"
#include "JSInfoPlugin.h" #include "ScriptInfoPlugin.h"
#include "JSAccount.h" #include "JSAccount.h"
#include "../utils/Logger.h" #include "../utils/Logger.h"
@@ -49,14 +49,14 @@ JSInfoSystemHelper::nativeAddInfoPlugin( int id )
Q_D( JSInfoSystemHelper ); Q_D( JSInfoSystemHelper );
// create infoplugin instance // create infoplugin instance
JSInfoPlugin* jsInfoPlugin = new JSInfoPlugin( id, d->scriptAccount ); ScriptInfoPlugin* scriptInfoPlugin = new ScriptInfoPlugin( id, d->scriptAccount );
Tomahawk::InfoSystem::InfoPluginPtr infoPlugin( jsInfoPlugin ); Tomahawk::InfoSystem::InfoPluginPtr infoPlugin( scriptInfoPlugin );
// move it to infosystem thread // move it to infosystem thread
infoPlugin->moveToThread( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().data() ); infoPlugin->moveToThread( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().data() );
// add it to local list of infoplugins // add it to local list of infoplugins
d->infoPlugins[id] = jsInfoPlugin; d->infoPlugins[id] = scriptInfoPlugin;
// add it to infosystem // add it to infosystem
Tomahawk::InfoSystem::InfoSystem::instance()->addInfoPlugin( infoPlugin ); Tomahawk::InfoSystem::InfoSystem::instance()->addInfoPlugin( infoPlugin );

View File

@@ -40,7 +40,7 @@ public:
private: private:
JSAccount* scriptAccount; JSAccount* scriptAccount;
QMap<int,JSInfoPlugin*> infoPlugins; QMap<int,ScriptInfoPlugin*> infoPlugins;
}; };

View File

@@ -42,7 +42,7 @@
#include "TomahawkSettings.h" #include "TomahawkSettings.h"
#include "TomahawkVersion.h" #include "TomahawkVersion.h"
#include "Track.h" #include "Track.h"
#include "JSInfoPlugin.h" #include "ScriptInfoPlugin.h"
#include "JSAccount.h" #include "JSAccount.h"
#include <QDir> #include <QDir>

View File

@@ -33,7 +33,7 @@
namespace Tomahawk namespace Tomahawk
{ {
class JSInfoPlugin; class ScriptInfoPlugin;
class JSResolverHelper; class JSResolverHelper;
class JSResolverPrivate; class JSResolverPrivate;
class ScriptEngine; class ScriptEngine;

View File

@@ -16,7 +16,7 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "JSInfoPlugin_p.h" #include "ScriptInfoPlugin_p.h"
#include "JSAccount.h" #include "JSAccount.h"
#include "Typedefs.h" #include "Typedefs.h"
@@ -26,8 +26,8 @@
using namespace Tomahawk; using namespace Tomahawk;
JSInfoPlugin::JSInfoPlugin( int id, JSAccount *resolver ) ScriptInfoPlugin::ScriptInfoPlugin( int id, JSAccount *resolver )
: d_ptr( new JSInfoPluginPrivate( this, id, resolver ) ) : d_ptr( new ScriptInfoPluginPrivate( this, id, resolver ) )
{ {
Q_ASSERT( resolver ); Q_ASSERT( resolver );
@@ -35,25 +35,25 @@ JSInfoPlugin::JSInfoPlugin( int id, JSAccount *resolver )
m_supportedGetTypes = parseSupportedTypes( callMethodOnInfoPluginWithResult( "supportedGetTypes" ) ); m_supportedGetTypes = parseSupportedTypes( callMethodOnInfoPluginWithResult( "supportedGetTypes" ) );
m_supportedPushTypes = parseSupportedTypes( callMethodOnInfoPluginWithResult( "supportedPushTypes" ) ); m_supportedPushTypes = parseSupportedTypes( callMethodOnInfoPluginWithResult( "supportedPushTypes" ) );
setFriendlyName( QString( "JSInfoPlugin: %1" ).arg( resolver->name() ) ); setFriendlyName( QString( "ScriptInfoPlugin: %1" ).arg( resolver->name() ) );
} }
JSInfoPlugin::~JSInfoPlugin() ScriptInfoPlugin::~ScriptInfoPlugin()
{ {
} }
void void
JSInfoPlugin::init() ScriptInfoPlugin::init()
{ {
} }
void void
JSInfoPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ) ScriptInfoPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
Q_D( JSInfoPlugin ); Q_D( ScriptInfoPlugin );
d->requestDataCache[ requestData.requestId ] = requestData; d->requestDataCache[ requestData.requestId ] = requestData;
@@ -68,7 +68,7 @@ JSInfoPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
void void
JSInfoPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData ) ScriptInfoPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData )
{ {
QString eval = QString( "pushInfo({ type: %1, pushFlags: %2, input: %3, additionalInput: %4})" ) QString eval = QString( "pushInfo({ type: %1, pushFlags: %2, input: %3, additionalInput: %4})" )
.arg( pushData.type ) .arg( pushData.type )
@@ -81,9 +81,9 @@ JSInfoPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData )
void void
JSInfoPlugin::notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) ScriptInfoPlugin::notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
Q_D( JSInfoPlugin ); Q_D( ScriptInfoPlugin );
d->requestDataCache[ requestData.requestId ] = requestData; d->requestDataCache[ requestData.requestId ] = requestData;
d->criteriaCache[ requestData.requestId ] = criteria; d->criteriaCache[ requestData.requestId ] = criteria;
@@ -100,7 +100,7 @@ JSInfoPlugin::notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tom
void void
JSInfoPlugin::addInfoRequestResult( int requestId, qint64 maxAge, const QVariantMap& returnedData ) ScriptInfoPlugin::addInfoRequestResult( int requestId, qint64 maxAge, const QVariantMap& returnedData )
{ {
if ( QThread::currentThread() != thread() ) if ( QThread::currentThread() != thread() )
{ {
@@ -108,7 +108,7 @@ JSInfoPlugin::addInfoRequestResult( int requestId, qint64 maxAge, const QVariant
return; return;
} }
Q_D( JSInfoPlugin ); Q_D( ScriptInfoPlugin );
// retrieve requestData from cache and delete it // retrieve requestData from cache and delete it
Tomahawk::InfoSystem::InfoRequestData requestData = d->requestDataCache[ requestId ]; Tomahawk::InfoSystem::InfoRequestData requestData = d->requestDataCache[ requestId ];
@@ -125,7 +125,7 @@ JSInfoPlugin::addInfoRequestResult( int requestId, qint64 maxAge, const QVariant
void void
JSInfoPlugin::emitGetCachedInfo( int requestId, const QVariantMap& criteria, int newMaxAge ) ScriptInfoPlugin::emitGetCachedInfo( int requestId, const QVariantMap& criteria, int newMaxAge )
{ {
if ( QThread::currentThread() != thread() ) if ( QThread::currentThread() != thread() )
{ {
@@ -133,7 +133,7 @@ JSInfoPlugin::emitGetCachedInfo( int requestId, const QVariantMap& criteria, int
return; return;
} }
Q_D( JSInfoPlugin ); Q_D( ScriptInfoPlugin );
emit getCachedInfo( convertQVariantMapToInfoStringHash( criteria ), newMaxAge, d->requestDataCache[ requestId ]); emit getCachedInfo( convertQVariantMapToInfoStringHash( criteria ), newMaxAge, d->requestDataCache[ requestId ]);
@@ -141,7 +141,7 @@ JSInfoPlugin::emitGetCachedInfo( int requestId, const QVariantMap& criteria, int
void void
JSInfoPlugin::emitInfo( int requestId, const QVariantMap& output ) ScriptInfoPlugin::emitInfo( int requestId, const QVariantMap& output )
{ {
if ( QThread::currentThread() != thread() ) if ( QThread::currentThread() != thread() )
{ {
@@ -149,25 +149,25 @@ JSInfoPlugin::emitInfo( int requestId, const QVariantMap& output )
return; return;
} }
Q_D( JSInfoPlugin ); Q_D( ScriptInfoPlugin );
emit info( d->requestDataCache[ requestId ], output ); emit info( d->requestDataCache[ requestId ], output );
} }
QString QString
JSInfoPlugin::serviceGetter() const ScriptInfoPlugin::serviceGetter() const
{ {
Q_D( const JSInfoPlugin ); Q_D( const ScriptInfoPlugin );
return QString( "Tomahawk.InfoSystem.getInfoPlugin(%1)" ).arg( d->id ); return QString( "Tomahawk.InfoSystem.getInfoPlugin(%1)" ).arg( d->id );
} }
// TODO: DRY, really move things into base class // TODO: DRY, really move things into base class
void void
JSInfoPlugin::callMethodOnInfoPlugin( const QString& scriptSource ) ScriptInfoPlugin::callMethodOnInfoPlugin( const QString& scriptSource )
{ {
Q_D( JSInfoPlugin ); Q_D( ScriptInfoPlugin );
QString eval = QString( "%1.%2" ).arg( serviceGetter() ).arg( scriptSource ); QString eval = QString( "%1.%2" ).arg( serviceGetter() ).arg( scriptSource );
@@ -178,9 +178,9 @@ JSInfoPlugin::callMethodOnInfoPlugin( const QString& scriptSource )
QVariant QVariant
JSInfoPlugin::callMethodOnInfoPluginWithResult(const QString& scriptSource) ScriptInfoPlugin::callMethodOnInfoPluginWithResult(const QString& scriptSource)
{ {
Q_D( JSInfoPlugin ); Q_D( ScriptInfoPlugin );
QString eval = QString( "%1.%2" ).arg( serviceGetter() ).arg( scriptSource ); QString eval = QString( "%1.%2" ).arg( serviceGetter() ).arg( scriptSource );
@@ -192,7 +192,7 @@ JSInfoPlugin::callMethodOnInfoPluginWithResult(const QString& scriptSource)
QSet< Tomahawk::InfoSystem::InfoType > QSet< Tomahawk::InfoSystem::InfoType >
JSInfoPlugin::parseSupportedTypes( const QVariant& variant ) ScriptInfoPlugin::parseSupportedTypes( const QVariant& variant )
{ {
QVariantList list = variant.toList(); QVariantList list = variant.toList();
@@ -213,7 +213,7 @@ JSInfoPlugin::parseSupportedTypes( const QVariant& variant )
QString QString
JSInfoPlugin::serializeQVariantMap( const QVariantMap& map ) ScriptInfoPlugin::serializeQVariantMap( const QVariantMap& map )
{ {
QVariantMap localMap = map; QVariantMap localMap = map;
@@ -234,7 +234,7 @@ JSInfoPlugin::serializeQVariantMap( const QVariantMap& map )
QVariantMap QVariantMap
JSInfoPlugin::convertInfoStringHashToQVariantMap( const Tomahawk::InfoSystem::InfoStringHash& hash ) ScriptInfoPlugin::convertInfoStringHashToQVariantMap( const Tomahawk::InfoSystem::InfoStringHash& hash )
{ {
QVariantMap map; QVariantMap map;
@@ -248,7 +248,7 @@ JSInfoPlugin::convertInfoStringHashToQVariantMap( const Tomahawk::InfoSystem::In
Tomahawk::InfoSystem::InfoStringHash Tomahawk::InfoSystem::InfoStringHash
JSInfoPlugin::convertQVariantMapToInfoStringHash( const QVariantMap& map ) ScriptInfoPlugin::convertQVariantMapToInfoStringHash( const QVariantMap& map )
{ {
Tomahawk::InfoSystem::InfoStringHash hash; Tomahawk::InfoSystem::InfoStringHash hash;

View File

@@ -16,8 +16,8 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TOMAHAWK_JSINFOPLUGIN_H #ifndef TOMAHAWK_SCRIPTINFOPLUGIN_H
#define TOMAHAWK_JSINFOPLUGIN_H #define TOMAHAWK_SCRIPTINFOPLUGIN_H
#include "../infosystem/InfoSystem.h" #include "../infosystem/InfoSystem.h"
@@ -28,10 +28,10 @@ namespace Tomahawk
{ {
class JSAccount; class JSAccount;
class JSInfoPluginPrivate; class ScriptInfoPluginPrivate;
class DLLEXPORT JSInfoPlugin : public Tomahawk::InfoSystem::InfoPlugin class DLLEXPORT ScriptInfoPlugin : public Tomahawk::InfoSystem::InfoPlugin
{ {
Q_OBJECT Q_OBJECT
@@ -39,8 +39,8 @@ public:
/** /**
* @param id unique identifier to identify an infoplugin in its scope * @param id unique identifier to identify an infoplugin in its scope
*/ */
JSInfoPlugin( int id, JSAccount* resolver ); ScriptInfoPlugin( int id, JSAccount* resolver );
virtual ~JSInfoPlugin(); virtual ~ScriptInfoPlugin();
Q_INVOKABLE void addInfoRequestResult( int requestId, qint64 maxAge, const QVariantMap& returnedData ); Q_INVOKABLE void addInfoRequestResult( int requestId, qint64 maxAge, const QVariantMap& returnedData );
@@ -66,10 +66,10 @@ private:
static QVariantMap convertInfoStringHashToQVariantMap(const Tomahawk::InfoSystem::InfoStringHash& hash); static QVariantMap convertInfoStringHashToQVariantMap(const Tomahawk::InfoSystem::InfoStringHash& hash);
static Tomahawk::InfoSystem::InfoStringHash convertQVariantMapToInfoStringHash( const QVariantMap& map ); static Tomahawk::InfoSystem::InfoStringHash convertQVariantMapToInfoStringHash( const QVariantMap& map );
Q_DECLARE_PRIVATE( JSInfoPlugin ) Q_DECLARE_PRIVATE( ScriptInfoPlugin )
QScopedPointer<JSInfoPluginPrivate> d_ptr; QScopedPointer<ScriptInfoPluginPrivate> d_ptr;
}; };
}; // ns: Tomahawk }; // ns: Tomahawk
#endif // TOMAHAWK_JSINFOPLUGIN_H #endif // TOMAHAWK_SCRIPTINFOPLUGIN_H

View File

@@ -16,30 +16,30 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TOMAHAWK_JSINFOPLUGIN_P_H #ifndef TOMAHAWK_SCRIPTINFOPLUGIN_P_H
#define TOMAHAWK_JSINFOPLUGIN_P_H #define TOMAHAWK_SCRIPTINFOPLUGIN_P_H
#include "JSInfoPlugin.h" #include "ScriptInfoPlugin.h"
namespace Tomahawk namespace Tomahawk
{ {
class JSInfoPluginPrivate class ScriptInfoPluginPrivate
{ {
friend class JSInfoPlugin; friend class ScriptInfoPlugin;
public: public:
JSInfoPluginPrivate( JSInfoPlugin* q, int id, JSAccount* resolver ) ScriptInfoPluginPrivate( ScriptInfoPlugin* q, int id, JSAccount* resolver )
: q_ptr ( q ) : q_ptr ( q )
, id( id ) , id( id )
, resolver( resolver ) , resolver( resolver )
{ {
} }
JSInfoPlugin* q_ptr; ScriptInfoPlugin* q_ptr;
Q_DECLARE_PUBLIC ( JSInfoPlugin ) Q_DECLARE_PUBLIC ( ScriptInfoPlugin )
private: private:
int id; int id;
// HACK: JSInfoPlugin needs to be refactored to track a ScriptObject // HACK: ScriptInfoPlugin needs to be refactored to track a ScriptObject
JSAccount* resolver; JSAccount* resolver;
QMap< int, Tomahawk::InfoSystem::InfoRequestData > requestDataCache; QMap< int, Tomahawk::InfoSystem::InfoRequestData > requestDataCache;
@@ -48,4 +48,4 @@ private:
} // ns: Tomahawk } // ns: Tomahawk
#endif // TOMAHAWK_JSINFOPLUGIN_P_H #endif // TOMAHAWK_SCRIPTINFOPLUGIN_P_H