You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by lo...@apache.org on 2012/05/08 17:07:00 UTC
[1/2] qt commit: network all pass, minor fixes for file api
Updated Branches:
refs/heads/master 4552ef483 -> 3ad4f1c5f
network all pass, minor fixes for 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/3ad4f1c5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/tree/3ad4f1c5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/diff/3ad4f1c5
Branch: refs/heads/master
Commit: 3ad4f1c5f900d5fa2c86f0183ea76ab01216e737
Parents: 882712d
Author: Longwei Su <lo...@apache.org>
Authored: Tue May 8 11:06:52 2012 -0400
Committer: Longwei Su <lo...@apache.org>
Committed: Tue May 8 11:06:52 2012 -0400
----------------------------------------------------------------------
src/plugins/fileapi.cpp | 53 +++++++++++++++++++++++-------------------
www/js/connection.js | 14 +++++-----
2 files changed, 36 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/3ad4f1c5/src/plugins/fileapi.cpp
----------------------------------------------------------------------
diff --git a/src/plugins/fileapi.cpp b/src/plugins/fileapi.cpp
index 0456565..2d007db 100644
--- a/src/plugins/fileapi.cpp
+++ b/src/plugins/fileapi.cpp
@@ -38,7 +38,7 @@ FileAPI::FileAPI() : CPlugin() {
* LocalFileSystem.requestFileSystem - http://www.w3.org/TR/file-system-api/#widl-LocalFileSystem-requestFileSystem
*/
void FileAPI::requestFileSystem( int scId, int ecId, unsigned short p_type ) {
-// Q_UNUSED(ecId)
+ // Q_UNUSED(ecId)
QDir dir;
@@ -49,10 +49,15 @@ void FileAPI::requestFileSystem( int scId, int ecId, unsigned short p_type ) {
else {
dir = QDir::home();
}
- if (p_type >= 10000){
- this->callback( ecId, "FileSystem.cast( 'Home', '" + dir.dirName() + "', '" + dir.absolutePath() + "/' )" );
- } else {
- this->callback( scId, "FileSystem.cast( 'Home', '" + dir.dirName() + "', '" + dir.absolutePath() + "/' )" );
+ if (p_type == 0){
+ this->callback( scId, "FileSystem.cast( 'temporary', '" + dir.dirName() + "', '" + dir.absolutePath() + "/' )" );
+ } else if (p_type == 1){
+ this->callback( scId, "FileSystem.cast( 'persistent', '" + dir.dirName() + "', '" + dir.absolutePath() + "/' )" );
+ } else if (p_type == -1){
+ this->callback( ecId, "FileError.cast( FileError.SYNTAX_ERR )" );
+ }
+ else {
+ this->callback(ecId, "FileSystem.cast( 'ERROR', '" + dir.dirName() + "', '" + dir.absolutePath() + "/' )" );
}
@@ -405,25 +410,25 @@ 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;
-// }
-// }
-// else {
-// if( !QFile::remove( fileInfo.absoluteFilePath() ) ) {
-// return false;
-// }
-// }
-// }
-
-// // Finally remove the current dir
-// qDebug() << p_dir.absolutePath();
-// return p_dir.rmdir( p_dir.absolutePath() );
-// }
+ // 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;
+ // }
+ // }
+ // }
+
+ // // 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/3ad4f1c5/www/js/connection.js
----------------------------------------------------------------------
diff --git a/www/js/connection.js b/www/js/connection.js
index 9e39767..c39666c 100644
--- a/www/js/connection.js
+++ b/www/js/connection.js
@@ -18,13 +18,13 @@ function Connection() {
}
Connection.prototype.type = 1;
-Connection.UNKNOWN = 1;
-Connection.ETHERNET = 2;
-Connection.WIFI = 3;
-Connection.CELL_2G = 4;
-Connection.CELL_3G = 5;
-Connection.CELL_4G = 6;
-Connection.NONE = 7;
+Connection.UNKNOWN = "unknown";
+Connection.ETHERNET = "ethernet";
+Connection.WIFI = "wifi";
+Connection.CELL_2G = "2g";
+Connection.CELL_3G = "3g";
+Connection.CELL_4G = "4g";
+Connection.NONE = "none";
/**
* Internal function for listening to change events