From f0e1248e3de8d2c60ecef38bf7296f8d578ee94b Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Fri, 5 Dec 2014 07:21:35 +0100 Subject: [PATCH] Use LinkGenerator in AdiumPlugin too --- src/infoplugins/mac/adium/AdiumPlugin.cpp | 19 +++++++++++++++---- src/infoplugins/mac/adium/AdiumPlugin.h | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/infoplugins/mac/adium/AdiumPlugin.cpp b/src/infoplugins/mac/adium/AdiumPlugin.cpp index 920d4c188..e27b1f525 100644 --- a/src/infoplugins/mac/adium/AdiumPlugin.cpp +++ b/src/infoplugins/mac/adium/AdiumPlugin.cpp @@ -26,7 +26,7 @@ #include "Artist.h" #include "Result.h" #include "TomahawkSettings.h" -#include "GlobalActionManager.h" +#include "utils/LinkGenerator.h" #include "utils/Logger.h" #include "AdiumPlugin.h" @@ -161,11 +161,19 @@ AdiumPlugin::audioStarted( const Tomahawk::InfoSystem::PushInfoPair pushInfoPair m_currentArtist = hash["artist"]; // Request a short URL - m_currentLongUrl = GlobalActionManager::instance()->openLink( hash.value( "title" ), hash.value( "artist" ), hash.value( "album" ) ); + ScriptJob* job = Utils::LinkGenerator::instance()->openLink( hash.value( "title" ), hash.value( "artist" ), hash.value( "album" ) ); + connect( job, SIGNAL( done( QVariantMap ) ), SLOT ( onQueryLinkReady( QVariantMap ) ) ); + job->start(); +} + + +void +AdiumPlugin::onQueryLinkReady( const QVariantMap& data ) +{ + + m_currentLongUrl = data[ "url" ].toUrl(); QUrl shortUrl = m_currentLongUrl; - if ( pushInfoPair.first.contains( "shortUrl" ) ) - shortUrl = pushInfoPair.first[ "shortUrl" ].toUrl(); QString nowPlaying = ""; nowPlaying.append( m_currentArtist ); @@ -184,8 +192,11 @@ AdiumPlugin::audioStarted( const Tomahawk::InfoSystem::PushInfoPair pushInfoPair nowPlaying.append( " " ); nowPlaying.append( shortUrl.toEncoded() ); setStatus( nowPlaying ); + + sender()->deleteLater(); } + void AdiumPlugin::audioFinished( const QVariant &input ) { diff --git a/src/infoplugins/mac/adium/AdiumPlugin.h b/src/infoplugins/mac/adium/AdiumPlugin.h index b0fe123d4..519b8f6e6 100644 --- a/src/infoplugins/mac/adium/AdiumPlugin.h +++ b/src/infoplugins/mac/adium/AdiumPlugin.h @@ -65,6 +65,7 @@ public slots: private slots: void clearStatus(); void settingsChanged(); + void onQueryLinkReady( const QVariantMap& data ); private: void audioStarted( const Tomahawk::InfoSystem::PushInfoPair pushInfoPair );