Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7E7249DD9 for ; Fri, 20 Apr 2012 00:21:41 +0000 (UTC) Received: (qmail 57386 invoked by uid 500); 20 Apr 2012 00:21:41 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 57328 invoked by uid 500); 20 Apr 2012 00:21:41 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 57077 invoked by uid 99); 20 Apr 2012 00:21:41 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Apr 2012 00:21:40 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 8E5B0DA44; Fri, 20 Apr 2012 00:21:40 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: anis@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [15/15] git commit: adding bada platform Message-Id: <20120420002140.8E5B0DA44@tyr.zones.apache.org> Date: Fri, 20 Apr 2012 00:21:40 +0000 (UTC) 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 Authored: Tue Apr 17 14:14:17 2012 -0700 Committer: Anis Kadri 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();