From 43205def4b071f16d57afee00b4add60dd9ab5b3 Mon Sep 17 00:00:00 2001 From: Doug Turner Date: Wed, 15 Jul 2009 14:57:32 -0700 Subject: [PATCH] [Bug 503942] Implement Geolocation Addresses r=jst, sr=jst --- dom/interfaces/geolocation/Makefile.in | 1 + .../geolocation/nsIDOMGeoPosition.idl | 7 ++- .../geolocation/nsIDOMGeoPositionAddress.idl | 52 +++++++++++++++++++ .../geolocation/NetworkGeolocationProvider.js | 47 +++++++++++++++-- 4 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 dom/interfaces/geolocation/nsIDOMGeoPositionAddress.idl diff --git a/dom/interfaces/geolocation/Makefile.in b/dom/interfaces/geolocation/Makefile.in index d3b12803aac..419408d49d2 100644 --- a/dom/interfaces/geolocation/Makefile.in +++ b/dom/interfaces/geolocation/Makefile.in @@ -49,6 +49,7 @@ GRE_MODULE = 1 XPIDLSRCS = \ nsIDOMGeoGeolocation.idl \ nsIDOMGeoPosition.idl \ + nsIDOMGeoPositionAddress.idl \ nsIDOMGeoPositionCoords.idl \ nsIDOMGeoPositionCallback.idl \ nsIDOMGeoPositionError.idl \ diff --git a/dom/interfaces/geolocation/nsIDOMGeoPosition.idl b/dom/interfaces/geolocation/nsIDOMGeoPosition.idl index bb4cf1728da..ef3ec01714d 100644 --- a/dom/interfaces/geolocation/nsIDOMGeoPosition.idl +++ b/dom/interfaces/geolocation/nsIDOMGeoPosition.idl @@ -37,10 +37,13 @@ #include "domstubs.idl" #include "nsIDOMGeoPositionCoords.idl" +#include "nsIDOMGeoPositionAddress.idl" -[scriptable, uuid(76888EB0-5EAB-4BE6-BFE0-489EC4095358)] +[scriptable, uuid(23E5269F-4DD7-41C4-B52A-75918694C2DE)] interface nsIDOMGeoPosition : nsISupports { - readonly attribute nsIDOMGeoPositionCoords coords; readonly attribute DOMTimeStamp timestamp; + readonly attribute nsIDOMGeoPositionCoords coords; + readonly attribute nsIDOMGeoPositionAddress address; + }; diff --git a/dom/interfaces/geolocation/nsIDOMGeoPositionAddress.idl b/dom/interfaces/geolocation/nsIDOMGeoPositionAddress.idl new file mode 100644 index 00000000000..0e0549b4746 --- /dev/null +++ b/dom/interfaces/geolocation/nsIDOMGeoPositionAddress.idl @@ -0,0 +1,52 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Geolocation. + * + * The Initial Developer of the Original Code is Mozilla Corporation + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Doug Turner (Original Author) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + + +#include "domstubs.idl" + +[scriptable, uuid(98808DEB-C8E4-422C-BA97-08BF2031464C)] +interface nsIDOMGeoPositionAddress : nsISupports +{ + readonly attribute string streetNumber; + readonly attribute string street; + readonly attribute string premises; + readonly attribute string city; + readonly attribute string county; + readonly attribute string region; + readonly attribute string country; + readonly attribute string countryCode; + readonly attribute string postalCode; +}; diff --git a/dom/src/geolocation/NetworkGeolocationProvider.js b/dom/src/geolocation/NetworkGeolocationProvider.js index 50230ae9bed..9c037a593e3 100644 --- a/dom/src/geolocation/NetworkGeolocationProvider.js +++ b/dom/src/geolocation/NetworkGeolocationProvider.js @@ -20,6 +20,37 @@ function LOG(aMsg) { } } +function WifiGeoAddressObject(streetNumber, street, premises, city, county, region, country, countryCode, postalCode) { + + this.streetNumber = streetNumber; + this.street = street; + this.premises = premises; + this.city = city; + this.county = county; + this.region = region; + this.country = country; + this.countryCode = countryCode; + this.postalCode = postalCode; +} + +WifiGeoAddressObject.prototype = { + + QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPositionAddress, Ci.nsIClassInfo]), + + getInterfaces: function(countRef) { + var interfaces = [Ci.nsIDOMGeoPositionAddress, Ci.nsIClassInfo, Ci.nsISupports]; + countRef.value = interfaces.length; + return interfaces; + }, + + getHelperForLanguage: function(language) null, + contractID: "", + classDescription: "wifi geo position address object", + classID: null, + implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT, + flags: Ci.nsIClassInfo.DOM_OBJECT, +}; + function WifiGeoCoordsObject(lat, lon, acc) { this.latitude = lat; this.longitude = lon; @@ -53,8 +84,9 @@ WifiGeoCoordsObject.prototype = { speed: 0, }; -function WifiGeoPositionObject(lat, lon, acc) { +function WifiGeoPositionObject(lat, lon, acc, streetNumber, street, premises, city, county, region, county, countryCode, postalCode) { this.coords = new WifiGeoCoordsObject(lat, lon, acc); + this.address = new WifiGeoAddressObject(streetNumber, street, premises, city, county, region, county, countryCode, postalCode); this.timestamp = Date.now(); }; @@ -240,7 +272,16 @@ WifiGeoPositionProvider.prototype = { var newLocation = new WifiGeoPositionObject(response.location.latitude, response.location.longitude, - response.location.accuracy); + response.location.accuracy, + response.location.address.street_number, + response.location.address.street, + response.location.address.premises, + response.location.address.city, + response.location.address.county, + response.location.address.region, + response.location.address.county, + response.location.address.country_code, + response.location.address.postal_code); var update = Cc["@mozilla.org/geolocation/service;1"].getService(Ci.nsIGeolocationUpdate); update.update(newLocation); @@ -250,7 +291,7 @@ WifiGeoPositionProvider.prototype = { var request = { version: "1.1.0", -// request_address: true, + request_address: true, }; if (accessToken != "")