extra/firefox to 58.0.2-1

This commit is contained in:
Kevin Mihelich 2018-02-08 00:28:02 +00:00
parent 16dbd59505
commit 790b553e4f
6 changed files with 35 additions and 731 deletions

View file

@ -1,203 +0,0 @@
From 05ec1aa0d5e8806dd0c5c6d08c82846a1389b599 Mon Sep 17 00:00:00 2001
Message-Id: <05ec1aa0d5e8806dd0c5c6d08c82846a1389b599.1512038840.git.jan.steffens@gmail.com>
From: Robin Grenet <robin.grenet@wanadoo.fr>
Date: Thu, 16 Nov 2017 13:35:58 +0100
Subject: [PATCH 1/2] Bug 1360278 - Add preference to trigger context menu on
mouse up for GTK+ and macOS, r=mstange,smaug
MozReview-Commit-ID: Bg60bD8jIg6
--HG--
extra : rebase_source : cc8bd5796096f49ad4fdab81885a426afd6117e4
---
modules/libpref/init/all.js | 4 ++++
widget/cocoa/nsChildView.mm | 23 +++++++++++++++++++++--
widget/gtk/nsWindow.cpp | 27 ++++++++++++++++++++-------
widget/gtk/nsWindow.h | 2 ++
widget/nsBaseWidget.cpp | 16 ++++++++++++++++
widget/nsBaseWidget.h | 6 ++++++
6 files changed, 69 insertions(+), 9 deletions(-)
diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
index 9febead1d363d792..7a6e6a20f3cc3fd6 100644
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -231,6 +231,10 @@ pref("browser.sessionhistory.max_total_viewers", -1);
pref("ui.use_native_colors", true);
pref("ui.click_hold_context_menus", false);
+
+// Pop up context menu on mouseup instead of mousedown, if that's the OS default.
+// Note: ignored on Windows (context menus always use mouseup)
+pref("ui.context_menus.after_mouseup", false);
// Duration of timeout of incremental search in menus (ms). 0 means infinite.
pref("ui.menu.incremental_search.timeout", 1000);
// If true, all popups won't hide automatically on blur
diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm
index 25b4c1ba7a2d1207..2affd1ef386cbfd0 100644
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -4719,30 +4719,49 @@ NSEvent* gLastDragMouseDownEvent = nil;
if (!mGeckoChild)
return;
- // Let the superclass do the context menu stuff.
- [super rightMouseDown:theEvent];
+ if (!nsBaseWidget::ShowContextMenuAfterMouseUp()) {
+ // Let the superclass do the context menu stuff.
+ [super rightMouseDown:theEvent];
+ }
NS_OBJC_END_TRY_ABORT_BLOCK;
}
- (void)rightMouseUp:(NSEvent *)theEvent
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
if (!mGeckoChild)
return;
if (mTextInputHandler->OnHandleEvent(theEvent)) {
return;
}
WidgetMouseEvent geckoEvent(true, eMouseUp, mGeckoChild,
WidgetMouseEvent::eReal);
[self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
geckoEvent.button = WidgetMouseEvent::eRightButton;
geckoEvent.mClickCount = [theEvent clickCount];
nsAutoRetainCocoaObject kungFuDeathGrip(self);
mGeckoChild->DispatchInputEvent(&geckoEvent);
+ if (!mGeckoChild)
+ return;
+
+ if (nsBaseWidget::ShowContextMenuAfterMouseUp()) {
+ // Let the superclass do the context menu stuff, but pretend it's rightMouseDown.
+ NSEvent *dupeEvent = [NSEvent mouseEventWithType:NSRightMouseDown
+ location:theEvent.locationInWindow
+ modifierFlags:theEvent.modifierFlags
+ timestamp:theEvent.timestamp
+ windowNumber:theEvent.windowNumber
+ context:theEvent.context
+ eventNumber:theEvent.eventNumber
+ clickCount:theEvent.clickCount
+ pressure:theEvent.pressure];
+
+ [super rightMouseDown:dupeEvent];
+ }
NS_OBJC_END_TRY_ABORT_BLOCK;
}
diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp
index 37b6aae4c3d0b4e7..2b80124538c20ed6 100644
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -2727,6 +2727,19 @@ static guint ButtonMaskFromGDKButton(guint button)
return GDK_BUTTON1_MASK << (button - 1);
}
+void
+nsWindow::DispatchContextMenuEventFromMouseEvent(uint16_t domButton,
+ GdkEventButton *aEvent)
+{
+ if (domButton == WidgetMouseEvent::eRightButton && MOZ_LIKELY(!mIsDestroyed)) {
+ WidgetMouseEvent contextMenuEvent(true, eContextMenu, this,
+ WidgetMouseEvent::eReal);
+ InitButtonEvent(contextMenuEvent, aEvent);
+ contextMenuEvent.pressure = mLastMotionPressure;
+ DispatchInputEvent(&contextMenuEvent);
+ }
+}
+
void
nsWindow::OnButtonPressEvent(GdkEventButton *aEvent)
{
@@ -2796,13 +2809,8 @@ nsWindow::OnButtonPressEvent(GdkEventButton *aEvent)
DispatchInputEvent(&event);
// right menu click on linux should also pop up a context menu
- if (domButton == WidgetMouseEvent::eRightButton &&
- MOZ_LIKELY(!mIsDestroyed)) {
- WidgetMouseEvent contextMenuEvent(true, eContextMenu, this,
- WidgetMouseEvent::eReal);
- InitButtonEvent(contextMenuEvent, aEvent);
- contextMenuEvent.pressure = mLastMotionPressure;
- DispatchInputEvent(&contextMenuEvent);
+ if (!nsBaseWidget::ShowContextMenuAfterMouseUp()) {
+ DispatchContextMenuEventFromMouseEvent(domButton, aEvent);
}
}
@@ -2838,6 +2846,11 @@ nsWindow::OnButtonReleaseEvent(GdkEventButton *aEvent)
DispatchInputEvent(&event);
mLastMotionPressure = pressure;
+
+ // right menu click on linux should also pop up a context menu
+ if (nsBaseWidget::ShowContextMenuAfterMouseUp()) {
+ DispatchContextMenuEventFromMouseEvent(domButton, aEvent);
+ }
}
void
diff --git a/widget/gtk/nsWindow.h b/widget/gtk/nsWindow.h
index f7c07d57491b0b83..b969c9db4306ba6a 100644
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -245,6 +245,8 @@ private:
void UpdateClientOffset();
+ void DispatchContextMenuEventFromMouseEvent(uint16_t domButton,
+ GdkEventButton *aEvent);
public:
void ThemeChanged(void);
void OnDPIChanged(void);
diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp
index 996409f45db11cc7..de73fe36d27955cd 100644
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -1222,6 +1222,22 @@ nsBaseWidget::DispatchEventToAPZOnly(mozilla::WidgetInputEvent* aEvent)
}
}
+// static
+bool
+nsBaseWidget::ShowContextMenuAfterMouseUp()
+{
+ static bool gContextMenuAfterMouseUp = false;
+ static bool gContextMenuAfterMouseUpCached = false;
+ if (!gContextMenuAfterMouseUpCached) {
+ Preferences::AddBoolVarCache(&gContextMenuAfterMouseUp,
+ "ui.context_menus.after_mouseup",
+ false);
+
+ gContextMenuAfterMouseUpCached = true;
+ }
+ return gContextMenuAfterMouseUp;
+}
+
nsIDocument*
nsBaseWidget::GetDocument() const
{
diff --git a/widget/nsBaseWidget.h b/widget/nsBaseWidget.h
index 6d6b93ea73d64b38..cdc6aa0c87279832 100644
--- a/widget/nsBaseWidget.h
+++ b/widget/nsBaseWidget.h
@@ -418,6 +418,12 @@ public:
void RecvScreenPixels(mozilla::ipc::Shmem&& aMem, const ScreenIntSize& aSize) override {};
#endif
+ /**
+ * Whether context menus should only appear on mouseup instead of mousedown,
+ * on OSes where they normally appear on mousedown (macOS, *nix).
+ */
+ static bool ShowContextMenuAfterMouseUp();
+
protected:
// These are methods for CompositorWidgetWrapper, and should only be
// accessed from that class. Derived widgets can choose which methods to
--
2.15.1

View file

@ -0,0 +1,27 @@
From 2877a352715ce7e30ef364722757c6ec380236b1 Mon Sep 17 00:00:00 2001
Message-Id: <2877a352715ce7e30ef364722757c6ec380236b1.1518037075.git.jan.steffens@gmail.com>
From: Harald van Dijk <harald@gigawatt.nl>
Date: Thu, 18 Jan 2018 15:18:37 -0700
Subject: [PATCH] Bug 1430274 - Define MOZ_ALSA for more source files. r=jld
---
security/sandbox/linux/moz.build | 3 +++
1 file changed, 3 insertions(+)
diff --git a/security/sandbox/linux/moz.build b/security/sandbox/linux/moz.build
index 681d658bfeb7..1a49b548af2d 100644
--- a/security/sandbox/linux/moz.build
+++ b/security/sandbox/linux/moz.build
@@ -78,6 +78,9 @@ if CONFIG['MOZ_GMP_SANDBOX']:
'SandboxOpenedFiles.cpp',
]
+if CONFIG['MOZ_ALSA']:
+ DEFINES['MOZ_ALSA'] = True
+
# This copy of SafeSPrintf doesn't need to avoid the Chromium logging
# dependency like the one in libxul does, but this way the behavior is
# consistent. See also the comment in SandboxLogging.h.
--
2.16.1

