File indexing completed on 2024-05-19 04:50:19
0001 /**************************************************************************************** 0002 * Copyright (c) 2009 Nikolaj Hald Nielsen <nhn@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #include "MagnatuneUrlRunner.h" 0018 0019 #include <KLocalizedString> 0020 0021 MagnatuneUrlRunner::MagnatuneUrlRunner() 0022 : QObject() 0023 , AmarokUrlRunnerBase() 0024 { 0025 } 0026 0027 MagnatuneUrlRunner::~MagnatuneUrlRunner() 0028 { 0029 } 0030 0031 QString MagnatuneUrlRunner::command() const 0032 { 0033 return "service-magnatune"; 0034 } 0035 0036 QString MagnatuneUrlRunner::prettyCommand() const 0037 { 0038 return i18nc( "A type of command that triggers an action in the integrated Magnatune.com service", "Magnatune" ); 0039 } 0040 0041 QIcon MagnatuneUrlRunner::icon() const 0042 { 0043 return QIcon::fromTheme( "view-services-magnatune-amarok" ); 0044 } 0045 0046 bool MagnatuneUrlRunner::run( const AmarokUrl &url ) 0047 { 0048 DEBUG_BLOCK 0049 if ( !url.isNull() ) 0050 { 0051 QString command = url.args().value( "command" ); 0052 0053 if( command == "show_favorites" ) 0054 { 0055 Q_EMIT( showFavorites() ); 0056 } 0057 else if ( command == "show_home" ) 0058 { 0059 Q_EMIT( showHome() ); 0060 } 0061 else if ( command == "show_recommendations" ) 0062 { 0063 Q_EMIT( showRecommendations() ); 0064 } 0065 else if ( command == "download" || command == "purchase" || command == "buy" ) 0066 { 0067 //allow some aliases for this command as the context might make one of 0068 //them more appropriate. In any case, non and stream members will be given the 0069 //purchase dialog and will have to pay, download members will get the 0070 //free download 0071 0072 if ( url.args().keys().contains( "sku" ) ) 0073 { 0074 QString sku = url.args().value( "sku" ); 0075 Q_EMIT( buyOrDownload( sku ) ); 0076 } 0077 } 0078 else if ( command == "remove_favorite" ) 0079 { 0080 if ( url.args().keys().contains( "sku" ) ) 0081 { 0082 QString sku = url.args().value( "sku" ); 0083 debug() << "remove from favorites sku: " << sku; 0084 Q_EMIT( removeFromFavorites( sku ) ); 0085 } 0086 } 0087 0088 } 0089 return true; 0090 } 0091 0092