diff --git a/src/libtomahawk/GlobalActionManager.cpp b/src/libtomahawk/GlobalActionManager.cpp index 2b31b7586..afbddc214 100644 --- a/src/libtomahawk/GlobalActionManager.cpp +++ b/src/libtomahawk/GlobalActionManager.cpp @@ -354,6 +354,10 @@ GlobalActionManager::parseTomahawkLink( const QString& urlIn ) { return handleViewCommand( u ); } + else if ( cmdType == "import" ) + { + return handleImportCommand( u ); + } else { tLog() << "Tomahawk link not supported, command not known!" << cmdType << u.path(); @@ -429,6 +433,43 @@ GlobalActionManager::handlePlaylistCommand( const QUrl& url ) } +bool +GlobalActionManager::handleImportCommand( const QUrl& url ) +{ + QStringList parts = url.path().split( "/" ).mid( 1 ); // get the rest of the command + if ( parts.size() < 1 ) + return false; + + if ( parts[ 0 ] == "playlist" ) + { + if ( url.hasQueryItem( "xspf" ) ) + { + QUrl xspf = QUrl::fromUserInput( url.queryItemValue( "xspf" ) ); + QString title = url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString(); + XSPFLoader* l= new XSPFLoader( true, this ); + l->setOverrideTitle( title ); + l->load( xspf ); + connect( l, SIGNAL( ok( Tomahawk::playlist_ptr ) ), this, SLOT( playlistCreatedToShow( Tomahawk::playlist_ptr) ) ); + + return true; + } + else if ( url.hasQueryItem( "jspf" ) ) + { + QUrl jspf = QUrl::fromUserInput( url.queryItemValue( "jspf" ) ); + QString title = url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString(); + JSPFLoader* l= new JSPFLoader( true, this ); + l->setOverrideTitle( title ); + l->load( jspf ); + connect( l, SIGNAL( ok( Tomahawk::playlist_ptr ) ), this, SLOT( playlistCreatedToShow( Tomahawk::playlist_ptr) ) ); + + return true; + } + } + + return false; +} + + void GlobalActionManager::playlistCreatedToShow( const playlist_ptr& pl ) { diff --git a/src/libtomahawk/GlobalActionManager.h b/src/libtomahawk/GlobalActionManager.h index fbd985ef2..a7d519ff3 100644 --- a/src/libtomahawk/GlobalActionManager.h +++ b/src/libtomahawk/GlobalActionManager.h @@ -106,6 +106,7 @@ private: bool handleSearchCommand( const QUrl& url ); bool handleQueueCommand( const QUrl& url ); bool handleAutoPlaylistCommand( const QUrl& url ); + bool handleImportCommand( const QUrl& url ); bool doQueueAdd( const QStringList& parts, const QList< QPair< QString, QString > >& queryItems ); bool playSpotify( const QUrl& url );