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 7DA119BD1 for ; Fri, 6 Apr 2012 01:20:43 +0000 (UTC) Received: (qmail 48620 invoked by uid 500); 6 Apr 2012 01:20:43 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 48576 invoked by uid 500); 6 Apr 2012 01:20:43 -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 48518 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 B81DEB50B; Fri, 6 Apr 2012 01:20:42 +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: [8/40] git commit: Monkey patched file API to use JSON encoded map of known values Message-Id: <20120406012042.B81DEB50B@tyr.zones.apache.org> Date: Fri, 6 Apr 2012 01:20:42 +0000 (UTC) Monkey patched file API to use JSON encoded map of known values 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/95a46c62 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/95a46c62 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/95a46c62 Branch: refs/heads/master Commit: 95a46c6211e7e258b94d182b172bdec075d49199 Parents: 0f9cb70 Author: Jesse MacFadyen Authored: Tue Apr 3 17:46:38 2012 -0700 Committer: Jesse MacFadyen Committed: Tue Apr 3 17:46:38 2012 -0700 ---------------------------------------------------------------------- lib/wp7/exec.js | 59 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 55 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/95a46c62/lib/wp7/exec.js ---------------------------------------------------------------------- diff --git a/lib/wp7/exec.js b/lib/wp7/exec.js index e90432e..8432e99 100644 --- a/lib/wp7/exec.js +++ b/lib/wp7/exec.js @@ -13,10 +13,56 @@ var cordova = require('cordova'); * @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 MonkeyPatch = +{ + File: + { + "getFileMetadata":function(arg) + { + return {fullPath:arg[0]}; + }, + "readAsText":function(arg) + { //[this.fileName, enc] + return {fileName:arg[0],encoding:arg[1]}; + }, + "readAsDataURL":function(arg) + { + return {fileName:arg[0]}; + }, + "getDirectory":function(arg) + { + return {fullPath:arg[0],path:arg[1],options:arg[2]}; + }, + "removeRecursively":function(arg) + { + return {fullPath:arg[0]}; + }, + "getFile":function(arg) + { + return {fullPath:arg[0],path:arg[1],options:arg[2]}; + }, + "readEntries":function(arg) + { + return {fullPath:arg[0]}; + }, + "write":function(arg) + { + return {fileName:arg[0],data:arg[1],position:arg[2]}; + }, + "truncate":function(arg) + { + return {fileName:arg[0],size:arg[1]}; + } + + } +}; module.exports = function(success, fail, service, action, args) { + var callbackId = service + cordova.callbackId++; if (typeof success == "function" || typeof fail == "function") { @@ -24,10 +70,15 @@ module.exports = function(success, fail, service, action, args) } // generate a new command string, ex. DebugConsole/log/DebugConsole23/{"message":"wtf dude?"} - if(args && args.length && args.length == 1) - { - args = args[0]; - } + if(MonkeyPatch[service] && MonkeyPatch[service][action]) + { + console.log("MonkeyPatching " + service + "." + action); + args = MonkeyPatch[service][action](args); + } + else if(args && args.length && args.length == 1) + { + args = args[0]; + } var command = service + "/" + action + "/" + callbackId + "/" + JSON.stringify(args); // pass it on to Notify