[Bug 503942] Implement Geolocation Addresses r=jst, sr=jst
☠☠ backed out by 191ef763e892 ☠ ☠
authorDoug Turner <dougt@meer.net>
Wed, 15 Jul 2009 14:57:32 -0700
changeset 30343 ebea850caba803942ef77addabd73a0dd9ce9087
parent 30342 d190d9b6ccd1d3d31a83d5bef4dc7667eff43227
child 30344 88f2dae8a5ff0594ef1072187fee1968a208f3d6
child 30345 191ef763e892a81b56685717adad3788fad266fd
push id8042
push userdougt@mozilla.com
push dateWed, 15 Jul 2009 21:57:42 +0000
treeherdermozilla-central@ebea850caba8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst, jst
bugs503942
milestone1.9.2a1pre
[Bug 503942] Implement Geolocation Addresses r=jst, sr=jst
dom/interfaces/geolocation/Makefile.in
dom/interfaces/geolocation/nsIDOMGeoPosition.idl
dom/interfaces/geolocation/nsIDOMGeoPositionAddress.idl
dom/src/geolocation/NetworkGeolocationProvider.js
--- a/dom/interfaces/geolocation/Makefile.in
+++ b/dom/interfaces/geolocation/Makefile.in
@@ -44,16 +44,17 @@ include $(DEPTH)/config/autoconf.mk
 
 MODULE         = dom
 XPIDL_MODULE   = dom_geolocation
 GRE_MODULE     = 1
 
 XPIDLSRCS =                                    \
             nsIDOMGeoGeolocation.idl           \
             nsIDOMGeoPosition.idl              \
+            nsIDOMGeoPositionAddress.idl       \
             nsIDOMGeoPositionCoords.idl        \
             nsIDOMGeoPositionCallback.idl      \
             nsIDOMGeoPositionError.idl         \
             nsIDOMGeoPositionErrorCallback.idl \
             nsIDOMGeoPositionOptions.idl       \
             nsIDOMNavigatorGeolocation.idl     \
             nsIGeolocationProvider.idl         \
             $(NULL)
--- a/dom/interfaces/geolocation/nsIDOMGeoPosition.idl
+++ b/dom/interfaces/geolocation/nsIDOMGeoPosition.idl
@@ -32,15 +32,18 @@
  * 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"
 #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 DOMTimeStamp timestamp;
   readonly attribute nsIDOMGeoPositionCoords coords;
-  readonly attribute DOMTimeStamp timestamp;
+  readonly attribute nsIDOMGeoPositionAddress address;
+
 };
new file mode 100644
--- /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 <dougt@meer.net>  (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;
+};
--- a/dom/src/geolocation/NetworkGeolocationProvider.js
+++ b/dom/src/geolocation/NetworkGeolocationProvider.js
@@ -15,16 +15,47 @@ function LOG(aMsg) {
     if (gLoggingEnabled)
     {
         aMsg = ("*** WIFI GEO: " + aMsg);
         Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService).logStringMessage(aMsg);
         dump(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;
     this.accuracy = acc;
 };
 
 WifiGeoCoordsObject.prototype = {
 
@@ -48,18 +79,19 @@ WifiGeoCoordsObject.prototype = {
     accuracy: 0,
 
     altitude: 0,
     altitudeAccuracy: 0,
     heading: 0,
     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();
 };
 
 WifiGeoPositionObject.prototype = {
 
     QueryInterface:   XPCOMUtils.generateQI([Ci.nsIDOMGeoPosition, Ci.nsIClassInfo]),
 
     // Class Info is required to be able to pass objects back into the DOM.
@@ -235,27 +267,36 @@ WifiGeoPositionProvider.prototype = {
                     
                     prefService.setIntPref(accessTokenPrefName + ".time", nowInSeconds());
                     prefService.setCharPref(accessTokenPrefName, newAccessToken);
                 }
             }
 
             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);
         };
 
         var accessToken = this.getAccessTokenForURL(this.provider_url);
 
         var request = {
             version: "1.1.0",
-//          request_address: true,
+            request_address: true,
         };
 
         if (accessToken != "")
             request.access_token = accessToken;
 
         if (accessPoints != null) {
             request.wifi_towers = accessPoints.map(function (ap) ({
                         mac_address: ap.mac,