mozilla-gio-launch-uri.patch
changeset 236 a4f5954df3a3
parent 232 156406e2b62d
child 237 676030198746
equal deleted inserted replaced
232:156406e2b62d 236:a4f5954df3a3
     1 # HG changeset patch
       
     2 # Parent 689e53e965fdd8c76354a69fa936a3fd4f07a220
       
     3 
       
     4 diff --git a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
       
     5 --- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
       
     6 +++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
       
     7 @@ -53,16 +53,18 @@
       
     8  #include "nsContentHandlerApp.h"
       
     9  #endif
       
    10  #endif
       
    11  
       
    12  #include "nsMIMEInfoUnix.h"
       
    13  #include "nsCommonRegistry.h"
       
    14  #include "nsIGIOService.h"
       
    15  #include "nsIGnomeVFSService.h"
       
    16 +#include "nsNetCID.h"
       
    17 +#include "nsIIOService.h"
       
    18  #include "nsAutoPtr.h"
       
    19  #ifdef MOZ_ENABLE_DBUS
       
    20  #include "nsDBusHandlerApp.h"
       
    21  #endif
       
    22  #if defined(XP_UNIX) && !defined(XP_MACOSX)
       
    23  #include "nsKDEUtils.h"
       
    24  #endif
       
    25  
       
    26 @@ -172,38 +174,50 @@ nsMIMEInfoUnix::LaunchDefaultWithFile(ns
       
    27      }
       
    28      if (!mDefaultApplication)
       
    29        return NS_ERROR_FILE_NOT_FOUND;
       
    30  
       
    31      return LaunchWithIProcess(mDefaultApplication, nativePath);
       
    32    }
       
    33  
       
    34    nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
       
    35 +  nsCAutoString uriSpec;
       
    36 +  if (giovfs) {
       
    37 +    // nsGIOMimeApp->Launch wants a URI string instead of local file
       
    38 +    nsresult rv;
       
    39 +    nsCOMPtr<nsIIOService> ioservice = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
       
    40 +    NS_ENSURE_SUCCESS(rv, rv);
       
    41 +    nsCOMPtr<nsIURI> uri;
       
    42 +    rv = ioservice->NewFileURI(aFile, getter_AddRefs(uri));
       
    43 +    NS_ENSURE_SUCCESS(rv, rv);
       
    44 +    uri->GetSpec(uriSpec);
       
    45 +  }
       
    46 +
       
    47    nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
       
    48    if (giovfs) {
       
    49      nsCOMPtr<nsIGIOMimeApp> app;
       
    50      if (NS_SUCCEEDED(giovfs->GetAppForMimeType(mSchemeOrType, getter_AddRefs(app))) && app)
       
    51 -      return app->Launch(nativePath);
       
    52 +      return app->Launch(uriSpec);
       
    53    } else if (gnomevfs) {
       
    54      /* Fallback to GnomeVFS */
       
    55      nsCOMPtr<nsIGnomeVFSMimeApp> app;
       
    56      if (NS_SUCCEEDED(gnomevfs->GetAppForMimeType(mSchemeOrType, getter_AddRefs(app))) && app)
       
    57        return app->Launch(nativePath);
       
    58    }
       
    59  
       
    60    // If we haven't got an app we try to get a valid one by searching for the
       
    61    // extension mapped type
       
    62    nsRefPtr<nsMIMEInfoBase> mimeInfo = nsCommonRegistry::GetFromExtension(nativePath);
       
    63    if (mimeInfo) {
       
    64      nsCAutoString type;
       
    65      mimeInfo->GetType(type);
       
    66      if (giovfs) {
       
    67        nsCOMPtr<nsIGIOMimeApp> app;
       
    68        if (NS_SUCCEEDED(giovfs->GetAppForMimeType(type, getter_AddRefs(app))) && app)
       
    69 -        return app->Launch(nativePath);
       
    70 +        return app->Launch(uriSpec);
       
    71      } else if (gnomevfs) {
       
    72        nsCOMPtr<nsIGnomeVFSMimeApp> app;
       
    73        if (NS_SUCCEEDED(gnomevfs->GetAppForMimeType(type, getter_AddRefs(app))) && app)
       
    74          return app->Launch(nativePath);
       
    75      }
       
    76    }
       
    77  
       
    78    if (!mDefaultApplication)