From 65e7255c868bed3bb950e7e36ab786934edc559f Mon Sep 17 00:00:00 2001 From: PliablePixels Date: Thu, 25 Jun 2015 16:10:07 -0400 Subject: https now works with self-signed certificates (needs provisioning though) --- .../org.apache.cordova.file/www/DirectoryEntry.js | 108 ------ .../org.apache.cordova.file/www/DirectoryReader.js | 71 ---- plugins/org.apache.cordova.file/www/Entry.js | 224 ------------ plugins/org.apache.cordova.file/www/File.js | 77 ---- plugins/org.apache.cordova.file/www/FileEntry.js | 80 ----- plugins/org.apache.cordova.file/www/FileError.js | 46 --- plugins/org.apache.cordova.file/www/FileReader.js | 387 --------------------- plugins/org.apache.cordova.file/www/FileSystem.js | 38 -- .../www/FileUploadOptions.js | 41 --- .../www/FileUploadResult.js | 32 -- plugins/org.apache.cordova.file/www/FileWriter.js | 297 ---------------- plugins/org.apache.cordova.file/www/Flags.js | 36 -- .../org.apache.cordova.file/www/LocalFileSystem.js | 23 -- plugins/org.apache.cordova.file/www/Metadata.js | 31 -- .../org.apache.cordova.file/www/ProgressEvent.js | 67 ---- .../www/blackberry10/DirectoryEntry.js | 112 ------ .../www/blackberry10/DirectoryReader.js | 54 --- .../www/blackberry10/Entry.js | 120 ------- .../www/blackberry10/File.js | 56 --- .../www/blackberry10/FileEntry.js | 49 --- .../www/blackberry10/FileReader.js | 90 ----- .../www/blackberry10/FileSystem.js | 27 -- .../www/blackberry10/FileWriter.js | 120 ------- .../www/blackberry10/fileUtils.js | 52 --- .../www/blackberry10/requestFileSystem.js | 44 --- .../www/blackberry10/resolveLocalFileSystemURI.js | 55 --- plugins/org.apache.cordova.file/www/ios/Entry.js | 32 -- .../www/requestFileSystem.js | 61 ---- .../www/resolveLocalFileSystemURI.js | 64 ---- .../www/wp/FileUploadOptions.js | 49 --- 30 files changed, 2543 deletions(-) delete mode 100644 plugins/org.apache.cordova.file/www/DirectoryEntry.js delete mode 100644 plugins/org.apache.cordova.file/www/DirectoryReader.js delete mode 100644 plugins/org.apache.cordova.file/www/Entry.js delete mode 100644 plugins/org.apache.cordova.file/www/File.js delete mode 100644 plugins/org.apache.cordova.file/www/FileEntry.js delete mode 100644 plugins/org.apache.cordova.file/www/FileError.js delete mode 100644 plugins/org.apache.cordova.file/www/FileReader.js delete mode 100644 plugins/org.apache.cordova.file/www/FileSystem.js delete mode 100644 plugins/org.apache.cordova.file/www/FileUploadOptions.js delete mode 100644 plugins/org.apache.cordova.file/www/FileUploadResult.js delete mode 100644 plugins/org.apache.cordova.file/www/FileWriter.js delete mode 100644 plugins/org.apache.cordova.file/www/Flags.js delete mode 100644 plugins/org.apache.cordova.file/www/LocalFileSystem.js delete mode 100644 plugins/org.apache.cordova.file/www/Metadata.js delete mode 100644 plugins/org.apache.cordova.file/www/ProgressEvent.js delete mode 100644 plugins/org.apache.cordova.file/www/blackberry10/DirectoryEntry.js delete mode 100644 plugins/org.apache.cordova.file/www/blackberry10/DirectoryReader.js delete mode 100644 plugins/org.apache.cordova.file/www/blackberry10/Entry.js delete mode 100644 plugins/org.apache.cordova.file/www/blackberry10/File.js delete mode 100644 plugins/org.apache.cordova.file/www/blackberry10/FileEntry.js delete mode 100644 plugins/org.apache.cordova.file/www/blackberry10/FileReader.js delete mode 100644 plugins/org.apache.cordova.file/www/blackberry10/FileSystem.js delete mode 100644 plugins/org.apache.cordova.file/www/blackberry10/FileWriter.js delete mode 100644 plugins/org.apache.cordova.file/www/blackberry10/fileUtils.js delete mode 100644 plugins/org.apache.cordova.file/www/blackberry10/requestFileSystem.js delete mode 100644 plugins/org.apache.cordova.file/www/blackberry10/resolveLocalFileSystemURI.js delete mode 100644 plugins/org.apache.cordova.file/www/ios/Entry.js delete mode 100644 plugins/org.apache.cordova.file/www/requestFileSystem.js delete mode 100644 plugins/org.apache.cordova.file/www/resolveLocalFileSystemURI.js delete mode 100644 plugins/org.apache.cordova.file/www/wp/FileUploadOptions.js (limited to 'plugins/org.apache.cordova.file/www') diff --git a/plugins/org.apache.cordova.file/www/DirectoryEntry.js b/plugins/org.apache.cordova.file/www/DirectoryEntry.js deleted file mode 100644 index 053ef9a3..00000000 --- a/plugins/org.apache.cordova.file/www/DirectoryEntry.js +++ /dev/null @@ -1,108 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -var argscheck = require('cordova/argscheck'), - utils = require('cordova/utils'), - exec = require('cordova/exec'), - Entry = require('./Entry'), - FileError = require('./FileError'), - DirectoryReader = require('./DirectoryReader'); - -/** - * An interface representing a directory on the file system. - * - * {boolean} isFile always false (readonly) - * {boolean} isDirectory always true (readonly) - * {DOMString} name of the directory, excluding the path leading to it (readonly) - * {DOMString} fullPath the absolute full path to the directory (readonly) - * {FileSystem} filesystem on which the directory resides (readonly) - */ -var DirectoryEntry = function(name, fullPath, fileSystem) { - DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath, fileSystem); -}; - -utils.extend(DirectoryEntry, Entry); - -/** - * Creates a new DirectoryReader to read entries from this directory - */ -DirectoryEntry.prototype.createReader = function() { - return new DirectoryReader(this.fullPath); -}; - -/** - * Creates or looks up a directory - * - * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory - * @param {Flags} options to create or exclusively create the directory - * @param {Function} successCallback is called with the new entry - * @param {Function} errorCallback is called with a FileError - */ -DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) { - argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments); - var fs = this.filesystem; - var win = successCallback && function(result) { - var entry = new DirectoryEntry(result.name, result.fullPath, fs); - successCallback(entry); - }; - var fail = errorCallback && function(code) { - errorCallback(new FileError(code)); - }; - exec(win, fail, "File", "getDirectory", [this.fullPath, path, options]); -}; - -/** - * Deletes a directory and all of it's contents - * - * @param {Function} successCallback is called with no parameters - * @param {Function} errorCallback is called with a FileError - */ -DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) { - argscheck.checkArgs('FF', 'DirectoryEntry.removeRecursively', arguments); - var fail = errorCallback && function(code) { - errorCallback(new FileError(code)); - }; - exec(successCallback, fail, "File", "removeRecursively", [this.fullPath]); -}; - -/** - * Creates or looks up a file - * - * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file - * @param {Flags} options to create or exclusively create the file - * @param {Function} successCallback is called with the new entry - * @param {Function} errorCallback is called with a FileError - */ -DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) { - argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments); - var fs = this.filesystem; - var win = successCallback && function(result) { - var FileEntry = require('./FileEntry'); - var entry = new FileEntry(result.name, result.fullPath, fs); - successCallback(entry); - }; - var fail = errorCallback && function(code) { - errorCallback(new FileError(code)); - }; - exec(win, fail, "File", "getFile", [this.fullPath, path, options]); -}; - -module.exports = DirectoryEntry; diff --git a/plugins/org.apache.cordova.file/www/DirectoryReader.js b/plugins/org.apache.cordova.file/www/DirectoryReader.js deleted file mode 100644 index 07e7bf6b..00000000 --- a/plugins/org.apache.cordova.file/www/DirectoryReader.js +++ /dev/null @@ -1,71 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -var exec = require('cordova/exec'), - FileError = require('./FileError') ; - -/** - * An interface that lists the files and directories in a directory. - */ -function DirectoryReader(path) { - this.path = path || null; - this.hasReadEntries = false; -} - -/** - * Returns a list of entries from a directory. - * - * @param {Function} successCallback is called with a list of entries - * @param {Function} errorCallback is called with a FileError - */ -DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) { - // If we've already read and passed on this directory's entries, return an empty list. - if (this.hasReadEntries) { - successCallback([]); - return; - } - var reader = this; - var win = typeof successCallback !== 'function' ? null : function(result) { - var retVal = []; - for (var i=0; i= 2) { - if (end < 0) { - newEnd = Math.max(size + end, 0); - } else { - newEnd = Math.min(end, size); - } - } - - var newFile = new File(this.name, this.fullPath, this.type, this.lastModifiedData, this.size); - newFile.start = this.start + newStart; - newFile.end = this.start + newEnd; - return newFile; -}; - - -module.exports = File; diff --git a/plugins/org.apache.cordova.file/www/FileEntry.js b/plugins/org.apache.cordova.file/www/FileEntry.js deleted file mode 100644 index dc9352db..00000000 --- a/plugins/org.apache.cordova.file/www/FileEntry.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -var utils = require('cordova/utils'), - exec = require('cordova/exec'), - Entry = require('./Entry'), - FileWriter = require('./FileWriter'), - File = require('./File'), - FileError = require('./FileError'); - -/** - * An interface representing a file on the file system. - * - * {boolean} isFile always true (readonly) - * {boolean} isDirectory always false (readonly) - * {DOMString} name of the file, excluding the path leading to it (readonly) - * {DOMString} fullPath the absolute full path to the file (readonly) - * {FileSystem} filesystem on which the file resides (readonly) - */ -var FileEntry = function(name, fullPath, fileSystem) { - FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath, fileSystem]); -}; - -utils.extend(FileEntry, Entry); - -/** - * Creates a new FileWriter associated with the file that this FileEntry represents. - * - * @param {Function} successCallback is called with the new FileWriter - * @param {Function} errorCallback is called with a FileError - */ -FileEntry.prototype.createWriter = function(successCallback, errorCallback) { - this.file(function(filePointer) { - var writer = new FileWriter(filePointer); - - if (writer.fileName === null || writer.fileName === "") { - errorCallback && errorCallback(new FileError(FileError.INVALID_STATE_ERR)); - } else { - successCallback && successCallback(writer); - } - }, errorCallback); -}; - -/** - * Returns a File that represents the current state of the file that this FileEntry represents. - * - * @param {Function} successCallback is called with the new File object - * @param {Function} errorCallback is called with a FileError - */ -FileEntry.prototype.file = function(successCallback, errorCallback) { - var win = successCallback && function(f) { - var file = new File(f.name, f.fullPath, f.type, f.lastModifiedDate, f.size); - successCallback(file); - }; - var fail = errorCallback && function(code) { - errorCallback(new FileError(code)); - }; - exec(win, fail, "File", "getFileMetadata", [this.fullPath]); -}; - - -module.exports = FileEntry; diff --git a/plugins/org.apache.cordova.file/www/FileError.js b/plugins/org.apache.cordova.file/www/FileError.js deleted file mode 100644 index 6507921f..00000000 --- a/plugins/org.apache.cordova.file/www/FileError.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -/** - * FileError - */ -function FileError(error) { - this.code = error || null; -} - -// File error codes -// Found in DOMException -FileError.NOT_FOUND_ERR = 1; -FileError.SECURITY_ERR = 2; -FileError.ABORT_ERR = 3; - -// Added by File API specification -FileError.NOT_READABLE_ERR = 4; -FileError.ENCODING_ERR = 5; -FileError.NO_MODIFICATION_ALLOWED_ERR = 6; -FileError.INVALID_STATE_ERR = 7; -FileError.SYNTAX_ERR = 8; -FileError.INVALID_MODIFICATION_ERR = 9; -FileError.QUOTA_EXCEEDED_ERR = 10; -FileError.TYPE_MISMATCH_ERR = 11; -FileError.PATH_EXISTS_ERR = 12; - -module.exports = FileError; diff --git a/plugins/org.apache.cordova.file/www/FileReader.js b/plugins/org.apache.cordova.file/www/FileReader.js deleted file mode 100644 index 3cc75b5c..00000000 --- a/plugins/org.apache.cordova.file/www/FileReader.js +++ /dev/null @@ -1,387 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -var exec = require('cordova/exec'), - modulemapper = require('cordova/modulemapper'), - utils = require('cordova/utils'), - File = require('./File'), - FileError = require('./FileError'), - ProgressEvent = require('./ProgressEvent'), - origFileReader = modulemapper.getOriginalSymbol(this, 'FileReader'); - -/** - * This class reads the mobile device file system. - * - * For Android: - * The root directory is the root of the file system. - * To read from the SD card, the file name is "sdcard/my_file.txt" - * @constructor - */ -var FileReader = function() { - this._readyState = 0; - this._error = null; - this._result = null; - this._fileName = ''; - this._realReader = origFileReader ? new origFileReader() : {}; -}; - -// States -FileReader.EMPTY = 0; -FileReader.LOADING = 1; -FileReader.DONE = 2; - -utils.defineGetter(FileReader.prototype, 'readyState', function() { - return this._fileName ? this._readyState : this._realReader.readyState; -}); - -utils.defineGetter(FileReader.prototype, 'error', function() { - return this._fileName ? this._error: this._realReader.error; -}); - -utils.defineGetter(FileReader.prototype, 'result', function() { - return this._fileName ? this._result: this._realReader.result; -}); - -function defineEvent(eventName) { - utils.defineGetterSetter(FileReader.prototype, eventName, function() { - return this._realReader[eventName] || null; - }, function(value) { - this._realReader[eventName] = value; - }); -} -defineEvent('onloadstart'); // When the read starts. -defineEvent('onprogress'); // While reading (and decoding) file or fileBlob data, and reporting partial file data (progress.loaded/progress.total) -defineEvent('onload'); // When the read has successfully completed. -defineEvent('onerror'); // When the read has failed (see errors). -defineEvent('onloadend'); // When the request has completed (either in success or failure). -defineEvent('onabort'); // When the read has been aborted. For instance, by invoking the abort() method. - -function initRead(reader, file) { - // Already loading something - if (reader.readyState == FileReader.LOADING) { - throw new FileError(FileError.INVALID_STATE_ERR); - } - - reader._result = null; - reader._error = null; - reader._readyState = FileReader.LOADING; - - if (typeof file.fullPath == 'string') { - reader._fileName = file.fullPath; - } else { - reader._fileName = ''; - return true; - } - - reader.onloadstart && reader.onloadstart(new ProgressEvent("loadstart", {target:reader})); -} - -/** - * Abort reading file. - */ -FileReader.prototype.abort = function() { - if (origFileReader && !this._fileName) { - return this._realReader.abort(); - } - this._result = null; - - if (this._readyState == FileReader.DONE || this._readyState == FileReader.EMPTY) { - return; - } - - this._readyState = FileReader.DONE; - - // If abort callback - if (typeof this.onabort === 'function') { - this.onabort(new ProgressEvent('abort', {target:this})); - } - // If load end callback - if (typeof this.onloadend === 'function') { - this.onloadend(new ProgressEvent('loadend', {target:this})); - } -}; - -/** - * Read text file. - * - * @param file {File} File object containing file properties - * @param encoding [Optional] (see http://www.iana.org/assignments/character-sets) - */ -FileReader.prototype.readAsText = function(file, encoding) { - if (initRead(this, file)) { - return this._realReader.readAsText(file, encoding); - } - - // Default encoding is UTF-8 - var enc = encoding ? encoding : "UTF-8"; - var me = this; - var execArgs = [this._fileName, enc, file.start, file.end]; - - // Read file - exec( - // Success callback - function(r) { - // If DONE (cancelled), then don't do anything - if (me._readyState === FileReader.DONE) { - return; - } - - // Save result - me._result = r; - - // If onload callback - if (typeof me.onload === "function") { - me.onload(new ProgressEvent("load", {target:me})); - } - - // DONE state - me._readyState = FileReader.DONE; - - // If onloadend callback - if (typeof me.onloadend === "function") { - me.onloadend(new ProgressEvent("loadend", {target:me})); - } - }, - // Error callback - function(e) { - // If DONE (cancelled), then don't do anything - if (me._readyState === FileReader.DONE) { - return; - } - - // DONE state - me._readyState = FileReader.DONE; - - // null result - me._result = null; - - // Save error - me._error = new FileError(e); - - // If onerror callback - if (typeof me.onerror === "function") { - me.onerror(new ProgressEvent("error", {target:me})); - } - - // If onloadend callback - if (typeof me.onloadend === "function") { - me.onloadend(new ProgressEvent("loadend", {target:me})); - } - }, "File", "readAsText", execArgs); -}; - - -/** - * Read file and return data as a base64 encoded data url. - * A data url is of the form: - * data:[][;base64], - * - * @param file {File} File object containing file properties - */ -FileReader.prototype.readAsDataURL = function(file) { - if (initRead(this, file)) { - return this._realReader.readAsDataURL(file); - } - - var me = this; - var execArgs = [this._fileName, file.start, file.end]; - - // Read file - exec( - // Success callback - function(r) { - // If DONE (cancelled), then don't do anything - if (me._readyState === FileReader.DONE) { - return; - } - - // DONE state - me._readyState = FileReader.DONE; - - // Save result - me._result = r; - - // If onload callback - if (typeof me.onload === "function") { - me.onload(new ProgressEvent("load", {target:me})); - } - - // If onloadend callback - if (typeof me.onloadend === "function") { - me.onloadend(new ProgressEvent("loadend", {target:me})); - } - }, - // Error callback - function(e) { - // If DONE (cancelled), then don't do anything - if (me._readyState === FileReader.DONE) { - return; - } - - // DONE state - me._readyState = FileReader.DONE; - - me._result = null; - - // Save error - me._error = new FileError(e); - - // If onerror callback - if (typeof me.onerror === "function") { - me.onerror(new ProgressEvent("error", {target:me})); - } - - // If onloadend callback - if (typeof me.onloadend === "function") { - me.onloadend(new ProgressEvent("loadend", {target:me})); - } - }, "File", "readAsDataURL", execArgs); -}; - -/** - * Read file and return data as a binary data. - * - * @param file {File} File object containing file properties - */ -FileReader.prototype.readAsBinaryString = function(file) { - if (initRead(this, file)) { - return this._realReader.readAsBinaryString(file); - } - - var me = this; - var execArgs = [this._fileName, file.start, file.end]; - - // Read file - exec( - // Success callback - function(r) { - // If DONE (cancelled), then don't do anything - if (me._readyState === FileReader.DONE) { - return; - } - - // DONE state - me._readyState = FileReader.DONE; - - me._result = r; - - // If onload callback - if (typeof me.onload === "function") { - me.onload(new ProgressEvent("load", {target:me})); - } - - // If onloadend callback - if (typeof me.onloadend === "function") { - me.onloadend(new ProgressEvent("loadend", {target:me})); - } - }, - // Error callback - function(e) { - // If DONE (cancelled), then don't do anything - if (me._readyState === FileReader.DONE) { - return; - } - - // DONE state - me._readyState = FileReader.DONE; - - me._result = null; - - // Save error - me._error = new FileError(e); - - // If onerror callback - if (typeof me.onerror === "function") { - me.onerror(new ProgressEvent("error", {target:me})); - } - - // If onloadend callback - if (typeof me.onloadend === "function") { - me.onloadend(new ProgressEvent("loadend", {target:me})); - } - }, "File", "readAsBinaryString", execArgs); -}; - -/** - * Read file and return data as a binary data. - * - * @param file {File} File object containing file properties - */ -FileReader.prototype.readAsArrayBuffer = function(file) { - if (initRead(this, file)) { - return this._realReader.readAsArrayBuffer(file); - } - - var me = this; - var execArgs = [this._fileName, file.start, file.end]; - - // Read file - exec( - // Success callback - function(r) { - // If DONE (cancelled), then don't do anything - if (me._readyState === FileReader.DONE) { - return; - } - - // DONE state - me._readyState = FileReader.DONE; - - me._result = r; - - // If onload callback - if (typeof me.onload === "function") { - me.onload(new ProgressEvent("load", {target:me})); - } - - // If onloadend callback - if (typeof me.onloadend === "function") { - me.onloadend(new ProgressEvent("loadend", {target:me})); - } - }, - // Error callback - function(e) { - // If DONE (cancelled), then don't do anything - if (me._readyState === FileReader.DONE) { - return; - } - - // DONE state - me._readyState = FileReader.DONE; - - me._result = null; - - // Save error - me._error = new FileError(e); - - // If onerror callback - if (typeof me.onerror === "function") { - me.onerror(new ProgressEvent("error", {target:me})); - } - - // If onloadend callback - if (typeof me.onloadend === "function") { - me.onloadend(new ProgressEvent("loadend", {target:me})); - } - }, "File", "readAsArrayBuffer", execArgs); -}; - -module.exports = FileReader; diff --git a/plugins/org.apache.cordova.file/www/FileSystem.js b/plugins/org.apache.cordova.file/www/FileSystem.js deleted file mode 100644 index 76e3f89d..00000000 --- a/plugins/org.apache.cordova.file/www/FileSystem.js +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -var DirectoryEntry = require('./DirectoryEntry'); - -/** - * An interface representing a file system - * - * @constructor - * {DOMString} name the unique name of the file system (readonly) - * {DirectoryEntry} root directory of the file system (readonly) - */ -var FileSystem = function(name, root) { - this.name = name || null; - if (root) { - this.root = new DirectoryEntry(root.name, root.fullPath, this); - } -}; - -module.exports = FileSystem; diff --git a/plugins/org.apache.cordova.file/www/FileUploadOptions.js b/plugins/org.apache.cordova.file/www/FileUploadOptions.js deleted file mode 100644 index b2977de7..00000000 --- a/plugins/org.apache.cordova.file/www/FileUploadOptions.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -/** - * Options to customize the HTTP request used to upload files. - * @constructor - * @param fileKey {String} Name of file request parameter. - * @param fileName {String} Filename to be used by the server. Defaults to image.jpg. - * @param mimeType {String} Mimetype of the uploaded file. Defaults to image/jpeg. - * @param params {Object} Object with key: value params to send to the server. - * @param headers {Object} Keys are header names, values are header values. Multiple - * headers of the same name are not supported. - */ -var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers, httpMethod) { - this.fileKey = fileKey || null; - this.fileName = fileName || null; - this.mimeType = mimeType || null; - this.params = params || null; - this.headers = headers || null; - this.httpMethod = httpMethod || null; -}; - -module.exports = FileUploadOptions; diff --git a/plugins/org.apache.cordova.file/www/FileUploadResult.js b/plugins/org.apache.cordova.file/www/FileUploadResult.js deleted file mode 100644 index 294995f0..00000000 --- a/plugins/org.apache.cordova.file/www/FileUploadResult.js +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -/** - * FileUploadResult - * @constructor - */ -var FileUploadResult = function() { - this.bytesSent = 0; - this.responseCode = null; - this.response = null; -}; - -module.exports = FileUploadResult; diff --git a/plugins/org.apache.cordova.file/www/FileWriter.js b/plugins/org.apache.cordova.file/www/FileWriter.js deleted file mode 100644 index 44d7a322..00000000 --- a/plugins/org.apache.cordova.file/www/FileWriter.js +++ /dev/null @@ -1,297 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -var exec = require('cordova/exec'), - FileError = require('./FileError'), - ProgressEvent = require('./ProgressEvent'); - -/** - * This class writes to the mobile device file system. - * - * For Android: - * The root directory is the root of the file system. - * To write to the SD card, the file name is "sdcard/my_file.txt" - * - * @constructor - * @param file {File} File object containing file properties - * @param append if true write to the end of the file, otherwise overwrite the file - */ -var FileWriter = function(file) { - this.fileName = ""; - this.length = 0; - if (file) { - this.fileName = file.fullPath || file; - this.length = file.size || 0; - } - // default is to write at the beginning of the file - this.position = 0; - - this.readyState = 0; // EMPTY - - this.result = null; - - // Error - this.error = null; - - // Event handlers - this.onwritestart = null; // When writing starts - this.onprogress = null; // While writing the file, and reporting partial file data - this.onwrite = null; // When the write has successfully completed. - this.onwriteend = null; // When the request has completed (either in success or failure). - this.onabort = null; // When the write has been aborted. For instance, by invoking the abort() method. - this.onerror = null; // When the write has failed (see errors). -}; - -// States -FileWriter.INIT = 0; -FileWriter.WRITING = 1; -FileWriter.DONE = 2; - -/** - * Abort writing file. - */ -FileWriter.prototype.abort = function() { - // check for invalid state - if (this.readyState === FileWriter.DONE || this.readyState === FileWriter.INIT) { - throw new FileError(FileError.INVALID_STATE_ERR); - } - - // set error - this.error = new FileError(FileError.ABORT_ERR); - - this.readyState = FileWriter.DONE; - - // If abort callback - if (typeof this.onabort === "function") { - this.onabort(new ProgressEvent("abort", {"target":this})); - } - - // If write end callback - if (typeof this.onwriteend === "function") { - this.onwriteend(new ProgressEvent("writeend", {"target":this})); - } -}; - -/** - * Writes data to the file - * - * @param data text or blob to be written - */ -FileWriter.prototype.write = function(data) { - - var that=this; - var supportsBinary = (typeof window.Blob !== 'undefined' && typeof window.ArrayBuffer !== 'undefined'); - var isBinary; - - // Check to see if the incoming data is a blob - if (data instanceof File || (supportsBinary && data instanceof Blob)) { - var fileReader = new FileReader(); - fileReader.onload = function() { - // Call this method again, with the arraybuffer as argument - FileWriter.prototype.write.call(that, this.result); - }; - if (supportsBinary) { - fileReader.readAsArrayBuffer(data); - } else { - fileReader.readAsText(data); - } - return; - } - - // Mark data type for safer transport over the binary bridge - isBinary = supportsBinary && (data instanceof ArrayBuffer); - - // Throw an exception if we are already writing a file - if (this.readyState === FileWriter.WRITING) { - throw new FileError(FileError.INVALID_STATE_ERR); - } - - // WRITING state - this.readyState = FileWriter.WRITING; - - var me = this; - - // If onwritestart callback - if (typeof me.onwritestart === "function") { - me.onwritestart(new ProgressEvent("writestart", {"target":me})); - } - - // Write file - exec( - // Success callback - function(r) { - // If DONE (cancelled), then don't do anything - if (me.readyState === FileWriter.DONE) { - return; - } - - // position always increases by bytes written because file would be extended - me.position += r; - // The length of the file is now where we are done writing. - - me.length = me.position; - - // DONE state - me.readyState = FileWriter.DONE; - - // If onwrite callback - if (typeof me.onwrite === "function") { - me.onwrite(new ProgressEvent("write", {"target":me})); - } - - // If onwriteend callback - if (typeof me.onwriteend === "function") { - me.onwriteend(new ProgressEvent("writeend", {"target":me})); - } - }, - // Error callback - function(e) { - // If DONE (cancelled), then don't do anything - if (me.readyState === FileWriter.DONE) { - return; - } - - // DONE state - me.readyState = FileWriter.DONE; - - // Save error - me.error = new FileError(e); - - // If onerror callback - if (typeof me.onerror === "function") { - me.onerror(new ProgressEvent("error", {"target":me})); - } - - // If onwriteend callback - if (typeof me.onwriteend === "function") { - me.onwriteend(new ProgressEvent("writeend", {"target":me})); - } - }, "File", "write", [this.fileName, data, this.position, isBinary]); -}; - -/** - * Moves the file pointer to the location specified. - * - * If the offset is a negative number the position of the file - * pointer is rewound. If the offset is greater than the file - * size the position is set to the end of the file. - * - * @param offset is the location to move the file pointer to. - */ -FileWriter.prototype.seek = function(offset) { - // Throw an exception if we are already writing a file - if (this.readyState === FileWriter.WRITING) { - throw new FileError(FileError.INVALID_STATE_ERR); - } - - if (!offset && offset !== 0) { - return; - } - - // See back from end of file. - if (offset < 0) { - this.position = Math.max(offset + this.length, 0); - } - // Offset is bigger than file size so set position - // to the end of the file. - else if (offset > this.length) { - this.position = this.length; - } - // Offset is between 0 and file size so set the position - // to start writing. - else { - this.position = offset; - } -}; - -/** - * Truncates the file to the size specified. - * - * @param size to chop the file at. - */ -FileWriter.prototype.truncate = function(size) { - // Throw an exception if we are already writing a file - if (this.readyState === FileWriter.WRITING) { - throw new FileError(FileError.INVALID_STATE_ERR); - } - - // WRITING state - this.readyState = FileWriter.WRITING; - - var me = this; - - // If onwritestart callback - if (typeof me.onwritestart === "function") { - me.onwritestart(new ProgressEvent("writestart", {"target":this})); - } - - // Write file - exec( - // Success callback - function(r) { - // If DONE (cancelled), then don't do anything - if (me.readyState === FileWriter.DONE) { - return; - } - - // DONE state - me.readyState = FileWriter.DONE; - - // Update the length of the file - me.length = r; - me.position = Math.min(me.position, r); - - // If onwrite callback - if (typeof me.onwrite === "function") { - me.onwrite(new ProgressEvent("write", {"target":me})); - } - - // If onwriteend callback - if (typeof me.onwriteend === "function") { - me.onwriteend(new ProgressEvent("writeend", {"target":me})); - } - }, - // Error callback - function(e) { - // If DONE (cancelled), then don't do anything - if (me.readyState === FileWriter.DONE) { - return; - } - - // DONE state - me.readyState = FileWriter.DONE; - - // Save error - me.error = new FileError(e); - - // If onerror callback - if (typeof me.onerror === "function") { - me.onerror(new ProgressEvent("error", {"target":me})); - } - - // If onwriteend callback - if (typeof me.onwriteend === "function") { - me.onwriteend(new ProgressEvent("writeend", {"target":me})); - } - }, "File", "truncate", [this.fileName, size]); -}; - -module.exports = FileWriter; diff --git a/plugins/org.apache.cordova.file/www/Flags.js b/plugins/org.apache.cordova.file/www/Flags.js deleted file mode 100644 index a9ae6da3..00000000 --- a/plugins/org.apache.cordova.file/www/Flags.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -/** - * Supplies arguments to methods that lookup or create files and directories. - * - * @param create - * {boolean} file or directory if it doesn't exist - * @param exclusive - * {boolean} used with create; if true the command will fail if - * target path exists - */ -function Flags(create, exclusive) { - this.create = create || false; - this.exclusive = exclusive || false; -} - -module.exports = Flags; diff --git a/plugins/org.apache.cordova.file/www/LocalFileSystem.js b/plugins/org.apache.cordova.file/www/LocalFileSystem.js deleted file mode 100644 index 1e8f2eeb..00000000 --- a/plugins/org.apache.cordova.file/www/LocalFileSystem.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -exports.TEMPORARY = 0; -exports.PERSISTENT = 1; diff --git a/plugins/org.apache.cordova.file/www/Metadata.js b/plugins/org.apache.cordova.file/www/Metadata.js deleted file mode 100644 index bee26bda..00000000 --- a/plugins/org.apache.cordova.file/www/Metadata.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -/** - * Information about the state of the file or directory - * - * {Date} modificationTime (readonly) - */ -var Metadata = function(time) { - this.modificationTime = (typeof time != 'undefined'?new Date(time):null); -}; - -module.exports = Metadata; diff --git a/plugins/org.apache.cordova.file/www/ProgressEvent.js b/plugins/org.apache.cordova.file/www/ProgressEvent.js deleted file mode 100644 index f176f808..00000000 --- a/plugins/org.apache.cordova.file/www/ProgressEvent.js +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -// If ProgressEvent exists in global context, use it already, otherwise use our own polyfill -// Feature test: See if we can instantiate a native ProgressEvent; -// if so, use that approach, -// otherwise fill-in with our own implementation. -// -// NOTE: right now we always fill in with our own. Down the road would be nice if we can use whatever is native in the webview. -var ProgressEvent = (function() { - /* - var createEvent = function(data) { - var event = document.createEvent('Events'); - event.initEvent('ProgressEvent', false, false); - if (data) { - for (var i in data) { - if (data.hasOwnProperty(i)) { - event[i] = data[i]; - } - } - if (data.target) { - // TODO: cannot call .dispatchEvent - // need to first figure out how to implement EventTarget - } - } - return event; - }; - try { - var ev = createEvent({type:"abort",target:document}); - return function ProgressEvent(type, data) { - data.type = type; - return createEvent(data); - }; - } catch(e){ - */ - return function ProgressEvent(type, dict) { - this.type = type; - this.bubbles = false; - this.cancelBubble = false; - this.cancelable = false; - this.lengthComputable = false; - this.loaded = dict && dict.loaded ? dict.loaded : 0; - this.total = dict && dict.total ? dict.total : 0; - this.target = dict && dict.target ? dict.target : null; - }; - //} -})(); - -module.exports = ProgressEvent; diff --git a/plugins/org.apache.cordova.file/www/blackberry10/DirectoryEntry.js b/plugins/org.apache.cordova.file/www/blackberry10/DirectoryEntry.js deleted file mode 100644 index cb6628d5..00000000 --- a/plugins/org.apache.cordova.file/www/blackberry10/DirectoryEntry.js +++ /dev/null @@ -1,112 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -var argscheck = require('cordova/argscheck'), - utils = require('cordova/utils'), - Entry = require('./BB10Entry'), - FileError = require('./FileError'), - DirectoryReader = require('./BB10DirectoryReader'), - fileUtils = require('./BB10Utils'), - DirectoryEntry = function (name, fullPath, fileSystem) { - DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath, fileSystem); - }; - -utils.extend(DirectoryEntry, Entry); - -function err(sandboxState, errorCallback) { - return function (e) { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [sandboxState]); - errorCallback(e); - } -}; - -DirectoryEntry.prototype.createReader = function () { - return new DirectoryReader(this.fullPath); -}; - -DirectoryEntry.prototype.getDirectory = function (path, options, successCallback, errorCallback) { - var sandboxState, - currentPath = this.nativeEntry.fullPath; - - cordova.exec(function (sandboxed) { - sandboxState = sandboxed; - }, function (e) { - console.log("[ERROR]: Could not retrieve sandbox state ", e); - }, "org.apache.cordova.file", "isSandboxed"); - - argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments); - - if (fileUtils.isOutsideSandbox(path)) { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [false]); - window.webkitRequestFileSystem(window.PERSISTENT, this.filesystem._size, function (fs) { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [sandboxState]); - fs.root.getDirectory(currentPath + '/' + path, options, function (entry) { - successCallback(fileUtils.createEntry(entry)); - }, err(sandboxState, errorCallback)); - }, err(sandboxState, errorCallback)); - } else { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [true]); - window.webkitRequestFileSystem(fileUtils.getFileSystemName(this.filesystem) === "persistent" ? window.PERSISTENT : window.TEMPORARY, this.filesystem._size, function (fs) { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [sandboxState]); - fs.root.getDirectory(currentPath + '/' + path, options, function (entry) { - successCallback(fileUtils.createEntry(entry)); - }, err(sandboxState, errorCallback)); - }, err(sandboxState, errorCallback)); - } -}; - -DirectoryEntry.prototype.removeRecursively = function (successCallback, errorCallback) { - argscheck.checkArgs('FF', 'DirectoryEntry.removeRecursively', arguments); - this.nativeEntry.removeRecursively(successCallback, errorCallback); -}; - -DirectoryEntry.prototype.getFile = function (path, options, successCallback, errorCallback) { - var sandboxState, - currentPath = this.nativeEntry.fullPath; - - cordova.exec(function (sandboxed) { - sandboxState = sandboxed; - }, function (e) { - console.log("[ERROR]: Could not retrieve sandbox state ", e); - }, "org.apache.cordova.file", "isSandboxed"); - - argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments); - - if (fileUtils.isOutsideSandbox(path)) { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [false]); - window.webkitRequestFileSystem(window.PERSISTENT, this.filesystem._size, function (fs) { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [sandboxState]); - fs.root.getFile(currentPath + '/' + path, options, function (entry) { - successCallback(fileUtils.createEntry(entry)); - }, err(sandboxState, errorCallback)); - }, err(sandboxState, errorCallback)); - } else { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [true]); - window.webkitRequestFileSystem(fileUtils.getFileSystemName(this.filesystem) === "persistent" ? window.PERSISTENT: window.TEMPORARY, this.filesystem._size, function (fs) { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [sandboxState]); - fs.root.getFile(currentPath + '/' + path, options, function (entry) { - successCallback(fileUtils.createEntry(entry)); - }, err(sandboxState, errorCallback)); - }, err(sandboxState, errorCallback)); - } -}; - -module.exports = DirectoryEntry; diff --git a/plugins/org.apache.cordova.file/www/blackberry10/DirectoryReader.js b/plugins/org.apache.cordova.file/www/blackberry10/DirectoryReader.js deleted file mode 100644 index 6aa3d730..00000000 --- a/plugins/org.apache.cordova.file/www/blackberry10/DirectoryReader.js +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -var FileError = require('./FileError'), - fileUtils = require('./BB10Utils'); - -function DirectoryReader(path) { - this.path = path; - this.nativeReader = null; -} - -DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) { - var self = this, - win = typeof successCallback !== 'function' ? null : function(result) { - var retVal = []; - for (var i=0; i= 1000000000000000) { - fail(new FileError(FileError.QUOTA_EXCEEDED_ERR)); - } else if (type !== 1 && type !== 0) { - fail(new FileError(FileError.SYNTAX_ERR)); - } else { - window.webkitRequestFileSystem(type, size, function (fs) { - cordovaFsRoot = fileUtils.createEntry(fs.root); - cordovaFs = new FileSystem(fileUtils.getFileSystemName(fs), cordovaFsRoot); - cordovaFsRoot.filesystem = cordovaFs; - cordovaFs._size = size; - success(cordovaFs); - }, function (error) { - fail(new FileError(error)); - }); - } -}; diff --git a/plugins/org.apache.cordova.file/www/blackberry10/resolveLocalFileSystemURI.js b/plugins/org.apache.cordova.file/www/blackberry10/resolveLocalFileSystemURI.js deleted file mode 100644 index 4d5af613..00000000 --- a/plugins/org.apache.cordova.file/www/blackberry10/resolveLocalFileSystemURI.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -var fileUtils = require('./BB10Utils'), - FileError = require('./FileError'); - -function stripURI(uri) { - var rmFsLocal = uri.substring("filesystem:local:///".length); - return rmFsLocal.substring(rmFsLocal.indexOf('/') + 1); -} - -module.exports = function (uri, success, fail) { - var sandboxState, - decodedURI = decodeURI(uri); - - cordova.exec(function (sandboxed) { - sandboxState = sandboxed; - }, function (e) { - console.log("[ERROR]: Could not retrieve sandbox state ", e); - }, "org.apache.cordova.file", "isSandboxed"); - - if (fileUtils.isOutsideSandbox(stripURI(decodedURI))) { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [false]); - } else { - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [true]); - } - window.webkitResolveLocalFileSystemURL(decodedURI, function (entry) { - success(fileUtils.createEntry(entry)); - }, function (e) { - window.webkitResolveLocalFileSystemURL(decodedURI + '/', function (entry) { - success(fileUtils.createEntry(entry)); - }, function (e) { - fail(e); - }); - }); - cordova.exec(null, null, "org.apache.cordova.file", "setSandbox", [sandboxState]); -}; diff --git a/plugins/org.apache.cordova.file/www/ios/Entry.js b/plugins/org.apache.cordova.file/www/ios/Entry.js deleted file mode 100644 index bb8d43c7..00000000 --- a/plugins/org.apache.cordova.file/www/ios/Entry.js +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -module.exports = { - toURL:function() { - // TODO: refactor path in a cross-platform way so we can eliminate - // these kinds of platform-specific hacks. - return "file://localhost" + this.fullPath; - }, - toURI: function() { - console.log("DEPRECATED: Update your code to use 'toURL'"); - return "file://localhost" + this.fullPath; - } -}; diff --git a/plugins/org.apache.cordova.file/www/requestFileSystem.js b/plugins/org.apache.cordova.file/www/requestFileSystem.js deleted file mode 100644 index bad3291e..00000000 --- a/plugins/org.apache.cordova.file/www/requestFileSystem.js +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -var argscheck = require('cordova/argscheck'), - FileError = require('./FileError'), - FileSystem = require('./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) { - argscheck.checkArgs('nnFF', 'requestFileSystem', arguments); - var fail = function(code) { - errorCallback && 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 (successCallback) { - // 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, size]); - } -}; - -module.exports = requestFileSystem; diff --git a/plugins/org.apache.cordova.file/www/resolveLocalFileSystemURI.js b/plugins/org.apache.cordova.file/www/resolveLocalFileSystemURI.js deleted file mode 100644 index b5a0debb..00000000 --- a/plugins/org.apache.cordova.file/www/resolveLocalFileSystemURI.js +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -var argscheck = require('cordova/argscheck'), - DirectoryEntry = require('./DirectoryEntry'), - FileEntry = require('./FileEntry'), - FileError = require('./FileError'), - exec = require('cordova/exec'); - -/** - * Look up file system Entry referred to by local URI. - * @param {DOMString} uri URI referring to a local file or directory - * @param successCallback invoked with Entry object corresponding to URI - * @param errorCallback invoked if error occurs retrieving file system entry - */ -module.exports = function(uri, successCallback, errorCallback) { - argscheck.checkArgs('sFF', 'resolveLocalFileSystemURI', arguments); - // error callback - var fail = function(error) { - errorCallback && errorCallback(new FileError(error)); - }; - // sanity check for 'not:valid:filename' - if(!uri || uri.split(":").length > 2) { - setTimeout( function() { - fail(FileError.ENCODING_ERR); - },0); - return; - } - // if successful, return either a file or directory entry - var success = function(entry) { - var result; - if (entry) { - if (successCallback) { - // create appropriate Entry object - result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath) : new FileEntry(entry.name, entry.fullPath); - successCallback(result); - } - } - else { - // no Entry object returned - fail(FileError.NOT_FOUND_ERR); - } - }; - - exec(success, fail, "File", "resolveLocalFileSystemURI", [uri]); -}; diff --git a/plugins/org.apache.cordova.file/www/wp/FileUploadOptions.js b/plugins/org.apache.cordova.file/www/wp/FileUploadOptions.js deleted file mode 100644 index 696573ab..00000000 --- a/plugins/org.apache.cordova.file/www/wp/FileUploadOptions.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -/** - * Options to customize the HTTP request used to upload files. - * @constructor - * @param fileKey {String} Name of file request parameter. - * @param fileName {String} Filename to be used by the server. Defaults to image.jpg. - * @param mimeType {String} Mimetype of the uploaded file. Defaults to image/jpeg. - * @param params {Object} Object with key: value params to send to the server. - */ -var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers, httpMethod) { - this.fileKey = fileKey || null; - this.fileName = fileName || null; - this.mimeType = mimeType || null; - this.headers = headers || null; - this.httpMethod = httpMethod || null; - - if(params && typeof params != typeof "") { - var arrParams = []; - for(var v in params) { - arrParams.push(v + "=" + params[v]); - } - this.params = encodeURIComponent(arrParams.join("&")); - } - else { - this.params = params || null; - } -}; - -module.exports = FileUploadOptions; -- cgit v1.2.3