File ksuseinstall.diff of Package amarok

--- amarok-2.3.90/src/CMakeLists.txt	2010-12-05 22:08:01.000000000 +0100
+++ new/src/CMakeLists.txt	2010-12-13 11:55:22.209999993 +0100
@@ -910,6 +910,7 @@
     amarokcore
     amarokocsclient
     amarok-transcoding
+    ksuseinstall
 )
 
 if(KDE4_BUILD_TESTS)
--- amarok-2.3.90/src/EngineController.cpp	2010-12-05 22:08:01.000000000 +0100
+++ new/src/EngineController.cpp	2010-12-13 11:54:22.860999993 +0100
@@ -58,6 +58,8 @@
 
 #include <cmath>
 
+#include <ksuseinstall.h>
+
 namespace The {
     EngineController* engineController() { return EngineController::instance(); }
 }
@@ -276,6 +278,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
@@ -285,6 +288,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?")
@@ -293,11 +302,29 @@
             , KStandardGuiItem::no()
             , "codecInstallWarning" ) == KMessageBox::Yes )
             {
+#if 0
                     KRun::runCommand(installScript, 0);
                     return true;
+#else
+                    if( KSUSEInstall::installCapabilities( QStringList() << "libxine1-codecs",
+                        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