1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 19:30:21 +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/ScriptResolver.cpp
resolvers/JSInfoPlugin.cpp
resolvers/ScriptInfoPlugin.cpp
resolvers/JSInfoSystemHelper.cpp
resolvers/JSResolver.cpp
resolvers/JSResolverHelper.cpp

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -16,8 +16,8 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TOMAHAWK_JSINFOPLUGIN_H
#define TOMAHAWK_JSINFOPLUGIN_H
#ifndef TOMAHAWK_SCRIPTINFOPLUGIN_H
#define TOMAHAWK_SCRIPTINFOPLUGIN_H
#include "../infosystem/InfoSystem.h"
@@ -28,10 +28,10 @@ namespace Tomahawk
{
class JSAccount;
class JSInfoPluginPrivate;
class ScriptInfoPluginPrivate;
class DLLEXPORT JSInfoPlugin : public Tomahawk::InfoSystem::InfoPlugin
class DLLEXPORT ScriptInfoPlugin : public Tomahawk::InfoSystem::InfoPlugin
{
Q_OBJECT
@@ -39,8 +39,8 @@ public:
/**
* @param id unique identifier to identify an infoplugin in its scope
*/
JSInfoPlugin( int id, JSAccount* resolver );
virtual ~JSInfoPlugin();
ScriptInfoPlugin( int id, JSAccount* resolver );
virtual ~ScriptInfoPlugin();
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 Tomahawk::InfoSystem::InfoStringHash convertQVariantMapToInfoStringHash( const QVariantMap& map );
Q_DECLARE_PRIVATE( JSInfoPlugin )
QScopedPointer<JSInfoPluginPrivate> d_ptr;
Q_DECLARE_PRIVATE( ScriptInfoPlugin )
QScopedPointer<ScriptInfoPluginPrivate> d_ptr;
};
}; // 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/>.
*/
#ifndef TOMAHAWK_JSINFOPLUGIN_P_H
#define TOMAHAWK_JSINFOPLUGIN_P_H
#ifndef TOMAHAWK_SCRIPTINFOPLUGIN_P_H
#define TOMAHAWK_SCRIPTINFOPLUGIN_P_H
#include "JSInfoPlugin.h"
#include "ScriptInfoPlugin.h"
namespace Tomahawk
{
class JSInfoPluginPrivate
class ScriptInfoPluginPrivate
{
friend class JSInfoPlugin;
friend class ScriptInfoPlugin;
public:
JSInfoPluginPrivate( JSInfoPlugin* q, int id, JSAccount* resolver )
ScriptInfoPluginPrivate( ScriptInfoPlugin* q, int id, JSAccount* resolver )
: q_ptr ( q )
, id( id )
, resolver( resolver )
{
}
JSInfoPlugin* q_ptr;
Q_DECLARE_PUBLIC ( JSInfoPlugin )
ScriptInfoPlugin* q_ptr;
Q_DECLARE_PUBLIC ( ScriptInfoPlugin )
private:
int id;
// HACK: JSInfoPlugin needs to be refactored to track a ScriptObject
// HACK: ScriptInfoPlugin needs to be refactored to track a ScriptObject
JSAccount* resolver;
QMap< int, Tomahawk::InfoSystem::InfoRequestData > requestDataCache;
@@ -48,4 +48,4 @@ private:
} // ns: Tomahawk
#endif // TOMAHAWK_JSINFOPLUGIN_P_H
#endif // TOMAHAWK_SCRIPTINFOPLUGIN_P_H