--- src/EngineController.cpp 2008-09-06 19:14:14.000000000 -0300 +++ src/EngineController.cpp.new 2008-09-11 16:55:24.000000000 -0300 @@ -42,6 +42,7 @@ #include <QByteArray> #include <QFile> #include <QTimer> +#include <QList> EngineController::ExtensionCache EngineController::s_extensionCache; @@ -156,7 +157,8 @@ const bool valid = Phonon::BackendCapabilities::isMimeTypeAvailable( item.mimetype() ); //we special case this as otherwise users hate us - if ( !valid && ext.toLower() == "mp3" && !installDistroCodec() ) + if ( !valid && ext.toLower() == "mp3" ) + if ( !installDistroCodec() ) The::statusBar()->longMessageThreadSafe( i18n( "<p>Phonon claims it <b>cannot</b> play MP3 files. You may want to examine " "the installation of the backend that phonon uses.</p>" @@ -172,25 +174,35 @@ bool EngineController::installDistroCodec() { - KService::List services = KServiceTypeTrader::self()->query( "Amarok/CodecInstall" - , QString("[X-KDE-Amarok-codec] == 'mp3' and [X-KDE-Amarok-engine] == 'phonon-%1'").arg("xine") ); - //todo - figure out how to query Phonon for the current backend loaded - if( !services.isEmpty() ) - { - KService::Ptr service = services.first(); //list is not empty - QString installScript = service->exec(); - if( !installScript.isNull() ) //just a sanity check + KService::List services; + QList<QString> phononBackends; + + // Officially we have two linux backends, gstreamer and xine + phononBackends << "xine" << "gstreamer"; + + QList<QString>::const_iterator backend; + for( backend = phononBackends.constBegin(); backend != phononBackends.constEnd(); ++backend ) + { + services = KServiceTypeTrader::self()->query( "Amarok/CodecInstall", + QString("[X-KDE-Amarok-codec] == 'mp3' and [X-KDE-Amarok-engine] == 'phonon-%1'").arg( *backend ) ); + //todo - figure out how to query Phonon for the current backend loaded + if( !services.isEmpty() ) { - KGuiItem installButton( i18n( "Install MP3 Support" ) ); - if(KMessageBox::questionYesNo( The::mainWindow() - , i18n("Amarok currently cannot play MP3 files. Do you want to install support for MP3?") - , i18n( "No MP3 Support" ) - , installButton - , KStandardGuiItem::no() - , "codecInstallWarning" ) == KMessageBox::Yes ) + KService::Ptr service = services.first(); //list is not empty + QString installScript = service->exec(); + if( !installScript.isNull() ) //just a sanity check { + KGuiItem installButton( i18n( "Install MP3 Support" ) ); + if(KMessageBox::questionYesNo( The::mainWindow(), + i18n("Amarok currently cannot play MP3 files. Do you want to install support for MP3?"), + i18n( "No MP3 Support" ), + installButton, + KStandardGuiItem::no(), + "codecInstallWarning" ) == KMessageBox::Yes ) + { KRun::runCommand(installScript, 0); return true; + } } } }