fixed gnome shell search provider patch

This commit is contained in:
Martin Stransky 2019-11-27 21:43:03 +01:00
parent 9c047cad1c
commit 836d9a03a1
3 changed files with 52 additions and 45 deletions

View File

@ -34,4 +34,4 @@ pref("spellchecker.dictionary_path","/usr/share/myspell");
pref("network.trr.mode", 5); pref("network.trr.mode", 5);
/* Enable per-user policy dir, see mozbz#1583466 */ /* Enable per-user policy dir, see mozbz#1583466 */
pref("browser.policies.perUserDir", true); pref("browser.policies.perUserDir", true);
pref("widget.gnome-search-provider.enabled",true); pref("browser.gnome-search-provider.enabled",true);

View File

@ -94,7 +94,7 @@ ExcludeArch: ppc64le
Summary: Mozilla Firefox Web browser Summary: Mozilla Firefox Web browser
Name: firefox Name: firefox
Version: 71.0 Version: 71.0
Release: 5%{?pre_tag}%{?dist} Release: 6%{?pre_tag}%{?dist}
URL: https://www.mozilla.org/firefox/ URL: https://www.mozilla.org/firefox/
License: MPLv1.1 or GPLv2+ or LGPLv2+ License: MPLv1.1 or GPLv2+ or LGPLv2+
Source0: https://archive.mozilla.org/pub/firefox/releases/%{version}%{?pre_version}/source/firefox-%{version}%{?pre_version}.source.tar.xz Source0: https://archive.mozilla.org/pub/firefox/releases/%{version}%{?pre_version}/source/firefox-%{version}%{?pre_version}.source.tar.xz
@ -357,7 +357,7 @@ This package contains results of tests executed during build.
%endif %endif
%patch227 -p1 -b .locale-debug %patch227 -p1 -b .locale-debug
%patch228 -p1 -b .mozilla-1583466 %patch228 -p1 -b .mozilla-1583466
#%patch239 -p1 -b .gnome-shell-search-provider %patch239 -p1 -b .gnome-shell-search-provider
%patch402 -p1 -b .1196777 %patch402 -p1 -b .1196777
%ifarch %{arm} %ifarch %{arm}
@ -964,6 +964,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
#--------------------------------------------------------------------- #---------------------------------------------------------------------
%changelog %changelog
* Wed Nov 27 2019 Martin Stransky <stransky@redhat.com> - 71.0-6
- Enable Gnome search provider
* Wed Nov 27 2019 Martin Stransky <stransky@redhat.com> - 71.0-5 * Wed Nov 27 2019 Martin Stransky <stransky@redhat.com> - 71.0-5
- Added fix for mozbz#1593408 - Added fix for mozbz#1593408
- Temporary disable Gnome search provider - Temporary disable Gnome search provider

View File

