Bug 421879 - "opening a file with the default helper app can fail by using the wrong app in the end" [p=mh+mozilla@glandium.org (Mike Hommey) r=biesi a=blocking1.9+]
authorreed@reedloden.com
Wed, 12 Mar 2008 15:53:18 -0700
changeset 12980 f985db69e9a75f5f19ecf9abb6c314f8017975dd
parent 12979 fefda0f421acbc3914615fcb541edad4d58a7aa6
child 12981 24bba1f8fa577debf4f895a4cb7692b9e5b0d437
push idunknown
push userunknown
push dateunknown
reviewersbiesi, blocking1.9
bugs421879
milestone1.9b5pre
Bug 421879 - "opening a file with the default helper app can fail by using the wrong app in the end" [p=mh+mozilla@glandium.org (Mike Hommey) r=biesi a=blocking1.9+]
toolkit/system/gnome/nsGnomeVFSService.cpp
uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
xpcom/system/nsIGnomeVFSService.idl
--- a/toolkit/system/gnome/nsGnomeVFSService.cpp
+++ b/toolkit/system/gnome/nsGnomeVFSService.cpp
@@ -98,16 +98,42 @@ nsGnomeVFSMimeApp::GetCanOpenMultipleFil
 
 NS_IMETHODIMP
 nsGnomeVFSMimeApp::GetExpectsURIs(PRInt32* aExpects)
 {
   *aExpects = mApp->expects_uris;
   return NS_OK;
 }
 
+NS_IMETHODIMP
+nsGnomeVFSMimeApp::Launch(const nsACString &aUri)
+{
+  char *uri = gnome_vfs_make_uri_from_input(PromiseFlatCString(aUri).get());
+
+  if (! uri)
+    return NS_ERROR_FAILURE;
+
+  GList *uris = g_list_append(NULL, uri);
+
+  if (! uris) {
+    g_free(uri);
+    return NS_ERROR_FAILURE;
+  }
+
+  GnomeVFSResult result = gnome_vfs_mime_application_launch(mApp, uris);
+
+  g_free(uri);
+  g_list_free(uris);
+
+  if (result != GNOME_VFS_OK)
+    return NS_ERROR_FAILURE;
+
+  return NS_OK;
+}
+
 class UTF8StringEnumerator : public nsIUTF8StringEnumerator
 {
 public:
   UTF8StringEnumerator() : mIndex(0) { }
   ~UTF8StringEnumerator() { }
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIUTF8STRINGENUMERATOR
--- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
+++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
@@ -66,16 +66,16 @@ nsMIMEInfoUnix::LaunchDefaultWithFile(ns
   nsCAutoString nativePath;
   aFile->GetNativePath(nativePath);
 
   nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
 
   if (vfs) {
     nsCOMPtr<nsIGnomeVFSMimeApp> app;
     if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app)
-      return vfs->ShowURIForInput(nativePath);
+      return app->Launch(nativePath);
   }
 
   if (!mDefaultApplication)
     return NS_ERROR_FILE_NOT_FOUND;
 
   return LaunchWithIProcess(mDefaultApplication, nativePath);
 }
--- a/xpcom/system/nsIGnomeVFSService.idl
+++ b/xpcom/system/nsIGnomeVFSService.idl
@@ -39,45 +39,47 @@
 #include "nsISupports.idl"
 
 interface nsIUTF8StringEnumerator;
 interface nsIURI;
 
 /* nsIGnomeVFSMimeApp holds information about an application that is looked up
    with nsIGnomeVFSService::GetAppForMimeType. */
 
-[scriptable, uuid(57b1ef41-35cd-48e9-a248-2030c8365067)]
+[scriptable, uuid(66009894-9877-405b-9321-bf30420e34e6)]
 interface nsIGnomeVFSMimeApp : nsISupports
 {
   const long EXPECTS_URIS  = 0;
   const long EXPECTS_PATHS = 1;
   const long EXPECTS_URIS_FOR_NON_FILES = 2;
 
   readonly attribute AUTF8String         id;
   readonly attribute AUTF8String         name;
   readonly attribute AUTF8String         command;
   readonly attribute boolean             canOpenMultipleFiles;
   readonly attribute long                expectsURIs;  // see constants above
   readonly attribute nsIUTF8StringEnumerator supportedURISchemes;
   readonly attribute boolean             requiresTerminal;
+
+  void launch(in AUTF8String uri);
 };
 
 /*
  * The VFS service makes use of two distinct registries.
  *
  * The application registry holds information about applications (uniquely
  * identified by id), such as which MIME types and URI schemes they are
  * capable of handling, whether they run in a terminal, etc.
  *
  * The MIME registry holds information about MIME types, such as which
  * extensions map to a given MIME type.  The MIME registry also stores the
  * id of the application selected to handle each MIME type.
  */
 
-[scriptable, uuid(4d6b9f23-8682-41b3-bbff-937a958e6496)]
+[scriptable, uuid(dea20bf0-4e4d-48c5-b932-dc3e116dc64b)]
 interface nsIGnomeVFSService : nsISupports
 {
   /*** Application registry methods ***/
 
   /* string keys */
   const long APP_KEY_COMMAND = 0;
   const long APP_KEY_NAME = 1;
   const long APP_KEY_SUPPORTED_URI_SCHEMES = 2;  /* comma-separated list */