mozilla-gio-launch-uri.patch
author Wolfgang Rosenauer <wr@rosenauer.org>
Wed, 23 Feb 2011 15:14:39 +0100
changeset 229 298263f797be
parent 228 9ba8fb8909c4
child 231 bb385ce8c773
permissions -rw-r--r--
update to 2.0b12/4.0b12

# HG changeset patch
# Parent 7d47a19639db505e19282ac69c305c636d0fec18

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
@@ -53,16 +53,18 @@
 #include "nsContentHandlerApp.h"
 #endif
 #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
 
@@ -172,38 +174,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)