Lines 46-57
Link Here
|
46 |
#include "nsMIMEInfoUnix.h" |
46 |
#include "nsMIMEInfoUnix.h" |
47 |
#include "nsGNOMERegistry.h" |
47 |
#include "nsGNOMERegistry.h" |
48 |
#include "nsIGnomeVFSService.h" |
48 |
#include "nsIGnomeVFSService.h" |
49 |
#ifdef MOZ_ENABLE_DBUS |
49 |
#ifdef MOZ_ENABLE_DBUS |
50 |
#include "nsDBusHandlerApp.h" |
50 |
#include "nsDBusHandlerApp.h" |
51 |
#endif |
51 |
#endif |
|
|
52 |
#include "nsAutoPtr.h" |
52 |
|
53 |
|
53 |
|
54 |
|
54 |
nsresult |
55 |
nsresult |
55 |
nsMIMEInfoUnix::LoadUriInternal(nsIURI * aURI) |
56 |
nsMIMEInfoUnix::LoadUriInternal(nsIURI * aURI) |
56 |
{ |
57 |
{ |
57 |
nsresult rv = nsGNOMERegistry::LoadURL(aURI); |
58 |
nsresult rv = nsGNOMERegistry::LoadURL(aURI); |
Lines 71-89
nsMIMEInfoUnix::LoadUriInternal(nsIURI *
Link Here
|
71 |
} |
72 |
} |
72 |
|
73 |
|
73 |
NS_IMETHODIMP |
74 |
NS_IMETHODIMP |
74 |
nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval) |
75 |
nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval) |
75 |
{ |
76 |
{ |
76 |
*_retval = PR_FALSE; |
77 |
*_retval = PR_FALSE; |
77 |
nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID); |
78 |
nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromType(mType); |
78 |
if (vfs) { |
79 |
if (!mimeInfo) { |
79 |
nsCOMPtr<nsIGnomeVFSMimeApp> app; |
80 |
nsCAutoString ext; |
80 |
if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app) |
81 |
GetPrimaryExtension(ext); |
81 |
*_retval = PR_TRUE; |
82 |
mimeInfo = nsGNOMERegistry::GetFromExtension(ext); |
82 |
} |
83 |
} |
83 |
|
84 |
|
|
|
85 |
if (mimeInfo) |
86 |
*_retval = PR_TRUE; |
87 |
|
84 |
if (*_retval) |
88 |
if (*_retval) |
85 |
return NS_OK; |
89 |
return NS_OK; |
86 |
|
90 |
|
87 |
#ifdef MOZ_PLATFORM_HILDON |
91 |
#ifdef MOZ_PLATFORM_HILDON |
88 |
HildonURIAction *action = hildon_uri_get_default_action(mType.get(), nsnull); |
92 |
HildonURIAction *action = hildon_uri_get_default_action(mType.get(), nsnull); |
89 |
if (action) { |
93 |
if (action) { |
Lines 106-117
nsMIMEInfoUnix::LaunchDefaultWithFile(ns
Link Here
|
106 |
nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID); |
110 |
nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID); |
107 |
|
111 |
|
108 |
if (vfs) { |
112 |
if (vfs) { |
109 |
nsCOMPtr<nsIGnomeVFSMimeApp> app; |
113 |
nsCOMPtr<nsIGnomeVFSMimeApp> app; |
110 |
if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app) |
114 |
if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app) |
111 |
return app->Launch(nativePath); |
115 |
return app->Launch(nativePath); |
|
|
116 |
|
117 |
// If we haven't got an app we try to get a valid one by searching for the |
118 |
// extension mapped type |
119 |
nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromExtension(nativePath); |
120 |
if (mimeInfo) { |
121 |
nsCAutoString type; |
122 |
mimeInfo->GetType(type); |
123 |
if (NS_SUCCEEDED(vfs->GetAppForMimeType(type, getter_AddRefs(app))) && app) |
124 |
return app->Launch(nativePath); |
125 |
} |
112 |
} |
126 |
} |
113 |
|
127 |
|
114 |
if (!mDefaultApplication) |
128 |
if (!mDefaultApplication) |
115 |
return NS_ERROR_FILE_NOT_FOUND; |
129 |
return NS_ERROR_FILE_NOT_FOUND; |
116 |
|
130 |
|
117 |
return LaunchWithIProcess(mDefaultApplication, nativePath); |
131 |
return LaunchWithIProcess(mDefaultApplication, nativePath); |