cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [3/50] js commit: Initial wireup of B2G (Firefox OS) platform
Date Tue, 12 Feb 2013 19:33:07 GMT
Initial wireup of B2G (Firefox OS) platform

Added support for:
Device
Network
Accelerometer


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/44c2a450
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/44c2a450
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/44c2a450

Branch: refs/heads/symbolmapping
Commit: 44c2a4509ea5fb6b77f78d40e058ff39745db08d
Parents: 29b266b
Author: Dan Silivestru <dan.silivestru@gmail.com>
Authored: Sat Jan 26 15:06:54 2013 -0500
Committer: Gord Tanner <gtanner@gmail.com>
Committed: Mon Jan 28 21:33:49 2013 -0500

----------------------------------------------------------------------
 lib/b2g/exec.js                     |   56 ++++++++++++++++++++++++++++++
 lib/b2g/platform.js                 |   26 ++++++++++++++
 lib/b2g/plugin/b2g/accelerometer.js |   41 ++++++++++++++++++++++
 lib/b2g/plugin/b2g/device.js        |   39 +++++++++++++++++++++
 lib/b2g/plugin/b2g/network.js       |   29 +++++++++++++++
 lib/scripts/bootstrap-b2g.js        |   22 ++++++++++++
 6 files changed, 213 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/44c2a450/lib/b2g/exec.js
----------------------------------------------------------------------
diff --git a/lib/b2g/exec.js b/lib/b2g/exec.js
new file mode 100644
index 0000000..e8bb34c
--- /dev/null
+++ b/lib/b2g/exec.js
@@ -0,0 +1,56 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+/**
+ * Execute a cordova command.  It is up to the native side whether this action
+ * is synchronous or asynchronous.  The native side can return:
+ *      Synchronous: PluginResult object as a JSON string
+ *      Asynchrounous: Empty string ""
+ * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
+ * depending upon the result of the action.
+ *
+ * @param {Function} success    The success callback
+ * @param {Function} fail       The fail callback
+ * @param {String} service      The name of the service to use
+ * @param {String} action       Action to be run in cordova
+ * @param {String[]} [args]     Zero or more arguments to pass to the method
+ */
+
+var plugins = {
+    "Device": require('cordova/plugin/b2g/device'),
+    "NetworkStatus": require('cordova/plugin/b2g/network'),
+    "Accelerometer" : require('cordova/plugin/b2g/accelerometer')
+    //"Notification" : require('cordova/plugin/b2g/notification')
+};
+
+module.exports = function(success, fail, service, action, args) {
+    try {
+        console.error("exec:call plugin:"+service+":"+action);
+        plugins[service][action](success, fail, args);
+    }
+    catch(e) {
+        console.error("missing exec: " + service + "." + action);
+        console.error(args);
+        console.error(e);
+        console.error(e.stack);
+    }
+};
+

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/44c2a450/lib/b2g/platform.js
----------------------------------------------------------------------
diff --git a/lib/b2g/platform.js b/lib/b2g/platform.js
new file mode 100644
index 0000000..c462826
--- /dev/null
+++ b/lib/b2g/platform.js
@@ -0,0 +1,26 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+module.exports = {
+    id: "b2g",
+    initialize: function() {
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/44c2a450/lib/b2g/plugin/b2g/accelerometer.js
----------------------------------------------------------------------
diff --git a/lib/b2g/plugin/b2g/accelerometer.js b/lib/b2g/plugin/b2g/accelerometer.js
new file mode 100644
index 0000000..7437124
--- /dev/null
+++ b/lib/b2g/plugin/b2g/accelerometer.js
@@ -0,0 +1,41 @@
+/*
+ *
+ * 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 cordova = require('cordova'),
+    callback;
+
+module.exports = {
+    start: function (win, fail, args) {
+        window.removeEventListener("devicemotion", callback);
+        callback = function (motion) {
+            win({
+                x: motion.accelerationIncludingGravity.x,
+                y: motion.accelerationIncludingGravity.y,
+                z: motion.accelerationIncludingGravity.z,
+                timestamp: motion.timestamp
+            });
+        };
+        window.addEventListener("devicemotion", callback);
+    },
+    stop: function (win, fail, args) {
+        window.removeEventListener("devicemotion", callback);
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/44c2a450/lib/b2g/plugin/b2g/device.js
----------------------------------------------------------------------
diff --git a/lib/b2g/plugin/b2g/device.js b/lib/b2g/plugin/b2g/device.js
new file mode 100644
index 0000000..5d9d36b
--- /dev/null
+++ b/lib/b2g/plugin/b2g/device.js
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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 channel = require('cordova/channel'),
+    cordova = require('cordova');
+
+// Tell cordova channel to wait on the CordovaInfoReady event
+channel.waitForInitialization('onCordovaInfoReady');
+
+module.exports = {
+    getDeviceInfo : function(win, fail, args){
+        win({
+            platform: "Firefox OS",
+            version: "0.0.1",
+            model: "Beta Phone",
+            name: "Beta Phone", // deprecated: please use device.model
+            uuid: "somestring",
+            cordova: "2.4.0rc1"
+        });
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/44c2a450/lib/b2g/plugin/b2g/network.js
----------------------------------------------------------------------
diff --git a/lib/b2g/plugin/b2g/network.js b/lib/b2g/plugin/b2g/network.js
new file mode 100644
index 0000000..9d3b218
--- /dev/null
+++ b/lib/b2g/plugin/b2g/network.js
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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 cordova = require('cordova');
+
+module.exports = {
+    getConnectionInfo: function (win, fail, args) {
+        win("3G");
+        return { "status": cordova.callbackStatus.OK, "message": "3G"};
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/44c2a450/lib/scripts/bootstrap-b2g.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-b2g.js b/lib/scripts/bootstrap-b2g.js
new file mode 100644
index 0000000..91a6f71
--- /dev/null
+++ b/lib/scripts/bootstrap-b2g.js
@@ -0,0 +1,22 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+require('cordova/channel').onNativeReady.fire();


Mime
View raw message