View file

@ -1,254 +0,0 @@
From f19a0f3bc5e1e87d3c663cc2b147c5c0831519c5 Mon Sep 17 00:00:00 2001
Message-Id: <f19a0f3bc5e1e87d3c663cc2b147c5c0831519c5.1512038840.git.jan.steffens@gmail.com>
In-Reply-To: <05ec1aa0d5e8806dd0c5c6d08c82846a1389b599.1512038840.git.jan.steffens@gmail.com>
References: <05ec1aa0d5e8806dd0c5c6d08c82846a1389b599.1512038840.git.jan.steffens@gmail.com>
From: Bob Silverberg <bsilverberg@mozilla.com>
Date: Fri, 24 Nov 2017 07:45:03 -0500
Subject: [PATCH 2/2] Bug 1419426 - Implement
browserSettings.contextMenuShowEvent, r=kmag a=gchang
Uplift for 58.
---
.../components/extensions/ext-browserSettings.js | 45 ++++++++++++++++
.../extensions/schemas/browser_settings.json | 10 ++++
.../test/xpcshell/test_ext_browserSettings.js | 62 ++++++++++++++++++++--
3 files changed, 114 insertions(+), 3 deletions(-)
diff --git a/toolkit/components/extensions/ext-browserSettings.js b/toolkit/components/extensions/ext-browserSettings.js
index f3212f351baf6975..2b24bcc1d09091f2 100644
--- a/toolkit/components/extensions/ext-browserSettings.js
+++ b/toolkit/components/extensions/ext-browserSettings.js
@@ -2,17 +2,23 @@
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
+XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
+ "resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ExtensionSettingsStore",
"resource://gre/modules/ExtensionSettingsStore.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService",
"@mozilla.org/browser/aboutnewtab-service;1",
"nsIAboutNewTabService");
Cu.import("resource://gre/modules/ExtensionPreferencesManager.jsm");
+var {
+ ExtensionError,
+} = ExtensionUtils;
+
const HOMEPAGE_OVERRIDE_SETTING = "homepage_override";
const HOMEPAGE_URL_PREF = "browser.startup.homepage";
const URL_STORE_TYPE = "url_overrides";
@@ -82,6 +88,16 @@ ExtensionPreferencesManager.addSetting("imageAnimationBehavior", {
},
});
+ExtensionPreferencesManager.addSetting("contextMenuShowEvent", {
+ prefNames: [
+ "ui.context_menus.after_mouseup",
+ ],
+
+ setCallback(value) {
+ return {[this.prefNames[0]]: value === "mouseup"};
+ },
+});
+
this.browserSettings = class extends ExtensionAPI {
getAPI(context) {
let {extension} = context;
@@ -114,6 +130,35 @@ this.browserSettings = class extends ExtensionAPI {
() => {
return aboutNewTabService.newTabURL;
}, URL_STORE_TYPE, true),
+ contextMenuShowEvent: Object.assign(
+ getSettingsAPI(
+ extension,
+ "contextMenuShowEvent",
+ () => {
+ if (AppConstants.platform === "win") {
+ return "mouseup";
+ }
+ let prefValue = Services.prefs.getBoolPref(
+ "ui.context_menus.after_mouseup", null);
+ return prefValue ? "mouseup" : "mousedown";
+ }
+ ),
+ {
+ set: details => {
+ if (!["mouseup", "mousedown"].includes(details.value)) {
+ throw new ExtensionError(
+ `${details.value} is not a valid value for contextMenuShowEvent.`);
+ }
+ if (AppConstants.platform === "android" ||
+ (AppConstants.platform === "win" &&
+ details.value === "mousedown")) {
+ return false;
+ }
+ return ExtensionPreferencesManager.setSetting(
+ extension, "contextMenuShowEvent", details.value);
+ },
+ }
+ ),
},
};
}
diff --git a/toolkit/components/extensions/schemas/browser_settings.json b/toolkit/components/extensions/schemas/browser_settings.json
index af073d933723cbd5..4f354e69dfedaf96 100644
--- a/toolkit/components/extensions/schemas/browser_settings.json
+++ b/toolkit/components/extensions/schemas/browser_settings.json
@@ -27,28 +27,38 @@
"type": "string",
"enum": ["normal", "none", "once"],
"description": "How images should be animated in the browser."
+ },
+ {
+ "id": "ContextMenuMouseEvent",
+ "type": "string",
+ "enum": ["mouseup", "mousedown"],
+ "description": "After which mouse event context menus should popup."
}
],
"properties": {
"allowPopupsForUserEvents": {
"$ref": "types.Setting",
"description": "Allows or disallows pop-up windows from opening in response to user events."
},
"cacheEnabled": {
"$ref": "types.Setting",
"description": "Enables or disables the browser cache."
},
"homepageOverride": {
"$ref": "types.Setting",
"description": "Returns the value of the overridden home page. Read-only."
},
"imageAnimationBehavior": {
"$ref": "types.Setting",
"description": "Controls the behaviour of image animation in the browser. This setting's value is of type ImageAnimationBehavior, defaulting to <code>normal</code>."
},
"newTabPageOverride": {
"$ref": "types.Setting",
"description": "Returns the value of the overridden new tab page. Read-only."
+ },
+ "contextMenuShowEvent": {
+ "$ref": "types.Setting",
+ "description": "Controls after which mouse event context menus popup. This setting's value is of type ContextMenuMouseEvent, which has possible values of <code>mouseup</code> and <code>mousedown</code>."
}
}
}
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_browserSettings.js b/toolkit/components/extensions/test/xpcshell/test_ext_browserSettings.js
index 5c441df3e4198671..7e9c1576a723dfc6 100644
--- a/toolkit/components/extensions/test/xpcshell/test_ext_browserSettings.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_browserSettings.js
@@ -24,13 +24,20 @@ add_task(async function test_browser_settings() {
"browser.cache.memory.enable": true,
"dom.popup_allowed_events": Preferences.get("dom.popup_allowed_events"),
"image.animation_mode": "none",
+ "ui.context_menus.after_mouseup": false,
};
async function background() {
browser.test.onMessage.addListener(async (msg, apiName, value) => {
let apiObj = browser.browserSettings[apiName];
- await apiObj.set({value});
- browser.test.sendMessage("settingData", await apiObj.get({}));
+ let result = await apiObj.set({value});
+ if (msg === "set") {
+ browser.test.assertTrue(result, "set returns true.");
+ browser.test.sendMessage("settingData", await apiObj.get({}));
+ } else {
+ browser.test.assertFalse(result, "set returns false for a no-op.");
+ browser.test.sendMessage("no-op set");
+ }
});
}
@@ -69,33 +76,82 @@ add_task(async function test_browser_settings() {
}
}
+ async function testNoOpSetting(setting, value, expected) {
+ extension.sendMessage("setNoOp", setting, value);
+ await extension.awaitMessage("no-op set");
+ for (let pref in expected) {
+ equal(Preferences.get(pref), expected[pref], `${pref} set correctly for ${value}`);
+ }
+ }
+
await testSetting(
"cacheEnabled", false,
{
"browser.cache.disk.enable": false,
"browser.cache.memory.enable": false,
});
await testSetting(
"cacheEnabled", true,
{
"browser.cache.disk.enable": true,
"browser.cache.memory.enable": true,
});
await testSetting(
"allowPopupsForUserEvents", false,
{"dom.popup_allowed_events": ""});
await testSetting(
"allowPopupsForUserEvents", true,
{"dom.popup_allowed_events": PREFS["dom.popup_allowed_events"]});
for (let value of ["normal", "none", "once"]) {
await testSetting(
"imageAnimationBehavior", value,
{"image.animation_mode": value});
}
- await extension.unload();
+ // This setting is a no-op on Android.
+ if (AppConstants.platform === "android") {
+ await testNoOpSetting("contextMenuShowEvent", "mouseup",
+ {"ui.context_menus.after_mouseup": false});
+ } else {
+ await testSetting(
+ "contextMenuShowEvent", "mouseup",
+ {"ui.context_menus.after_mouseup": true});
+ }
+ // "mousedown" is also a no-op on Windows.
+ if (["android", "win"].includes(AppConstants.platform)) {
+ await testNoOpSetting("contextMenuShowEvent", "mousedown",
+ {"ui.context_menus.after_mouseup": AppConstants.platform === "win"});
+ } else {
+ await testSetting(
+ "contextMenuShowEvent", "mousedown",
+ {"ui.context_menus.after_mouseup": false});
+ }
+
+ await extension.unload();
await promiseShutdownManager();
});
+
+add_task(async function test_bad_value() {
+ async function background() {
+ await browser.test.assertRejects(
+ browser.browserSettings.contextMenuShowEvent.set({value: "bad"}),
+ /bad is not a valid value for contextMenuShowEvent/,
+ "contextMenuShowEvent.set rejects with an invalid value.");
+
+ browser.test.sendMessage("done");
+ }
+
+ let extension = ExtensionTestUtils.loadExtension({
+ background,
+ manifest: {
+ permissions: ["browserSettings"],
+ },
+ });
+
+ await extension.startup();
+ await extension.awaitMessage("done");
+ await extension.unload();
+});
--
2.15.1

