mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-21 16:29:43 +01:00
Untested but relatively straightforward...add InfoShareTrack, custom message/account ability for twitter
This commit is contained in:
parent
07430668d2
commit
710780f3e9
@ -206,13 +206,13 @@ LastFmPlugin::sendLoveSong( const InfoType type, QVariant input )
|
||||
{
|
||||
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!";
|
||||
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" ) )
|
||||
return;
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace InfoSystem
|
||||
TwitterInfoPlugin::TwitterInfoPlugin( Tomahawk::Accounts::TwitterAccount* account )
|
||||
: m_account( account )
|
||||
{
|
||||
//m_supportedPushTypes << InfoLove;
|
||||
m_supportedPushTypes << InfoShareTrack << InfoLove;
|
||||
}
|
||||
|
||||
|
||||
@ -122,21 +122,47 @@ TwitterInfoPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData )
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
QVariantMap map = pushInfoPair.second.toMap();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash info = pushInfoPair.second.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
|
||||
QString msg = tr( "Listening to \"%1\" by %2 and loving it! %3" )
|
||||
.arg( info[ "title" ] )
|
||||
.arg( info[ "artist" ] )
|
||||
.arg( pushInfoPair.first.contains( "shorturl" ) ?
|
||||
pushInfoPair.first[ "shorturl" ].toUrl().toString() :
|
||||
GlobalActionManager::instance()->openLink( info[ "title" ], info[ "artist" ], info[ "album" ] ).toString() );
|
||||
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[ "artist" ] )
|
||||
.arg( pushInfoPair.first.contains( "shorturl" ) ?
|
||||
pushInfoPair.first[ "shorturl" ].toUrl().toString() :
|
||||
GlobalActionManager::instance()->openLink( info[ "title" ], info[ "artist" ], info[ "album" ] ).toString() );
|
||||
}
|
||||
else
|
||||
msg = map[ "message" ].toString();
|
||||
|
||||
QTweetStatusUpdate *statUpdate = new QTweetStatusUpdate( m_twitterAuth.data(), this );
|
||||
connect( statUpdate, SIGNAL( postedStatus(const QTweetStatus &) ), SLOT( postLovedStatusUpdateReply(const QTweetStatus &) ) );
|
||||
|
@ -582,14 +582,17 @@ Query::setLoved( bool loved )
|
||||
{
|
||||
m_currentSocialActions[ "Love" ] = loved;
|
||||
|
||||
QVariantMap loveInfo;
|
||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||
trackInfo["title"] = track();
|
||||
trackInfo["artist"] = artist();
|
||||
trackInfo["album"] = album();
|
||||
|
||||
loveInfo[ "trackinfo" ] = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
||||
|
||||
Tomahawk::InfoSystem::InfoPushData pushData ( id(),
|
||||
( loved ? Tomahawk::InfoSystem::InfoLove : Tomahawk::InfoSystem::InfoUnLove ),
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ),
|
||||
loveInfo,
|
||||
Tomahawk::InfoSystem::PushShortUrlFlag );
|
||||
|
||||
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,
|
||||
InfoUnLove = 91,
|
||||
InfoShareTrack = 92,
|
||||
|
||||
InfoNotifyUser = 100,
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user