ported and reenabled KDE integration (bnc#746591) firefox10
authorWolfgang Rosenauer <wr@rosenauer.org>
Tue, 21 Feb 2012 20:51:21 +0100
branchfirefox10
changeset 396 c7b8a6aede34
parent 393 997d2e729a8c
child 397 efe18be91213
ported and reenabled KDE integration (bnc#746591) explicitely build-require xorg-x11-devel
MozillaFirefox/MozillaFirefox.changes
MozillaFirefox/MozillaFirefox.spec
firefox-kde.patch
mozilla-kde.patch
--- a/MozillaFirefox/MozillaFirefox.changes	Sat Feb 18 22:28:33 2012 +0100
+++ b/MozillaFirefox/MozillaFirefox.changes	Tue Feb 21 20:51:21 2012 +0100
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Tue Feb 21 16:42:43 UTC 2012 - wr@rosenauer.org
+
+- ported and reenabled KDE integration (bnc#746591)
+- explicitely build-require xorg-x11-devel
+
 -------------------------------------------------------------------
 Fri Feb 17 17:41:11 UTC 2012 - pcerny@suse.com
 
--- a/MozillaFirefox/MozillaFirefox.spec	Sat Feb 18 22:28:33 2012 +0100
+++ b/MozillaFirefox/MozillaFirefox.spec	Tue Feb 21 20:51:21 2012 +0100
@@ -34,6 +34,7 @@
 BuildRequires:  startup-notification-devel
 BuildRequires:  unzip
 BuildRequires:  update-desktop-files
+BuildRequires:  xorg-x11-devel
 BuildRequires:  yasm
 BuildRequires:  zip
 %if %suse_version > 1110
@@ -206,7 +207,7 @@
 %patch2 -p1
 %patch3 -p1
 %patch4 -p1
-#%patch5 -p1
+%patch5 -p1
 %patch6 -p1
 %patch7 -p1
 %patch8 -p1
@@ -224,10 +225,10 @@
 %patch31 -p1
 %patch32 -p1
 %if %suse_version >= 1110
-#%patch33 -p1
+%patch33 -p1
 %endif
 %if %suse_version >= 1140
-#%patch34 -p1
+%patch34 -p1
 %endif
 %patch38 -p1
 %patch39 -p1
@@ -240,11 +241,11 @@
 TIME="\"$(date -d "${modified}" "+%%R")\""
 find . -regex ".*\.c\|.*\.cpp\|.*\.h" -exec sed -i "s/__DATE__/${DATE}/g;s/__TIME__/${TIME}/g" {} +
 #
-#kdehelperversion=$(cat toolkit/xre/nsKDEUtils.cpp | grep '#define KMOZILLAHELPER_VERSION' | cut -d ' ' -f 3)
-#if test "$kdehelperversion" != %{kde_helper_version}; then
-#  echo fix kde helper version in the .spec file
-#  exit 1
-#fi
+kdehelperversion=$(cat toolkit/xre/nsKDEUtils.cpp | grep '#define KMOZILLAHELPER_VERSION' | cut -d ' ' -f 3)
+if test "$kdehelperversion" != %{kde_helper_version}; then
+  echo fix kde helper version in the .spec file
+  exit 1
+fi
 source %{SOURCE5}
 export MOZ_SOURCE_STAMP=$REV
 export SOURCE_REPO=$REPO
--- a/firefox-kde.patch	Sat Feb 18 22:28:33 2012 +0100
+++ b/firefox-kde.patch	Tue Feb 21 20:51:21 2012 +0100
@@ -1270,7 +1270,7 @@
 new file mode 100644
 --- /dev/null
 +++ b/browser/components/shell/src/nsKDEShellService.cpp
-@@ -0,0 +1,193 @@
+@@ -0,0 +1,257 @@
 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 +/* ***** BEGIN LICENSE BLOCK *****
 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
@@ -1316,6 +1316,9 @@
 +#include "nsILocalFile.h"
 +#include "nsServiceManagerUtils.h"
 +#include "nsComponentManagerUtils.h"
++#include "nsIMutableArray.h"
++#include "nsISupportsPrimitives.h"
++#include "nsArrayUtils.h"
 +
 +nsresult
 +nsKDEShellService::Init()
@@ -1331,13 +1334,23 @@
 +nsKDEShellService::IsDefaultBrowser(bool aStartupCheck,
 +                                    bool* aIsDefaultBrowser)
 +    {
-+    *aIsDefaultBrowser = PR_FALSE;
++    *aIsDefaultBrowser = false;
 +    if (aStartupCheck)
-+        mCheckedThisSession = PR_TRUE;
-+    nsTArray<nsCString> command;
-+    command.AppendElement( NS_LITERAL_CSTRING( "ISDEFAULTBROWSER" ));
++        mCheckedThisSession = true;
++
++    nsCOMPtr<nsIMutableArray> command = do_CreateInstance( NS_ARRAY_CONTRACTID );
++    if (!command)
++        return NS_ERROR_FAILURE;
++
++    nsCOMPtr<nsISupportsCString> str = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
++    if (!str)
++        return NS_ERROR_FAILURE;
++
++    str->SetData( NS_LITERAL_CSTRING( "ISDEFAULTBROWSER" ));
++    command->AppendElement( str, false );
++
 +    if( nsKDEUtils::command( command ))
-+        *aIsDefaultBrowser = PR_TRUE;
++        *aIsDefaultBrowser = true;
 +    return NS_OK;
 +    }
 +
@@ -1345,9 +1358,21 @@
 +nsKDEShellService::SetDefaultBrowser(bool aClaimAllTypes,
 +                                     bool aForAllUsers)
 +    {
-+    nsTArray<nsCString> command;
-+    command.AppendElement( NS_LITERAL_CSTRING( "SETDEFAULTBROWSER" ));
-+    command.AppendElement( aClaimAllTypes ? NS_LITERAL_CSTRING( "ALLTYPES" ) : NS_LITERAL_CSTRING( "NORMAL" ));
++    nsCOMPtr<nsIMutableArray> command = do_CreateInstance( NS_ARRAY_CONTRACTID );
++    if (!command)
++        return NS_ERROR_FAILURE;
++
++    nsCOMPtr<nsISupportsCString> cmdstr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
++    nsCOMPtr<nsISupportsCString> paramstr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
++    if (!cmdstr || !paramstr)
++        return NS_ERROR_FAILURE;
++
++    cmdstr->SetData( NS_LITERAL_CSTRING( "SETDEFAULTBROWSER" ));
++    command->AppendElement( cmdstr, false );
++
++    paramstr->SetData( aClaimAllTypes ? NS_LITERAL_CSTRING( "ALLTYPES" ) : NS_LITERAL_CSTRING( "NORMAL" ));
++    command->AppendElement( paramstr, false );
++
 +    return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
 +    }
 +
@@ -1357,7 +1382,7 @@
 +  // If we've already checked, the browser has been started and this is a
 +  // new window open, and we don't want to check again.
 +  if (mCheckedThisSession) {
-+    *aResult = PR_FALSE;
++    *aResult = false;
 +    return NS_OK;
 +  }
 +
@@ -1387,7 +1412,7 @@
 +}
 +
 +NS_IMETHODIMP
-+nsKDEShellService::SetDesktopBackground(nsIDOMElement* aElement, 
++nsKDEShellService::SetDesktopBackground(nsIDOMElement* aElement,
 +                                          PRInt32 aPosition)
 +    {
 +    return NS_ERROR_NOT_IMPLEMENTED;
@@ -1408,26 +1433,47 @@
 +NS_IMETHODIMP
 +nsKDEShellService::OpenApplication(PRInt32 aApplication)
 +    {
-+    nsTArray<nsCString> command;
++    nsCOMPtr<nsIMutableArray> command = do_CreateInstance( NS_ARRAY_CONTRACTID );
++    if (!command)
++        return NS_ERROR_FAILURE;
++
++    nsCOMPtr<nsISupportsCString> str = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
++    if (!str)
++        return NS_ERROR_FAILURE;
++
 +    if( aApplication == APPLICATION_MAIL )
-+        command.AppendElement( NS_LITERAL_CSTRING( "OPENMAIL" ));
++        str->SetData( NS_LITERAL_CSTRING( "OPENMAIL" ));
 +    else if( aApplication == APPLICATION_NEWS )
-+        command.AppendElement( NS_LITERAL_CSTRING( "OPENNEWS" ));
++        str->SetData( NS_LITERAL_CSTRING( "OPENNEWS" ));
 +    else
 +        return NS_ERROR_NOT_IMPLEMENTED;
++
++    command->AppendElement( str, false );
 +    return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
 +    }
 +
 +NS_IMETHODIMP
 +nsKDEShellService::OpenApplicationWithURI(nsILocalFile* aApplication, const nsACString& aURI)
 +    {
-+    nsTArray<nsCString> command;
-+    command.AppendElement( NS_LITERAL_CSTRING( "RUN" ));
-+    nsCString app;
++    nsCOMPtr<nsIMutableArray> command = do_CreateInstance( NS_ARRAY_CONTRACTID );
++    if (!command)
++        return NS_ERROR_FAILURE;
++
++    nsCOMPtr<nsISupportsCString> cmdstr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
++    nsCOMPtr<nsISupportsCString> appstr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
++    nsCOMPtr<nsISupportsCString> uristr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
++    if (!cmdstr || !appstr || !uristr)
++        return NS_ERROR_FAILURE;
++
++    cmdstr->SetData( NS_LITERAL_CSTRING( "RUN" ));
++    command->AppendElement( cmdstr, false );
++    nsCAutoString app;
 +    nsresult rv = aApplication->GetNativePath( app );
 +    NS_ENSURE_SUCCESS( rv, rv );
-+    command.AppendElement( app );
-+    command.AppendElement( aURI );
++    appstr->SetData( app );
++    command->AppendElement( appstr, false );
++    uristr->SetData( aURI );
++    command->AppendElement( uristr, false );
 +    return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
 +    }
 +
@@ -1436,14 +1482,32 @@
 +    {
 +    *_retval = nsnull;
 +
-+    nsTArray<nsCString> command;
-+    command.AppendElement( NS_LITERAL_CSTRING( "GETDEFAULTFEEDREADER" ));
-+    nsTArray<nsCString> output;
-+    if( !nsKDEUtils::command( command, &output ) || output.Length() != 1 )
++    nsCOMPtr<nsIMutableArray> command = do_CreateInstance( NS_ARRAY_CONTRACTID );
++    if( !command )
++        return NS_ERROR_FAILURE;
++
++    nsCOMPtr<nsISupportsCString> str = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
++    if( !str )
 +        return NS_ERROR_FAILURE;
 +
-+    nsCString path;
-+    path = output[ 0 ];
++    str->SetData( NS_LITERAL_CSTRING( "GETDEFAULTFEEDREADER" ));
++    command->AppendElement( str, false );
++
++    nsCOMPtr<nsIArray> output;
++    if( !nsKDEUtils::command( command, getter_AddRefs( output ) ) )
++        return NS_ERROR_FAILURE;
++
++    PRUint32 length;
++    output->GetLength( &length );
++    if( length != 1 )
++        return NS_ERROR_FAILURE;
++
++    nsCOMPtr<nsISupportsCString> resstr = do_QueryElementAt( output, 0 );
++    if( !resstr )
++        return NS_ERROR_FAILURE;
++
++    nsCAutoString path;
++    resstr->GetData( path );
 +    if (path.IsEmpty())
 +        return NS_ERROR_FAILURE;
 +
--- a/mozilla-kde.patch	Sat Feb 18 22:28:33 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). */