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 EDC1E9BE5 for ; Fri, 6 Apr 2012 01:20:44 +0000 (UTC) Received: (qmail 49414 invoked by uid 500); 6 Apr 2012 01:20:44 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 49350 invoked by uid 500); 6 Apr 2012 01:20:44 -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 48815 invoked by uid 99); 6 Apr 2012 01:20:43 -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, 06 Apr 2012 01:20:43 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 3745BB52D; Fri, 6 Apr 2012 01:20:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: purplecabbage@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [25/40] git commit: Fixed case issue with CordovaCommandResult, device is the same implemenation as Android Message-Id: <20120406012043.3745BB52D@tyr.zones.apache.org> Date: Fri, 6 Apr 2012 01:20:43 +0000 (UTC) Fixed case issue with CordovaCommandResult, device is the same implemenation as Android 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/558a6325 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/558a6325 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/558a6325 Branch: refs/heads/master Commit: 558a632534591d25a48b23752b78a7ff58a93795 Parents: b1c58fa Author: Jesse MacFadyen Authored: Wed Mar 28 01:06:11 2012 -0700 Committer: Jesse MacFadyen Committed: Wed Mar 28 16:01:35 2012 -0700 ---------------------------------------------------------------------- lib/wp7/plugin/wp7/device.js | 78 +++++++++++++++++++++++++++++-------- 1 files changed, 62 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/558a6325/lib/wp7/plugin/wp7/device.js ---------------------------------------------------------------------- diff --git a/lib/wp7/plugin/wp7/device.js b/lib/wp7/plugin/wp7/device.js index 62587f8..ad3c9e7 100644 --- a/lib/wp7/plugin/wp7/device.js +++ b/lib/wp7/plugin/wp7/device.js @@ -3,26 +3,72 @@ * phone, etc. * @constructor */ -var Device = function() -{ +var exec = require('cordova/exec'), + channel = require('cordova/channel'); +var Cordova = require("cordova"); + +var Device = function() { this.platform = null; this.version = null; this.name = null; - this.phonegap = null; + this.cordova = null; this.uuid = null; - try { - this.platform = DeviceInfo.platform; - this.version = DeviceInfo.version; - this.name = DeviceInfo.name; - this.phonegap = DeviceInfo.gap; - this.uuid = DeviceInfo.uuid; - } - catch(e) { - // TODO: - - console.log("error in device.js : " + e); + + var me = this; + this.getInfo(function (res) { + console.log("Device.getInfo::" + res); + var info = JSON.parse(res); + console.log("GotDeviceInfo :: " + info.version); + me.available = true; + me.platform = info.platform; + me.version = info.version; + me.name = info.name; + me.uuid = info.uuid; + me.cordova = info.cordova; + + Cordova.onCordovaInfoReady.fire(); + }, + function(e) { + me.available = false; + console.log("Error initializing Cordova: " + e); + }); +}; + +/** + * Get device info + * + * @param {Function} successCallback The function to call when the heading data is available + * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL) + */ +Device.prototype.getInfo = function(successCallback, errorCallback) { + + // successCallback required + if (typeof successCallback !== "function") { + console.log("Device Error: successCallback is not a function"); + return; + } + + // errorCallback optional + if (errorCallback && (typeof errorCallback !== "function")) { + console.log("Device Error: errorCallback is not a function"); + return; + } + + // Get info + exec(successCallback, errorCallback, "Device", "Get"); +}; + +Device.prototype.setInfo = function(info) { + try { + this.platform = info.platform; + this.version = info.version; + this.name = info.name; + this.cordova = info.gap; + this.uuid = info.uuid; + channel.onCordovaInfoReady.fire(); + } catch(e) { + alert('Error during device info setting in cordova/plugin/ios/device!'); } - this.available = Cordova.available = !!this.uuid; }; -module.exports = new Device(); +module.exports = new Device;