@ -1,6 +1,6 @@
diff -up firefox-71.0/browser/components/shell/moz.build.gnome-shell-search-provider firefox-71.0/browser/components/shell/moz.build diff -up firefox-71.0/browser/components/shell/moz.build.gnome-shell-search-provider firefox-71.0/browser/components/shell/moz.build
--- firefox-71.0/browser/components/shell/moz.build.gnome-shell-search-provider 2019-11-26 01:02:19.000000000 +0100 --- firefox-71.0/browser/components/shell/moz.build.gnome-shell-search-provider 2019-11-26 01:02:19.000000000 +0100
+++ firefox-71.0/browser/components/shell/moz.build 2019-11-26 12:35:50.033210214 +0100 +++ firefox-71.0/browser/components/shell/moz.build 2019-11-27 21:37:02.754148375 +0100
@@ -34,6 +34,11 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gt @@ -34,6 +34,11 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gt
SOURCES += [ SOURCES += [
'nsGNOMEShellService.cpp', 'nsGNOMEShellService.cpp',
@ -23,9 +23,9 @@ diff -up firefox-71.0/browser/components/shell/moz.build.gnome-shell-search-prov
with Files('**'): with Files('**'):
BUG_COMPONENT = ('Firefox', 'Shell Integration') BUG_COMPONENT = ('Firefox', 'Shell Integration')
diff -up firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.cpp.gnome-shell-search-provider firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.cpp diff -up firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.cpp.gnome-shell-search-provider firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.cpp
--- firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.cpp.gnome-shell-search-provider 2019-11-26 12:35:50.033210214 +0100 --- firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.cpp.gnome-shell-search-provider 2019-11-27 21:37:02.754148375 +0100
+++ firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.cpp 2019-11-26 12:35:50.033210214 +0100 +++ firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.cpp 2019-11-27 21:37:02.754148375 +0100
@@ -0,0 +1,607 @@ @@ -0,0 +1,621 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: +/* vim:expandtab:shiftwidth=2:tabstop=2:
+ */ + */
@ -137,7 +137,7 @@ diff -up firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.cpp.gn
+ nsINavHistoryQueryOptions::SORT_BY_VISITCOUNT_DESCENDING); + nsINavHistoryQueryOptions::SORT_BY_VISITCOUNT_DESCENDING);
+ NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, rv);
+ +
+ rv = histQueryOpts->SetMaxResults(10); + rv = histQueryOpts->SetMaxResults(MAX_SEARCH_RESULTS_NUM);
+ NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, rv);
+ +
+ // We only search history, because searching both bookmarks and history + // We only search history, because searching both bookmarks and history
@ -184,6 +184,20 @@ diff -up firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.cpp.gn
+ return NS_SUCCEEDED(rv) && !title.IsEmpty(); + return NS_SUCCEEDED(rv) && !title.IsEmpty();
+} +}
+ +
+void nsGNOMEShellSearchProvider::GetIDKeyForURI(int aIndex, nsAutoCString& aUri,
+ nsAutoCString& aIDKey) {
+ // Compose ID as NN:URL where NN is index to our current history
+ // result container.
+ aIDKey = nsPrintfCString("%.2d:%s", aIndex, aUri.get());
+}
+
+int nsGNOMEShellSearchProvider::GetIndexFromIDKey(const char* aIDKey) {
+ // ID is NN:URL where NN is index to our current history
+ // result container.
+ char tmp[] = {aIDKey[0], aIDKey[1], '\0'};
+ return atoi(tmp);
+}
+
+void nsGNOMEShellSearchProvider::ComposeSearchResultReply( +void nsGNOMEShellSearchProvider::ComposeSearchResultReply(
+ DBusMessage* reply, const char* aSearchTerm) { + DBusMessage* reply, const char* aSearchTerm) {
+ uint32_t childCount = 0; + uint32_t childCount = 0;
@ -214,8 +228,10 @@ diff -up firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.cpp.gn
+ nsAutoCString uri; + nsAutoCString uri;
+ child->GetUri(uri); + child->GetUri(uri);
+ +
+ nsPrintfCString idString("%d", i); + nsAutoCString idKey;
+ const char* id = idString.get(); + GetIDKeyForURI(i, uri, idKey);
+
+ const char* id = idKey.get();
+ dbus_message_iter_append_basic(&iterArray, DBUS_TYPE_STRING, &id); + dbus_message_iter_append_basic(&iterArray, DBUS_TYPE_STRING, &id);
+ } + }
+ +
@ -309,10 +325,8 @@ diff -up firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.cpp.gn
+*/ +*/
+void nsGNOMEShellSearchProvider::AppendResultID(DBusMessageIter* aIter, +void nsGNOMEShellSearchProvider::AppendResultID(DBusMessageIter* aIter,
+ const char* aID) { + const char* aID) {
+ int keyIndex = atoi(aID);
+ nsCOMPtr<nsINavHistoryResultNode> child; + nsCOMPtr<nsINavHistoryResultNode> child;
+ mHistResultContainer->GetChild(keyIndex, getter_AddRefs(child)); + mHistResultContainer->GetChild(GetIndexFromIDKey(aID), getter_AddRefs(child));
+
+ nsAutoCString title; + nsAutoCString title;
+ if (NS_FAILED(child->GetTitle(title))) { + if (NS_FAILED(child->GetTitle(title))) {
+ return; + return;
@ -386,16 +400,6 @@ diff -up firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.cpp.gn
+ +
+void nsGNOMEShellSearchProvider::LaunchWithID(const char* aID, +void nsGNOMEShellSearchProvider::LaunchWithID(const char* aID,
+ uint32_t aTimeStamp) { + uint32_t aTimeStamp) {
+ int keyIndex = atoi(aID);
+ nsCOMPtr<nsINavHistoryResultNode> child;
+ mHistResultContainer->GetChild(keyIndex, getter_AddRefs(child));
+
+ nsAutoCString uri;
+ nsresult rv = child->GetUri(uri);
+ if (NS_FAILED(rv)) {
+ return;
+ }
+
+ char* commandLine = nullptr; + char* commandLine = nullptr;
+ int tmp; + int tmp;
+ +
@ -404,6 +408,16 @@ diff -up firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.cpp.gn
+ const char* urlList[2] = {"unused", searchString.get()}; + const char* urlList[2] = {"unused", searchString.get()};
+ commandLine = ConstructCommandLine(2, (char**)urlList, 0, &tmp); + commandLine = ConstructCommandLine(2, (char**)urlList, 0, &tmp);
+ } else { + } else {
+ int keyIndex = atoi(aID);
+ nsCOMPtr<nsINavHistoryResultNode> child;
+ mHistResultContainer->GetChild(keyIndex, getter_AddRefs(child));
+
+ nsAutoCString uri;
+ nsresult rv = child->GetUri(uri);
+ if (NS_FAILED(rv)) {
+ return;
+ }
+
+ const char* urlList[2] = {"unused", uri.get()}; + const char* urlList[2] = {"unused", uri.get()};
+ commandLine = ConstructCommandLine(2, (char**)urlList, 0, &tmp); + commandLine = ConstructCommandLine(2, (char**)urlList, 0, &tmp);
+ } + }
@ -634,9 +648,9 @@ diff -up firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.cpp.gn
+ mConnection = nullptr; + mConnection = nullptr;
+} +}
diff -up firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.h.gnome-shell-search-provider firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.h diff -up firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.h.gnome-shell-search-provider firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.h
--- firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.h.gnome-shell-search-provider 2019-11-26 12:35:50.033210214 +0100 --- firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.h.gnome-shell-search-provider 2019-11-27 21:37:02.754148375 +0100
+++ firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.h 2019-11-26 12:35:50.033210214 +0100 +++ firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.h 2019-11-27 21:37:02.754148375 +0100
@@ -0,0 +1,53 @@ @@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: +/* vim:expandtab:shiftwidth=2:tabstop=2:
+ */ + */
@ -674,6 +688,8 @@ diff -up firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.h.gnom
+ DBusHandlerResult LaunchSearch(DBusMessage* msg); + DBusHandlerResult LaunchSearch(DBusMessage* msg);
+ +
+ nsresult QueryHistory(const char* aSearchTerm); + nsresult QueryHistory(const char* aSearchTerm);
+ void GetIDKeyForURI(int aIndex, nsAutoCString& aUri, nsAutoCString& aIDKey);
+ int GetIndexFromIDKey(const char* aIDKey);
+ bool IsHistoryResultNodeURI(nsINavHistoryResultNode* aHistoryNode); + bool IsHistoryResultNodeURI(nsINavHistoryResultNode* aHistoryNode);
+ void AppendResultID(DBusMessageIter* aIter, const char* aID); + void AppendResultID(DBusMessageIter* aIter, const char* aID);
+ void AppendSearchID(DBusMessageIter* aIter, const char* aID); + void AppendSearchID(DBusMessageIter* aIter, const char* aID);
@ -692,13 +708,13 @@ diff -up firefox-71.0/browser/components/shell/nsGNOMEShellSearchProvider.h.gnom
+#endif // __nsGNOMEShellSearchProvider_h__ +#endif // __nsGNOMEShellSearchProvider_h__
diff -up firefox-71.0/browser/components/shell/nsGNOMEShellService.cpp.gnome-shell-search-provider firefox-71.0/browser/components/shell/nsGNOMEShellService.cpp diff -up firefox-71.0/browser/components/shell/nsGNOMEShellService.cpp.gnome-shell-search-provider firefox-71.0/browser/components/shell/nsGNOMEShellService.cpp
--- firefox-71.0/browser/components/shell/nsGNOMEShellService.cpp.gnome-shell-search-provider 2019-11-26 01:02:19.000000000 +0100 --- firefox-71.0/browser/components/shell/nsGNOMEShellService.cpp.gnome-shell-search-provider 2019-11-26 01:02:19.000000000 +0100
+++ firefox-71.0/browser/components/shell/nsGNOMEShellService.cpp 2019-11-27 08:44:18.204710354 +0100 +++ firefox-71.0/browser/components/shell/nsGNOMEShellService.cpp 2019-11-27 21:37:02.754148375 +0100
@@ -92,6 +92,12 @@ nsresult nsGNOMEShellService::Init() { @@ -92,6 +92,12 @@ nsresult nsGNOMEShellService::Init() {
if (!giovfs && !gsettings) return NS_ERROR_NOT_AVAILABLE; if (!giovfs && !gsettings) return NS_ERROR_NOT_AVAILABLE;
+#ifdef MOZ_ENABLE_DBUS +#ifdef MOZ_ENABLE_DBUS
+ if (Preferences::GetBool("widget.gnome-search-provider.enabled", false)) { + if (Preferences::GetBool("browser.gnome-search-provider.enabled", false)) {
+ mSearchProvider.Startup(); + mSearchProvider.Startup();
+ } + }
+#endif +#endif
@ -706,21 +722,9 @@ diff -up firefox-71.0/browser/components/shell/nsGNOMEShellService.cpp.gnome-she
// Check G_BROKEN_FILENAMES. If it's set, then filenames in glib use // Check G_BROKEN_FILENAMES. If it's set, then filenames in glib use
// the locale encoding. If it's not set, they use UTF-8. // the locale encoding. If it's not set, they use UTF-8.
mUseLocaleFilenames = PR_GetEnv("G_BROKEN_FILENAMES") != nullptr; mUseLocaleFilenames = PR_GetEnv("G_BROKEN_FILENAMES") != nullptr;
@@ -107,7 +113,10 @@ nsresult nsGNOMEShellService::Init() {
getter_AddRefs(appPath));
NS_ENSURE_SUCCESS(rv, rv);
- return appPath->GetNativePath(mAppPath);
+ rv = appPath->GetNativePath(mAppPath);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ return NS_OK;
}
NS_IMPL_ISUPPORTS(nsGNOMEShellService, nsIGNOMEShellService, nsIShellService,
diff -up firefox-71.0/browser/components/shell/nsGNOMEShellService.h.gnome-shell-search-provider firefox-71.0/browser/components/shell/nsGNOMEShellService.h diff -up firefox-71.0/browser/components/shell/nsGNOMEShellService.h.gnome-shell-search-provider firefox-71.0/browser/components/shell/nsGNOMEShellService.h
--- firefox-71.0/browser/components/shell/nsGNOMEShellService.h.gnome-shell-search-provider 2019-11-26 01:02:19.000000000 +0100 --- firefox-71.0/browser/components/shell/nsGNOMEShellService.h.gnome-shell-search-provider 2019-11-26 01:02:19.000000000 +0100
+++ firefox-71.0/browser/components/shell/nsGNOMEShellService.h 2019-11-26 12:35:50.033210214 +0100 +++ firefox-71.0/browser/components/shell/nsGNOMEShellService.h 2019-11-27 21:37:02.754148375 +0100
@@ -10,6 +10,9 @@ @@ -10,6 +10,9 @@
#include "nsToolkitShellService.h" #include "nsToolkitShellService.h"
#include "nsString.h" #include "nsString.h"
@ -742,8 +746,8 @@ diff -up firefox-71.0/browser/components/shell/nsGNOMEShellService.h.gnome-shell
bool mUseLocaleFilenames; bool mUseLocaleFilenames;
nsCString mAppPath; nsCString mAppPath;
diff -up firefox-71.0/browser/locales/en-US/chrome/browser/browser.properties.gnome-shell-search-provider firefox-71.0/browser/locales/en-US/chrome/browser/browser.properties diff -up firefox-71.0/browser/locales/en-US/chrome/browser/browser.properties.gnome-shell-search-provider firefox-71.0/browser/locales/en-US/chrome/browser/browser.properties
--- firefox-71.0/browser/locales/en-US/chrome/browser/browser.properties.gnome-shell-search-provider 2019-11-26 01:02:19.000000000 +0100 --- firefox-71.0/browser/locales/en-US/chrome/browser/browser.properties.gnome-shell-search-provider 2019-11-27 21:37:02.755148375 +0100
+++ firefox-71.0/browser/locales/en-US/chrome/browser/browser.properties 2019-11-26 12:35:50.034210214 +0100 +++ firefox-71.0/browser/locales/en-US/chrome/browser/browser.properties 2019-11-27 21:39:11.796094294 +0100
@@ -1025,3 +1025,7 @@ confirmationHint.passwordSaved.label = P @@ -1025,3 +1025,7 @@ confirmationHint.passwordSaved.label = P
# Used by the export of user's live bookmarks to an OPML file as a title for the file. # Used by the export of user's live bookmarks to an OPML file as a title for the file.
# %S will be replaced with brandShortName # %S will be replaced with brandShortName
@ -754,7 +758,7 @@ diff -up firefox-71.0/browser/locales/en-US/chrome/browser/browser.properties.gn
+gnomeSearchProviderSearch=Search the web for “%s” +gnomeSearchProviderSearch=Search the web for “%s”
diff -up firefox-71.0/toolkit/components/remote/moz.build.gnome-shell-search-provider firefox-71.0/toolkit/components/remote/moz.build diff -up firefox-71.0/toolkit/components/remote/moz.build.gnome-shell-search-provider firefox-71.0/toolkit/components/remote/moz.build
--- firefox-71.0/toolkit/components/remote/moz.build.gnome-shell-search-provider 2019-11-26 01:02:29.000000000 +0100 --- firefox-71.0/toolkit/components/remote/moz.build.gnome-shell-search-provider 2019-11-26 01:02:29.000000000 +0100
+++ firefox-71.0/toolkit/components/remote/moz.build 2019-11-26 12:35:50.034210214 +0100 +++ firefox-71.0/toolkit/components/remote/moz.build 2019-11-27 21:37:02.755148375 +0100
@@ -25,6 +25,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk' @@ -25,6 +25,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk'
'nsDBusRemoteServer.cpp', 'nsDBusRemoteServer.cpp',
] ]
@ -768,7 +772,7 @@ diff -up firefox-71.0/toolkit/components/remote/moz.build.gnome-shell-search-pro
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
diff -up firefox-71.0/toolkit/components/remote/nsDBusRemoteServer.cpp.gnome-shell-search-provider firefox-71.0/toolkit/components/remote/nsDBusRemoteServer.cpp diff -up firefox-71.0/toolkit/components/remote/nsDBusRemoteServer.cpp.gnome-shell-search-provider firefox-71.0/toolkit/components/remote/nsDBusRemoteServer.cpp
--- firefox-71.0/toolkit/components/remote/nsDBusRemoteServer.cpp.gnome-shell-search-provider 2019-11-26 01:02:29.000000000 +0100 --- firefox-71.0/toolkit/components/remote/nsDBusRemoteServer.cpp.gnome-shell-search-provider 2019-11-26 01:02:29.000000000 +0100
+++ firefox-71.0/toolkit/components/remote/nsDBusRemoteServer.cpp 2019-11-26 12:35:50.034210214 +0100 +++ firefox-71.0/toolkit/components/remote/nsDBusRemoteServer.cpp 2019-11-27 21:37:02.755148375 +0100
@@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
#include <dlfcn.h> #include <dlfcn.h>