Bug 733652 - Remove geolocation address handling (v2). Little adoption, costly implementation r=jdm

This commit is contained in:
Doug Turner 2012-03-08 22:16:25 -08:00
Родитель ea95d36e68
Коммит 5e105f2069
15 изменённых файлов: 10 добавлений и 493 удалений

Просмотреть файл

@ -1422,9 +1422,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(GeoPositionCoords, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(GeoPositionAddress, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(GeoPositionError, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@ -4020,10 +4017,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionCoords)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(GeoPositionAddress, nsIDOMGeoPositionAddress)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionAddress)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(GeoPositionError, nsIDOMGeoPositionError)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionError)
DOM_CLASSINFO_MAP_END

Просмотреть файл

@ -422,7 +422,6 @@ DOMCI_CLASS(MessageEvent)
DOMCI_CLASS(GeoGeolocation)
DOMCI_CLASS(GeoPosition)
DOMCI_CLASS(GeoPositionCoords)
DOMCI_CLASS(GeoPositionAddress)
DOMCI_CLASS(GeoPositionError)
DOMCI_CLASS(MozBatteryManager)

Просмотреть файл

@ -49,7 +49,6 @@ GRE_MODULE = 1
XPIDLSRCS = \
nsIDOMGeoGeolocation.idl \
nsIDOMGeoPosition.idl \
nsIDOMGeoPositionAddress.idl \
nsIDOMGeoPositionCoords.idl \
nsIDOMGeoPositionCallback.idl \
nsIDOMGeoPositionError.idl \

Просмотреть файл

@ -37,13 +37,10 @@
#include "domstubs.idl"
#include "nsIDOMGeoPositionCoords.idl"
#include "nsIDOMGeoPositionAddress.idl"
[scriptable, uuid(23E5269F-4DD7-41C4-B52A-75918694C2DE)]
[scriptable, uuid(dd9f7e81-0f74-4fb5-b361-37019bf60c3f)]
interface nsIDOMGeoPosition : nsISupports
{
readonly attribute DOMTimeStamp timestamp;
readonly attribute nsIDOMGeoPositionCoords coords;
readonly attribute nsIDOMGeoPositionAddress address;
};

Просмотреть файл

