mozilla-gio-launch-uri.patch
changeset 228 9ba8fb8909c4
child 229 298263f797be
equal deleted inserted replaced
226:6bf3bb4c115e 228:9ba8fb8909c4
       
     1 # HG changeset patch
       
     2 # Parent f81b405b9adebc56c3af5cfbf2f74cf01c22956b
       
     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 @@ -51,16 +51,18 @@
       
     8  #include <contentaction/contentaction.h>
       
     9  #include "nsContentHandlerApp.h"
       
    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 @@ -170,38 +172,47 @@ 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 +    nsCOMPtr<nsIIOService> ioservice = do_GetService(NS_IOSERVICE_CONTRACTID);
       
    39 +    nsCOMPtr<nsIURI> uri;
       
    40 +    ioservice->NewFileURI(aFile, getter_AddRefs(uri));
       
    41 +    uri->GetSpec(uriSpec);
       
    42 +  }
       
    43 +
       
    44    nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
       
    45    if (giovfs) {
       
    46      nsCOMPtr<nsIGIOMimeApp> app;
       
    47      if (NS_SUCCEEDED(giovfs->GetAppForMimeType(mSchemeOrType, getter_AddRefs(app))) && app)
       
    48 -      return app->Launch(nativePath);
       
    49 +      return app->Launch(uriSpec);
       
    50    } else if (gnomevfs) {
       
    51      /* Fallback to GnomeVFS */
       
    52      nsCOMPtr<nsIGnomeVFSMimeApp> app;
       
    53      if (NS_SUCCEEDED(gnomevfs->GetAppForMimeType(mSchemeOrType, getter_AddRefs(app))) && app)
       
    54        return app->Launch(nativePath);
       
    55    }
       
    56  
       
    57    // If we haven't got an app we try to get a valid one by searching for the
       
    58    // extension mapped type
       
    59    nsRefPtr<nsMIMEInfoBase> mimeInfo = nsCommonRegistry::GetFromExtension(nativePath);
       
    60    if (mimeInfo) {
       
    61      nsCAutoString type;
       
    62      mimeInfo->GetType(type);
       
    63      if (giovfs) {
       
    64        nsCOMPtr<nsIGIOMimeApp> app;
       
    65        if (NS_SUCCEEDED(giovfs->GetAppForMimeType(type, getter_AddRefs(app))) && app)
       
    66 -        return app->Launch(nativePath);
       
    67 +        return app->Launch(uriSpec);
       
    68      } else if (gnomevfs) {
       
    69        nsCOMPtr<nsIGnomeVFSMimeApp> app;
       
    70        if (NS_SUCCEEDED(gnomevfs->GetAppForMimeType(type, getter_AddRefs(app))) && app)
       
    71          return app->Launch(nativePath);
       
    72      }
       
    73    }
       
    74  
       
    75    if (!mDefaultApplication)