incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [9/40] git commit: exec fix for single item arrays, platform specific file apis
Date Fri, 06 Apr 2012 01:20:42 GMT
exec fix for single item arrays, platform specific file apis


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/0f9cb70e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/0f9cb70e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/0f9cb70e

Branch: refs/heads/master
Commit: 0f9cb70e5d3310117f0f50e680e7cd521e24120f
Parents: 6736142
Author: Jesse MacFadyen <purplecabbage@gmail.com>
Authored: Tue Apr 3 11:58:15 2012 -0700
Committer: Jesse MacFadyen <purplecabbage@gmail.com>
Committed: Tue Apr 3 11:58:15 2012 -0700

----------------------------------------------------------------------
 lib/wp7/exec.js                                 |    6 +++
 lib/wp7/platform.js                             |   15 ++++++
 lib/wp7/plugin/wp7/requestFileSystem.js         |   42 ++++++++++++++++++
 lib/wp7/plugin/wp7/resolveLocalFileSystemURI.js |   37 +++++++++++++++
 4 files changed, 100 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0f9cb70e/lib/wp7/exec.js
----------------------------------------------------------------------
diff --git a/lib/wp7/exec.js b/lib/wp7/exec.js
index 227a489..e90432e 100644
--- a/lib/wp7/exec.js
+++ b/lib/wp7/exec.js
@@ -23,6 +23,12 @@ module.exports = function(success, fail, service, action, args)
         cordova.callbacks[callbackId] = {success:success, fail:fail};
     }
     // generate a new command string, ex. DebugConsole/log/DebugConsole23/{"message":"wtf
dude?"}
+	
+	if(args && args.length && args.length == 1)
+	{
+		args = args[0];	
+	}
+	
      var command = service + "/" + action + "/" + callbackId + "/" + JSON.stringify(args);
      // pass it on to Notify
 	 try

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0f9cb70e/lib/wp7/platform.js
----------------------------------------------------------------------
diff --git a/lib/wp7/platform.js b/lib/wp7/platform.js
index 5989c77..f98bd1f 100644
--- a/lib/wp7/platform.js
+++ b/lib/wp7/platform.js
@@ -210,6 +210,21 @@ if(!window.localStorage)
 		CordovaCommandResult: {
 			path:"cordova/plugin/wp7/CordovaCommandResult"
 		},
+		requestFileSystem: {
+			path:"cordova/plugin/wp7/requestFileSystem"
+		},
+		resolveLocalFileSystemURI: {
+			path:"cordova/plugin/wp7/resolveLocalFileSystemURI"
+		},		
+		File: { 
+            path: "cordova/plugin/File"
+        },
+        FileReader: { 
+            path: "cordova/plugin/FileReader"
+        },
+        FileError: { 
+            path: "cordova/plugin/FileError"
+        },
         navigator: {
             children: {
                 device: {

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0f9cb70e/lib/wp7/plugin/wp7/requestFileSystem.js
----------------------------------------------------------------------
diff --git a/lib/wp7/plugin/wp7/requestFileSystem.js b/lib/wp7/plugin/wp7/requestFileSystem.js
new file mode 100644
index 0000000..a22d4a3
--- /dev/null
+++ b/lib/wp7/plugin/wp7/requestFileSystem.js
@@ -0,0 +1,42 @@
+
+var FileError = require('cordova/plugin/FileError'),
+    FileSystem = require('cordova/plugin/FileSystem'),
+    exec = require('cordova/exec');
+
+/**
+ * Request a file system in which to store application data.
+ * @param type  local file system type
+ * @param size  indicates how much storage space, in bytes, the application expects to need
+ * @param successCallback  invoked with a FileSystem object
+ * @param errorCallback  invoked if error occurs retrieving file system
+ */
+var requestFileSystem = function(type, size, successCallback, errorCallback) {
+	// wp7 custom imp
+    var fail = function(code) {
+        if (typeof errorCallback === 'function') {
+            errorCallback(new FileError(code));
+        }
+    };
+
+    if (type < 0 || type > 3) {
+        fail(FileError.SYNTAX_ERR);
+    } else {
+        // if successful, return a FileSystem object
+        var success = function(file_system) {
+            if (file_system) {
+                if (typeof successCallback === 'function') {
+                    // grab the name and root from the file system object
+                    var result = new FileSystem(file_system.name, file_system.root);
+                    successCallback(result);
+                }
+            }
+            else {
+                // no FileSystem object returned
+                fail(FileError.NOT_FOUND_ERR);
+            }
+        };
+        exec(success, fail, "File", "requestFileSystem", {type:type,size:size});
+    }
+};
+
+module.exports = requestFileSystem;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0f9cb70e/lib/wp7/plugin/wp7/resolveLocalFileSystemURI.js
----------------------------------------------------------------------
diff --git a/lib/wp7/plugin/wp7/resolveLocalFileSystemURI.js b/lib/wp7/plugin/wp7/resolveLocalFileSystemURI.js
new file mode 100644
index 0000000..f00c339
--- /dev/null
+++ b/lib/wp7/plugin/wp7/resolveLocalFileSystemURI.js
@@ -0,0 +1,37 @@
+
+
+var DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
+    FileEntry = require('cordova/plugin/FileEntry'),
+    exec = require('cordova/exec');
+	
+module.exports = function(uri, successCallback, errorCallback) {
+    // error callback
+    var fail = function(error) {
+        if (typeof errorCallback === 'function') {
+            errorCallback(new FileError(error));
+        }
+    };
+    // if successful, return either a file or directory entry
+    var success = function(entry) {
+        var result;
+
+        if (entry) {
+            if (typeof successCallback === 'function') {
+                // create appropriate Entry object
+                result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath)
: new FileEntry(entry.name, entry.fullPath);
+                try {
+                    successCallback(result);
+                }
+                catch (e) {
+                    console.log('Error invoking callback: ' + e);
+                }
+            }
+        }
+        else {
+            // no Entry object returned
+            fail(FileError.NOT_FOUND_ERR);
+        }
+    };
+
+    exec(success, fail, "File", "resolveLocalFileSystemURI", {uri:uri});
+};
\ No newline at end of file


Mime
View raw message