@ -1,51 +0,0 @@
/* ***** 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 Foundation
* 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(93abae10-7024-49eb-8e05-1931343b0ebb)]
interface nsIDOMGeoPositionAddress : nsISupports
{
readonly attribute DOMString streetNumber;
readonly attribute DOMString street;
readonly attribute DOMString premises;
readonly attribute DOMString city;
readonly attribute DOMString county;
readonly attribute DOMString region;
readonly attribute DOMString country;
readonly attribute DOMString postalCode;
};

Просмотреть файл

@ -40,100 +40,6 @@
#include "nsGeoPosition.h"
#include "nsDOMClassInfoID.h"
////////////////////////////////////////////////////
// nsGeoPositionAddress
////////////////////////////////////////////////////
nsGeoPositionAddress::nsGeoPositionAddress(const nsAString &aStreetNumber,
const nsAString &aStreet,
const nsAString &aPremises,
const nsAString &aCity,
const nsAString &aCounty,
const nsAString &aRegion,
const nsAString &aCountry,
const nsAString &aPostalCode)
: mStreetNumber(aStreetNumber)
, mStreet(aStreet)
, mPremises(aPremises)
, mCity(aCity)
, mCounty(aCounty)
, mRegion(aRegion)
, mCountry(aCountry)
, mPostalCode(aPostalCode)
{
}
nsGeoPositionAddress::~nsGeoPositionAddress()
{
}
DOMCI_DATA(GeoPositionAddress, nsGeoPositionAddress)
NS_INTERFACE_MAP_BEGIN(nsGeoPositionAddress)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeoPositionAddress)
NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPositionAddress)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(GeoPositionAddress)
NS_INTERFACE_MAP_END
NS_IMPL_THREADSAFE_ADDREF(nsGeoPositionAddress)
NS_IMPL_THREADSAFE_RELEASE(nsGeoPositionAddress)
NS_IMETHODIMP
nsGeoPositionAddress::GetStreetNumber(nsAString & aStreetNumber)
{
aStreetNumber = mStreetNumber;
return NS_OK;
}
NS_IMETHODIMP
nsGeoPositionAddress::GetStreet(nsAString & aStreet)
{
aStreet = mStreet;
return NS_OK;
}
NS_IMETHODIMP
nsGeoPositionAddress::GetPremises(nsAString & aPremises)
{
aPremises = mPremises;
return NS_OK;
}
NS_IMETHODIMP
nsGeoPositionAddress::GetCity(nsAString & aCity)
{
aCity = mCity;
return NS_OK;
}
NS_IMETHODIMP
nsGeoPositionAddress::GetCounty(nsAString & aCounty)
{
aCounty = mCounty;
return NS_OK;
}
NS_IMETHODIMP
nsGeoPositionAddress::GetRegion(nsAString & aRegion)
{
aRegion = mRegion;
return NS_OK;
}
NS_IMETHODIMP
nsGeoPositionAddress::GetCountry(nsAString & aCountry)
{
aCountry = mCountry;
return NS_OK;
}
NS_IMETHODIMP
nsGeoPositionAddress::GetPostalCode(nsAString & aPostalCode)
{
aPostalCode = mPostalCode;
return NS_OK;
}
////////////////////////////////////////////////////
// nsGeoPositionCoords
////////////////////////////////////////////////////
@ -239,11 +145,9 @@ nsGeoPosition::nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
}
nsGeoPosition::nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
nsIDOMGeoPositionAddress *aAddress,
DOMTimeStamp aTimestamp) :
mTimestamp(aTimestamp),
mCoords(aCoords),
mAddress(aAddress)
mCoords(aCoords)
{
}
@ -275,11 +179,3 @@ nsGeoPosition::GetCoords(nsIDOMGeoPositionCoords * *aCoords)
NS_IF_ADDREF(*aCoords = mCoords);
return NS_OK;
}
NS_IMETHODIMP
nsGeoPosition::GetAddress(nsIDOMGeoPositionAddress** aAddress)
{
NS_IF_ADDREF(*aAddress = mAddress);
return NS_OK;
}

Просмотреть файл

@ -43,42 +43,10 @@
#include "nsAutoPtr.h"
#include "nsIClassInfo.h"
#include "nsDOMClassInfoID.h"
#include "nsIDOMGeoPositionAddress.h"
#include "nsIDOMGeoPositionCoords.h"
#include "nsIDOMGeoPosition.h"
#include "nsString.h"
////////////////////////////////////////////////////
// nsGeoPositionAddress
////////////////////////////////////////////////////
class nsGeoPositionAddress : public nsIDOMGeoPositionAddress
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMGEOPOSITIONADDRESS
nsGeoPositionAddress( const nsAString &aStreetNumber,
const nsAString &aStreet,
const nsAString &aPremises,
const nsAString &aCity,
const nsAString &aCounty,
const nsAString &aRegion,
const nsAString &aCountry,
const nsAString &aPostalCode);
~nsGeoPositionAddress();
private:
const nsString mStreetNumber;
const nsString mStreet;
const nsString mPremises;
const nsString mCity;
const nsString mCounty;
const nsString mRegion;
const nsString mCountry;
const nsString mPostalCode;
};
////////////////////////////////////////////////////
// nsGeoPositionCoords
////////////////////////////////////////////////////
@ -122,18 +90,12 @@ public:
long long aTimestamp);
nsGeoPosition(nsIDOMGeoPositionCoords *aCoords,
nsIDOMGeoPositionAddress *aAddress,
DOMTimeStamp aTimestamp);
void SetAddress(nsIDOMGeoPositionAddress *address) {
mAddress = address;
}
private:
~nsGeoPosition();
long long mTimestamp;
nsRefPtr<nsIDOMGeoPositionCoords> mCoords;
nsRefPtr<nsIDOMGeoPositionAddress> mAddress;
};
#endif /* nsGeoPosition_h */

Просмотреть файл

