Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4005395AD for ; Fri, 25 May 2012 19:11:22 +0000 (UTC) Received: (qmail 35994 invoked by uid 500); 25 May 2012 19:11:22 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 35959 invoked by uid 500); 25 May 2012 19:11:22 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 35948 invoked by uid 99); 25 May 2012 19:11:22 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 May 2012 19:11:22 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B786717F23; Fri, 25 May 2012 19:11:21 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: longwei@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [3/3] qt commit: fixes, moveTo dir using helper function copyFolder instead of copyDir Message-Id: <20120525191121.B786717F23@tyr.zones.apache.org> Date: Fri, 25 May 2012 19:11:21 +0000 (UTC) fixes, moveTo dir using helper function copyFolder instead of copyDir 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/03d83eb4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/tree/03d83eb4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/diff/03d83eb4 Branch: refs/heads/master Commit: 03d83eb48896794971827dd31232fa4b8f106404 Parents: 5361a61 Author: Longwei Su Authored: Fri May 25 13:22:14 2012 -0400 Committer: Longwei Su Committed: Fri May 25 13:22:14 2012 -0400 ---------------------------------------------------------------------- cordovaqt.pro | 12 +++++----- main.cpp | 2 +- src/plugins/fileapi.cpp | 47 ++++++++++++++++++++++++++--------------- src/plugins/fileapi.h | 2 +- 4 files changed, 38 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/03d83eb4/cordovaqt.pro ---------------------------------------------------------------------- diff --git a/cordovaqt.pro b/cordovaqt.pro index 5ec963c..bee3766 100644 --- a/cordovaqt.pro +++ b/cordovaqt.pro @@ -5,9 +5,8 @@ wwwDir.source = www xmlDir.source = xml qmlDir.source = qml -docDir.source = doc -DEPLOYMENTFOLDERS = wwwDir xmlDir qmlDir docDir# file1 dir1 +DEPLOYMENTFOLDERS = wwwDir xmlDir qmlDir# file1 dir1 SOURCES += main.cpp \ @@ -24,8 +23,8 @@ SOURCES += main.cpp \ src/cordova.cpp \ src/cplugin.cpp \ src/plugins/contacts.cpp \ - src/plugins/camera.cpp - #src/plugins/media.cpp + src/plugins/camera.cpp +# src/plugins/media.cpp HEADERS += \ src/plugins/notification.h \ @@ -81,7 +80,7 @@ greaterThan(QT_MAJOR_VERSION, 4) { symbian:TARGET.UID3 = 0xE3522943 #symbian:DEPLOYMENT.installer_header = 0x2002CCCF symbian:TARGET.CAPABILITY += NetworkServices UserEnvironment ReadUserData WriteUserData - symbian:{LIBS += -lecam -lServiceHandler -lnewservice -lbafl} + symbian:{LIBS += -lecam -lServiceHandler -lbafl} QT += declarative QT += webkit @@ -101,4 +100,5 @@ OTHER_FILES += \ qtc_packaging/debian_harmattan/control \ qtc_packaging/debian_harmattan/compat \ qtc_packaging/debian_harmattan/changelog \ - qml/main_qt4.qml + qml/main_qt4.qml \ + qml/main.qml http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/03d83eb4/main.cpp ---------------------------------------------------------------------- diff --git a/main.cpp b/main.cpp index 894bb23..0231a80 100644 --- a/main.cpp +++ b/main.cpp @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) view->setSource(QUrl(QString("%1/qml/main_qt4.qml").arg(Cordova::instance()->workingDir()))); view->showFullScreen(); # else - view->setSource(QUrl(QString("%1/qml/main_qt4.qml").arg(Cordova::instance()->workingDir()))); + view->setSource(QUrl(QString("%1/qml/main.qml").arg(Cordova::instance()->workingDir()))); # if defined(Q_OS_SYMBIAN) || defined(QT_SIMULATOR) view->showFullScreen(); # else http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/03d83eb4/src/plugins/fileapi.cpp ---------------------------------------------------------------------- diff --git a/src/plugins/fileapi.cpp b/src/plugins/fileapi.cpp index 57f9490..e37abac 100644 --- a/src/plugins/fileapi.cpp +++ b/src/plugins/fileapi.cpp @@ -255,6 +255,7 @@ void FileAPI::getDirectory( int scId, int ecId, QString p_path, QVariantMap p_op * DirectoryEntry.removeRecursively - http://www.w3.org/TR/file-system-api/#widl-DirectoryEntry-removeRecursively */ void FileAPI::removeRecursively( int scId, int ecId, QString p_path ) { + qDebug()<< Q_FUNC_INFO; QDir dir( p_path ); if( FileAPI::rmDir(dir) ) { this->callback( scId, "" ); @@ -511,6 +512,7 @@ void FileAPI::readAsDataURL( int scId, int ecId, QString p_path ) { * Helper function for recursively removing a directory */ bool FileAPI::rmDir( QDir p_dir ) { + qDebug()<< Q_FUNC_INFO ; if ( p_dir == persistentDir_){//can't remove root dir return false; } @@ -592,7 +594,7 @@ void FileAPI::moveFile(int scId, int ecId,const QString& sourceFile, const QStri } -bool FileAPI::copyDir(int scId, int ecId,const QString& sourceFolder, const QString& destinationParentDir, const QString& newName) +void FileAPI::copyDir(int scId, int ecId,const QString& sourceFolder, const QString& destinationParentDir, const QString& newName) { qDebug()<< Q_FUNC_INFO << sourceFolder << ", " << destinationParentDir << ", " << newName; QDir sourceDir(sourceFolder); @@ -605,47 +607,59 @@ bool FileAPI::copyDir(int scId, int ecId,const QString& sourceFolder, const QStr //can't copy a dir on a file if(QFileInfo(destFolder).isFile()){ this->callback( ecId, "FileException.cast( FileException.INVALID_MODIFICATION_ERR )" ); - return false; + return; } QDir destDir(destFolder); //can't copy on or in itself if( (sourceFolder == destFolder) || (sourceFolder == destinationParentDir)){ this->callback( ecId, "FileException.cast( FileException.INVALID_MODIFICATION_ERR )" ); - return false; + return; } //create the dir if(!destDir.exists()){ qDebug() << "mkdir" << destDir.mkdir(destFolder);; } else{ this->callback( ecId, "FileException.cast( FileException.INVALID_MODIFICATION_ERR )" ); - return false; + return; } //recursively copying begin if(copyFolder(sourceFolder, destFolder)){ this->callback( scId, "DirectoryEntry.cast( '" + dirName + "', '" + destFolder + "' )" ); - return true; + return; }else{ this->callback( ecId, "FileException.cast( FileException.INVALID_MODIFICATION_ERR )" ); - return false; + return; } } void FileAPI::moveDir(int scId, int ecId,const QString& sourceDir, const QString& destinationParentDir, const QString& newName){ - + qDebug()<< Q_FUNC_INFO; QString dirName = ((newName.isEmpty()) ? QDir(sourceDir).dirName() : newName); QString destFolder(destinationParentDir + "/" + dirName); QDir destDir(destFolder); - if(destDir.exists() && (destFolder != sourceDir)){ - qDebug() << "***empty folder***"; - if(QDir(destinationParentDir).rmdir(dirName)){ - qDebug() << "rmed"; - } + + //can't copy a dir on a file + if(QFileInfo(destFolder).isFile()){ + this->callback( ecId, "FileException.cast( FileException.INVALID_MODIFICATION_ERR )" ); + return; + } + //can't copy on or in itself + if( (sourceDir == destFolder) || (sourceDir == destinationParentDir)){ + this->callback( ecId, "FileException.cast( FileException.INVALID_MODIFICATION_ERR )" ); + return; } - if(copyDir(scId, ecId, sourceDir, destinationParentDir,newName)){ - removeRecursively(scId, ecId,sourceDir ); - this->callback( scId, "" ); + if(destDir.exists() && (destFolder != sourceDir)){ + if(QDir(destinationParentDir).rmdir(dirName)){ + qDebug() << "empty folder rmed"; + } + } + if(copyFolder(sourceDir, destFolder)){ + qDebug() << "rming src dir if src-> dest copy success"; + rmDir(sourceDir ); + this->callback( scId, "DirectoryEntry.cast( '" + dirName + "', '" + destFolder + "' )" ); + return; } else { qDebug()<< "unable to copy dirs" <