Lines 41-56
Link Here
|
41 |
#include <glib.h> |
41 |
#include <glib.h> |
42 |
#include <hildon-uri.h> |
42 |
#include <hildon-uri.h> |
43 |
#endif |
43 |
#endif |
44 |
|
44 |
|
45 |
|
45 |
|
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 |
#include "nsAutoPtr.h" |
49 |
#ifdef MOZ_ENABLE_DBUS |
50 |
#ifdef MOZ_ENABLE_DBUS |
50 |
#include "nsDBusHandlerApp.h" |
51 |
#include "nsDBusHandlerApp.h" |
51 |
#endif |
52 |
#endif |
52 |
|
53 |
|
53 |
|
54 |
|
54 |
nsresult |
55 |
nsresult |
55 |
nsMIMEInfoUnix::LoadUriInternal(nsIURI * aURI) |
56 |
nsMIMEInfoUnix::LoadUriInternal(nsIURI * aURI) |
56 |
{ |
57 |
{ |
Lines 69-91
nsMIMEInfoUnix::LoadUriInternal(nsIURI *
Link Here
|
69 |
#endif |
70 |
#endif |
70 |
return rv; |
71 |
return rv; |
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) { |
90 |
*_retval = PR_TRUE; |
94 |
*_retval = PR_TRUE; |
91 |
hildon_uri_action_unref(action); |
95 |
hildon_uri_action_unref(action); |
Lines 104-119
nsMIMEInfoUnix::LaunchDefaultWithFile(ns
Link Here
|
104 |
aFile->GetNativePath(nativePath); |
108 |
aFile->GetNativePath(nativePath); |
105 |
|
109 |
|
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); |
118 |
} |
132 |
} |
119 |
|
133 |
|