CB-6521: Remove development branch
diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 7a4a3ea..0000000 --- a/LICENSE +++ /dev/null
@@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file
diff --git a/NOTICE b/NOTICE deleted file mode 100644 index 8ec56a5..0000000 --- a/NOTICE +++ /dev/null
@@ -1,5 +0,0 @@ -Apache Cordova -Copyright 2012 The Apache Software Foundation - -This product includes software developed at -The Apache Software Foundation (http://www.apache.org/).
diff --git a/README.md b/README.md index 5bfc420..0424085 100644 --- a/README.md +++ b/README.md
@@ -20,3 +20,5 @@ # org.apache.cordova.geolocation Plugin documentation: [doc/index.md](doc/index.md) + +This is `dev` - the deprecated development branch of this plugin; development of this plugin has moved to the `master` branch
diff --git a/RELEASENOTES.md b/RELEASENOTES.md deleted file mode 100644 index 56add6f..0000000 --- a/RELEASENOTES.md +++ /dev/null
@@ -1,61 +0,0 @@ -<!-- -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ---> -# Release Notes - -### 0.3.0 (Sept 5, 2013) -* Added support for windows 8 (Adds required permission) - -### 0.3.2 (Sept 25, 2013) -* CB-4889 bumping&resetting version -* [BlackBerry10] removed uneeded permission tags in plugin.xml -* CB-4889 renaming org.apache.cordova.core.geolocation to org.apache.cordova.geolocation - -### 0.3.3 (Oct 28, 2013) -* CB-5128: add repo + issue tag to plugin.xml for geolocation plugin -* [CB-4915] Incremented plugin version on dev branch. - -### 0.3.4 (Dec 4, 2013) -* Append proxy to platform definition in plugin.xml -* Append windows 8 Geolocation proxy -* Code clean-up for android src. -* Updated amazon-fireos platform + reverting some of the fixes in android code. -* Added amazon-fireos platform + some of the fixes in android code. -* CB-5334 [BlackBerry10] Use command proxy -* call FxOS's getCurrentProxy added -* pass by only coords -* proper implementation for firefoxos - -### 0.3.5 (Jan 02, 2014) -* CB-5658 Add doc/index.md for Geolocation plugin -* windows8: adds missing reference to PositionError (w/o it the app crashes) -* Removing incorrectly added closing comments for wp7 platform in plugin.xml - -### 0.3.6 (Feb 05, 2014) -* add ubuntu platform support -* CB-5326 adding FFOS permission and updating supported platforms -* CB-5729 [BlackBerry10] Update GeolocationProxy to return collapsed object - -### 0.3.7 (Apr 17, 2014) -* CB-6422: [windows8] use cordova/exec/proxy -* CB-6212: [iOS] fix warnings compiled under arm64 64-bit -* CB-5977: [android] Removing the Android Geolocation Code. Mission Accomplished. -* CB-6460: Update license headers -* Add NOTICE file
diff --git a/doc/index.md b/doc/index.md deleted file mode 100644 index 038af3d..0000000 --- a/doc/index.md +++ /dev/null
@@ -1,279 +0,0 @@ -<!--- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> - -# org.apache.cordova.geolocation - -This plugin provides information about the device's location, such as -latitude and longitude. Common sources of location information include -Global Positioning System (GPS) and location inferred from network -signals such as IP address, RFID, WiFi and Bluetooth MAC addresses, -and GSM/CDMA cell IDs. There is no guarantee that the API returns the -device's actual location. - -This API is based on the -[W3C Geolocation API Specification](http://dev.w3.org/geo/api/spec-source.html), -and only executes on devices that don't already provide an implementation. - -__WARNING__: Collection and use of geolocation data -raises important privacy issues. Your app's privacy policy should -discuss how the app uses geolocation data, whether it is shared with -any other parties, and the level of precision of the data (for -example, coarse, fine, ZIP code level, etc.). Geolocation data is -generally considered sensitive because it can reveal user's -whereabouts and, if stored, the history of their travels. -Therefore, in addition to the app's privacy policy, you should -strongly consider providing a just-in-time notice before the app -accesses geolocation data (if the device operating system doesn't do -so already). That notice should provide the same information noted -above, as well as obtaining the user's permission (e.g., by presenting -choices for __OK__ and __No Thanks__). For more information, please -see the Privacy Guide. - -## Installation - - cordova plugin add org.apache.cordova.geolocation - -### Firefox OS Quirks - -Create __www/manifest.webapp__ as described in -[Manifest Docs](https://developer.mozilla.org/en-US/Apps/Developing/Manifest). -Add permisions: - - "permissions": { - "geolocation": { "description": "Used to position the map to your current position" } - } - -## Supported Platforms - -- Amazon Fire OS -- Android -- BlackBerry 10 -- Firefox OS -- iOS -- Tizen -- Windows Phone 7 and 8 -- Windows 8 - -## Methods - -- navigator.geolocation.getCurrentPosition -- navigator.geolocation.watchPosition -- navigator.geolocation.clearWatch - -## Objects (Read-Only) - -- Position -- PositionError -- Coordinates - -## navigator.geolocation.getCurrentPosition - -Returns the device's current position to the `geolocationSuccess` -callback with a `Position` object as the parameter. If there is an -error, the `geolocationError` callback is passed a -`PositionError` object. - - navigator.geolocation.getCurrentPosition(geolocationSuccess, - [geolocationError], - [geolocationOptions]); - -### Parameters - -- __geolocationSuccess__: The callback that is passed the current position. - -- __geolocationError__: _(Optional)_ The callback that executes if an error occurs. - -- __geolocationOptions__: _(Optional)_ The geolocation options. - - -### Example - - // onSuccess Callback - // This method accepts a Position object, which contains the - // current GPS coordinates - // - var onSuccess = function(position) { - alert('Latitude: ' + position.coords.latitude + '\n' + - 'Longitude: ' + position.coords.longitude + '\n' + - 'Altitude: ' + position.coords.altitude + '\n' + - 'Accuracy: ' + position.coords.accuracy + '\n' + - 'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' + - 'Heading: ' + position.coords.heading + '\n' + - 'Speed: ' + position.coords.speed + '\n' + - 'Timestamp: ' + position.timestamp + '\n'); - }; - - // onError Callback receives a PositionError object - // - function onError(error) { - alert('code: ' + error.code + '\n' + - 'message: ' + error.message + '\n'); - } - - navigator.geolocation.getCurrentPosition(onSuccess, onError); - -## navigator.geolocation.watchPosition - -Returns the device's current position when a change in position is detected. -When the device retrieves a new location, the `geolocationSuccess` -callback executes with a `Position` object as the parameter. If -there is an error, the `geolocationError` callback executes with a -`PositionError` object as the parameter. - - var watchId = navigator.geolocation.watchPosition(geolocationSuccess, - [geolocationError], - [geolocationOptions]); - -### Parameters - -- __geolocationSuccess__: The callback that is passed the current position. - -- __geolocationError__: (Optional) The callback that executes if an error occurs. - -- __geolocationOptions__: (Optional) The geolocation options. - -### Returns - -- __String__: returns a watch id that references the watch position interval. The watch id should be used with `navigator.geolocation.clearWatch` to stop watching for changes in position. - -### Example - - // onSuccess Callback - // This method accepts a `Position` object, which contains - // the current GPS coordinates - // - function onSuccess(position) { - var element = document.getElementById('geolocation'); - element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' + - 'Longitude: ' + position.coords.longitude + '<br />' + - '<hr />' + element.innerHTML; - } - - // onError Callback receives a PositionError object - // - function onError(error) { - alert('code: ' + error.code + '\n' + - 'message: ' + error.message + '\n'); - } - - // Options: throw an error if no update is received every 30 seconds. - // - var watchID = navigator.geolocation.watchPosition(onSuccess, onError, { timeout: 30000 }); - - -## geolocationOptions - -Optional parameters to customize the retrieval of the geolocation -`Position`. - - { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true }; - -### Options - -- __enableHighAccuracy__: Provides a hint that the application needs the best possible results. By default, the device attempts to retrieve a `Position` using network-based methods. Setting this property to `true` tells the framework to use more accurate methods, such as satellite positioning. _(Boolean)_ - -- __timeout__: The maximum length of time (milliseconds) that is allowed to pass from the call to `navigator.geolocation.getCurrentPosition` or `geolocation.watchPosition` until the corresponding `geolocationSuccess` callback executes. If the `geolocationSuccess` callback is not invoked within this time, the `geolocationError` callback is passed a `PositionError.TIMEOUT` error code. (Note that when used in conjunction with `geolocation.watchPosition`, the `geolocationError` callback could be called on an interval every `timeout` milliseconds!) _(Number)_ - -- __maximumAge__: Accept a cached position whose age is no greater than the specified time in milliseconds. _(Number)_ - -### Android Quirks - -Android 2.x emulators do not return a geolocation result unless the `enableHighAccuracy` option is set to `true`. - -## navigator.geolocation.clearWatch - -Stop watching for changes to the device's location referenced by the -`watchID` parameter. - - navigator.geolocation.clearWatch(watchID); - -### Parameters - -- __watchID__: The id of the `watchPosition` interval to clear. (String) - -### Example - - // Options: watch for changes in position, and use the most - // accurate position acquisition method available. - // - var watchID = navigator.geolocation.watchPosition(onSuccess, onError, { enableHighAccuracy: true }); - - // ...later on... - - navigator.geolocation.clearWatch(watchID); - -## Position - -Contains `Position` coordinates and timestamp, created by the geolocation API. - -### Properties - -- __coords__: A set of geographic coordinates. _(Coordinates)_ - -- __timestamp__: Creation timestamp for `coords`. _(Date)_ - -## Coordinates - -A `Coordinates` object is attached to a `Position` object that is -available to callback functions in requests for the current position. -It contains a set of properties that describe the geographic coordinates of a position. - -### Properties - -* __latitude__: Latitude in decimal degrees. _(Number)_ - -* __longitude__: Longitude in decimal degrees. _(Number)_ - -* __altitude__: Height of the position in meters above the ellipsoid. _(Number)_ - -* __accuracy__: Accuracy level of the latitude and longitude coordinates in meters. _(Number)_ - -* __altitudeAccuracy__: Accuracy level of the altitude coordinate in meters. _(Number)_ - -* __heading__: Direction of travel, specified in degrees counting clockwise relative to the true north. _(Number)_ - -* __speed__: Current ground speed of the device, specified in meters per second. _(Number)_ - -### Amazon Fire OS Quirks - -__altitudeAccuracy__: Not supported by Android devices, returning `null`. - -### Android Quirks - -__altitudeAccuracy__: Not supported by Android devices, returning `null`. - -## PositionError - -The `PositionError` object is passed to the `geolocationError` -callback function when an error occurs with navigator.geolocation. - -### Properties - -- __code__: One of the predefined error codes listed below. - -- __message__: Error message describing the details of the error encountered. - -### Constants - -- `PositionError.PERMISSION_DENIED` - - Returned when users do not allow the app to retrieve position information. This is dependent on the platform. -- `PositionError.POSITION_UNAVAILABLE` - - Returned when the device is unable to retrieve a position. In general, this means the device is not connected to a network or can't get a satellite fix. -- `PositionError.TIMEOUT` - - Returned when the device is unable to retrieve a position within the time specified by the `timeout` included in `geolocationOptions`. When used with `navigator.geolocation.watchPosition`, this error could be repeatedly passed to the `geolocationError` callback every `timeout` milliseconds.
diff --git a/plugin.xml b/plugin.xml deleted file mode 100644 index f395fa4..0000000 --- a/plugin.xml +++ /dev/null
@@ -1,230 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> - -<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" -xmlns:rim="http://www.blackberry.com/ns/widgets" -xmlns:android="http://schemas.android.com/apk/res/android" - id="org.apache.cordova.geolocation" - version="0.3.8-dev"> - - <name>Geolocation</name> - <description>Cordova Geolocation Plugin</description> - <license>Apache 2.0</license> - <keywords>cordova,geolocation</keywords> - <repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git</repo> - <issue>https://issues.apache.org/jira/browse/CB/component/12320638</issue> - - <!-- android --> - <platform name="android"> - - <config-file target="AndroidManifest.xml" parent="/*"> - <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> - <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> - </config-file> - - </platform> - - <!-- amazon-fireos --> - <platform name="amazon-fireos"> - - <js-module src="www/Coordinates.js" name="Coordinates"> - <clobbers target="Coordinates" /> - </js-module> - - <js-module src="www/PositionError.js" name="PositionError"> - <clobbers target="PositionError" /> - </js-module> - - <js-module src="www/Position.js" name="Position"> - <clobbers target="Position" /> - </js-module> - - <js-module src="www/geolocation.js" name="geolocation"> - <clobbers target="navigator.geolocation" /> - </js-module> - - <config-file target="res/xml/config.xml" parent="/*"> - <feature name="Geolocation"> - <param name="android-package" value="org.apache.cordova.geolocation.GeoBroker"/> - </feature> - </config-file> - - <config-file target="AndroidManifest.xml" parent="/*"> - <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> - <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> - </config-file> - - <source-file src="src/amazon/GeoBroker.java" target-dir="src/org/apache/cordova/geolocation" /> - <source-file src="src/amazon/GPSListener.java" target-dir="src/org/apache/cordova/geolocation" /> - <source-file src="src/amazon/NetworkListener.java" target-dir="src/org/apache/cordova/geolocation" /> - <source-file src="src/amazon/CordovaLocationListener.java" target-dir="src/org/apache/cordova/geolocation" /> - - </platform> - - <!-- ios --> - <platform name="ios"> - - <js-module src="www/Coordinates.js" name="Coordinates"> - <clobbers target="Coordinates" /> - </js-module> - - <js-module src="www/PositionError.js" name="PositionError"> - <clobbers target="PositionError" /> - </js-module> - - <js-module src="www/Position.js" name="Position"> - <clobbers target="Position" /> - </js-module> - - <js-module src="www/geolocation.js" name="geolocation"> - <clobbers target="navigator.geolocation" /> - </js-module> - - <config-file target="config.xml" parent="/*"> - <feature name="Geolocation"> - <param name="ios-package" value="CDVLocation"/> - </feature> - </config-file> - <header-file src="src/ios/CDVLocation.h" /> - <source-file src="src/ios/CDVLocation.m" /> - </platform> - - <!-- blackberry10 --> - <platform name="blackberry10"> - - <js-module src="www/blackberry10/GeolocationProxy.js" name="GeolocationProxy"> - <runs /> - </js-module> - - <js-module src="www/Coordinates.js" name="Coordinates"> - <clobbers target="Coordinates" /> - </js-module> - - <js-module src="www/PositionError.js" name="PositionError"> - <clobbers target="PositionError" /> - </js-module> - - <js-module src="www/Position.js" name="Position"> - <clobbers target="Position" /> - </js-module> - - <js-module src="www/geolocation.js" name="geolocation"> - <clobbers target="navigator.geolocation" /> - </js-module> - - <config-file target="www/config.xml" parent="/widget"> - <feature name="Geolocation" value="Geolocation"/> - </config-file> - - <config-file target="www/config.xml" parent="/widget/rim:permissions"> - <rim:permit>read_geolocation</rim:permit> - </config-file> - - </platform> - - <!-- ubuntu --> - <platform name="ubuntu"> - <js-module src="www/Coordinates.js" name="Coordinates"> - <clobbers target="Coordinates" /> - </js-module> - - <js-module src="www/PositionError.js" name="PositionError"> - <clobbers target="PositionError" /> - </js-module> - - <js-module src="www/Position.js" name="Position"> - <clobbers target="Position" /> - </js-module> - - <js-module src="www/geolocation.js" name="geolocation"> - <clobbers target="navigator.geolocation" /> - </js-module> - - <source-file src="src/ubuntu/geolocation.cpp" /> - <header-file src="src/ubuntu/geolocation.h" /> - <config-file target="config.xml" parent="/*"> - <feature name="Geolocation"> - <param policy_group="location" policy_version="1" /> - </feature> - </config-file> - </platform> - - <!-- wp7 --> - <platform name="wp7"> - - <config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities"> - <Capability Name="ID_CAP_LOCATION" /> - </config-file> - - <source-file src="src/wp/Geolocation.cs" /> - </platform> - - <!-- wp8 --> - <platform name="wp8"> - - <config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities"> - <Capability Name="ID_CAP_LOCATION" /> - </config-file> - - <source-file src="src/wp/Geolocation.cs" /> - </platform> - - <!-- windows8 --> - <platform name="windows8"> - <config-file target="package.appxmanifest" parent="/Package/Capabilities"> - <DeviceCapability Name="location" /> - </config-file> - <js-module src="www/PositionError.js" name="PositionError"> - <clobbers target="PositionError" /> - </js-module> - <js-module src="src/windows8/GeolocationProxy.js" name="GeolocationProxy"> - <merges target="" /> - </js-module> - </platform> - - <!-- firefoxos --> - <platform name="firefoxos"> - <config-file target="config.xml" parent="/*"> - <feature name="Geolocation"> - <param name="firefoxos-package" value="Geolocation" /> - </feature> - </config-file> - - <js-module src="src/firefoxos/GeolocationProxy.js" name="GeolocationProxy"> - <runs /> - </js-module> - - <js-module src="www/Coordinates.js" name="Coordinates"> - <clobbers target="Coordinates" /> - </js-module> - - <js-module src="www/PositionError.js" name="PositionError"> - <clobbers target="PositionError" /> - </js-module> - - <js-module src="www/Position.js" name="Position"> - <clobbers target="Position" /> - </js-module> - - <js-module src="www/geolocation.js" name="geolocation"> - <clobbers target="navigator.geolocation" /> - </js-module> - </platform> -</plugin>
diff --git a/src/amazon/CordovaLocationListener.java b/src/amazon/CordovaLocationListener.java deleted file mode 100755 index 8a29d2f..0000000 --- a/src/amazon/CordovaLocationListener.java +++ /dev/null
@@ -1,252 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -*/ -package org.apache.cordova.geolocation; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Timer; -import java.util.TimerTask; - -import org.apache.cordova.CallbackContext; - -import android.location.Location; -import android.location.LocationListener; -import android.location.LocationManager; -import android.os.Bundle; -import android.os.Looper; -import android.util.Log; - -public class CordovaLocationListener implements LocationListener { - public static int PERMISSION_DENIED = 1; - public static int POSITION_UNAVAILABLE = 2; - public static int TIMEOUT = 3; - - protected LocationManager locationManager; - private GeoBroker owner; - protected boolean running = false; - - public HashMap<String, CallbackContext> watches = new HashMap<String, CallbackContext>(); - private List<CallbackContext> callbacks = new ArrayList<CallbackContext>(); - - private Timer timer = null; - - private String TAG = "[Cordova Location Listener]"; - - public CordovaLocationListener(LocationManager manager, GeoBroker broker, String tag) { - this.locationManager = manager; - this.owner = broker; - this.TAG = tag; - } - - protected void fail(int code, String message) { - this.cancelTimer(); - for (CallbackContext callbackContext: this.callbacks) - { - this.owner.fail(code, message, callbackContext, false); - } - if(this.owner.isGlobalListener(this) && this.watches.size() == 0) - { - Log.d(TAG, "Stopping global listener"); - this.stop(); - } - this.callbacks.clear(); - - Iterator<CallbackContext> it = this.watches.values().iterator(); - while (it.hasNext()) { - this.owner.fail(code, message, it.next(), true); - } - } - - private void win(Location loc) { - this.cancelTimer(); - for (CallbackContext callbackContext: this.callbacks) - { - this.owner.win(loc, callbackContext, false); - } - if(this.owner.isGlobalListener(this) && this.watches.size() == 0) - { - Log.d(TAG, "Stopping global listener"); - this.stop(); - } - this.callbacks.clear(); - - Iterator<CallbackContext> it = this.watches.values().iterator(); - while (it.hasNext()) { - this.owner.win(loc, it.next(), true); - } - } - - /** - * Location Listener Methods - */ - - /** - * Called when the provider is disabled by the user. - * - * @param provider - */ - public void onProviderDisabled(String provider) { - Log.d(TAG, "Location provider '" + provider + "' disabled."); - this.fail(POSITION_UNAVAILABLE, "GPS provider disabled."); - } - - /** - * Called when the provider is enabled by the user. - * - * @param provider - */ - public void onProviderEnabled(String provider) { - Log.d(TAG, "Location provider "+ provider + " has been enabled"); - } - - /** - * Called when the provider status changes. This method is called when a - * provider is unable to fetch a location or if the provider has recently - * become available after a period of unavailability. - * - * @param provider - * @param status - * @param extras - */ - public void onStatusChanged(String provider, int status, Bundle extras) { - Log.d(TAG, "The status of the provider " + provider + " has changed"); - if (status == 0) { - Log.d(TAG, provider + " is OUT OF SERVICE"); - this.fail(CordovaLocationListener.POSITION_UNAVAILABLE, "Provider " + provider + " is out of service."); - } - else if (status == 1) { - Log.d(TAG, provider + " is TEMPORARILY_UNAVAILABLE"); - } - else { - Log.d(TAG, provider + " is AVAILABLE"); - } - } - - /** - * Called when the location has changed. - * - * @param location - */ - public void onLocationChanged(Location location) { - Log.d(TAG, "The location has been updated!"); - this.win(location); - } - - // PUBLIC - - public int size() { - return this.watches.size() + this.callbacks.size(); - } - - public void addWatch(String timerId, CallbackContext callbackContext) { - this.watches.put(timerId, callbackContext); - if (this.size() == 1) { - this.start(); - } - } - public void addCallback(CallbackContext callbackContext, int timeout) { - if(this.timer == null) { - this.timer = new Timer(); - } - this.timer.schedule(new LocationTimeoutTask(callbackContext, this), timeout); - this.callbacks.add(callbackContext); - if (this.size() == 1) { - this.start(); - } - } - public void clearWatch(String timerId) { - if (this.watches.containsKey(timerId)) { - this.watches.remove(timerId); - } - if (this.size() == 0) { - this.stop(); - } - } - - /** - * Destroy listener. - */ - public void destroy() { - this.stop(); - } - - // LOCAL - - /** - * Start requesting location updates. - * - * @param interval - */ - protected void start() { - if (!this.running) { - if (this.locationManager.getProvider(LocationManager.NETWORK_PROVIDER) != null) { - this.running = true; - this.locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000, 10, this, Looper.getMainLooper()); - } else { - this.fail(CordovaLocationListener.POSITION_UNAVAILABLE, "Network provider is not available."); - } - } - } - - /** - * Stop receiving location updates. - */ - private void stop() { - this.cancelTimer(); - if (this.running) { - this.locationManager.removeUpdates(this); - this.running = false; - } - } - - private void cancelTimer() { - if(this.timer != null) { - this.timer.cancel(); - this.timer.purge(); - this.timer = null; - } - } - - private class LocationTimeoutTask extends TimerTask { - - private CallbackContext callbackContext = null; - private CordovaLocationListener listener = null; - - public LocationTimeoutTask(CallbackContext callbackContext, CordovaLocationListener listener) { - this.callbackContext = callbackContext; - this.listener = listener; - } - - @Override - public void run() { - for (CallbackContext callbackContext: listener.callbacks) { - if(this.callbackContext == callbackContext) { - listener.callbacks.remove(callbackContext); - break; - } - } - - if(listener.size() == 0) { - listener.stop(); - } - } - } -}
diff --git a/src/amazon/GPSListener.java b/src/amazon/GPSListener.java deleted file mode 100755 index 1d712e9..0000000 --- a/src/amazon/GPSListener.java +++ /dev/null
@@ -1,51 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -*/ - -package org.apache.cordova.geolocation; - -import android.os.Looper; -import android.location.LocationManager; - -/** - * This class handles requests for GPS location services. - * - */ -public class GPSListener extends CordovaLocationListener { - public GPSListener(LocationManager locationManager, GeoBroker m) { - super(locationManager, m, "[Cordova GPSListener]"); - } - - - /** - * Start requesting location updates. - * - * @param interval - */ - @Override - protected void start() { - if (!this.running) { - if (this.locationManager.getProvider(LocationManager.GPS_PROVIDER) != null) { - this.running = true; - this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 0, this, Looper.getMainLooper()); - } else { - this.fail(CordovaLocationListener.POSITION_UNAVAILABLE, "GPS provider is not available."); - } - } - } -}
diff --git a/src/amazon/GeoBroker.java b/src/amazon/GeoBroker.java deleted file mode 100755 index bd88d38..0000000 --- a/src/amazon/GeoBroker.java +++ /dev/null
@@ -1,205 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -*/ -package org.apache.cordova.geolocation; - -import org.apache.cordova.CallbackContext; -import org.apache.cordova.CordovaPlugin; -import org.apache.cordova.PluginResult; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import android.content.Context; -import android.location.Location; -import android.location.LocationManager; - -/* - * This class is the interface to the Geolocation. It's bound to the geo object. - * - * This class only starts and stops various GeoListeners, which consist of a GPS and a Network Listener - */ - -public class GeoBroker extends CordovaPlugin { - private GPSListener gpsListener; - private NetworkListener networkListener; - private LocationManager locationManager; - - /** - * Executes the request and returns PluginResult. - * - * @param action The action to execute. - * @param args JSONArry of arguments for the plugin. - * @param callbackContext The callback id used when calling back into JavaScript. - * @return True if the action was valid, or false if not. - */ - public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { - if (locationManager == null) { - locationManager = (LocationManager) this.cordova.getActivity().getSystemService(Context.LOCATION_SERVICE); - } - if ( locationManager.isProviderEnabled( LocationManager.GPS_PROVIDER ) || - locationManager.isProviderEnabled( LocationManager.NETWORK_PROVIDER )) { - if (networkListener == null) { - networkListener = new NetworkListener(locationManager, this); - } - if (gpsListener == null) { - gpsListener = new GPSListener(locationManager, this); - } - - - if (action.equals("getLocation")) { - boolean enableHighAccuracy = args.getBoolean(0); - int maximumAge = args.getInt(1); - String provider = (enableHighAccuracy && locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) ? LocationManager.GPS_PROVIDER : LocationManager.NETWORK_PROVIDER; - Location last = this.locationManager.getLastKnownLocation(provider); - // Check if we can use lastKnownLocation to get a quick reading and use less battery - if (last != null && (System.currentTimeMillis() - last.getTime()) <= maximumAge) { - PluginResult result = new PluginResult(PluginResult.Status.OK, this.returnLocationJSON(last)); - callbackContext.sendPluginResult(result); - } else { - this.getCurrentLocation(callbackContext, enableHighAccuracy, args.optInt(2, 60000)); - } - } - else if (action.equals("addWatch")) { - String id = args.getString(0); - boolean enableHighAccuracy = args.getBoolean(1); - this.addWatch(id, callbackContext, enableHighAccuracy); - } - else if (action.equals("clearWatch")) { - String id = args.getString(0); - this.clearWatch(id); - } - else { - return false; - } - } else { - PluginResult.Status status = PluginResult.Status.NO_RESULT; - String message = "Location API is not available for this device."; - PluginResult result = new PluginResult(status, message); - callbackContext.sendPluginResult(result); - } - return true; - } - - private void clearWatch(String id) { - this.gpsListener.clearWatch(id); - this.networkListener.clearWatch(id); - } - - private void getCurrentLocation(CallbackContext callbackContext, boolean enableHighAccuracy, int timeout) { - if (enableHighAccuracy && locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { - this.gpsListener.addCallback(callbackContext, timeout); - } else { - this.networkListener.addCallback(callbackContext, timeout); - } - } - - private void addWatch(String timerId, CallbackContext callbackContext, boolean enableHighAccuracy) { - if (enableHighAccuracy && locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { - this.gpsListener.addWatch(timerId, callbackContext); - } else { - this.networkListener.addWatch(timerId, callbackContext); - } - } - - /** - * Called when the activity is to be shut down. - * Stop listener. - */ - public void onDestroy() { - if (this.networkListener != null) { - this.networkListener.destroy(); - this.networkListener = null; - } - if (this.gpsListener != null) { - this.gpsListener.destroy(); - this.gpsListener = null; - } - } - - /** - * Called when the view navigates. - * Stop the listeners. - */ - public void onReset() { - this.onDestroy(); - } - - public JSONObject returnLocationJSON(Location loc) { - JSONObject o = new JSONObject(); - - try { - o.put("latitude", loc.getLatitude()); - o.put("longitude", loc.getLongitude()); - o.put("altitude", (loc.hasAltitude() ? loc.getAltitude() : null)); - o.put("accuracy", loc.getAccuracy()); - o.put("heading", (loc.hasBearing() ? (loc.hasSpeed() ? loc.getBearing() : null) : null)); - o.put("velocity", loc.getSpeed()); - o.put("timestamp", loc.getTime()); - } catch (JSONException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - return o; - } - - public void win(Location loc, CallbackContext callbackContext, boolean keepCallback) { - PluginResult result = new PluginResult(PluginResult.Status.OK, this.returnLocationJSON(loc)); - result.setKeepCallback(keepCallback); - callbackContext.sendPluginResult(result); - } - - /** - * Location failed. Send error back to JavaScript. - * - * @param code The error code - * @param msg The error message - * @throws JSONException - */ - public void fail(int code, String msg, CallbackContext callbackContext, boolean keepCallback) { - JSONObject obj = new JSONObject(); - String backup = null; - try { - obj.put("code", code); - obj.put("message", msg); - } catch (JSONException e) { - obj = null; - backup = "{'code':" + code + ",'message':'" + msg.replaceAll("'", "\'") + "'}"; - } - PluginResult result; - if (obj != null) { - result = new PluginResult(PluginResult.Status.ERROR, obj); - } else { - result = new PluginResult(PluginResult.Status.ERROR, backup); - } - - result.setKeepCallback(keepCallback); - callbackContext.sendPluginResult(result); - } - - public boolean isGlobalListener(CordovaLocationListener listener) - { - if (gpsListener != null && networkListener != null) - { - return gpsListener.equals(listener) || networkListener.equals(listener); - } - else - return false; - } -}
diff --git a/src/amazon/NetworkListener.java b/src/amazon/NetworkListener.java deleted file mode 100755 index aeb39ce..0000000 --- a/src/amazon/NetworkListener.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -*/ - -package org.apache.cordova.geolocation; - - -import android.location.LocationManager; - -/** - * This class handles requests for GPS location services. - * - */ -public class NetworkListener extends CordovaLocationListener { - public NetworkListener(LocationManager locationManager, GeoBroker m) { - super(locationManager, m, "[Cordova NetworkListener]"); - } -}
diff --git a/src/firefoxos/GeolocationProxy.js b/src/firefoxos/GeolocationProxy.js deleted file mode 100644 index 305eed1..0000000 --- a/src/firefoxos/GeolocationProxy.js +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -// latest geolocation spec can be found here: http://www.w3.org/TR/geolocation-API/ - -var idsMap = {}; - -module.exports = { - getLocation: function(success, error, args) { - var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); - function successCallback(position) { - // Cordova is creating Position object using just coords - success(position.coords); - } - geo.getCurrentPosition(successCallback, error, { - enableHighAccuracy: args[0], - maximumAge: args[1] - }); - }, - - addWatch: function(success, error, args) { - var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); - var id = args[0]; - var nativeId = geo.watchPosition(success, error, { - enableHighAccuracy: args[1] - }); - - idsMap[id] = nativeId; - }, - - clearWatch: function(success, error, args) { - var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); - var id = args[0]; - - if(id in idsMap) { - geo.clearWatch(idsMap[id]); - delete idsMap[id]; - } - - if(success) { - success(); - } - } -}; - -require("cordova/firefoxos/commandProxy").add("Geolocation", module.exports);
diff --git a/src/ios/CDVLocation.h b/src/ios/CDVLocation.h deleted file mode 100644 index 3c7e463..0000000 --- a/src/ios/CDVLocation.h +++ /dev/null
@@ -1,71 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - */ - -#import <UIKit/UIKit.h> -#import <CoreLocation/CoreLocation.h> -#import <Cordova/CDVPlugin.h> -#import <Cordova/CDVShared.h> - -enum CDVLocationStatus { - PERMISSIONDENIED = 1, - POSITIONUNAVAILABLE, - TIMEOUT -}; -typedef NSUInteger CDVLocationStatus; - -// simple object to keep track of location information -@interface CDVLocationData : NSObject { - CDVLocationStatus locationStatus; - NSMutableArray* locationCallbacks; - NSMutableDictionary* watchCallbacks; - CLLocation* locationInfo; -} - -@property (nonatomic, assign) CDVLocationStatus locationStatus; -@property (nonatomic, strong) CLLocation* locationInfo; -@property (nonatomic, strong) NSMutableArray* locationCallbacks; -@property (nonatomic, strong) NSMutableDictionary* watchCallbacks; - -@end - -@interface CDVLocation : CDVPlugin <CLLocationManagerDelegate>{ - @private BOOL __locationStarted; - @private BOOL __highAccuracyEnabled; - CDVLocationData* locationData; -} - -@property (nonatomic, strong) CLLocationManager* locationManager; -@property (nonatomic, strong) CDVLocationData* locationData; - -- (void)getLocation:(CDVInvokedUrlCommand*)command; -- (void)addWatch:(CDVInvokedUrlCommand*)command; -- (void)clearWatch:(CDVInvokedUrlCommand*)command; -- (void)returnLocationInfo:(NSString*)callbackId andKeepCallback:(BOOL)keepCallback; -- (void)returnLocationError:(NSUInteger)errorCode withMessage:(NSString*)message; -- (void)startLocation:(BOOL)enableHighAccuracy; - -- (void)locationManager:(CLLocationManager*)manager - didUpdateToLocation:(CLLocation*)newLocation - fromLocation:(CLLocation*)oldLocation; - -- (void)locationManager:(CLLocationManager*)manager - didFailWithError:(NSError*)error; - -- (BOOL)isLocationServicesEnabled; -@end
diff --git a/src/ios/CDVLocation.m b/src/ios/CDVLocation.m deleted file mode 100644 index d52b03d..0000000 --- a/src/ios/CDVLocation.m +++ /dev/null
@@ -1,343 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - */ - -#import "CDVLocation.h" -#import <Cordova/NSArray+Comparisons.h> - -#pragma mark Constants - -#define kPGLocationErrorDomain @"kPGLocationErrorDomain" -#define kPGLocationDesiredAccuracyKey @"desiredAccuracy" -#define kPGLocationForcePromptKey @"forcePrompt" -#define kPGLocationDistanceFilterKey @"distanceFilter" -#define kPGLocationFrequencyKey @"frequency" - -#pragma mark - -#pragma mark Categories - -@interface CLHeading (JSONMethods) - -- (NSString*)JSONRepresentation; - -@end - -@implementation CDVLocationData - -@synthesize locationStatus, locationInfo, locationCallbacks, watchCallbacks; -- (CDVLocationData*)init -{ - self = (CDVLocationData*)[super init]; - if (self) { - self.locationInfo = nil; - self.locationCallbacks = nil; - self.watchCallbacks = nil; - } - return self; -} - -@end - -#pragma mark - -#pragma mark CDVLocation - -@implementation CDVLocation - -@synthesize locationManager, locationData; - -- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView -{ - self = (CDVLocation*)[super initWithWebView:(UIWebView*)theWebView]; - if (self) { - self.locationManager = [[CLLocationManager alloc] init]; - self.locationManager.delegate = self; // Tells the location manager to send updates to this object - __locationStarted = NO; - __highAccuracyEnabled = NO; - self.locationData = nil; - } - return self; -} - -- (BOOL)isAuthorized -{ - BOOL authorizationStatusClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(authorizationStatus)]; // iOS 4.2+ - - if (authorizationStatusClassPropertyAvailable) { - NSUInteger authStatus = [CLLocationManager authorizationStatus]; - return (authStatus == kCLAuthorizationStatusAuthorized) || (authStatus == kCLAuthorizationStatusNotDetermined); - } - - // by default, assume YES (for iOS < 4.2) - return YES; -} - -- (BOOL)isLocationServicesEnabled -{ - BOOL locationServicesEnabledInstancePropertyAvailable = [self.locationManager respondsToSelector:@selector(locationServicesEnabled)]; // iOS 3.x - BOOL locationServicesEnabledClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(locationServicesEnabled)]; // iOS 4.x - - if (locationServicesEnabledClassPropertyAvailable) { // iOS 4.x - return [CLLocationManager locationServicesEnabled]; - } else if (locationServicesEnabledInstancePropertyAvailable) { // iOS 2.x, iOS 3.x - return [(id)self.locationManager locationServicesEnabled]; - } else { - return NO; - } -} - -- (void)startLocation:(BOOL)enableHighAccuracy -{ - if (![self isLocationServicesEnabled]) { - [self returnLocationError:PERMISSIONDENIED withMessage:@"Location services are not enabled."]; - return; - } - if (![self isAuthorized]) { - NSString* message = nil; - BOOL authStatusAvailable = [CLLocationManager respondsToSelector:@selector(authorizationStatus)]; // iOS 4.2+ - if (authStatusAvailable) { - NSUInteger code = [CLLocationManager authorizationStatus]; - if (code == kCLAuthorizationStatusNotDetermined) { - // could return POSITION_UNAVAILABLE but need to coordinate with other platforms - message = @"User undecided on application's use of location services."; - } else if (code == kCLAuthorizationStatusRestricted) { - message = @"Application's use of location services is restricted."; - } - } - // PERMISSIONDENIED is only PositionError that makes sense when authorization denied - [self returnLocationError:PERMISSIONDENIED withMessage:message]; - - return; - } - - // Tell the location manager to start notifying us of location updates. We - // first stop, and then start the updating to ensure we get at least one - // update, even if our location did not change. - [self.locationManager stopUpdatingLocation]; - [self.locationManager startUpdatingLocation]; - __locationStarted = YES; - if (enableHighAccuracy) { - __highAccuracyEnabled = YES; - // Set to distance filter to "none" - which should be the minimum for best results. - self.locationManager.distanceFilter = kCLDistanceFilterNone; - // Set desired accuracy to Best. - self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; - } else { - __highAccuracyEnabled = NO; - // TODO: Set distance filter to 10 meters? and desired accuracy to nearest ten meters? arbitrary. - self.locationManager.distanceFilter = 10; - self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; - } -} - -- (void)_stopLocation -{ - if (__locationStarted) { - if (![self isLocationServicesEnabled]) { - return; - } - - [self.locationManager stopUpdatingLocation]; - __locationStarted = NO; - __highAccuracyEnabled = NO; - } -} - -- (void)locationManager:(CLLocationManager*)manager - didUpdateToLocation:(CLLocation*)newLocation - fromLocation:(CLLocation*)oldLocation -{ - CDVLocationData* cData = self.locationData; - - cData.locationInfo = newLocation; - if (self.locationData.locationCallbacks.count > 0) { - for (NSString* callbackId in self.locationData.locationCallbacks) { - [self returnLocationInfo:callbackId andKeepCallback:NO]; - } - - [self.locationData.locationCallbacks removeAllObjects]; - } - if (self.locationData.watchCallbacks.count > 0) { - for (NSString* timerId in self.locationData.watchCallbacks) { - [self returnLocationInfo:[self.locationData.watchCallbacks objectForKey:timerId] andKeepCallback:YES]; - } - } else { - // No callbacks waiting on us anymore, turn off listening. - [self _stopLocation]; - } -} - -- (void)getLocation:(CDVInvokedUrlCommand*)command -{ - NSString* callbackId = command.callbackId; - BOOL enableHighAccuracy = [[command.arguments objectAtIndex:0] boolValue]; - - if ([self isLocationServicesEnabled] == NO) { - NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2]; - [posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"]; - [posError setObject:@"Location services are disabled." forKey:@"message"]; - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; - } else { - if (!self.locationData) { - self.locationData = [[CDVLocationData alloc] init]; - } - CDVLocationData* lData = self.locationData; - if (!lData.locationCallbacks) { - lData.locationCallbacks = [NSMutableArray arrayWithCapacity:1]; - } - - if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) { - // add the callbackId into the array so we can call back when get data - if (callbackId != nil) { - [lData.locationCallbacks addObject:callbackId]; - } - // Tell the location manager to start notifying us of heading updates - [self startLocation:enableHighAccuracy]; - } else { - [self returnLocationInfo:callbackId andKeepCallback:NO]; - } - } -} - -- (void)addWatch:(CDVInvokedUrlCommand*)command -{ - NSString* callbackId = command.callbackId; - NSString* timerId = [command.arguments objectAtIndex:0]; - BOOL enableHighAccuracy = [[command.arguments objectAtIndex:1] boolValue]; - - if (!self.locationData) { - self.locationData = [[CDVLocationData alloc] init]; - } - CDVLocationData* lData = self.locationData; - - if (!lData.watchCallbacks) { - lData.watchCallbacks = [NSMutableDictionary dictionaryWithCapacity:1]; - } - - // add the callbackId into the dictionary so we can call back whenever get data - [lData.watchCallbacks setObject:callbackId forKey:timerId]; - - if ([self isLocationServicesEnabled] == NO) { - NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2]; - [posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"]; - [posError setObject:@"Location services are disabled." forKey:@"message"]; - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; - } else { - if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) { - // Tell the location manager to start notifying us of location updates - [self startLocation:enableHighAccuracy]; - } - } -} - -- (void)clearWatch:(CDVInvokedUrlCommand*)command -{ - NSString* timerId = [command.arguments objectAtIndex:0]; - - if (self.locationData && self.locationData.watchCallbacks && [self.locationData.watchCallbacks objectForKey:timerId]) { - [self.locationData.watchCallbacks removeObjectForKey:timerId]; - } -} - -- (void)stopLocation:(CDVInvokedUrlCommand*)command -{ - [self _stopLocation]; -} - -- (void)returnLocationInfo:(NSString*)callbackId andKeepCallback:(BOOL)keepCallback -{ - CDVPluginResult* result = nil; - CDVLocationData* lData = self.locationData; - - if (lData && !lData.locationInfo) { - // return error - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:POSITIONUNAVAILABLE]; - } else if (lData && lData.locationInfo) { - CLLocation* lInfo = lData.locationInfo; - NSMutableDictionary* returnInfo = [NSMutableDictionary dictionaryWithCapacity:8]; - NSNumber* timestamp = [NSNumber numberWithDouble:([lInfo.timestamp timeIntervalSince1970] * 1000)]; - [returnInfo setObject:timestamp forKey:@"timestamp"]; - [returnInfo setObject:[NSNumber numberWithDouble:lInfo.speed] forKey:@"velocity"]; - [returnInfo setObject:[NSNumber numberWithDouble:lInfo.verticalAccuracy] forKey:@"altitudeAccuracy"]; - [returnInfo setObject:[NSNumber numberWithDouble:lInfo.horizontalAccuracy] forKey:@"accuracy"]; - [returnInfo setObject:[NSNumber numberWithDouble:lInfo.course] forKey:@"heading"]; - [returnInfo setObject:[NSNumber numberWithDouble:lInfo.altitude] forKey:@"altitude"]; - [returnInfo setObject:[NSNumber numberWithDouble:lInfo.coordinate.latitude] forKey:@"latitude"]; - [returnInfo setObject:[NSNumber numberWithDouble:lInfo.coordinate.longitude] forKey:@"longitude"]; - - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:returnInfo]; - [result setKeepCallbackAsBool:keepCallback]; - } - if (result) { - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; - } -} - -- (void)returnLocationError:(NSUInteger)errorCode withMessage:(NSString*)message -{ - NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2]; - - [posError setObject:[NSNumber numberWithUnsignedInteger:errorCode] forKey:@"code"]; - [posError setObject:message ? message:@"" forKey:@"message"]; - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError]; - - for (NSString* callbackId in self.locationData.locationCallbacks) { - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; - } - - [self.locationData.locationCallbacks removeAllObjects]; - - for (NSString* callbackId in self.locationData.watchCallbacks) { - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; - } -} - -- (void)locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)error -{ - NSLog(@"locationManager::didFailWithError %@", [error localizedFailureReason]); - - CDVLocationData* lData = self.locationData; - if (lData && __locationStarted) { - // TODO: probably have to once over the various error codes and return one of: - // PositionError.PERMISSION_DENIED = 1; - // PositionError.POSITION_UNAVAILABLE = 2; - // PositionError.TIMEOUT = 3; - NSUInteger positionError = POSITIONUNAVAILABLE; - if (error.code == kCLErrorDenied) { - positionError = PERMISSIONDENIED; - } - [self returnLocationError:positionError withMessage:[error localizedDescription]]; - } - - [self.locationManager stopUpdatingLocation]; - __locationStarted = NO; -} - -- (void)dealloc -{ - self.locationManager.delegate = nil; -} - -- (void)onReset -{ - [self _stopLocation]; - [self.locationManager stopUpdatingHeading]; -} - -@end
diff --git a/src/ubuntu/geolocation.cpp b/src/ubuntu/geolocation.cpp deleted file mode 100644 index c820cfe..0000000 --- a/src/ubuntu/geolocation.cpp +++ /dev/null
@@ -1,119 +0,0 @@ -/* - * - * Copyright 2013 Canonical Ltd. - * - * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -#include <QUuid> - -#include "geolocation.h" - -Geolocation::Geolocation(Cordova *cordova): CPlugin(cordova), - _geoPositionInfoSource(QGeoPositionInfoSource::createDefaultSource(this)) { - if (_geoPositionInfoSource.data() != 0) { - QObject::connect(_geoPositionInfoSource.data(), SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); - QObject::connect(_geoPositionInfoSource.data(), SIGNAL(updateTimeout()), this, SLOT(updateTimeout())); - } -} - -void Geolocation::addWatch(int scId, int ecId, const QString &id, bool enableHighAccuracy) { - Q_UNUSED(enableHighAccuracy); - - assert(_id2sc.find(id) == _id2sc.end()); - - if (!_geoPositionInfoSource.data()) { - QVariantMap err; - err.insert("code", POSITION_UNAVAILABLE); - err.insert("message", "unavailable"); - - this->cb(ecId, err); - return; - } - - _id2sc[id] = scId; - _id2ec[id] = ecId; -} - -void Geolocation::clearWatch(int scId, int ecId, const QString &id) { - _id2sc.remove(id); - _id2ec.remove(id); -} - -void Geolocation::getLocation(int scId, int ecId, bool enableHighAccuracy, qint64 maximumAge) { - Q_UNUSED(maximumAge); - Q_UNUSED(enableHighAccuracy); - - if (!_geoPositionInfoSource.data()) { - QVariantMap err; - err.insert("code", POSITION_UNAVAILABLE); - err.insert("message", "unavailable"); - - this->cb(ecId, err); - return; - } - - _geoPositionInfoSource->requestUpdate(); - - QString id = QString("_INTERNAL_") + QUuid::createUuid().toString(); - - _id2sc[id] = scId; - _id2ec[id] = ecId; - _singleUpdate.insert(id); -} - -void Geolocation::positionUpdated(const QGeoPositionInfo &update) { - QGeoCoordinate coordinate = update.coordinate(); - - QVariantMap p; - - p.insert("latitude", coordinate.latitude()); - p.insert("longitude", coordinate.longitude()); - p.insert("altitude", coordinate.altitude()); - - if (update.hasAttribute(QGeoPositionInfo::VerticalAccuracy)) - p.insert("accuracy", update.attribute(QGeoPositionInfo::VerticalAccuracy)); - if (update.hasAttribute(QGeoPositionInfo::Direction)) - p.insert("heading", update.attribute(QGeoPositionInfo::Direction)); - if (update.hasAttribute(QGeoPositionInfo::GroundSpeed)) - p.insert("velocity", update.attribute(QGeoPositionInfo::GroundSpeed)); - if (update.hasAttribute(QGeoPositionInfo::HorizontalAccuracy)) - p.insert("altitudeAccuracy", update.attribute(QGeoPositionInfo::HorizontalAccuracy)); - p.insert("timestamp", update.timestamp().toMSecsSinceEpoch()); - - for (const QString &id: _id2sc.keys()) { - int scId = _id2sc[id]; - this->cb(scId, p); - if (_singleUpdate.contains(id)) { - _singleUpdate.remove(id); - _id2sc.remove(id); - _id2ec.remove(id); - } - } -} - -void Geolocation::updateTimeout() { - QVariantMap err; - err.insert("code", TIMEOUT); - err.insert("message", "timeout"); - - for (int ecId: _id2ec) { - this->cb(ecId, err); - } - - _id2ec.clear(); - _id2sc.clear(); - _singleUpdate.clear(); -}
diff --git a/src/ubuntu/geolocation.h b/src/ubuntu/geolocation.h deleted file mode 100644 index 7345bec..0000000 --- a/src/ubuntu/geolocation.h +++ /dev/null
@@ -1,69 +0,0 @@ -/* - * - * Copyright 2013 Canonical Ltd. - * - * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -#ifndef GEOLOCATION_H_SVO2013 -#define GEOLOCATION_H_SVO2013 - -#include <QGeoPositionInfoSource> -#include <QGeoPositionInfo> -#include <QtCore> -#include <cassert> - -#include <cplugin.h> - -class Geolocation: public CPlugin { - Q_OBJECT -public: - explicit Geolocation(Cordova *cordova); - - virtual const QString fullName() override { - return Geolocation::fullID(); - } - - virtual const QString shortName() override { - return "Geolocation"; - } - - static const QString fullID() { - return "Geolocation"; - } - -public slots: - void getLocation(int scId, int ecId, bool enableHighAccuracy, qint64 maximumAge); - void addWatch(int scId, int ecId, const QString &id, bool enableHighAccuracy); - void clearWatch(int scId, int ecId, const QString &id); - -protected slots: - void positionUpdated(const QGeoPositionInfo &update); - void updateTimeout(); - -private: - QMap<QString, int> _id2sc; - QMap<QString, int> _id2ec; - QSet<QString> _singleUpdate; - QSharedPointer<QGeoPositionInfoSource> _geoPositionInfoSource; - - enum PositionError { - PERMISSION_DENIED = 1, - POSITION_UNAVAILABLE = 2, - TIMEOUT = 3 - }; -}; - -#endif
diff --git a/src/windows8/GeolocationProxy.js b/src/windows8/GeolocationProxy.js deleted file mode 100644 index c341431..0000000 --- a/src/windows8/GeolocationProxy.js +++ /dev/null
@@ -1,163 +0,0 @@ -/* - * Copyright 2013 Research In Motion Limited. - * - * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var PositionError = require('./PositionError'), - ids = {}, - loc; - -function ensureLocator() { - if (loc == null) - loc = new Windows.Devices.Geolocation.Geolocator(); - - return loc; -} - -function createErrorCode() { - switch (loc.locationStatus) { - case Windows.Devices.Geolocation.PositionStatus.initializing: - // This status indicates that a location device is still initializing - case Windows.Devices.Geolocation.PositionStatus.noData: - // No location data is currently available - case Windows.Devices.Geolocation.PositionStatus.notInitialized: - // This status indicates that the app has not yet requested - // location data by calling GetGeolocationAsync() or - // registering an event handler for the positionChanged event. - case Windows.Devices.Geolocation.PositionStatus.notAvailable: - // Location is not available on this version of Windows - return PositionError.POSITION_UNAVAILABLE; - - case Windows.Devices.Geolocation.PositionStatus.disabled: - // The app doesn't have permission to access location, - // either because location has been turned off. - return PositionError.PERMISSION_DENIED; - - default: - break; - } -} - -module.exports = { - getLocation: function (success, fail, args, env) { - ensureLocator(); - if (loc != null) - { - var highAccuracy = args[0], - maxAge = args[1]; - - loc.desiredAccuracy = highAccuracy ? - Windows.Devices.Geolocation.PositionAccuracy.high : - Windows.Devices.Geolocation.PositionAccuracy.default; - - loc.reportInterval = maxAge ? maxAge : 0; - - loc.getGeopositionAsync().then( - function (pos) { - success({ - latitude: pos.coordinate.latitude, - longitude: pos.coordinate.longitude, - altitude: pos.coordinate.altitude, - accuracy: pos.coordinate.accuracy, - heading: pos.coordinate.heading, - velocity: pos.coordinate.speed, - altitudeAccuracy: pos.coordinate.altitudeAccuracy, - timestamp: pos.coordinate.timestamp - }); - }, - function (err) { - fail({ - code: createErrorCode(), - message: err.message - }); - } - ); - } - else - { - fail({ - code: PositionError.POSITION_UNAVAILABLE, - message: "You do not have the required location services present on your system." - }); - } - }, - - addWatch: function (success, fail, args, env) { - ensureLocator(); - var clientId = args[0], - highAccuracy = args[1], - - onPositionChanged = function (e) { - success({ - latitude: e.position.coordinate.latitude, - longitude: e.position.coordinate.longitude, - altitude: e.position.coordinate.altitude, - accuracy: e.position.coordinate.accuracy, - heading: e.position.coordinate.heading, - velocity: e.position.coordinate.speed, - altitudeAccuracy: e.position.coordinate.altitudeAccuracy, - timestamp: e.position.coordinate.timestamp - }); - }, - - onStatusChanged = function (e) { - switch (e.status) { - case Windows.Devices.Geolocation.PositionStatus.noData: - case Windows.Devices.Geolocation.PositionStatus.notAvailable: - fail({ - code: PositionError.POSITION_UNAVAILABLE, - message: "Data from location services is currently unavailable or you do not have the required location services present on your system." - }); - break; - - case Windows.Devices.Geolocation.PositionStatus.disabled: - fail({ - code: PositionError.PERMISSION_DENIED, - message: "Your location is currently turned off." - }); - break; - - case Windows.Devices.Geolocation.PositionStatus.initializing: - case Windows.Devices.Geolocation.PositionStatus.ready: - default: - break; - } - }; - - loc.desiredAccuracy = highAccuracy ? - Windows.Devices.Geolocation.PositionAccuracy.high : - Windows.Devices.Geolocation.PositionAccuracy.default; - - loc.addEventListener("positionchanged", onPositionChanged); - loc.addEventListener("statuschanged", onStatusChanged); - - ids[clientId] = { pos: onPositionChanged, status: onStatusChanged }; - }, - - clearWatch: function (success, fail, args, env) { - var clientId = args[0], - callbacks = ids[clientId]; - - if (callbacks) { - loc.removeEventListener("positionchanged", callbacks.pos); - loc.removeEventListener("statuschanged", callbacks.status); - - delete ids[clientId]; - } - - success && success(); - } -}; - -require("cordova/exec/proxy").add("Geolocation", module.exports);
diff --git a/src/wp/GeoLocation.cs b/src/wp/GeoLocation.cs deleted file mode 100644 index 42af72d..0000000 --- a/src/wp/GeoLocation.cs +++ /dev/null
@@ -1,34 +0,0 @@ -/* - Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -using System; -using System.Collections.Generic; -using System.Runtime.Serialization; -using System.Threading; -using System.Device.Location; - -namespace WPCordovaClassLib.Cordova.Commands -{ - /// <summary> - /// This is a command stub, the browser provides the correct implementation. We use this to trigger the static analyzer that we require this permission - /// </summary> - public class Geolocation - { - /* Unreachable code, by design -jm */ - private void triggerGeoInclusion() - { - new GeoCoordinateWatcher(); - } - } -}
diff --git a/www/Coordinates.js b/www/Coordinates.js deleted file mode 100644 index 84fdd5b..0000000 --- a/www/Coordinates.js +++ /dev/null
@@ -1,69 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -/** - * This class contains position information. - * @param {Object} lat - * @param {Object} lng - * @param {Object} alt - * @param {Object} acc - * @param {Object} head - * @param {Object} vel - * @param {Object} altacc - * @constructor - */ -var Coordinates = function(lat, lng, alt, acc, head, vel, altacc) { - /** - * The latitude of the position. - */ - this.latitude = lat; - /** - * The longitude of the position, - */ - this.longitude = lng; - /** - * The accuracy of the position. - */ - this.accuracy = acc; - /** - * The altitude of the position. - */ - this.altitude = (alt !== undefined ? alt : null); - /** - * The direction the device is moving at the position. - */ - this.heading = (head !== undefined ? head : null); - /** - * The velocity with which the device is moving at the position. - */ - this.speed = (vel !== undefined ? vel : null); - - if (this.speed === 0 || this.speed === null) { - this.heading = NaN; - } - - /** - * The altitude accuracy of the position. - */ - this.altitudeAccuracy = (altacc !== undefined) ? altacc : null; -}; - -module.exports = Coordinates;
diff --git a/www/Position.js b/www/Position.js deleted file mode 100644 index f0470de..0000000 --- a/www/Position.js +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -var Coordinates = require('./Coordinates'); - -var Position = function(coords, timestamp) { - if (coords) { - this.coords = new Coordinates(coords.latitude, coords.longitude, coords.altitude, coords.accuracy, coords.heading, coords.velocity, coords.altitudeAccuracy); - } else { - this.coords = new Coordinates(); - } - this.timestamp = (timestamp !== undefined) ? timestamp : new Date(); -}; - -module.exports = Position;
diff --git a/www/PositionError.js b/www/PositionError.js deleted file mode 100644 index 9403f11..0000000 --- a/www/PositionError.js +++ /dev/null
@@ -1,38 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -/** - * Position error object - * - * @constructor - * @param code - * @param message - */ -var PositionError = function(code, message) { - this.code = code || null; - this.message = message || ''; -}; - -PositionError.PERMISSION_DENIED = 1; -PositionError.POSITION_UNAVAILABLE = 2; -PositionError.TIMEOUT = 3; - -module.exports = PositionError;
diff --git a/www/blackberry10/GeolocationProxy.js b/www/blackberry10/GeolocationProxy.js deleted file mode 100644 index 0bba226..0000000 --- a/www/blackberry10/GeolocationProxy.js +++ /dev/null
@@ -1,69 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -var idsMap = {}, - geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); - -module.exports = { - - getLocation: function(success, error, args) { - var successCallback = function (result) { - var pos = result.coords; - pos.timestamp = result.timestamp; - if (success) { - success(pos); - } - }; - geo.getCurrentPosition(successCallback, error, { - enableHighAccuracy: args[0], - maximumAge: args[1] - }); - }, - - addWatch: function(success, error, args) { - var id = args[0], - successCallback = function (result) { - var pos = result.coords; - pos.timestamp = result.timestamp; - if (success) { - success(pos); - } - }, - nativeId = geo.watchPosition(successCallback, error, { - enableHighAccuracy: args[1] - }); - idsMap[id] = nativeId; - }, - - clearWatch: function(success, error, args) { - var id = args[0]; - if(id in idsMap) { - geo.clearWatch(idsMap[id]); - delete idsMap[id]; - } - if(success) { - success(); - } - } - -}; - -require("cordova/exec/proxy").add("Geolocation", module.exports);
diff --git a/www/geolocation.js b/www/geolocation.js deleted file mode 100644 index 3814919..0000000 --- a/www/geolocation.js +++ /dev/null
@@ -1,211 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -var argscheck = require('cordova/argscheck'), - utils = require('cordova/utils'), - exec = require('cordova/exec'), - PositionError = require('./PositionError'), - Position = require('./Position'); - -var timers = {}; // list of timers in use - -// Returns default params, overrides if provided with values -function parseParameters(options) { - var opt = { - maximumAge: 0, - enableHighAccuracy: false, - timeout: Infinity - }; - - if (options) { - if (options.maximumAge !== undefined && !isNaN(options.maximumAge) && options.maximumAge > 0) { - opt.maximumAge = options.maximumAge; - } - if (options.enableHighAccuracy !== undefined) { - opt.enableHighAccuracy = options.enableHighAccuracy; - } - if (options.timeout !== undefined && !isNaN(options.timeout)) { - if (options.timeout < 0) { - opt.timeout = 0; - } else { - opt.timeout = options.timeout; - } - } - } - - return opt; -} - -// Returns a timeout failure, closed over a specified timeout value and error callback. -function createTimeout(errorCallback, timeout) { - var t = setTimeout(function() { - clearTimeout(t); - t = null; - errorCallback({ - code:PositionError.TIMEOUT, - message:"Position retrieval timed out." - }); - }, timeout); - return t; -} - -var geolocation = { - lastPosition:null, // reference to last known (cached) position returned - /** - * Asynchronously acquires the current position. - * - * @param {Function} successCallback The function to call when the position data is available - * @param {Function} errorCallback The function to call when there is an error getting the heading position. (OPTIONAL) - * @param {PositionOptions} options The options for getting the position data. (OPTIONAL) - */ - getCurrentPosition:function(successCallback, errorCallback, options) { - argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments); - options = parseParameters(options); - - // Timer var that will fire an error callback if no position is retrieved from native - // before the "timeout" param provided expires - var timeoutTimer = {timer:null}; - - var win = function(p) { - clearTimeout(timeoutTimer.timer); - if (!(timeoutTimer.timer)) { - // Timeout already happened, or native fired error callback for - // this geo request. - // Don't continue with success callback. - return; - } - var pos = new Position( - { - latitude:p.latitude, - longitude:p.longitude, - altitude:p.altitude, - accuracy:p.accuracy, - heading:p.heading, - velocity:p.velocity, - altitudeAccuracy:p.altitudeAccuracy - }, - (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp))) - ); - geolocation.lastPosition = pos; - successCallback(pos); - }; - var fail = function(e) { - clearTimeout(timeoutTimer.timer); - timeoutTimer.timer = null; - var err = new PositionError(e.code, e.message); - if (errorCallback) { - errorCallback(err); - } - }; - - // Check our cached position, if its timestamp difference with current time is less than the maximumAge, then just - // fire the success callback with the cached position. - if (geolocation.lastPosition && options.maximumAge && (((new Date()).getTime() - geolocation.lastPosition.timestamp.getTime()) <= options.maximumAge)) { - successCallback(geolocation.lastPosition); - // If the cached position check failed and the timeout was set to 0, error out with a TIMEOUT error object. - } else if (options.timeout === 0) { - fail({ - code:PositionError.TIMEOUT, - message:"timeout value in PositionOptions set to 0 and no cached Position object available, or cached Position object's age exceeds provided PositionOptions' maximumAge parameter." - }); - // Otherwise we have to call into native to retrieve a position. - } else { - if (options.timeout !== Infinity) { - // If the timeout value was not set to Infinity (default), then - // set up a timeout function that will fire the error callback - // if no successful position was retrieved before timeout expired. - timeoutTimer.timer = createTimeout(fail, options.timeout); - } else { - // This is here so the check in the win function doesn't mess stuff up - // may seem weird but this guarantees timeoutTimer is - // always truthy before we call into native - timeoutTimer.timer = true; - } - exec(win, fail, "Geolocation", "getLocation", [options.enableHighAccuracy, options.maximumAge]); - } - return timeoutTimer; - }, - /** - * Asynchronously watches the geolocation for changes to geolocation. When a change occurs, - * the successCallback is called with the new location. - * - * @param {Function} successCallback The function to call each time the location data is available - * @param {Function} errorCallback The function to call when there is an error getting the location data. (OPTIONAL) - * @param {PositionOptions} options The options for getting the location data such as frequency. (OPTIONAL) - * @return String The watch id that must be passed to #clearWatch to stop watching. - */ - watchPosition:function(successCallback, errorCallback, options) { - argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments); - options = parseParameters(options); - - var id = utils.createUUID(); - - // Tell device to get a position ASAP, and also retrieve a reference to the timeout timer generated in getCurrentPosition - timers[id] = geolocation.getCurrentPosition(successCallback, errorCallback, options); - - var fail = function(e) { - clearTimeout(timers[id].timer); - var err = new PositionError(e.code, e.message); - if (errorCallback) { - errorCallback(err); - } - }; - - var win = function(p) { - clearTimeout(timers[id].timer); - if (options.timeout !== Infinity) { - timers[id].timer = createTimeout(fail, options.timeout); - } - var pos = new Position( - { - latitude:p.latitude, - longitude:p.longitude, - altitude:p.altitude, - accuracy:p.accuracy, - heading:p.heading, - velocity:p.velocity, - altitudeAccuracy:p.altitudeAccuracy - }, - (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp))) - ); - geolocation.lastPosition = pos; - successCallback(pos); - }; - - exec(win, fail, "Geolocation", "addWatch", [id, options.enableHighAccuracy]); - - return id; - }, - /** - * Clears the specified heading watch. - * - * @param {String} id The ID of the watch returned from #watchPosition - */ - clearWatch:function(id) { - if (id && timers[id] !== undefined) { - clearTimeout(timers[id].timer); - timers[id].timer = false; - exec(null, null, "Geolocation", "clearWatch", [id]); - } - } -}; - -module.exports = geolocation;