# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1286140006 -10800 # Node ID 1bebd60c0f005efa67460084ad786f273aaac410 # Parent 22e202702210ebd112ba1abb8c31e3d39034d0cf Revision: 201037 Kit: 201039 diff -r 22e202702210 -r 1bebd60c0f00 filemanager/examples/demo_fmfiledialog/demo_fmfiledialog.pro --- a/filemanager/examples/demo_fmfiledialog/demo_fmfiledialog.pro Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/examples/demo_fmfiledialog/demo_fmfiledialog.pro Mon Oct 04 00:06:46 2010 +0300 @@ -29,3 +29,6 @@ SOURCES += main.cpp mainwindow.cpp LIBS += -lfmfiledialog + + +symbian:MMP_RULES += SMPSAFE diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/filemanager.pro --- a/filemanager/src/filemanager/filemanager.pro Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/filemanager.pro Mon Oct 04 00:06:46 2010 +0300 @@ -24,6 +24,10 @@ # remove this path when export plat header to app layer path # INCLUDEPATH += ../../filemanager_plat/inc +symbian { + include(../../rom/rom.pri) +} + include ( ../common.pri ) include ( ../inc/commoninc.pri ) include ( ../inc/commonutils.pri ) @@ -42,7 +46,9 @@ -lefsrv \ -lapgrfx \ -lcone \ - -lsysutil + -lsysutil \ + -lbafl \ + -leikcore TARGET.UID3 = 0x2002BCC0 TARGET.EPOCHEAPSIZE = 0x020000 0x1000000 @@ -52,4 +58,6 @@ BLD_INF_RULES.prj_exports += "./burconfig.xml z:/private/2002BCC0/burconfig.xml" } +symbian:MMP_RULES += SMPSAFE + TRANSLATIONS = filemanager.ts diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/resources/hblistviewitem.css --- a/filemanager/src/filemanager/resources/hblistviewitem.css Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/resources/hblistviewitem.css Mon Oct 04 00:06:46 2010 +0300 @@ -22,6 +22,7 @@ bottom: var(hb-param-margin-gene-middle-vertical); font-variant: secondary-small; text-align: left; + size-policy-horizontal: ignored; } HbListViewItem::icon-1[layoutName="drive"]:portrait{ top: -var(hb-param-margin-gene-top); @@ -46,6 +47,7 @@ bottom: var(hb-param-margin-gene-top); font-variant: secondary-small; text-align: left; + size-policy-horizontal: ignored; } HbListViewItem::icon-1[layoutName="drive"]:landscape{ top: -var(hb-param-margin-gene-top); diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/backuprestore/fmbackupview.cpp --- a/filemanager/src/filemanager/src/backuprestore/fmbackupview.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/backuprestore/fmbackupview.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -97,19 +97,19 @@ case FmErrNone: break; case FmErrWrongParam: - FmDlgUtils::information( QString( hbTrId("Operation canceled with wrong param!") ) ); + FmDlgUtils::warning( QString( hbTrId("Operation canceled with wrong param!") ) ); break; case FmErrAlreadyStarted: - FmDlgUtils::information( QString( hbTrId("Operation canceled because already started!") ) ); + FmDlgUtils::warning( QString( hbTrId("Operation canceled because already started!") ) ); break; case FmErrPathNotFound: - FmDlgUtils::information( QString( hbTrId("Operation canceled because can not find target path or drive is not available!") ) ); + FmDlgUtils::warning( QString( hbTrId("Operation canceled because can not find target path or drive is not available!") ) ); break; case FmErrAlreadyExists: - FmDlgUtils::information( QString( hbTrId("backup canceled") ) ); + FmDlgUtils::warning( QString( hbTrId("backup canceled") ) ); break; default: - FmDlgUtils::information( QString( hbTrId("backup failed") ) ); + FmDlgUtils::warning( QString( hbTrId("backup failed") ) ); break; } } diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/backuprestore/fmrestoreview.cpp --- a/filemanager/src/filemanager/src/backuprestore/fmrestoreview.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/backuprestore/fmrestoreview.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -99,13 +99,13 @@ case FmErrNone: break; case FmErrWrongParam: - FmDlgUtils::information( QString( hbTrId("Operation canceled with wrong param!") ) ); + FmDlgUtils::warning( QString( hbTrId("Operation canceled with wrong param!") ) ); break; case FmErrAlreadyStarted: - FmDlgUtils::information( QString( hbTrId("Operation canceled because already started!") ) ); + FmDlgUtils::warning( QString( hbTrId("Operation canceled because already started!") ) ); break; default: - FmDlgUtils::information(hbTrId("restore failed")); + FmDlgUtils::warning(hbTrId("restore failed")); break; } } diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/components/fmdlgutils.cpp --- a/filemanager/src/filemanager/src/components/fmdlgutils.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/components/fmdlgutils.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -435,13 +435,24 @@ /*! This is a convenience function for showing an information dialog with \a informationText - Default button is OK. + Default button is OK, default behavior is not blocking ui.. */ void FmDlgUtils::information( const QString &informationText, - HbMessageBox::StandardButtons buttons ) + HbMessageBox::StandardButtons buttons, bool isBlocking ) { FmMessageBox msgBox; - return msgBox.information( informationText, buttons ); + return msgBox.information( informationText, buttons, isBlocking ); +} + +/*! + This is a convenience function for showing an warning dialog with \a warningText + Default button is OK, default behavior is blocking ui. +*/ +void FmDlgUtils::warning( const QString &warningText, + HbMessageBox::StandardButtons buttons, bool isBlocking ) +{ + FmMessageBox msgBox; + return msgBox.warning( warningText, buttons, isBlocking ); } /*! diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/components/fmdlgutils.h --- a/filemanager/src/filemanager/src/components/fmdlgutils.h Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/components/fmdlgutils.h Mon Oct 04 00:06:46 2010 +0300 @@ -72,7 +72,10 @@ HbMessageBox::StandardButtons buttons = HbMessageBox::Yes | HbMessageBox::No ); static void information( const QString &informationText, - HbMessageBox::StandardButtons buttons = HbMessageBox::Ok ); + HbMessageBox::StandardButtons buttons = HbMessageBox::Ok, bool isBlocking = false ); + + static void warning( const QString &warningText, + HbMessageBox::StandardButtons buttons = HbMessageBox::Ok, bool isBlocking = false ); static QString showBackupDriveQuery( const QString& title ); diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/components/fmmessagebox.cpp --- a/filemanager/src/filemanager/src/components/fmmessagebox.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/components/fmmessagebox.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -23,11 +23,14 @@ This is a convenience function for showing an information dialog with \a informationText */ void FmMessageBox::information( const QString &informationText, - HbMessageBox::StandardButtons buttons ) -{ - HbMessageBox::information ( informationText, + HbMessageBox::StandardButtons buttons, bool isBlocking ) +{ + HbMessageBox::information( informationText, this, SLOT(dialogClosed(HbAction*)), buttons ); - mEventLoop.exec(); + if ( isBlocking ) { + mEventLoop.exec(); + } + } /*! @@ -36,12 +39,25 @@ bool FmMessageBox::question( const QString &questionText, HbMessageBox::StandardButtons buttons ) { - HbMessageBox::question ( questionText, + HbMessageBox::question( questionText, this, SLOT(dialogClosed(HbAction*)), buttons ); mEventLoop.exec(); return mRet; } +/*! + This is a convenience function for showing a warning dialog with \a warningText +*/ +void FmMessageBox::warning( const QString &warningText, + HbMessageBox::StandardButtons buttons, bool isBlocking ) +{ + HbMessageBox::warning( warningText, + this, SLOT(dialogClosed(HbAction*)), buttons ); + if ( isBlocking ) { + mEventLoop.exec(); + } +} + void FmMessageBox::dialogClosed(HbAction *action) { HbMessageBox *dlg = static_cast(sender()); diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/components/fmmessagebox.h --- a/filemanager/src/filemanager/src/components/fmmessagebox.h Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/components/fmmessagebox.h Mon Oct 04 00:06:46 2010 +0300 @@ -34,11 +34,14 @@ { } void information( const QString &informationText, - HbMessageBox::StandardButtons buttons ); + HbMessageBox::StandardButtons buttons, bool isBlocking = false ); bool question( const QString &questionText, HbMessageBox::StandardButtons buttons ); + void warning( const QString &warningText, + HbMessageBox::StandardButtons buttons, bool isBlocking = false ); + public slots: void dialogClosed(HbAction *action); private: diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/fmdriverlistwidget.cpp --- a/filemanager/src/filemanager/src/fmdriverlistwidget.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/fmdriverlistwidget.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -248,7 +248,7 @@ FmDriverInfo driverInfo = FmUtils::queryDriverInfo( diskName ); if ( state & FmDriverInfo::EDriveWriteProtected ){ - FmDlgUtils::information( hbTrId( "Unable to perform operation. Memory card is read only." ) ); + FmDlgUtils::warning( hbTrId( "Unable to perform operation. Memory card is read only." ) ); return; } @@ -267,13 +267,13 @@ } int err = FmUtils::renameDrive( diskName, volumeName ); if ( err == FmErrNone ) { - FmDlgUtils::information( hbTrId( "The name has been changed!" ) ); + FmDlgUtils::information( hbTrId( "The name has been changed!" ), HbMessageBox::Ok, true ); mModel->refresh(); break; } else if( err == FmErrBadName ) { - FmDlgUtils::information( hbTrId( "Illegal characters! Use only letters and numbers." ) ); + FmDlgUtils::warning( hbTrId( "Illegal characters! Use only letters and numbers." ), HbMessageBox::Ok, true ); } else{ - FmDlgUtils::information( hbTrId( "Error occurred, operation cancelled!" ) ); + FmDlgUtils::warning( hbTrId( "Error occurred, operation cancelled!" ) ); break; } } @@ -299,10 +299,10 @@ QString associatedDrives( FmUtils::getDriveLetterFromPath( diskName ) ); if( FmDlgUtils::showMultiPasswordQuery( firstLabel, secondLabel, newPwd, FmMaxLengthofDrivePassword, associatedDrives ) ) { if ( FmUtils::setDrivePwd( diskName, oldPwd, newPwd ) == 0 ){ - FmDlgUtils::information( hbTrId( "The password has been set!" ) ); + FmDlgUtils::information( hbTrId( "The password has been set!" ), HbMessageBox::Ok, true ); } else{ - FmDlgUtils::information( hbTrId( "Error occurred, operation cancelled!" ) ); + FmDlgUtils::warning( hbTrId( "Error occurred, operation cancelled!" ) ); } } } @@ -325,7 +325,7 @@ if ( FmUtils::setDrivePwd( diskName, oldPwd, newPwd ) == 0 ){ FmDlgUtils::information( hbTrId( "The password has been changed!" ) ); } else { - FmDlgUtils::information( hbTrId( "Error occurred, operation cancelled!" ) ); + FmDlgUtils::warning( hbTrId( "Error occurred, operation cancelled!" ) ); } break; } else { @@ -354,12 +354,12 @@ FmDlgUtils::information( hbTrId( "The password has been removed!" ) ); } else{ - FmDlgUtils::information( hbTrId( "Error occurred, operation cancelled!" ) ); + FmDlgUtils::warning( hbTrId( "Error occurred, operation cancelled!" ) ); } break; } else { - FmDlgUtils::information( hbTrId( "The password is incorrect, try again!" ) ); + FmDlgUtils::warning( hbTrId( "The password is incorrect, try again!" ), HbMessageBox::Ok, true ); } } @@ -378,18 +378,18 @@ while( FmDlgUtils::showSinglePasswordQuery( title, oldPwd, FmMaxLengthofDrivePassword ) ) { int err = FmUtils::unlockDrive( diskName, oldPwd ); if( err == FmErrNone ) { - FmDlgUtils::information( hbTrId( "The memory is unlocked!" ) ); + FmDlgUtils::warning( hbTrId( "The memory is unlocked!" ) ); break; } else if ( err == FmErrAccessDenied ) { - FmDlgUtils::information( hbTrId( "The password is incorrect, try again!" ) ); + FmDlgUtils::warning( hbTrId( "The password is incorrect, try again!" ), HbMessageBox::Ok, true ); } else if (err == FmErrAlreadyExists ) { FmDlgUtils::information( hbTrId( "The disk has already been unlocked!" ) ); break; } else if( err == FmErrNotSupported ) { - FmDlgUtils::information( hbTrId( "The media does not support password locking!" ) ); + FmDlgUtils::warning( hbTrId( "The media does not support password locking!" ) ); break; } else { - FmDlgUtils::information( hbTrId( "Error occurred, operation cancelled!" ) ); + FmDlgUtils::warning( hbTrId( "Error occurred, operation cancelled!" ) ); break; } } diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/fmfilebrowsewidget.cpp --- a/filemanager/src/filemanager/src/fmfilebrowsewidget.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/fmfilebrowsewidget.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -24,7 +24,9 @@ #include "fmviewmanager.h" #include "fmfiledialog.h" #include "fmdlgutils.h" +#include "fmserviceutils.h" #include "fmfileiconprovider.h" +#include "fmfilesystemproxymodel.h" #include #include @@ -39,8 +41,6 @@ #include #include -#include - // These define comes from implementation of QFileSystemModel #define QFileSystemSortName 0 #define QFileSystemSortSize 1 @@ -81,6 +81,7 @@ mTreeView->setModel( 0 ); mListView->setModel( 0 ); + delete mSourceModel; delete mModel; delete mFileIconProvider; @@ -135,7 +136,7 @@ } case FmErrPathNotExist: { - FmDlgUtils::information( hbTrId( "Path is not exist" ) ); + FmDlgUtils::warning( hbTrId( "Path is not exist" ) ); break; } case FmErrDriveNotAvailable: @@ -146,7 +147,7 @@ case FmErrDriveDenied: case FmErrPathDenied: { - FmDlgUtils::information( hbTrId( "Can not access" ) ); + FmDlgUtils::warning( hbTrId( "Can not access" ) ); break; } default: @@ -412,11 +413,15 @@ void FmFileBrowseWidget::initFileModel() { - mModel = new QFileSystemModel( this ); - mModel->setReadOnly( false ); + mSourceModel = new QFileSystemModel( this ); + mSourceModel->setReadOnly( false ); mFileIconProvider = new FmFileIconProvider(); - mModel->setIconProvider( mFileIconProvider ); + mSourceModel->setIconProvider( mFileIconProvider ); + + mModel = new FmFileSystemProxyModel( this ); + mModel->setSourceModel( mSourceModel ); + } void FmFileBrowseWidget::initLayout() @@ -596,7 +601,7 @@ QString filePath = mModel->filePath( mCurrentItem->modelIndex() ); QStringList list; list.append( filePath ); - FmViewManager::viewManager()->shareUi()->send( list, true ); + FmViewManager::viewManager()->serviceUtils()->sendFile( list ); } void FmFileBrowseWidget::on_viewAction_triggered() @@ -624,13 +629,13 @@ break; case FmErrAlreadyStarted: // last operation have not finished - FmDlgUtils::information( hbTrId( "Operatin already started!" ) ); + FmDlgUtils::warning( hbTrId( "Operatin already started!" ) ); break; case FmErrWrongParam: - FmDlgUtils::information( hbTrId( "Wrong parameters!" ) ); + FmDlgUtils::warning( hbTrId( "Wrong parameters!" ) ); break; default: - FmDlgUtils::information( hbTrId( "Operation fail to start!" ) ); + FmDlgUtils::warning( hbTrId( "Operation fail to start!" ) ); } } } @@ -653,13 +658,13 @@ break; case FmErrAlreadyStarted: // last operation have not finished - FmDlgUtils::information( hbTrId( "Operatin already started!" ) ); + FmDlgUtils::warning( hbTrId( "Operatin already started!" ) ); break; case FmErrWrongParam: - FmDlgUtils::information( hbTrId( "Wrong parameters!" ) ); + FmDlgUtils::warning( hbTrId( "Wrong parameters!" ) ); break; default: - FmDlgUtils::information( hbTrId( "Operation fail to start!" ) ); + FmDlgUtils::warning( hbTrId( "Operation fail to start!" ) ); } } @@ -683,13 +688,13 @@ break; case FmErrAlreadyStarted: // last operation have not finished - FmDlgUtils::information( hbTrId( "Operatin already started!" ) ); + FmDlgUtils::warning( hbTrId( "Operatin already started!" ) ); break; case FmErrWrongParam: - FmDlgUtils::information( hbTrId( "Wrong parameters!" ) ); + FmDlgUtils::warning( hbTrId( "Wrong parameters!" ) ); break; default: - FmDlgUtils::information( hbTrId( "Operation fail to start!" ) ); + FmDlgUtils::warning( hbTrId( "Operation fail to start!" ) ); } } } @@ -716,11 +721,11 @@ // check if name/path is available for use // add new Name to check, in order to avoid problem of newName is empty if( !FmUtils::checkNewFolderOrFile( newName, newTargetPath, errString ) ) { - FmDlgUtils::information( errString ); + FmDlgUtils::warning( errString, HbMessageBox::Ok, true ); continue; } if( !rename( fileInfo.absoluteFilePath(), newTargetPath ) ) { - FmDlgUtils::information( hbTrId("Rename failed!") ); + FmDlgUtils::warning( hbTrId("Rename failed!") ); } else { // Rename succeed diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/fmfilebrowsewidget.h --- a/filemanager/src/filemanager/src/fmfilebrowsewidget.h Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/fmfilebrowsewidget.h Mon Oct 04 00:06:46 2010 +0300 @@ -37,6 +37,7 @@ class HbLabel; class FmFileIconProvider; +class FmFileSystemProxyModel; class FmFileBrowseWidget : public HbWidget { @@ -122,7 +123,8 @@ HbTreeView *mTreeView; HbListView *mListView; QGraphicsLinearLayout *mLayout; - QFileSystemModel *mModel; + QFileSystemModel *mSourceModel; + FmFileSystemProxyModel *mModel; bool mSelectable; diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/fmfileview.cpp --- a/filemanager/src/filemanager/src/fmfileview.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/fmfileview.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -256,7 +256,7 @@ void FmFileView::infoNoFileSelected() { - FmDlgUtils::information( hbTrId("No File/Folder selected" ) ); + FmDlgUtils::warning( hbTrId("No File/Folder selected" ) ); } #ifdef FM_CHANGE_ORIENT_ENABLE @@ -303,13 +303,13 @@ break; case FmErrAlreadyStarted: // last operation have not finished - FmDlgUtils::information( hbTrId( "Operatin already started!" ) ); + FmDlgUtils::warning( hbTrId( "Operatin already started!" ) ); break; case FmErrWrongParam: - FmDlgUtils::information( hbTrId( "Wrong parameters!" ) ); + FmDlgUtils::warning( hbTrId( "Wrong parameters!" ) ); break; default: - FmDlgUtils::information( hbTrId( "Operation fail to start!" ) ); + FmDlgUtils::warning( hbTrId( "Operation fail to start!" ) ); } setSelectable( false ); } @@ -341,13 +341,13 @@ break; case FmErrAlreadyStarted: // last operation have not finished - FmDlgUtils::information( hbTrId( "Operatin already started!" ) ); + FmDlgUtils::warning( hbTrId( "Operatin already started!" ) ); break; case FmErrWrongParam: - FmDlgUtils::information( hbTrId( "Wrong parameters!" ) ); + FmDlgUtils::warning( hbTrId( "Wrong parameters!" ) ); break; default: - FmDlgUtils::information( hbTrId( "Operation fail to start!" ) ); + FmDlgUtils::warning( hbTrId( "Operation fail to start!" ) ); } setSelectable( false ); } @@ -379,13 +379,13 @@ break; case FmErrAlreadyStarted: // last operation have not finished - FmDlgUtils::information( hbTrId( "Operatin already started!" ) ); + FmDlgUtils::warning( hbTrId( "Operatin already started!" ) ); break; case FmErrWrongParam: - FmDlgUtils::information( hbTrId( "Wrong parameters!" ) ); + FmDlgUtils::warning( hbTrId( "Wrong parameters!" ) ); break; default: - FmDlgUtils::information( hbTrId( "Operation fail to start!" ) ); + FmDlgUtils::warning( hbTrId( "Operation fail to start!" ) ); } setSelectable( false ); } @@ -411,11 +411,11 @@ QString errString; // check if name/path is available for use if( !FmUtils::checkNewFolderOrFile( dirName, newTargetPath, errString ) ) { - FmDlgUtils::information( errString ); + FmDlgUtils::warning( errString, HbMessageBox::Ok, true ); continue; } if( !dir.mkdir( dirName ) ) { - FmDlgUtils::information( hbTrId("Operation failed!") ); + FmDlgUtils::warning( hbTrId("Operation failed!") ); } break; } diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/fmfindthread.cpp --- a/filemanager/src/filemanager/src/fmfindthread.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/fmfindthread.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -17,6 +17,7 @@ */ #include "fmfindthread.h" +#include "fmutils.h" #include "fmcommon.h" #include @@ -117,17 +118,21 @@ QString name = it->fileName(); QString absolutPath = it->absoluteFilePath(); if (findPattern.exactMatch( it->fileName() )) { - tempResultList.append( it->absoluteFilePath() ); - if (tempResultList.count() > notifyPerCount) { - emitFound(); - } else if (time.elapsed() > notifyPerElapsedTime && tempResultList.count() > 0) { - emitFound(); + if( !FmUtils::isSystemFolder( it->absoluteFilePath()) ) { + tempResultList.append( it->absoluteFilePath() ); + if (tempResultList.count() > notifyPerCount) { + emitFound(); + } else if (time.elapsed() > notifyPerElapsedTime && tempResultList.count() > 0) { + emitFound(); + } } } // exclude directory named ".." and "." if (it->isDir() && it->fileName() != ParentDir && it->fileName() != CurrentDir ) { - findDirs.append( QDir( it->absoluteFilePath() ) ); + if( !FmUtils::isSystemFolder( it->absoluteFilePath()) ) { + findDirs.append( QDir( it->absoluteFilePath() ) ); + } } } diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/fmfindwidget.cpp --- a/filemanager/src/filemanager/src/fmfindwidget.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/fmfindwidget.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -121,6 +121,8 @@ QGraphicsLinearLayout *emptyTipLayout = new QGraphicsLinearLayout( mEmptyTipWidget ); HbLabel *emptyTipLable = new HbLabel( hbTrId( "No found files or folders" ), mEmptyTipWidget ); emptyTipLayout->addItem( emptyTipLable ); + emptyTipLayout->setAlignment( emptyTipLable, Qt::AlignCenter ); + emptyTipLable->setAlignment( Qt::AlignCenter ); mContentWidget->addWidget( mListView ); mContentWidget->addWidget( mEmptyTipWidget ); diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/fmmainwindow.cpp --- a/filemanager/src/filemanager/src/fmmainwindow.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/fmmainwindow.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -20,10 +20,21 @@ #include "fmcommon.h" #include +#include +/*! + \fn void applicationReady() + This signal is emitted when application is launched and ready to use +*/ + + +/*! + constructor +*/ FmMainWindow::FmMainWindow() : mViewManager( 0 ), mFirstViewLoaded( false ) { - // connect(this, SIGNAL(viewReady()), this, SLOT(delayedLoading())); + // delayedLoading is not used currently but reserved for future + // connect(this, SIGNAL(viewReady()), this, SLOT(delayedLoading())); init(); } @@ -34,21 +45,21 @@ FmViewManager::RemoveViewManager(); } +/* + handle orientation change event. not used yet as views can handle such event by themself +*/ void FmMainWindow::onOrientationChanged( Qt::Orientation orientation ) { Q_UNUSED( orientation ); - /* - if ( orientation == Qt::Vertical ) { - activateDriverView(); - } else { - activateSplitView(); - } - */ } +/* + init main window +*/ void FmMainWindow::init() { FM_LOG("FmMainWindow::init start"); + mViewManager = FmViewManager::CreateViewManager( this ); mViewManager->createDriverView(); connect(this, SIGNAL(aboutToChangeView(HbView *, HbView *)), @@ -56,14 +67,17 @@ connect( this, SIGNAL( orientationChanged( Qt::Orientation ) ), this, SLOT( onOrientationChanged( Qt::Orientation ) ) ); + + connect(&mShowTimer, SIGNAL(timeout()), this, SLOT(onApplicationReady())); + mShowTimer.start(); + FM_LOG("FmMainWindow::init end"); -// if ( orientation() == Qt::Vertical ) { -// createDriverView(); -// } else { -// createSplitView(); -// } } + +/* + delayedLoading is not used currently but reserved for future +*/ void FmMainWindow::delayedLoading() { FM_LOG("FmMainWindow::delayedLoading start"); @@ -75,3 +89,11 @@ FM_LOG("FmMainWindow::delayedLoading end"); } +/* + Slot to receive timer event after application started and emit applicationReady signal +*/ +void FmMainWindow::onApplicationReady() +{ + mShowTimer.stop(); + emit applicationReady(); +} diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/fmmainwindow.h --- a/filemanager/src/filemanager/src/fmmainwindow.h Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/fmmainwindow.h Mon Oct 04 00:06:46 2010 +0300 @@ -23,7 +23,7 @@ #include "fmviewmanager.h" #include - +#include class HbAction; class FmMainWindow : public HbMainWindow @@ -33,14 +33,21 @@ FmMainWindow(); ~FmMainWindow(); +signals: + void applicationReady(); + private slots: void onOrientationChanged( Qt::Orientation orientation ); void delayedLoading(); + void onApplicationReady(); private: void init(); FmViewManager *mViewManager; bool mFirstViewLoaded; + + // timer used to get opportunity for emit applicationReady signal. + QTimer mShowTimer; }; #endif diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/fmviewbase.cpp --- a/filemanager/src/filemanager/src/fmviewbase.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/fmviewbase.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -50,4 +50,4 @@ void FmViewBase::aboutToClose() { -} \ No newline at end of file +} diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/fmviewmanager.cpp --- a/filemanager/src/filemanager/src/fmviewmanager.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/fmviewmanager.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -30,6 +30,7 @@ #include "fmdrivewatcher.h" #include "fmdialog.h" #include "fmdlgutils.h" +#include "fmserviceutils.h" #include #include @@ -39,8 +40,6 @@ #include #include -#include - FmViewManager *FmViewManager::mViewManager = 0; @@ -75,7 +74,8 @@ return mDialog; } -FmViewManager::FmViewManager( FmMainWindow* mainWindow ) : mOperationService( 0 ), mShareUi( 0 ) +FmViewManager::FmViewManager( FmMainWindow* mainWindow ) + : mOperationService( 0 ), mServiceUtils( 0 ) { mMainWindow = mainWindow; mDriveWatcher = new FmDriveWatcher( this ); @@ -101,8 +101,8 @@ delete mDriveWatcher; mDriveWatcher = 0; - delete mShareUi; - mShareUi = 0; + delete mServiceUtils; + mServiceUtils = 0; } @@ -130,19 +130,20 @@ if ( !mOperationService ) { mOperationService = new FmOperationService( this ); mOperationService->setObjectName( "operationService" ); + QMetaObject::connectSlotsByName( this ); } return mOperationService; } /* - return \a shareUi which is used to send files. + return \a FmServiceUtils. */ -ShareUi *FmViewManager::shareUi() +FmServiceUtils *FmViewManager::serviceUtils() { - if( !mShareUi ) { - mShareUi = new ShareUi; + if( !mServiceUtils ) { + mServiceUtils = new FmServiceUtils; } - return mShareUi; + return mServiceUtils; } void FmViewManager::popViewAndShow() @@ -205,6 +206,7 @@ mMainWindow->setCurrentView( driverView ); HbActivityManager* activityManager = qobject_cast(qApp)->activityManager(); bool ok = activityManager->removeActivity("FMMemoryStoragesList"); + Q_UNUSED( ok ); connect( this, SIGNAL( driveSpaceChanged() ), driverView, SLOT( refreshDrive() ) ); @@ -236,7 +238,7 @@ } if( checkedPath.isEmpty() ) { - FmDlgUtils::information( QString( hbTrId("Path: %1 is unavailable!").arg( path )) ); + FmDlgUtils::warning( QString( hbTrId("Path: %1 is unavailable!").arg( path )) ); return; } @@ -353,7 +355,7 @@ // add the activity to the activity manager bool ok = activityManager->addActivity("FMMemoryStoragesList", QVariant(), metadata); // do not need check return value - + Q_UNUSED( ok ); } void FmViewManager::onAboutToChangeView(HbView * oldView, HbView *newView) diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/fmviewmanager.h --- a/filemanager/src/filemanager/src/fmviewmanager.h Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/fmviewmanager.h Mon Oct 04 00:06:46 2010 +0300 @@ -32,7 +32,7 @@ class QFileSystemWatcher; class FmDriveWatcher; class FmDialog; -class ShareUi; +class FmServiceUtils; /* * this class is used to record relationship between dialog and drive name @@ -66,7 +66,7 @@ static void RemoveViewManager(); static FmViewManager *viewManager(); FmOperationService *operationService(); - ShareUi *shareUi(); + FmServiceUtils *serviceUtils(); Qt::Orientation orientation(); @@ -148,9 +148,9 @@ QList mDlgCloseUnitList; QPixmap mScreenShot; - - // used to send files - ShareUi *mShareUi; + + // non-static service utils + FmServiceUtils *mServiceUtils; }; diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/operationservice/fmoperationcopyormove.cpp --- a/filemanager/src/filemanager/src/operationservice/fmoperationcopyormove.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/operationservice/fmoperationcopyormove.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -127,7 +127,8 @@ QString checkedSource( FmUtils::formatPath( source ) ); QFileInfo fi( checkedSource ); if( !fi.exists() ) { - mErrString = checkedSource; + mErrString = checkedSource; + emit driveSpaceChanged(); emit notifyError( FmErrSrcPathDoNotExist, mErrString ); return; } @@ -168,22 +169,22 @@ } } if( ret != FmErrNone ) { - emit notifyError( ret, mErrString ); // refresh drive space no care if cancel, error or finished. // as filemanger cannot notify drive space changed // do not refresh path as QFileSystemModel will do auto-refresh emit driveSpaceChanged(); + emit notifyError( ret, mErrString ); return; } ret = copyOrMove( checkedSource, mTargetPath, newName ); if( ret != FmErrNone ) { + emit driveSpaceChanged(); emit notifyError( ret, mErrString ); - emit driveSpaceChanged(); return; } - } + } + emit driveSpaceChanged(); emit notifyFinish(); - emit driveSpaceChanged(); } /* diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/operationservice/fmoperationformat.h --- a/filemanager/src/filemanager/src/operationservice/fmoperationformat.h Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/operationservice/fmoperationformat.h Mon Oct 04 00:06:46 2010 +0300 @@ -35,7 +35,9 @@ signals: void driveSpaceChanged(); - +private: + void storeVolumeName( int drive ); + void restoreVolumeName( int drive ); private: QString mDriverName; diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/operationservice/fmoperationformat_s60.cpp --- a/filemanager/src/filemanager/src/operationservice/fmoperationformat_s60.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/operationservice/fmoperationformat_s60.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -19,8 +19,11 @@ #include "fmcommon.h" #include "fmoperationbase.h" #include "fmutils.h" +#include "fmviewmanager.h" +#include "fmserviceutils.h" #include +#include #include #include @@ -71,6 +74,8 @@ emit notifyError( FmErrWrongParam, QString() ); return; } + FmViewManager::viewManager()->serviceUtils()->closeApps(); + RFormat format; @@ -84,7 +89,9 @@ TInt drive = 0; drive = mDriverName[0].toUpper().toAscii() - 'A' + EDriveA; - + // save volume name for MassStorage + storeVolumeName( drive ); + TDriveName formatDriveName( TDriveUnit( drive ).Name() ); int finalValue = 0; @@ -196,18 +203,60 @@ format.Close(); fs.Close(); + // restore volume name for MassStorage + restoreVolumeName( drive ); FmUtils::createDefaultFolders( mDriverName ); } + FmViewManager::viewManager()->serviceUtils()->restartApps(); + + // refresh drive space no care if cancel, error or finished. + // as filemanger cannot notify drive space changed + // do not refresh path as QFileSystemModel will do auto-refresh + emit driveSpaceChanged(); if( err == KErrNone ){ emit notifyFinish(); } else{ emit notifyError( FmErrTypeFormatFailed, QString() ); } - // refresh drive space no care if cancel, error or finished. - // as filemanger cannot notify drive space changed - // do not refresh path as QFileSystemModel will do auto-refresh - emit driveSpaceChanged(); +} + +void FmOperationFormat::storeVolumeName( int drive ) +{ + FmDriverInfo driverInfo = FmUtils::queryDriverInfo( FmUtils::numberToDriveName( drive ) ); + if ( driverInfo.driveType() == FmDriverInfo::EDriveTypeMassStorage ) + { + QString volumeName( driverInfo.volumeName() ); + QSettings settings( "Nokia", "FileManager" ); + settings.beginGroup( "Settings" ); + settings.setValue( "MassStorageDriveNumber", drive ); + settings.setValue( "MassStorageVolumeName", volumeName ); + settings.endGroup(); + } +} + +// ----------------------------------------------------------------------------- +// CFileManagerEngine::RestoreVolumeNameL() +// +// ----------------------------------------------------------------------------- +// +void FmOperationFormat::restoreVolumeName( int drive ) +{ + + FmDriverInfo driveInfo = FmUtils::queryDriverInfo( FmUtils::numberToDriveName( drive )); + if ( driveInfo.driveType() == FmDriverInfo::EDriveTypeMassStorage ) + { + QSettings settings("Nokia", "FileManager"); + settings.beginGroup("Settings"); + int massStorageDriveNumber = settings.value( "MassStorageDriveNumber", -1 ).toInt(); + QString massStorageVolumeName = settings.value( "MassStorageVolumeName", QString() ).toString(); + settings.endGroup(); + if ( ( !massStorageVolumeName.isEmpty() ) && + ( massStorageDriveNumber == drive ) ) + { + FmUtils::renameDrive( FmUtils::numberToDriveName( drive ), massStorageVolumeName ); + } + } } diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/operationservice/fmoperationremove.cpp --- a/filemanager/src/filemanager/src/operationservice/fmoperationremove.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/operationservice/fmoperationremove.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -95,16 +95,16 @@ foreach( const QString& srcPath, mPathList ) { int ret = remove( srcPath ); if( ret != FmErrNone ) { - emit notifyError( ret, mErrString ); // refresh drive space no care if cancel, error or finished. // as filemanger cannot notify drive space changed // do not refresh path as QFileSystemModel will do auto-refresh emit driveSpaceChanged(); + emit notifyError( ret, mErrString ); return; } - } + } + emit driveSpaceChanged(); emit notifyFinish(); - emit driveSpaceChanged(); } /* diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/operationservice/fmoperationresultprocesser.cpp --- a/filemanager/src/filemanager/src/operationservice/fmoperationresultprocesser.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/operationservice/fmoperationresultprocesser.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -72,7 +72,7 @@ QString errString; // check if name/path is available for use. if( !FmUtils::checkNewFolderOrFile( value, newTargetPath, errString ) ) { - FmDlgUtils::information( errString ); + FmDlgUtils::warning( errString, HbMessageBox::Ok, true ); ret = FmDlgUtils::showTextQuery( questionText, value, regExpList, maxFileNameLength, QString(), false ); continue; } else { @@ -86,7 +86,7 @@ if ( ( srcFileInfo.suffix().compare( destFileInfo.suffix(), Qt::CaseInsensitive ) != 0 ) && srcFileInfo.isFile() ) { // popup warning when the suffix of file is changed. - FmDlgUtils::information( hbTrId( "File may become unusable when file name extension is changed" ) ); + FmDlgUtils::warning( hbTrId( "File may become unusable when file name extension is changed" ) ); } } } @@ -117,7 +117,7 @@ void FmOperationResultProcesser::onShowNote( FmOperationBase* operationBase, const char *noteString ) { Q_UNUSED( operationBase ); - FmDlgUtils::information(hbTrId(noteString)); + FmDlgUtils::information(hbTrId(noteString), HbMessageBox::Ok, true ); } /* @@ -175,6 +175,7 @@ break; case FmOperationService::EOperationTypeFormat: title = hbTrId("format preparing"); + FmUtils::setSystem( true ); break; default: break; @@ -257,7 +258,8 @@ } case FmOperationService::EOperationTypeFormat: { - FmDlgUtils::information( QString( hbTrId("Format succeed!")) ); + FmUtils::setSystem( false ); + FmDlgUtils::information( QString( hbTrId("Format succeed!")), HbMessageBox::Ok, true ); FmOperationFormat *paramFormat = static_cast( operationBase ); QString title( hbTrId( "Drive name ") ); QString driveName( paramFormat->driverName() ); @@ -280,9 +282,9 @@ mOperationService->on_operation_driveSpaceChanged(); break; } else if( err == FmErrBadName ) { - FmDlgUtils::information( hbTrId( "Illegal characters! Use only letters and numbers." ) ); + FmDlgUtils::warning( hbTrId( "Illegal characters! Use only letters and numbers." ), HbMessageBox::Ok, true ); } else{ - FmDlgUtils::information( hbTrId( "Error occurred, operation cancelled!" ) ); + FmDlgUtils::warning( hbTrId( "Error occurred, operation cancelled!" ) ); break; } } @@ -313,6 +315,9 @@ { Q_UNUSED( errString ); failAndCloseProgress(); + if( operationBase->operationType() == FmOperationService::EOperationTypeFormat ) { + FmUtils::setSystem( false ); + } switch( error ) { case FmErrCancel: @@ -325,7 +330,7 @@ // If need use QEventLoop::exec to block code execute sequence, It should be invoked in a Qt::QueuedConnection slot. return; case FmErrAlreadyStarted: - FmDlgUtils::information( QString( hbTrId("Operation already started!")) ); + FmDlgUtils::warning( QString( hbTrId("Operation already started!")) ); return; case FmErrLocked: { @@ -335,14 +340,14 @@ QString targetDrive( operationBackup->targetDrive() ); QString defaultDriveVolume( FmUtils::getDefaultVolumeName( targetDrive ) ); QString driveString( defaultDriveVolume.isEmpty()? targetDrive:defaultDriveVolume ); - FmDlgUtils::information( QString( hbTrId("txt_fmgr_info_backup_locked") ).arg( driveString ) ); + FmDlgUtils::warning( QString( hbTrId("txt_fmgr_info_backup_locked") ).arg( driveString ) ); } else { - FmDlgUtils::information( QString( hbTrId("Operation failed because drive is locked!")) ); + FmDlgUtils::warning( QString( hbTrId("Operation failed because drive is locked!")) ); } return; } case FmErrPathNotFound: - FmDlgUtils::information( QString( hbTrId("Operation failed because can not find target path or drive is not available!") ) ); + FmDlgUtils::warning( QString( hbTrId("Operation failed because can not find target path or drive is not available!") ) ); return; case FmErrCorrupt: { @@ -352,9 +357,9 @@ QString targetDrive( operationBackup->targetDrive() ); QString defaultDriveVolume( FmUtils::getDefaultVolumeName( targetDrive ) ); QString driveString( defaultDriveVolume.isEmpty()? targetDrive:defaultDriveVolume ); - FmDlgUtils::information( QString( hbTrId("txt_fmgr_info_backup_corrupted") ).arg( driveString ) ); + FmDlgUtils::warning( QString( hbTrId("txt_fmgr_info_backup_corrupted") ).arg( driveString ) ); } else { - FmDlgUtils::information( QString( hbTrId("Operation failed because target media is corrupted!") ) ); + FmDlgUtils::warning( QString( hbTrId("Operation failed because target media is corrupted!") ) ); } return; } @@ -366,48 +371,48 @@ QString targetDrive( operationBackup->targetDrive() ); QString defaultDriveVolume( FmUtils::getDefaultVolumeName( targetDrive ) ); QString driveString( defaultDriveVolume.isEmpty()? targetDrive:defaultDriveVolume ); - FmDlgUtils::information( QString( hbTrId("txt_fmgr_info_backup_unavailable") ).arg( driveString ) ); + FmDlgUtils::warning( QString( hbTrId("txt_fmgr_info_backup_unavailable") ).arg( driveString ) ); } else { - FmDlgUtils::information( QString( hbTrId("Operation failed because device is not ready!") ) ); + FmDlgUtils::warning( QString( hbTrId("Operation failed because device is not ready!") ) ); } return; } case FmErrDisMounted: // Caused by eject MMC when preparing backup, will be localized later - FmDlgUtils::information( QString( hbTrId("Operation failed because backup target drive has been removed!") ) ); + FmDlgUtils::warning( QString( hbTrId("Operation failed because backup target drive has been removed!") ) ); return; case FmErrDiskFull: - FmDlgUtils::information( QString( hbTrId("Not enough space. Operation cancelled!")) ); + FmDlgUtils::warning( QString( hbTrId("Not enough space. Operation cancelled!")) ); return; case FmErrCopyDestToSubFolderInSrc: - FmDlgUtils::information( QString( hbTrId("Can not copy to sub folder!")) ); + FmDlgUtils::warning( QString( hbTrId("Can not copy to sub folder!")) ); return; case FmErrMoveDestToSubFolderInSrc: - FmDlgUtils::information( QString( hbTrId("Can not move to sub folder!")) ); + FmDlgUtils::warning( QString( hbTrId("Can not move to sub folder!")) ); return; case FmErrCannotRemove:{ if( operationBase->operationType() == FmOperationService::EOperationTypeCopy ) { // when copy a file/dir to same name destination, and delete dest fail, this error will occur - FmDlgUtils::information( QString( hbTrId( "Can not copy because %1 can not be deleted!" ).arg( errString ) ) ); + FmDlgUtils::warning( QString( hbTrId( "Can not copy because %1 can not be deleted!" ).arg( errString ) ) ); return; } else if( operationBase->operationType() == FmOperationService::EOperationTypeMove ) { // when move a file/dir to same name destination, and delete dest fail, this error will occur - FmDlgUtils::information( QString( hbTrId( "Can not move because %1 can not be deleted!" ).arg( errString ) ) ); + FmDlgUtils::warning( QString( hbTrId( "Can not move because %1 can not be deleted!" ).arg( errString ) ) ); return; } // when delete file/dir fail, this error will occur - FmDlgUtils::information( QString( hbTrId( "Can not delete %1!" ).arg( errString ) ) ); + FmDlgUtils::warning( QString( hbTrId( "Can not delete %1!" ).arg( errString ) ) ); return; } case FmErrRemoveDefaultFolder:{ if( operationBase->operationType() == FmOperationService::EOperationTypeMove ) { // when move a default folder - FmDlgUtils::information( QString( hbTrId( "Could not move because the default folder %1 can not be deleted!" ).arg( errString ) ) ); + FmDlgUtils::warning( QString( hbTrId( "Could not move because the default folder %1 can not be deleted!" ).arg( errString ) ) ); return; } else { // when delete the default folder - FmDlgUtils::information( QString( hbTrId( "Could not remove the default folder %1 " ).arg( errString ) ) ); + FmDlgUtils::warning( QString( hbTrId( "Could not remove the default folder %1 " ).arg( errString ) ) ); return; } } @@ -416,10 +421,10 @@ switch( operationBase->operationType() ) { case FmOperationService::EOperationTypeFormat: - FmDlgUtils::information( QString( hbTrId("Format failed!")) ); + FmDlgUtils::warning( QString( hbTrId("Format failed!")) ); break; default: - FmDlgUtils::information( QString( hbTrId("Operation failed")) ); + FmDlgUtils::warning( QString( hbTrId("Operation failed")) ); } } diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/filemanager/src/operationservice/fmoperationservice.cpp --- a/filemanager/src/filemanager/src/operationservice/fmoperationservice.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/filemanager/src/operationservice/fmoperationservice.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -66,7 +66,7 @@ * Constructs one operation Service with \a parent. */ FmOperationService::FmOperationService( QObject *parent ) : QObject( parent ), - mCurrentOperation( 0 ), mBackupRestoreHandler( 0 ) + mBackupRestoreHandler( 0 ), mCurrentOperation( 0 ) { mThread = new FmOperationThread( this ); mThread->setObjectName( "operationThread" ); @@ -353,19 +353,20 @@ void FmOperationService::connectSignalsAndSlots( FmOperationBase *operation ) { - connect( operation, SIGNAL( showNote( QString ) ), - this, SLOT( on_operation_showNote( QString )), Qt::BlockingQueuedConnection ); + connect( operation, SIGNAL( showNote( QString ) ), // blocking because need wait for show note + this, SLOT( on_operation_showNote( QString )), Qt::BlockingQueuedConnection ); + connect( operation, SIGNAL( notifyPreparing( bool ) ), // blocking to show waiting note immediately + this, SLOT( on_operation_notifyPreparing( bool )), Qt::BlockingQueuedConnection ); + connect( operation, SIGNAL( notifyProgress( int ) ), // blocking to make progress more accurate + this, SLOT( on_operation_notifyProgress( int ) ), Qt::BlockingQueuedConnection ); + connect( operation, SIGNAL( notifyStart( bool, int ) ), // blocking to show waiting note immediately + this, SLOT( on_operation_notifyStart( bool, int ) ), Qt::BlockingQueuedConnection ); + connect( operation, SIGNAL( notifyWaiting( bool ) ), // blocking to show waiting note immediately + this, SLOT( on_operation_notifyWaiting( bool )), Qt::BlockingQueuedConnection ); + connect( operation, SIGNAL( notifyFinish() ), + this, SLOT( on_operation_notifyFinish()) ); connect( operation, SIGNAL( notifyError( int, QString ) ), this, SLOT( on_operation_notifyError( int, QString ) ) ); - connect( operation, SIGNAL( notifyStart( bool, int ) ), - this, SLOT( on_operation_notifyStart( bool, int ) ) ); - connect( operation, SIGNAL( notifyProgress( int ) ), - this, SLOT( on_operation_notifyProgress( int ) ) ); - connect( operation, SIGNAL( notifyFinish() ), - this, SLOT( on_operation_notifyFinish()) ); - connect( operation, SIGNAL( notifyWaiting( bool ) ), - this, SLOT( on_operation_notifyWaiting( bool )) ); - } /* diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/fmbkupengine/group/fmbkupengine.mmp --- a/filemanager/src/fmbkupengine/group/fmbkupengine.mmp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/fmbkupengine/group/fmbkupengine.mmp Mon Oct 04 00:06:46 2010 +0300 @@ -49,3 +49,6 @@ // End of File + + +SMPSAFE diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/fmbkupenginewrapper/fmbkupenginewrapper.pro --- a/filemanager/src/fmbkupenginewrapper/fmbkupenginewrapper.pro Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/fmbkupenginewrapper/fmbkupenginewrapper.pro Mon Oct 04 00:06:46 2010 +0300 @@ -36,6 +36,10 @@ LIBS += -leikcore LIBS += -lcone LIBS += -lsysutil - LIBS += -lplatformenv + LIBS += -lplatformenv + LIBS += -lbafl } + + +symbian:MMP_RULES += SMPSAFE diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/fmbkupenginewrapper/src/fmbackupsettings.cpp --- a/filemanager/src/fmbkupenginewrapper/src/fmbackupsettings.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/fmbkupenginewrapper/src/fmbackupsettings.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -346,8 +346,11 @@ { QStringList driveList; + QString defaultDrive; mBkupEngine->getBackupDriveList( driveList ); - QString defaultDrive( driveList.first() ); + if( !driveList.isEmpty() ) { + defaultDrive = driveList.first(); + } QDate date; QSettings settings("Nokia", "FileManager"); @@ -358,7 +361,7 @@ mScheduling = (TFileManagerBackupSchedule)(settings.value("scheduling", EFileManagerBackupScheduleNever ).toInt()); // Never schedule for default value mWeekday = (TFileManagerBackupWeekday)(settings.value("weekday", EFileManagerBackupWeekdayMonday ).toInt()); // monday for default value mTime = (settings.value("time", QTime::currentTime() ).toTime()); // empty for default - mTargetDrive = (settings.value("targetDrive", defaultDrive ) ).toString(); // C for default + mTargetDrive = (settings.value("targetDrive", defaultDrive ) ).toString(); // empty or first backup-able drive for default value mDate = (settings.value("backupDate", date)).toDate(); settings.endGroup(); refreshList(); diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/fmfiledialog/fmfiledialog.pro --- a/filemanager/src/fmfiledialog/fmfiledialog.pro Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/fmfiledialog/fmfiledialog.pro Mon Oct 04 00:06:46 2010 +0300 @@ -29,7 +29,9 @@ -lefsrv \ -lapgrfx \ -lcone \ - -lsysutil + -lsysutil \ + -lbafl \ + -leikcore TARGET.UID3 = 0x2002BCC3 @@ -41,3 +43,6 @@ headers.sources = $$EXPORT_PLATFORM_HEADERS for(header, headers.sources):BLD_INF_RULES.prj_exports += "./$$header $$APP_LAYER_PLATFORM_EXPORT_PATH($$basename(header))" } + + +symbian:MMP_RULES += SMPSAFE diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/fmfiledialog/src/fmfiledialog.cpp --- a/filemanager/src/fmfiledialog/src/fmfiledialog.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/fmfiledialog/src/fmfiledialog.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -25,12 +25,13 @@ #include "fmdrivemodel.h" #include "fmcommon.h" -#include "hbwidget.h" -#include "hblabel.h" -#include "hbaction.h" -#include "hbpushbutton.h" -#include "hblineedit.h" - +#include +#include +#include +#include +#include +#include + #include #include @@ -50,7 +51,9 @@ const QStringList &nameFilters, Options options ) { - + HbTranslator translator("filemanager"); + translator.loadCommon(); + QString ret; FmFileDialogPrivate::FmFileDialogArgs args; @@ -68,7 +71,7 @@ FmFileDialog dialog( parent ); dialog.d_ptr->init( args ); if( dialog.exec() ) { - ret = FmUtils::formatPath( dialog.d_ptr->currentPath() ); + ret = FmUtils::fillPathWithSplash( dialog.d_ptr->currentPath() ); } return ret; } @@ -79,7 +82,9 @@ const QStringList &nameFilters, Options options ) { - + HbTranslator translator("filemanager"); + translator.loadCommon(); + QString ret; FmFileDialogPrivate::FmFileDialogArgs args; @@ -97,7 +102,7 @@ FmFileDialog dialog( parent ); dialog.d_ptr->init( args ); if( dialog.exec() ) { - ret = FmUtils::formatPath( dialog.d_ptr->currentPath() ) + ret = FmUtils::fillPathWithSplash( dialog.d_ptr->currentPath() ) + dialog.d_ptr->selectedFile(); } return ret; @@ -110,6 +115,9 @@ const QStringList &nameFilters, Options options ) { + HbTranslator translator("filemanager"); + translator.loadCommon(); + QString ret; FmFileDialogPrivate::FmFileDialogArgs args; @@ -127,7 +135,7 @@ FmFileDialog dialog( parent ); dialog.d_ptr->init( args ); if( dialog.exec() ) { - ret = FmUtils::formatPath( dialog.d_ptr->currentPath() ) + ret = FmUtils::fillPathWithSplash( dialog.d_ptr->currentPath() ) + dialog.d_ptr->selectedFile(); } return ret; diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/fmfiledialog/src/fmfiledialog_p.cpp --- a/filemanager/src/fmfiledialog/src/fmfiledialog_p.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/fmfiledialog/src/fmfiledialog_p.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -28,7 +28,7 @@ #include #include -#define backButtonIcon ":image/qtg_indi_status_back.svg" +#define backButtonIcon "qtg_mono_app_exit" /*! constructor diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/fmfiledialog/src/fmfilewidget.cpp --- a/filemanager/src/fmfiledialog/src/fmfilewidget.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/fmfiledialog/src/fmfilewidget.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -18,10 +18,11 @@ */ #include "fmfilewidget.h" #include "fmutils.h" +#include "fmcommon.h" #include "fmdrivemodel.h" #include "fmdrivewatcher.h" -#include "fmcommon.h" #include "fmfileiconprovider.h" +#include "fmfilesystemproxymodel.h" #include "hbstyle.h" #include "hbabstractitemview.h" @@ -44,7 +45,8 @@ FmFileWidget::~FmFileWidget() { setModel( 0 ); - delete mFileSystemModel; + delete mFileSystemSourceModel; + delete mFileModel; delete mFileIconProvider; delete mDriveModel; @@ -59,8 +61,8 @@ if( !index.isValid() ) { return QFileInfo(); } - if( mCurrentModel == mFileSystemModel ) { - return mFileSystemModel->fileInfo( index ); + if( mCurrentModel == mFileModel ) { + return mFileModel->fileInfo( index ); } else { return QFileInfo(); } @@ -78,9 +80,9 @@ emit pathChanged( QString() ); } else { FM_LOG( "FmFileWidget::setRootPath set dir model end" ); - setModel( mFileSystemModel ); + setModel( mFileModel ); FM_LOG( "FmFileWidget::setRootPath set dir model end" ); - mListView->setRootIndex( mFileSystemModel->setRootPath( pathName ) ); + mListView->setRootIndex( mFileModel->setRootPath( pathName ) ); FM_LOG( "FmFileWidget::setRootPath set rootIndex" ); emit pathChanged( pathName ); } @@ -105,21 +107,21 @@ } FM_LOG("FmFileWidget::on_list_activated setModel dir start" ); - setModel( mFileSystemModel ); + setModel( mFileModel ); FM_LOG("FmFileWidget::on_list_activated setModel dir end" ); setRootPath( checkedPath ); FM_LOG("FmFileWidget::on_list_activated setRootIndex" ); emit pathChanged( checkedPath ); FM_LOG("FmFileWidget::on_list_activated finish emit pathChanged" ); } - else if( mCurrentModel == mFileSystemModel ) { + else if( mCurrentModel == mFileModel ) { //If current model is FileSystemModel, open path or emit file activate signal. - if ( mFileSystemModel->isDir( mActivatedModelIndex ) ) { + if ( mFileModel->isDir( mActivatedModelIndex ) ) { FM_LOG("FmFileWidget::on_list_activated start changeRootIndex" ); changeRootIndex( mActivatedModelIndex ); FM_LOG("FmFileWidget::on_list_activated finish changeRootIndex" ); } else { - QFileInfo fileInfo( mFileSystemModel->filePath( mActivatedModelIndex ) ); + QFileInfo fileInfo( mFileModel->filePath( mActivatedModelIndex ) ); if( fileInfo.isFile() ) { emit fileActivated( fileInfo.fileName() ); FM_LOG("FmFileWidget::on_list_activated finish emit fileActivated" ); @@ -133,24 +135,24 @@ void FmFileWidget::setModelFilter( QDir::Filters filters ) { - mFileSystemModel->setFilter( filters ); + mFileModel->setFilter( filters ); } void FmFileWidget::setNameFilters( const QStringList &nameFilters ) { - mFileSystemModel->setNameFilters( nameFilters ); + mFileModel->setNameFilters( nameFilters ); } void FmFileWidget::changeRootIndex( const QModelIndex &index ) { FM_LOG("FmFileWidget::changeRootIndex start" ); - if( mCurrentModel != mFileSystemModel ) { - FM_LOG("FmFileWidget::changeRootIndex end because model not equal mFileSystemModel" ); + if( mCurrentModel != mFileModel ) { + FM_LOG("FmFileWidget::changeRootIndex end because model not equal mFileModel" ); return; } - mFileSystemModel->fetchMore(index); - QString filePath = mFileSystemModel->fileInfo( index ).absoluteFilePath(); + mFileModel->fetchMore(index); + QString filePath = mFileModel->fileInfo( index ).absoluteFilePath(); // pathChanged signal will be emitted in setRootPath setRootPath( filePath ); FM_LOG("FmFileWidget::changeRootIndex end" ); @@ -170,10 +172,15 @@ FmDriveModel::FillWithVolume | FmDriveModel::FillWithDefaultVolume | FmDriveModel::HideUnAvailableDrive ); qDebug( QTime::currentTime().toString().toUtf8().data() ); - mFileSystemModel = new QFileSystemModel( this ); + mFileSystemSourceModel = new QFileSystemModel( this ); mFileIconProvider = new FmFileIconProvider(); - mFileSystemModel->setIconProvider( mFileIconProvider ); - qDebug("constructed mFileSystemModel"); + mFileSystemSourceModel->setIconProvider( mFileIconProvider ); + qDebug("constructed mFileSystemSourceModel"); + + + mFileModel = new FmFileSystemProxyModel( this ); + mFileModel->setSourceModel( mFileSystemSourceModel ); + qDebug( QTime::currentTime().toString().toUtf8().data() ); setModel( mDriveModel ); @@ -207,7 +214,7 @@ ViewType viewType = DriveView; if( mCurrentModel == mDriveModel ) { viewType = DriveView; - } else if( mCurrentModel == mFileSystemModel ) { + } else if( mCurrentModel == mFileModel ) { viewType = DirView; } else { Q_ASSERT( false ); diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/fmfiledialog/src/fmfilewidget.h --- a/filemanager/src/fmfiledialog/src/fmfilewidget.h Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/fmfiledialog/src/fmfilewidget.h Mon Oct 04 00:06:46 2010 +0300 @@ -24,13 +24,15 @@ #include #include -class QFileSystemModel; class FmDriveModel; class FmDriveWatcher; -class HbListView; +class FmFileIconProvider; +class FmFileSystemProxyModel; + +class QFileSystemModel; class QGraphicsLinearLayout; -class FmFileIconProvider; +class HbListView; class FmFileWidget : public HbWidget { @@ -69,9 +71,10 @@ private: HbListView *mListView; - QGraphicsLinearLayout *mLayout; - QFileSystemModel *mFileSystemModel; - FmDriveModel *mDriveModel; + QGraphicsLinearLayout *mLayout; + QFileSystemModel *mFileSystemSourceModel; + FmFileSystemProxyModel *mFileModel; + FmDriveModel *mDriveModel; QAbstractItemModel *mCurrentModel; FmDriveWatcher *mDriveWatcher; diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/inc/commonutils.pri --- a/filemanager/src/inc/commonutils.pri Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/inc/commonutils.pri Mon Oct 04 00:06:46 2010 +0300 @@ -18,32 +18,44 @@ $$PWD/fmdrivemodel.h \ $$PWD/fmfileiconprovider.h \ $$PWD/fmdrivewatcher/fmdrivewatcher.h \ - $$PWD/fmfiletyperecognizer.h + $$PWD/fmfiletyperecognizer.h \ + $$PWD/fmfilesystemproxymodel.h \ + $$PWD/fmserviceutils/fmserviceutils.h INTERNAL_SOURCES += $$PWD/fmdrivemodel.cpp \ $$PWD/fmfileiconprovider.cpp \ $$PWD/fmdrivewatcher/fmdrivewatcher.cpp \ $$PWD/fmfiletyperecognizer.cpp \ - $$PWD/fmutils.cpp + $$PWD/fmutils.cpp \ + $$PWD/fmfilesystemproxymodel.cpp \ + $$PWD/fmserviceutils/fmserviceutils.cpp symbian { INTERNAL_HEADERS += $$PWD/fms60utils.h \ $$PWD/fmdrivewatcher/private/symbian/fmdrivewatcherprivate.h \ - $$PWD/fmdrivewatcher/private/symbian/fmdriveevent.h + $$PWD/fmdrivewatcher/private/symbian/fmdriveevent.h \ + $$PWD/fmserviceutils/private/symbian/fmserviceutilsprivate.h \ + $$PWD/fmserviceutils/private/symbian/fmserviceutilshandler.h INTERNAL_SOURCES += $$PWD/fmutils_s60.cpp \ $$PWD/fms60utils.cpp \ $$PWD/fmdrivewatcher/private/symbian/fmdrivewatcherprivate.cpp \ - $$PWD/fmdrivewatcher/private/symbian/fmdriveevent.cpp + $$PWD/fmdrivewatcher/private/symbian/fmdriveevent.cpp \ + $$PWD/fmserviceutils/private/symbian/fmserviceutilsprivate.cpp \ + $$PWD/fmserviceutils/private/symbian/fmserviceutilshandler.cpp } win32 { INCLUDEPATH += $$PWD/fmdrivewatcher/ INCLUDEPATH += $$PWD/fmdrivewatcher/private/win32/ + INCLUDEPATH += $$PWD/fmserviceutils/ + INCLUDEPATH += $$PWD/fmserviceutils/private/win32/ - INTERNAL_HEADERS += $$PWD/fmdrivewatcher/private/win32/fmdrivewatcherprivate.h + INTERNAL_HEADERS += $$PWD/fmdrivewatcher/private/win32/fmdrivewatcherprivate.h \ + $$PWD/fmserviceutils/private/win32/fmserviceutilsprivate.h INTERNAL_SOURCES += $$PWD/fmutils_win.cpp \ - $$PWD/fmdrivewatcher/private/win32/fmdrivewatcherprivate.cpp + $$PWD/fmdrivewatcher/private/win32/fmdrivewatcherprivate.cpp \ + $$PWD/fmserviceutils/private/win32/fmserviceutilsprivate.cpp } diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/inc/fmdefine.h --- a/filemanager/src/inc/fmdefine.h Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/inc/fmdefine.h Mon Oct 04 00:06:46 2010 +0300 @@ -91,4 +91,13 @@ // is not end with dot( trim blank characters in the end first ) #define Regex_ValidNotEndWithDot QString( "^.*[^\\.\\s][\\s]*$" ) +// use slash(/) not backslash(\) or QDir::separator() because QRegExp can not recognize BackSlash(\) +#define RegexWidecard_SystemFolder QString( "?:/system/*" ) +#define RegexWidecard_SysFolder QString( "?:/sys/*" ) +#define RegexWidecard_PrivateFolder QString( "?:/private/*" ) +#define RegexWidecard_ResourceFolder QString( "?:/resource/*" ) + +#define Char_Slash QChar( '/' ) +#define Char_BackSlash QChar( '\\' ) + #endif diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/inc/fmfilesystemproxymodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/src/inc/fmfilesystemproxymodel.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,176 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: proxy model for QFileSystemModel +* +*/ + +#include "fmfilesystemproxymodel.h" +#include "fmutils.h" +#include + +#include + +// name column number, this define comes from implementation of QFileSystemModel +const int NameColumn = 0; + +/*! + Constructor +*/ +FmFileSystemProxyModel::FmFileSystemProxyModel( QObject *parent ) : + QSortFilterProxyModel( parent ) +{ + +} + +/*! + Destructor +*/ +FmFileSystemProxyModel::~FmFileSystemProxyModel() +{ + +} + +/*! + return data by \a index and \a role + this function will localize the folder by HbDirectoryNameLocalizer +*/ +QVariant FmFileSystemProxyModel::data ( const QModelIndex & index, int role ) const +{ + QAbstractItemModel *itemModel = sourceModel(); + QFileSystemModel *sourceModel = qobject_cast( itemModel ); + if( sourceModel && ( role == Qt::DisplayRole ) ) { + QString name( FmUtils::localize(sourceModel->fileInfo( mapToSource( index ) ).absoluteFilePath()) ); + if( name.isEmpty() ) { + return sourceModel->data( mapToSource( index ), role ); + } else { + return name; + } + } + if( sourceModel ) + { + return sourceModel->data( mapToSource( index ), role ); + } + else + { + return QVariant(); + } +} + +/*! + Return fileInfo by \a index + Return empty QFileInfo if sourceModel is not QFileSystemModel +*/ +QFileInfo FmFileSystemProxyModel::fileInfo ( const QModelIndex & index ) const +{ + QAbstractItemModel *itemModel = sourceModel(); + QFileSystemModel *sourceModel = qobject_cast( itemModel ); + if( sourceModel ) { + return sourceModel->fileInfo( mapToSource( index ) ); + } + + return QFileInfo(); +} + +/*! + Sets the directory \a newPath as current path to display + Return empty QModelIndex if sourceModel is not QFileSystemModel +*/ +QModelIndex FmFileSystemProxyModel::setRootPath ( const QString & newPath ) +{ + QAbstractItemModel *itemModel = sourceModel(); + QFileSystemModel *sourceModel = qobject_cast( itemModel ); + if( sourceModel ) { + return mapFromSource( sourceModel->setRootPath( newPath ) ); + } + + return QModelIndex(); +} + +/*! + Judge if object pointed by \a index is a directory. + Return false also if sourceModel is not QFileSystemModel +*/ +bool FmFileSystemProxyModel::isDir ( const QModelIndex & index ) const +{ + QAbstractItemModel *itemModel = sourceModel(); + QFileSystemModel *sourceModel = qobject_cast( itemModel ); + if( sourceModel ) { + return sourceModel->isDir( mapToSource( index ) ); + } + + return false; +} + +/*! + Get filePath by \a index. + Return empty string if sourceModel is not QFileSystemModel +*/ +QString FmFileSystemProxyModel::filePath ( const QModelIndex & index ) const +{ + QAbstractItemModel *itemModel = sourceModel(); + QFileSystemModel *sourceModel = qobject_cast( itemModel ); + if( sourceModel ) { + return sourceModel->filePath( mapToSource( index ) ); + } + + return QString(); +} + +/*! + Set model filters + Nothing will be done if sourceModel is not QFileSystemModel +*/ +void FmFileSystemProxyModel::setFilter ( QDir::Filters filters ) +{ + QAbstractItemModel *itemModel = sourceModel(); + QFileSystemModel *sourceModel = qobject_cast( itemModel ); + if( sourceModel ) { + sourceModel->setFilter( filters ); + } +} + +/*! + Set name filters + Nothing will be done if sourceModel is not QFileSystemModel +*/ +void FmFileSystemProxyModel::setNameFilters(const QStringList &filters) +{ + QAbstractItemModel *itemModel = sourceModel(); + QFileSystemModel *sourceModel = qobject_cast( itemModel ); + if( sourceModel ) { + sourceModel->setNameFilters( filters ); + } +} + +/* + Filter directories that should not be seen by user. + For example, return false for such folders: C:\sys\, C:\system\, C:\private\, C:\resource\ + Return default value(true) if sourceModel is not QFileSystemModel +*/ +bool FmFileSystemProxyModel::filterAcceptsRow(int sourceRow, + const QModelIndex &sourceParent) const +{ + QAbstractItemModel *itemModel = sourceModel(); + QFileSystemModel *sourceModel = qobject_cast( itemModel ); + if( sourceModel ) { + QModelIndex nameIndex = sourceModel->index(sourceRow, NameColumn, sourceParent); + QFileInfo fileInfo = sourceModel->fileInfo( nameIndex ); + QString absoluteFilePath = fileInfo.absoluteFilePath(); + if( FmUtils::isSystemFolder( absoluteFilePath ) ) { + return false; + } + } + return true; +} + diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/inc/fmfilesystemproxymodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/src/inc/fmfilesystemproxymodel.h Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: file system proxy model, used to filter system folders +* +*/ + +#ifndef FMFILESYSTEMPROXYMODEL_H +#define FMFILESYSTEMPROXYMODEL_H + +#include +#include +#include +#include +#include + +/*! + \class FmFileSystemProxyModel + \brief The class FmFileSystemProxyModel provide file system model + that can filter system folder and enable folder localization if source model is QFileSystemModel + Most functions only can be used when source model is QFileSystemModel +*/ +class FmFileSystemProxyModel : public QSortFilterProxyModel +{ +Q_OBJECT +public: + + explicit FmFileSystemProxyModel( QObject *parent = 0 ); + virtual ~FmFileSystemProxyModel(); + + virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; + QFileInfo fileInfo ( const QModelIndex & index ) const; + QModelIndex setRootPath ( const QString & newPath ); + bool isDir ( const QModelIndex & index ) const; + QString filePath ( const QModelIndex & index ) const; + void setFilter ( QDir::Filters filters ); + void setNameFilters(const QStringList &filters); + +private: + virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; +}; + + + +#endif diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/inc/fmfiletyperecognizer.cpp --- a/filemanager/src/inc/fmfiletyperecognizer.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/inc/fmfiletyperecognizer.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -49,6 +49,7 @@ mFileExtensionMap.insert( QString( "3g2" ), FileTypeVideo ); mFileExtensionMap.insert( QString( "rmvb" ),FileTypeVideo ); mFileExtensionMap.insert( QString( "mkv" ), FileTypeVideo ); + mFileExtensionMap.insert( QString( "3gpp" ),FileTypeVideo ); mFileExtensionMap.insert( QString( "aac" ), FileTypeTone ); diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/inc/fmserviceutils/fmserviceutils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/src/inc/fmserviceutils/fmserviceutils.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* +* Description: +* The source file of service utils +*/ + +#include "fmserviceutils.h" + +#include "fmserviceutilsprivate.h" + +FmServiceUtils::FmServiceUtils( QObject *parent ) : QObject( parent ) +{ + d = new FmServiceUtilsPrivate; +} + +FmServiceUtils::~FmServiceUtils() +{ + delete d; +} + +/*! + send files that included in \a filePathList via ShareUi +*/ +void FmServiceUtils::sendFile( const QStringList &filePathList ) +{ + d->sendFile( filePathList ); +} + +/*! + call CBaBackupSessionWrapper to close apps, for example, before formant, apps need be closed + this is synchronous which will take a while, please call this function in thread +*/ +void FmServiceUtils::closeApps() +{ + d->closeApps(); +} + +/*! + call CBaBackupSessionWrapper to restart apps + for example, after formant, closed apps need be restarted + this is synchronous which will return quickly. +*/ +void FmServiceUtils::restartApps() +{ + d->restartApps(); +} diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/inc/fmserviceutils/fmserviceutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/src/inc/fmserviceutils/fmserviceutils.h Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* +* Description: +* The header file of service utils +*/ + +#ifndef FMSERVICEUTILS_H +#define FMSERVICEUTILS_H + +#include +#include + +class FmServiceUtilsPrivate; + +/*! + \class FmServiceUtils + \brief The class FmServiceUtils provide some service utils APIs + As FmUtils provide static APIs, FmServiceUtils provide non-static APIs +*/ +class FmServiceUtils : public QObject +{ +Q_OBJECT +public: + FmServiceUtils( QObject *parent = 0 ); + virtual ~FmServiceUtils(); + void sendFile( const QStringList &filePathList ); + + void closeApps(); + void restartApps(); + +private: + FmServiceUtilsPrivate *d; +}; + + +#endif diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/inc/fmserviceutils/private/symbian/fmserviceutilshandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/src/inc/fmserviceutils/private/symbian/fmserviceutilshandler.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,173 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* +* Description: +* The source file of service utils handler +*/ + + + +// INCLUDE FILES +#include "fmserviceutilshandler.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fmutils.h" +#include +#include + +// CONSTANTS +const TInt KAppCloseTimeout = 1000000; + +/*! + constructor. +*/ +CFmServiceUtilsHandler::CFmServiceUtilsHandler() : + CActive( CActive::EPriorityStandard ) +{ +} + +/*! + Two-phased constructor. +*/ +void CFmServiceUtilsHandler::ConstructL() +{ + CActiveScheduler::Add( this ); +} + +/*! + Two-phased constructor. +*/ +CFmServiceUtilsHandler* CFmServiceUtilsHandler::NewL() + { + RFs& fs( CCoeEnv::Static()->FsSession() ); + CFmServiceUtilsHandler* self = + new( ELeave ) CFmServiceUtilsHandler(); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + + return self; + } + +/*! + destructor. +*/ +CFmServiceUtilsHandler::~CFmServiceUtilsHandler() +{ + Cancel(); + if( iBSWrapper ) { + delete iBSWrapper; + iBSWrapper = 0; + } +} + +/* + \sa CActive +*/ +void CFmServiceUtilsHandler::DoCancel() +{ +} + +/* + \sa CActive +*/ +void CFmServiceUtilsHandler::RunL() + { + iWait.AsyncStop(); + TInt err( iStatus.Int() ); + } + +/* + \sa CActive +*/ +TInt CFmServiceUtilsHandler::RunError( TInt aError ) +{ + iWait.AsyncStop(); + return KErrNone; +} + +/* + Call CBaBackupSessionWrapper to close apps + this is synchronous which will take a while, please call this function in thread +*/ +void CFmServiceUtilsHandler::CloseAppsL() +{ + if( iBSWrapper ) { + delete iBSWrapper; + iBSWrapper = 0; + } + + iBSWrapper = CBaBackupSessionWrapper::NewL(); + + TBackupOperationAttributes atts( + MBackupObserver::EReleaseLockNoAccess, + MBackupOperationObserver::EStart ); + iBSWrapper->NotifyBackupOperationL( atts ); + iBSWrapper->CloseAll( MBackupObserver::EReleaseLockNoAccess, iStatus ); + SetActive(); + + // Memory card formatting cannot be executed if there are open files on it. + // It has been detected, that in some cases memory card using applications + // have no time to close file handles before formatting is tried to be executed. + // To address this issue, we need to add a delay here after client-notification + // about pending format and real formatting procedure. + User::After( KAppCloseTimeout ); + StartWait(); +} + +/* + Call CBaBackupSessionWrapper to restart closed apps + this is synchronous which will return quickly. +*/ +void CFmServiceUtilsHandler::RestartAppsL() +{ + if ( !iBSWrapper ) + { + return; + } + + TBackupOperationAttributes atts( + MBackupObserver::ETakeLock, MBackupOperationObserver::EEnd ); + iBSWrapper->NotifyBackupOperationL( atts ); + iBSWrapper->RestartAll(); + + // Get rid of the wrapper instance + delete iBSWrapper; + iBSWrapper = 0; +} + +/* + wait till request returned in RunL +*/ +void CFmServiceUtilsHandler::StartWait() +{ + if ( iWait.IsStarted() != (TInt)ETrue ) + { + iWait.Start(); + } +} + +// End of File diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/inc/fmserviceutils/private/symbian/fmserviceutilshandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/src/inc/fmserviceutils/private/symbian/fmserviceutilshandler.h Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* +* Description: +* The header file of service utils handler +*/ + + +#ifndef FMSERVICEUTILSHANDLER_H +#define FMSERVICEUTILSHANDLER_H + +#include +#include +#include + + +// INCLUDES +#include +#include + + +// FORWARD DECLARATIONS +class CBaBackupSessionWrapper; + +/*! + \class CFmServiceUtilsHandler + \brief The class CFmServiceUtilsHandler provide implement of service utils APIs +*/ +NONSHARABLE_CLASS(CFmServiceUtilsHandler) : + public CActive + { + +public: + static CFmServiceUtilsHandler* NewL(); + virtual ~CFmServiceUtilsHandler(); + +public: // New methods + void CloseAppsL(); + void RestartAppsL(); + +private: // From CActive + void DoCancel(); + void RunL(); + TInt RunError( TInt aError ); + +private: + + CFmServiceUtilsHandler(); + void ConstructL(); + void StartWait(); + +private: // Data + /** + * Last process error + */ + TInt iLastError; + + /** + * For closing and restarting open files while formatting + */ + CBaBackupSessionWrapper* iBSWrapper; + + /** + * Target drive of the process + */ + TInt iDrive; + + /** + * Wait is used to change asynchronous function to synchronous function + */ + CActiveSchedulerWait iWait; + }; + +#endif + +// End of File diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/inc/fmserviceutils/private/symbian/fmserviceutilsprivate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/src/inc/fmserviceutils/private/symbian/fmserviceutilsprivate.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* +* Description: +* The source file of service utils private +*/ + +#include "fmserviceutilsprivate.h" +#include "fmserviceutilshandler.h" +#include "fmcommon.h" +#include + +FmServiceUtilsPrivate::FmServiceUtilsPrivate() + :mShareUi( 0 ), mServiceUtilsHandler( 0 ) +{ + +} + +FmServiceUtilsPrivate::~FmServiceUtilsPrivate() +{ + if( mShareUi ) { + delete mShareUi; + mShareUi = 0; + } + + if( mServiceUtilsHandler ) { + delete mServiceUtilsHandler; + mServiceUtilsHandler = 0; + } + +} + +/* + return \a shareUi which is used to send files. +*/ +ShareUi *FmServiceUtilsPrivate::shareUi() +{ + if( !mShareUi ) { + mShareUi = new ShareUi; + } + return mShareUi; +} + +/* + return \a CFmServiceUtilsHandler which is used to closeApps and restartApps +*/ +CFmServiceUtilsHandler *FmServiceUtilsPrivate::serviceUtilsHandler() +{ + if( !mServiceUtilsHandler ) { + TRAPD(err, mServiceUtilsHandler = CFmServiceUtilsHandler::NewL()); + if( err != KErrNone ) { + mServiceUtilsHandler = 0; + } + } + return mServiceUtilsHandler; +} + +/*! + send files that included in \a filePathList via ShareUi +*/ +void FmServiceUtilsPrivate::sendFile( const QStringList &filePathList ) +{ + // send do not accept const QStringList, so use QStringList()<send( QStringList()<CloseAppsL() ); + } +} + +/*! + call CBaBackupSessionWrapper to restart apps + for example, after formant, closed apps need be restarted + this is synchronous which will return quickly. +*/ +void FmServiceUtilsPrivate::restartApps() +{ + CFmServiceUtilsHandler *utilsHandler = serviceUtilsHandler(); + if( utilsHandler ) { + TRAP_IGNORE( serviceUtilsHandler()->RestartAppsL() ); + } +} + diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/inc/fmserviceutils/private/symbian/fmserviceutilsprivate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/src/inc/fmserviceutils/private/symbian/fmserviceutilsprivate.h Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* +* Description: +* The header file of service utils private +*/ + +#ifndef FMSERVICEUTILSPRIVATE_H +#define FMSERVICEUTILSPRIVATE_H + +#include +#include + +class ShareUi; +class CFmServiceUtilsHandler; + +/*! + \class FmServiceUtilsPrivate + \brief The class FmServiceUtilsPrivate provide service utils APIs private wrapper +*/ +class FmServiceUtilsPrivate +{ +public: + FmServiceUtilsPrivate(); + virtual ~FmServiceUtilsPrivate(); + + void sendFile( const QStringList &filePath ); + void closeApps(); + void restartApps(); + +private: + ShareUi *shareUi(); + CFmServiceUtilsHandler *serviceUtilsHandler(); + +private: + // used to send files + ShareUi *mShareUi; + + // used for some service utils + CFmServiceUtilsHandler *mServiceUtilsHandler; + +}; + +#endif diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/inc/fmserviceutils/private/win32/fmserviceutilsprivate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/src/inc/fmserviceutils/private/win32/fmserviceutilsprivate.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* +* Description: +* The source file of service utils private for win32 wrapper +*/ + +#include "fmserviceutilsprivate.h" + +/*! + constructor +*/ +FmServiceUtilsPrivate::FmServiceUtilsPrivate() +{ +} + +/*! + destructor +*/ +FmServiceUtilsPrivate::~FmServiceUtilsPrivate() +{ +} + +/*! + dummy function for win32 build +*/ +void FmServiceUtilsPrivate::sendFile( const QStringList &filePathList ) +{ + Q_UNUSED( filePathList ); +} + +/*! + dummy function for win32 build +*/ +void FmServiceUtilsPrivate::closeApps() +{ + +} + +/*! + dummy function for win32 build +*/ +void FmServiceUtilsPrivate::restartApps() +{ + +} diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/inc/fmserviceutils/private/win32/fmserviceutilsprivate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/src/inc/fmserviceutils/private/win32/fmserviceutilsprivate.h Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* +* Description: +* The header file of service utils private for win32 wrapper +*/ + +#ifndef FMSERVICEUTILSPRIVATE_H +#define FMSERVICEUTILSPRIVATE_H + +#include + +class FmServiceUtilsPrivate +{ +public: + FmServiceUtilsPrivate(); + virtual ~FmServiceUtilsPrivate(); + + void sendFile( const QStringList &filePathList ); + void closeApps(); + void restartApps(); + +}; + +#endif diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/inc/fmutils.cpp --- a/filemanager/src/inc/fmutils.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/inc/fmutils.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -18,11 +18,12 @@ #include "fmutils.h" -#include +#include #include #include + /*! Used to get drive type for convenience. */ @@ -117,10 +118,11 @@ } /*! - All "/" and "\" in \a path will be changed to QDir::separator + All "/" and "\" in \a path will be changed to \a splitter + QDir::separator is default value for splitter \sa fillPathWithSplash, fillPathWithSplash will append QDir::separator in the end */ -QString FmUtils::formatPath( const QString &path ) +QString FmUtils::formatPath( const QString &path, const QChar &splitter ) { QString formatPath; if( path.isEmpty() ) { @@ -129,7 +131,7 @@ foreach( const QChar &ch, path ) { if( ch == QChar('\\') || ch == QChar('/') ) { - formatPath.append( QDir::separator() ); + formatPath.append( splitter ); } else { formatPath.append( ch ); } @@ -139,22 +141,23 @@ } /*! - Fill splash in the end of \a filePath. And all "/" and "\" will be changed to QDir::separator + Fill splash in the end of \a filePath. And all "/" and "\" will be changed to \a splitter + QDir::separator is default value for splitter Please do not call this function if path is a file. Use \a formatPath instead, \a formatPath will not append QDir::separator in the end. \sa formatPath only changed "/" and "\" to QDir::separator */ -QString FmUtils::fillPathWithSplash( const QString &filePath ) +QString FmUtils::fillPathWithSplash( const QString &filePath, const QChar &splitter ) { QString newFilePath; if( filePath.isEmpty() ) { return newFilePath; } - newFilePath = formatPath( filePath ); + newFilePath = formatPath( filePath, splitter ); - if( newFilePath.right( 1 )!= QDir::separator() ){ - newFilePath.append( QDir::separator() ); + if( newFilePath.right( 1 )!= splitter ){ + newFilePath.append( splitter ); } return newFilePath; } @@ -410,3 +413,27 @@ FM_LOG("FmUtils::isSubFolder: false"); return false; } + +/*! + Check if \a path is system path. +*/ +bool FmUtils::isSystemFolder( const QString &path ) +{ + QFileInfo fileInfo( path ); + if( fileInfo.isDir() ) { + QString checkedPath( fillPathWithSplash( path, Char_Slash ) ); + + QRegExp systemFolder ( RegexWidecard_SystemFolder, Qt::CaseInsensitive, QRegExp::Wildcard ); + QRegExp sysFolder ( RegexWidecard_SysFolder, Qt::CaseInsensitive, QRegExp::Wildcard ); + QRegExp privateFolder ( RegexWidecard_PrivateFolder, Qt::CaseInsensitive, QRegExp::Wildcard ); + QRegExp resourceFolder( RegexWidecard_ResourceFolder, Qt::CaseInsensitive, QRegExp::Wildcard ); + + if( systemFolder.exactMatch( checkedPath ) || + sysFolder.exactMatch( checkedPath ) || + privateFolder.exactMatch( checkedPath ) || + resourceFolder.exactMatch( checkedPath ) ) { + return true; + } + } + return false; +} diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/inc/fmutils.h --- a/filemanager/src/inc/fmutils.h Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/inc/fmutils.h Mon Oct 04 00:06:46 2010 +0300 @@ -21,6 +21,7 @@ #include "fmcommon.h" +#include #include /*! @@ -148,8 +149,8 @@ static QString getDriveLetterFromPath( const QString &path ); static QString formatStorageSize( quint64 size ); static bool isDrive( const QString &path ); - static QString formatPath( const QString &path ); - static QString fillPathWithSplash( const QString &filePath ); + static QString formatPath( const QString &path, const QChar &splitter = QDir::separator() ); + static QString fillPathWithSplash( const QString &filePath, const QChar &splitter = QDir::separator() ); static QString removePathSplash( const QString &filePath ); static void getDriveList( QStringList &driveList, bool isHideUnAvailableDrive ); static QString fillDriveVolume( QString driveName, bool isFillWithDefaultVolume ); @@ -159,6 +160,7 @@ static bool checkFolderFileName( const QString& name ); static bool checkNewFolderOrFile( const QString& fileName, const QString &path, QString &errString ); static bool isSubLevelPath( const QString &src, const QString &dest ); + static bool isSystemFolder( const QString &path ); // ////////////////////////////////////////////////////////////////// @@ -202,6 +204,8 @@ static bool isDriveC( const QString &driverName ); static int getMaxFileNameLength(); static bool checkMaxPathLength( const QString& path ); + static void setSystem( bool isSystem ); + static QString numberToDriveName( int drive ); // ////////////////////////////////////////////////////////////////// }; diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/inc/fmutils_s60.cpp --- a/filemanager/src/inc/fmutils_s60.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/inc/fmutils_s60.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -21,6 +21,8 @@ #include "fmcommon.h" #include "fms60utils.h" +#include +#include #include #include #include @@ -54,8 +56,11 @@ if( driveName.isEmpty() ) { return FmDriverInfo( 0, 0, driveName, QString(), FmDriverInfo::EDriveNotPresent ); } - CCoeEnv *env = CCoeEnv::Static(); - RFs& fs = env->FsSession(); + // CCoeEnv *env = CCoeEnv::Static(); + // RFs& fs = env->FsSession(); + // make new fs so that this function can be called in thread + RFs fs; + fs.Connect(); TVolumeInfo volumeInfo; TInt drive = 0; @@ -186,6 +191,7 @@ "_errorCode:" + QString::number( errorCode ) + "_driveSatus:" + QString::number( state ) ); FM_LOG( logString ); + fs.Close(); return FmDriverInfo( volumeInfo.iSize, volumeInfo.iFree, driveName, volumeName, state ); } @@ -383,8 +389,11 @@ } } - CCoeEnv *env = CCoeEnv::Static(); - RFs& fs = env->FsSession(); + // CCoeEnv *env = CCoeEnv::Static(); + // RFs& fs = env->FsSession(); + // make new fs so that this function can be called in thread + RFs fs; + fs.Connect(); TInt drive = 0; drive = driveName[0].toUpper().toAscii() - 'A' + EDriveA; @@ -396,6 +405,7 @@ QString logString = "Rename error:" + QString::number( err ); FM_LOG( logString ); + fs.Close(); if( err == KErrNone ){ return FmErrNone; } @@ -512,6 +522,12 @@ FM_LOG( QString( "isPathAccessabel false: path contain C and not in data folder" ) ); return FmErrPathDenied; } + + if( isSystemFolder( fileInfo.absoluteFilePath() ) ) { + FM_LOG( QString( "isPathAccessabel false: path is system path that not accessable" ) ); + return FmErrPathDenied; + } + if( !checkDriveAccessFilter( FmUtils::getDriveNameFromPath( fileInfo.absoluteFilePath() ) ) ){ return FmErrDriveDenied; } @@ -655,8 +671,9 @@ } /*! + return localized file name by \a path, empty string returned for non-localized path. In Symbian system, default folders will be localized. - So localize is used to check if a path is a default folder + So localize also can be used to check if a path is a default folder \sa isDefaultFolder */ QString FmUtils::localize( const QString &path ) @@ -847,3 +864,28 @@ } return true; } + +/*! + Set appliation as system mode if \a isSystem is true. + Otherwise set application as non-system mode +*/ +void FmUtils::setSystem( bool isSystem ) +{ + CCoeEnv* coeEnv = CCoeEnv::Static(); + CEikonEnv* eikonEnv = (STATIC_CAST(CEikonEnv*,coeEnv)); + if( isSystem ) { + eikonEnv->SetSystem(ETrue); + } else { + eikonEnv->SetSystem(EFalse); + } +} + +/*! + return drive name by \a drive +*/ +QString FmUtils::numberToDriveName( int drive ) +{ + QChar driveChar( drive - EDriveA + 'A' ); + QString driveName = QString( driveChar ) + ':'; + return driveName; +} diff -r 22e202702210 -r 1bebd60c0f00 filemanager/src/inc/fmutils_win.cpp --- a/filemanager/src/inc/fmutils_win.cpp Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/src/inc/fmutils_win.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -32,6 +32,9 @@ const int KMaxFileName=0x100; const int KMaxPath=0x100; +// EDriveA means number of A drive +const int EDriveA = 0; + FmDriverInfo FmUtils::queryDriverInfo( const QString &driveName ) { quint64 size = 0; @@ -168,6 +171,19 @@ } /*! + return localized file name by \a path, empty string returned for non-localized path. + In Symbian system, default folders will be localized. + So localize also can be used to check if a path is a default folder + Do not need localize on windows. + \sa isDefaultFolder +*/ +QString FmUtils::localize( const QString &path ) +{ + Q_UNUSED( path ); + return QString(); +} + +/*! set the \a desFile attributes as the same with \a srcFile */ int FmUtils::setFileAttributes( const QString &srcFile, const QString &desFile ) @@ -246,3 +262,15 @@ } return true; } + +void FmUtils::setSystem( bool isSystem ) +{ + Q_UNUSED( isSystem ); +} + +QString FmUtils::numberToDriveName( int drive ) +{ + QChar driveChar( drive - EDriveA + 'A' ); + QString driveName = QString( driveChar ) + ':'; + return driveName; +} diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/tsrc.pro --- a/filemanager/tsrc/tsrc.pro Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/tsrc/tsrc.pro Mon Oct 04 00:06:46 2010 +0300 @@ -15,7 +15,11 @@ # TEMPLATE = subdirs -SUBDIRS = unit/unit_backuprestoresettings +SUBDIRS = unit/unit_backuprestoresettings \ + unit/ut_fminternaldrivermodel \ + unit/ut_fminternalfmutils \ + unit/ut_fmfiletypeprovider \ + unit/ut_fmfiletyperecognizer \ CONFIG += ordered #CONFIG += symbian_test diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/unit_backuprestoresettings/unit_backuprestoresettings.pro --- a/filemanager/tsrc/unit/unit_backuprestoresettings/unit_backuprestoresettings.pro Fri Sep 17 08:27:42 2010 +0300 +++ b/filemanager/tsrc/unit/unit_backuprestoresettings/unit_backuprestoresettings.pro Mon Oct 04 00:06:46 2010 +0300 @@ -42,4 +42,6 @@ autotest.commands =/epoc32/RELEASE/WINSCW/udeb/unit_backuprestoresettings -xml -o c:/unit_backuprestoresettings.xml } } -QMAKE_EXTRA_TARGETS += test autotest \ No newline at end of file +QMAKE_EXTRA_TARGETS += test autotest + +symbian:MMP_RULES += SMPSAFE diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_common.pri --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_common.pri Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,35 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +LIBS += -lfmbkupenginewrapper +LIBS += -lfmfiledialog + +symbian { + LIBS += -lplatformenv \ + -lapmime \ + -lxqservice \ + -lxqutils \ + -lshareui \ + -lefsrv \ + -lapgrfx \ + -lcone \ + -ldirectorylocalizer \ + -lsysutil \ + -lbafl \ + -leikcore +} + +QMAKE_EXTRA_TARGETS += test autotest \ No newline at end of file diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fmfiletypeprovider/src/ut_fmfiletypeprovider.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmfiletypeprovider/src/ut_fmfiletypeprovider.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,134 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This class is test case for file manager internal api class. +* +*/ + +#include "fmfileiconprovider.h" +#include "fmfiletyperecognizer.h" +#include +#include +#include +#include +#include + + +class TestFmFileTypeProvider: public QObject +{ + Q_OBJECT + +private slots: + void initTestCase(); + + void testFmFileIconProvider(); // test the FmFileIconProvider() constructor funtion. + + void testIconKnown(); // test the icon() funtion. +// void testIconUnKnown(); + + void cleanupTestCase(); // Finalize test data +}; + +/*! + \class TestFmFileTypeProvider + \brief describe the test case's goal, like: \n + class name: FmDriveModel \n + class's description: Test the File Manager internal api functions. \n + type of test case: unit test\n + test cases' number totally: \n + */ + +void TestFmFileTypeProvider::initTestCase() +{ +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + FmFileIconProvider(); \n + 2. Case Descrition: test the constructor function. \n + 3. Input Parameters: \n    + <1> no \n + 4. Expected result: \n    + <1> no crash \n + */ +void TestFmFileTypeProvider::testFmFileIconProvider() +{ + FmFileIconProvider *testProvider = new FmFileIconProvider(); +//QMap mFileExtensionMap is a private member, can not verify the result. +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + virtual QIcon icon(const QFileInfo &info) const; \n + 2. Case Descrition: Verify the right file type is returned \n + 3. Input Parameters: \n    + <1> path = QString(XX) \n + 4. Expected result: \n    + <1> retType = FileTypeDrive \n + */ +void TestFmFileTypeProvider::testIconKnown() +{ + QFileInfo path1("C:\\image.jpg"); + QFileInfo path2("D:\\Video.rm"); + QFileInfo path3("D:\\Tone.wav"); + QFileInfo path4("Z:\\Text.doc"); + QFileInfo path5("Z:\\Install.sisx"); + QFileInfo path6("D:\\Java.jar"); + QFileInfo path7("C:\\Flash.swf"); + + FmFileIconProvider *testProvider = new FmFileIconProvider(); + QIcon retIcon1 = testProvider->icon(Drive_C); +// QVERIFY(retIcon1 != QIcon()); + + QIcon retIcon2 = testProvider->icon(Drive_D); +// QVERIFY(retIcon2 != 0); + + QIcon retIcon3 = testProvider->icon(Drive_Z); +// QVERIFY(retIcon3 != 0); + + QIcon retIcon4 = testProvider->icon(Folder_C_Data); +// QVERIFY(retIcon4 != 0); + + QIcon retIcon01 = testProvider->icon(path1); +// QVERIFY(retIcon01 != 0); + + QIcon retIcon02 = testProvider->icon(path2); +// QVERIFY(retIcon02 != 0); + + QIcon retIcon03 = testProvider->icon(path3); +// QVERIFY(retIcon03 != 0); + + QIcon retIcon04 = testProvider->icon(path4); +// QVERIFY(retIcon04 != 0); + + QIcon retIcon05 = testProvider->icon(path5); +// QVERIFY(retIcon05 != 0); + + QIcon retIcon06 = testProvider->icon(path6); +// QVERIFY(retIcon06 != 0); + + QIcon retIcon07 = testProvider->icon(path7); +// QVERIFY(retIcon07 != 0); + + delete testProvider; +} + +void TestFmFileTypeProvider::cleanupTestCase() +{ + +} + +QTEST_MAIN(TestFmFileTypeProvider) +#include "ut_fmfiletypeprovider.moc" diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fmfiletypeprovider/ut_fmfiletypeprovider.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmfiletypeprovider/ut_fmfiletypeprovider.pro Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,34 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +QT += testlib +CONFIG += hb qtestlib +CONFIG += symbian_test +TEMPLATE = app +TARGET = ut_fmfiletypeprovider +include ( ../../../src/common.pri ) +include ( ../../../src/inc/commoninc.pri ) +include ( ../../../src/inc/commonutils.pri ) +include ( ../ut_common.pri ) + +DEPENDPATH += . +INCLUDEPATH += . + +symbian:MMP_RULES += SMPSAFE + +TARGET.CAPABILITY = ALL -TCB + +SOURCES += src/ut_fmfiletypeprovider.cpp diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Flash.swf Binary file filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Flash.swf has changed diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Install.sisx Binary file filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Install.sisx has changed diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Java.jar Binary file filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Java.jar has changed diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Tone.wav Binary file filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Tone.wav has changed diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Video.rm Binary file filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Video.rm has changed diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/image.jpg Binary file filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/image.jpg has changed diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fmfiletyperecognizer/src/ut_fmfiletyperecognizer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmfiletyperecognizer/src/ut_fmfiletyperecognizer.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,189 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This class is test case for file manager internal api class. +* +*/ + +#include "fmfiletyperecognizer.h" +#include +#include +#include +#include + +class TestFmFileTypeRcognizer: public QObject +{ + Q_OBJECT + +private slots: + void initTestCase(); + + void testFmFileTypeRecognizer(); // test the FmFileTypeRecognizer() constructor. + + void testGetTypeDrive(); // test the getType() function + void testGetTypePath(); + void testGetTypeKnown(); + void testGetTypeUnKnown(); + + void cleanupTestCase(); // Finalize test data +}; + +/*! + \class TestFmFileTypeRcognizer + \brief \n + class name: FmDriveModel \n + class's description: Test the File Manager internal api functions. \n + type of test case: unit test\n + test cases' number totally: 5 \n + */ + +void TestFmFileTypeRcognizer::initTestCase() +{ +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + FmFileTypeRecognizer(); \n + 2. Case Descrition: test the constructor function. \n + 3. Input Parameters: \n    + <1> no \n + 4. Expected result: \n    + <1> no crash \n + */ +void TestFmFileTypeRcognizer::testFmFileTypeRecognizer() +{ + FmFileTypeRecognizer *testRcognizer = new FmFileTypeRecognizer(); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + FmFileTypeRecognizer::FileType getType( const QString& path ) const ; \n + 2. Case Descrition: Verify the right file type is returned \n + 3. Input Parameters: \n    + <1> path = QString(XX) \n + 4. Expected result: \n    + <1> retType = FileTypeDrive \n + */ +void TestFmFileTypeRcognizer::testGetTypeDrive() +{ + FmFileTypeRecognizer *testRcognizer = new FmFileTypeRecognizer(); + FmFileTypeRecognizer::FileType retType = testRcognizer->getType( "C:\\" ); + qDebug() << retType; + QVERIFY(retType == FmFileTypeRecognizer::FileTypeDrive); + delete testRcognizer; +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + FmFileTypeRecognizer::FileType getType( const QString& path ) const ; \n + 2. Case Descrition: Verify the right file type is returned \n + 3. Input Parameters: \n    + <1> path = QString(XX) \n + 4. Expected result: \n    + <1> retType = FileTypeFolder \n + */ +void TestFmFileTypeRcognizer::testGetTypePath() +{ + FmFileTypeRecognizer *testRcognizer = new FmFileTypeRecognizer(); + FmFileTypeRecognizer::FileType retType = testRcognizer->getType( Folder_C_Data); + qDebug() << retType; + QVERIFY(retType == FmFileTypeRecognizer::FileTypeFolder); + delete testRcognizer; +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + FmFileTypeRecognizer::FileType getType( const QString& path ) const ; \n + 2. Case Descrition: Verify the right file type is returned \n + 3. Input Parameters: \n    + <1> path = QString(XX) \n + 4. Expected result: \n    + <1> return the correct file type \n + */ +void TestFmFileTypeRcognizer::testGetTypeKnown() +{ + QString path1 = "image.jpg"; + QString path2 = "Video.rm"; + QString path3 = "Tone.wav"; + QString path4 = "Text.doc"; + QString path5 = "Install.sisx"; + QString path6 = "Java.jar"; + QString path7 = "Flash.swf"; +#ifdef FEATURE_NOT_IMPLEMENTED_TYPERECOG + QString pathWidget = "widget.wgz"; + QString pathWebLink = "abc.lnk";// Need confirm the suffix +#endif + FmFileTypeRecognizer *testRcognizer = new FmFileTypeRecognizer(); + + FmFileTypeRecognizer::FileType retType1 = testRcognizer->getType( path1); + QVERIFY(retType1 == FmFileTypeRecognizer::FileTypeImage); + + FmFileTypeRecognizer::FileType retType2 = testRcognizer->getType( path2); +// qDebug() << retType1; + QVERIFY(retType2 == FmFileTypeRecognizer::FileTypeVideo); + + FmFileTypeRecognizer::FileType retType3 = testRcognizer->getType( path3); + QVERIFY(retType3 == FmFileTypeRecognizer::FileTypeTone); + + FmFileTypeRecognizer::FileType retType4 = testRcognizer->getType( path4); + QVERIFY(retType4 == FmFileTypeRecognizer::FileTypeText); + + FmFileTypeRecognizer::FileType retType5 = testRcognizer->getType( path5); + QVERIFY(retType5 == FmFileTypeRecognizer::FileTypeSisx); + + FmFileTypeRecognizer::FileType retType6 = testRcognizer->getType( path6); + QVERIFY(retType6 == FmFileTypeRecognizer::FileTypeJava); + + FmFileTypeRecognizer::FileType retType7 = testRcognizer->getType( path7); + QVERIFY(retType7 == FmFileTypeRecognizer::FileTypeFlash); + +#ifdef FEATURE_NOT_IMPLEMENTED_TYPERECOG + FmFileTypeRecognizer::FileType retType8 = testRcognizer->getType( pathWidget); +// QVERIFY(retType8 == FmFileTypeRecognizer::FileTypeWidget); + + FmFileTypeRecognizer::FileType retType9 = testRcognizer->getType( pathWebLink); +// QVERIFY(retType9 == FmFileTypeRecognizer::FileTypeWebLink); +#endif + delete testRcognizer; +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + FmFileTypeRecognizer::FileType getType( const QString& path ) const ; \n + 2. Case Descrition: Verify the right file type is returned \n + 3. Input Parameters: \n    + <1> path = QString(XX) \n + 4. Expected result: \n    + <1> retType = FileTypeUnKnown \n + */ +void TestFmFileTypeRcognizer::testGetTypeUnKnown() +{ + FmFileTypeRecognizer *testRcognizer = new FmFileTypeRecognizer(); + + FmFileTypeRecognizer::FileType retType = testRcognizer->getType( "unknown.unknow"); + QVERIFY(retType == FmFileTypeRecognizer::FileTypeUnKnown); + delete testRcognizer; +} + +void TestFmFileTypeRcognizer::cleanupTestCase() +{ + +} + +QTEST_MAIN(TestFmFileTypeRcognizer) +#include "ut_fmfiletyperecognizer.moc" diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fmfiletyperecognizer/ut_fmfiletyperecognizer.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmfiletyperecognizer/ut_fmfiletyperecognizer.pro Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,35 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +QT += testlib +CONFIG += hb qtestlib +CONFIG += symbian_test +TEMPLATE = app +TARGET = ut_fmfiletyperecognizer + +include ( ../../../src/common.pri ) +include ( ../../../src/inc/commoninc.pri ) +include ( ../../../src/inc/commonutils.pri ) +include ( ../ut_common.pri ) + +DEPENDPATH += . +INCLUDEPATH += . + +TARGET.CAPABILITY = ALL -TCB + +symbian:MMP_RULES += SMPSAFE + +SOURCES += src/ut_fmfiletyperecognizer.cpp diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fminternaldrivermodel/runtest.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fminternaldrivermodel/runtest.bat Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,19 @@ +@rem +@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +@rem All rights reserved. +@rem This component and the accompanying materials are made available +@rem under the terms of "Eclipse Public License v1.0" +@rem which accompanies this distribution, and is available +@rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +@rem +@rem Initial Contributors: +@rem Nokia Corporation - initial contribution. +@rem +@rem Contributors: +@rem +@rem Description: +@rem + +\epoc32\RELEASE\WINSCW\udeb\ut_fminternaldrivemodel.exe -xml -o c:\ut_fminternaldrivemodel.xml +copy \epoc32\winscw\c\ut_fminternaldrivemodel.xml +del \epoc32\winscw\c\ut_fminternaldrivemodel.xml \ No newline at end of file diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fminternaldrivermodel/src/testclassdatafmdrivelistprovider.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fminternaldrivermodel/src/testclassdatafmdrivelistprovider.h Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,38 @@ +/* + * testDataClassFmDriveListProvider.h + * + * Created on: Jul 13, 2010 + * + */ + +#ifndef TESTCLASSDATAFMDRIVELISTPROVIDER_H +#define TESTCLASSDATAFMDRIVELISTPROVIDER_H +#include "fmdrivemodel.h" + +class TestDataClassFmDriveListProvider: public FmDriveListProvider +{ +public: + TestDataClassFmDriveListProvider(); + ~TestDataClassFmDriveListProvider(); + virtual void getDriveList( QStringList &driveList ); + +}; + +#endif //TESTCLASSDATAFMDRIVELISTPROVIDER_H + +TestDataClassFmDriveListProvider::TestDataClassFmDriveListProvider() +{ + +} + +TestDataClassFmDriveListProvider::~TestDataClassFmDriveListProvider() +{ + +} + +void TestDataClassFmDriveListProvider::getDriveList(QStringList &driveList) +{ + driveList<<"drive1:" + <<"drive2:" + <<"drive3:"; +} diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fminternaldrivermodel/src/ut_fminternaldrivemodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fminternaldrivermodel/src/ut_fminternaldrivemodel.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,350 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* test the file manager internal apis. +*/ + +#include "ut_fminternaldrivemodel.h" +#include "testclassdatafmdrivelistprovider.h" +#include "fmdrivemodel.h" +#include +#include +#include "fmutils.h" +/*! + \class TestFmInternalDriveModel + \brief \n + class name: FmDriveModel \n + class's description: Test the File Manager internal api functions. \n + type of test case: unit test\n + test cases' number totally: 10 \n + */ + +void TestFmInternalDriveModel::initTestCase() +{ + // translate the related text. + QString lang = QLocale::system().name(); + QString path = "z:/resource/qt/translations/"; + mTranslator.load( path + "filemanager_" + lang ); + qApp->installTranslator(&mTranslator); + + // get all the drives which can be shown, the parameters should be according to the parameter (Options) of FmDriveModel. + FmUtils::getDriveList(mDriverList, false); + qDebug() << mDriverList; +} +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + explicit FmDriveModel( QObject *parent = 0, Options options = 0, + FmDriveListProvider *driveListProvider = 0 ); \n + 2. Case Descrition: test the constructor function. \n + 3. Input Parameters: \n    + <1> parent = new QObject(), + Options = FmDriveModel::FillWithVolume, + driveListProvider = new TestDataClassFmDriveListProvider();\n    + <2> parent = new QObject(), + Options = FmDriveModel::FillWithVolume | FillWithDefaultVolume, + driveListProvider = 0 \n   + <3> parent = new QObject(); + Options = FmDriveModel::FillWithVolume | FillWithDefaultVolume |HideUnAvailableDrive, + driveListProvider = 0 \n + 4. Expected result: \n    + <1> no crash \n    + <2> no crash \n    + <3> no crash \n + */ +void TestFmInternalDriveModel::testConstructor() +{ + QObject *pObject = new QObject(); + // the class TestDataClassFmDriveListProvider is a sub class from FmDriveListProvider. + TestDataClassFmDriveListProvider *driveListProvider = new TestDataClassFmDriveListProvider(); + FmDriveModel *fmDriveModel = new FmDriveModel( pObject,FmDriveModel::FillWithVolume,driveListProvider ); + QVERIFY ( fmDriveModel != 0 ); + + // the drive number in class TestDataClassFmDriveListProvider is "3". + QVERIFY ( fmDriveModel->rowCount() == 3 ); + delete fmDriveModel; + fmDriveModel = 0; + + fmDriveModel = new FmDriveModel( pObject,FmDriveModel::FillWithVolume | FmDriveModel::FillWithDefaultVolume ,0 ); + QVERIFY ( fmDriveModel != 0 ); + QVERIFY ( fmDriveModel->rowCount() > 0 ); + delete fmDriveModel; + fmDriveModel = 0; + + fmDriveModel = new FmDriveModel( pObject, FmDriveModel::FillWithVolume | FmDriveModel::FillWithDefaultVolume | FmDriveModel::HideUnAvailableDrive ,0 ); + QVERIFY ( fmDriveModel != 0 ); + QVERIFY ( fmDriveModel->rowCount() > 0 ); + + delete fmDriveModel; + delete pObject; + delete driveListProvider; +} + +/*! + Test Case Description:\n + 1. Fucntion Name: int rowCount( const QModelIndex &parent = QModelIndex() ) const; \n + 2. Case Descrition: Verify it return the right row count. \n + 3. Input Parameters: \n    + <1> parent = QModelIndex() \n + 4. Expected result: \n    + <1> retColumnCount = 1 \n + */ +void TestFmInternalDriveModel::testRowCount() +{ + FmDriveModel *fmDriveModel = new FmDriveModel(0); + QModelIndex testIndex1 = fmDriveModel->index(1,0); + + int retRowCount1 = fmDriveModel->rowCount(testIndex1); + QVERIFY(retRowCount1 == 0); + int retRowCount2 = fmDriveModel->rowCount(); + delete fmDriveModel; +} + +/*! + Test Case Description:\n + 1. Fucntion Name: int columnCount( const QModelIndex &parent = QModelIndex() ) const; \n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> parent = QModelIndex() \n + 4. Expected result: \n    + <1> retColumnCount = 1 \n + */ +void TestFmInternalDriveModel::testColumnCount() +{ + FmDriveModel *fmDriveModel = new FmDriveModel(0); + QModelIndex testIndex = QModelIndex(); + int retColumnCount = fmDriveModel->columnCount(testIndex); + QVERIFY(retColumnCount == 1); + delete fmDriveModel; +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; \n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> index = QModelIndex(), role = Qt::DisplayRole \n    + <2> index = QModelIndex(), role = Qt::UserRole \n    + <3> index = QModelIndex(), role = Qt::DecorationRole \n    + <4> index = QModelIndex(), role = Qt::TextAlignmentRole \n    + 4. Expected result: \n    + <1> retData1 = "C:" \n    + <2> retData2 = "C:\" \n    + <3> return the right icon + <4> to be delete... + */ +void TestFmInternalDriveModel::testData() +{ + QObject *pObject = new QObject(); + TestDataClassFmDriveListProvider *driveListProvider = new TestDataClassFmDriveListProvider(); + + FmDriveModel *fmDriveModel = new FmDriveModel( 0 ); + QModelIndex index = fmDriveModel->index(0,0); + + QVariant retData1 = fmDriveModel->data(index, Qt::DisplayRole); + QString strTemp1 = retData1.toString(); + QVERIFY( strTemp1.trimmed() == "C:" ); + +// unable to verify the return icon is the right one. + QVariant retData3 = fmDriveModel->data(index, Qt::DecorationRole); + +// need to delete the "if (index.column() == 1 && role == Qt::TextAlignmentRole)", because only one column is defined. + QVariant retData4 = fmDriveModel->data(index, Qt::TextAlignmentRole); + + delete driveListProvider; + driveListProvider = 0; + delete fmDriveModel; + fmDriveModel = 0; +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + bool indexValid( const QModelIndex &index ) const; \n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> index = QModelIndex() \n    + 4. Expected result: \n    + <1> retBool = true \n + */ +void TestFmInternalDriveModel::testIndexValid() +{ + FmDriveModel *fmDriveModel = new FmDriveModel(0); + QModelIndex aIndex = fmDriveModel->index(0,0); + QModelIndex bIndex = fmDriveModel->index(0,1); + bool a = fmDriveModel->indexValid(aIndex); + QVERIFY(a == true); + bool b = fmDriveModel->indexValid(bIndex); + QVERIFY(b == true); + delete fmDriveModel; + fmDriveModel = 0; +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; \n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> section = 0, orientation = Qt::Horizontal, role = Qt::DisplayRole \n    + <2> section = 1, orientation = Qt::Horizontal, role = Qt::DisplayRole \n    + <3> section = 2, orientation = Qt::Horizontal, role = Qt::DisplayRole \n    + <4> section = 3, orientation = Qt::Horizontal, role = Qt::DisplayRole \n    + <5> section = 4, orientation = Qt::Horizontal, role = Qt::DisplayRole \n    + <6> section = 1, orientation = Qt::Vertical, role = Qt::DisplayRole \n    + <7> section = 1, orientation = Qt::Horizontal, role = Qt::UserRole \n + 4. Expected result: \n    + <1> retHeaderData.toString() = "Name" \n    + <2> retHeaderData.toString() = "Size" \n    + <3> retHeaderData.toString() = "Type" \n    + <4> retHeaderData.toString() = "Date Modified" \n    + <5> no crash \n    + <6> no crash \n    + <7> no crash \n + */ +void TestFmInternalDriveModel::testHeaderData() +{ + FmDriveModel *fmDriveModel = new FmDriveModel(0); + // + QVariant retHeaderData1 = fmDriveModel->headerData(0, Qt::Horizontal, Qt::DisplayRole); + QVERIFY(retHeaderData1.toString() == "Name"); + + QVariant retHeaderData2 = fmDriveModel->headerData(1, Qt::Horizontal, Qt::DisplayRole); + QVERIFY(retHeaderData2.toString() == "Size"); + + QVariant retHeaderData3 = fmDriveModel->headerData(2, Qt::Horizontal, Qt::DisplayRole); + QVERIFY(retHeaderData3.toString() == "Type"); + + QVariant retHeaderData4 = fmDriveModel->headerData(3, Qt::Horizontal, Qt::DisplayRole); + QVERIFY(retHeaderData4.toString() == "Date Modified"); + + QVariant retHeaderData5 = fmDriveModel->headerData(4, Qt::Horizontal, Qt::DisplayRole); + QVERIFY(retHeaderData5.toString().isEmpty());// ""); + +#ifdef TO_BE_INVESTIGATE + QVariant retHeaderData6 = fmDriveModel->headerData(0, Qt::Vertical, Qt::DisplayRole); + QString a = retHeaderData6.toString(); // to be investigated. +// QVERIFY(retHeaderData6.toString() == ""); +#endif + + QVariant retHeaderData7 = fmDriveModel->headerData(1, Qt::Horizontal, Qt::UserRole); + QVERIFY(retHeaderData7.toString().isEmpty()); //== ""); + + delete fmDriveModel; + fmDriveModel = 0; +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + QString displayString( const QModelIndex &index ) const; \n + 2. Case Descrition: Verify the correct display string is shown. \n + 3. Input Parameters: \n    + <1> index = QModelIndex() \n    + 4. Expected result: \n    + <1> retBool = true \n + */ +void TestFmInternalDriveModel::testDisplayStringWithVolume() +{ + // option = FillWithVolume | FillWithDefaultVolume + FmDriveModel *fmDriveModel = new FmDriveModel( 0,FmDriveModel::FillWithVolume | FmDriveModel::FillWithDefaultVolume, 0); + + for(int i=0; i < mDriverList.count(); i++){ + QModelIndex indexValid = fmDriveModel->index(i,0); + // get the display string. + QVariant retData = fmDriveModel->displayString(indexValid); + QVERIFY(retData.toString() == FmUtils::fillDriveVolume(mDriverList[i], true)); + } + delete fmDriveModel; +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + QString displayString( const QModelIndex &index ) const; \n + 2. Case Descrition: Verify the correct display string is shown. \n + 3. Input Parameters: \n    + <1> index = QModelIndex() \n    + 4. Expected result: \n    + <1> retBool = true \n + */ +void TestFmInternalDriveModel::testDisplayStringWithoutVolume() +{ + FmDriveModel *fmDriveModel = new FmDriveModel(); + + for(int i=0; i < mDriverList.count(); i++){ + QModelIndex indexValid = fmDriveModel->index(i,0); + // get the display string. + QVariant retData = fmDriveModel->displayString(indexValid); +// QString retString = retData.toString(); +// qDebug()< index = QModelIndex() \n    + 4. Expected result: \n    + <1> retString = QString() \n + */ +void TestFmInternalDriveModel::testDisplayStringEmpty() +{ + FmDriveModel *fmDriveModel = new FmDriveModel(); + QModelIndex indexInValid = fmDriveModel->index(-1,0); + QVariant retData = fmDriveModel->displayString(indexInValid); + QVERIFY(retData.toString() == QString()); +} +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + QString driveName( const QModelIndex &index ) const; \n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> indexValid = QModelIndex() \n    + <2> indexInValid = QModelIndex() \n + 4. Expected result: \n    + <1> return the rignt drive name. \n    + <2> no crash. \n + */ +void TestFmInternalDriveModel::testDriveName() +{ + FmDriveModel *fmDriveModel = new FmDriveModel(); + QModelIndex indexValid = fmDriveModel->index(0,0); + QModelIndex indexInValid1 = fmDriveModel->index(0,2); + QModelIndex indexInValid2 = fmDriveModel->index(18); + QModelIndex indexInValid3 = fmDriveModel->index(5,0); + QString retDriveName1 = fmDriveModel->driveName(indexValid); + QVERIFY(retDriveName1 == "C:/"); + QString retDriveName2 = fmDriveModel->driveName(indexInValid1); + QVERIFY(retDriveName2.isEmpty()); + QString retDriveName3 = fmDriveModel->driveName(indexInValid2); + QVERIFY(retDriveName3.isEmpty()); + QString retDriveName4 = fmDriveModel->driveName(indexInValid3); + QVERIFY(retDriveName4.isEmpty()); + delete fmDriveModel; + fmDriveModel = 0; +} + +void TestFmInternalDriveModel::cleanupTestCase() +{ +} + +QTEST_MAIN(TestFmInternalDriveModel) diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fminternaldrivermodel/src/ut_fminternaldrivemodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fminternaldrivermodel/src/ut_fminternaldrivemodel.h Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* test application for qt control panel public apis. +*/ + +#ifndef UT_FMINTERNALDRIVEMODEL_H_ +#define UT_FMINTERNALDRIVEMODEL_H_ + +#include +#include +#include +class TestFmInternalDriveModel :public QObject +{ + Q_OBJECT +private slots: + void initTestCase(); + void testConstructor(); //test the constructor function. + void testRowCount(); // test the rowCount() function. + void testColumnCount(); // test the columnCount() function. + void testData(); + void testIndexValid(); // test the indexValid() function. + void testHeaderData(); // test the headerData() function. + + void testDisplayStringWithVolume(); // test the displayString() function. + void testDisplayStringWithoutVolume(); + void testDisplayStringEmpty(); + + void testDriveName(); // test the driveName() function. + void cleanupTestCase(); +private: + QTranslator mTranslator; + QStringList mDriverList; +}; +#endif /* UT_FMINTERNALDRIVEMODEL_H_ */ diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fminternaldrivermodel/ut_fminternaldrivermodel.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fminternaldrivermodel/ut_fminternaldrivermodel.pro Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,39 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +TEMPLATE = app +TARGET = ut_fminternaldrivemodel + +QT += testlib +CONFIG += hb qtestlib +CONFIG += symbian_test + +include ( ../../../src/common.pri ) +include ( ../../../src/inc/commoninc.pri ) +include ( ../../../src/inc/commonutils.pri ) +include ( ../ut_common.pri ) + +symbian:MMP_RULES += SMPSAFE + +DEPENDPATH += . +INCLUDEPATH += . + +#TARGET.CAPABILITY = ALL -TCB +TARGET.CAPABILITY = CAP_APPLICATION DiskAdmin AllFiles PowerMgmt + +HEADERS += src/testclassdatafmdrivelistprovider.h \ + src/ut_fminternaldrivemodel.h +SOURCES += src/ut_fminternaldrivemodel.cpp diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fminternalfmutils/data/Image.jpg Binary file filemanager/tsrc/unit/ut_fminternalfmutils/data/Image.jpg has changed diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fminternalfmutils/data/Imageformove.jpg Binary file filemanager/tsrc/unit/ut_fminternalfmutils/data/Imageformove.jpg has changed diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fminternalfmutils/data/Tone.mp3 Binary file filemanager/tsrc/unit/ut_fminternalfmutils/data/Tone.mp3 has changed diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fminternalfmutils/data/unknow.unknow --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fminternalfmutils/data/unknow.unknow Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,1 @@ +unknow type \ No newline at end of file diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fminternalfmutils/runtest.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fminternalfmutils/runtest.bat Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,19 @@ +@rem +@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +@rem All rights reserved. +@rem This component and the accompanying materials are made available +@rem under the terms of "Eclipse Public License v1.0" +@rem which accompanies this distribution, and is available +@rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +@rem +@rem Initial Contributors: +@rem Nokia Corporation - initial contribution. +@rem +@rem Contributors: +@rem +@rem Description: +@rem + +\epoc32\RELEASE\WINSCW\udeb\ut_fminternalfmutils.exe -xml -o c:\ut_fminternalfmutils.xml +copy \epoc32\winscw\c\ut_fminternalfmutils.xml +del \epoc32\winscw\c\ut_fminternalfmutils.xml \ No newline at end of file diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fminternalfmutils/src/ut_fminternalfmutils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fminternalfmutils/src/ut_fminternalfmutils.cpp Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,1568 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* test the file manager internal apis. +*/ + +#include "ut_fminternalfmutils.h" +#include "fmutils.h" +#include "fmdrivemodel.h" +#include +#include +#include +#include + +/*! + \class TestFmInternalFmUtils + \brief \n + class name: FmDriveModel \n + class's description: Test the File Manager internal api functions. \n + type of test case: unit test\n + test cases' number totally: 63 \n + */ + +/*! + Description of test data + */ +void TestFmInternalFmUtils::initTestCase() +{ + QString lang = QLocale::system().name(); + QString path = "z:/resource/qt/translations/"; + mTranslator.load( path + "filemanager_" + lang ); + qApp->installTranslator(&mTranslator); + + // init the path of test data. + mFilePath = Drive_C + QString("data") + QDir::separator() + QString("resource") + QDir::separator() + QString( "fmtestdata" ) + QDir::separator(); + // get all the drives + QFileInfoList fileInfoList = QDir::drives(); + foreach(const QFileInfo &fileInfo,fileInfoList) { + QString str = fileInfo.filePath(); + if (str.length() > 2) { + str = str.left(3); + } + // append the drives to mDrives1 which drive type is USB or Memory card. + FmDriverInfo driverInfo = FmUtils::queryDriverInfo( str ); + FmDriverInfo::DriveType driveType = driverInfo.driveType(); + if( driveType == FmDriverInfo::EDriveTypeMemoryCard || + driveType == FmDriverInfo::EDriveTypeUsbMemory){ + mDrives1.append(str); + mDrives.append(str); + }else{ + mDrives2.append(str); + mDrives.append(str); + } + } + qDebug() << mDrives; + qDebug() << mDrives1; + qDebug() << mDrives2; +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString getDriveNameFromPath( const QString &path ); \n    + static QString fillPathWithSplash( const QString &filePath ); \n + 2. Case Descrition: verify that it return the right drive name. \n + 3. Input Parameters: \n    + <1> strpath = QString() \n    + <2> strpath = QString(XX) [XX.length() < 3] \n    + <3> strpath = QString(XX) [XX.length() >= 3] \n    + 4. Expected result: \n    + <1> retPath = QString() \n    + <2> retPath = QString() \n    + <3> retPath = checkpath.left(3) \n + */ +void TestFmInternalFmUtils::testGetDriveNameFromPath() +{ + QString strPath1 = "C"; + QString strPath2 = "D:\\dir\\subdir"; + QString strPath3 = "T:/dir/subdir"; + QString strPath4 = "pathwithoutLetter"; + QString strPath5 = "C:"; + QString strPath6 = "C:\\"; + // path = QString(). + QString retDriveName1 = FmUtils::getDriveNameFromPath(QString()); + QVERIFY(retDriveName1.isEmpty()); + // path1.length() < 3 + QString retDriveName2 = FmUtils::getDriveNameFromPath(strPath1); + QVERIFY(retDriveName2.isEmpty()); + // path1.length() >= 3 + QString retDriveName3 = FmUtils::getDriveNameFromPath(strPath2); + QVERIFY(retDriveName3 == QString("D:") + QDir::separator()); + + QString retDriveName4 = FmUtils::getDriveNameFromPath(strPath3); + QVERIFY(retDriveName4 == QString("T:") + QDir::separator()); + + QString retDriveName5 = FmUtils::getDriveNameFromPath(strPath5); + QVERIFY(retDriveName5 == QString("C:") + QDir::separator()); + + QString retDriveName6 = FmUtils::getDriveNameFromPath(strPath6); + QVERIFY(retDriveName6 == QString("C:") + QDir::separator()); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString getDriveLetterFromPath( const QString &path ); \n    + 2. Case Descrition: verify that it return the right first drive letter. \n + 3. Input Parameters: \n    + <1> strpath = QString(XX) [XX.length() < 2] \n    + <2> strpath = QString(XX) [XX.length() >= 2] \n + 4. Expected result: \n    + <1> retPath = QString() \n    + <2> retPath = strPath.left(1) \n    + */ +void TestFmInternalFmUtils::testGetDriveLetterFromPath() +{ + QString strPath1 = "C"; + QString strPath2 = "X:\\dir\\subdir"; + // path = QString(). + QString retDriveName1 = FmUtils::getDriveLetterFromPath(QString()); + QVERIFY(retDriveName1.isEmpty()); + // path1.length() < 2 + QString retDriveName2 = FmUtils::getDriveLetterFromPath(strPath1); + QVERIFY(retDriveName2.isEmpty()); + // path1.length() >= 2 + QString retDriveName3 = FmUtils::getDriveLetterFromPath(strPath2); + QVERIFY(retDriveName3 == QString("X")); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString formatStorageSize( quint64 size ); \n    + 2. Case Descrition: verify that it return the correct storage size. \n + 3. Input Parameters: \n    + <1> size = Q_UINT64_C( 555 ) \n    + <2> size = Q_UINT64_C( 1024 ) \n    + <3> size = Q_UINT64_C( 1200000 ) \n    + <4> size = Q_UINT64_C( 1000*1000*1000 + 1024 ) \n    + <5> size = Q_UINT64_C( -5 ) \n + 4. Expected result: \n    + <1> retSize = QString( "555 B" ) \n    + <2> retSize = QString( "1.00 KB" ) \n    + <3> retSize = QString( "1.1 MB" ) \n    + <4> retSize = QString( "0.9 GB" ) \n    + <5> no crash. \n + */ +void TestFmInternalFmUtils::testFormatStorageSize() +{ + quint64 size1 = Q_UINT64_C(555); +// quint64 sizetemp = Q_UINT64_C(1000); + quint64 size2 = Q_UINT64_C( 1024 ); + quint64 size3 = Q_UINT64_C( 1200000 ); + quint64 size4 = Q_UINT64_C( 1000*1000*1000 + 1024 ); +#ifdef BUG_TO_BE_FIX + quint64 sizeInvalid = Q_UINT64_C( -5 ); +#endif +// X < 1000 + QString retSize1 = FmUtils::formatStorageSize(size1); + QVERIFY( retSize1 == QString::number(size1) + QString(" B") ); +// 1000 < X < 1000*1000 + QString retSize2 = FmUtils::formatStorageSize(size2); + QVERIFY( retSize2 == QString::number( size2 / 1024.0, 'f', 2 ) + " KB" ); +// 1000*1000 < X < 1000*1000*1000 + QString retSize3 = FmUtils::formatStorageSize(size3); + QVERIFY( retSize3 == QString::number( size3 / (1024.0 * 1024.0), 'f', 1 ) + " MB" ); +// X > 1000*1000*1000 + QString retSize4 = FmUtils::formatStorageSize(size4); + QVERIFY( retSize4 == QString::number( size4 / ( 1024.0 * 1024.0 * 1024.0 ), 'f', 1 ) + " GB" ); + +#ifdef BUG_TO_BE_FIX + QString retSize5 = FmUtils::formatStorageSize(sizeInvalid); + qDebug()< driverName = "C:\" \n + 4. Expected result: \n    + <1> retResult = true \n + */ +void TestFmInternalFmUtils::testIsDriveYes() +{ + bool retResult = FmUtils::isDrive("C:/"); + QVERIFY( retResult == true ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool isDrive( const QString &path ); \n    + 2. Case Descrition: verify it is not a drive with wrong path. \n + 3. Input Parameters: \n    + <1> driverName = "C" \n    + <2> driverName = "D:\path" \n + 4. Expected result: \n    + <1> retResult = false \n    + <2> retResult = false \n + */ +void TestFmInternalFmUtils::testIsDriveNo() +{ + bool retResult1 = FmUtils::isDrive("C"); + QVERIFY( retResult1 == false ); + + bool retResult2 = FmUtils::isDrive("D:\\path"); + QVERIFY( retResult2 == false ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString formatPath( const QString &path ); \n    + 2. Case Descrition: verify it doesn't crash with empty path. \n + 3. Input Parameters: \n    + <1> path = QString() \n + 4. Expected result: \n    + <1> retPath = QString() \n + */ +void TestFmInternalFmUtils::testFormatPathWithEmptyPath() +{ + QString retPath = FmUtils::formatPath(QString()); + QVERIFY( retPath.isEmpty() ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString formatPath( const QString &path ); \n    + 2. Case Descrition: verify it doesn't crash with empty path. \n + 3. Input Parameters: \n    + <1> path = QString("C:\\path1\\subpath") \n    + <2> path = QString("C:/path2/subpath") \n + 4. Expected result: \n    + <1> retPath = QString("C:")+QDir::QDir::separator()+QString("path1")+QDir::separator()+QString("subpath") \n    + <2> retPath = QString("C:")+QDir::QDir::separator()+QString("path2")+QDir::separator()+QString("subpath") \n + */ +void TestFmInternalFmUtils::testFormatPath() +{ + QString retPath1 = FmUtils::formatPath("C:\\path1\\subpath"); + QVERIFY( retPath1 == QString("C:") + QDir::separator() +QString("path1") +QDir::separator() + QString("subpath") ); + + QString retPath2 = FmUtils::formatPath("C:/path2/subpath"); + QVERIFY( retPath2 == QString("C:")+ QDir::separator()+QString("path2")+ QDir::separator()+QString("subpath") ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString fillPathWithSplash( const QString &filePath ); \n    + 2. Case Descrition: verify it doesn't crash with empty path. \n + 3. Input Parameters: \n    + <1> path = QString() \n + 4. Expected result: \n    + <1> retPath = QString() \n + */ +void TestFmInternalFmUtils::testFillPathWithSplashUseEmptyPath() +{ + QString retPath = FmUtils::fillPathWithSplash(QString()); + QVERIFY( retPath.isEmpty() ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString fillPathWithSplash( const QString &filePath ); \n    + 2. Case Descrition: verify it doesn't add splash again when the path has the splash in the end. \n + 3. Input Parameters: \n    + <1> path = QString(XX) \n + 4. Expected result: \n    + <1> retPath = path \n + */ +void TestFmInternalFmUtils::testFillPathWithSplashHasSplash() +{ + QString path1 = "C:\\hasSplash\\"; + QString path2 = "D:/hasSplash/"; + QString retPath1 = FmUtils::fillPathWithSplash(path1); + QVERIFY(retPath1 == QString("C:") + QDir::separator() + QString("hasSplash") + QDir::separator()); + + QString retPath2 = FmUtils::fillPathWithSplash(path2); + QVERIFY(retPath2 == QString("D:") + QDir::separator() + QString("hasSplash") + QDir::separator()); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString fillPathWithSplash( const QString &filePath ); \n    + 2. Case Descrition: verify the splash is added at the end of the path. \n + 3. Input Parameters: \n    + <1> path = QString(XX) \n + 4. Expected result: \n    + <1> retPath = QString(XX) + QDir::separator() \n + */ +void TestFmInternalFmUtils::testFillPathWithSplashWithoutSplash() +{ + QString path1 = "C:\\noSplash"; + QString path2 = "D:/noSplash"; + QString retPath1 = FmUtils::fillPathWithSplash(path1); + QVERIFY(retPath1 == QString("C:") + QDir::separator() + QString("noSplash") + QDir::separator()); + + QString retPath2 = FmUtils::fillPathWithSplash(path2); + QVERIFY(retPath2 == QString("D:") + QDir::separator() + QString("noSplash") + QDir::separator()); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString removePathSplash( const QString &filePath ); \n    + 2. Case Descrition: verify it doesn't crash with empty path. \n + 3. Input Parameters: \n    + <1> path = QString() \n + 4. Expected result: \n    + <1> retPath = QString() \n + */ +void TestFmInternalFmUtils::testRemovePathSplashUseEmptyPath() +{ + QString retPath = FmUtils::removePathSplash(QString()); + QVERIFY( retPath.isEmpty()); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString removePathSplash( const QString &filePath ); \n    + 2. Case Descrition: verify the splash at the end is removed. \n + 3. Input Parameters: \n    + <1> path = QString(XX) \n + 4. Expected result: \n    + <1> retPath = QString(XX) \n + */ +void TestFmInternalFmUtils::testRemovePathSplashHasSplash() +{ + QString path1 = "C:\\hasSplash\\"; + QString path2 = "D:/hasSplash/"; + QString path3 = "/"; + QString path4 = "\\"; + + QString retPath1 = FmUtils::removePathSplash(path1); + QVERIFY(retPath1 == QString("C:") + QDir::separator() + QString("hasSplash")); + + QString retPath2 = FmUtils::removePathSplash(path2); + QVERIFY(retPath2 == "D:/hasSplash"); + + QString retPath3 = FmUtils::removePathSplash( path3 ); + QVERIFY(retPath3.isEmpty()); + + QString retPath4 = FmUtils::removePathSplash( path4 ); + QVERIFY(retPath4.isEmpty()); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString removePathSplash( const QString &filePath ); \n    + 2. Case Descrition: verify it doesn't crash with empty path. \n + 3. Input Parameters: \n    + <1> path = QString() \n + 4. Expected result: \n + <1> retPath = QString() \n + */ +void TestFmInternalFmUtils::testRemovePathSplashWithoutSplash() +{ + QString path1 = "C:\\withoutSplash"; + QString path2 = "D:/withoutSplash"; + QString retPath1 = FmUtils::removePathSplash(path1); + QVERIFY(retPath1 == QString("C:") + QDir::separator() + QString("withoutSplash")); + + QString retPath2 = FmUtils::removePathSplash(path2); + QVERIFY(retPath2 == "D:/withoutSplash"); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static void getDriveList( QStringList &driveList, bool isHideUnAvailableDrive ); \n    + 2. Case Descrition: verify the correct drives are returned. \n + 3. Input Parameters: \n    + <1> driveList = QStringList, isHideUnAvailableDrive = false \n + 4. Expected result: \n    + <1> driveList == driveListForVerify\n + */ +void TestFmInternalFmUtils::testGetDriveListAll() +{ + QStringList driveList; + QStringList driveListForVerify; + + FmUtils::getDriveList(driveList, false); + qDebug()< 2) { + str = str.left(3); + } + // append the drives to driveListForVerify except the drive type are EDriveRam and EDriveRom. + FmDriverInfo driverInfo = FmUtils::queryDriverInfo( str ); + FmDriverInfo::DriveType driveType = driverInfo.driveType(); + // fliter the drives which drive type are EDriveRam and EDriveRom. + bool driveFilter = ( driverInfo.driveState()& FmDriverInfo::EDriveRam ) ||( driverInfo.driveState()& FmDriverInfo::EDriveRom ); + if( !driveFilter ){ + driveListForVerify.append(str); + } + } + qDebug()< driveList = QStringList, isHideUnAvailableDrive = true \n + 4. Expected result: \n    + <1> driveList == driveListForVerify \n + */ +void TestFmInternalFmUtils::testGetDriveListPart() +{ + QStringList driveList; + QStringList driveListForVerify; + + FmUtils::getDriveList(driveList, true); + qDebug() << driveList; + + QFileInfoList fileInfoList = QDir::drives(); + foreach(const QFileInfo &fileInfo,fileInfoList) { + QString str = fileInfo.filePath(); + if (str.length() > 2) { + str = str.left(3); + } + FmDriverInfo driverInfo = FmUtils::queryDriverInfo( str ); + FmDriverInfo::DriveType driveType = driverInfo.driveType(); + // fliter the drives which drive type are EDriveRam and EDriveRom. + bool driveFilter = ( driverInfo.driveState()& FmDriverInfo::EDriveRam ) ||( driverInfo.driveState()& FmDriverInfo::EDriveRom ); + // filter the unavailable drive + if( !driveFilter && FmUtils::isDriveAvailable( str ) ){ + driveListForVerify.append(str); + } + } + qDebug()< driveName = QString(), isFillWithDefaultVolume = false \n    + <2> driveName = QString(), isFillWithDefaultVolume = true \n + 4. Expected result: \n    + <1> retDriveVolume2 == QString() \n + */ +void TestFmInternalFmUtils::testFillDriveVolumeEmptyName() +{ + QString retDriveVolume1 = FmUtils::fillDriveVolume( QString(), false ); + QVERIFY(retDriveVolume1.isEmpty()); + + QString retDriveVolume2 = FmUtils::fillDriveVolume( QString(), false ); + QVERIFY(retDriveVolume2.isEmpty()); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString fillDriveVolume( QString driveName, bool isFillWithDefaultVolume ); \n    + 2. Case Descrition: verify the default volume is set when the isFillWithDefaultVolume is true. \n + 3. Input Parameters: \n    + <1> driveName = QString(XX), isFillWithDefaultVolume = true \n + 4. Expected result: \n    + <1> return the right drive volume(e.g.: C:memory) \n + */ +void TestFmInternalFmUtils::testFillDriveVolumeDefaultVolume() +{ + foreach(QString strDriveName, mDrives ){ + QString retDriveVolume = FmUtils::fillDriveVolume(strDriveName, true ); + + QString tempDriveName = FmUtils::fillPathWithSplash( strDriveName ); + FmDriverInfo driverInfo = FmUtils::queryDriverInfo( tempDriveName ); + QString checkedDriveName( FmUtils::removePathSplash( strDriveName ) ); + QString volumeName = driverInfo.volumeName(); + if(volumeName.isEmpty()){ + switch ( driverInfo.driveType() ) + { + case FmDriverInfo::EDriveTypeMassStorage: + QVERIFY(retDriveVolume == hbTrId("txt_fmgr_dblist_1_mass_storage").arg(checkedDriveName)); + break; + case FmDriverInfo::EDriveTypeUsbMemory: + QVERIFY(retDriveVolume == hbTrId("txt_fmgr_dblist_1_usb_memory").arg(checkedDriveName)); + break; + case FmDriverInfo::EDriveTypeMemoryCard: + QVERIFY(retDriveVolume == hbTrId("txt_fmgr_dblist_1_memory_card").arg(checkedDriveName)); + break; + case FmDriverInfo::EDriveTypePhoneMemory: + QVERIFY(retDriveVolume == hbTrId("txt_fmgr_dblist_1_device_memory").arg(checkedDriveName)); + break; + default: + break; + } + } + } +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString fillDriveVolume( QString driveName, bool isFillWithDefaultVolume ); \n    + 2. Case Descrition: verify it doesn't crash with empty path. \n + 3. Input Parameters: \n    + <1> driveList = QStringList, isHideUnAvailableDrive = false \n + 4. Expected result: \n + <1> \n + */ +void TestFmInternalFmUtils::testFillDriveVolume() +{ + foreach(QString strDriveName, mDrives ){ + QString retDriveVolume = FmUtils::fillDriveVolume(strDriveName, false ); + + FmDriverInfo driverInfo = FmUtils::queryDriverInfo( strDriveName ); + QString checkedDriveName( FmUtils::removePathSplash( strDriveName ) ); + QString volumeName = driverInfo.volumeName(); + QString volumeNameForVerify = hbTrId( "%1 %2" ).arg( checkedDriveName ).arg( volumeName ); + QVERIFY(retDriveVolume == volumeNameForVerify); + } +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString getDefaultVolumeName( const QString &driveName ); \n    + 2. Case Descrition: verify the correct default volume is returned \n + 3. Input Parameters: \n    + <1> driveName = QString(XX) \n + 4. Expected result: \n    + <1> return the right drive volume(e.g.: "Device memory" when crive name is "C:") \n + */ +void TestFmInternalFmUtils::testGetDefaultVolumeName() +{ + foreach(QString strDriveName, mDrives ){ + // get the volume using getDefaultVolumeName function. + QString retDriveVolume = FmUtils::getDefaultVolumeName(strDriveName); + + FmDriverInfo driverInfo = FmUtils::queryDriverInfo( strDriveName ); + switch ( driverInfo.driveType() ) + { + case FmDriverInfo::EDriveTypeMassStorage: + QVERIFY(retDriveVolume == hbTrId("Mass storage")); + break; + case FmDriverInfo::EDriveTypeUsbMemory: + QVERIFY(retDriveVolume == hbTrId("USB memory")); + break; + case FmDriverInfo::EDriveTypeMemoryCard: + QVERIFY(retDriveVolume == hbTrId("Memory card")); + break; + case FmDriverInfo::EDriveTypePhoneMemory: + QVERIFY(retDriveVolume == hbTrId("Device memory")); + break; + case FmDriverInfo::EDriveTypeNotExist: + default: + break; + } + } +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString getVolumeNameWithDefaultNameIfNull( const QString &diskName, bool &defaultName ); \n    + 2. Case Descrition: verify the right volume name is returned. \n + 3. Input Parameters: \n    + <1> driveName = QString(XX) \n + 4. Expected result: \n    + <1> return the right drive volume(e.g.: "Device memory" when drive name is "C:" & is empty) \n + */ +void TestFmInternalFmUtils::testGetVolumeNameWithDefaultNameIfNull() +{ + foreach(QString strDriveName, mDrives ){ + // get the volume using getVolumeNameWithDefaultNameIfNull() function. + bool isDefaultName = false; + QString retDriveVolume = FmUtils::getVolumeNameWithDefaultNameIfNull(strDriveName, isDefaultName); + + FmDriverInfo driverInfo = FmUtils::queryDriverInfo( strDriveName ); + QString volumeName = driverInfo.volumeName(); + if ( volumeName.isEmpty() ){ + switch ( driverInfo.driveType() ) + { + case FmDriverInfo::EDriveTypeMassStorage: + QVERIFY(retDriveVolume == hbTrId("Mass storage")); + break; + case FmDriverInfo::EDriveTypeUsbMemory: + QVERIFY(retDriveVolume == hbTrId("USB memory")); + break; + case FmDriverInfo::EDriveTypeMemoryCard: + QVERIFY(retDriveVolume == hbTrId("Memory card")); + break; + case FmDriverInfo::EDriveTypePhoneMemory: + QVERIFY(retDriveVolume == hbTrId("Device memory")); + break; + case FmDriverInfo::EDriveTypeNotExist: + default: + break; + } + } + } +} +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool isPathEqual( const QString &pathFst, const QString &pathLast ); \n    + 2. Case Descrition: Verify the two path are the same. \n + 3. Input Parameters: \n    + <1> pathFst = QString(X), pathLast = QString(X)\n + 4. Expected result: \n    + <1> isEqual = true \n + */ +void TestFmInternalFmUtils::testisPathEqualWithSamePath() +{ + QString path1 = "C:\\the path is same"; + QString path2 = "C:\\the path is same"; + QString path3 = "C:\\ frontbland\\isSame"; + QString path4 = "C:\\ frontbland\\isSame"; + QString path5 = "C:\\endwithbland \\isSame"; + QString path6 = "C:\\endwithbland \\isSame"; + bool isEqual1 = FmUtils::isPathEqual(QString(), QString()); + QVERIFY(isEqual1 == true); + + bool isEqual2 = FmUtils::isPathEqual(path1, path2); + QVERIFY(isEqual2 == true); + + bool isEqual3 = FmUtils::isPathEqual(path3, path4); + QVERIFY(isEqual3 == true); + + bool isEqual4 = FmUtils::isPathEqual(path5, path6); + QVERIFY(isEqual4 == true); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool isPathEqual( const QString &pathFst, const QString &pathLast ); \n    + 2. Case Descrition: Verify the two path are different. \n + 3. Input Parameters: \n    + <1> pathFst = QString(X), pathLast = QString(Y)\n + 4. Expected result: \n    + <1> isEqual = false \n + */ +void TestFmInternalFmUtils::testisPathEqualWithDiffPath() +{ + QString path1 = "C:\\the path is different"; + QString path2 = "C:\\the path is not same\\subdir\\"; + bool isEqual = FmUtils::isPathEqual(path1, path2); + QVERIFY(isEqual == false); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool checkFolderFileName( const QString& name ); \n    + 2. Case Descrition: Verify folder or file name is OK. \n + 3. Input Parameters: \n    + <1> pathFst = QString(XX)\n + 4. Expected result: \n    + <1> isValid= true \n + */ +void TestFmInternalFmUtils::testcheckFolderFileNameNormal() +{ + QString name = "This is a valid name"; + bool isValid = FmUtils::checkFolderFileName(name); + QVERIFY(isValid == true); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool checkFolderFileName( const QString& name ); \n    + 2. Case Descrition: Verify the folder or file name is invalid. \n + 3. Input Parameters: \n    + <1> pathFst = QString(XX)\n + 4. Expected result: \n    + <1> isValid= false \n + */ +void TestFmInternalFmUtils::testcheckFolderFileNameUnNormal() +{ + QList list; + list << '\\' << '/' << ':' << '*' << '?' << '\"' << '<' << '>' <<'|'; + foreach(QChar ilegelChar, list){ + QString name = QString("This is an invalid name") + ilegelChar; + bool isValid = FmUtils::checkFolderFileName(name); + QVERIFY(isValid == false); + } + // end with "." + QString nameEndWithDot = "End with dot."; + bool isValid1 = FmUtils::checkFolderFileName(nameEndWithDot); + QVERIFY(isValid1 == false); + // more than max size + QString nameMax; + nameMax.fill('x', 300); + bool isValid2 = FmUtils::checkFolderFileName(nameMax); + QVERIFY(isValid2 == false); + // name is empty + bool isValid3 = FmUtils::checkFolderFileName(QString()); + QVERIFY(isValid3 == false); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool checkNewFolderOrFile( const QString& fileName, const QString &path, QString &errString ); \n    + 2. Case Descrition: Verify it is a new folder or file.\n + 3. Input Parameters: \n    + <1> fileName = QString(XX), path = QString(XX), errString = QString(XX)\n + 4. Expected result: \n    + <1> isNew = true \n + */ +void TestFmInternalFmUtils::testCheckNewFolderOrFileUnNormal() +{ + QString fileName = "newFolder"; + QString path = mFilePath + "newFolder"; + QString errStr; + bool isNew = FmUtils::checkNewFolderOrFile(fileName, path, errStr); + QVERIFY(isNew == true); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool checkNewFolderOrFile( const QString& fileName, const QString &path, QString &errString ); \n    + 2. Case Descrition: Verify the function when the folder/file name with ilegel characters.\n + 3. Input Parameters: \n    + <1> fileName = QString(XX), path = QString(XX), errString = QString(XX)\n + 4. Expected result: \n    + <1> isNew = false \n + */ +void TestFmInternalFmUtils::testCheckNewFolderOrFileIlegel() +{ + QString validName = "Image.jpg"; + QString ilegelFileName = "isInvalidName?"; + QString validPath = mFilePath + "newFolder"; + QString inValidPath; + inValidPath.fill('x', 300); + QString errStr; + + // file name is invalid + bool isNew1 = FmUtils::checkNewFolderOrFile(ilegelFileName, validPath, errStr); + QVERIFY(isNew1 == false); + QVERIFY(errStr == hbTrId( "Invalid file or folder name!" )); + // path is too long + bool isNew2 = FmUtils::checkNewFolderOrFile(validName, inValidPath, errStr); + QVERIFY(isNew2 == false); + QVERIFY(errStr == hbTrId( "the path you specified is too long!" )); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool checkNewFolderOrFile( const QString& fileName, const QString &path, QString &errString ); \n    + 2. Case Descrition: Verify it is not a new folder or file.\n + 3. Input Parameters: \n    + <1> fileName = QString(XX), path = QString(XX), errString = QString(XX)\n + 4. Expected result: \n    + <1> isNew = false \n + */ +void TestFmInternalFmUtils::testCheckNewFolderOrFileNo() +{ + QString validName = "Image.jpg"; + QString exsitPath = mFilePath; + QString errStr; + // the file\folder has been exsit + bool isNew3 = FmUtils::checkNewFolderOrFile(validName, exsitPath, errStr); + QVERIFY(isNew3 == false); + QFileInfo fileInfo( exsitPath ); + QVERIFY(errStr == hbTrId( "%1 already exist!" ).arg( fileInfo.fileName())); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool isSubLevelPath( const QString &src, const QString &dest ); \n    + 2. Case Descrition: Verify the path is a sub level path.\n + 3. Input Parameters: \n    + <1> src = QString(XX), dest = QString(XX)\n + 4. Expected result: \n    + <1> isSubLevelPath = true \n + */ +void TestFmInternalFmUtils::testIsSubLevelPathYes() +{ + QString src = "C:\\dir"; + QString dest = "C:\\dir\\subdir"; + bool isSubLevelPath = FmUtils::isSubLevelPath(src, dest); + QVERIFY(isSubLevelPath == true); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool isSubLevelPath( const QString &src, const QString &dest ); \n    + 2. Case Descrition: Verify the path is a sub level path.\n + 3. Input Parameters: \n    + <1> src = QString(XX), dest = QString(XX)\n + 4. Expected result: \n    + <1> isSubLevelPath = false \n + */ +void TestFmInternalFmUtils::testIsSubLevelPathNo() +{ + QString src1 = "C:\\dir1"; + QString dest1 = "C:\\dir2\\subdir"; + QString src2 = "C:\\dir1\\subdir"; + QString dest2 = "C:\\dir1"; + // dest does not contain src. + bool isSubLevelPath1 = FmUtils::isSubLevelPath(src1, dest1); + QVERIFY(isSubLevelPath1 == false); + // dest.length < src.length + bool isSubLevelPath2 = FmUtils::isSubLevelPath(src2, dest2); + QVERIFY(isSubLevelPath2 == false); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static int removeDrivePwd( const QString &driverName, const QString &Pwd ); \n    + 2. Case Descrition: verify this function can remove the password successfully. \n + 3. Input Parameters: \n    + <1> driverName = QString(), password = QString(XX) \n    + 4. Expected result: \n + <1> retErr = FmErrNone, \n + */ +void TestFmInternalFmUtils::testRemoveDrivePwdNormal() +{ + if( ! mDrives1.empty() ){ + // set the password. + FmUtils::setDrivePwd( mDrives1[0], QString(), QString("123456") ); + FmDriverInfo driverInfo = FmUtils::queryDriverInfo( mDrives1[0] ); + int a = driverInfo.driveState()& FmDriverInfo::EDrivePasswordProtected; + QVERIFY( a == FmDriverInfo::EDrivePasswordProtected ); + //remove the password and verify the drive state. + int retRemovePwdErr = FmUtils::removeDrivePwd( mDrives1[0], QString("123456") ); + driverInfo = FmUtils::queryDriverInfo( mDrives1[0] ); +// int b = driverInfo.driveState()& FmDriverInfo::EDrivePasswordProtected; + QVERIFY( !(driverInfo.driveState()& FmDriverInfo::EDrivePasswordProtected) ); + + QVERIFY( retRemovePwdErr == FmErrNone ); + } + else + QWARN("No memory crad or USB device are available."); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static int removeDrivePwd( const QString &driverName, const QString &Pwd ); \n    + 2. Case Descrition: verify this function can remove the password successfully. \n + 3. Input Parameters: \n    + <1> driverName = QString(), password = QString(XX) \n    + <2> driverName = QString(XX), password = QString(XX) \n    + 4. Expected result: \n    + <1> retErr = FmErrWrongParam, \n    + <2> no crash. \n + */ +void TestFmInternalFmUtils::testRemoveDrivePwdUnNormal() +{ + int retErr1 = FmUtils::removeDrivePwd( QString(), QString() ); + QVERIFY( retErr1 == FmErrWrongParam ); + + int retErr2 = FmUtils::removeDrivePwd( QString("C:/"), QString("5t0Lfezb") ); + QVERIFY( retErr2 == FmErrUnKnown ); + + int retErr3 = FmUtils::removeDrivePwd( QString("U:/"), QString("5t0Lfezb") ); + QVERIFY( retErr3 == FmErrUnKnown ); +} +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static int setDrivePwd( const QString &driverName, const QString &oldPwd, const QString &newPwd); \n    + 2. Case Descrition: verify this function can set the password correctly. \n + 3. Input Parameters: \n    + <1> driverName = QString(XX), oldPwd = QString(), newPwd = QString(XX) \n + 4. Expected result: \n    + <1> retErr = FmErrNone + */ +void TestFmInternalFmUtils::testSetDrivePwdNormal() +{ + if( ! mDrives1.empty() ){ + //set the password + int retErr = FmUtils::setDrivePwd( mDrives1[0], QString(), QString("123456") ); + // get the drive state and verify it. + FmDriverInfo driverInfo = FmUtils::queryDriverInfo( mDrives1[0] ); + int a = driverInfo.driveState()& FmDriverInfo::EDrivePasswordProtected; + QVERIFY( a == FmDriverInfo::EDrivePasswordProtected ); + QVERIFY( retErr == FmErrNone ); + + FmUtils::removeDrivePwd( mDrives1[0], QString("123456") ); + } + else + QWARN("No memory crad or USB device are available."); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static int setDrivePwd( const QString &driverName, const QString &oldPwd, const QString &newPwd); \n    + 2. Case Descrition: verify this function can set the password correctly. \n + 3. Input Parameters: \n    + <1> driverName = QString(), oldPwd = QString(), newPwd = QString(X) \n    + <2> driverName = QString(X), oldPwd = QString(), newPwd = QString(X.length()>8) \n    + <3> driverName = QString(C:), oldPwd = QString(), newPwd = QString(X) \n + 4. Expected result: \n    + <1> retErr = FmErrWrongParam \n    + <2> retErr = FmErrWrongParam \n    + <3> retErr = FmErrNotSupported \n + */ +void TestFmInternalFmUtils::testSetDrivePwdUnNormal() +{ + // The drive name is empty + int retSetPwdErr1 = FmUtils::setDrivePwd( QString(""), QString(""), QString("123456") ); + QVERIFY( retSetPwdErr1 == FmErrWrongParam ); + + if( !mDrives1.empty() ){ + int retSetPwdEr2 = FmUtils::setDrivePwd( mDrives1[0], QString(""), QString("1234567890123456") ); + FmDriverInfo driverInfo = FmUtils::queryDriverInfo( mDrives1[0] ); + QVERIFY( !(driverInfo.driveState()& FmDriverInfo::EDrivePasswordProtected) ); + QVERIFY( retSetPwdEr2 == FmErrWrongParam ); + }else + QWARN("No memory crad or USB device are available."); + + int retSetPwdErr3 = FmUtils::setDrivePwd( mDrives2[0], QString(""), QString("123456") ); + QVERIFY( retSetPwdErr3 == FmErrNotSupported ); + + // return + int retSetPwdErr4 = FmUtils::setDrivePwd( QString("9527"), QString("oldpwd"), QString("123456") ); + QVERIFY( retSetPwdErr4 == FmErrUnKnown ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static int checkDrivePwd( const QString &driverName, const QString &pwd); \n    + 2. Case Descrition: verify this function can check whether the drive having password . \n + 3. Input Parameters: \n    + <1> driverName = QString(), password = QString(X.length()<8) \n    + <2> driverName = QString(X), password = QString(X.length()>8) \n    + <3> driverName = QString(X), password = QString(X.length()<8) \n + 4. Expected result: \n    + <1> retErr = FmErrWrongParam \n    + <2> retErr = FmErrWrongParam \n    + <3> retErr = FmErrNone\n + */ +void TestFmInternalFmUtils::testCheckDrivePwd() +{ + if( !mDrives1.empty() ){ + //the drive name is empty + int retCheckStatus1 = FmUtils::checkDrivePwd( QString(), QString("password")); + FmDriverInfo driverInfo = FmUtils::queryDriverInfo( mDrives1[0] ); + + QVERIFY( !(driverInfo.driveState()& FmDriverInfo::EDrivePasswordProtected) ); + QVERIFY( retCheckStatus1 == FmErrWrongParam ); + + // the length of the password is more than 8 + int retCheckStatus2 = FmUtils::checkDrivePwd( mDrives1[0], QString("oldpassword")); + driverInfo = FmUtils::queryDriverInfo( mDrives1[0] ); + + QVERIFY( !(driverInfo.driveState()& FmDriverInfo::EDrivePasswordProtected) ); + QVERIFY( retCheckStatus2 == FmErrWrongParam ); + + int retCheckStatus3 = FmUtils::checkDrivePwd( mDrives1[0], QString("password")); + driverInfo = FmUtils::queryDriverInfo( mDrives1[0] ); +#ifdef BUG_TO_FIX + QVERIFY( !(driverInfo.driveState()& FmDriverInfo::EDrivePasswordProtected) ); //The drive state of FmDriverInfo::EDrivePasswordProtected should not be changed with a valid pwd parameter. + QVERIFY( retCheckStatus3 == FmErrNone ); +#endif + } + else + QWARN("No memory crad or USB device are available."); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static void emptyPwd( QString &pwd ); \n    + 2. Case Descrition: verify this function can empty the password . \n + 3. Input Parameters: \n    + <1> pwd = QString() \n    + <2> pwd = QString(XX) \n + 4. Expected result: \n    + <1> no crash \n    + <2> no crash. \n + */ +void TestFmInternalFmUtils::testEmptyPwd() +{ + QString strPassword= QString("password"); + QString pwdEmpty = QString(); + FmUtils::emptyPwd( pwdEmpty ); + FmUtils::emptyPwd( strPassword ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static int renameDrive( const QString &driverName, const QString &newVolumeName); \n + 2. Case Descrition: verify that it does not crash with bad names. \n + 3. Input Parameters: \n    + <1> driveName = QString(), newVolumeName = QString(XX) \n    + <2> driveName = "C:", newVolumeName = QString() \n    + <3> driveName = "C:", newVolumeName = QString("!$@^#*#dsfljlke"). \n    + <4> driveName = "C:", newVolumeName = QString("more than maximum words"). \n + 4. Expected result: \n    + <1> return FmErrWrongParam \n    + <2> return FmErrUnKnown \n    + <3> return FmErrBadName \n    + <4> return FmErrBadName \n + */ +void TestFmInternalFmUtils::testRenameDriveWithBadName() +{ + int retInfo1 = FmUtils::renameDrive( QString(),QString("new volume name") ); + QVERIFY( retInfo1 == FmErrWrongParam ); + + if( !mDrives1.empty() ){ + int retInfo2 = FmUtils::renameDrive( mDrives1[0],QString("") ); + QVERIFY( retInfo2 == FmErrNone ); + + int retInfo3 = FmUtils::renameDrive( mDrives1[0],QString("!$@^#*e") ); + QVERIFY( retInfo3 == FmErrBadName ); + + int retInfo4 = FmUtils::renameDrive( mDrives1[0],QString("more than maximum words") ); + QVERIFY( retInfo4 == FmErrUnKnown ); + }else + QWARN("No memory crad or USB device are available."); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static int renameDrive( const QString &driverName, const QString &newVolumeName); \n + 2. Case Descrition: verify this function can empty the password . \n + 3. Input Parameters: \n    + <1> driveName = QString(X), newVolumeName = QString(XX) \n    + <2> driveName = "C:", newVolumeName = QString() \n + 4. Expected result: \n    + <1> return FmErrWrongParam \n    + <2> return FmErrBadName \n + */ +void TestFmInternalFmUtils::testRenameDriveWithNormalName() +{ + if( !mDrives1.empty() ){ + int retInfo1 = FmUtils::renameDrive(mDrives1[0],QString("newname") ); + bool defaultName = false; + QString retVolumeName = FmUtils::getVolumeNameWithDefaultNameIfNull( mDrives1[0], defaultName ); + QVERIFY( retVolumeName == "newname" ); + QVERIFY( retInfo1 == FmErrNone ); + //set the name back + FmUtils::renameDrive(mDrives1[0],QString()); + }else + QWARN("No memory crad or USB device are available."); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool checkDriveAccessFilter( const QString &driveName ); \n + 2. Case Descrition: verify whether the drive can be accessable. \n + 3. Input Parameters: \n    + <1> driveName = QString() \n    + <2> driveName = QString(XX) \n + 4. Expected result: \n    + <1> isAccessable == false \n    + <2> return true if it's accessful, or return false \n + */ +void TestFmInternalFmUtils::testCheckDriveAccessFilter() +{ + foreach(QString strDriveName, mDrives ){ + bool isAccessable1 = FmUtils::checkDriveAccessFilter(strDriveName); + + FmDriverInfo driveInfo = FmUtils::queryDriverInfo( strDriveName ); + if ((driveInfo.driveState()& FmDriverInfo::EDriveRam ) || + +( driveInfo.driveState()& FmDriverInfo::EDriveRom ) ) { + QVERIFY(isAccessable1 == false); + }else + QVERIFY(isAccessable1 == true); + } + // set drive name as QString + bool isAccessable2 = FmUtils::checkDriveAccessFilter(QString()); + QVERIFY(isAccessable2 == false); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString checkDriveToFolderFilter( const QString &path ); \n + 2. Case Descrition: Verify the correct path is returned. \n + 3. Input Parameters: \n    + <1> path = QString("C:") \n + 4. Expected result: \n    + <1> retPath == path + QDir::separator() + QString( "data" ) + QDir::separator() \n    + */ +void TestFmInternalFmUtils::testCheckDriveToFolderFilterC() +{ + QString path = Drive_C; + QString retPath = FmUtils::checkDriveToFolderFilter(path); + QVERIFY(retPath == path + QString( "data" ) + QDir::separator()); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString checkDriveToFolderFilter( const QString &path ); \n + 2. Case Descrition: Verify the correct path is returned. \n + 3. Input Parameters: \n    + <1> path = QString(XX) \n + 4. Expected result: \n    + <1> retPath == path \n    + */ +void TestFmInternalFmUtils::testCheckDriveToFolderFilterNormal() +{ + QString path = "D:"; + QString retPath1 = FmUtils::checkDriveToFolderFilter(path); + QVERIFY(retPath1 == path); + + QString retPath2 = FmUtils::checkDriveToFolderFilter(QString()); + QVERIFY(retPath2.isEmpty()); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString checkFolderToDriveFilter( const QString &path );\n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> path = "C:\\data" \n + 4. Expected result: \n    + <1> retPath == "C:" \n + */ +void TestFmInternalFmUtils::testCheckFolderToDriveFilterC() +{ + QString path = "C:\\data"; + QString retPath = FmUtils::checkFolderToDriveFilter(path); + QVERIFY(retPath == Drive_C); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString checkFolderToDriveFilter( const QString &path );\n + 2. Case Descrition: Verify the correct path is returned. \n + 3. Input Parameters: \n    + <1> path = QString() \n    + <2> path = QString(XX) \n + 4. Expected result: \n    + <1> retPath == QString() \n    + <2> retPath == path \n + */ +void TestFmInternalFmUtils::testCheckFolderToDriveFilterNormal() +{ + QString path = "E:\\thisIsNotCDrive"; + QString retPath1 = FmUtils::checkDriveToFolderFilter(path); + QVERIFY(retPath1 == path); + + QString retPath2 = FmUtils::checkDriveToFolderFilter(QString()); + QVERIFY(retPath2.isEmpty()); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static int isPathAccessabel( const QString &path );\n + 2. Case Descrition: Verify the right info is returned when using empty path \n + 3. Input Parameters: \n    + <1> path = QString() \n + 4. Expected result: \n    + <1> retInfo == FmErrPathNotExist \n + */ +void TestFmInternalFmUtils::testIsPathAccessableEmpty() +{ + int retInfo = FmUtils::isPathAccessabel(QString()); + QVERIFY(retInfo == FmErrPathNotExist); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static int isPathAccessabel( const QString &path );\n + 2. Case Descrition: Verify the right info is returned when using valid path \n + 3. Input Parameters: \n    + <1> path = Folder_C_Data\n + 4. Expected result: \n    + <1> retInfo == FmErrNone \n + */ +void TestFmInternalFmUtils::testIsPathAccessableOK() +{ + QString path = Folder_C_Data; + int retInfo = FmUtils::isPathAccessabel(path); + QVERIFY(retInfo == FmErrNone); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static int isPathAccessabel( const QString &path );\n + 2. Case Descrition: Verify the right info is returned when using unAccessable path \n + 3. Input Parameters: \n    + <1> path = Drive_C +QString(XX) \n    + <2> path = QString(XX) \n + 4. Expected result: \n    + <1> retInfo == FmErrDriveDenied \n + <2> retInfo == FmErrPathNotExist \n + */ +void TestFmInternalFmUtils::testIsPathAccessableNo() +{ + QString path = "cannotaccesspath"; + int retInfo = FmUtils::isPathAccessabel(path); + QVERIFY(retInfo == FmErrPathNotExist); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool isDriveAvailable( const QString &path );\n + 2. Case Descrition: Verify the drive is available of the path. \n + 3. Input Parameters: \n    + <1> path = QString(XX) \n    + <2> path = QString() \n + 4. Expected result: \n    + <1> \n    + <2> isAvailable == fasle \n + */ +void TestFmInternalFmUtils::testIsDriveAvailable() +{ + foreach(QString strDriveName, mDrives ){ + bool isAvailable1 = FmUtils::isDriveAvailable(strDriveName + QString("availableOrNot")); + + FmDriverInfo::DriveState driveState = FmUtils::queryDriverInfo( strDriveName + QString("availableOrNot") ).driveState(); + if( ( driveState & FmDriverInfo::EDriveAvailable ) ) { + QVERIFY(isAvailable1 == true); + }else + QVERIFY(isAvailable1 == false); + } + // set drive name as QString + bool isAccessable2 = FmUtils::isDriveAvailable(QString()); + QVERIFY(isAccessable2 == false); + + QString pathNotAvailable = "A:\\notAvailabel"; + bool isAccessable3 = FmUtils::isDriveAvailable(pathNotAvailable); + QVERIFY(isAccessable3 == false); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool isDefaultFolder( const QString &folderPath );\n + 2. Case Descrition: Verify the folder is default folder. \n + 3. Input Parameters: \n    + <1> filePath = QString(XX) \n + 4. Expected result: \n    + <1> isDefault == true \n + */ +void TestFmInternalFmUtils::testIsDefaultFolder() +{ + QString filePath1 = "C:\\data\\Games"; + QString filePath2 = "C:\\data\\Images"; + QString filePath3 = "C:\\data\\Installs"; + bool isDefault1 = FmUtils::isDefaultFolder(filePath1); + QVERIFY(isDefault1 == true); + bool isDefault2 = FmUtils::isDefaultFolder(filePath2); + QVERIFY(isDefault2 == true); + bool isDefault3 = FmUtils::isDefaultFolder(filePath3); + QVERIFY(isDefault3 == true); + + bool isDefaultPath1 = FmUtils::isDefaultFolder(QString()); + QVERIFY(isDefaultPath1 == false); + bool isDefaultPath2 = FmUtils::isDefaultFolder(mFilePath); + QVERIFY(isDefaultPath2 == false); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static void createDefaultFolders( const QString &driverName );\n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> driveName = QString() \n    + <2> driveName = QString(XX) \n + 4. Expected result: \n    + <1> isAccessable == false \n    + <2> return true if it's accessful, or return false \n + */ +void TestFmInternalFmUtils::testCreateDefaultFolders() +{ + FmUtils::createDefaultFolders( Folder_C_Data ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static int setFileAttributes( const QString &srcFile, const QString &desFile );\n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> driveName = QString() \n    + <2> driveName = QString(XX) \n + 4. Expected result: \n    + <1> isAccessable == false \n    + <2> return true if it's accessful, or return false \n + */ +void TestFmInternalFmUtils::testSetFileAttributes() +{ + QString srcFile = mFilePath +"Image.jpg"; + QString desFile = mFilePath +"Tone.mp3"; + int err = FmUtils::setFileAttributes( srcFile, desFile ); + QVERIFY(err == 0); + //crash when run to these lines below. +// User::LeaveIfError( src.Open( fsSession, *buf1, EFileRead | EFileShareReadersOnly ) ); +// User::LeaveIfError( des.Open( fsSession, *buf2, EFileWrite | EFileShareExclusive ) ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool hasEnoughSpace( const QString &targetDrive, qint64 size );\n + 2. Case Descrition: Verify the Specified drive has enough space. \n + 3. Input Parameters: \n    + <1> driveName = QString(XX), size = qint64 \n + 4. Expected result: \n    + <1> isHasSpace == true \n + */ +void TestFmInternalFmUtils::testHasEnoughSpaceYes() +{ + qint64 size = 1024; + bool isHasSpace = FmUtils::hasEnoughSpace(mDrives[0], size); + QVERIFY(isHasSpace == true); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool hasEnoughSpace( const QString &targetDrive, qint64 size );\n + 2. Case Descrition: Verify the Specified drive does not has enough space when using large size. \n + 3. Input Parameters: \n    + <1> driveName = QString(XX), size = qint64 \n + 4. Expected result: \n    + <1> isHasSpace == false \n + */ +void TestFmInternalFmUtils::testHasEnoughSpaceNo() +{ + qint64 size = 999999999999999; + bool isHasSpace = FmUtils::hasEnoughSpace(mDrives[0], size); + QVERIFY(isHasSpace == false); +} +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static int moveInsideDrive( const QString &source, const QString &target );\n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> source = QString(XX) \n    + <2> target = QString(XX) \n + 4. Expected result: \n    + <1> isAccessable == false \n + */ +void TestFmInternalFmUtils::testMoveInsideDrive() +{ + QString source = mFilePath + "Imageformove.jpg"; + QString target = Drive_C + QString("data") + QDir::separator() + QString("resource") + QDir::separator() + "Imagenew.jpg"; + QString errStr1; + QString errStr2; + FmUtils::moveInsideDrive(source,target); + FmUtils::checkNewFolderOrFile("Imagenew.jpg", target, errStr1); + bool isNotExsit = FmUtils::checkNewFolderOrFile("Imageformove.jpg", source, errStr2); + qDebug()< driveName = QString() \n    + <2> driveName = QString(XX) \n + 4. Expected result: \n    + <1> isAccessable == false \n    + <2> return true if it's accessful, or return false \n + */ +void TestFmInternalFmUtils::testLaunchFile() +{ +// QString filePath = mFilePath + "Image.jpg"; +// int retInfo = FmUtils::launchFile(filePath); // switch to other thread, test app will shut down. +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static void sendFiles( QStringList &filePathList );\n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> driveName = QString() \n    + <2> driveName = QString(XX) \n + 4. Expected result: \n    + <1> isAccessable == false \n    + <2> return true if it's accessful, or return false \n + */ +void TestFmInternalFmUtils::testSendFiles() +{ + // will delete this case in future +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString getBurConfigPath( QString appPath );\n + 2. Case Descrition: verify the right path for backup restore config file. \n + 3. Input Parameters: \n    + <1> driveName = QString() \n + 4. Expected result: \n    + <1> isAccessable == false \n + */ +void TestFmInternalFmUtils::testGetBurConfigPath() +{ + QString retPath = FmUtils::getBurConfigPath(QString()); + QVERIFY(retPath == "z:/private/2002BCC0/burconfig.xml"); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool isDriveC( const QString &driverName );\n + 2. Case Descrition: Verify the drive is C. \n + 3. Input Parameters: \n    + <1> driveName = Drive_C + QString("ItisCDrive") \n + 4. Expected result: \n    + <1> isDriveC == true \n + */ +void TestFmInternalFmUtils::testIsDriveCYes() +{ + QString pathToVerify = Drive_C +"ItisCDrive"; + bool isDriveC = FmUtils::isDriveC(pathToVerify); + QVERIFY(isDriveC == true); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool isDriveC( const QString &driverName );\n + 2. Case Descrition: Verify the drive is C. \n + 3. Input Parameters: \n    + <1> driveName = Drive_C + QString("ItisCDrive") \n + 4. Expected result: \n    + <1> isDriveC == true \n + */ +void TestFmInternalFmUtils::testIsDriveCNo() +{ + QString pathToVerify ="A:\\ItisCDrive"; + bool isDriveC1 = FmUtils::isDriveC(pathToVerify); + QVERIFY(isDriveC1 == false); + + bool isDriveC2 = FmUtils::isDriveC(QString()); + QVERIFY(isDriveC2 == false); +} +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static int getMaxFileNameLength();\n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> driveName = QString() \n    + <2> driveName = QString(XX) \n + 4. Expected result: \n    + <1> isAccessable == false \n    + <2> return true if it's accessful, or return false \n + */ +void TestFmInternalFmUtils::testGetMaxFileNameLength() +{ + QVERIFY( FmUtils::getMaxFileNameLength() == KMaxFileName ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static bool checkMaxPathLength( const QString& path );\n + 2. Case Descrition: Verify whether the path length is exceed max path length. \n + 3. Input Parameters: \n    + <1> driveName = QString() \n    + <2> driveName = QString(XX) \n + 4. Expected result: \n    + <1> isAccessable == false \n    + <2> return true if it's accessful, or return false \n + */ +void TestFmInternalFmUtils::testCheckMaxPathLength() +{ + QString nameMaxPath; + nameMaxPath.fill('x',320); + QString nameNormalPath = "D:\\ThisIsNormalName"; + + bool isMax1 = FmUtils::checkMaxPathLength(nameMaxPath); + QVERIFY(isMax1 == false); + + bool isMax2 = FmUtils::checkMaxPathLength(nameNormalPath); + QVERIFY(isMax2 == true); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString getFileType( const QString &filePath ); \n + 2. Case Descrition: verify the right file type is returned. \n + 3. Input Parameters: \n    + <1> path =QString(XX) \n + 4. Expected result: \n    + <1> return the right file type(e.g.: the file is "*.jpg", then return "image/jpeg" \n + */ +void TestFmInternalFmUtils::testGetFileTypeWithSupportType() +{ + QString path1 = mFilePath + QString("Image.jpg"); + QString path2 = mFilePath + QString("Tone.mp3"); + + QString retType = FmUtils::getFileType(path2); + QVERIFY( FmUtils::getFileType(path1) == "image/jpeg"); + QVERIFY( FmUtils::getFileType(path2) == "audio/mpeg"); +} +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + static QString getFileType( const QString &filePath ); \n + 2. Case Descrition: verify the funtion when using unsupported file type \n + 3. Input Parameters: \n    + <1> path =QString(XX) \n + 4. Expected result: \n    + <1> \n + */ +void TestFmInternalFmUtils::testGetFileTypeWithUnSupportType() +{ + QString path1 = mFilePath + QString("unknow.unknow"); + + QString retType = FmUtils::getFileType(path1); +// QVERIFY( FmUtils::getFileType(path1) == ""); +} +/*! + Descrition of what you will do in this function + */ +void TestFmInternalFmUtils::cleanupTestCase() +{ +} + +QTEST_MAIN(TestFmInternalFmUtils) diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fminternalfmutils/src/ut_fminternalfmutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fminternalfmutils/src/ut_fminternalfmutils.h Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,137 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* test application for File manager internal apis. +*/ + +#ifndef UT_FMINTERNALFMUTILS_H_ +#define UT_FMINTERNALFMUTILS_H_ + +#include +#include +#include +#include +class TestFmInternalFmUtils :public QObject +{ + Q_OBJECT +private slots: + void initTestCase(); + + void testGetDriveNameFromPath(); //test the getDriveNameFromPath() and fillPathWithSplash() functions. + + void testGetDriveLetterFromPath(); // test the getDriveLetterFromPath() function. + + void testFormatStorageSize(); // test the formatStorageSize() function. + + void testIsDriveYes(); // test isDrive() function with normal drive path + void testIsDriveNo(); // test isDrive() function with an unnormal drive path + + void testFormatPathWithEmptyPath(); // test formatPath() with empty path + void testFormatPath(); // test formatPath() using path with "/" or "\" + + void testFillPathWithSplashUseEmptyPath(); // fillPathWithSplash() + void testFillPathWithSplashHasSplash(); // fillPathWithSplash() + void testFillPathWithSplashWithoutSplash(); // fillPathWithSplash() + + void testRemovePathSplashUseEmptyPath(); // removePathSplash() + void testRemovePathSplashHasSplash(); // removePathSplash() + void testRemovePathSplashWithoutSplash(); // removePathSplash() + + void testGetDriveListAll();//getDriveList() + void testGetDriveListPart();//getDriveList() + + void testFillDriveVolumeEmptyName(); // fillDriveVolume() + void testFillDriveVolumeDefaultVolume(); // fillDriveVolume() + void testFillDriveVolume(); // fillDriveVolume() + + void testGetDefaultVolumeName(); // test getDefaultVolumeName() funtion + + void testGetVolumeNameWithDefaultNameIfNull(); + + void testisPathEqualWithSamePath(); // test isPathEqual() with same path parameter + void testisPathEqualWithDiffPath(); // test isPathEqual() with different path parameter + + void testcheckFolderFileNameNormal(); // test checkFolderFileName() with valid name + void testcheckFolderFileNameUnNormal(); //test checkFolderFileName() with invalid name + + void testCheckNewFolderOrFileUnNormal(); // test checkNewFolderOrFile() function + void testCheckNewFolderOrFileIlegel(); + void testCheckNewFolderOrFileNo(); + + void testIsSubLevelPathYes(); // test isSubLevelPath() function + void testIsSubLevelPathNo(); + + void testRemoveDrivePwdNormal(); // test the removeDrivePwd() function + void testRemoveDrivePwdUnNormal(); + + void testSetDrivePwdNormal(); // test the setDrivePwd() function. + void testSetDrivePwdUnNormal(); + + void testCheckDrivePwd(); // test the checkDrivePwd() function. + void testEmptyPwd(); + + void testRenameDriveWithBadName(); // test renameDrive() function with bad names. + void testRenameDriveWithNormalName(); // test renameDrive() function with normal names. + + void testCheckDriveAccessFilter(); // test the checkDriveAccessFilter() function. + + void testCheckDriveToFolderFilterC(); // test the checkDriveToFolderFilter() function. + void testCheckDriveToFolderFilterNormal(); + + void testCheckFolderToDriveFilterC(); // test CheckFolderToDriveFilter() function. + void testCheckFolderToDriveFilterNormal(); + + void testIsPathAccessableEmpty(); + void testIsPathAccessableOK(); + void testIsPathAccessableNo(); + + void testIsDriveAvailable(); // test the isDriveAvailable() function. + + void testIsDefaultFolder(); // test the isDefaultFolder() function. + + void testCreateDefaultFolders(); // test the createDefaultFolders() function. + + void testSetFileAttributes(); // test teh setFileAttributes() function. + + void testHasEnoughSpaceYes(); // test the hasEnoughSpace() function. + void testHasEnoughSpaceNo(); + + void testMoveInsideDrive(); // test the moveInsideDrive() function. + + void testLaunchFile(); // test the launchFile() funtion. + + void testSendFiles(); + + void testGetBurConfigPath(); + + void testGetFileTypeWithSupportType(); // test the GetFileType() function using file manager supported types. + void testGetFileTypeWithUnSupportType(); + + void testIsDriveCYes(); + void testIsDriveCNo(); + + void testGetMaxFileNameLength(); + + void testCheckMaxPathLength(); + + void cleanupTestCase(); +private: + QString mFilePath; + QStringList mDrives; // all drives + QStringList mDrives1;// drives which type is USB or MemCard + QStringList mDrives2;// drives except USB and MemCard + + QTranslator mTranslator; +}; +#endif /* UT_FMINTERNALFMUTILS_H_ */ diff -r 22e202702210 -r 1bebd60c0f00 filemanager/tsrc/unit/ut_fminternalfmutils/ut_fminternalfmutils.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fminternalfmutils/ut_fminternalfmutils.pro Mon Oct 04 00:06:46 2010 +0300 @@ -0,0 +1,51 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +QT += testlib +CONFIG += hb qtestlib +CONFIG += symbian_test + +TEMPLATE = app +TARGET = ut_fminternalfmutils + +include ( ../ut_common.pri ) +include ( ../../../src/common.pri ) +include ( ../../../src/inc/commoninc.pri ) +include ( ../../../src/inc/commonutils.pri ) + +DEPENDPATH += . +INCLUDEPATH += . + +#TARGET.CAPABILITY = ALL -TCB +TARGET.CAPABILITY = CAP_APPLICATION DiskAdmin AllFiles PowerMgmt + +HEADERS += src/*.h +SOURCES += src/*.cpp + +symbian:MMP_RULES += SMPSAFE + +symbian { + deploy.path = C: + files.sources += data/Image.jpg \ + data/Tone.mp3 \ + data/unknow.unknow \ + data/Imageformove.jpg + files.path = /data/resource/fmtestdata + DEPLOYMENT += files + + # This is for new exporting system coming in garden + for(file, files.sources):BLD_INF_RULES.prj_exports += "./$$file $$deploy.path$$files.path/$$basename(file)" +}