@@ -0,0 +1,393 @@
+Index: uriloader/exthandler/Makefile.in
+================================================================================
+--- uriloader/exthandler/Makefile.in
++++ uriloader/exthandler/Makefile.in
+@@ -103,7 +103,7 @@
+ LOCAL_INCLUDES = -I$(srcdir)
+
+ ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
+-OSHELPER += nsGNOMERegistry.cpp
++OSHELPER += nsMIMEInfoUnix.cpp nsGNOMERegistry.cpp
+ endif
+
+ ifeq ($(MOZ_WIDGET_TOOLKIT),beos)
+--- uriloader/exthandler/unix/nsGNOMERegistry.cpp
++++ uriloader/exthandler/unix/nsGNOMERegistry.cpp
+@@ -42,7 +42,7 @@
+ #include "nsString.h"
+ #include "nsIComponentManager.h"
+ #include "nsILocalFile.h"
+-#include "nsMIMEInfoImpl.h"
++#include "nsMIMEInfoUnix.h"
+ #include "nsAutoPtr.h"
+
+ #include <glib.h>
+@@ -56,12 +56,12 @@
+ typedef struct _GnomeProgram GnomeProgram;
+ typedef struct _GnomeModuleInfo GnomeModuleInfo;
+
+-typedef struct {
++struct GnomeVFSMimeApplication {
+ char *id;
+ char *name;
+ char *command;
+ /* there is more here, but we don't need it */
+-} GnomeVFSMimeApplication;
++};
+
+ typedef GConfClient * (*_gconf_client_get_default_fn)();
+ typedef gchar * (*_gconf_client_get_string_fn)(GConfClient *,
+@@ -264,7 +264,7 @@
+ }
+
+
+-/* static */ already_AddRefed<nsMIMEInfoBase>
++/* static */ already_AddRefed<nsMIMEInfoUnix>
+ nsGNOMERegistry::GetFromExtension(const char *aFileExt)
+ {
+ if (!gconfLib)
+@@ -286,7 +286,7 @@
+ return GetFromType(mimeType);
+ }
+
+-/* static */ already_AddRefed<nsMIMEInfoBase>
++/* static */ already_AddRefed<nsMIMEInfoUnix>
+ nsGNOMERegistry::GetFromType(const char *aMIMEType)
+ {
+ if (!gconfLib)
+@@ -296,9 +296,11 @@
+ if (!handlerApp)
+ return nsnull;
+
+- nsRefPtr<nsMIMEInfoImpl> mimeInfo = new nsMIMEInfoImpl(aMIMEType);
++ nsRefPtr<nsMIMEInfoUnix> mimeInfo = new nsMIMEInfoUnix(aMIMEType);
+ NS_ENSURE_TRUE(mimeInfo, nsnull);
+
++ mimeInfo->SetDefaultGnomeVFSMimeApplication(handlerApp);
++
+ // Get the list of extensions and append then to the mimeInfo.
+ GList *extensions = _gnome_vfs_mime_get_extensions_list(aMIMEType);
+ for (GList *extension = extensions; extension; extension = extension->next)
+@@ -320,11 +322,21 @@
+ return nsnull;
+ }
+
+- gchar *commandPath = g_find_program_in_path(nativeCommand);
++ gchar **argv;
++ gboolean res = g_shell_parse_argv(nativeCommand, NULL, &argv, NULL);
++ if (!res) {
++ NS_ERROR("Could not convert helper app command to filesystem encoding");
++ _gnome_vfs_mime_application_free(handlerApp);
++ return nsnull;
++ }
++
++ gchar *commandPath = g_find_program_in_path(argv[0]);
+
+ g_free(nativeCommand);
++ g_strfreev(argv);
+
+ if (!commandPath) {
++ NS_WARNING("could not find command in path");
+ _gnome_vfs_mime_application_free(handlerApp);
+ return nsnull;
+ }
+@@ -342,7 +354,7 @@
+
+ _gnome_vfs_mime_application_free(handlerApp);
+
+- nsMIMEInfoBase* retval;
++ nsMIMEInfoUnix* retval;
+ NS_ADDREF((retval = mimeInfo));
+ return retval;
+ }
+--- uriloader/exthandler/unix/nsGNOMERegistry.h
++++ uriloader/exthandler/unix/nsGNOMERegistry.h
+@@ -35,10 +35,13 @@
+ *
+ * ***** END LICENSE BLOCK ***** */
+
++#ifndef nsGNOMERegistry_h__
++#define nsGNOMERegistry_h__
++
+ #include "nsIURI.h"
+ #include "nsCOMPtr.h"
+
+-class nsMIMEInfoBase;
++class nsMIMEInfoUnix;
+
+ class nsGNOMERegistry
+ {
+@@ -52,7 +55,9 @@
+ static void GetAppDescForScheme(const nsACString& aScheme,
+ nsAString& aDesc);
+
+- static already_AddRefed<nsMIMEInfoBase> GetFromExtension(const char *aFileExt);
++ static already_AddRefed<nsMIMEInfoUnix> GetFromExtension(const char *aFileExt);
+
+- static already_AddRefed<nsMIMEInfoBase> GetFromType(const char *aMIMEType);
++ static already_AddRefed<nsMIMEInfoUnix> GetFromType(const char *aMIMEType);
+ };
++
++#endif // nsGNOMERegistry_h__
+--- uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
++++ uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
+@@ -0,0 +1,196 @@
++/* ***** BEGIN LICENSE BLOCK *****
++ * Version: MPL 1.1
++ *
++ * The contents of this file are subject to the Mozilla Public License Version
++ * 1.1 (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ * http://www.mozilla.org/MPL/
++ *
++ * Software distributed under the License is distributed on an "AS IS" basis,
++ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
++ * for the specific language governing rights and limitations under the
++ * License.
++ *
++ * The Original Code is mozilla.org Code.
++ *
++ * The Initial Developer of the Original Code is
++ * Red Hat, Inc.
++ * Portions created by the Initial Developer are Copyright (C) 2005
++ * the Initial Developer. All Rights Reserved.
++ *
++ * Contributor(s):
++ * Christopher Aillon <caillon@redhat.com> (Original author)
++ *
++ *
++ * ***** END LICENSE BLOCK ***** */
++
++#include "nsMIMEInfoUnix.h"
++#include "prlink.h"
++#include "prmem.h"
++#include <glib.h>
++#include <glib-object.h>
++
++static PRLibrary *gnomeLib;
++static PRLibrary *vfsLib;
++
++typedef struct _GnomeProgram GnomeProgram;
++typedef struct _GnomeModuleInfo GnomeModuleInfo;
++
++typedef enum {
++ GNOME_VFS_OK // there's more but we don't care about them.
++} GnomeVFSResult;
++
++typedef GnomeVFSResult (*_gnome_vfs_mime_application_launch_fn)
++ (GnomeVFSMimeApplication *app,
++ GList *uris);
++typedef void (*_gnome_vfs_mime_application_free_fn)(GnomeVFSMimeApplication *);
++typedef GnomeVFSMimeApplication * (*_gnome_vfs_mime_application_copy_fn)(GnomeVFSMimeApplication *);
++typedef GnomeProgram * (*_gnome_program_init_fn)(const char *, const char *,
++ const GnomeModuleInfo *, int,
++ char **, const char *, ...);
++typedef const char * (*_gnome_vfs_mime_application_get_name_fn)(GnomeVFSMimeApplication *);
++typedef const GnomeModuleInfo * (*_libgnome_module_info_get_fn)();
++typedef GnomeProgram * (*_gnome_program_get_fn)();
++typedef char * (*_gnome_vfs_make_uri_from_input_fn)(const char *);
++
++#define DECL_FUNC_PTR(func) static _##func##_fn _##func
++
++DECL_FUNC_PTR(gnome_vfs_mime_application_launch);
++DECL_FUNC_PTR(gnome_vfs_mime_application_free);
++DECL_FUNC_PTR(gnome_vfs_mime_application_copy);
++DECL_FUNC_PTR(gnome_vfs_mime_application_get_name);
++DECL_FUNC_PTR(gnome_program_init);
++DECL_FUNC_PTR(gnome_program_get);
++DECL_FUNC_PTR(libgnome_module_info_get);
++DECL_FUNC_PTR(gnome_vfs_make_uri_from_input);
|