mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
Untested but relatively straightforward...add InfoShareTrack, custom message/account ability for twitter
This commit is contained in:
@@ -206,13 +206,13 @@ LastFmPlugin::sendLoveSong( const InfoType type, QVariant input )
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
if ( !input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
if ( !input.toMap().contains( "trackinfo" ) || !input.toMap()[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||||
{
|
{
|
||||||
tLog() << "LastFmPlugin::nowPlaying cannot convert input!";
|
tLog() << "LastFmPlugin::nowPlaying cannot convert input!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InfoStringHash hash = input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
InfoStringHash hash = input.toMap()[ "trackinfo" ].value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||||
if ( !hash.contains( "title" ) || !hash.contains( "artist" ) || !hash.contains( "album" ) )
|
if ( !hash.contains( "title" ) || !hash.contains( "artist" ) || !hash.contains( "album" ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -37,7 +37,7 @@ namespace InfoSystem
|
|||||||
TwitterInfoPlugin::TwitterInfoPlugin( Tomahawk::Accounts::TwitterAccount* account )
|
TwitterInfoPlugin::TwitterInfoPlugin( Tomahawk::Accounts::TwitterAccount* account )
|
||||||
: m_account( account )
|
: m_account( account )
|
||||||
{
|
{
|
||||||
//m_supportedPushTypes << InfoLove;
|
m_supportedPushTypes << InfoShareTrack << InfoLove;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -123,20 +123,46 @@ TwitterInfoPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData )
|
|||||||
|
|
||||||
Tomahawk::InfoSystem::PushInfoPair pushInfoPair = pushData.infoPair;
|
Tomahawk::InfoSystem::PushInfoPair pushInfoPair = pushData.infoPair;
|
||||||
|
|
||||||
if ( !pushInfoPair.second.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
if ( !pushInfoPair.second.canConvert< QVariantMap >() )
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO << "Cannot convert input into an info string hash";
|
tLog() << Q_FUNC_INFO << "Failed to find QVariantMap!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoStringHash info = pushInfoPair.second.value< Tomahawk::InfoSystem::InfoStringHash >();
|
QVariantMap map = pushInfoPair.second.toMap();
|
||||||
|
|
||||||
QString msg = tr( "Listening to \"%1\" by %2 and loving it! %3" )
|
if ( !map.contains( "accountlist" ) || !map[ "accountlist" ].canConvert< QStringList >() )
|
||||||
|
{
|
||||||
|
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Cowardly failing to send out a message without an account list present";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !map[ "accountlist" ].toStringList().contains( m_account->accountId() ) )
|
||||||
|
{
|
||||||
|
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Our account not in the list, not tweeting out";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !map.contains( "message" ) && ( !map.contains( "trackinfo" ) || !map[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() ) )
|
||||||
|
{
|
||||||
|
tLog() << Q_FUNC_INFO << "Failed to find message or trackinfo";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tomahawk::InfoSystem::InfoStringHash info;
|
||||||
|
QString msg;
|
||||||
|
if ( !map.contains( "message" ) )
|
||||||
|
{
|
||||||
|
info = map[ "trackinfo" ].value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||||
|
msg = tr( "Listening to \"%1\" by %2 and loving it! %3" )
|
||||||
.arg( info[ "title" ] )
|
.arg( info[ "title" ] )
|
||||||
.arg( info[ "artist" ] )
|
.arg( info[ "artist" ] )
|
||||||
.arg( pushInfoPair.first.contains( "shorturl" ) ?
|
.arg( pushInfoPair.first.contains( "shorturl" ) ?
|
||||||
pushInfoPair.first[ "shorturl" ].toUrl().toString() :
|
pushInfoPair.first[ "shorturl" ].toUrl().toString() :
|
||||||
GlobalActionManager::instance()->openLink( info[ "title" ], info[ "artist" ], info[ "album" ] ).toString() );
|
GlobalActionManager::instance()->openLink( info[ "title" ], info[ "artist" ], info[ "album" ] ).toString() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
msg = map[ "message" ].toString();
|
||||||
|
|
||||||
QTweetStatusUpdate *statUpdate = new QTweetStatusUpdate( m_twitterAuth.data(), this );
|
QTweetStatusUpdate *statUpdate = new QTweetStatusUpdate( m_twitterAuth.data(), this );
|
||||||
connect( statUpdate, SIGNAL( postedStatus(const QTweetStatus &) ), SLOT( postLovedStatusUpdateReply(const QTweetStatus &) ) );
|
connect( statUpdate, SIGNAL( postedStatus(const QTweetStatus &) ), SLOT( postLovedStatusUpdateReply(const QTweetStatus &) ) );
|
||||||
|
@@ -582,14 +582,17 @@ Query::setLoved( bool loved )
|
|||||||
{
|
{
|
||||||
m_currentSocialActions[ "Love" ] = loved;
|
m_currentSocialActions[ "Love" ] = loved;
|
||||||
|
|
||||||
|
QVariantMap loveInfo;
|
||||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||||
trackInfo["title"] = track();
|
trackInfo["title"] = track();
|
||||||
trackInfo["artist"] = artist();
|
trackInfo["artist"] = artist();
|
||||||
trackInfo["album"] = album();
|
trackInfo["album"] = album();
|
||||||
|
|
||||||
|
loveInfo[ "trackinfo" ] = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoPushData pushData ( id(),
|
Tomahawk::InfoSystem::InfoPushData pushData ( id(),
|
||||||
( loved ? Tomahawk::InfoSystem::InfoLove : Tomahawk::InfoSystem::InfoUnLove ),
|
( loved ? Tomahawk::InfoSystem::InfoLove : Tomahawk::InfoSystem::InfoUnLove ),
|
||||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ),
|
loveInfo,
|
||||||
Tomahawk::InfoSystem::PushShortUrlFlag );
|
Tomahawk::InfoSystem::PushShortUrlFlag );
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData );
|
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData );
|
||||||
|
@@ -129,6 +129,7 @@ enum InfoType { // as items are saved in cache, mark them here to not change the
|
|||||||
|
|
||||||
InfoLove = 90,
|
InfoLove = 90,
|
||||||
InfoUnLove = 91,
|
InfoUnLove = 91,
|
||||||
|
InfoShareTrack = 92,
|
||||||
|
|
||||||
InfoNotifyUser = 100,
|
InfoNotifyUser = 100,
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user