File ksuseinstall.diff of Package amarok.openSUSE_12.1_Update

diff -uNr amarok-2.4.3.orig/src/CMakeLists.txt amarok-2.4.3/src/CMakeLists.txt
--- amarok-2.4.3.orig/src/CMakeLists.txt	2011-07-28 16:04:45.000000000 +0300
+++ amarok-2.4.3/src/CMakeLists.txt	2011-08-01 20:24:43.751000029 +0300
@@ -918,6 +918,7 @@
     amarokcore
     amarokocsclient
     amarok-transcoding
+    ksuseinstall
 )
 
 if( TAGLIB_FOUND )
diff -uNr amarok-2.4.3.orig/src/EngineController.cpp amarok-2.4.3/src/EngineController.cpp
--- amarok-2.4.3.orig/src/EngineController.cpp	2011-07-28 16:04:45.000000000 +0300
+++ amarok-2.4.3/src/EngineController.cpp	2011-08-01 20:28:18.760000029 +0300
@@ -54,6 +54,8 @@
 #include <QTextDocument>
 #include <QtCore/qmath.h>
 
+#include <ksuseinstall.h>
+
 namespace The {
     EngineController* engineController() { return EngineController::instance(); }
 }
@@ -280,6 +282,7 @@
 bool
 EngineController::installDistroCodec()
 {
+#if 0
     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
@@ -289,6 +292,12 @@
         QString installScript = service->exec();
         if( !installScript.isNull() ) //just a sanity check
         {
+#else
+    // amarok restart may be required, do not complain repeatedly in such case
+    static bool alreadyDone = false;
+    if( alreadyDone )
+        return true;
+#endif
             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?")
@@ -297,11 +306,29 @@
             , KStandardGuiItem::no()
             , "codecInstallWarning" ) == KMessageBox::Yes )
             {
+#if 0
                     KRun::runCommand(installScript, 0);
                     return true;
+#else
+                    if( KSUSEInstall::installCapabilities( QStringList() << "gstreamer-0_10-fluendo-mp3",
+                        KSUSEInstall::FullInstallRequired, The::mainWindow()))
+                    { // TODO use the items
+                        KGuiItem restartNowGuiItem( KStandardGuiItem::yes());
+                        restartNowGuiItem.setText( i18nc( "@action:button", "Restart Now" ));
+                        KGuiItem restartLaterGuiItem( KStandardGuiItem::no());
+                        restartLaterGuiItem.setText( i18nc( "@action:button", "Restart Later" ));
+                        KMessageBox::information( The::mainWindow(),
+                            i18n( "The necessary support has been successfully installed."
+                                " It may be necessary to restart the application for the support to be activated." ));
+                        alreadyDone = true;
+                        return true;
+                    }
+#endif
             }
+#if 0
         }
     }
+#endif
 
     return false;
 }
openSUSE Build Service is sponsored by