cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmo...@apache.org
Subject [12/47] git commit: CB-5334 [BlackBerry10] Use command proxy
Date Mon, 05 May 2014 16:13:09 GMT
CB-5334 [BlackBerry10] Use command proxy


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/commit/cbf86fd5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/cbf86fd5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/cbf86fd5

Branch: refs/heads/cdvtest
Commit: cbf86fd575ba0d596c6590c8b566c37d858a23b7
Parents: f3e416d
Author: Bryan Higgins <bryan@bryanhiggins.net>
Authored: Sun Nov 10 17:43:37 2013 -0500
Committer: Bryan Higgins <bryan@bryanhiggins.net>
Committed: Sun Nov 10 17:43:37 2013 -0500

----------------------------------------------------------------------
 plugin.xml                           |  7 +++-
 src/blackberry10/index.js            | 64 -------------------------------
 www/blackberry10/GeolocationProxy.js | 61 +++++++++++++++++++++++++++++
 3 files changed, 67 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/cbf86fd5/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 7e9548c..0da41e9 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -81,6 +81,10 @@ xmlns:android="http://schemas.android.com/apk/res/android"
     <!-- 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>
@@ -97,13 +101,14 @@ xmlns:android="http://schemas.android.com/apk/res/android"
             <clobbers target="navigator.geolocation" />
         </js-module>
 
-        <source-file src="src/blackberry10/index.js" target-dir="Geolocation" />
         <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>
 
     <!-- wp7 -->

http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/cbf86fd5/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
deleted file mode 100644
index c12c15f..0000000
--- a/src/blackberry10/index.js
+++ /dev/null
@@ -1,64 +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 ids = {};
-
-module.exports = {
-    getLocation: function (success, fail, args, env) {
-        var result = new PluginResult(args, env),
-            options = {
-                "enableHighAccuracy": decodeURIComponent(args[0]),
-                "maximumAge": decodeURIComponent(args[1])
-            };
-
-        navigator.geolocation.getCurrentPosition(function (pos) {
-            result.callbackOk(pos.coords, false);
-        }, function (err) {
-            result.error(err, false);
-        }, options);
-
-        result.noResult(true);
-    },
-
-    addWatch: function (success, fail, args, env) {
-        var result = new PluginResult(args, env),
-            options = {
-                "enableHighAccuracy": decodeURIComponent(args[1])
-            },
-            clientId = decodeURIComponent(args[0]);
-            id = navigator.geolocation.watchPosition(function (pos) {
-                    result.callbackOk(pos.coords, false);
-                }, function (err) {
-                    result.error(err, false);
-                }, options);
-
-        ids[clientId] = id;
-
-        result.noResult(true);
-    },
-
-    clearWatch: function (success, fail, args, env) {
-        var result = new PluginResult(args, env),
-            clientId = decodeURIComponent(args[0]),
-            id = ids[clientId];
-
-        if (id) {
-            navigator.geolocation.clearWatch(id);
-            delete ids[clientId];
-        }
-
-        result.ok(null, false);
-    }
-};

http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/cbf86fd5/www/blackberry10/GeolocationProxy.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/GeolocationProxy.js b/www/blackberry10/GeolocationProxy.js
new file mode 100644
index 0000000..6428942
--- /dev/null
+++ b/www/blackberry10/GeolocationProxy.js
@@ -0,0 +1,61 @@
+/*
+ *
+ * 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 = {};
+
+module.exports = {
+    getLocation: function(success, error, args) {
+        var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'),
+            successCallback = function (position) {
+                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'),
+            id = args[0],
+            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'),
+            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);


Mime
View raw message