forked from sailfishos/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0024-sailfishos-gecko-Use-libcontentaction-for-custom-sch.patch
142 lines (129 loc) · 4.95 KB
/
0024-sailfishos-gecko-Use-libcontentaction-for-custom-sch.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Raine Makelainen <[email protected]>
Date: Fri, 31 Jan 2020 11:09:02 +0000
Subject: [PATCH] [sailfishos][gecko] Use libcontentaction for custom scheme
uri handling. JB#47892
Signed-off-by: Raine Makelainen <[email protected]>
---
old-configure.in | 8 +++++---
uriloader/exthandler/nsContentHandlerApp.h | 5 +++--
uriloader/exthandler/unix/nsMIMEInfoUnix.cpp | 15 +++++++++++++--
.../exthandler/unix/nsOSHelperAppService.cpp | 5 +++++
xpcom/io/moz.build | 2 ++
xpcom/io/nsLocalFileUnix.cpp | 4 ++++
6 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/old-configure.in b/old-configure.in
index ae16f305943c..f08d51c34942 100644
--- a/old-configure.in
+++ b/old-configure.in
@@ -2320,11 +2320,13 @@ then
fi
MOZ_ENABLE_CONTENTACTION=
- PKG_CHECK_MODULES(LIBCONTENTACTION, contentaction-0.1, _LIB_FOUND=1, _LIB_FOUND=)
+ PKG_CHECK_MODULES(LIBCONTENTACTION, contentaction5,
+ MOZ_ENABLE_CONTENTACTION=1,
+ MOZ_ENABLE_CONTENTACTION=)
if test "$MOZ_ENABLE_CONTENTACTION"; then
MOZ_ENABLE_CONTENTACTION=1
- MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_CONTENTACTION_CFLAGS"
- MOZ_QT_LIBS="$MOZ_QT_LIBS $_CONTENTACTION_LIBS"
+ MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $LIBCONTENTACTION_CFLAGS"
+ MOZ_QT_LIBS="$MOZ_QT_LIBS $LIBCONTENTACTION_LIBS"
AC_DEFINE(MOZ_ENABLE_CONTENTACTION)
AC_SUBST(MOZ_ENABLE_CONTENTACTION)
fi
diff --git a/uriloader/exthandler/nsContentHandlerApp.h b/uriloader/exthandler/nsContentHandlerApp.h
index f372d8735e0a..fa35109fa37d 100644
--- a/uriloader/exthandler/nsContentHandlerApp.h
+++ b/uriloader/exthandler/nsContentHandlerApp.h
@@ -7,7 +7,7 @@
#ifndef __nsContentHandlerAppImpl_h__
#define __nsContentHandlerAppImpl_h__
-#include <contentaction/contentaction.h>
+#include <contentaction5/contentaction.h>
#include "nsString.h"
#include "nsIMIMEInfo.h"
@@ -18,9 +18,10 @@ class nsContentHandlerApp : public nsIHandlerApp {
nsContentHandlerApp(nsString aName, nsCString aType,
ContentAction::Action& aAction);
+
+ private:
virtual ~nsContentHandlerApp() {}
- protected:
nsString mName;
nsCString mType;
nsString mDetailedDescription;
diff --git a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
index 807583a57d12..786b1f7b79a3 100644
--- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
+++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
@@ -5,8 +5,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef MOZ_WIDGET_QT
-#if (MOZ_ENABLE_CONTENTACTION)
-#include <contentaction/contentaction.h>
+#if defined(MOZ_ENABLE_CONTENTACTION)
+#include <contentaction5/contentaction.h>
#include "nsContentHandlerApp.h"
#endif
#endif
@@ -74,6 +74,17 @@ nsresult nsMIMEInfoUnix::LaunchDefaultWithFile(nsIFile *aFile) {
nsAutoCString nativePath;
aFile->GetNativePath(nativePath);
+#if defined(MOZ_ENABLE_CONTENTACTION)
+ QUrl localFileUri = QUrl::fromLocalFile(QString::fromUtf8(nativePath.get()));
+ ContentAction::Action action =
+ ContentAction::Action::defaultActionForFile(localFileUri, QString(mSchemeOrType.get()));
+ if (action.isValid()) {
+ action.trigger();
+ return NS_OK;
+ }
+ return NS_ERROR_FAILURE;
+#endif
+
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
if (!giovfs) {
return NS_ERROR_FAILURE;
diff --git a/uriloader/exthandler/unix/nsOSHelperAppService.cpp b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
index 65c95b8fe4c5..d5b318f12217 100644
--- a/uriloader/exthandler/unix/nsOSHelperAppService.cpp
+++ b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
@@ -7,6 +7,11 @@
#include <sys/types.h>
#include <sys/stat.h>
+#if defined(MOZ_ENABLE_CONTENTACTION)
+#include <contentaction5/contentaction.h>
+#include <QString>
+#endif
+
#include "nsOSHelperAppService.h"
#include "nsMIMEInfoUnix.h"
#ifdef MOZ_WIDGET_GTK
diff --git a/xpcom/io/moz.build b/xpcom/io/moz.build
index 7357ded22996..3eea8dafe77c 100644
--- a/xpcom/io/moz.build
+++ b/xpcom/io/moz.build
@@ -144,6 +144,8 @@ LOCAL_INCLUDES += [
'../build',
]
+CXXFLAGS += CONFIG['TK_CFLAGS']
+
if CONFIG['CC_TYPE'] in ('msvc', 'clang-cl'):
# This is intended as a temporary hack to support building with VS2015.
# '_snwprintf' : format string '%s' requires an argument of type 'wchar_t *',
diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp
index 17237c6422f4..d0fdfb14b33b 100644
--- a/xpcom/io/nsLocalFileUnix.cpp
+++ b/xpcom/io/nsLocalFileUnix.cpp
@@ -69,6 +69,10 @@ static nsresult MacErrorMapper(OSErr inErr);
#include <linux/magic.h>
#endif
+#ifdef MOZ_ENABLE_CONTENTACTION
+#include <contentaction5/contentaction.h>
+#endif
+
#include "nsNativeCharsetUtils.h"
#include "nsTraceRefcnt.h"
#include "nsHashKeys.h"
--
2.26.2