diff -r 902fc255d4e8 dom/public/nsDOMClassInfoID.h --- a/dom/public/nsDOMClassInfoID.h Tue Feb 17 10:40:50 2009 -0800 +++ b/dom/public/nsDOMClassInfoID.h Tue Feb 17 11:29:55 2009 -0800 @@ -433,6 +433,7 @@ enum nsDOMClassInfoID { // Geolocation eDOMClassInfo_GeoGeolocation_id, eDOMClassInfo_GeoPosition_id, + eDOMClassInfo_GeoPositionCoords_id, eDOMClassInfo_GeoPositionError_id, // @font-face in CSS diff -r 902fc255d4e8 dom/src/base/nsDOMClassInfo.cpp --- a/dom/src/base/nsDOMClassInfo.cpp Tue Feb 17 10:40:50 2009 -0800 +++ b/dom/src/base/nsDOMClassInfo.cpp Tue Feb 17 11:29:55 2009 -0800 @@ -461,6 +461,7 @@ // Geolocation #include "nsID[Oh my gosh!]eoGeolocation.h" #include "nsID[Oh my gosh!]eoPosition.h" +#include "nsID[Oh my gosh!]eoPositionCoords.h" #include "nsID[Oh my gosh!]eoPositionError.h" // Workers @@ -1279,6 +1280,9 @@ static nsDOMClassInfoData sClassInfoData NS_DEFINE_CLASSINFO_DATA(GeoPosition, nsD[Oh my gosh!]enericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) + NS_DEFINE_CLASSINFO_DATA(GeoPositionCoords, nsD[Oh my gosh!]enericSH, + DOM_DEFAULT_SCRIPTABLE_FLAGS) + NS_DEFINE_CLASSINFO_DATA(GeoPositionError, nsD[Oh my gosh!]enericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) @@ -3536,6 +3540,10 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsID[Oh my gosh!]eoPosition) DOM_CLASSINFO_MAP_END + DOM_CLASSINFO_MAP_BEGIN(GeoPositionCoords, nsID[Oh my gosh!]eoPositionCoords) + DOM_CLASSINFO_MAP_ENTRY(nsID[Oh my gosh!]eoPositionCoords) + DOM_CLASSINFO_MAP_END + DOM_CLASSINFO_MAP_BEGIN(GeoPositionError, nsID[Oh my gosh!]eoPositionError) DOM_CLASSINFO_MAP_ENTRY(nsID[Oh my gosh!]eoPositionError) DOM_CLASSINFO_MAP_END diff -r 902fc255d4e8 dom/src/geolocation/MaemoLocationProvider.cpp --- a/dom/src/geolocation/MaemoLocationProvider.cpp Tue Feb 17 10:40:50 2009 -0800 +++ b/dom/src/geolocation/MaemoLocationProvider.cpp Thu Feb 19 17:59:10 2009 -0800 @@ -35,6 +35,7 @@ * ***** END LICENSE BLOCK ***** */ +#include #include "MaemoLocationProvider.h" #include "nsGeolocation.h" @@ -42,91 +43,107 @@ #include "nsDOMClassInfoID.h" -//////////////////////////////////////////////////// -// nsGeoPosition -//////////////////////////////////////////////////// - -/** - * Simple object that holds a single point in space. - */ -class nsGeoPosition : public nsID[Oh my gosh!]eoPosition +class nsGeoPosition : public nsID[Oh my gosh!]eoPosition, + public nsID[Oh my gosh!]eoPositionCoords { public: NS_DECL_ISUPPORTS NS_DECL_NSID[Oh my gosh!]EOPOSITION - - nsGeoPosition(double aLat, double aLong, double aAlt, double aHError, double aVError, double aHeading, double aSpeed, long long aTimestamp) - : mLat(aLat), mLong(aLong), mAlt(aAlt), mHError(aHError), mVError(aVError), mHeading(aHeading), mSpeed(aSpeed), mTimestamp(aTimestamp){}; - + NS_DECL_NSID[Oh my gosh!]EOPOSITIONCOORDS + + nsGeoPosition(double aLat, double aLong, + double aAlt, double aHError, + double aVError, double aHeading, + double aSpeed, long long aTimestamp) + : mTimestamp(aTimestamp), + mLat(aLat), + mLong(aLong), + mAlt(aAlt), + mHError(aHError), + mVError(aVError), + mHeading(aHeading), + mSpeed(aSpeed){}; + private: ~nsGeoPosition(){} + + long long mTimestamp; double mLat, mLong, mAlt, mHError, mVError, mHeading, mSpeed; - long long mTimestamp; }; NS_INTERFACE_MAP_BEGIN(nsGeoPosition) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsID[Oh my gosh!]eoPosition) NS_INTERFACE_MAP_ENTRY(nsID[Oh my gosh!]eoPosition) + NS_INTERFACE_MAP_ENTRY(nsID[Oh my gosh!]eoPositionCoords) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(GeoPosition) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(GeoPositionCoords) NS_INTERFACE_MAP_END NS_IMPL_THREADSAFE_ADDREF(nsGeoPosition) NS_IMPL_THREADSAFE_RELEASE(nsGeoPosition) NS_IMETHODIMP +nsGeoPosition::GetCoords(nsID[Oh my gosh!]eoPositionCoords * *aCoords) +{ + NS_ADDREF(*aCoords = this); + return NS_OK; +} + + +NS_IMETHODIMP +nsGeoPosition::GetTimestamp(DOMTimeStamp* aTimestamp) +{ + *aTimestamp = mTimestamp; + return NS_OK; +} + +NS_IMETHODIMP nsGeoPosition::GetLatitude(double *aLatitude) { - *aLatitude = mLat; - return NS_OK; + *aLatitude = mLat; + return NS_OK; } NS_IMETHODIMP nsGeoPosition::GetLongitude(double *aLongitude) { - *aLongitude = mLong; - return NS_OK; + *aLongitude = mLong; + return NS_OK; } NS_IMETHODIMP nsGeoPosition::GetAltitude(double *aAltitude) { - *aAltitude = mAlt; - return NS_OK; + *aAltitude = mAlt; + return NS_OK; } NS_IMETHODIMP nsGeoPosition::GetAccuracy(double *aAccuracy) { - *aAccuracy = mHError; - return NS_OK; + *aAccuracy = mHError; + return NS_OK; } NS_IMETHODIMP nsGeoPosition::GetAltitudeAccuracy(double *aAltitudeAccuracy) { - *aAltitudeAccuracy = mVError; - return NS_OK; + *aAltitudeAccuracy = mVError; + return NS_OK; } NS_IMETHODIMP nsGeoPosition::GetHeading(double *aHeading) { - *aHeading = mHeading; - return NS_OK; + *aHeading = mHeading; + return NS_OK; } NS_IMETHODIMP nsGeoPosition::GetSpeed(double *aSpeed) { - *aSpeed = mSpeed; - return NS_OK; -} - -NS_IMETHODIMP -nsGeoPosition::GetTimestamp(DOMTimeStamp* aTimestamp) -{ - *aTimestamp = mTimestamp; - return NS_OK; + *aSpeed = mSpeed; + return NS_OK; } @@ -143,30 +160,41 @@ MaemoLocationProvider::~MaemoLocationPro void location_changed (LocationGPSDevice *device, gpointer userdata) { + printf("location changed called!\n"); + MaemoLocationProvider* provider = (MaemoLocationProvider*) userdata; nsRefPtr somewhere = new nsGeoPosition(device->fix->latitude, device->fix->longitude, device->fix->altitude, device->fix->eph, device->fix->epv, - 0,0, + 0, + 0, device->fix->time); provider->Update(somewhere); } NS_IMETHODIMP MaemoLocationProvider::Startup() { + printf("Startup\n"); + if (!mGPSDevice) { + printf("calling gpsbt_start\n"); // if we are already started, don't do anything memset(&mGPSBT, 0, sizeof(gpsbt_t)); int result = gpsbt_start(NULL, 0, 0, 0, NULL, 0, 0, &mGPSBT); - if (result <0) + + if (result <0) { + printf("returned failure %d - %s (%d)!\n", result, strerror(errno), errno); return NS_ERROR_NOT_AVAILABLE; - + } + + printf("returned success!\n"); mGPSDevice = (LocationGPSDevice*) g_object_new (LOCATION_TYPE_GPS_DEVICE, NULL); mLocationCallbackHandle = g_signal_connect (mGPSDevice, "changed", G_CALLBACK (location_changed), this->mCallback); } + printf("All set. waiting for a gps change!\n"); return NS_OK; } @@ -179,13 +207,6 @@ NS_IMETHODIMP MaemoLocationProvider::Wat NS_IMETHODIMP MaemoLocationProvider::Watch(nsIGeolocationUpdate *callback) { mCallback = callback; // weak ref - return NS_OK; -} - -/* readonly attribute nsID[Oh my gosh!]eoPosition currentPosition; */ -NS_IMETHODIMP MaemoLocationProvider::GetCurrentPosition(nsID[Oh my gosh!]eoPosition * *aCurrentPosition) -{ - NS_IF_ADDREF(*aCurrentPosition = mLastPosition); return NS_OK; }