--- a/mozilla-kde.patch Tue Feb 21 16:36:37 2012 +0100
+++ b/mozilla-kde.patch Tue Feb 21 20:51:21 2012 +0100
@@ -1,3 +1,9 @@
+Description: Add KDE integration to Firefox (toolkit parts)
+Author: Wolfgang Rosenauer <wolfgang@rosenauer.org>
+Author: Lubos Lunak <lunak@suse.com>
+Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=140751
+ https://bugzilla.novell.com/show_bug.cgi?id=170055
+
diff --git a/modules/libpref/src/Makefile.in b/modules/libpref/src/Makefile.in
--- a/modules/libpref/src/Makefile.in
+++ b/modules/libpref/src/Makefile.in
@@ -2171,9 +2177,9 @@
+ command.AppendElement( NS_LITERAL_CSTRING( "GETPROXY" ));
+ command.AppendElement( url );
+ nsTArray<nsCString> result;
-+ if( !nsKDEUtils::command( command, &result ) || result.Count() != 1 )
++ if( !nsKDEUtils::command( command, &result ) || result.Length() != 1 )
+ return NS_ERROR_FAILURE;
-+ aResult = *result[ 0 ];
++ aResult = result[0];
+ return NS_OK;
+}
+
@@ -2204,7 +2210,7 @@
new file mode 100644
--- /dev/null
+++ b/toolkit/xre/nsKDEUtils.cpp
-@@ -0,0 +1,330 @@
+@@ -0,0 +1,372 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
@@ -2244,6 +2250,10 @@
+
+#include "nsKDEUtils.h"
+#include "nsIWidget.h"
++#include "nsISupportsPrimitives.h"
++#include "nsIMutableArray.h"
++#include "nsComponentManagerUtils.h"
++#include "nsArrayUtils.h"
+
+#include <gtk/gtk.h>
+
@@ -2302,7 +2312,7 @@
+ nsTArray<nsCString> command;
+ command.AppendElement( NS_LITERAL_CSTRING( "CHECK" ));
+ command.AppendElement( NS_LITERAL_CSTRING( MAKE_STR( KMOZILLAHELPER_VERSION )));
-+ bool kde = nsKDEUtils::command( command.get() );
++ bool kde = nsKDEUtils::command( command );
+#ifdef DEBUG_KDE
+ fprintf( stderr, "KDE RUNNING %d\n", kde );
+#endif
@@ -2395,6 +2405,46 @@
+ return self()->internalCommand( command, NULL, false, output );
+ }
+
++bool nsKDEUtils::command( nsIArray* command, nsIArray** output)
++ {
++ NS_ENSURE_ARG( command );
++
++ nsTArray<nsCString> in;
++ PRUint32 length;
++ command->GetLength( &length );
++ for ( PRUint32 i = 0; i < length; i++ )
++ {
++ nsCOMPtr<nsISupportsCString> str = do_QueryElementAt( command, i );
++ if( str )
++ {
++ nsCAutoString s;
++ str->GetData( s );
++ in.AppendElement( s );
++ }
++ }
++
++ nsTArray<nsCString> out;
++ bool ret = self()->internalCommand( in, NULL, false, &out );
++
++ if ( !output ) return ret;
++
++ nsCOMPtr<nsIMutableArray> result = do_CreateInstance( NS_ARRAY_CONTRACTID );
++ if ( !result ) return false;
++
++ for ( PRUint32 i = 0; i < out.Length(); i++ )
++ {
++ nsCOMPtr<nsISupportsCString> rstr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
++ if ( !rstr ) return false;
++
++ rstr->SetData( out[i] );
++ result->AppendElement( rstr, false );
++ }
++
++ NS_ADDREF( *output = result);
++ return ret;
++ }
++
++
+bool nsKDEUtils::commandBlockUi( const nsTArray<nsCString>& command, const GtkWindow* parent, nsTArray<nsCString>* output )
+ {
+ return self()->internalCommand( command, parent, true, output );
@@ -2403,11 +2453,9 @@
+bool nsKDEUtils::internalCommand( const nsTArray<nsCString>& command, const GtkWindow* parent, bool blockUi,
+ nsTArray<nsCString>* output )
+ {
-+ nsCString internal_command;
-+ internal_command.AssignLiteral(command);
+ if( !startHelper())
+ return false;
-+ feedCommand(internal_command);
++ feedCommand( command );
+ // do not store the data in 'this' but in extra structure, just in case there
+ // is reentrancy (can there be? the event loop is re-entered)
+ nsKDECommandData data;
@@ -2539,7 +2587,7 @@
new file mode 100644
--- /dev/null
+++ b/toolkit/xre/nsKDEUtils.h
-@@ -0,0 +1,78 @@
+@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * ***** BEGIN LICENSE BLOCK *****
@@ -2587,6 +2635,8 @@
+
+typedef struct _GtkWindow GtkWindow;
+
++class nsIArray;
++
+class NS_EXPORT nsKDEUtils
+ {
+ public:
@@ -2599,6 +2649,7 @@
+ static bool kdeSupport();
+ /* Executes the given helper command, returns true if helper returned success. */
+ static bool command( const nsTArray<nsCString>& command, nsTArray<nsCString>* output = NULL );
++ static bool command( nsIArray* command, nsIArray** output = NULL );
+ /* Like command(), but additionally blocks the parent widget like if there was
+ a modal dialog shown and enters the event loop (i.e. there are still paint updates,
+ this is for commands that take long). */