1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-02 20:28:14 +02:00

Move HypemPlugin over to new plugin paradigm

This commit is contained in:
Jeff Mitchell
2012-05-14 12:34:48 -04:00
parent 3e60adfe37
commit 50fbe986d7
6 changed files with 78 additions and 24 deletions

View File

@@ -1 +1,2 @@
ADD_SUBDIRECTORY( echonest ) ADD_SUBDIRECTORY( echonest )
ADD_SUBDIRECTORY( hypem )

View File

@@ -0,0 +1,43 @@
project( tomahawk )
include( ${QT_USE_FILE} )
add_definitions( ${QT_DEFINITIONS} )
add_definitions( -DQT_PLUGIN )
add_definitions( -DQT_SHARED )
add_definitions( -DINFOPLUGINDLLEXPORT_PRO )
set( hypemInfoPluginSources
HypemPlugin.cpp
)
set( hypemInfoPluginHeaders
HypemPlugin.h
)
include_directories(
${QT_INCLUDE_DIR}
)
qt4_wrap_cpp( hypemInfoPluginMoc ${hypemInfoPluginHeaders} )
add_library( tomahawk_infoplugin_hypem SHARED ${hypemInfoPluginSources} ${hypemInfoPluginMoc} ${RC_SRCS} )
IF( WIN32 )
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
"winmm.dll"
"iphlpapi.a"
)
ENDIF( WIN32 )
target_link_libraries( tomahawk_infoplugin_hypem
${TOMAHAWK_LIBRARIES}
${QT_LIBRARIES}
${OS_SPECIFIC_LINK_LIBRARIES}
)
IF( APPLE )
# SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" )
ENDIF( APPLE )
install( TARGETS tomahawk_infoplugin_hypem DESTINATION ${CMAKE_INSTALL_LIBDIR} )

View File

@@ -17,13 +17,14 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "hypemPlugin.h" #include "HypemPlugin.h"
#include <QDir> #include <QDir>
#include <QSettings> #include <QSettings>
#include <QCryptographicHash> #include <QCryptographicHash>
#include <QNetworkConfiguration> #include <QNetworkConfiguration>
#include <QNetworkReply> #include <QNetworkReply>
#include <QtPlugin>
#include "Album.h" #include "Album.h"
#include "Typedefs.h" #include "Typedefs.h"
@@ -36,10 +37,14 @@
#include <qjson/parser.h> #include <qjson/parser.h>
#include <qjson/serializer.h> #include <qjson/serializer.h>
using namespace Tomahawk::InfoSystem; namespace Tomahawk
{
namespace InfoSystem
{
hypemPlugin::hypemPlugin() HypemPlugin::HypemPlugin()
: InfoPlugin() : InfoPlugin()
, m_chartsFetchJobs( 0 ) , m_chartsFetchJobs( 0 )
{ {
@@ -95,14 +100,14 @@ hypemPlugin::hypemPlugin()
hypemPlugin::~hypemPlugin() HypemPlugin::~HypemPlugin()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
} }
void void
hypemPlugin::dataError( Tomahawk::InfoSystem::InfoRequestData requestData ) HypemPlugin::dataError( Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
emit info( requestData, QVariant() ); emit info( requestData, QVariant() );
return; return;
@@ -110,7 +115,7 @@ hypemPlugin::dataError( Tomahawk::InfoSystem::InfoRequestData requestData )
void void
hypemPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ) HypemPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
qDebug() << Q_FUNC_INFO << requestData.caller; qDebug() << Q_FUNC_INFO << requestData.caller;
qDebug() << Q_FUNC_INFO << requestData.customData; qDebug() << Q_FUNC_INFO << requestData.customData;
@@ -140,7 +145,7 @@ hypemPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
} }
void void
hypemPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData ) HypemPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() ) if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
@@ -168,7 +173,7 @@ hypemPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData )
} }
void void
hypemPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requestData ) HypemPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() ) if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
{ {
@@ -181,7 +186,7 @@ hypemPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData reque
} }
void void
hypemPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) HypemPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
switch ( requestData.type ) switch ( requestData.type )
{ {
@@ -225,9 +230,9 @@ hypemPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSys
void void
hypemPlugin::chartTypes() HypemPlugin::chartTypes()
{ {
/// Get possible chart type for specifichypemPlugin: InfoChart types returned chart source /// Get possible chart type for specificHypemPlugin: InfoChart types returned chart source
tDebug() << Q_FUNC_INFO << "Got hypem types"; tDebug() << Q_FUNC_INFO << "Got hypem types";
QVariantMap charts; QVariantMap charts;
@@ -295,13 +300,13 @@ hypemPlugin::chartTypes()
m_allChartsMap.insert( "Hype Machine", QVariant::fromValue<QVariantMap>( charts ) ); m_allChartsMap.insert( "Hype Machine", QVariant::fromValue<QVariantMap>( charts ) );
qDebug() << "hypemPlugin:Chartstype: " << m_allChartsMap; qDebug() << "HypemPlugin:Chartstype: " << m_allChartsMap;
} }
void void
hypemPlugin::chartReturned() HypemPlugin::chartReturned()
{ {
/// Chart request returned something! Woho /// Chart request returned something! Woho
@@ -387,3 +392,9 @@ hypemPlugin::chartReturned()
qDebug() << "Network error in fetching chart:" << reply->url().toString(); qDebug() << "Network error in fetching chart:" << reply->url().toString();
} }
}
}
Q_EXPORT_PLUGIN2( Tomahawk::InfoSystem::InfoPlugin, Tomahawk::InfoSystem::HypemPlugin )

