зеркало из https://github.com/mozilla/gecko-dev.git
Bug 651657 - Remove WinCE & Windows Mobile code from dom/* ; r=jst,dolske
This commit is contained in:
Родитель
b3d5a4893d
Коммит
d1593c3361
|
@ -123,11 +123,9 @@ static PRLogModuleInfo* gJSDiagnostics;
|
|||
#endif
|
||||
|
||||
// Thank you Microsoft!
|
||||
#ifndef WINCE
|
||||
#ifdef CompareString
|
||||
#undef CompareString
|
||||
#endif
|
||||
#endif // WINCE
|
||||
|
||||
// The amount of time we wait between a request to GC (due to leaving
|
||||
// a page) and doing the actual GC.
|
||||
|
|
|
@ -67,11 +67,6 @@ LOCAL_INCLUDES = \
|
|||
|
||||
EXPORTS = nsGeoPosition.h
|
||||
|
||||
ifdef WINCE_WINDOWS_MOBILE
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/dom/system/windows \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifdef MOZ_MAEMO_LIBLOCATION
|
||||
LOCAL_INCLUDES += $(MOZ_PLATFORM_MAEMO_CFLAGS) \
|
||||
-I$(topsrcdir)/dom/system/unix \
|
||||
|
|
|
@ -75,10 +75,6 @@
|
|||
|
||||
#include <math.h>
|
||||
|
||||
#ifdef WINCE_WINDOWS_MOBILE
|
||||
#include "WinMobileLocationProvider.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_MAEMO_LIBLOCATION
|
||||
#include "MaemoLocationProvider.h"
|
||||
#endif
|
||||
|
@ -577,12 +573,6 @@ nsresult nsGeolocationService::Init()
|
|||
|
||||
// we should move these providers outside of this file! dft
|
||||
|
||||
#ifdef WINCE_WINDOWS_MOBILE
|
||||
provider = new WinMobileLocationProvider();
|
||||
if (provider)
|
||||
mProviders.AppendObject(provider);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_MAEMO_LIBLOCATION
|
||||
provider = new MaemoLocationProvider();
|
||||
if (provider)
|
||||
|
|
|
@ -55,11 +55,4 @@ CPPSRCS = \
|
|||
nsAccelerometerSystem.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef WINCE_WINDOWS_MOBILE
|
||||
CPPSRCS += WinMobileLocationProvider.cpp
|
||||
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/dom/src/geolocation \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -1,179 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** 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) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Doug Turner <dougt@meer.net> (Original Author)
|
||||
* Nino D'Aversa <ninodaversa@gmail.com>
|
||||
*
|
||||
* 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 "nsGeoPosition.h"
|
||||
#include "WinMobileLocationProvider.h"
|
||||
#include "nsGeolocation.h"
|
||||
#include "nsIClassInfo.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(WinMobileLocationProvider, nsIGeolocationProvider, nsITimerCallback)
|
||||
|
||||
WinMobileLocationProvider::WinMobileLocationProvider() :
|
||||
mGPSDevice(nsnull),
|
||||
mOpenDevice(nsnull),
|
||||
mCloseDevice(nsnull),
|
||||
mGetPosition(nsnull),
|
||||
mGetDeviceState(nsnull),
|
||||
mHasSeenLocation(PR_FALSE),
|
||||
mHasGPS(PR_TRUE) /* think positively */
|
||||
{
|
||||
}
|
||||
|
||||
WinMobileLocationProvider::~WinMobileLocationProvider()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WinMobileLocationProvider::Notify(nsITimer* aTimer)
|
||||
{
|
||||
if (!mGPSDevice || !mGetPosition)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
GPS_POSITION pos;
|
||||
memset(&pos, 0, sizeof(GPS_POSITION));
|
||||
pos.dwVersion = GPS_VERSION_1;
|
||||
pos.dwSize = sizeof(GPS_POSITION);
|
||||
|
||||
//TODO: add ability to control maximum age with the PositionOptions
|
||||
//100ms is maximum age of GPS data
|
||||
mGetPosition(mGPSDevice, &pos, 100, 0);
|
||||
|
||||
if ((!(pos.dwValidFields & GPS_VALID_LATITUDE) &&
|
||||
!(pos.dwValidFields & GPS_VALID_LONGITUDE) ) ||
|
||||
pos.dwFlags == GPS_DATA_FLAGS_HARDWARE_OFF ||
|
||||
pos.FixQuality == GPS_FIX_QUALITY_UNKNOWN)
|
||||
return NS_OK;
|
||||
|
||||
nsRefPtr<nsGeoPosition> somewhere =
|
||||
new nsGeoPosition(pos.dblLatitude,
|
||||
pos.dblLongitude,
|
||||
(double)pos.flAltitudeWRTSeaLevel,
|
||||
(double)pos.flHorizontalDilutionOfPrecision,
|
||||
(double)pos.flVerticalDilutionOfPrecision,
|
||||
(double)pos.flHeading,
|
||||
(double)pos.flSpeed,
|
||||
PR_Now());
|
||||
Update(somewhere);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP WinMobileLocationProvider::Startup()
|
||||
{
|
||||
if (mHasGPS && !mGPSInst) {
|
||||
mGPSInst = LoadLibraryW(L"gpsapi.dll");
|
||||
|
||||
if(!mGPSInst) {
|
||||
mHasGPS = PR_FALSE;
|
||||
NS_ASSERTION(mGPSInst, "failed to load library gpsapi.dll");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mOpenDevice = (OpenDeviceProc) GetProcAddress(mGPSInst,"GPSOpenDevice");
|
||||
mCloseDevice = (CloseDeviceProc) GetProcAddress(mGPSInst,"GPSCloseDevice");
|
||||
mGetPosition = (GetPositionProc) GetProcAddress(mGPSInst,"GPSGetPosition");
|
||||
mGetDeviceState = (GetDeviceStateProc) GetProcAddress(mGPSInst,"GPSGetDeviceState");
|
||||
|
||||
if (!mOpenDevice || !mCloseDevice || !mGetPosition || !mGetDeviceState)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mGPSDevice = mOpenDevice(NULL, NULL, NULL, 0);
|
||||
|
||||
if (!mGPSDevice) {
|
||||
NS_ASSERTION(mGPSDevice, "GPS Device not found");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsresult rv;
|
||||
mUpdateTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
PRInt32 update = 3000; //3 second default timer
|
||||
if (prefs)
|
||||
prefs->GetIntPref("geo.default.update", &update);
|
||||
|
||||
mUpdateTimer->InitWithCallback(this, update, nsITimer::TYPE_REPEATING_SLACK);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP WinMobileLocationProvider::Watch(nsIGeolocationUpdate *callback)
|
||||
{
|
||||
if (mCallback)
|
||||
return NS_OK;
|
||||
|
||||
mCallback = callback;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP WinMobileLocationProvider::Shutdown()
|
||||
{
|
||||
if (mUpdateTimer)
|
||||
mUpdateTimer->Cancel();
|
||||
|
||||
if (mGPSDevice)
|
||||
mCloseDevice(mGPSDevice);
|
||||
|
||||
mGPSDevice = nsnull;
|
||||
|
||||
mHasSeenLocation = PR_FALSE;
|
||||
|
||||
mCallback = nsnull;
|
||||
|
||||
FreeLibrary(mGPSInst);
|
||||
mGPSInst = nsnull;
|
||||
|
||||
mOpenDevice = nsnull;
|
||||
mCloseDevice = nsnull;
|
||||
mGetPosition = nsnull;
|
||||
mGetDeviceState = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void WinMobileLocationProvider::Update(nsIDOMGeoPosition* aPosition)
|
||||
{
|
||||
mHasSeenLocation = PR_TRUE;
|
||||
if (mCallback)
|
||||
mCallback->Update(aPosition);
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** 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) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Doug Turner <dougt@meer.net> (Original Author)
|
||||
* Nino D'Aversa <ninodaversa@gmail.com>
|
||||
*
|
||||
* 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 <windows.h>
|
||||
|
||||
#undef GetMessage //prevent collision with nsDOMGeoPositionError::GetMessage(nsAString & aMessage)
|
||||
|
||||
#include <gpsapi.h>
|
||||
#include "nsIGeolocationProvider.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsITimer.h"
|
||||
|
||||
typedef HANDLE (*OpenDeviceProc)(HANDLE hNewLocationData, HANDLE hDeviceStateChange, const WCHAR *szDeviceName, DWORD dwFlags);
|
||||
typedef DWORD (*CloseDeviceProc)(HANDLE hGPSDevice);
|
||||
typedef DWORD (*GetPositionProc)(HANDLE hGPSDevice, GPS_POSITION *pGPSPosition, DWORD dwMaximumAge, DWORD dwFlags);
|
||||
typedef DWORD (*GetDeviceStateProc)(GPS_DEVICE *pGPSDevice);
|
||||
|
||||
class WinMobileLocationProvider : public nsIGeolocationProvider,
|
||||
public nsITimerCallback
|
||||
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIGEOLOCATIONPROVIDER
|
||||
NS_DECL_NSITIMERCALLBACK
|
||||
|
||||
WinMobileLocationProvider();
|
||||
|
||||
void Update(nsIDOMGeoPosition* aPosition);
|
||||
|
||||
private:
|
||||
~WinMobileLocationProvider();
|
||||
|
||||
nsCOMPtr<nsIGeolocationUpdate> mCallback;
|
||||
PRPackedBool mHasSeenLocation;
|
||||
PRPackedBool mHasGPS;
|
||||
|
||||
nsCOMPtr<nsITimer> mUpdateTimer;
|
||||
|
||||
HINSTANCE mGPSInst;
|
||||
HANDLE mGPSDevice;
|
||||
OpenDeviceProc mOpenDevice;
|
||||
CloseDeviceProc mCloseDevice;
|
||||
GetPositionProc mGetPosition;
|
||||
GetDeviceStateProc mGetDeviceState;
|
||||
};
|
Загрузка…
Ссылка в новой задаче