@ -41,98 +41,11 @@
#include "nsGeoPosition.h"
#include "nsIDOMGeoPosition.h"
typedef nsIDOMGeoPositionAddress *GeoPositionAddress;
typedef nsGeoPositionCoords *GeoPositionCoords;
typedef nsIDOMGeoPosition *GeoPosition;
namespace IPC {
template <>
struct ParamTraits<GeoPositionAddress>
{
typedef GeoPositionAddress paramType;
// Function to serialize a geo position address
static void Write(Message *aMsg, const paramType& aParam)
{
bool isNull = !aParam;
WriteParam(aMsg, isNull);
// If it is null, then we are done
if (isNull) return;
nsString addressLine;
aParam->GetStreetNumber(addressLine);
WriteParam(aMsg, addressLine);
aParam->GetStreet(addressLine);
WriteParam(aMsg, addressLine);
aParam->GetPremises(addressLine);
WriteParam(aMsg, addressLine);
aParam->GetCity(addressLine);
WriteParam(aMsg, addressLine);
aParam->GetCounty(addressLine);
WriteParam(aMsg, addressLine);
aParam->GetRegion(addressLine);
WriteParam(aMsg, addressLine);
aParam->GetCountry(addressLine);
WriteParam(aMsg, addressLine);
aParam->GetPostalCode(addressLine);
WriteParam(aMsg, addressLine);
}
// Function to de-serialize a geoposition
static bool Read(const Message* aMsg, void **aIter, paramType* aResult)
{
// Check if it is the null pointer we have transfered
bool isNull;
if (!ReadParam(aMsg, aIter, &isNull)) return false;
if (isNull) {
*aResult = 0;
return true;
}
// We need somewhere to store the address before we create the object
nsString streetNumber;
nsString street;
nsString premises;
nsString city;
nsString county;
nsString region;
nsString country;
nsString postalCode;
// It's not important to us where it fails, but rather if it fails
if (!(ReadParam(aMsg, aIter, &streetNumber) &&
ReadParam(aMsg, aIter, &street ) &&
ReadParam(aMsg, aIter, &premises ) &&
ReadParam(aMsg, aIter, &city ) &&
ReadParam(aMsg, aIter, &county ) &&
ReadParam(aMsg, aIter, &region ) &&
ReadParam(aMsg, aIter, &country ) &&
ReadParam(aMsg, aIter, &postalCode ))) return false;
// We now have all the data
*aResult = new nsGeoPositionAddress(streetNumber, /* aStreetNumber */
street, /* aStreet */
premises, /* aPremises */
city, /* aCity */
county, /* aCounty */
region, /* aRegion */
country, /* aCountry */
postalCode /* aPostalCode */
);
return true;
}
} ;
template <>
struct ParamTraits<GeoPositionCoords>
{
@ -235,11 +148,6 @@ struct ParamTraits<GeoPosition>
aParam->GetCoords(getter_AddRefs(coords));
GeoPositionCoords simpleCoords = static_cast<GeoPositionCoords>(coords.get());
WriteParam(aMsg, simpleCoords);
nsCOMPtr<nsIDOMGeoPositionAddress> address;
aParam->GetAddress(getter_AddRefs(address));
GeoPositionAddress simpleAddress = address.get();
WriteParam(aMsg, simpleAddress);
}
// Function to de-serialize a geoposition
@ -256,20 +164,17 @@ struct ParamTraits<GeoPosition>
DOMTimeStamp timeStamp;
GeoPositionCoords coords = nsnull;
GeoPositionAddress address;
// It's not important to us where it fails, but rather if it fails
if (!( ReadParam(aMsg, aIter, &timeStamp)
&& ReadParam(aMsg, aIter, &coords )
&& ReadParam(aMsg, aIter, &address ))) {
&& ReadParam(aMsg, aIter, &coords ))) {
// note it is fine to do "delete nsnull" in case coords hasn't
// been allocated and we will never have a case where address
// gets allocated and we end here
// been allocated
delete coords;
return false;
}
*aResult = new nsGeoPosition(coords, address, timeStamp);
*aResult = new nsGeoPosition(coords, timeStamp);
return true;
};

Просмотреть файл