View File

@@ -17,9 +17,10 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef hypemPlugin_H #ifndef HYPEMPLUGIN_H
#define hypemPlugin_H #define HYPEMPLUGIN_H
#include "infoplugins/InfoPluginDllMacro.h"
#include "infosystem/InfoSystem.h" #include "infosystem/InfoSystem.h"
#include "infosystem/InfoSystemWorker.h" #include "infosystem/InfoSystemWorker.h"
#include <QNetworkReply> #include <QNetworkReply>
@@ -33,13 +34,14 @@ namespace Tomahawk
namespace InfoSystem namespace InfoSystem
{ {
class hypemPlugin : public InfoPlugin class INFOPLUGINDLLEXPORT HypemPlugin : public InfoPlugin
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES( Tomahawk::InfoSystem::InfoPlugin )
public: public:
hypemPlugin(); HypemPlugin();
virtual ~hypemPlugin(); virtual ~HypemPlugin();
enum ChartType { enum ChartType {
None = 0x00, None = 0x00,
@@ -91,4 +93,4 @@ private:
} }
#endif // hypemPlugin_H #endif // HYPEMPLUGIN_H

View File

@@ -257,7 +257,6 @@ set( libSources
infosystem/infoplugins/generic/ChartsPlugin.cpp infosystem/infoplugins/generic/ChartsPlugin.cpp
infosystem/infoplugins/generic/NewReleasesPlugin.cpp infosystem/infoplugins/generic/NewReleasesPlugin.cpp
infosystem/infoplugins/generic/spotifyPlugin.cpp infosystem/infoplugins/generic/spotifyPlugin.cpp
infosystem/infoplugins/generic/hypemPlugin.cpp
infosystem/infoplugins/generic/MusixMatchPlugin.cpp infosystem/infoplugins/generic/MusixMatchPlugin.cpp
infosystem/infoplugins/generic/musicbrainzPlugin.cpp infosystem/infoplugins/generic/musicbrainzPlugin.cpp
infosystem/infoplugins/generic/RoviPlugin.cpp infosystem/infoplugins/generic/RoviPlugin.cpp

View File

@@ -35,7 +35,6 @@
#include "infoplugins/generic/NewReleasesPlugin.h" #include "infoplugins/generic/NewReleasesPlugin.h"
#include "infoplugins/generic/spotifyPlugin.h" #include "infoplugins/generic/spotifyPlugin.h"
#include "infoplugins/generic/musicbrainzPlugin.h" #include "infoplugins/generic/musicbrainzPlugin.h"
#include "infoplugins/generic/hypemPlugin.h"
#include "GlobalActionManager.h" #include "GlobalActionManager.h"
#include "utils/TomahawkUtils.h" #include "utils/TomahawkUtils.h"
#include "utils/Logger.h" #include "utils/Logger.h"
@@ -96,7 +95,6 @@ InfoSystemWorker::init( Tomahawk::InfoSystem::InfoSystemCache* cache )
addInfoPlugin( InfoPluginPtr( new NewReleasesPlugin() ) ); addInfoPlugin( InfoPluginPtr( new NewReleasesPlugin() ) );
addInfoPlugin( InfoPluginPtr( new RoviPlugin() ) ); addInfoPlugin( InfoPluginPtr( new RoviPlugin() ) );
addInfoPlugin( InfoPluginPtr( new SpotifyPlugin() ) ); addInfoPlugin( InfoPluginPtr( new SpotifyPlugin() ) );
addInfoPlugin( InfoPluginPtr( new hypemPlugin() ) );
#endif #endif
#ifdef Q_WS_MAC #ifdef Q_WS_MAC