v96.0.2-1: fix kde patch
This commit is contained in:
parent
fc16f6ba32
commit
76feb8fb78
1 changed files with 643 additions and 25 deletions
|
|
@ -1,7 +1,7 @@
|
|||
From 19d8aa8d36e560616b3ff08358ed9e4e285ded10 Mon Sep 17 00:00:00 2001
|
||||
From 98a25a4e07e06d0e74d49bf9728c81e157fa7d5a Mon Sep 17 00:00:00 2001
|
||||
From: evs-ch <evs-ch@users.noreply.github.com>
|
||||
Date: Fri, 21 Jan 2022 13:14:43 +0100
|
||||
Subject: [PATCH] kde patch if applied after unity patch
|
||||
Date: Fri, 21 Jan 2022 15:38:38 +0100
|
||||
Subject: [PATCH] kde
|
||||
|
||||
---
|
||||
modules/libpref/Preferences.cpp | 14 +-
|
||||
|
|
@ -9,23 +9,35 @@ Subject: [PATCH] kde patch if applied after unity patch
|
|||
python/mozbuild/mozpack/chrome/flags.py | 1 +
|
||||
python/mozbuild/mozpack/chrome/manifest.py | 1 +
|
||||
toolkit/components/downloads/moz.build | 4 +
|
||||
toolkit/mozapps/downloads/HelperAppDlg.jsm | 70 +++--
|
||||
.../unixproxy/nsUnixSystemProxySettings.cpp | 32 +++
|
||||
toolkit/mozapps/downloads/HelperAppDlg.jsm | 70 ++--
|
||||
.../unixproxy/nsUnixSystemProxySettings.cpp | 32 ++
|
||||
toolkit/xre/moz.build | 2 +
|
||||
toolkit/xre/nsKDEUtils.cpp | 321 ++++++++++++++++++
|
||||
toolkit/xre/nsKDEUtils.h | 48 +++
|
||||
uriloader/exthandler/HandlerServiceParent.cpp | 6 +-
|
||||
uriloader/exthandler/moz.build | 3 +
|
||||
.../exthandler/unix/nsCommonRegistry.cpp | 53 +++
|
||||
uriloader/exthandler/unix/nsCommonRegistry.h | 28 ++
|
||||
uriloader/exthandler/unix/nsKDERegistry.cpp | 86 +++++
|
||||
uriloader/exthandler/unix/nsKDERegistry.h | 34 ++
|
||||
uriloader/exthandler/unix/nsMIMEInfoUnix.cpp | 30 +-
|
||||
.../exthandler/unix/nsOSHelperAppService.cpp | 10 +-
|
||||
widget/gtk/moz.build | 1 +
|
||||
widget/gtk/nsFilePicker.cpp | 258 +++++++++++++++++-
|
||||
widget/gtk/nsFilePicker.cpp | 258 +++++++++++++-
|
||||
widget/gtk/nsFilePicker.h | 6 +
|
||||
xpcom/components/ManifestParser.cpp | 11 +-
|
||||
xpcom/components/moz.build | 1 +
|
||||
xpcom/io/nsLocalFileUnix.cpp | 28 +-
|
||||
18 files changed, 440 insertions(+), 42 deletions(-)
|
||||
24 files changed, 1010 insertions(+), 42 deletions(-)
|
||||
create mode 100644 toolkit/xre/nsKDEUtils.cpp
|
||||
create mode 100644 toolkit/xre/nsKDEUtils.h
|
||||
create mode 100644 uriloader/exthandler/unix/nsCommonRegistry.cpp
|
||||
create mode 100644 uriloader/exthandler/unix/nsCommonRegistry.h
|
||||
create mode 100644 uriloader/exthandler/unix/nsKDERegistry.cpp
|
||||
create mode 100644 uriloader/exthandler/unix/nsKDERegistry.h
|
||||
|
||||
diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp
|
||||
index 27b1f2312..51d093cf0 100644
|
||||
index 27b1f2312e..51d093cf07 100644
|
||||
--- a/modules/libpref/Preferences.cpp
|
||||
+++ b/modules/libpref/Preferences.cpp
|
||||
@@ -89,6 +89,7 @@
|
||||
|
|
@ -64,7 +76,7 @@ index 27b1f2312..51d093cf0 100644
|
|||
}
|
||||
|
||||
diff --git a/modules/libpref/moz.build b/modules/libpref/moz.build
|
||||
index 9d76b9085..467227ccc 100644
|
||||
index 9d76b9085e..467227ccc9 100644
|
||||
--- a/modules/libpref/moz.build
|
||||
+++ b/modules/libpref/moz.build
|
||||
@@ -124,6 +124,10 @@ UNIFIED_SOURCES += [
|
||||
|
|
@ -79,7 +91,7 @@ index 9d76b9085..467227ccc 100644
|
|||
|
||||
GeneratedFile(
|
||||
diff --git a/python/mozbuild/mozpack/chrome/flags.py b/python/mozbuild/mozpack/chrome/flags.py
|
||||
index 7d6d7e0c7..724c527b4 100644
|
||||
index 7d6d7e0c7f..724c527b4c 100644
|
||||
--- a/python/mozbuild/mozpack/chrome/flags.py
|
||||
+++ b/python/mozbuild/mozpack/chrome/flags.py
|
||||
@@ -234,6 +234,7 @@ class Flags(OrderedDict):
|
||||
|
|
@ -91,7 +103,7 @@ index 7d6d7e0c7..724c527b4 100644
|
|||
RE = re.compile(r"([!<>=]+)")
|
||||
|
||||
diff --git a/python/mozbuild/mozpack/chrome/manifest.py b/python/mozbuild/mozpack/chrome/manifest.py
|
||||
index a733685f9..f64b17fb7 100644
|
||||
index a733685f95..f64b17fb7b 100644
|
||||
--- a/python/mozbuild/mozpack/chrome/manifest.py
|
||||
+++ b/python/mozbuild/mozpack/chrome/manifest.py
|
||||
@@ -44,6 +44,7 @@ class ManifestEntry(object):
|
||||
|
|
@ -103,7 +115,7 @@ index a733685f9..f64b17fb7 100644
|
|||
|
||||
def __init__(self, base, *flags):
|
||||
diff --git a/toolkit/components/downloads/moz.build b/toolkit/components/downloads/moz.build
|
||||
index 19ae8dcb5..e206a816e 100644
|
||||
index 19ae8dcb56..e206a816ec 100644
|
||||
--- a/toolkit/components/downloads/moz.build
|
||||
+++ b/toolkit/components/downloads/moz.build
|
||||
@@ -50,5 +50,9 @@ if CONFIG["MOZ_PLACES"]:
|
||||
|
|
@ -117,7 +129,7 @@ index 19ae8dcb5..e206a816e 100644
|
|||
with Files("**"):
|
||||
BUG_COMPONENT = ("Toolkit", "Downloads API")
|
||||
diff --git a/toolkit/mozapps/downloads/HelperAppDlg.jsm b/toolkit/mozapps/downloads/HelperAppDlg.jsm
|
||||
index 9b0c901c2..f80be96d7 100644
|
||||
index 9b0c901c27..f80be96d75 100644
|
||||
--- a/toolkit/mozapps/downloads/HelperAppDlg.jsm
|
||||
+++ b/toolkit/mozapps/downloads/HelperAppDlg.jsm
|
||||
@@ -1236,26 +1236,56 @@ nsUnknownContentTypeDialog.prototype = {
|
||||
|
|
@ -198,7 +210,7 @@ index 9b0c901c2..f80be96d7 100644
|
|||
var nsIFilePicker = Ci.nsIFilePicker;
|
||||
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
|
||||
diff --git a/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp b/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
|
||||
index f8d088054..091ccf3d9 100644
|
||||
index f8d0880545..091ccf3d9e 100644
|
||||
--- a/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
|
||||
+++ b/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
|
||||
@@ -18,6 +18,7 @@
|
||||
|
|
@ -262,7 +274,7 @@ index f8d088054..091ccf3d9 100644
|
|||
auto result = MakeRefPtr<nsUnixSystemProxySettings>();
|
||||
result->Init();
|
||||
diff --git a/toolkit/xre/moz.build b/toolkit/xre/moz.build
|
||||
index e39d75d60..cd287739b 100644
|
||||
index e39d75d603..cd287739b8 100644
|
||||
--- a/toolkit/xre/moz.build
|
||||
+++ b/toolkit/xre/moz.build
|
||||
@@ -97,7 +97,9 @@ elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "uikit":
|
||||
|
|
@ -275,8 +287,389 @@ index e39d75d60..cd287739b 100644
|
|||
"nsNativeAppSupportUnix.cpp",
|
||||
]
|
||||
CXXFLAGS += CONFIG["MOZ_X11_SM_CFLAGS"]
|
||||
diff --git a/toolkit/xre/nsKDEUtils.cpp b/toolkit/xre/nsKDEUtils.cpp
|
||||
new file mode 100644
|
||||
index 0000000000..7a6edf0770
|
||||
--- /dev/null
|
||||
+++ b/toolkit/xre/nsKDEUtils.cpp
|
||||
@@ -0,0 +1,321 @@
|
||||
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
+/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
+
|
||||
+#include "nsKDEUtils.h"
|
||||
+#include "nsIWidget.h"
|
||||
+#include "nsISupportsPrimitives.h"
|
||||
+#include "nsIMutableArray.h"
|
||||
+#include "nsComponentManagerUtils.h"
|
||||
+#include "nsArrayUtils.h"
|
||||
+
|
||||
+#include <gtk/gtk.h>
|
||||
+
|
||||
+#include <limits.h>
|
||||
+#include <stdio.h>
|
||||
+#include <sys/wait.h>
|
||||
+#include <sys/resource.h>
|
||||
+#include <unistd.h>
|
||||
+#include <X11/Xlib.h>
|
||||
+// copied from X11/X.h as a hack since for an unknown
|
||||
+// reason it's not picked up from X11/X.h
|
||||
+#ifndef None
|
||||
+#define None 0L /* universal null resource or null atom */
|
||||
+#endif
|
||||
+
|
||||
+//#define DEBUG_KDE
|
||||
+#ifdef DEBUG_KDE
|
||||
+#define KMOZILLAHELPER "kmozillahelper"
|
||||
+#else
|
||||
+// not need for lib64, it's a binary
|
||||
+#define KMOZILLAHELPER "/usr/lib/mozilla/kmozillahelper"
|
||||
+#endif
|
||||
+
|
||||
+#define KMOZILLAHELPER_VERSION 6
|
||||
+#define MAKE_STR2( n ) #n
|
||||
+#define MAKE_STR( n ) MAKE_STR2( n )
|
||||
+
|
||||
+static bool getKdeSession()
|
||||
+{
|
||||
+ if (PR_GetEnv("KDE_FULL_SESSION"))
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static bool getKdeSupport()
|
||||
+ {
|
||||
+ nsTArray<nsCString> command;
|
||||
+ command.AppendElement( "CHECK"_ns );
|
||||
+ command.AppendElement( "KMOZILLAHELPER_VERSION"_ns );
|
||||
+ bool kde = nsKDEUtils::command( command );
|
||||
+#ifdef DEBUG_KDE
|
||||
+ fprintf( stderr, "KDE RUNNING %d\n", kde );
|
||||
+#endif
|
||||
+ return kde;
|
||||
+ }
|
||||
+
|
||||
+nsKDEUtils::nsKDEUtils()
|
||||
+ : commandFile( NULL )
|
||||
+ , replyFile( NULL )
|
||||
+ {
|
||||
+ }
|
||||
+
|
||||
+nsKDEUtils::~nsKDEUtils()
|
||||
+ {
|
||||
+// closeHelper(); not actually useful, exiting will close the fd too
|
||||
+ }
|
||||
+
|
||||
+nsKDEUtils* nsKDEUtils::self()
|
||||
+ {
|
||||
+ static nsKDEUtils s;
|
||||
+ return &s;
|
||||
+ }
|
||||
+
|
||||
+static bool helperRunning = false;
|
||||
+static bool helperFailed = false;
|
||||
+
|
||||
+bool nsKDEUtils::kdeSession()
|
||||
+ {
|
||||
+ static bool session = getKdeSession();
|
||||
+ return session;
|
||||
+ }
|
||||
+
|
||||
+bool nsKDEUtils::kdeSupport()
|
||||
+ {
|
||||
+ static bool support = kdeSession() && getKdeSupport();
|
||||
+ return support && helperRunning;
|
||||
+ }
|
||||
+
|
||||
+struct nsKDECommandData
|
||||
+ {
|
||||
+ FILE* file;
|
||||
+ nsTArray<nsCString>* output;
|
||||
+ GMainLoop* loop;
|
||||
+ bool success;
|
||||
+ };
|
||||
+
|
||||
+static gboolean kdeReadFunc( GIOChannel*, GIOCondition, gpointer data )
|
||||
+ {
|
||||
+ nsKDECommandData* p = static_cast< nsKDECommandData* >( data );
|
||||
+ char buf[ 8192 ]; // TODO big enough
|
||||
+ bool command_done = false;
|
||||
+ bool command_failed = false;
|
||||
+ while( !command_done && !command_failed && fgets( buf, 8192, p->file ) != NULL )
|
||||
+ { // TODO what if the kernel splits a line into two chunks?
|
||||
+//#ifdef DEBUG_KDE
|
||||
+// fprintf( stderr, "READ: %s %d\n", buf, feof( p->file ));
|
||||
+//#endif
|
||||
+ if( char* eol = strchr( buf, '\n' ))
|
||||
+ *eol = '\0';
|
||||
+ command_done = ( strcmp( buf, "\\1" ) == 0 );
|
||||
+ command_failed = ( strcmp( buf, "\\0" ) == 0 );
|
||||
+ nsAutoCString line( buf );
|
||||
+ line.ReplaceSubstring( "\\n", "\n" );
|
||||
+ line.ReplaceSubstring( "\\" "\\", "\\" ); // \\ -> \ , i.e. unescape
|
||||
+ if( p->output && !( command_done || command_failed ))
|
||||
+ p->output->AppendElement( nsCString( buf )); // TODO utf8?
|
||||
+ }
|
||||
+ bool quit = false;
|
||||
+ if( feof( p->file ) || command_failed )
|
||||
+ {
|
||||
+ quit = true;
|
||||
+ p->success = false;
|
||||
+ }
|
||||
+ if( command_done )
|
||||
+ { // reading one reply finished
|
||||
+ quit = true;
|
||||
+ p->success = true;
|
||||
+ }
|
||||
+ if( quit )
|
||||
+ {
|
||||
+ if( p->loop )
|
||||
+ g_main_loop_quit( p->loop );
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ return TRUE;
|
||||
+ }
|
||||
+
|
||||
+bool nsKDEUtils::command( const nsTArray<nsCString>& command, nsTArray<nsCString>* output )
|
||||
+ {
|
||||
+ return self()->internalCommand( command, NULL, false, output );
|
||||
+ }
|
||||
+
|
||||
+bool nsKDEUtils::command( nsIArray* command, nsIArray** output)
|
||||
+ {
|
||||
+ nsTArray<nsCString> in;
|
||||
+ PRUint32 length;
|
||||
+ command->GetLength( &length );
|
||||
+ for ( PRUint32 i = 0; i < length; i++ )
|
||||
+ {
|
||||
+ nsCOMPtr<nsISupportsCString> str = do_QueryElementAt( command, i );
|
||||
+ if( str )
|
||||
+ {
|
||||
+ nsAutoCString 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 );
|
||||
+ }
|
||||
+
|
||||
+ NS_ADDREF( *output = result);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+bool nsKDEUtils::commandBlockUi( const nsTArray<nsCString>& command, GtkWindow* parent, nsTArray<nsCString>* output )
|
||||
+ {
|
||||
+ return self()->internalCommand( command, parent, true, output );
|
||||
+ }
|
||||
+
|
||||
+bool nsKDEUtils::internalCommand( const nsTArray<nsCString>& command, GtkWindow* parent, bool blockUi,
|
||||
+ nsTArray<nsCString>* output )
|
||||
+ {
|
||||
+ if( !startHelper())
|
||||
+ return false;
|
||||
+ 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;
|
||||
+ data.file = replyFile;
|
||||
+ data.output = output;
|
||||
+ data.success = false;
|
||||
+ if( blockUi )
|
||||
+ {
|
||||
+ data.loop = g_main_loop_new( NULL, FALSE );
|
||||
+ GtkWidget* window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
|
||||
+ if( parent && gtk_window_get_group(parent) )
|
||||
+ gtk_window_group_add_window( gtk_window_get_group(parent), GTK_WINDOW( window ));
|
||||
+ gtk_widget_realize( window );
|
||||
+ gtk_widget_set_sensitive( window, TRUE );
|
||||
+ gtk_grab_add( window );
|
||||
+ GIOChannel* channel = g_io_channel_unix_new( fileno( data.file ));
|
||||
+ g_io_add_watch( channel, static_cast< GIOCondition >( G_IO_IN | G_IO_ERR | G_IO_HUP ), kdeReadFunc, &data );
|
||||
+ g_io_channel_unref( channel );
|
||||
+ g_main_loop_run( data.loop );
|
||||
+ g_main_loop_unref( data.loop );
|
||||
+ gtk_grab_remove( window );
|
||||
+ gtk_widget_destroy( window );
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ data.loop = NULL;
|
||||
+ while( kdeReadFunc( NULL, static_cast< GIOCondition >( 0 ), &data ))
|
||||
+ ;
|
||||
+ }
|
||||
+ return data.success;
|
||||
+ }
|
||||
+
|
||||
+bool nsKDEUtils::startHelper()
|
||||
+ {
|
||||
+ if( helperRunning )
|
||||
+ return true;
|
||||
+ if( helperFailed )
|
||||
+ return false;
|
||||
+ helperFailed = true;
|
||||
+ int fdcommand[ 2 ];
|
||||
+ int fdreply[ 2 ];
|
||||
+ if( pipe( fdcommand ) < 0 )
|
||||
+ return false;
|
||||
+ if( pipe( fdreply ) < 0 )
|
||||
+ {
|
||||
+ close( fdcommand[ 0 ] );
|
||||
+ close( fdcommand[ 1 ] );
|
||||
+ return false;
|
||||
+ }
|
||||
+ char* args[ 2 ] = { const_cast< char* >( KMOZILLAHELPER ), NULL };
|
||||
+ switch( fork())
|
||||
+ {
|
||||
+ case -1:
|
||||
+ {
|
||||
+ close( fdcommand[ 0 ] );
|
||||
+ close( fdcommand[ 1 ] );
|
||||
+ close( fdreply[ 0 ] );
|
||||
+ close( fdreply[ 1 ] );
|
||||
+ return false;
|
||||
+ }
|
||||
+ case 0: // child
|
||||
+ {
|
||||
+ if( dup2( fdcommand[ 0 ], STDIN_FILENO ) < 0 )
|
||||
+ _exit( 1 );
|
||||
+ if( dup2( fdreply[ 1 ], STDOUT_FILENO ) < 0 )
|
||||
+ _exit( 1 );
|
||||
+ int maxfd = 1024; // close all other fds
|
||||
+ struct rlimit rl;
|
||||
+ if( getrlimit( RLIMIT_NOFILE, &rl ) == 0 )
|
||||
+ maxfd = rl.rlim_max;
|
||||
+ for( int i = 3;
|
||||
+ i < maxfd;
|
||||
+ ++i )
|
||||
+ close( i );
|
||||
+#ifdef DEBUG_KDE
|
||||
+ execvp( KMOZILLAHELPER, args );
|
||||
+#else
|
||||
+ execv( KMOZILLAHELPER, args );
|
||||
+#endif
|
||||
+ _exit( 1 ); // failed
|
||||
+ }
|
||||
+ default: // parent
|
||||
+ {
|
||||
+ commandFile = fdopen( fdcommand[ 1 ], "w" );
|
||||
+ replyFile = fdopen( fdreply[ 0 ], "r" );
|
||||
+ close( fdcommand[ 0 ] );
|
||||
+ close( fdreply[ 1 ] );
|
||||
+ if( commandFile == NULL || replyFile == NULL )
|
||||
+ {
|
||||
+ closeHelper();
|
||||
+ return false;
|
||||
+ }
|
||||
+ // ok, helper ready, getKdeRunning() will check if it works
|
||||
+ }
|
||||
+ }
|
||||
+ helperFailed = false;
|
||||
+ helperRunning = true;
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+void nsKDEUtils::closeHelper()
|
||||
+ {
|
||||
+ if( commandFile != NULL )
|
||||
+ fclose( commandFile ); // this will also make the helper quit
|
||||
+ if( replyFile != NULL )
|
||||
+ fclose( replyFile );
|
||||
+ helperRunning = false;
|
||||
+ }
|
||||
+
|
||||
+void nsKDEUtils::feedCommand( const nsTArray<nsCString>& command )
|
||||
+ {
|
||||
+ for( int i = 0;
|
||||
+ i < command.Length();
|
||||
+ ++i )
|
||||
+ {
|
||||
+ nsCString line = command[ i ];
|
||||
+ line.ReplaceSubstring( "\\", "\\" "\\" ); // \ -> \\ , i.e. escape
|
||||
+ line.ReplaceSubstring( "\n", "\\n" );
|
||||
+#ifdef DEBUG_KDE
|
||||
+ fprintf( stderr, "COMM: %s\n", line.get());
|
||||
+#endif
|
||||
+ fputs( line.get(), commandFile );
|
||||
+ fputs( "\n", commandFile );
|
||||
+ }
|
||||
+ fputs( "\\E\n", commandFile ); // done as \E, so it cannot happen in normal data
|
||||
+ fflush( commandFile );
|
||||
+ }
|
||||
diff --git a/toolkit/xre/nsKDEUtils.h b/toolkit/xre/nsKDEUtils.h
|
||||
new file mode 100644
|
||||
index 0000000000..c9c1284e29
|
||||
--- /dev/null
|
||||
+++ b/toolkit/xre/nsKDEUtils.h
|
||||
@@ -0,0 +1,48 @@
|
||||
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
+/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
+
|
||||
+#ifndef nsKDEUtils_h__
|
||||
+#define nsKDEUtils_h__
|
||||
+
|
||||
+#include "nsString.h"
|
||||
+#include "nsTArray.h"
|
||||
+#include <stdio.h>
|
||||
+
|
||||
+typedef struct _GtkWindow GtkWindow;
|
||||
+
|
||||
+class nsIArray;
|
||||
+
|
||||
+class NS_EXPORT nsKDEUtils
|
||||
+ {
|
||||
+ public:
|
||||
+ /* Returns true if running inside a KDE session (regardless of whether there is KDE
|
||||
+ support available for Firefox). This should be used e.g. when determining
|
||||
+ dialog button order but not for code that requires the KDE support. */
|
||||
+ static bool kdeSession();
|
||||
+ /* Returns true if running inside a KDE session and KDE support is available
|
||||
+ for Firefox. This should be used everywhere where the external helper is needed. */
|
||||
+ 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). */
|
||||
+ static bool commandBlockUi( const nsTArray<nsCString>& command, GtkWindow* parent, nsTArray<nsCString>* output = NULL );
|
||||
+
|
||||
+ private:
|
||||
+ nsKDEUtils();
|
||||
+ ~nsKDEUtils();
|
||||
+ static nsKDEUtils* self();
|
||||
+ bool startHelper();
|
||||
+ void closeHelper();
|
||||
+ void feedCommand( const nsTArray<nsCString>& command );
|
||||
+ bool internalCommand( const nsTArray<nsCString>& command, GtkWindow* parent, bool isParent,
|
||||
+ nsTArray<nsCString>* output );
|
||||
+ FILE* commandFile;
|
||||
+ FILE* replyFile;
|
||||
+ };
|
||||
+
|
||||
+#endif // nsKDEUtils
|
||||
diff --git a/uriloader/exthandler/HandlerServiceParent.cpp b/uriloader/exthandler/HandlerServiceParent.cpp
|
||||
index 0796c7428..4f21c058f 100644
|
||||
index 0796c7428b..4f21c058f8 100644
|
||||
--- a/uriloader/exthandler/HandlerServiceParent.cpp
|
||||
+++ b/uriloader/exthandler/HandlerServiceParent.cpp
|
||||
@@ -12,7 +12,7 @@
|
||||
|
|
@ -307,7 +700,7 @@ index 0796c7428..4f21c058f 100644
|
|||
*aHandlerExists = false;
|
||||
}
|
||||
diff --git a/uriloader/exthandler/moz.build b/uriloader/exthandler/moz.build
|
||||
index 8bac7bcfa..dab98e1aa 100644
|
||||
index 8bac7bcfa3..dab98e1aa4 100644
|
||||
--- a/uriloader/exthandler/moz.build
|
||||
+++ b/uriloader/exthandler/moz.build
|
||||
@@ -83,7 +83,9 @@ else:
|
||||
|
|
@ -328,8 +721,233 @@ index 8bac7bcfa..dab98e1aa 100644
|
|||
]
|
||||
|
||||
if CONFIG["MOZ_ENABLE_DBUS"]:
|
||||
diff --git a/uriloader/exthandler/unix/nsCommonRegistry.cpp b/uriloader/exthandler/unix/nsCommonRegistry.cpp
|
||||
new file mode 100644
|
||||
index 0000000000..630ab6147d
|
||||
--- /dev/null
|
||||
+++ b/uriloader/exthandler/unix/nsCommonRegistry.cpp
|
||||
@@ -0,0 +1,53 @@
|
||||
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
+/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
+
|
||||
+#include "nsCommonRegistry.h"
|
||||
+
|
||||
+#include "nsGNOMERegistry.h"
|
||||
+#include "nsKDERegistry.h"
|
||||
+#include "nsString.h"
|
||||
+#include "nsKDEUtils.h"
|
||||
+
|
||||
+/* static */ bool
|
||||
+nsCommonRegistry::HandlerExists(const char *aProtocolScheme)
|
||||
+{
|
||||
+ if( nsKDEUtils::kdeSupport())
|
||||
+ return nsKDERegistry::HandlerExists( aProtocolScheme );
|
||||
+ return nsGNOMERegistry::HandlerExists( aProtocolScheme );
|
||||
+}
|
||||
+
|
||||
+/* static */ nsresult
|
||||
+nsCommonRegistry::LoadURL(nsIURI *aURL)
|
||||
+{
|
||||
+ if( nsKDEUtils::kdeSupport())
|
||||
+ return nsKDERegistry::LoadURL( aURL );
|
||||
+ return nsGNOMERegistry::LoadURL( aURL );
|
||||
+}
|
||||
+
|
||||
+/* static */ void
|
||||
+nsCommonRegistry::GetAppDescForScheme(const nsACString& aScheme,
|
||||
+ nsAString& aDesc)
|
||||
+{
|
||||
+ if( nsKDEUtils::kdeSupport())
|
||||
+ return nsKDERegistry::GetAppDescForScheme( aScheme, aDesc );
|
||||
+ return nsGNOMERegistry::GetAppDescForScheme( aScheme, aDesc );
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/* static */ already_AddRefed<nsMIMEInfoBase>
|
||||
+nsCommonRegistry::GetFromExtension(const nsACString& aFileExt)
|
||||
+{
|
||||
+ if( nsKDEUtils::kdeSupport())
|
||||
+ return nsKDERegistry::GetFromExtension( aFileExt );
|
||||
+ return nsGNOMERegistry::GetFromExtension( aFileExt );
|
||||
+}
|
||||
+
|
||||
+/* static */ already_AddRefed<nsMIMEInfoBase>
|
||||
+nsCommonRegistry::GetFromType(const nsACString& aMIMEType)
|
||||
+{
|
||||
+ if( nsKDEUtils::kdeSupport())
|
||||
+ return nsKDERegistry::GetFromType( aMIMEType );
|
||||
+ return nsGNOMERegistry::GetFromType( aMIMEType );
|
||||
+}
|
||||
diff --git a/uriloader/exthandler/unix/nsCommonRegistry.h b/uriloader/exthandler/unix/nsCommonRegistry.h
|
||||
new file mode 100644
|
||||
index 0000000000..85b3d9cee2
|
||||
--- /dev/null
|
||||
+++ b/uriloader/exthandler/unix/nsCommonRegistry.h
|
||||
@@ -0,0 +1,28 @@
|
||||
+/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
+
|
||||
+#ifndef nsCommonRegistry_h__
|
||||
+#define nsCommonRegistry_h__
|
||||
+
|
||||
+#include "nsIURI.h"
|
||||
+#include "nsCOMPtr.h"
|
||||
+
|
||||
+class nsMIMEInfoBase;
|
||||
+
|
||||
+class nsCommonRegistry
|
||||
+{
|
||||
+ public:
|
||||
+ static bool HandlerExists(const char *aProtocolScheme);
|
||||
+
|
||||
+ static nsresult LoadURL(nsIURI *aURL);
|
||||
+
|
||||
+ static void GetAppDescForScheme(const nsACString& aScheme,
|
||||
+ nsAString& aDesc);
|
||||
+
|
||||
+ static already_AddRefed<nsMIMEInfoBase> GetFromExtension(const nsACString& aFileExt);
|
||||
+
|
||||
+ static already_AddRefed<nsMIMEInfoBase> GetFromType(const nsACString& aMIMEType);
|
||||
+};
|
||||
+
|
||||
+#endif
|
||||
diff --git a/uriloader/exthandler/unix/nsKDERegistry.cpp b/uriloader/exthandler/unix/nsKDERegistry.cpp
|
||||
new file mode 100644
|
||||
index 0000000000..95c13f38e1
|
||||
--- /dev/null
|
||||
+++ b/uriloader/exthandler/unix/nsKDERegistry.cpp
|
||||
@@ -0,0 +1,86 @@
|
||||
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
+/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
+
|
||||
+#include "nsKDERegistry.h"
|
||||
+#include "prlink.h"
|
||||
+#include "prmem.h"
|
||||
+#include "nsString.h"
|
||||
+#include "nsMIMEInfoUnix.h"
|
||||
+#include "nsKDEUtils.h"
|
||||
+
|
||||
+/* static */ bool
|
||||
+nsKDERegistry::HandlerExists(const char *aProtocolScheme)
|
||||
+{
|
||||
+ nsTArray<nsCString> command;
|
||||
+ command.AppendElement( "HANDLEREXISTS"_ns );
|
||||
+ command.AppendElement( nsAutoCString( aProtocolScheme ));
|
||||
+ return nsKDEUtils::command( command );
|
||||
+}
|
||||
+
|
||||
+/* static */ nsresult
|
||||
+nsKDERegistry::LoadURL(nsIURI *aURL)
|
||||
+{
|
||||
+ nsTArray<nsCString> command;
|
||||
+ command.AppendElement( "OPEN"_ns );
|
||||
+ nsCString url;
|
||||
+ aURL->GetSpec( url );
|
||||
+ command.AppendElement( url );
|
||||
+ bool rv = nsKDEUtils::command( command );
|
||||
+ if (!rv)
|
||||
+ return NS_ERROR_FAILURE;
|
||||
+
|
||||
+ return NS_OK;
|
||||
+}
|
||||
+
|
||||
+/* static */ void
|
||||
+nsKDERegistry::GetAppDescForScheme(const nsACString& aScheme,
|
||||
+ nsAString& aDesc)
|
||||
+{
|
||||
+ nsTArray<nsCString> command;
|
||||
+ command.AppendElement( "GETAPPDESCFORSCHEME"_ns );
|
||||
+ command.AppendElement( aScheme );
|
||||
+ nsTArray<nsCString> output;
|
||||
+ if( nsKDEUtils::command( command, &output ) && output.Length() == 1 )
|
||||
+ CopyUTF8toUTF16( output[ 0 ], aDesc );
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/* static */ already_AddRefed<nsMIMEInfoBase>
|
||||
+nsKDERegistry::GetFromExtension(const nsACString& aFileExt)
|
||||
+{
|
||||
+ NS_ASSERTION(aFileExt[0] != '.', "aFileExt shouldn't start with a dot");
|
||||
+ nsTArray<nsCString> command;
|
||||
+ command.AppendElement( "GETFROMEXTENSION"_ns );
|
||||
+ command.AppendElement( aFileExt );
|
||||
+ return GetFromHelper( command );
|
||||
+}
|
||||
+
|
||||
+/* static */ already_AddRefed<nsMIMEInfoBase>
|
||||
+nsKDERegistry::GetFromType(const nsACString& aMIMEType)
|
||||
+{
|
||||
+ nsTArray<nsCString> command;
|
||||
+ command.AppendElement( "GETFROMTYPE"_ns );
|
||||
+ command.AppendElement( aMIMEType );
|
||||
+ return GetFromHelper( command );
|
||||
+}
|
||||
+
|
||||
+/* static */ already_AddRefed<nsMIMEInfoBase>
|
||||
+nsKDERegistry::GetFromHelper(const nsTArray<nsCString>& command)
|
||||
+{
|
||||
+ nsTArray<nsCString> output;
|
||||
+ if( nsKDEUtils::command( command, &output ) && output.Length() == 3 )
|
||||
+ {
|
||||
+ nsCString mimetype = output[ 0 ];
|
||||
+ RefPtr<nsMIMEInfoUnix> mimeInfo = new nsMIMEInfoUnix( mimetype );
|
||||
+ NS_ENSURE_TRUE(mimeInfo, nullptr);
|
||||
+ nsCString description = output[ 1 ];
|
||||
+ mimeInfo->SetDescription(NS_ConvertUTF8toUTF16(description));
|
||||
+ nsCString handlerAppName = output[ 2 ];
|
||||
+ mimeInfo->SetDefaultDescription(NS_ConvertUTF8toUTF16(handlerAppName));
|
||||
+ mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
|
||||
+ return mimeInfo.forget();
|
||||
+ }
|
||||
+ return nullptr;
|
||||
+}
|
||||
diff --git a/uriloader/exthandler/unix/nsKDERegistry.h b/uriloader/exthandler/unix/nsKDERegistry.h
|
||||
new file mode 100644
|
||||
index 0000000000..5b07eebc6d
|
||||
--- /dev/null
|
||||
+++ b/uriloader/exthandler/unix/nsKDERegistry.h
|
||||
@@ -0,0 +1,34 @@
|
||||
+/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
+
|
||||
+#ifndef nsKDERegistry_h__
|
||||
+#define nsKDERegistry_h__
|
||||
+
|
||||
+#include "nsIURI.h"
|
||||
+#include "nsCOMPtr.h"
|
||||
+#include "nsTArray.h"
|
||||
+
|
||||
+class nsMIMEInfoBase;
|
||||
+//class nsAutoCString;
|
||||
+//class nsCString;
|
||||
+
|
||||
+class nsKDERegistry
|
||||
+{
|
||||
+ public:
|
||||
+ static bool HandlerExists(const char *aProtocolScheme);
|
||||
+
|
||||
+ static nsresult LoadURL(nsIURI *aURL);
|
||||
+
|
||||
+ static void GetAppDescForScheme(const nsACString& aScheme,
|
||||
+ nsAString& aDesc);
|
||||
+
|
||||
+ static already_AddRefed<nsMIMEInfoBase> GetFromExtension(const nsACString& aFileExt);
|
||||
+
|
||||
+ static already_AddRefed<nsMIMEInfoBase> GetFromType(const nsACString& aMIMEType);
|
||||
+ private:
|
||||
+ static already_AddRefed<nsMIMEInfoBase> GetFromHelper(const nsTArray<nsCString>& command);
|
||||
+
|
||||
+};
|
||||
+
|
||||
+#endif //nsKDERegistry_h__
|
||||
diff --git a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
|
||||
index 7cbefcce3..84083348c 100644
|
||||
index 7cbefcce3e..84083348c8 100644
|
||||
--- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
|
||||
+++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
|
||||
@@ -5,16 +5,19 @@
|
||||
|
|
@ -398,7 +1016,7 @@ index 7cbefcce3..84083348c 100644
|
|||
if (!giovfs) {
|
||||
return NS_ERROR_FAILURE;
|
||||
diff --git a/uriloader/exthandler/unix/nsOSHelperAppService.cpp b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
|
||||
index b9e7aed3c..367ad9ee2 100644
|
||||
index b9e7aed3cb..367ad9ee24 100644
|
||||
--- a/uriloader/exthandler/unix/nsOSHelperAppService.cpp
|
||||
+++ b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
|
||||
@@ -10,7 +10,7 @@
|
||||
|
|
@ -447,7 +1065,7 @@ index b9e7aed3c..367ad9ee2 100644
|
|||
LOG(
|
||||
("Got MIMEInfo from GNOME registry without extensions; setting them "
|
||||
diff --git a/widget/gtk/moz.build b/widget/gtk/moz.build
|
||||
index 78c852e98..2bc734e95 100644
|
||||
index 78c852e989..2bc734e95a 100644
|
||||
--- a/widget/gtk/moz.build
|
||||
+++ b/widget/gtk/moz.build
|
||||
@@ -152,6 +152,7 @@ LOCAL_INCLUDES += [
|
||||
|
|
@ -459,7 +1077,7 @@ index 78c852e98..2bc734e95 100644
|
|||
"/widget/headless",
|
||||
]
|
||||
diff --git a/widget/gtk/nsFilePicker.cpp b/widget/gtk/nsFilePicker.cpp
|
||||
index fd032d0be..ca37f4fc3 100644
|
||||
index fd032d0bec..ca37f4fc3b 100644
|
||||
--- a/widget/gtk/nsFilePicker.cpp
|
||||
+++ b/widget/gtk/nsFilePicker.cpp
|
||||
@@ -5,6 +5,7 @@
|
||||
|
|
@ -756,7 +1374,7 @@ index fd032d0be..ca37f4fc3 100644
|
|||
void* nsFilePicker::GtkFileChooserNew(const gchar* title, GtkWindow* parent,
|
||||
GtkFileChooserAction action,
|
||||
diff --git a/widget/gtk/nsFilePicker.h b/widget/gtk/nsFilePicker.h
|
||||
index 9b3110aa0..be9d559c7 100644
|
||||
index 9b3110aa00..be9d559c7b 100644
|
||||
--- a/widget/gtk/nsFilePicker.h
|
||||
+++ b/widget/gtk/nsFilePicker.h
|
||||
@@ -72,6 +72,12 @@ class nsFilePicker : public nsBaseFilePicker {
|
||||
|
|
@ -773,7 +1391,7 @@ index 9b3110aa0..be9d559c7 100644
|
|||
GtkFileChooserAction action,
|
||||
const gchar* accept_label);
|
||||
diff --git a/xpcom/components/ManifestParser.cpp b/xpcom/components/ManifestParser.cpp
|
||||
index f3d0055f2..d13543ab5 100644
|
||||
index f3d0055f2c..d13543ab52 100644
|
||||
--- a/xpcom/components/ManifestParser.cpp
|
||||
+++ b/xpcom/components/ManifestParser.cpp
|
||||
@@ -43,6 +43,7 @@
|
||||
|
|
@ -852,7 +1470,7 @@ index f3d0055f2..d13543ab5 100644
|
|||
stTablet == eBad ||
|
||||
#endif
|
||||
diff --git a/xpcom/components/moz.build b/xpcom/components/moz.build
|
||||
index 655e2a607..128a4093a 100644
|
||||
index 655e2a607a..128a4093a3 100644
|
||||
--- a/xpcom/components/moz.build
|
||||
+++ b/xpcom/components/moz.build
|
||||
@@ -71,6 +71,7 @@ LOCAL_INCLUDES += [
|
||||
|
|
@ -864,7 +1482,7 @@ index 655e2a607..128a4093a 100644
|
|||
|
||||
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
|
||||
diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp
|
||||
index 37b11fd2c..92a65ac1c 100644
|
||||
index 37b11fd2ce..92a65ac1c9 100644
|
||||
--- a/xpcom/io/nsLocalFileUnix.cpp
|
||||
+++ b/xpcom/io/nsLocalFileUnix.cpp
|
||||
@@ -58,6 +58,7 @@
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue