incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From long...@apache.org
Subject [3/4] qt commit: added /doc as the persistent file system starting point. some other Minor on file API.
Date Mon, 14 May 2012 21:02:40 GMT
added /doc as the persistent file system starting point. some other Minor on file API.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/commit/25dfdbd7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/tree/25dfdbd7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/diff/25dfdbd7

Branch: refs/heads/master
Commit: 25dfdbd78351506ac721838f770a03ec9ff13da2
Parents: 6c81771
Author: Longwei Su <lsu@ics.com>
Authored: Mon May 14 14:33:27 2012 -0400
Committer: Longwei Su <lsu@ics.com>
Committed: Mon May 14 14:33:27 2012 -0400

----------------------------------------------------------------------
 cordovaqt.pro           |    3 +-
 src/plugins/fileapi.cpp |   73 +++++--
 www/js/file.js          |  486 ++++++++++++++++++++++--------------------
 3 files changed, 308 insertions(+), 254 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/25dfdbd7/cordovaqt.pro
----------------------------------------------------------------------
diff --git a/cordovaqt.pro b/cordovaqt.pro
index 5b590ce..5ec963c 100644
--- a/cordovaqt.pro
+++ b/cordovaqt.pro
@@ -5,8 +5,9 @@
 wwwDir.source = www
 xmlDir.source = xml
 qmlDir.source = qml
+docDir.source = doc
 
-DEPLOYMENTFOLDERS = wwwDir xmlDir qmlDir # file1 dir1
+DEPLOYMENTFOLDERS = wwwDir xmlDir qmlDir docDir# file1 dir1
 
 
 SOURCES += main.cpp \

