Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B8575D0B3 for ; Mon, 20 May 2013 21:48:10 +0000 (UTC) Received: (qmail 85717 invoked by uid 500); 20 May 2013 21:48:11 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 85650 invoked by uid 500); 20 May 2013 21:48:11 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 85642 invoked by uid 99); 20 May 2013 21:48:11 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 May 2013 21:48:11 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C9609890A88; Mon, 20 May 2013 21:48:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: steven@apache.org To: commits@cordova.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: js commit: removed location code Date: Mon, 20 May 2013 21:48:10 +0000 (UTC) Updated Branches: refs/heads/3.0.0 8ac64ca00 -> eda98d16b removed location code Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/eda98d16 Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/eda98d16 Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/eda98d16 Branch: refs/heads/3.0.0 Commit: eda98d16b1b0705dac00e2c5c9e694a81e31d2ea Parents: 8ac64ca Author: Steven Gill Authored: Mon May 20 12:09:16 2013 -0700 Committer: Steven Gill Committed: Mon May 20 12:09:16 2013 -0700 ---------------------------------------------------------------------- lib/common/plugin/Position.js | 33 ---- lib/common/plugin/PositionError.js | 38 ----- lib/common/plugin/geolocation.js | 211 ------------------------ lib/common/plugin/geolocation/symbols.js | 27 --- lib/ios/plugin/ios/geolocation/symbols.js | 23 --- 5 files changed, 0 insertions(+), 332 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-js/blob/eda98d16/lib/common/plugin/Position.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/Position.js b/lib/common/plugin/Position.js deleted file mode 100644 index 0f21ba3..0000000 --- a/lib/common/plugin/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('cordova/plugin/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; http://git-wip-us.apache.org/repos/asf/cordova-js/blob/eda98d16/lib/common/plugin/PositionError.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/PositionError.js b/lib/common/plugin/PositionError.js deleted file mode 100644 index 9403f11..0000000 --- a/lib/common/plugin/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; http://git-wip-us.apache.org/repos/asf/cordova-js/blob/eda98d16/lib/common/plugin/geolocation.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/geolocation.js b/lib/common/plugin/geolocation.js deleted file mode 100644 index 6af92ca..0000000 --- a/lib/common/plugin/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('cordova/plugin/PositionError'), - Position = require('cordova/plugin/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; http://git-wip-us.apache.org/repos/asf/cordova-js/blob/eda98d16/lib/common/plugin/geolocation/symbols.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/geolocation/symbols.js b/lib/common/plugin/geolocation/symbols.js deleted file mode 100644 index ee31422..0000000 --- a/lib/common/plugin/geolocation/symbols.js +++ /dev/null @@ -1,27 +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 modulemapper = require('cordova/modulemapper'); - -modulemapper.defaults('cordova/plugin/geolocation', 'navigator.geolocation'); -modulemapper.clobbers('cordova/plugin/PositionError', 'PositionError'); -modulemapper.clobbers('cordova/plugin/Position', 'Position'); -modulemapper.clobbers('cordova/plugin/Coordinates', 'Coordinates'); http://git-wip-us.apache.org/repos/asf/cordova-js/blob/eda98d16/lib/ios/plugin/ios/geolocation/symbols.js ---------------------------------------------------------------------- diff --git a/lib/ios/plugin/ios/geolocation/symbols.js b/lib/ios/plugin/ios/geolocation/symbols.js deleted file mode 100644 index ce8d2e2..0000000 --- a/lib/ios/plugin/ios/geolocation/symbols.js +++ /dev/null @@ -1,23 +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 modulemapper = require('cordova/modulemapper'); - -modulemapper.merges('cordova/plugin/geolocation', 'navigator.geolocation');