View file

@ -11,8 +11,8 @@ buildarch=12
highmem=1
pkgname=firefox
pkgver=58.0.1
pkgrel=2
pkgver=58.0.2
pkgrel=1
pkgdesc="Standalone web browser from mozilla.org"
arch=(x86_64)
license=(MPL GPL LGPL)
@ -28,10 +28,12 @@ optdepends=('networkmanager: Location detection via available WiFi networks'
options=(!emptydirs !makeflags !strip)
source=(https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/$pkgver/source/firefox-$pkgver.source.tar.xz
$pkgname.desktop firefox-symbolic.svg
0001-Bug-1430274-Define-MOZ_ALSA-for-more-source-files.-r.patch
firefox-install-dir.patch no-crmf.diff)
sha256sums=('0e0a39caabf94d7467d8bb4008fa9e7340a7be57b8c78ccf0cf98791a3bfaaff'
sha256sums=('2b7794e4c2a24fa388f3acb2956c96bb2c3eae455467f0e386788ebaea7240c3'
'677e1bde4c6b3cff114345c211805c7c43085038ca0505718a11e96432e9811a'
'9a1a572dc88014882d54ba2d3079a1cf5b28fa03c5976ed2cb763c93dabbd797'
'e8a695bd6a007525390c502739c0f00d5d753a1bde7053c21c712075f2c2994d'
'a94f80abe65608cd49054a30acc31e4d0885fe5b2a38cf08ded5e5b51b87c99d'
'fb85a538044c15471c12cf561d6aa74570f8de7b054a7063ef88ee1bdfc1ccbb')
@ -55,6 +57,9 @@ prepare() {
cd $pkgname-$pkgver
patch -Np1 -i ../firefox-install-dir.patch
# https://bugs.archlinux.org/task/57285
patch -Np1 -i ../0001-Bug-1430274-Define-MOZ_ALSA-for-more-source-files.-r.patch
# https://bugzilla.mozilla.org/show_bug.cgi?id=1371991
patch -Np1 -i ../no-crmf.diff

View file

@ -1,245 +0,0 @@
# HG changeset patch
# Parent 2edd69b245fbc493c3a1cf17c40c63b0280ead12
Bug 1314968 - Disentangle nsWifiScannerDBus::SendMessage. r?kanru
Make a copy of the function and specialize it for each message sent.
Avoids the mess of comparing the method name to figure out what to do.
diff --git a/netwerk/wifi/nsWifiScannerDBus.cpp b/netwerk/wifi/nsWifiScannerDBus.cpp
--- a/netwerk/wifi/nsWifiScannerDBus.cpp
+++ b/netwerk/wifi/nsWifiScannerDBus.cpp
@@ -34,19 +34,47 @@ nsWifiScannerDBus::Scan()
if (!mConnection) {
return NS_ERROR_NOT_AVAILABLE;
}
- return SendMessage("org.freedesktop.NetworkManager",
- "/org/freedesktop/NetworkManager",
- "GetDevices");
+ return SendGetDevices();
}
+// http://dbus.freedesktop.org/doc/api/html/group__DBusConnection.html
+// Refer to function dbus_connection_send_with_reply_and_block.
+static const uint32_t DBUS_DEFAULT_TIMEOUT = -1;
+
nsresult
-nsWifiScannerDBus::SendMessage(const char* aInterface,
- const char* aPath,
- const char* aFuncCall)
-{
- RefPtr<DBusMessage> msg = already_AddRefed<DBusMessage>(
- dbus_message_new_method_call("org.freedesktop.NetworkManager",
- aPath, aInterface, aFuncCall));
+nsWifiScannerDBus::SendGetDevices()
+{
+ RefPtr<DBusMessage> msg = already_AddRefed<DBusMessage>(
+ dbus_message_new_method_call("org.freedesktop.NetworkManager",
+ "/org/freedesktop/NetworkManager",
+ "org.freedesktop.NetworkManager",
+ "GetDevices"));
+ if (!msg) {
+ return NS_ERROR_FAILURE;
+ }
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ RefPtr<DBusMessage> reply = already_AddRefed<DBusMessage>(
+ dbus_connection_send_with_reply_and_block(mConnection, msg,
+ DBUS_DEFAULT_TIMEOUT, &err));
+ if (dbus_error_is_set(&err)) {
+ dbus_error_free(&err);
+ return NS_ERROR_FAILURE;
+ }
+
+ return IdentifyDevices(reply);
+}
+
+nsresult
+nsWifiScannerDBus::SendGetDeviceType(const char* aPath)
+{
+ RefPtr<DBusMessage> msg = already_AddRefed<DBusMessage>(
+ dbus_message_new_method_call("org.freedesktop.NetworkManager",
+ aPath,
+ "org.freedesktop.DBus.Properties",
+ "Get"));
if (!msg) {
return NS_ERROR_FAILURE;
}
@@ -54,58 +82,92 @@ nsWifiScannerDBus::SendMessage(const cha
DBusMessageIter argsIter;
dbus_message_iter_init_append(msg, &argsIter);
- if (!strcmp(aFuncCall, "Get")) {
- const char* paramInterface = "org.freedesktop.NetworkManager.Device";
- if (!dbus_message_iter_append_basic(&argsIter, DBUS_TYPE_STRING,
- &paramInterface)) {
- return NS_ERROR_FAILURE;
- }
-
- const char* paramDeviceType = "DeviceType";
- if (!dbus_message_iter_append_basic(&argsIter, DBUS_TYPE_STRING,
- &paramDeviceType)) {
- return NS_ERROR_FAILURE;
- }
- } else if (!strcmp(aFuncCall, "GetAll")) {
- const char* param = "";
- if (!dbus_message_iter_append_basic(&argsIter, DBUS_TYPE_STRING, &param)) {
- return NS_ERROR_FAILURE;
- }
- }
+ const char* paramInterface = "org.freedesktop.NetworkManager.Device";
+ if (!dbus_message_iter_append_basic(&argsIter, DBUS_TYPE_STRING,
+ &paramInterface)) {
+ return NS_ERROR_FAILURE;
+ }
+
+ const char* paramDeviceType = "DeviceType";
+ if (!dbus_message_iter_append_basic(&argsIter, DBUS_TYPE_STRING,
+ &paramDeviceType)) {
+ return NS_ERROR_FAILURE;
+ }
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ RefPtr<DBusMessage> reply = already_AddRefed<DBusMessage>(
+ dbus_connection_send_with_reply_and_block(mConnection, msg,
+ DBUS_DEFAULT_TIMEOUT, &err));
+ if (dbus_error_is_set(&err)) {
+ dbus_error_free(&err);
+ return NS_ERROR_FAILURE;
+ }
+
+ return IdentifyDeviceType(reply, aPath);
+}
+
+nsresult
+nsWifiScannerDBus::SendGetAccessPoints(const char* aPath)
+{
+ RefPtr<DBusMessage> msg = already_AddRefed<DBusMessage>(
+ dbus_message_new_method_call("org.freedesktop.NetworkManager",
+ aPath,
+ "org.freedesktop.NetworkManager.Device.Wireless",
+ "GetAccessPoints"));
+ if (!msg) {
+ return NS_ERROR_FAILURE;
+ }
DBusError err;
dbus_error_init(&err);
- // http://dbus.freedesktop.org/doc/api/html/group__DBusConnection.html
- // Refer to function dbus_connection_send_with_reply_and_block.
- const uint32_t DBUS_DEFAULT_TIMEOUT = -1;
RefPtr<DBusMessage> reply = already_AddRefed<DBusMessage>(
dbus_connection_send_with_reply_and_block(mConnection, msg,
DBUS_DEFAULT_TIMEOUT, &err));
if (dbus_error_is_set(&err)) {
dbus_error_free(&err);
-
// In the GetAccessPoints case, if there are no access points, error is set.
// We don't want to error out here.
- if (!strcmp(aFuncCall, "GetAccessPoints")) {
- return NS_OK;
- }
- return NS_ERROR_FAILURE;
+ return NS_OK;
}
- nsresult rv;
- if (!strcmp(aFuncCall, "GetDevices")) {
- rv = IdentifyDevices(reply);
- } else if (!strcmp(aFuncCall, "Get")) {
- rv = IdentifyDeviceType(reply, aPath);
- } else if (!strcmp(aFuncCall, "GetAccessPoints")) {
- rv = IdentifyAccessPoints(reply);
- } else if (!strcmp(aFuncCall, "GetAll")) {
- rv = IdentifyAPProperties(reply);
- } else {
- rv = NS_ERROR_FAILURE;
- }
- return rv;
+ return IdentifyAccessPoints(reply);
+}
+
+nsresult
+nsWifiScannerDBus::SendGetAPProperties(const char* aPath)
+{
+ RefPtr<DBusMessage> msg = already_AddRefed<DBusMessage>(
+ dbus_message_new_method_call("org.freedesktop.NetworkManager",
+ aPath,
+ "org.freedesktop.DBus.Properties",
+ "GetAll"));
+ if (!msg) {
+ return NS_ERROR_FAILURE;
+ }
+
+ DBusMessageIter argsIter;
+ dbus_message_iter_init_append(msg, &argsIter);
+
+ const char* param = "";
+ if (!dbus_message_iter_append_basic(&argsIter, DBUS_TYPE_STRING, &param)) {
+ return NS_ERROR_FAILURE;
+ }
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ RefPtr<DBusMessage> reply = already_AddRefed<DBusMessage>(
+ dbus_connection_send_with_reply_and_block(mConnection, msg,
+ DBUS_DEFAULT_TIMEOUT, &err));
+ if (dbus_error_is_set(&err)) {
+ dbus_error_free(&err);
+ return NS_ERROR_FAILURE;
+ }
+
+ return IdentifyAPProperties(reply);
}
nsresult
@@ -126,7 +188,7 @@ nsWifiScannerDBus::IdentifyDevices(DBusM
return NS_ERROR_FAILURE;
}
- rv = SendMessage("org.freedesktop.DBus.Properties", devicePath, "Get");
+ rv = SendGetDeviceType(devicePath);
NS_ENSURE_SUCCESS(rv, rv);
} while (dbus_message_iter_next(&iter));
@@ -159,8 +221,7 @@ nsWifiScannerDBus::IdentifyDeviceType(DB
const uint32_t NM_DEVICE_TYPE_WIFI = 2;
nsresult rv = NS_OK;
if (deviceType == NM_DEVICE_TYPE_WIFI) {
- rv = SendMessage("org.freedesktop.NetworkManager.Device.Wireless",
- aDevicePath, "GetAccessPoints");
+ rv = SendGetAccessPoints(aDevicePath);
}
return rv;
@@ -183,7 +244,7 @@ nsWifiScannerDBus::IdentifyAccessPoints(
return NS_ERROR_FAILURE;
}
- rv = SendMessage("org.freedesktop.DBus.Properties", path, "GetAll");
+ rv = SendGetAPProperties(path);
NS_ENSURE_SUCCESS(rv, rv);
} while (dbus_message_iter_next(&iter));
diff --git a/netwerk/wifi/nsWifiScannerDBus.h b/netwerk/wifi/nsWifiScannerDBus.h
--- a/netwerk/wifi/nsWifiScannerDBus.h
+++ b/netwerk/wifi/nsWifiScannerDBus.h
@@ -25,9 +25,10 @@ public:
nsresult Scan();
private:
- nsresult SendMessage(const char* aInterface,
- const char* aPath,
- const char* aFuncCall);
+ nsresult SendGetDevices();
+ nsresult SendGetDeviceType(const char* aPath);
+ nsresult SendGetAccessPoints(const char* aPath);
+ nsresult SendGetAPProperties(const char* aPath);
nsresult IdentifyDevices(DBusMessage* aMsg);
nsresult IdentifyDeviceType(DBusMessage* aMsg, const char* aDevicePath);
nsresult IdentifyAccessPoints(DBusMessage* aMsg);

View file

@ -1,26 +0,0 @@
# HG changeset patch
# Parent 7a6d836b62779aa61988981c6ca646495574a505
Bug 1314968 - Explicitly specify the AccessPoint interface name. r?kanru
The DBus specification allows passing an empty string as the interface to the
org.freedesktop.DBus.Properties.GetAll call to get all properties, throwing away the namespace
(interface) information.
However, GDBus does not allow this. When NetworkManager moved to using GDBus, Firefox lost the
ability to retrieve access points from NetworkManager.
Since we're only interested in properties from the org.freedesktop.NetworkManager.AccessPoint
interface, name it explicitly. This works with both the old and the new NetworkManager.
diff --git a/netwerk/wifi/nsWifiScannerDBus.cpp b/netwerk/wifi/nsWifiScannerDBus.cpp
--- a/netwerk/wifi/nsWifiScannerDBus.cpp
+++ b/netwerk/wifi/nsWifiScannerDBus.cpp
@@ -151,7 +151,7 @@ nsWifiScannerDBus::SendGetAll(const char
DBusMessageIter argsIter;
dbus_message_iter_init_append(msg, &argsIter);
- const char* param = "";
+ const char* param = "org.freedesktop.NetworkManager.AccessPoint";
if (!dbus_message_iter_append_basic(&argsIter, DBUS_TYPE_STRING, &param)) {
return NS_ERROR_FAILURE;
}