@ -252,10 +252,9 @@ public class GeckoEvent {
}
}
public GeckoEvent(Location l, Address a) {
public GeckoEvent(Location l) {
mType = LOCATION_EVENT;
mLocation = l;
mAddress = a;
}
public GeckoEvent(int imeAction, int offset, int count) {

Просмотреть файл

@ -580,47 +580,10 @@ class GeckoSurfaceView
GeckoAppShell.sendEventToGecko(new GeckoEvent(event));
}
private class GeocoderTask extends AsyncTask<Location, Void, Void> {
protected Void doInBackground(Location... location) {
try {
List<Address> addresses = mGeocoder.getFromLocation(location[0].getLatitude(),
location[0].getLongitude(), 1);
// grab the first address. in the future,
// may want to expose multiple, or filter
// for best.
mLastGeoAddress = addresses.get(0);
GeckoAppShell.sendEventToGecko(new GeckoEvent(location[0], mLastGeoAddress));
} catch (Exception e) {
Log.w(LOG_FILE_NAME, "GeocoderTask "+e);
}
return null;
}
}
// geolocation
public void onLocationChanged(Location location)
{
if (mGeocoder == null)
mGeocoder = new Geocoder(getContext(), Locale.getDefault());
if (mLastGeoAddress == null) {
new GeocoderTask().execute(location);
}
else {
float[] results = new float[1];
Location.distanceBetween(location.getLatitude(),
location.getLongitude(),
mLastGeoAddress.getLatitude(),
mLastGeoAddress.getLongitude(),
results);
// pfm value. don't want to slam the
// geocoder with very similar values, so
// only call after about 100m
if (results[0] > 100)
new GeocoderTask().execute(location);
}
GeckoAppShell.sendEventToGecko(new GeckoEvent(location, mLastGeoAddress));
GeckoAppShell.sendEventToGecko(new GeckoEvent(location));
}
public void onProviderDisabled(String provider)
@ -825,9 +788,6 @@ class GeckoSurfaceView
ByteBuffer mSoftwareBuffer;
Bitmap mSoftwareBufferCopy;
Geocoder mGeocoder;
Address mLastGeoAddress;
final SynchronousQueue<Object> mSyncDraws = new SynchronousQueue<Object>();
}

Просмотреть файл

@ -139,8 +139,6 @@ abstract public class GeckoApp
public static FormAssistPopup mFormAssistPopup;
public Favicons mFavicons;
private Geocoder mGeocoder;
private Address mLastGeoAddress;
private static LayerController mLayerController;
private static PlaceholderLayerClient mPlaceholderLayerClient;
private static GeckoSoftwareLayerClient mSoftwareLayerClient;
@ -2618,51 +2616,12 @@ abstract public class GeckoApp
GeckoAppShell.sendEventToGecko(GeckoEvent.createSensorEvent(event));
}
private class GeocoderRunnable implements Runnable {
Location mLocation;
GeocoderRunnable (Location location) {
mLocation = location;
}
public void run() {
try {
List<Address> addresses = mGeocoder.getFromLocation(mLocation.getLatitude(),
mLocation.getLongitude(), 1);
// grab the first address. in the future,
// may want to expose multiple, or filter
// for best.
mLastGeoAddress = addresses.get(0);
GeckoAppShell.sendEventToGecko(GeckoEvent.createLocationEvent(mLocation, mLastGeoAddress));
} catch (Exception e) {
Log.w(LOGTAG, "GeocoderTask "+e);
}
}
}
// geolocation
public void onLocationChanged(Location location)
{
Log.w(LOGTAG, "onLocationChanged "+location);
if (mGeocoder == null)
mGeocoder = new Geocoder(mLayerController.getView().getContext(), Locale.getDefault());
if (mLastGeoAddress == null) {
GeckoAppShell.getHandler().post(new GeocoderRunnable(location));
}
else {
float[] results = new float[1];
Location.distanceBetween(location.getLatitude(),
location.getLongitude(),
mLastGeoAddress.getLatitude(),
mLastGeoAddress.getLongitude(),
results);
// pfm value. don't want to slam the
// geocoder with very similar values, so
// only call after about 100m
if (results[0] > 100)
GeckoAppShell.getHandler().post(new GeocoderRunnable(location));
}
GeckoAppShell.sendEventToGecko(GeckoEvent.createLocationEvent(location, mLastGeoAddress));
GeckoAppShell.sendEventToGecko(GeckoEvent.createLocationEvent(location));
}
public void onProviderDisabled(String provider)

Просмотреть файл

