From 4ca4439255bad8fb7a6d8cfe6f5c56ed19f92bc6 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 9 Dec 2012 02:16:25 +0100 Subject: [PATCH] * Support tomahawk://view/track in GlobalActionManager. --- src/libtomahawk/GlobalActionManager.cpp | 32 ++++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/libtomahawk/GlobalActionManager.cpp b/src/libtomahawk/GlobalActionManager.cpp index 760112ea0..e012f3069 100644 --- a/src/libtomahawk/GlobalActionManager.cpp +++ b/src/libtomahawk/GlobalActionManager.cpp @@ -808,19 +808,21 @@ bool GlobalActionManager::handleViewCommand( const QUrl& url ) { QStringList parts = url.path().split( "/" ).mid( 1 ); // get the rest of the command - if ( parts.isEmpty() ) { + if ( parts.isEmpty() ) + { tLog() << "No specific view command:" << url.toString(); return false; } if ( parts[ 0 ] == "artist" ) { - const QString artist = url.queryItemValue( "name" ); + const QString artist = QUrl::fromPercentEncoding( url.encodedQueryItemValue( "name" ) ).replace( "+", " " ); if ( artist.isEmpty() ) { - tLog() << "Not artist supplied for view/artist command."; + tLog() << "No artist supplied for view/artist command."; return false; } + artist_ptr artistPtr = Artist::get( artist ); if ( !artistPtr.isNull() ) ViewManager::instance()->show( artistPtr ); @@ -829,19 +831,37 @@ GlobalActionManager::handleViewCommand( const QUrl& url ) } else if ( parts[ 0 ] == "album" ) { - const QString artist = url.queryItemValue( "artist" ); - const QString album = url.queryItemValue( "name" ); + const QString artist = QUrl::fromPercentEncoding( url.encodedQueryItemValue( "artist" ) ).replace( "+", " " ); + const QString album = QUrl::fromPercentEncoding( url.encodedQueryItemValue( "name" ) ).replace( "+", " " ); if ( artist.isEmpty() || album.isEmpty() ) { - tLog() << "Not artist or album supplied for view/artist command:" << url; + tLog() << "No artist or album supplied for view/album command:" << url; return false; } + album_ptr albumPtr = Album::get( Artist::get( artist, false ), album, false ); if ( !albumPtr.isNull() ) ViewManager::instance()->show( albumPtr ); return true; } + else if ( parts[ 0 ] == "track" ) + { + const QString artist = QUrl::fromPercentEncoding( url.encodedQueryItemValue( "artist" ) ).replace( "+", " " ); + const QString album = QUrl::fromPercentEncoding( url.encodedQueryItemValue( "album" ) ).replace( "+", " " ); + const QString track = QUrl::fromPercentEncoding( url.encodedQueryItemValue( "name" ) ).replace( "+", " " ); + if ( artist.isEmpty() || track.isEmpty() ) + { + tLog() << "No artist or track supplied for view/track command:" << url; + return false; + } + + query_ptr queryPtr = Query::get( artist, track, album ); + if ( !queryPtr.isNull() ) + ViewManager::instance()->show( queryPtr ); + + return true; + } return false; }