0
|
1 |
From: Wolfgang Rosenauer <wr@rosenauer.org>
|
|
2 |
Subject: no helper app for application/octet-stream but recognized extensions
|
|
3 |
References:
|
|
4 |
https://bugzilla.novell.com/show_bug.cgi?id=406979
|
|
5 |
https://bugzilla.mozilla.org/show_bug.cgi?id=327323
|
|
6 |
|
|
7 |
diff --git a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
|
|
8 |
--- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
|
|
9 |
+++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
|
|
10 |
@@ -47,6 +47,7 @@
|
|
11 |
#include "nsMIMEInfoUnix.h"
|
|
12 |
#include "nsGNOMERegistry.h"
|
|
13 |
#include "nsIGnomeVFSService.h"
|
|
14 |
+#include "nsAutoPtr.h"
|
|
15 |
#ifdef MOZ_ENABLE_DBUS
|
|
16 |
#include "nsDBusHandlerApp.h"
|
|
17 |
#endif
|
|
18 |
@@ -74,13 +75,16 @@ NS_IMETHODIMP
|
|
19 |
nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval)
|
|
20 |
{
|
|
21 |
*_retval = PR_FALSE;
|
|
22 |
- nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
|
|
23 |
- if (vfs) {
|
|
24 |
- nsCOMPtr<nsIGnomeVFSMimeApp> app;
|
|
25 |
- if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app)
|
|
26 |
- *_retval = PR_TRUE;
|
|
27 |
+ nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromType(mType);
|
|
28 |
+ if (!mimeInfo) {
|
|
29 |
+ nsCAutoString ext;
|
|
30 |
+ GetPrimaryExtension(ext);
|
|
31 |
+ mimeInfo = nsGNOMERegistry::GetFromExtension(ext);
|
|
32 |
}
|
|
33 |
|
|
34 |
+ if (mimeInfo)
|
|
35 |
+ *_retval = PR_TRUE;
|
|
36 |
+
|
|
37 |
if (*_retval)
|
|
38 |
return NS_OK;
|
|
39 |
|
|
40 |
@@ -113,6 +117,16 @@ nsMIMEInfoUnix::LaunchDefaultWithFile(ns
|
|
41 |
nsCOMPtr<nsIGnomeVFSMimeApp> app;
|
|
42 |
if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app)
|
|
43 |
return app->Launch(nativePath);
|
|
44 |
+
|
|
45 |
+ // If we haven't got an app we try to get a valid one by searching for the
|
|
46 |
+ // extension mapped type
|
|
47 |
+ nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromExtension(nativePath);
|
|
48 |
+ if (mimeInfo) {
|
|
49 |
+ nsCAutoString type;
|
|
50 |
+ mimeInfo->GetType(type);
|
|
51 |
+ if (NS_SUCCEEDED(vfs->GetAppForMimeType(type, getter_AddRefs(app))) && app)
|
|
52 |
+ return app->Launch(nativePath);
|
|
53 |
+ }
|
|
54 |
}
|
|
55 |
|
|
56 |
if (!mDefaultApplication)
|
|
57 |
diff --git a/uriloader/exthandler/unix/nsOSHelperAppService.cpp b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
|
|
58 |
--- a/uriloader/exthandler/unix/nsOSHelperAppService.cpp
|
|
59 |
+++ b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
|
|
60 |
@@ -1580,8 +1580,16 @@ nsOSHelperAppService::GetMIMEInfoFromOS(
|
|
61 |
return retval;
|
|
62 |
}
|
|
63 |
|
|
64 |
- // Copy the attributes of retval onto miByExt, to return it
|
|
65 |
+ // Copy the attributes of retval (mimeinfo from type) onto miByExt, to
|
|
66 |
+ // return it
|
|
67 |
+ // but reset to just collected mDefaultAppDescription (from ext)
|
|
68 |
+ // and preserve the primary extension as well
|
|
69 |
+ nsAutoString byExtDefault;
|
|
70 |
+ miByExt->GetDefaultDescription(byExtDefault);
|
|
71 |
+ retval->SetDefaultDescription(byExtDefault);
|
|
72 |
retval->CopyBasicDataTo(miByExt);
|
|
73 |
+ if (!aFileExt.IsEmpty())
|
|
74 |
+ miByExt->SetPrimaryExtension(aFileExt);
|
|
75 |
|
|
76 |
miByExt.swap(retval);
|
|
77 |
}
|