@ -305,10 +305,9 @@ public class GeckoEvent {
return event;
}
public static GeckoEvent createLocationEvent(Location l, Address a) {
public static GeckoEvent createLocationEvent(Location l) {
GeckoEvent event = new GeckoEvent(LOCATION_EVENT);
event.mLocation = l;
event.mAddress = a;
return event;
}

Просмотреть файл

@ -73,7 +73,6 @@ jfieldID AndroidGeckoEvent::jRangeStylesField = 0;
jfieldID AndroidGeckoEvent::jRangeForeColorField = 0;
jfieldID AndroidGeckoEvent::jRangeBackColorField = 0;
jfieldID AndroidGeckoEvent::jLocationField = 0;
jfieldID AndroidGeckoEvent::jAddressField = 0;
jfieldID AndroidGeckoEvent::jBandwidthField = 0;
jfieldID AndroidGeckoEvent::jCanBeMeteredField = 0;
@ -96,19 +95,6 @@ jmethodID AndroidLocation::jGetBearingMethod = 0;
jmethodID AndroidLocation::jGetSpeedMethod = 0;
jmethodID AndroidLocation::jGetTimeMethod = 0;
jclass AndroidAddress::jAddressClass = 0;
jmethodID AndroidAddress::jGetAddressLineMethod;
jmethodID AndroidAddress::jGetAdminAreaMethod;
jmethodID AndroidAddress::jGetCountryNameMethod;
jmethodID AndroidAddress::jGetFeatureNameMethod;
jmethodID AndroidAddress::jGetLocalityMethod;
jmethodID AndroidAddress::jGetPostalCodeMethod;
jmethodID AndroidAddress::jGetPremisesMethod;
jmethodID AndroidAddress::jGetSubAdminAreaMethod;
jmethodID AndroidAddress::jGetSubLocalityMethod;
jmethodID AndroidAddress::jGetSubThoroughfareMethod;
jmethodID AndroidAddress::jGetThoroughfareMethod;
jclass AndroidGeckoSoftwareLayerClient::jGeckoSoftwareLayerClientClass = 0;
jmethodID AndroidGeckoSoftwareLayerClient::jLockBufferMethod = 0;
jmethodID AndroidGeckoSoftwareLayerClient::jUnlockBufferMethod = 0;
@ -142,7 +128,6 @@ mozilla::InitAndroidJavaWrappers(JNIEnv *jEnv)
AndroidGeckoEvent::InitGeckoEventClass(jEnv);
AndroidPoint::InitPointClass(jEnv);
AndroidLocation::InitLocationClass(jEnv);
AndroidAddress::InitAddressClass(jEnv);
AndroidRect::InitRectClass(jEnv);
AndroidGeckoSoftwareLayerClient::InitGeckoSoftwareLayerClientClass(jEnv);
AndroidGeckoSurfaceView::InitGeckoSurfaceViewClass(jEnv);
@ -186,7 +171,6 @@ AndroidGeckoEvent::InitGeckoEventClass(JNIEnv *jEnv)
jRangeForeColorField = getField("mRangeForeColor", "I");
jRangeBackColorField = getField("mRangeBackColor", "I");
jLocationField = getField("mLocation", "Landroid/location/Location;");
jAddressField = getField("mAddress", "Landroid/location/Address;");
jBandwidthField = getField("mBandwidth", "D");
jCanBeMeteredField = getField("mCanBeMetered", "Z");
}
@ -225,60 +209,6 @@ AndroidLocation::InitLocationClass(JNIEnv *jEnv)
jGetTimeMethod = getMethod("getTime", "()J");
}
void
AndroidAddress::InitAddressClass(JNIEnv *jEnv)
{
initInit();
jAddressClass = getClassGlobalRef("android/location/Address");
jGetAddressLineMethod = getMethod("getAddressLine", "(I)Ljava/lang/String;");
jGetAdminAreaMethod = getMethod("getAdminArea", "()Ljava/lang/String;");
jGetCountryNameMethod = getMethod("getCountryName", "()Ljava/lang/String;");
jGetFeatureNameMethod = getMethod("getFeatureName", "()Ljava/lang/String;");
jGetLocalityMethod = getMethod("getLocality", "()Ljava/lang/String;");
jGetPostalCodeMethod = getMethod("getPostalCode", "()Ljava/lang/String;");
jGetPremisesMethod = getMethod("getPremises", "()Ljava/lang/String;");
jGetSubAdminAreaMethod = getMethod("getSubAdminArea", "()Ljava/lang/String;");
jGetSubLocalityMethod = getMethod("getSubLocality", "()Ljava/lang/String;");
jGetSubThoroughfareMethod = getMethod("getSubThoroughfare", "()Ljava/lang/String;");
jGetThoroughfareMethod = getMethod("getThoroughfare", "()Ljava/lang/String;");
}
nsGeoPositionAddress*
AndroidAddress::CreateGeoPositionAddress(JNIEnv *jenv, jobject jobj)
{
nsJNIString streetNumber(static_cast<jstring>(jenv->CallObjectMethod(jobj, jGetSubThoroughfareMethod)), jenv);
nsJNIString street(static_cast<jstring>(jenv->CallObjectMethod(jobj, jGetThoroughfareMethod)), jenv);
nsJNIString city(static_cast<jstring>(jenv->CallObjectMethod(jobj, jGetLocalityMethod)), jenv);
nsJNIString county(static_cast<jstring>(jenv->CallObjectMethod(jobj, jGetSubAdminAreaMethod)), jenv);
nsJNIString country(static_cast<jstring>(jenv->CallObjectMethod(jobj, jGetCountryNameMethod)), jenv);
nsJNIString premises(static_cast<jstring>(jenv->CallObjectMethod(jobj, jGetPremisesMethod)), jenv);
nsJNIString postalCode(static_cast<jstring>(jenv->CallObjectMethod(jobj, jGetPostalCodeMethod)), jenv);
nsJNIString region(static_cast<jstring>(jenv->CallObjectMethod(jobj, jGetAdminAreaMethod, 0)), jenv);
#ifdef DEBUG
printf_stderr("!!!!!!!!!!!!!! AndroidAddress::CreateGeoPositionAddress:\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n",
NS_LossyConvertUTF16toASCII(streetNumber).get(),
NS_LossyConvertUTF16toASCII(street).get(),
NS_LossyConvertUTF16toASCII(premises).get(),
NS_LossyConvertUTF16toASCII(city).get(),
NS_LossyConvertUTF16toASCII(county).get(),
NS_LossyConvertUTF16toASCII(region).get(),
NS_LossyConvertUTF16toASCII(country).get(),
NS_LossyConvertUTF16toASCII(postalCode).get());
#endif
return new nsGeoPositionAddress(streetNumber,
street,
premises,
city,
county,
region,
country,
postalCode);
}
nsGeoPosition*
AndroidLocation::CreateGeoPosition(JNIEnv *jenv, jobject jobj)
{
@ -511,11 +441,7 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj)
case LOCATION_EVENT: {
jobject location = jenv->GetObjectField(jobj, jLocationField);
jobject address = jenv->GetObjectField(jobj, jAddressField);
mGeoPosition = AndroidLocation::CreateGeoPosition(jenv, location);
if (address)
mGeoAddress = AndroidAddress::CreateGeoPositionAddress(jenv, address);
break;
}

