You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2012/04/20 02:21:40 UTC

[15/15] git commit: adding bada platform

adding bada platform


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

Branch: refs/heads/master
Commit: 293b8cc69af48ba651e6b9b31fa3a7871df01575
Parents: 38cd78f
Author: Anis Kadri <an...@gmail.com>
Authored: Tue Apr 17 14:14:17 2012 -0700
Committer: Anis Kadri <an...@gmail.com>
Committed: Tue Apr 17 14:14:17 2012 -0700

----------------------------------------------------------------------
 Jakefile                  |    1 +
 lib/bada/exec.js          |   16 +++++++
 lib/bada/platform.js      |   18 ++++++++
 lib/bada/plugin/device.js |   85 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 120 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/293b8cc6/Jakefile
----------------------------------------------------------------------
diff --git a/Jakefile b/Jakefile
index 3e62ff2..dd3a9b4 100644
--- a/Jakefile
+++ b/Jakefile
@@ -33,6 +33,7 @@ task('build', ['clean'], function () {
         packager.generate("ios",commitId);
         packager.generate("wp7",commitId);
         packager.generate("android",commitId);
+        packager.generate("bada",commitId);
         packager.generate("errgen",commitId);
         packager.generate("test",commitId);
         complete();

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/293b8cc6/lib/bada/exec.js
----------------------------------------------------------------------
diff --git a/lib/bada/exec.js b/lib/bada/exec.js
new file mode 100644
index 0000000..a18cb6e
--- /dev/null
+++ b/lib/bada/exec.js
@@ -0,0 +1,16 @@
+var plugins = {
+    "Device": require('bada/plugin/device'),
+};
+module.exports = {
+    exec: function(success, fail, service, action, args) {
+        try {
+            plugins[service][action](success, fail, args);
+        }
+        catch(e) {
+            console.log("missing exec: " + service + "." + action);
+            console.log(args);
+            console.log(e);
+            console.log(e.stack);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/293b8cc6/lib/bada/platform.js
----------------------------------------------------------------------
diff --git a/lib/bada/platform.js b/lib/bada/platform.js
new file mode 100644
index 0000000..bdf45a1
--- /dev/null
+++ b/lib/bada/platform.js
@@ -0,0 +1,18 @@
+module.exports = {
+    id: "bada",
+    initialize: function() {},
+    objects: {
+        device: {
+            path: 'cordova/plugin/bada/device'
+        }
+    },
+    merges: {
+        navigator: {
+            children: {
+                device: {
+                    path: "cordova/plugin/bada/device"
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/293b8cc6/lib/bada/plugin/device.js
----------------------------------------------------------------------
diff --git a/lib/bada/plugin/device.js b/lib/bada/plugin/device.js
new file mode 100644
index 0000000..36fc9f9
--- /dev/null
+++ b/lib/bada/plugin/device.js
@@ -0,0 +1,85 @@
+var channel = require('cordova/channel');
+
+function Device() {
+
+    this.platform = null;
+    this.version = null;
+    this.name = null;
+    this.uuid = null;
+    this.cordova = null
+
+    var me = this;
+    
+    channel.onCordovaReady.subscribeOnce(function() {
+        me.getInfo(function (device) {
+            me.platform = device.platform;
+            me.version  = device.version;
+            me.name     = device.name;
+            me.uuid     = device.uuid;
+            me.cordova  = device.cordova;
+
+            channel.onCordovaInfoReady.fire();
+        },
+        function (e) {
+            me.available = false;
+            console.log("error initializing cordova: " + e);
+        });
+    });
+};
+
+
+Device.prototype.getInfo = function(success, fail, args) {
+    console.log("getInfo");
+   var info = deviceapis.devicestatus;
+   var properties = ["name", "uuid", "os_name", "os_vendor", "os_version"];
+
+   var device = new Device();
+    
+   var name = null,
+       platform = null,
+       uuid = null,
+       os_name = null,
+       os_version = null,
+       os_vendor = null;
+
+   var checkProperties = function() {
+       properties.pop();
+       if(properties.length == 0) {
+           device.name = name;
+           device.platform = os_vendor + " " + os_name;
+           device.version = os_version;
+           device.uuid = uuid;
+           device.cordova = "1.6.0";
+           channel.onNativeReady().fire();
+           success(device);
+       }
+   };
+
+   info.getPropertyValue(function(value) {
+           console.log("Device IMEI: "+value);
+           uuid = value;
+           checkProperties();
+           }, fail, {aspect: "Device", property: "imei"});
+   info.getPropertyValue(function(value) {
+           console.log("Device name: "+value);
+           name = value;
+           checkProperties();
+           }, fail, {aspect: "Device", property: "version"});
+   info.getPropertyValue(function(value) {
+           console.log("OperatingSystem name: "+value);
+           os_name = value;
+           checkProperties();
+           }, fail, {aspect: "OperatingSystem", property: "name"});
+   info.getPropertyValue(function(value) {
+           console.log("OperatingSystem version: "+value);
+           os_version = value;
+           checkProperties();
+           }, fail, {aspect: "OperatingSystem", property: "version"});
+   info.getPropertyValue(function(value) {
+           console.log("OperatingSystem vendor: "+value);
+           os_vendor = value;
+           checkProperties();
+           }, fail, {aspect: "OperatingSystem", property: "vendor"});
+}
+
+module.exports = new Device();