File ksuseinstall.diff of Package kaffeine4

--- src/CMakeLists.txt	2010/07/07 18:16:03	1.1
+++ src/CMakeLists.txt	2010/07/07 18:17:30
@@ -42,6 +42,7 @@
 
 kde4_add_executable(kaffeine ${kaffeinedvb_SRCS} ${kaffeine_SRCS})
 target_link_libraries(kaffeine ${QT_QTSQL_LIBRARY} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS} ${KDE4_SOLID_LIBS} ${X11_Xscreensaver_LIB})
+target_link_libraries(kaffeine ksuseinstall)
 install(TARGETS kaffeine ${INSTALL_TARGETS_DEFAULT_ARGS})
 install(FILES scanfile.dvb DESTINATION ${DATA_INSTALL_DIR}/kaffeine)
 install(PROGRAMS kaffeine.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
--- src/backend-xine/xinecommands.h	2010/07/07 18:15:59	1.1
+++ src/backend-xine/xinecommands.h	2010/07/07 18:16:08
@@ -59,7 +59,8 @@
 		UpdateAngles		= 11,
 		UpdateMouseTracking	= 12,
 		UpdateMouseCursor	= 13,
-		UpdateVideoSize		= 14
+		UpdateVideoSize		= 14,
+		SupportedMimeTypes      = 15
 	};
 }
 
@@ -351,6 +352,13 @@
 			reinterpret_cast<const char *>(&videoSize), sizeof(videoSize));
 	}
 
+	void supportedMimeTypes(const QString& mime)
+	{
+		writer->write(XineCommands::SupportedMimeTypes,
+			reinterpret_cast<const char *>(mime.constData()),
+			static_cast<unsigned int>(mime.size()) * sizeof(QChar));
+	}
+
 	XinePipeWriterBase *writer;
 };
 
--- src/backend-xine/xinemediawidget.cpp.sav	2010-09-27 16:08:49.648890045 -0600
+++ src/backend-xine/xinemediawidget.cpp	2010-09-27 16:21:39.342889627 -0600
@@ -22,12 +22,16 @@
 #include "xinemediawidget_p.h"
 
 #include <QResizeEvent>
+#include <QTimer>
 #include <KDebug>
+#include <KLocale>
 #include <KMessageBox>
 #include <config-kaffeine.h>
 #include <errno.h>
 #include <unistd.h>
 
+#include <ksuseinstall.h>
+
 static QString binInstallPath()
 {
 	return QString::fromUtf8(KAFFEINE_BIN_INSTALL_DIR "/");
@@ -213,6 +217,15 @@
 
 			break;
 		    }
+		case XineCommands::SupportedMimeTypes: {
+			QString mime = reader->readString();
+
+			if (reader->isValid()) {
+				parent->supportedMimeTypes(mime);
+			}
+
+			break;
+		    }
 		default:
 			kError() << "unknown command" << command;
 			continue;
@@ -844,6 +857,45 @@
 	}
 }
 
+void XineMediaWidget::supportedMimeTypes(const QString &mime)
+{
+        // This is a bit lame, but simply check for a mimetype that the crippled package
+        // does not provide.
+        foreach( const QString& item, mime.split( ';' )) {
+            QStringList fields = item.split( ':' );
+            if( fields.count() == 3 ) {
+                if( fields.first() == "video/mp4" ) {
+                    return; // ok
+                }
+            }
+        }
+        QTimer::singleShot( 0, this, SLOT( installAdditionalCodecs()));
+}
+
+void XineMediaWidget::installAdditionalCodecs()
+{
+        KGuiItem installGuiItem( KStandardGuiItem::yes());
+        installGuiItem.setText( i18nc( "@action:button", "Install" ));
+        if( KMessageBox::warningYesNo( window(),
+            i18n( "Kaffeine currently cannot play some file formats. Do you want to install additional support?" ),
+            i18n( "Install Additional Codecs" ),
+            installGuiItem, KStandardGuiItem::no(), "suse_additional_codecs" ) != KMessageBox::Yes )
+            {
+            return;
+            }
+        if( KSUSEInstall::installCapabilities( QStringList() << "libxine2-codecs",
+                KSUSEInstall::FullInstallRequired, window()))
+            { // 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( window(),
+                i18n( "The necessary support has been successfully installed."
+                        " It may be necessary to restart the application for the support to be activated." ));
+            }
+}
+
 void XineMediaWidget::playEncodedUrl(const QByteArray &encodedUrl, StateFlags stateFlags)
 {
 	++sequenceNumber;

--- src/backend-xine/xinemediawidget.h.sav	2010-01-31 18:04:50.000000000 +0100
+++ src/backend-xine/xinemediawidget.h	2010-04-14 14:31:17.301512132 +0200
@@ -127,6 +127,9 @@ public:
 
 	Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)
 
+private slots:
+        void installAdditionalCodecs();
+
 private:
 	void mouseMoveEvent(QMouseEvent *event);
 	void mousePressEvent(QMouseEvent *event);
@@ -149,6 +152,7 @@ private:
 	void updateMouseTracking(bool mouseTrackingEnabled);
 	void updateMouseCursor(bool pointingMouseCursor);
 	void updateVideoSize(unsigned int videoSize_);
+	void supportedMimeTypes(const QString &mime);
 
 	void playEncodedUrl(const QByteArray &encodedUrl, StateFlags stateFlags = 0);
 	void stateChanged();
--- src/backend-xine/xineapplication.cpp.sav	2010-09-27 16:30:01.619888519 -0600
+++ src/backend-xine/xineapplication.cpp	2010-09-27 16:39:05.239888392 -0600
@@ -295,7 +295,11 @@
 	xine_config_load(engine,
 		QFile::encodeName(KStandardDirs::locateLocal("data", "kaffeine/xine-config")));
 	xine_init(engine);
-
+	
+	if( char* mimes = xine_get_mime_types( engine )) {
+	  parentProcess->supportedMimeTypes( mimes );
+	}
+	
 	QVector<const char *> audioDrivers;
 	audioDrivers.append("auto");
 
openSUSE Build Service is sponsored by