Просмотреть файл

@ -384,25 +384,6 @@ public:
static jmethodID jGetTimeMethod;
};
class AndroidAddress : public WrappedJavaObject
{
public:
static void InitAddressClass(JNIEnv *jEnv);
static nsGeoPositionAddress* CreateGeoPositionAddress(JNIEnv *jenv, jobject jobj);
static jclass jAddressClass;
static jmethodID jGetAddressLineMethod;
static jmethodID jGetAdminAreaMethod;
static jmethodID jGetCountryNameMethod;
static jmethodID jGetFeatureNameMethod;
static jmethodID jGetLocalityMethod;
static jmethodID jGetPostalCodeMethod;
static jmethodID jGetPremisesMethod;
static jmethodID jGetSubAdminAreaMethod;
static jmethodID jGetSubLocalityMethod;
static jmethodID jGetSubThoroughfareMethod;
static jmethodID jGetThoroughfareMethod;
};
class AndroidGeckoEvent : public WrappedJavaObject
{
public:
@ -461,7 +442,6 @@ public:
int RangeForeColor() { return mRangeForeColor; }
int RangeBackColor() { return mRangeBackColor; }
nsGeoPosition* GeoPosition() { return mGeoPosition; }
nsGeoPositionAddress* GeoAddress() { return mGeoAddress; }
double Bandwidth() { return mBandwidth; }
bool CanBeMetered() { return mCanBeMetered; }
@ -486,7 +466,6 @@ protected:
int mPointerIndex;
nsString mCharacters, mCharactersExtra;
nsRefPtr<nsGeoPosition> mGeoPosition;
nsRefPtr<nsGeoPositionAddress> mGeoAddress;
double mBandwidth;
bool mCanBeMetered;
@ -539,7 +518,6 @@ protected:
static jfieldID jRangeForeColorField;
static jfieldID jRangeBackColorField;
static jfieldID jLocationField;
static jfieldID jAddressField;
static jfieldID jBandwidthField;
static jfieldID jCanBeMeteredField;

Просмотреть файл

@ -351,12 +351,8 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
break;
nsGeoPosition* p = curEvent->GeoPosition();
nsGeoPositionAddress* a = curEvent->GeoAddress();
if (p) {
p->SetAddress(a);
if (p)
gLocationCallback->Update(curEvent->GeoPosition());
}
else
NS_WARNING("Received location event without geoposition!");
break;