mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-13 20:39:57 +01:00
Modify pushInfo interface to allow flags. These flags can be coded to
add extra common information for all consuming plugins. So far, a shorturl flag has been added, making a short url available to all plugins. I wasn't able to check this on OSX, so it might need a small amount of touching up.
This commit is contained in:
parent
5fc54a7e4c
commit
8ba61f5496
@ -127,13 +127,14 @@ LastFmPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
|
||||
|
||||
void
|
||||
LastFmPlugin::pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input )
|
||||
LastFmPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags )
|
||||
{
|
||||
Q_UNUSED( caller )
|
||||
Q_UNUSED( pushFlags )
|
||||
switch ( type )
|
||||
{
|
||||
case InfoSubmitNowPlaying:
|
||||
nowPlaying( input );
|
||||
nowPlaying( pushInfoPair.second );
|
||||
break;
|
||||
|
||||
case InfoSubmitScrobble:
|
||||
@ -142,7 +143,7 @@ LastFmPlugin::pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoTy
|
||||
|
||||
case InfoLove:
|
||||
case InfoUnLove:
|
||||
sendLoveSong( type, input );
|
||||
sendLoveSong( type, pushInfoPair.second );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -62,7 +62,7 @@ protected slots:
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data );
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags );
|
||||
|
||||
private:
|
||||
void fetchCoverArt( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
@ -57,8 +57,11 @@ Tomahawk::InfoSystem::XmppInfoPlugin::~XmppInfoPlugin()
|
||||
|
||||
|
||||
void
|
||||
Tomahawk::InfoSystem::XmppInfoPlugin::pushInfo(QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input)
|
||||
Tomahawk::InfoSystem::XmppInfoPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags )
|
||||
{
|
||||
Q_UNUSED( caller )
|
||||
Q_UNUSED( pushFlags )
|
||||
|
||||
tDebug() << Q_FUNC_INFO << m_sipPlugin->m_client->jid().full();
|
||||
|
||||
if( m_sipPlugin->m_account->configuration().value("publishtracks").toBool() == false )
|
||||
@ -72,8 +75,7 @@ Tomahawk::InfoSystem::XmppInfoPlugin::pushInfo(QString caller, Tomahawk::InfoSys
|
||||
case InfoNowPlaying:
|
||||
case InfoNowResumed:
|
||||
m_pauseTimer.stop();
|
||||
if ( input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
audioStarted( input.value< Tomahawk::InfoSystem::InfoStringHash >() );
|
||||
audioStarted( pushInfoPair );
|
||||
break;
|
||||
case InfoNowPaused:
|
||||
m_pauseTimer.start( PAUSE_TIMEOUT * 1000 );
|
||||
@ -91,18 +93,29 @@ Tomahawk::InfoSystem::XmppInfoPlugin::pushInfo(QString caller, Tomahawk::InfoSys
|
||||
|
||||
|
||||
void
|
||||
Tomahawk::InfoSystem::XmppInfoPlugin::audioStarted(const Tomahawk::InfoSystem::InfoStringHash& info)
|
||||
Tomahawk::InfoSystem::XmppInfoPlugin::audioStarted( const Tomahawk::InfoSystem::PushInfoPair &pushInfoPair )
|
||||
{
|
||||
if ( !pushInfoPair.second.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "did not find an infostringhash";
|
||||
return;
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash info = pushInfoPair.second.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
tDebug() << Q_FUNC_INFO << m_sipPlugin->m_client->jid().full() << info;
|
||||
|
||||
|
||||
Jreen::Tune::Ptr tune( new Jreen::Tune() );
|
||||
|
||||
tune->setTitle( info.value( "title" ) );
|
||||
tune->setArtist( info.value( "artist" ) );
|
||||
tune->setLength( info.value("duration").toInt() );
|
||||
tune->setTrack( info.value("albumpos") );
|
||||
tune->setUri( GlobalActionManager::instance()->openLink( info.value( "title" ), info.value( "artist" ), info.value( "album" ) ) );
|
||||
if ( pushInfoPair.first.contains( "shorturl" ) )
|
||||
tune->setUri( pushInfoPair.first[ "shorturl" ].toUrl() );
|
||||
else
|
||||
tune->setUri( GlobalActionManager::instance()->openLink( info.value( "title" ), info.value( "artist" ), info.value( "album" ) ) );
|
||||
|
||||
tDebug() << Q_FUNC_INFO << "Setting URI of " << tune->uri().toString();
|
||||
//TODO: provide a rating once available in Tomahawk
|
||||
tune->setRating( 10 );
|
||||
|
||||
|
@ -47,11 +47,11 @@ namespace Tomahawk {
|
||||
void notInCacheSlot( const Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
protected slots:
|
||||
void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input );
|
||||
void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags );
|
||||
void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
private slots:
|
||||
void audioStarted( const Tomahawk::InfoSystem::InfoStringHash& info );
|
||||
void audioStarted( const Tomahawk::InfoSystem::PushInfoPair& pushInfoPair );
|
||||
void audioStopped();
|
||||
void audioPaused();
|
||||
|
||||
|
@ -148,7 +148,8 @@ AudioEngine::play()
|
||||
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNowResumed,
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ) );
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ),
|
||||
Tomahawk::InfoSystem::PushNoFlag );
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -164,7 +165,7 @@ AudioEngine::pause()
|
||||
m_mediaObject->pause();
|
||||
emit paused();
|
||||
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNowPaused, QVariant() );
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNowPaused, QVariant(), Tomahawk::InfoSystem::PushNoFlag );
|
||||
}
|
||||
|
||||
|
||||
@ -199,7 +200,7 @@ AudioEngine::stop()
|
||||
map[ Tomahawk::InfoSystem::InfoNotifyUser ] = QVariant::fromValue< QVariantMap >( stopInfo );
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( s_aeInfoIdentifier, map );
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( s_aeInfoIdentifier, map, Tomahawk::InfoSystem::PushNoFlag );
|
||||
}
|
||||
|
||||
|
||||
@ -332,7 +333,8 @@ AudioEngine::sendWaitingNotificationSlot() const
|
||||
retryInfo["message"] = QString( "The current track could not be resolved. Tomahawk will pick back up with the next resolvable track from this source." );
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNotifyUser,
|
||||
QVariant::fromValue< QVariantMap >( retryInfo ) );
|
||||
QVariant::fromValue< QVariantMap >( retryInfo ),
|
||||
Tomahawk::InfoSystem::PushNoFlag );
|
||||
}
|
||||
|
||||
|
||||
@ -354,6 +356,7 @@ AudioEngine::sendNowPlayingNotification()
|
||||
void
|
||||
AudioEngine::onNowPlayingInfoReady()
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||
if ( m_currentTrack.isNull() ||
|
||||
m_currentTrack->track().isNull() ||
|
||||
m_currentTrack->artist().isNull() )
|
||||
@ -379,7 +382,8 @@ AudioEngine::onNowPlayingInfoReady()
|
||||
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNotifyUser,
|
||||
QVariant::fromValue< QVariantMap >( playInfo ) );
|
||||
QVariant::fromValue< QVariantMap >( playInfo ),
|
||||
Tomahawk::InfoSystem::PushNoFlag );
|
||||
}
|
||||
|
||||
|
||||
@ -474,7 +478,8 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||
s_aeInfoIdentifier,
|
||||
Tomahawk::InfoSystem::InfoNowPlaying,
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ) );
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ),
|
||||
Tomahawk::InfoSystem::PushShortUrlFlag );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,12 +123,12 @@ GlobalActionManager::openLink( const QString& title, const QString& artist, cons
|
||||
|
||||
|
||||
void
|
||||
GlobalActionManager::shortenLink( const QUrl& url )
|
||||
GlobalActionManager::shortenLink( const QUrl& url, const QVariantMap &callbackMap )
|
||||
{
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
|
||||
QMetaObject::invokeMethod( this, "shortenLink", Qt::QueuedConnection, Q_ARG( QUrl, url ) );
|
||||
QMetaObject::invokeMethod( this, "shortenLink", Qt::QueuedConnection, Q_ARG( QUrl, url ), Q_ARG( QVariantMap, callbackMap ) );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -136,6 +136,8 @@ GlobalActionManager::shortenLink( const QUrl& url )
|
||||
request.setUrl( url );
|
||||
|
||||
QNetworkReply *reply = TomahawkUtils::nam()->get( request );
|
||||
if ( !callbackMap.empty() )
|
||||
reply->setProperty( "callbackMap", callbackMap );
|
||||
connect( reply, SIGNAL( finished() ), SLOT( shortenLinkRequestFinished() ) );
|
||||
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ), SLOT( shortenLinkRequestError( QNetworkReply::NetworkError ) ) );
|
||||
}
|
||||
@ -894,10 +896,14 @@ GlobalActionManager::shortenLinkRequestFinished()
|
||||
// NOTE: this should never happen
|
||||
if( !reply )
|
||||
{
|
||||
emit shortLinkReady( QUrl( "" ), QUrl( "" ) );
|
||||
emit shortLinkReady( QUrl( "" ), QUrl( "" ), QVariantMap() );
|
||||
return;
|
||||
}
|
||||
|
||||
QVariantMap callbackMap;
|
||||
if ( reply->property( "callbackMap" ).canConvert< QVariantMap >() && !reply->property( "callbackMap" ).toMap().isEmpty() )
|
||||
callbackMap = reply->property( "callbackMap" ).toMap();
|
||||
|
||||
// Check for the redirect attribute, as this should be the shortened link
|
||||
QVariant urlVariant = reply->attribute( QNetworkRequest::RedirectionTargetAttribute );
|
||||
|
||||
@ -926,9 +932,9 @@ GlobalActionManager::shortenLinkRequestFinished()
|
||||
else
|
||||
{
|
||||
if ( !error )
|
||||
emit shortLinkReady( longUrl, shortUrl );
|
||||
emit shortLinkReady( longUrl, shortUrl, callbackMap );
|
||||
else
|
||||
emit shortLinkReady( longUrl, longUrl );
|
||||
emit shortLinkReady( longUrl, longUrl, callbackMap );
|
||||
}
|
||||
|
||||
reply->deleteLater();
|
||||
@ -946,12 +952,15 @@ GlobalActionManager::shortenLinkRequestError( QNetworkReply::NetworkError error
|
||||
// NOTE: this should never happen
|
||||
if( !reply )
|
||||
{
|
||||
emit shortLinkReady( QUrl( "" ), QUrl( "" ) );
|
||||
emit shortLinkReady( QUrl( "" ), QUrl( "" ), QVariantMap() );
|
||||
return;
|
||||
}
|
||||
|
||||
QVariantMap callbackMap;
|
||||
if ( reply->property( "callbackMap" ).canConvert< QVariantMap >() && !reply->property( "callbackMap" ).toMap().isEmpty() )
|
||||
callbackMap = reply->property( "callbackMap" ).toMap();
|
||||
reply->deleteLater();
|
||||
emit shortLinkReady( QUrl( "" ), QUrl( "" ) );
|
||||
emit shortLinkReady( QUrl( "" ), QUrl( "" ), callbackMap );
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
void savePlaylistToFile( const Tomahawk::playlist_ptr& playlist, const QString& filename );
|
||||
|
||||
public slots:
|
||||
void shortenLink( const QUrl& url );
|
||||
void shortenLink( const QUrl& url, const QVariantMap &callbackMap = QVariantMap() );
|
||||
|
||||
bool parseTomahawkLink( const QString& link );
|
||||
void waitingForResolved( bool );
|
||||
@ -67,7 +67,7 @@ public slots:
|
||||
void handlePlayTrack( const Tomahawk::query_ptr& qry );
|
||||
|
||||
signals:
|
||||
void shortLinkReady( QUrl longUrl, QUrl shortUrl ) const;
|
||||
void shortLinkReady( QUrl longUrl, QUrl shortUrl, QVariantMap callbackMap ) const;
|
||||
|
||||
private slots:
|
||||
void shortenLinkRequestFinished();
|
||||
|
@ -42,8 +42,13 @@ public:
|
||||
protected:
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
virtual void pushInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant )
|
||||
{}
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags )
|
||||
{
|
||||
Q_UNUSED( caller )
|
||||
Q_UNUSED( type)
|
||||
Q_UNUSED( pushInfoPair )
|
||||
Q_UNUSED( pushFlags )
|
||||
}
|
||||
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
|
@ -60,11 +60,12 @@ protected slots:
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data )
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags )
|
||||
{
|
||||
Q_UNUSED( caller )
|
||||
Q_UNUSED( type )
|
||||
Q_UNUSED( data )
|
||||
Q_UNUSED( type)
|
||||
Q_UNUSED( pushInfoPair )
|
||||
Q_UNUSED( pushFlags )
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -49,11 +49,12 @@ public:
|
||||
protected slots:
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant data )
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags )
|
||||
{
|
||||
Q_UNUSED( caller );
|
||||
Q_UNUSED( type );
|
||||
Q_UNUSED( data );
|
||||
Q_UNUSED( caller )
|
||||
Q_UNUSED( type)
|
||||
Q_UNUSED( pushInfoPair )
|
||||
Q_UNUSED( pushFlags )
|
||||
}
|
||||
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
|
@ -58,11 +58,12 @@ public slots:
|
||||
protected slots:
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input )
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags )
|
||||
{
|
||||
Q_UNUSED( caller )
|
||||
Q_UNUSED( type)
|
||||
Q_UNUSED( input )
|
||||
Q_UNUSED( pushInfoPair )
|
||||
Q_UNUSED( pushFlags )
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,11 +43,12 @@ protected slots:
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void notInCacheSlot( InfoStringHash criteria, InfoRequestData requestData );
|
||||
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data )
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags )
|
||||
{
|
||||
Q_UNUSED( caller );
|
||||
Q_UNUSED( type );
|
||||
Q_UNUSED( data );
|
||||
Q_UNUSED( caller )
|
||||
Q_UNUSED( type)
|
||||
Q_UNUSED( pushInfoPair )
|
||||
Q_UNUSED( pushFlags )
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,11 +46,12 @@ public slots:
|
||||
protected slots:
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data )
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags )
|
||||
{
|
||||
Q_UNUSED( caller );
|
||||
Q_UNUSED( type );
|
||||
Q_UNUSED( data );
|
||||
Q_UNUSED( caller )
|
||||
Q_UNUSED( type)
|
||||
Q_UNUSED( pushInfoPair )
|
||||
Q_UNUSED( pushFlags )
|
||||
}
|
||||
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
|
@ -58,11 +58,12 @@ public slots:
|
||||
protected slots:
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input )
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags )
|
||||
{
|
||||
Q_UNUSED( caller )
|
||||
Q_UNUSED( type)
|
||||
Q_UNUSED( input )
|
||||
Q_UNUSED( pushInfoPair )
|
||||
Q_UNUSED( pushFlags )
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -74,9 +74,6 @@ AdiumPlugin::AdiumPlugin()
|
||||
m_pauseTimer->setSingleShot( true );
|
||||
connect( m_pauseTimer, SIGNAL( timeout() ),
|
||||
this, SLOT( clearStatus() ) );
|
||||
|
||||
connect( GlobalActionManager::instance(), SIGNAL( shortLinkReady( QUrl, QUrl ) ),
|
||||
SLOT( shortLinkReady( QUrl, QUrl ) ) );
|
||||
}
|
||||
|
||||
|
||||
@ -87,33 +84,6 @@ AdiumPlugin::~AdiumPlugin()
|
||||
setStatus( "" );
|
||||
}
|
||||
|
||||
void
|
||||
AdiumPlugin::shortLinkReady( QUrl longUrl, QUrl shortUrl )
|
||||
{
|
||||
// The URL we received is either from a previous track, or not requested by us
|
||||
if( longUrl != m_currentLongUrl )
|
||||
return;
|
||||
|
||||
// Build the core of the now-playing string
|
||||
QString nowPlaying = "";
|
||||
nowPlaying.append( m_currentArtist );
|
||||
nowPlaying.append(" - ");
|
||||
nowPlaying.append( m_currentTitle );
|
||||
nowPlaying.replace( "\"", "\\\"" ); // Escape quotes, or Applescript gets confused
|
||||
|
||||
// We failed to get the short URL, just update the status with the metadata
|
||||
if( ( longUrl.toString() == "" ) )
|
||||
{
|
||||
setStatus( nowPlaying );
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the short URL
|
||||
nowPlaying.append( " " );
|
||||
nowPlaying.append( shortUrl.toEncoded() );
|
||||
setStatus( nowPlaying );
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
AdiumPlugin::clearStatus()
|
||||
@ -131,7 +101,7 @@ AdiumPlugin::settingsChanged()
|
||||
|
||||
|
||||
void
|
||||
AdiumPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input )
|
||||
AdiumPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
@ -141,13 +111,13 @@ AdiumPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVar
|
||||
switch ( type )
|
||||
{
|
||||
case InfoNowPlaying:
|
||||
audioStarted( input );
|
||||
audioStarted( pushInfoPair );
|
||||
break;
|
||||
case InfoNowPaused:
|
||||
audioPaused();
|
||||
return;
|
||||
case InfoNowResumed:
|
||||
audioResumed( input );
|
||||
audioResumed( pushInfoPair );
|
||||
break;
|
||||
case InfoNowStopped:
|
||||
audioStopped();
|
||||
@ -164,14 +134,15 @@ AdiumPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVar
|
||||
|
||||
/** Audio state slots */
|
||||
void
|
||||
AdiumPlugin::audioStarted( const QVariant &input )
|
||||
AdiumPlugin::audioStarted( const Tomahawk::InfoSystem::PushInfoPair pushInfoPair )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
if ( !input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
if ( !pushInfoPair.second.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
return;
|
||||
|
||||
InfoStringHash hash = input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
Tomahawk::InfoSystem::InfoStringHash hash = pushInfoPair.second.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
if ( !hash.contains( "title" ) || !hash.contains( "artist" ) )
|
||||
return;
|
||||
|
||||
@ -179,24 +150,29 @@ AdiumPlugin::audioStarted( const QVariant &input )
|
||||
m_currentArtist = hash["artist"];
|
||||
|
||||
// Request a short URL
|
||||
m_currentLongUrl = openLinkFromHash( hash );
|
||||
GlobalActionManager::instance()->shortenLink( m_currentLongUrl );
|
||||
}
|
||||
m_currentLongUrl = GlobalActionManager::instance()->openLink( info.value( "title" ), info.value( "artist" ), info.value( "album" ) );
|
||||
|
||||
QUrl
|
||||
AdiumPlugin::openLinkFromHash( const Tomahawk::InfoSystem::InfoStringHash& hash ) const
|
||||
{
|
||||
QString title, artist, album;
|
||||
QUrl shortUrl = m_currentLongUrl;
|
||||
if ( pushInfoPair.first.contains( "shortUrl" ) )
|
||||
shortUrl = pushInfoPair.first[ "shortUrl" ].toUrl();
|
||||
|
||||
QString nowPlaying = "";
|
||||
nowPlaying.append( m_currentArtist );
|
||||
nowPlaying.append(" - ");
|
||||
nowPlaying.append( m_currentTitle );
|
||||
nowPlaying.replace( "\"", "\\\"" ); // Escape quotes, or Applescript gets confused
|
||||
|
||||
if( !hash.isEmpty() && hash.contains( "title" ) && hash.contains( "artist" ) )
|
||||
// We failed to get the short URL, just update the status with the metadata
|
||||
if( ( m_currentLongUrl.toString() == "" ) )
|
||||
{
|
||||
title = hash["title"];
|
||||
artist = hash["artist"];
|
||||
if( hash.contains( "album" ) )
|
||||
album = hash["album"];
|
||||
setStatus( nowPlaying );
|
||||
return;
|
||||
}
|
||||
|
||||
return GlobalActionManager::instance()->openLink( title, artist, album );
|
||||
// Add the short URL
|
||||
nowPlaying.append( " " );
|
||||
nowPlaying.append( shortUrl.toEncoded() );
|
||||
setStatus( nowPlaying );
|
||||
}
|
||||
|
||||
void
|
||||
@ -220,9 +196,9 @@ AdiumPlugin::audioPaused()
|
||||
}
|
||||
|
||||
void
|
||||
AdiumPlugin::audioResumed( const QVariant &input )
|
||||
AdiumPlugin::audioResumed( const Tomahawk::InfoSystem::PushInfoPair pushInfoPair )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
audioStarted( input );
|
||||
audioStarted( pushInfoPair );
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ protected slots:
|
||||
Q_UNUSED( requestData );
|
||||
}
|
||||
|
||||
void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input );
|
||||
void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags );
|
||||
|
||||
public slots:
|
||||
virtual void notInCacheSlot( const Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
@ -57,19 +57,15 @@ public slots:
|
||||
}
|
||||
|
||||
private slots:
|
||||
void shortLinkReady( QUrl longUrl, QUrl shortUrl );
|
||||
|
||||
void clearStatus();
|
||||
void settingsChanged();
|
||||
|
||||
private:
|
||||
void audioStarted( const QVariant &input );
|
||||
void audioStarted( const Tomahawk::InfoSystem::PushInfoPair pushInfoPair );
|
||||
void audioFinished( const QVariant &input );
|
||||
void audioStopped();
|
||||
void audioPaused();
|
||||
void audioResumed( const QVariant &input );
|
||||
|
||||
QUrl openLinkFromHash( const InfoStringHash& hash ) const;
|
||||
void audioResumed( const Tomahawk::InfoSystem::PushInfoPair pushInfoPair );
|
||||
|
||||
bool m_active;
|
||||
QString m_beforeStatus;
|
||||
|
@ -63,10 +63,12 @@ FdoNotifyPlugin::~FdoNotifyPlugin()
|
||||
}
|
||||
|
||||
void
|
||||
FdoNotifyPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant pushData )
|
||||
FdoNotifyPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags )
|
||||
{
|
||||
Q_UNUSED( caller );
|
||||
Q_UNUSED( pushFlags );
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
QVariant pushData = pushInfoPair.second;
|
||||
if ( type != Tomahawk::InfoSystem::InfoNotifyUser || !pushData.canConvert< QVariantMap >() )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << " not the right type or could not convert the hash";
|
||||
|
@ -42,7 +42,7 @@ protected slots:
|
||||
Q_UNUSED( requestData );
|
||||
}
|
||||
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant pushData );
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags );
|
||||
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
|
@ -469,16 +469,17 @@ MprisPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
|
||||
|
||||
void
|
||||
MprisPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input )
|
||||
MprisPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags )
|
||||
{
|
||||
Q_UNUSED( caller );
|
||||
Q_UNUSED( pushFlags );
|
||||
bool isPlayingInfo = false;
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case InfoNowPlaying:
|
||||
isPlayingInfo = true;
|
||||
audioStarted( input );
|
||||
audioStarted( pushInfoPair.second );
|
||||
break;
|
||||
case InfoNowPaused:
|
||||
isPlayingInfo = true;
|
||||
@ -486,7 +487,7 @@ MprisPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVar
|
||||
break;
|
||||
case InfoNowResumed:
|
||||
isPlayingInfo = true;
|
||||
audioResumed( input );
|
||||
audioResumed( pushInfoPair.second );
|
||||
break;
|
||||
case InfoNowStopped:
|
||||
isPlayingInfo = true;
|
||||
|
@ -141,7 +141,7 @@ public slots:
|
||||
|
||||
protected slots:
|
||||
void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input );
|
||||
void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags );
|
||||
|
||||
private slots:
|
||||
void stateChanged( AudioState newState, AudioState oldState );
|
||||
|
@ -172,23 +172,24 @@ InfoSystem::getInfo( const QString &caller, const QVariantMap &customData, const
|
||||
|
||||
|
||||
bool
|
||||
InfoSystem::pushInfo( const QString &caller, const InfoType type, const QVariant& input )
|
||||
InfoSystem::pushInfo( const QString &caller, const InfoType type, const QVariant& input, const PushInfoFlags pushFlags )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
tDebug() << Q_FUNC_INFO << "type is " << type;
|
||||
if ( !m_inited || !m_infoSystemWorkerThreadController->worker() )
|
||||
{
|
||||
init();
|
||||
return false;
|
||||
}
|
||||
|
||||
QMetaObject::invokeMethod( m_infoSystemWorkerThreadController->worker(), "pushInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( QVariant, input ) );
|
||||
PushInfoPair currPair( QVariantMap(), input );
|
||||
QMetaObject::invokeMethod( m_infoSystemWorkerThreadController->worker(), "pushInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( Tomahawk::InfoSystem::PushInfoPair, currPair ), Q_ARG( Tomahawk::InfoSystem::PushInfoFlags, pushFlags ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
InfoSystem::pushInfo( const QString &caller, const InfoTypeMap &input )
|
||||
InfoSystem::pushInfo( const QString &caller, const InfoTypeMap &input, const PushInfoFlags pushFlags )
|
||||
{
|
||||
if ( !m_inited || !m_infoSystemWorkerThreadController->worker() )
|
||||
{
|
||||
@ -197,7 +198,10 @@ InfoSystem::pushInfo( const QString &caller, const InfoTypeMap &input )
|
||||
}
|
||||
|
||||
Q_FOREACH( InfoType type, input.keys() )
|
||||
QMetaObject::invokeMethod( m_infoSystemWorkerThreadController->worker(), "pushInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( QVariant, input[ type ] ) );
|
||||
{
|
||||
PushInfoPair currPair( QVariantMap(), input[ type ] );
|
||||
QMetaObject::invokeMethod( m_infoSystemWorkerThreadController->worker(), "pushInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( Tomahawk::InfoSystem::PushInfoPair, currPair ), Q_ARG( Tomahawk::InfoSystem::PushInfoFlags, pushFlags ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -44,6 +44,11 @@ namespace InfoSystem {
|
||||
class InfoSystemCache;
|
||||
class InfoSystemWorker;
|
||||
|
||||
enum PushInfoFlags { // must be powers of 2
|
||||
PushNoFlag = 1,
|
||||
PushShortUrlFlag = 2
|
||||
};
|
||||
|
||||
enum InfoType { // as items are saved in cache, mark them here to not change them
|
||||
InfoNoInfo = 0, //WARNING: *ALWAYS* keep this first!
|
||||
InfoTrackID = 1,
|
||||
@ -162,6 +167,7 @@ struct InfoRequestData {
|
||||
typedef QMap< InfoType, QVariant > InfoTypeMap;
|
||||
typedef QMap< InfoType, uint > InfoTimeoutMap;
|
||||
typedef QHash< QString, QString > InfoStringHash;
|
||||
typedef QPair< QVariantMap, QVariant > PushInfoPair;
|
||||
|
||||
class DLLEXPORT InfoPlugin : public QObject
|
||||
{
|
||||
@ -183,7 +189,7 @@ signals:
|
||||
|
||||
protected slots:
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ) = 0;
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data ) = 0;
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair pushInfoPair, Tomahawk::InfoSystem::PushInfoFlags pushFlags ) = 0;
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) = 0;
|
||||
|
||||
protected:
|
||||
@ -240,8 +246,8 @@ public:
|
||||
bool getInfo( const InfoRequestData &requestData );
|
||||
//WARNING: if changing timeoutMillis above, also change in below function in .cpp file
|
||||
bool getInfo( const QString &caller, const QVariantMap &customData, const InfoTypeMap &inputMap, const InfoTimeoutMap &timeoutMap = InfoTimeoutMap(), bool allSources = false );
|
||||
bool pushInfo( const QString &caller, const InfoType type, const QVariant &input );
|
||||
bool pushInfo( const QString &caller, const InfoTypeMap &input );
|
||||
bool pushInfo( const QString &caller, const InfoType type, const QVariant &input, const PushInfoFlags pushFlags );
|
||||
bool pushInfo( const QString &caller, const InfoTypeMap &input, const PushInfoFlags pushFlags );
|
||||
|
||||
public slots:
|
||||
// InfoSystem takes ownership of InfoPlugins
|
||||
@ -292,6 +298,9 @@ inline uint qHash( Tomahawk::InfoSystem::InfoStringHash hash )
|
||||
|
||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoRequestData );
|
||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoStringHash );
|
||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::PushInfoPair );
|
||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::PushInfoFlags );
|
||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoType );
|
||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoSystemCache* );
|
||||
Q_DECLARE_METATYPE( QList< Tomahawk::InfoSystem::InfoStringHash > );
|
||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoPlugin* );
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "infoplugins/generic/spotifyPlugin.h"
|
||||
#include "infoplugins/generic/musicbrainzPlugin.h"
|
||||
#include "infoplugins/generic/hypemPlugin.h"
|
||||
#include "globalactionmanager.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
@ -78,6 +79,7 @@ void
|
||||
InfoSystemWorker::init( Tomahawk::InfoSystem::InfoSystemCache* cache )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
m_shortLinksWaiting = 0;
|
||||
m_cache = cache;
|
||||
#ifndef ENABLE_HEADLESS
|
||||
addInfoPlugin( new EchoNestPlugin() );
|
||||
@ -216,18 +218,97 @@ InfoSystemWorker::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
|
||||
|
||||
void
|
||||
InfoSystemWorker::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input )
|
||||
InfoSystemWorker::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair input, Tomahawk::InfoSystem::PushInfoFlags pushFlags )
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
tDebug() << Q_FUNC_INFO << "type is " << type;
|
||||
|
||||
if ( pushFlags != PushNoFlag )
|
||||
{
|
||||
if ( pushFlags & PushShortUrlFlag )
|
||||
{
|
||||
pushFlags = Tomahawk::InfoSystem::PushInfoFlags( pushFlags & ~PushShortUrlFlag );
|
||||
QMetaObject::invokeMethod( this, "getShortUrl", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( Tomahawk::InfoSystem::PushInfoPair, input ), Q_ARG( Tomahawk::InfoSystem::PushInfoFlags, pushFlags ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Q_FOREACH( InfoPluginPtr ptr, m_infoPushMap[ type ] )
|
||||
{
|
||||
if( ptr )
|
||||
QMetaObject::invokeMethod( ptr.data(), "pushInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( QVariant, input ) );
|
||||
QMetaObject::invokeMethod( ptr.data(), "pushInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( Tomahawk::InfoSystem::PushInfoPair, input ), Q_ARG( Tomahawk::InfoSystem::PushInfoFlags, pushFlags ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InfoSystemWorker::getShortUrl( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair input, Tomahawk::InfoSystem::PushInfoFlags pushFlags )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "type is " << type;
|
||||
if ( !input.second.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
{
|
||||
QMetaObject::invokeMethod( this, "pushInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( Tomahawk::InfoSystem::PushInfoPair, input ), Q_ARG( Tomahawk::InfoSystem::PushInfoFlags, pushFlags ) );
|
||||
return;
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash hash = input.second.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
|
||||
if ( hash.isEmpty() || !hash.contains( "title" ) || !hash.contains( "artist" ) )
|
||||
{
|
||||
QMetaObject::invokeMethod( this, "pushInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( Tomahawk::InfoSystem::PushInfoPair, input ), Q_ARG( Tomahawk::InfoSystem::PushInfoFlags, pushFlags ) );
|
||||
return;
|
||||
}
|
||||
|
||||
QString title, artist, album;
|
||||
title = hash[ "title" ];
|
||||
artist = hash[ "artist" ];
|
||||
if( hash.contains( "album" ) )
|
||||
album = hash[ "album" ];
|
||||
|
||||
QUrl longUrl = GlobalActionManager::instance()->openLink( title, artist, album );
|
||||
|
||||
QVariantMap callbackMap;
|
||||
callbackMap[ "caller" ] = caller;
|
||||
callbackMap[ "type" ] = QVariant::fromValue< Tomahawk::InfoSystem::InfoType >( type );
|
||||
callbackMap[ "pushinfopair" ] = QVariant::fromValue< Tomahawk::InfoSystem::PushInfoPair >( input );
|
||||
callbackMap[ "pushflags" ] = QVariant::fromValue< Tomahawk::InfoSystem::PushInfoFlags >( pushFlags );
|
||||
GlobalActionManager::instance()->shortenLink( longUrl, callbackMap );
|
||||
connect( GlobalActionManager::instance(), SIGNAL( shortLinkReady( QUrl, QUrl, QVariantMap ) ), this, SLOT( shortLinkReady( QUrl, QUrl, QVariantMap ) ), Qt::UniqueConnection );
|
||||
m_shortLinksWaiting++;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InfoSystemWorker::shortLinkReady( QUrl longUrl, QUrl shortUrl, QVariantMap callbackMap )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "long url = " << longUrl << ", shortUrl = " << shortUrl;
|
||||
m_shortLinksWaiting--;
|
||||
if ( !m_shortLinksWaiting )
|
||||
disconnect( GlobalActionManager::instance(), SIGNAL( shortLinkReady( QUrl, QUrl, QVariantMap ) ) );
|
||||
|
||||
if ( callbackMap.isEmpty() || !callbackMap.contains( "caller" ) || !callbackMap.contains( "type" ) || !callbackMap.contains( "pushinfopair" ) || !callbackMap.contains( "pushflags" ) )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "callback map was empty, cannot continue";
|
||||
return;
|
||||
}
|
||||
|
||||
QString caller = callbackMap[ "caller" ].toString();
|
||||
Tomahawk::InfoSystem::InfoType type = callbackMap[ "type" ].value< Tomahawk::InfoSystem::InfoType >();
|
||||
Tomahawk::InfoSystem::PushInfoPair pushInfoPair = callbackMap[ "pushinfopair" ].value< Tomahawk::InfoSystem::PushInfoPair >();
|
||||
Tomahawk::InfoSystem::PushInfoFlags pushFlags = callbackMap[ "pushflags" ].value< Tomahawk::InfoSystem::PushInfoFlags >();
|
||||
|
||||
if ( !shortUrl.isEmpty() && longUrl != shortUrl )
|
||||
{
|
||||
QVariantMap flagProps = pushInfoPair.first;
|
||||
flagProps[ "shorturl" ] = shortUrl;
|
||||
pushInfoPair.first = flagProps;
|
||||
}
|
||||
|
||||
tDebug() << Q_FUNC_INFO << "pushInfoPair first is: " << pushInfoPair.first.keys();
|
||||
|
||||
QMetaObject::invokeMethod( this, "pushInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( Tomahawk::InfoSystem::PushInfoPair, pushInfoPair ), Q_ARG( Tomahawk::InfoSystem::PushInfoFlags, pushFlags ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InfoSystemWorker::infoSlot( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
||||
{
|
||||
|
@ -59,11 +59,15 @@ signals:
|
||||
public slots:
|
||||
void init( Tomahawk::InfoSystem::InfoSystemCache* cache );
|
||||
void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input );
|
||||
|
||||
void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair input, Tomahawk::InfoSystem::PushInfoFlags pushFlags );
|
||||
|
||||
void infoSlot( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
|
||||
void addInfoPlugin( Tomahawk::InfoSystem::InfoPlugin* plugin );
|
||||
|
||||
void getShortUrl( QString caller, Tomahawk::InfoSystem::InfoType type, Tomahawk::InfoSystem::PushInfoPair input, Tomahawk::InfoSystem::PushInfoFlags pushFlags );
|
||||
void shortLinkReady( QUrl longUrl, QUrl shortUrl, QVariantMap callbackMap );
|
||||
|
||||
private slots:
|
||||
void checkTimeoutsTimerFired();
|
||||
@ -88,6 +92,8 @@ private:
|
||||
QMap< InfoType, QList< InfoPluginPtr > > m_infoPushMap;
|
||||
|
||||
QTimer m_checkTimeoutsTimer;
|
||||
|
||||
quint64 m_shortLinksWaiting;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -589,7 +589,8 @@ Query::setLoved( bool loved )
|
||||
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||
id(), Tomahawk::InfoSystem::InfoLove,
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ) );
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ),
|
||||
Tomahawk::InfoSystem::PushNoFlag );
|
||||
|
||||
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction( q, QString( "Love" ), loved ? QString( "true" ) : QString( "false" ) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
|
@ -88,7 +88,8 @@ Scrobbler::trackStarted( const Tomahawk::result_ptr& track )
|
||||
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||
s_scInfoIdentifier, Tomahawk::InfoSystem::InfoSubmitNowPlaying,
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ) );
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ),
|
||||
Tomahawk::InfoSystem::PushNoFlag );
|
||||
|
||||
// liblastfm forces 0-length tracks to scrobble after 4 minutes, stupid.
|
||||
if ( track->duration() == 0 )
|
||||
@ -140,7 +141,7 @@ Scrobbler::scrobble()
|
||||
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||
s_scInfoIdentifier, Tomahawk::InfoSystem::InfoSubmitScrobble,
|
||||
QVariant() );
|
||||
QVariant(), Tomahawk::InfoSystem::PushNoFlag );
|
||||
}
|
||||
|
||||
|
||||
|
@ -442,6 +442,8 @@ TomahawkApp::registerMetaTypes()
|
||||
|
||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoStringHash >( "Tomahawk::InfoSystem::InfoStringHash" );
|
||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoType >( "Tomahawk::InfoSystem::InfoType" );
|
||||
qRegisterMetaType< Tomahawk::InfoSystem::PushInfoFlags >( "Tomahawk::InfoSystem::PushInfoFlags" );
|
||||
qRegisterMetaType< Tomahawk::InfoSystem::PushInfoPair >( "Tomahawk::InfoSystem::PushInfoPair" );
|
||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoRequestData >( "Tomahawk::InfoSystem::InfoRequestData" );
|
||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoSystemCache* >( "Tomahawk::InfoSystem::InfoSystemCache*" );
|
||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoPlugin* >( "Tomahawk::InfoSystem::InfoPlugin*" );
|
||||
|
Loading…
x
Reference in New Issue
Block a user