mozilla-gio-launch-uri.patch
changeset 228 9ba8fb8909c4
child 229 298263f797be
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mozilla-gio-launch-uri.patch	Thu Feb 17 20:14:47 2011 +0100
@@ -0,0 +1,75 @@
+# HG changeset patch
+# Parent f81b405b9adebc56c3af5cfbf2f74cf01c22956b
+
+diff --git a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
+--- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
++++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
+@@ -51,16 +51,18 @@
+ #include <contentaction/contentaction.h>
+ #include "nsContentHandlerApp.h"
+ #endif
+ 
+ #include "nsMIMEInfoUnix.h"
+ #include "nsCommonRegistry.h"
+ #include "nsIGIOService.h"
+ #include "nsIGnomeVFSService.h"
++#include "nsNetCID.h"
++#include "nsIIOService.h"
+ #include "nsAutoPtr.h"
+ #ifdef MOZ_ENABLE_DBUS
+ #include "nsDBusHandlerApp.h"
+ #endif
+ #if defined(XP_UNIX) && !defined(XP_MACOSX)
+ #include "nsKDEUtils.h"
+ #endif
+ 
+@@ -170,38 +172,47 @@ nsMIMEInfoUnix::LaunchDefaultWithFile(ns
+     }
+     if (!mDefaultApplication)
+       return NS_ERROR_FILE_NOT_FOUND;
+ 
+     return LaunchWithIProcess(mDefaultApplication, nativePath);
+   }
+ 
+   nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
++  nsCAutoString uriSpec;
++  if (giovfs) {
++    // nsGIOMimeApp->Launch wants a URI string instead of local file
++    nsCOMPtr<nsIIOService> ioservice = do_GetService(NS_IOSERVICE_CONTRACTID);
++    nsCOMPtr<nsIURI> uri;
++    ioservice->NewFileURI(aFile, getter_AddRefs(uri));
++    uri->GetSpec(uriSpec);
++  }
++
+   nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
+   if (giovfs) {
+     nsCOMPtr<nsIGIOMimeApp> app;
+     if (NS_SUCCEEDED(giovfs->GetAppForMimeType(mSchemeOrType, getter_AddRefs(app))) && app)
+-      return app->Launch(nativePath);
++      return app->Launch(uriSpec);
+   } else if (gnomevfs) {
+     /* Fallback to GnomeVFS */
+     nsCOMPtr<nsIGnomeVFSMimeApp> app;
+     if (NS_SUCCEEDED(gnomevfs->GetAppForMimeType(mSchemeOrType, getter_AddRefs(app))) && app)
+       return app->Launch(nativePath);
+   }
+ 
+   // If we haven't got an app we try to get a valid one by searching for the
+   // extension mapped type
+   nsRefPtr<nsMIMEInfoBase> mimeInfo = nsCommonRegistry::GetFromExtension(nativePath);
+   if (mimeInfo) {
+     nsCAutoString type;
+     mimeInfo->GetType(type);
+     if (giovfs) {
+       nsCOMPtr<nsIGIOMimeApp> app;
+       if (NS_SUCCEEDED(giovfs->GetAppForMimeType(type, getter_AddRefs(app))) && app)
+-        return app->Launch(nativePath);
++        return app->Launch(uriSpec);
+     } else if (gnomevfs) {
+       nsCOMPtr<nsIGnomeVFSMimeApp> app;
+       if (NS_SUCCEEDED(gnomevfs->GetAppForMimeType(type, getter_AddRefs(app))) && app)
+         return app->Launch(nativePath);
+     }
+   }
+ 
+   if (!mDefaultApplication)