http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/25dfdbd7/src/plugins/fileapi.cpp
----------------------------------------------------------------------
diff --git a/src/plugins/fileapi.cpp b/src/plugins/fileapi.cpp
index 44a7279..62b8572 100644
--- a/src/plugins/fileapi.cpp
+++ b/src/plugins/fileapi.cpp
@@ -50,8 +50,8 @@ void FileAPI::requestFileSystem( int scId, int ecId, unsigned short p_type,
unsi
         absPath = dir.absolutePath();
     }
     else {
-        dir = QDir::home();
-        absPath = dir.absolutePath();
+        dir = QDir::current();
+        absPath = dir.absolutePath() + "/doc";
     }
 
     if (p_type == 0){
@@ -104,6 +104,23 @@ void FileAPI::resolveLocalFileSystemURL( int scId, int ecId, QString
p_url ) {
  */
 void FileAPI::getFile( int scId, int ecId, QString p_path, QVariantMap p_options ) {
     qDebug() << Q_FUNC_INFO << p_path;
+    //NOTE: colon is not safe in url, it is not a valid path in Win and Mac, simple disable
it here.
+    if(p_path.contains(":")){
+        this->callback( ecId, "FileException.cast( FileException.ENCODING_ERR )" );
+        return;
+    }
+    // Check if we have a valid URL
+    QUrl url = QUrl::fromUserInput( p_path );
+    if( !url.isValid() ) {
+        this->callback( ecId, "FileException.cast( FileException.ENCODING_ERR )" );
+        return;
+    }//FIXEME: invalid pass
+
+    // Check for the correct scheme
+    if( url.scheme() != "file" ) {
+        this->callback( ecId, "FileException.cast( FileException.TYPE_MISMATCH_ERR )"
);
+        return;
+    }
     bool create = p_options.value("create").toBool();
     bool exclusive = p_options.value("exclusive").toBool();
 
@@ -143,13 +160,32 @@ void FileAPI::getFile( int scId, int ecId, QString p_path, QVariantMap
p_options
  */
 void FileAPI::getDirectory( int scId, int ecId, QString p_path, QVariantMap p_options ) {
     qDebug() << Q_FUNC_INFO << p_path;
+    //NOTE: colon is not safe in url, it is not a valid path in Win and Mac, simple disable
it here.
+    if(p_path.contains(":")){
+        this->callback( ecId, "FileException.cast( FileException.ENCODING_ERR )" );
+    }
+    // Check if we have a valid URL
+    QUrl url = QUrl::fromUserInput( p_path );
+    if( !url.isValid()) {
+        this->callback( ecId, "FileException.cast( FileException.ENCODING_ERR )" );
+        return;
+    }//FIXEME: invalid pass
+
+    // Check for the correct scheme
+    if( url.scheme() != "file" ) {
+        this->callback( ecId, "FileException.cast( File:Exception.TYPE_MISMATCH_ERR )"
);
+        return;
+    }
     bool create = p_options.value("create").toBool();
     bool exclusive = p_options.value("exclusive").toBool();
 
     QDir dir( p_path );
 
     if( dir.exists() ) {
-        if( create && exclusive ) {
+        if (create && (!exclusive)){
+            this->callback( ecId, "FileException.cast( FileException.TYPE_MISMATCH_ERR
)" );
+            return;
+        } else if( create && exclusive ) {
             this->callback( ecId, "FileException.cast( FileException.PATH_EXISTS_ERR )"
);
             return;
         }
@@ -425,25 +461,26 @@ void FileAPI::readAsDataURL( int scId, int ecId, QString p_path ) {
  * Helper function for recursively removing a directory
  */
 bool FileAPI::rmDir( QDir p_dir ) {
-//        if( p_dir.exists() ) {
-//            // Iterate over entries and remove them
-//            Q_FOREACH( const QFileInfo &fileInfo, p_dir.entryInfoList( QDir::Dirs |
QDir::Files | QDir::NoDotAndDotDot ) ) {
-//                if( fileInfo.isDir() ) {
-//                    if( !FileAPI::rmDir( fileInfo.dir() ) ) {
-//                        return false;
-//                    }
+    qDebug() << Q_FUNC_INFO << p_dir;
+//    if( p_dir.exists() ) {
+//        // Iterate over entries and remove them
+//        Q_FOREACH( const QFileInfo &fileInfo, p_dir.entryInfoList( QDir::Dirs | QDir::Files
| QDir::NoDotAndDotDot ) ) {
+//            if( fileInfo.isDir() ) {
+//                if( !FileAPI::rmDir( fileInfo.dir() ) ) {
+//                    return false;
 //                }
-//                else {
-//                    if( !QFile::remove( fileInfo.absoluteFilePath() ) ) {
-//                        return false;
-//                    }
+//            }
+//            else {
+//                if( !QFile::remove( fileInfo.absoluteFilePath() ) ) {
+//                    return false;
 //                }
 //            }
-
-//            // Finally remove the current dir
-//            qDebug() << p_dir.absolutePath();
-//            return p_dir.rmdir( p_dir.absolutePath() );
 //        }
 
+//        // Finally remove the current dir
+//        qDebug() << p_dir.absolutePath();
+//        return p_dir.rmdir( p_dir.absolutePath() );
+//    }
+
     return false;
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/25dfdbd7/www/js/file.js
----------------------------------------------------------------------
diff --git a/www/js/file.js b/www/js/file.js
index 26dfd2d..4eaf7bd 100644
--- a/www/js/file.js
+++ b/www/js/file.js
@@ -22,11 +22,11 @@ function FileError() {
 }
 
 FileError.cast = function( p_code ) {
-        var fe = new FileError();
-        fe.code = p_code;
+            var fe = new FileError();
+            fe.code = p_code;
 
-        return fe;
-}
+            return fe;
+        }
 FileError.prototype.code = 0;
 FileError.NOT_FOUND_ERR = 1;
 FileError.SECURITY_ERR = 2;
@@ -50,11 +50,11 @@ function FileException() {
 }
 
 FileException.cast = function( p_code ) {
-        var fe = new FileException();
-        fe.code = p_code;
+            var fe = new FileException();
+            fe.code = p_code;
 
-        return fe;
-}
+            return fe;
+        }
 FileException.prototype.code = 0;
 FileException.NOT_FOUND_ERR = 1;
 FileException.SECURITY_ERR = 2;
@@ -74,16 +74,32 @@ FileException.PATH_EXISTS_ERR = 12;
  * FileMetadata (Metadata) interface
  * http://www.w3.org/TR/file-system-api/#idl-def-Metadata
  */
-function FileMetadata() {
+function Metadata(p_modificationDate ) {
+    this.modificationTime = p_modificationDate || null;
+    return this;
 }
 
-FileMetadata.cast = function( p_modificationDate ) {
-        var md = new FileMetadata();
-        md.modificationTime = p_modificationDate;
+Metadata.cast = function( p_modificationDate ) {
+            var md = new Metadata(p_modificationDate);
+            return md;
+        }
+
+
+function Flags(create, exclusive) {
+    this.create = create || false;
+    this.exclusive = exclusive || false;
+};
+
+Flags.cast = function( p_modificationDate ) {
+            var md = new Metadata(p_modificationDate);
+            return md;
+        }
+Flags.cast = function(create, exclusive) {
+            var that = new Flags(create, exclusive);
+            return that;
+        };
+
 
-        return md;
-}
-FileMetadata.prototype.modificationTime = null;
 
 /**
  * Entry interface
@@ -97,24 +113,24 @@ Entry.prototype.name = "";
 Entry.prototype.fullPath = "";//fullpath for cordova-test = realFullPath - "/"
 Entry.prototype.filesystem = null;
 Entry.prototype.getMetadata = function( successCallback, errorCallback ) {
-        // Get metadata for this entry
-        Cordova.exec(successCallback, errorCallback, "com.cordova.File", "getMetadata", [this.fullPath]);
-}
+            // Get metadata for this entry
+            Cordova.exec(successCallback, errorCallback, "com.cordova.File", "getMetadata",
[this.fullPath]);
+        }
 Entry.prototype.moveTo = function( parent, newName, successCallback, errorCallback ) {
-}
+        }
 Entry.prototype.copyTo = function( parent, newName, successCallback, errorCallback ) {
-}
+        }
 Entry.prototype.toURL = function( mimeType ) {
-        return "file://" + this.fullPath;
-}
+            return "file://" + this.fullPath;
+        }
 Entry.prototype.remove = function( successCallback, errorCallback ) {
-        // Remove this entry
-        Cordova.exec(successCallback, errorCallback, "com.cordova.File", "remove", [this.fullPath]);
-}
+            // Remove this entry
+            Cordova.exec(successCallback, errorCallback, "com.cordova.File", "remove", [this.fullPath]);
+        }
 Entry.prototype.getParent = function( successCallback, errorCallback ) {
-        // Ask the system for our parent
-        Cordova.exec(successCallback, errorCallback, "com.cordova.File", "getParent", [this.fullPath]);
-}
+            // Ask the system for our parent
+            Cordova.exec(successCallback, errorCallback, "com.cordova.File", "getParent",
[this.fullPath]);
+        }
 
 /**
  * FileInfo (File) interface
@@ -125,15 +141,15 @@ function FileInfo() {
 }
 
 FileInfo.cast = function( p_name, p_fullPath, p_type, p_lastModifiedDate, p_size ) {
-        var f = new FileInfo();
-        f.name = p_name;
-        f.fullPath = p_fullPath;
-        f.type = p_type;
-        f.lastModifiedDate = p_lastModifiedDate;
-        f.size = p_size;
-
-        return f;
-}
+            var f = new FileInfo();
+            f.name = p_name;
+            f.fullPath = p_fullPath;
+            f.type = p_type;
+            f.lastModifiedDate = p_lastModifiedDate;
+            f.size = p_size;
+
+            return f;
+        }
 FileInfo.prototype.name = "";
 FileInfo.prototype.fullPath = "";
 FileInfo.prototype.type = "unknown/unknown";
@@ -148,24 +164,24 @@ function FileSaver() {
 }
 
 FileSaver.createEvent = function( p_type, p_target ) {
-        var evt = {
+            var evt = {
                 "type": p_type,
                 "target": p_target
-        };
+            };
 
-        return evt;
-}
+            return evt;
+        }
 
 FileSaver.prototype.abort = function() {
-        if( this.readyState == FileSaver.INIT || this.readyState == FileSaver.DONE ) throw
FileException.cast(FileException.INVALID_STATE_ERR);
+            if( this.readyState == FileSaver.INIT || this.readyState == FileSaver.DONE )
throw FileException.cast(FileException.INVALID_STATE_ERR);
 
-        this.error = FileError.cast(FileError.ABORT_ERR);
-        this.readyState = FileSaver.DONE;
+            this.error = FileError.cast(FileError.ABORT_ERR);
+            this.readyState = FileSaver.DONE;
 
-        if( typeof this.onerror === "function" ) this.onerror(FileSaver.createEvent("error",
this));
-        if( typeof this.onabort === "function" ) this.onabort(FileSaver.createEvent("abort",
this));
-        if( typeof this.onwriteend === "function" ) this.onwriteend(FileSaver.createEvent("writeend",
this));
-}
+            if( typeof this.onerror === "function" ) this.onerror(FileSaver.createEvent("error",
this));
+            if( typeof this.onabort === "function" ) this.onabort(FileSaver.createEvent("abort",
this));
+            if( typeof this.onwriteend === "function" ) this.onwriteend(FileSaver.createEvent("writeend",
this));
+        }
 
 FileSaver.INIT = 0;
 FileSaver.WRITING = 1;
@@ -191,105 +207,105 @@ function FileWriter() {
 }
 
 FileWriter.cast = function( p_fullPath, p_length ) {
-        var fw = new FileWriter();
-        fw.fullPath = p_fullPath;
-        fw.length = p_length;
+            var fw = new FileWriter();
+            fw.fullPath = p_fullPath;
+            fw.length = p_length;
 
-        return fw;
-}
+            return fw;
+        }
 
 FileWriter.prototype = new FileSaver();
 FileWriter.prototype.position = 0;
 FileWriter.prototype.length = 0;
 FileWriter.prototype.write = function( data ) {
-        //console.log( 'Calling write: ' + this.position + " / " + this.length );
-
-        // Check if we are able to write
-        if( this.readyState == FileSaver.WRITING ) throw FileException.cast(FileException.INVALID_STATE_ERR);
-        // We are writing now
-        this.readyState = FileSaver.WRITING;
-        // Emit the start event
-        if( typeof this.onwritestart === "function" ) this.onwritestart( FileSaver.createEvent("writestart",
this) );
-
-        // Finally do the writing
-        var me = this;
-        Cordova.exec(function(p_position, p_length) {
-                // Update position & length for file
-                me.position = p_position;
-                me.length = p_length;
-
-                // Update state
-                me.readyState = FileSaver.DONE;
-
-                // Dispatch missing events
-                if( typeof me.onwrite === "function" ) me.onwrite( FileSaver.createEvent("write",
me) );
-                if( typeof me.onwriteend === "function" ) me.onwriteend( FileSaver.createEvent("writeend",
me) );
-        }, function( p_fileError, p_position, p_length ) {
-                // Update position & length for file
-                me.position = p_position;
-                me.length = p_length;
-
-                // Set error object & update state
-                me.error = p_fileError;
-                me.readyState = FileSaver.DONE;
-
-                // Dispatch missing events
-                if( typeof me.onerror === "function" ) me.onerror( FileWriter.createEvent("error",
me) );
-                if( typeof me.onwriteend === "function" ) me.onwriteend( FileWriter.createEvent("writeend",
me) );
-        }, "com.cordova.File", "write", [this.fullPath, this.position, data]);
-}
+            //console.log( 'Calling write: ' + this.position + " / " + this.length );
+
+            // Check if we are able to write
+            if( this.readyState == FileSaver.WRITING ) throw FileException.cast(FileException.INVALID_STATE_ERR);
+            // We are writing now
+            this.readyState = FileSaver.WRITING;
+            // Emit the start event
+            if( typeof this.onwritestart === "function" ) this.onwritestart( FileSaver.createEvent("writestart",
this) );
+
+            // Finally do the writing
+            var me = this;
+            Cordova.exec(function(p_position, p_length) {
+                             // Update position & length for file
+                             me.position = p_position;
+                             me.length = p_length;
+
+                             // Update state
+                             me.readyState = FileSaver.DONE;
+
+                             // Dispatch missing events
+                             if( typeof me.onwrite === "function" ) me.onwrite( FileSaver.createEvent("write",
me) );
+                             if( typeof me.onwriteend === "function" ) me.onwriteend( FileSaver.createEvent("writeend",
me) );
+                         }, function( p_fileError, p_position, p_length ) {
+                             // Update position & length for file
+                             me.position = p_position;
+                             me.length = p_length;
+
+                             // Set error object & update state
+                             me.error = p_fileError;
+                             me.readyState = FileSaver.DONE;
+
+                             // Dispatch missing events
+                             if( typeof me.onerror === "function" ) me.onerror( FileWriter.createEvent("error",
me) );
+                             if( typeof me.onwriteend === "function" ) me.onwriteend( FileWriter.createEvent("writeend",
me) );
+                         }, "com.cordova.File", "write", [this.fullPath, this.position, data]);
+        }
 
 FileWriter.prototype.seek = function( offset ) {
-        //console.log( 'Calling seek: ' + offset + " / " + this.position + " / " + this.length
+ " / " + this.readyState );
+            //console.log( 'Calling seek: ' + offset + " / " + this.position + " / " + this.length
+ " / " + this.readyState );
 
-        if( this.readyState == FileSaver.WRITING ) throw FileException.cast(FileException.INVALID_STATE_ERR);
+            if( this.readyState == FileSaver.WRITING ) throw FileException.cast(FileException.INVALID_STATE_ERR);
 
-        if( offset < 0 ) {
+            if( offset < 0 ) {
                 this.position = offset + this.length;
-        }
-        else if( offset > this.length ) {
+            }
+            else if( offset > this.length ) {
                 this.position = this.length;
-        }
-        else {
+            }
+            else {
                 this.position = offset;
+            }
         }
-}
 
 FileWriter.prototype.truncate = function( size ) {
-        // Check if we are able to write
-        if( this.readyState == FileSaver.WRITING ) throw FileException.cast(FileException.INVALID_STATE_ERR);
-        // We are writing now
-        this.readyState = FileSaver.WRITING;
-        // Emit the start event
-        if( typeof this.onwritestart === "function" ) this.onwritestart( FileSaver.createEvent("writestart",
this) );
-
-        // Finally do the writing
-        var me = this;
-        Cordova.exec(function(p_position, p_length) {
-                // Update position & length for file
-                me.position = p_position;
-                me.length = p_length;
-
-                // Update state
-                me.readyState = FileSaver.DONE;
-
-                // Dispatch missing events
-                if( typeof me.onwrite === "function" ) me.onwrite( FileSaver.createEvent("write",
me) );
-                if( typeof me.onwriteend === "function" ) me.onwriteend( FileSaver.createEvent("writeend",
me) );
-        }, function( p_fileError, p_position, p_length ) {
-                // Update position & length for file
-                me.position = p_position;
-                me.length = p_length;
-
-                // Set error object & update state
-                me.error = p_fileError;
-                me.readyState = FileSaver.DONE;
-
-                // Dispatch missing events
-                if( typeof me.onerror === "function" ) me.onerror( FileSaver.createEvent("error",
me) );
-                if( typeof me.onwriteend === "function" ) me.onwriteend( FileSaver.createEvent("writeend",
me) );
-        }, "com.cordova.File", "truncate", [this.fullPath, size]);
-}
+            // Check if we are able to write
+            if( this.readyState == FileSaver.WRITING ) throw FileException.cast(FileException.INVALID_STATE_ERR);
+            // We are writing now
+            this.readyState = FileSaver.WRITING;
+            // Emit the start event
+            if( typeof this.onwritestart === "function" ) this.onwritestart( FileSaver.createEvent("writestart",
this) );
+
+            // Finally do the writing
+            var me = this;
+            Cordova.exec(function(p_position, p_length) {
+                             // Update position & length for file
+                             me.position = p_position;
+                             me.length = p_length;
+
+                             // Update state
+                             me.readyState = FileSaver.DONE;
+
+                             // Dispatch missing events
+                             if( typeof me.onwrite === "function" ) me.onwrite( FileSaver.createEvent("write",
me) );
+                             if( typeof me.onwriteend === "function" ) me.onwriteend( FileSaver.createEvent("writeend",
me) );
+                         }, function( p_fileError, p_position, p_length ) {
+                             // Update position & length for file
+                             me.position = p_position;
+                             me.length = p_length;
+
+                             // Set error object & update state
+                             me.error = p_fileError;
+                             me.readyState = FileSaver.DONE;
+
+                             // Dispatch missing events
+                             if( typeof me.onerror === "function" ) me.onerror( FileSaver.createEvent("error",
me) );
+                             if( typeof me.onwriteend === "function" ) me.onwriteend( FileSaver.createEvent("writeend",
me) );
+                         }, "com.cordova.File", "truncate", [this.fullPath, size]);
+        }
 
 /**
  * FileReader interface
@@ -313,69 +329,69 @@ FileReader.prototype.onerror = null;
 FileReader.prototype.onloadend = null;
 
 FileReader.prototype.readAsArrayBuffer = function( file ) {
-}
+        }
 FileReader.prototype.readAsBinaryString = function( file ) {
-}
+        }
 FileReader.prototype.readAsText = function( file ) {
-        this.readyState = FileReader.EMPTY;
-        this.result = null;
+            this.readyState = FileReader.EMPTY;
+            this.result = null;
 
-        this.readyState = FileReader.LOADING;
+            this.readyState = FileReader.LOADING;
 
-        if( typeof this.onloadstart === "function" ) this.onloadstart( FileSaver.createEvent(
"loadstart", this) );
+            if( typeof this.onloadstart === "function" ) this.onloadstart( FileSaver.createEvent(
"loadstart", this) );
 
-        var me = this;
+            var me = this;
 
-        // Lets read the file...
-        Cordova.exec(function( p_data ) {
-                me.readyState = FileReader.DONE;
-                me.result = atob( p_data );
+            // Lets read the file...
+            Cordova.exec(function( p_data ) {
+                             me.readyState = FileReader.DONE;
+                             me.result = atob( p_data );
 
-                if( typeof me.onload === "function" ) me.onload( FileSaver.createEvent( "load",
me) );
-                if( typeof me.onloadend === "function" ) me.onloadend( FileSaver.createEvent(
"loadend", me) );
-        }, function( p_fileError ) {
-                me.readyState = FileReader.DONE;
-                me.result = null;
-                me.error = p_fileError;
+                             if( typeof me.onload === "function" ) me.onload( FileSaver.createEvent(
"load", me) );
+                             if( typeof me.onloadend === "function" ) me.onloadend( FileSaver.createEvent(
"loadend", me) );
+                         }, function( p_fileError ) {
+                             me.readyState = FileReader.DONE;
+                             me.result = null;
+                             me.error = p_fileError;
 
-                if( typeof me.onloadend === "function" ) me.onloadend( FileSaver.createEvent(
"loadend", me) );
-                if( typeof me.onerror === "function" ) me.onerror( FileSaver.createEvent(
"error", me) );
-        }, "com.cordova.File", "readAsDataURL", [file.fullPath]);
-}
+                             if( typeof me.onloadend === "function" ) me.onloadend( FileSaver.createEvent(
"loadend", me) );
+                             if( typeof me.onerror === "function" ) me.onerror( FileSaver.createEvent(
"error", me) );
+                         }, "com.cordova.File", "readAsDataURL", [file.fullPath]);
+        }
 FileReader.prototype.readAsDataURL = function( file ) {
-        this.readyState = FileReader.EMPTY;
-        this.result = null;
+            this.readyState = FileReader.EMPTY;
+            this.result = null;
 
-        this.readyState = FileReader.LOADING;
+            this.readyState = FileReader.LOADING;
 
-        if( typeof this.onloadstart === "function" ) this.onloadstart( FileSaver.createEvent(
"loadstart", this) );
+            if( typeof this.onloadstart === "function" ) this.onloadstart( FileSaver.createEvent(
"loadstart", this) );
 
-        var me = this;
+            var me = this;
 
-        // Lets read the file...
-        Cordova.exec(function( p_data ) {
-                me.readyState = FileReader.DONE;
-                me.result = p_data;
+            // Lets read the file...
+            Cordova.exec(function( p_data ) {
+                             me.readyState = FileReader.DONE;
+                             me.result = p_data;
 
-                if( typeof me.onloadend === "function" ) me.onloadend( FileSaver.createEvent(
"loadend", me) );
-        }, function( p_fileError ) {
-                me.readyState = FileReader.DONE;
-                me.result = null;
-                me.error = p_fileError;
+                             if( typeof me.onloadend === "function" ) me.onloadend( FileSaver.createEvent(
"loadend", me) );
+                         }, function( p_fileError ) {
+                             me.readyState = FileReader.DONE;
+                             me.result = null;
+                             me.error = p_fileError;
 
-                if( typeof me.onloadend === "function" ) me.onloadend( FileSaver.createEvent(
"loadend", me) );
-                if( typeof me.onerror === "function" ) me.onerror( FileSaver.createEvent(
"error", me) );
-        }, "com.cordova.File", "readAsDataURL", [file.fullPath]);
-}
+                             if( typeof me.onloadend === "function" ) me.onloadend( FileSaver.createEvent(
"loadend", me) );
+                             if( typeof me.onerror === "function" ) me.onerror( FileSaver.createEvent(
"error", me) );
+                         }, "com.cordova.File", "readAsDataURL", [file.fullPath]);
+        }
 FileReader.prototype.abort = function() {
-        this.readyState = FileReader.DONE;
-        this.result = null;
-        this.error = FileError.cast( FileError.ABORT_ERR );
+            this.readyState = FileReader.DONE;
+            this.result = null;
+            this.error = FileError.cast( FileError.ABORT_ERR );
 
-        if( typeof this.onerror === "function" ) this.onerror( FileSaver.createEvent( "error",
me) ) ;
-        if( typeof this.onabort === "function" ) this.onabort( FileSaver.createEvent( "abort",
me) ) ;
-        if( typeof this.onloadend === "function" ) this.onloadend( FileSaver.createEvent(
"loadend", me) ) ;
-}
+            if( typeof this.onerror === "function" ) this.onerror( FileSaver.createEvent(
"error", me) ) ;
+            if( typeof this.onabort === "function" ) this.onabort( FileSaver.createEvent(
"abort", me) ) ;
+            if( typeof this.onloadend === "function" ) this.onloadend( FileSaver.createEvent(
"loadend", me) ) ;
+        }
 
 
 /**
@@ -384,28 +400,28 @@ FileReader.prototype.abort = function() {
  * http://www.w3.org/TR/file-system-api/#the-fileentry-interface
  */
 function FileEntry() {
-        this.isFile = true;
-        this.isDirectory = false;
+    this.isFile = true;
+    this.isDirectory = false;
 }
 
 FileEntry.cast = function( filename, path ) {
-        var fe = new FileEntry();
-        fe.name = filename;
-        fe.fullPath = path;
+            var fe = new FileEntry();
+            fe.name = filename;
+            fe.fullPath = path;
 
-        return fe;
-}
+            return fe;
+        }
 
 FileEntry.prototype = new Entry();
 FileEntry.prototype.createWriter = function( successCallback, errorCallback ) {
-        this.file( function(p_file) {
-                successCallback(FileWriter.cast(p_file.fullPath, p_file.size));
-        }, errorCallback);
-}
+            this.file( function(p_file) {
+                          successCallback(FileWriter.cast(p_file.fullPath, p_file.size));
+                      }, errorCallback);
+        }
 FileEntry.prototype.file = function( successCallback, errorCallback ) {
-        // Lets get the fileinfo
-        Cordova.exec(successCallback, errorCallback, "com.cordova.File", "file", [this.fullPath]);
-}
+            // Lets get the fileinfo
+            Cordova.exec(successCallback, errorCallback, "com.cordova.File", "file", [this.fullPath]);
+        }
 
 /**
  * DirectoryReader interface
@@ -415,17 +431,17 @@ function DirectoryReader() {
 }
 
 DirectoryReader.cast = function( p_fullPath ) {
-        var dr = new DirectoryReader();
-        dr.fullPath = p_fullPath;
+            var dr = new DirectoryReader();
+            dr.fullPath = p_fullPath;
 
-        return dr;
-}
+            return dr;
+        }
 
 DirectoryReader.prototype.fullPath = "";	// Not W3C conform, but required
 DirectoryReader.prototype.readEntries = function( successCallback, errorCallback ) {
-        // Get all entries for the directory
-        Cordova.exec(successCallback, errorCallback, "com.cordova.File", "readEntries", [this.fullPath]);
-}
+            // Get all entries for the directory
+            Cordova.exec(successCallback, errorCallback, "com.cordova.File", "readEntries",
[this.fullPath]);
+        }
 
 /**
  * DirectoryEntry interface
@@ -433,43 +449,43 @@ DirectoryReader.prototype.readEntries = function( successCallback, errorCallback
  * http://www.w3.org/TR/file-system-api/#the-directoryentry-interface
  */
 function DirectoryEntry() {
-        this.isFile = false;
-        this.isDirectory = true;
+    this.isFile = false;
+    this.isDirectory = true;
 }
 
 DirectoryEntry.cast = function( dirname, path ) {
-        var de = new DirectoryEntry();
-        de.name = dirname;
-        de.fullPath = path;
-        return de;
-}
+            var de = new DirectoryEntry();
+            de.name = dirname;
+            de.fullPath = path;
+            return de;
+        }
 
 DirectoryEntry.prototype = new Entry();
 DirectoryEntry.prototype.createReader = function() {
-        return DirectoryReader.cast(this.fullPath);
-}
+            return DirectoryReader.cast(this.fullPath);
+        }
 DirectoryEntry.prototype.getFile = function( path, options, successCallback, errorCallback
) {
-        var requestPath = path;
+            var requestPath = path;
 
-        // Check for a relative path
-        if( requestPath.charAt(0) != '/' ) requestPath = this.fullPath + "/" + requestPath;
+            // Check for a relative path
+            if( requestPath.charAt(0) != '/' ) requestPath = this.fullPath + "/" + requestPath;
 
-        // Lets get the file
-        Cordova.exec(successCallback, errorCallback, "com.cordova.File", "getFile", [requestPath,
options]);
-}
+            // Lets get the file
+            Cordova.exec(successCallback, errorCallback, "com.cordova.File", "getFile", [requestPath,
options]);
+        }
 DirectoryEntry.prototype.getDirectory = function( path, options, successCallback, errorCallback
) {
-        var requestPath = path;
+            var requestPath = path;
 
-        // Check for a relative path
-        if( requestPath.charAt(0) != '/' ) requestPath = this.fullPath + "/" + requestPath;
+            // Check for a relative path
+            if( requestPath.charAt(0) != '/' ) requestPath = this.fullPath + "/" + requestPath;
 
-        // Lets get the directory
-        Cordova.exec(successCallback, errorCallback, "com.cordova.File", "getDirectory",
[requestPath, options]);
-}
+            // Lets get the directory
+            Cordova.exec(successCallback, errorCallback, "com.cordova.File", "getDirectory",
[requestPath, options]);
+        }
 DirectoryEntry.prototype.removeRecursively = function( successCallback, errorCallback ) {
-        // Remove the directory
-        Cordova.exec(successCallback, errorCallback, "com.cordova.File", "removeRecursively",
[this.fullPath]);
-}
+            // Remove the directory
+            Cordova.exec(successCallback, errorCallback, "com.cordova.File", "removeRecursively",
[this.fullPath]);
+        }
 
 /**
  * FileSystem interface
@@ -479,12 +495,12 @@ function FileSystem() {
 }
 
 FileSystem.cast = function( fsname, dirname, path ) {
-        var fs = new FileSystem();
-        fs.name = fsname;
-        fs.root = DirectoryEntry.cast(dirname, path);
+            var fs = new FileSystem();
+            fs.name = fsname;
+            fs.root = DirectoryEntry.cast(dirname, path);
 
-        return fs;
-}
+            return fs;
+        }
 
 FileSystem.prototype.name = "";
 FileSystem.prototype.root = null;	// Should be a DirectoryEntry
@@ -500,17 +516,17 @@ LocalFileSystem.TEMPORARY = 0;
 LocalFileSystem.PERSISTENT = 1;
 
 LocalFileSystem.prototype.requestFileSystem = function( type, size, successCallback, errorCallback
) {
-        Cordova.exec(successCallback, errorCallback, "com.cordova.File", "requestFileSystem",
[type,size]);
-}
+            Cordova.exec(successCallback, errorCallback, "com.cordova.File", "requestFileSystem",
[type,size]);
+        }
 LocalFileSystem.prototype.resolveLocalFileSystemURL = function( url, successCallback, errorCallback
) {
-        Cordova.exec(successCallback, errorCallback, "com.cordova.File", "resolveLocalFileSystemURL",
[url]);
-}
+            Cordova.exec(successCallback, errorCallback, "com.cordova.File", "resolveLocalFileSystemURL",
[url]);
+        }
 
 /**
  * Let window implement the localfilesystem
  */
 Cordova.addConstructor( "com.cordova.File", function () {
-    var localFileSystem = new LocalFileSystem();
-    window.requestFileSystem = localFileSystem.requestFileSystem;
-    window.resolveLocalFileSystemURI = localFileSystem.resolveLocalFileSystemURL;
-} );
+                           var localFileSystem = new LocalFileSystem();
+                           window.requestFileSystem = localFileSystem.requestFileSystem;
+                           window.resolveLocalFileSystemURI = localFileSystem.resolveLocalFileSystemURL;
+                       } );


Mime
View raw message