ScrobblerAdapter::ScrobblerAdapter( const QString &clientId, const LastFmServiceConfigPtr &config ) : m_scrobbler( clientId ) , m_config( config ) { // work around a bug in liblastfm -- -it doesn't create its config dir, so when it // tries to write the track cache, it fails silently. Last check: liblastfm 1.0.! QList<QDir> dirs; dirs << lastfm::dir::runtimeData() << lastfm::dir::cache() << lastfm::dir::logs(); foreach( QDir dir, dirs ) { if( !dir.exists() ) { debug() << "creating" << dir.absolutePath() << "directory for liblastfm"; dir.mkpath( "." ); } } connect( The::mainWindow(), SIGNAL(loveTrack(Meta::TrackPtr)), SLOT(loveTrack(Meta::TrackPtr)) ); connect( The::mainWindow(), SIGNAL(banTrack(Meta::TrackPtr)), SLOT(banTrack(Meta::TrackPtr)) ); connect( &m_scrobbler, SIGNAL(scrobblesSubmitted(QList<lastfm::Track>)), SLOT(slotScrobblesSubmitted(QList<lastfm::Track>)) ); connect( &m_scrobbler, SIGNAL(nowPlayingError(int,QString)), SLOT(slotNowPlayingError(int,QString))); }
ScrobblerAdapter::ScrobblerAdapter( QObject *parent, const QString &clientId ) : QObject( parent ), m_scrobbler( new lastfm::Audioscrobbler( clientId ) ), m_clientId( clientId ), m_lastSaved( 0 ) { DEBUG_BLOCK resetVariables(); //HACK work around a bug in liblastfm---it doesn't create its config dir, so when it // tries to write the track cache, it fails silently. until we have a fixed version, do this // path finding code taken from liblastfm/src/misc.cpp QString lpath = QDir::home().filePath( ".local/share/Last.fm" ); QDir ldir = QDir( lpath ); if( !ldir.exists() ) { ldir.mkpath( lpath ); } connect( The::mainWindow(), SIGNAL( loveTrack( Meta::TrackPtr) ), SLOT( loveTrack( Meta::TrackPtr ) ) ); connect( The::mainWindow(), SIGNAL( banTrack() ), SLOT( banTrack() ) ); EngineController *engine = The::engineController(); connect( engine, SIGNAL( stopped( qint64, qint64 ) ), this, SLOT( stopped( qint64, qint64 ) ) ); connect( engine, SIGNAL( trackPositionChanged( qint64, bool ) ), this, SLOT( trackPositionChanged( qint64, bool ) ) ); //Use trackChanged instead of trackPlaying to prevent reset of current track after Unpausing. connect( engine, SIGNAL( trackChanged( Meta::TrackPtr ) ), this, SLOT( trackPlaying( Meta::TrackPtr ) ) ); connect( engine, SIGNAL( trackMetadataChanged( Meta::TrackPtr ) ), this, SLOT( trackMetadataChanged( Meta::TrackPtr ) ) ); }