extragear/multimedia/amarok/src [POSSIBLY UNSAFE]

Gábor Lehel illissius at gmail.com
Sun May 28 00:30:02 CEST 2006


SVN commit 545638 by illissius:

Now amarok will look for a .desktop file and give the user to run what 
it tells it to when amaroK can't play MP3 files. The idea is that 
KUbuntu et. all can roll a tar ball with such a desktop file with a 
script to add the repository and install the MP3 debs automatically.

Look at amarok/src/engine/xine/amarok_xine-mp3_install.desktop for an 
example.

I made some changes without compiling because Gabor broke the system.
So good luck! 

Rokymotion: please promote doing this to the distro writers, at least 
once we're more sure that it works. Thanks.

CCMAIL:Amarok-promo at kde.org
CCMAIL:jr at jriddell.org



 M  +2 -1      Makefile.am  
 A             amarok_codecinstall.desktop  
 M  +2 -1      engine/xine/Makefile.am  
 A             engine/xine/amarok_xine-mp3_install.desktop  
 M  +9 -0      engine/xine/xine-engine.cpp  
 M  +25 -2     enginecontroller.cpp   [POSSIBLY UNSAFE: KRun::runCommand]
 M  +3 -0      enginecontroller.h  


--- trunk/extragear/multimedia/amarok/src/Makefile.am #545637:545638
@@ -203,7 +203,8 @@
     amarok.desktop
 
 kde_servicetypes_DATA = \
-    amarok_plugin.desktop
+    amarok_plugin.desktop \
+    amarok_codecinstall.desktop
 
 
 servicemenudir = \
--- trunk/extragear/multimedia/amarok/src/engine/xine/Makefile.am #545637:545638
@@ -1,5 +1,6 @@
 kde_module_LTLIBRARIES = libamarok_xine-engine.la
-kde_services_DATA = amarok_xine-engine.desktop
+kde_services_DATA = \ 
+	amarok_xine-engine.desktop
 
 INCLUDES = \
     -I$(top_srcdir)/amarok/src \
--- trunk/extragear/multimedia/amarok/src/engine/xine/xine-engine.cpp #545637:545638
@@ -17,7 +17,10 @@
 #include "xine-config.h"
 #include "xinecfg.h"
 #include "xine-engine.h"
+#include "amarok.h"
+//these files are from libamarok
 #include "playlist.h"
+#include "enginecontroller.h"
 
 AMAROK_EXPORT_PLUGIN( XineEngine )
 
@@ -77,6 +80,7 @@
     addPluginProperty( "HasCrossfade", "true" );
     #endif
     addPluginProperty("HasCDDA", "true"); // new property
+    debug() << "hello" << endl;
 }
 
 XineEngine::~XineEngine()
@@ -300,7 +304,12 @@
     QString body;
 
     if (!xine_get_stream_info( m_stream, XINE_STREAM_INFO_AUDIO_HANDLED ))
+    {
         body = i18n("There is no available decoder.");
+        const QString ext = amaroK::extension( m_url.url() ).lower();
+        if( ext == "mp3" && EngineController::installDistroCodec("xine-engine") )
+           return;
+    }
     else if (!xine_get_stream_info( m_stream, XINE_STREAM_INFO_HAS_AUDIO ))
         body = i18n("There is no audio channel!");
     else {
--- trunk/extragear/multimedia/amarok/src/enginecontroller.cpp #545637:545638
@@ -2,6 +2,7 @@
  *   Copyright (C) 2004 Frederik Holljen <fh at ez.no>                        *
  *             (C) 2004,5 Max Howell <max.howell at methylblue.com>           *
  *             (C) 2004,5 Mark Kretschmann                                 *
+ *             (C) 2006 Ian Monroe                                         *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -235,7 +236,7 @@
     const bool valid = engine()->canDecode( url );
 
     //we special case this as otherwise users hate us
-    if ( !valid && ext == "mp3" )
+    if ( !valid && ext.lower() == "mp3" && !installDistroCodec(AmarokConfig::soundSystem()) )
         amaroK::StatusBar::instance()->longMessageThreadSafe(
            i18n( "<p>The %1 claims it <b>cannot</b> play MP3 files."
                  "<p>You may want to choose a different engine from the <i>Configure Dialog</i>, or examine "
@@ -247,9 +248,31 @@
     if ( !ext.isEmpty() )
         extensionCache().insert( ext, valid );
 
-    return valid;
+    return valid;   
 }
 
+bool EngineController::installDistroCodec( const QString& engine /*Filetype type*/)
+{
+    KGuiItem installButton("Install MP3 Support");    
+    
+    if(KMessageBox::questionYesNo(PlaylistWindow::self()
+       , i18n("amaroK currently cannot play MP3 files.")
+       , i18n( "No MP3 Support" )
+       , installButton
+       , KStdGuiItem::no()
+       , "codecInstallWarning" )  )
+    {
+        KService::Ptr service = KTrader::self()->query( "amaroK/CodecInstall"
+            , QString("[X-KDE-amaroK-codec] == 'mp3' and [X-KDE-amaroK-engine] == '%1'").arg(engine) ).first();
+        QString installScript = service->exec();
+        if( !installScript.isNull() ) //just a sanity check
+        {
+            KRun::runCommand(installScript);
+            return true;
+        }
+    }
+    return false;
+}
 
 void EngineController::restoreSession()
 {
--- trunk/extragear/multimedia/amarok/src/enginecontroller.h #545637:545638
@@ -60,6 +60,9 @@
 
     //xx000, xx100, xx200, so at most will be 200ms delay before time displays are updated
     static const int MAIN_TIMER = 300;
+    
+    /*enum Filetype { MP3 };*/ //assuming MP3 for time being
+    LIBAMAROK_EXPORT static bool installDistroCodec(const QString& engine /*Filetype type*/);
 
 public slots:
     void previous();


More information about the Amarok-promo mailing list