# HG changeset patch # User hgs # Date 1285835639 -28800 # Node ID 12b82dc0e8db0271e4256442846ad4846fbc1431 # Parent 4167eb56f30d4558d6de02ad00178125d6596216 201039 diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/examples/demo_fmfiledialog/demo_fmfiledialog.pro --- a/filemanager/examples/demo_fmfiledialog/demo_fmfiledialog.pro Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/examples/demo_fmfiledialog/demo_fmfiledialog.pro Thu Sep 30 16:33:59 2010 +0800 @@ -29,3 +29,12 @@ SOURCES += main.cpp mainwindow.cpp LIBS += -lfmfiledialog + +symbian { + INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE + INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE + INCLUDEPATH += $$MOC_DIR + TARGET.CAPABILITY = ALL -TCB + TARGET.EPOCALLOWDLLDATA = 1 + MMP_RULES += SMPSAFE +} diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/examples/demo_fmfiledialog/mainwindow.cpp --- a/filemanager/examples/demo_fmfiledialog/mainwindow.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/examples/demo_fmfiledialog/mainwindow.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -89,7 +89,7 @@ listWidget->addItem( "placeHolderY" ); listWidget->addItem( "placeHolderZ" ); - connect(listWidget, SIGNAL(activated(HbListWidgetItem*)), this,SLOT(activatedListItem(HbListWidgetItem*)) ); + connect(listWidget, SIGNAL(activated(HbListWidgetItem*)), this,SLOT(activatedListItem(HbListWidgetItem*)), Qt::QueuedConnection ); } void TestMainWindow::activatedListItem(HbListWidgetItem *item) diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/filemanager.pro --- a/filemanager/filemanager.pro Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/filemanager.pro Thu Sep 30 16:33:59 2010 +0800 @@ -20,5 +20,7 @@ include(rom/rom.pri) } +SUBDIRS += ../files_plat/filemanager_api +SUBDIRS += src/fmfiledialog SUBDIRS += src/fmbkupenginewrapper SUBDIRS += src/filemanager \ No newline at end of file diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/filemanager_plat/inc/filemanager_plat.pri --- a/filemanager/filemanager_plat/inc/filemanager_plat.pri Thu Sep 02 17:00:51 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -# -# 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: -# - -PLATFORM_HEADERS += $$PWD/fmglobal.h \ - $$PWD/fmfiledialog.h - -HEADERS += $$PLATFORM_HEADERS \ No newline at end of file diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/filemanager_plat/inc/fmfiledialog.h --- a/filemanager/filemanager_plat/inc/fmfiledialog.h Thu Sep 02 17:00:51 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -/* -* 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 the file dialog -* -*/ - -#ifndef FMFILEDIALOG_H -#define FMFILEDIALOG_H - -#include "fmglobal.h" - - -#include - -class QString; -class QStringList; -class FmFileDialogPrivate; - -class FMFILEDIALOG_EXPORT FmFileDialog : public HbDialog -{ -Q_OBJECT -public: - - enum Option - { - /* - * Open dir as dialog's working directory and prevent user up to parent directory - */ - PreventDirUp = 0x00000001, - /* - * Ignore filter for dir, list all directory. Set this when need only filter filename. - */ - DisplayAllDirs = 0x00000002 - }; - Q_DECLARE_FLAGS(Options, Option) - - /** - * Static function that will return an existing directory selected by the user - * @param parent Parent widget - * @param title Title for dialog - * @param dir Dialog's working directory is set to dir - * @param nameFilters used for filter folder - * @param Options Options - * @return Directory path that user selected. - * user can select cancel to close dialog and empty string will be returned - */ - static QString getExistingDirectory( HbWidget *parent = 0, - const QString &title = QString(), - const QString &dir = QString(), - const QStringList &nameFilters = QStringList(), - Options options = 0 ); - - /** - * Static function that returns an existing file selected by the use - * @param parent Parent widget - * @param title Title for dialog - * @param dir Dialog's working directory is set to dir - * @param nameFilters used for filter file/folder, such as "*.jpg", "*.txt" - * Please set options with "DisplayAllDirs" to avoid folder be filtered when only filter filename. - * @param Options Options - * @return File path that user selected. It is an esisting file. - * user can select cancel to close dialog and empty string will be returned - */ - static QString getOpenFileName( HbWidget *parent = 0, - const QString &title = QString(), - const QString &dir = QString(), - const QStringList &nameFilters = QStringList(), - Options options = 0 ); - /** - * Static function that will return a file name selected by the user. The file does not have to exist. - * @param parent Parent widget - * @param title Title for dialog - * @param dir Dialog's working directory is set to dir - * @param nameFilters used for filter file/folder, such as "*.jpg", "*.txt" - * Please set options with "DisplayAllDirs" to avoid folder be filtered when only filter filename. - * @param Options Options - * @return File path that user selected or inputted in file name line edit. - * This file does not have to exist. - * user can select cancel to close dialog and empty string will be returned - */ - static QString getSaveFileName( HbWidget *parent = 0, - const QString &title = QString(), - const QString &dir = QString(), - const QStringList &nameFilters = QStringList(), - Options options = 0 ); - -private slots: - void dialogClosed(HbAction *action); - -private: - explicit FmFileDialog( QGraphicsItem *parent ); - ~FmFileDialog(); - - bool exec(); - HbAction *primaryAction() const; - void setPrimaryAction( HbAction *action ); - - HbAction *secondaryAction() const; - void setSecondaryAction( HbAction *action ); - - FmFileDialogPrivate *d_ptr; - - Q_DISABLE_COPY( FmFileDialog) - Q_DECLARE_PRIVATE_D(d_ptr,FmFileDialog) - Q_PRIVATE_SLOT(d_func(),void _q_handleUpButton()) - Q_PRIVATE_SLOT(d_func(),void _q_handleTextChanged(QString)) - Q_PRIVATE_SLOT(d_func(),void _q_handlePathChanged(QString)) - Q_PRIVATE_SLOT(d_func(),void _q_handleFileActivated(QString)) -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(FmFileDialog::Options) - -#endif // FMFILEDIALOG_H diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/filemanager_plat/inc/fmglobal.h --- a/filemanager/filemanager_plat/inc/fmglobal.h Thu Sep 02 17:00:51 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -/* -* 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: -* -*/ - -#ifndef FMGLOBAL_H -#define FMGLOBAL_H - -#include - -#ifdef FMFILEDIALOG_LIBRARY -# define FMFILEDIALOG_EXPORT Q_DECL_EXPORT -#else -# define FMFILEDIALOG_EXPORT Q_DECL_IMPORT -#endif - -#endif diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/common.pri --- a/filemanager/src/common.pri Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/common.pri Thu Sep 30 16:33:59 2010 +0800 @@ -58,7 +58,7 @@ INCLUDEPATH += $$PWD/inc win32 { # add platfrom API for windows - INCLUDEPATH += $$PWD/../filemanager_plat/inc + INCLUDEPATH += $$PWD/../../files_plat/filemanager_api/inc } diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/filemanager.pro --- a/filemanager/src/filemanager/filemanager.pro Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/filemanager.pro Thu Sep 30 16:33:59 2010 +0800 @@ -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,10 @@ -lefsrv \ -lapgrfx \ -lcone \ - -lsysutil + -lsysutil \ + -lbafl \ + -leikcore \ + -lafservice TARGET.UID3 = 0x2002BCC0 TARGET.EPOCHEAPSIZE = 0x020000 0x1000000 @@ -52,4 +59,6 @@ BLD_INF_RULES.prj_exports += "./burconfig.xml z:/private/2002BCC0/burconfig.xml" } +symbian:MMP_RULES += SMPSAFE + TRANSLATIONS = filemanager.ts diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/resources/hblistviewitem.css --- a/filemanager/src/filemanager/resources/hblistviewitem.css Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/resources/hblistviewitem.css Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/backuprestore/fmbackupview.cpp --- a/filemanager/src/filemanager/src/backuprestore/fmbackupview.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/backuprestore/fmbackupview.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/backuprestore/fmrestoreview.cpp --- a/filemanager/src/filemanager/src/backuprestore/fmrestoreview.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/backuprestore/fmrestoreview.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/components/fmdlgutils.cpp --- a/filemanager/src/filemanager/src/components/fmdlgutils.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/components/fmdlgutils.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/components/fmdlgutils.h --- a/filemanager/src/filemanager/src/components/fmdlgutils.h Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/components/fmdlgutils.h Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/components/fmmessagebox.cpp --- a/filemanager/src/filemanager/src/components/fmmessagebox.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/components/fmmessagebox.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/components/fmmessagebox.h --- a/filemanager/src/filemanager/src/components/fmmessagebox.h Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/components/fmmessagebox.h Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/components/fmviewdetailsdialog.cpp --- a/filemanager/src/filemanager/src/components/fmviewdetailsdialog.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/components/fmviewdetailsdialog.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -100,7 +100,7 @@ mDataListModel->setData( mDataListModel->index( EMemoryName, 0 ), dataList, Qt::DisplayRole ); dataList.clear(); - dataList << hbTrId ( "txt_fmgr_dblist_size_memory" ); + dataList << hbTrId ( "txt_fmgr_dblist_size" ); dataList << FmUtils::formatStorageSize( driverInfo.size() ) ; mDataListModel->setData( mDataListModel->index( EMemorySize, 0 ), dataList, Qt::DisplayRole ); @@ -193,7 +193,7 @@ mDataListModel->removeRows( 0, mDataListModel->rowCount() ); mDataListModel->insertRows( 0, EFolderDetailEntryEnd ); - dataList << hbTrId ( "txt_fmgr_dblist_name_folder" ); + dataList << hbTrId ( "txt_fmgr_dblist_name" ); dataList << fileInfo.fileName(); mDataListModel->setData( mDataListModel->index( EFolderName, 0 ), dataList, Qt::DisplayRole ); @@ -202,17 +202,17 @@ QTime modifiedTime = modifiedDateTime.time(); dataList.clear(); - dataList << hbTrId ( "txt_fmgr_dblist_date_folder" ); + dataList << hbTrId ( "txt_fmgr_dblist_date" ); dataList << modifiedDate.toString(); mDataListModel->setData( mDataListModel->index( EModifiedDate, 0 ), dataList, Qt::DisplayRole ); dataList.clear(); - dataList << hbTrId ( "txt_fmgr_dblist_time_folder" ); + dataList << hbTrId ( "txt_fmgr_dblist_time" ); dataList << modifiedTime.toString(); mDataListModel->setData( mDataListModel->index( EModifiedTime, 0 ), dataList, Qt::DisplayRole ); dataList.clear(); - dataList << hbTrId ( "txt_fmgr_dblist_size_folder" ); + dataList << hbTrId ( "txt_fmgr_dblist_size" ); dataList << FmUtils::formatStorageSize( mSizeofFolder ); mDataListModel->setData( mDataListModel->index( EFolderSize, 0 ), dataList, Qt::DisplayRole ); @@ -239,8 +239,8 @@ mDataListModel->removeRows( 0, mDataListModel->rowCount() ); mDataListModel->insertRows( 0, EFileDetailEntryEnd ); - dataList << hbTrId ( "txt_fmgr_dblist_name_file" ); - dataList << fileInfo.fileName(); + dataList << hbTrId ( "txt_fmgr_dblist_name" ); + dataList << fileInfo.baseName(); mDataListModel->setData( mDataListModel->index( EFileName, 0 ), dataList, Qt::DisplayRole ); dataList.clear(); @@ -248,9 +248,12 @@ - QString fileType = FmUtils::getFileType( filePath ); + QString fileType( fileInfo.completeSuffix() ); if( fileType.isEmpty() ){ - fileType.append( fileInfo.suffix() ); + fileType.append( FmUtils::getFileType( filePath ) ); + } else { + //file type need to include the dot(.) + fileType.insert( 0, Pre_Suffix_Dot ); } dataList << fileType; mDataListModel->setData( mDataListModel->index( EFileType, 0 ), dataList, Qt::DisplayRole ); @@ -260,17 +263,17 @@ QTime modifiedTime = modifiedDateTime.time(); dataList.clear(); - dataList << hbTrId ( "txt_fmgr_dblist_date_file" ); + dataList << hbTrId ( "txt_fmgr_dblist_date" ); dataList << modifiedDate.toString(); mDataListModel->setData( mDataListModel->index( EFileModifiedDate, 0 ), dataList, Qt::DisplayRole ); dataList.clear(); - dataList << hbTrId ( "txt_fmgr_dblist_time_file" ); + dataList << hbTrId ( "txt_fmgr_dblist_time" ); dataList << modifiedTime.toString(); mDataListModel->setData( mDataListModel->index( EFileModifiedTime, 0 ), dataList, Qt::DisplayRole ); dataList.clear(); - dataList << hbTrId ( "txt_fmgr_dblist_size_file" ); + dataList << hbTrId ( "txt_fmgr_dblist_size" ); dataList << FmUtils::formatStorageSize( fileInfo.size() ); mDataListModel->setData( mDataListModel->index( EFileSize, 0 ), dataList, Qt::DisplayRole ); } diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/fmdriverlistwidget.cpp --- a/filemanager/src/filemanager/src/fmdriverlistwidget.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/fmdriverlistwidget.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 { @@ -333,7 +333,7 @@ break; } } else { - FmDlgUtils::information( hbTrId( "The password is incorrect, try again!" ) ); + FmDlgUtils::warning( hbTrId( "The password is incorrect, try again!" ), HbMessageBox::Ok, true ); } } @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/fmdriverview.cpp --- a/filemanager/src/filemanager/src/fmdriverview.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/fmdriverview.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -71,12 +71,6 @@ action->setObjectName( "restoreAction" ); action->setText( hbTrId( "txt_fmgr_opt_restore" ) ); menu()->addAction( action ); - - action = new HbAction( this ); - action->setObjectName( "exitAction" ); - action->setText( hbTrId( "Exit" ) ); - menu()->addAction( action ); - } void FmDriverView::initDiskListWidget() @@ -140,11 +134,6 @@ } #endif -void FmDriverView::on_exitAction_triggered() -{ - qApp->quit(); -} - void FmDriverView::on_backupAction_triggered() { FmViewManager::viewManager()->createBackupView(); diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/fmdriverview.h --- a/filemanager/src/filemanager/src/fmdriverview.h Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/fmdriverview.h Thu Sep 30 16:33:59 2010 +0800 @@ -37,7 +37,6 @@ private slots: void on_leftAction_triggered(); void on_rightAction_triggered(); - void on_exitAction_triggered(); void on_backupAction_triggered(); void on_restoreAction_triggered(); void on_findAction_triggered(); diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/fmfilebrowsewidget.cpp --- a/filemanager/src/filemanager/src/fmfilebrowsewidget.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/fmfilebrowsewidget.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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: @@ -288,7 +289,7 @@ HbAction *viewAction = new HbAction(); viewAction->setObjectName( "viewAction" ); - viewAction->setText( hbTrId( "txt_fmgr_menu_view_details_file" ) ); + viewAction->setText( hbTrId( "txt_fmgr_menu_view_details_memory" ) ); contextMenu->addAction( viewAction ); connect( viewAction, SIGNAL( triggered() ), @@ -297,7 +298,7 @@ //copy HbAction *copyAction = new HbAction(); copyAction->setObjectName( "copyAction" ); - copyAction->setText( hbTrId( "txt_fmgr_menu_copy" ) ); + copyAction->setText( hbTrId( "txt_common_menu_copy_to_folder" ) ); contextMenu->addAction( copyAction ); connect( copyAction, SIGNAL( triggered() ), @@ -312,7 +313,7 @@ //Move HbAction *moveAction = new HbAction(); moveAction->setObjectName( "moveAction" ); - moveAction->setText( hbTrId( "txt_fmgr_menu_move" ) ); + moveAction->setText( hbTrId( "txt_common_menu_move_to_folder" ) ); contextMenu->addAction( moveAction ); connect( moveAction, SIGNAL( triggered() ), @@ -321,7 +322,7 @@ //Delete HbAction *deleteAction = new HbAction(); deleteAction->setObjectName( "deleteAction" ); - deleteAction->setText( hbTrId( "txt_fmgr_menu_delete" ) ); + deleteAction->setText( hbTrId( "txt_common_menu_delete" ) ); contextMenu->addAction( deleteAction ); connect( deleteAction, SIGNAL( triggered() ), @@ -330,7 +331,7 @@ //rename HbAction *renameAction = new HbAction(); renameAction->setObjectName( "renameAction" ); - renameAction->setText( hbTrId( "txt_fmgr_menu_rename" ) ); + renameAction->setText( hbTrId( "txt_common_menu_rename_item" ) ); contextMenu->addAction( renameAction ); connect( renameAction, SIGNAL( triggered() ), @@ -340,7 +341,7 @@ if( fileInfo.isFile() ){ HbAction *sendAction = new HbAction(); sendAction->setObjectName( "sendAction" ); - sendAction->setText( hbTrId( "txt_fmgr_menu_send" ) ); + sendAction->setText( hbTrId( "txt_common_menu_send_item" ) ); contextMenu->addAction( sendAction ); connect( sendAction, SIGNAL( triggered() ), @@ -353,8 +354,9 @@ contextMenu->open(); } -void FmFileBrowseWidget::on_list_pressed( const QModelIndex & index ) +void FmFileBrowseWidget::on_list_pressed( const QModelIndex &index ) { + Q_UNUSED( index ); mListLongPressed = false; } @@ -412,11 +414,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 +602,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 +630,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 +659,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 +689,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 +722,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 @@ -734,3 +740,30 @@ } } +/*! + return BackWasNotConsumed if this view should be closed. + return BackWasConsumed if change to up level folder( back to up level folder ) +*/ +FmEventResponse FmFileBrowseWidget::offerBackEvent() +{ + QString currentPath( + FmUtils::fillPathWithSplash( this->currentPath().filePath() ) ); + // return BackWasNotConsumed to close current view if match root level path + if( mRootLevelPath.length() != 0 && + mRootLevelPath.compare( currentPath, Qt::CaseInsensitive ) == 0 ) { + return BackWasNotConsumed; + } else if ( cdUp() ) { + return BackWasConsumed; + } else { + return BackWasNotConsumed; + } +} + +/*! + \a rootPath used to lock root level path. + Root level path is the top leve path that user can view. +*/ +void FmFileBrowseWidget::setRootLevelPath(const QString &rootPath) +{ + mRootLevelPath = rootPath; +} diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/fmfilebrowsewidget.h --- a/filemanager/src/filemanager/src/fmfilebrowsewidget.h Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/fmfilebrowsewidget.h Thu Sep 30 16:33:59 2010 +0800 @@ -37,6 +37,7 @@ class HbLabel; class FmFileIconProvider; +class FmFileSystemProxyModel; class FmFileBrowseWidget : public HbWidget { @@ -74,7 +75,8 @@ int checkPathAndSetStyle( const QString& path ); void sortFiles( TSortType sortType ); void activeSearchPanel(); - + FmEventResponse offerBackEvent(); + void setRootLevelPath(const QString &rootPath); public slots: bool cdUp(); void setRootPath( const QString &pathName ); @@ -122,7 +124,8 @@ HbTreeView *mTreeView; HbListView *mListView; QGraphicsLinearLayout *mLayout; - QFileSystemModel *mModel; + QFileSystemModel *mSourceModel; + FmFileSystemProxyModel *mModel; bool mSelectable; @@ -146,6 +149,8 @@ // provide icon from filemanger FmFileIconProvider *mFileIconProvider; + //root path level to contain back action + QString mRootLevelPath; }; #endif diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/fmfileview.cpp --- a/filemanager/src/filemanager/src/fmfileview.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/fmfileview.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -33,13 +33,15 @@ #include #include #include +#include #include #include #include FmFileView::FmFileView() : FmViewBase( EFileView ), mWidget( 0 ), - mUpButton( 0 ), mStyleAction( 0 ), mSelectableAction( 0 ), - mFindAction( 0 ), mOperationService( 0 ), mMenu( 0 ), mIsFindDisabled( false ) + mStyleAction( 0 ), mSelectableAction( 0 ), + mFindAction( 0 ), mSortExtension( 0 ), + mOperationService( 0 ), mMenu( 0 ), mIsFindDisabled( false ) { mOperationService = FmViewManager::viewManager()->operationService(); initMenu(); @@ -88,7 +90,7 @@ void FmFileView::setRootLevelPath( const QString &pathName ) { - rootLevelPath = FmUtils::fillPathWithSplash( pathName ); + mWidget->setRootLevelPath( FmUtils::fillPathWithSplash( pathName ) ); } void FmFileView::setFindDisabled( bool disable ) @@ -122,21 +124,21 @@ action = new HbAction(); action->setObjectName( "delete" ); - action->setText( hbTrId( "txt_fmgr_menu_delete" ) ); + action->setText( hbTrId( "txt_common_opt_delete" ) ); menu()->addAction( action ); connect( action, SIGNAL( triggered() ), this, SLOT( on_delete_triggered() ), Qt::QueuedConnection ); action = new HbAction(); action->setObjectName( "copy" ); - action->setText( hbTrId( "txt_fmgr_menu_copy" ) ); + action->setText( hbTrId( "txt_common_opt_copy_to_folder" ) ); menu()->addAction( action ); connect( action, SIGNAL( triggered() ), this, SLOT( on_copy_triggered() ), Qt::QueuedConnection ); action = new HbAction(); action->setObjectName( "move" ); - action->setText( hbTrId( "txt_fmgr_menu_move" ) ); + action->setText( hbTrId( "txt_common_opt_move_to_folder" ) ); menu()->addAction( action ); connect( action, SIGNAL( triggered() ), this, SLOT( on_move_triggered() ), Qt::QueuedConnection ); @@ -215,20 +217,39 @@ mFindAction->setText( hbTrId("txt_fmgr_opt_find") ); mFindAction->setDisabled( mIsFindDisabled ); toolBar()->addAction( mFindAction ); - - mToolBarRightAction = new HbAction( this ); - mToolBarRightAction->setObjectName( "rightAction" ); - mToolBarRightAction->setText( hbTrId( "up" ) ); - toolBar()->addAction( mToolBarRightAction ); - toolBar()->setOrientation( Qt::Horizontal ); - //mToolBar = takeToolBar(); + mSortNameAction = new HbAction( this ); + mSortNameAction->setText( hbTrId( "txt_fmgr_setlabel_sort_by_name" ) ); + + mSortTimeAction = new HbAction( this ); + mSortTimeAction->setText( hbTrId( "txt_fmgr_setlabel_sort_by_time" ) ); + + mSortSizeAction = new HbAction( this ); + mSortSizeAction->setText( hbTrId( "txt_fmgr_setlabel_sort_by_size" ) ); + + mSortTypeAction = new HbAction( this ); + mSortTypeAction->setText( hbTrId( "txt_fmgr_setlabel_sort_by_type" ) ); + + mSortExtension = new HbToolBarExtension(); + mSortExtension->addAction( mSortNameAction ); + mSortExtension->addAction( mSortTimeAction ); + mSortExtension->addAction( mSortSizeAction ); + mSortExtension->addAction( mSortTypeAction ); + + HbAction* extensionAction = toolBar()->addExtension( mSortExtension ); + extensionAction->setText( hbTrId("txt_fmgr_opt_sort")); + connect( mFindAction, SIGNAL( triggered() ), - this, SLOT( on_leftAction_triggered() ) ); - connect( mToolBarRightAction, SIGNAL( triggered() ), - this, SLOT( on_rightAction_triggered() ), Qt::QueuedConnection ); - + this, SLOT( on_leftAction_triggered() ) ); + connect( mSortNameAction, SIGNAL( triggered() ), + this, SLOT( on_sortNameAction_triggered() ), Qt::QueuedConnection ); + connect( mSortTimeAction, SIGNAL( triggered() ), + this, SLOT( on_sortTimeAction_triggered() ), Qt::QueuedConnection ); + connect( mSortSizeAction, SIGNAL( triggered() ), + this, SLOT( on_sortSizeAction_triggered() ), Qt::QueuedConnection ); + connect( mSortTypeAction, SIGNAL( triggered() ), + this, SLOT( on_sortTypeAction_triggered() ), Qt::QueuedConnection ); } void FmFileView::setStyle( FmFileBrowseWidget::Style style ) @@ -256,7 +277,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 +324,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 +362,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 +400,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 +432,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; } @@ -423,29 +444,11 @@ } } -void FmFileView::on_upAction_triggered() -{ - mWidget->cdUp(); -} - void FmFileView::on_leftAction_triggered() { mWidget->activeSearchPanel(); } -void FmFileView::on_rightAction_triggered() -{ - QString currentPath( - FmUtils::fillPathWithSplash( mWidget->currentPath().filePath() ) ); - if( rootLevelPath.length() != 0 && - rootLevelPath.compare( currentPath, Qt::CaseInsensitive ) == 0 ) { - emit popViewAndShow(); - } else if ( !mWidget->cdUp() ) { - //hbInstance->allMainWindows()[0]->softKeyAction(Hb::SecondarySoftKey)->trigger(); - emit popViewAndShow(); - } -} - void FmFileView::on_driveChanged() { mWidget->on_driveChanged(); @@ -482,6 +485,10 @@ void FmFileView::removeToolBarAction() { toolBar()->clearActions(); + if ( mSortExtension ) { + delete mSortExtension; + mSortExtension = 0; + } } void FmFileView::on_mainWidget_setEmptyMenu( bool isMenuEmpty ) @@ -530,3 +537,9 @@ } return dirName; } + +FmEventResponse FmFileView::offerBackEvent() +{ + return mWidget->offerBackEvent(); +} + diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/fmfileview.h --- a/filemanager/src/filemanager/src/fmfileview.h Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/fmfileview.h Thu Sep 30 16:33:59 2010 +0800 @@ -29,6 +29,7 @@ class HbPushButton; class HbMenu; class FmOperationService; +class HbToolBarExtension; class FmFileView : public FmViewBase { @@ -58,9 +59,7 @@ void on_copy_triggered(); void on_move_triggered(); void on_newFolder_triggered(); - void on_upAction_triggered(); - void on_leftAction_triggered(); - void on_rightAction_triggered(); + void on_leftAction_triggered(); void on_sortNameAction_triggered(); void on_sortTimeAction_triggered(); void on_sortSizeAction_triggered(); @@ -93,21 +92,27 @@ QString createDefaultFolderName( const QString &path ); private: + // from FmViewBase: + virtual FmEventResponse offerBackEvent(); + +private: FmFileBrowseWidget *mWidget; - HbPushButton *mUpButton; - //HbLineEdit *mLineEdit; HbAction *mStyleAction; HbAction *mSelectableAction; HbAction *mFindAction; - QString rootLevelPath; + HbToolBarExtension* mSortExtension; FmOperationService *mOperationService; - - HbAction *mToolBarRightAction; + HbMenu *mMenu; // store the disable state of find action. true for disabled bool mIsFindDisabled; + + HbAction *mSortNameAction; + HbAction *mSortTimeAction; + HbAction *mSortSizeAction; + HbAction *mSortTypeAction; }; #endif diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/fmfindthread.cpp --- a/filemanager/src/filemanager/src/fmfindthread.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/fmfindthread.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/fmfindwidget.cpp --- a/filemanager/src/filemanager/src/fmfindwidget.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/fmfindwidget.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -88,7 +88,11 @@ void FmFindWidget::on_resultModel_findFinished() { - emit setEmptyMenu( false ); + if ( mModel->rowCount() > 0 ) { + emit setEmptyMenu( false ); + } else { + emit setEmptyMenu( true ); + } } void FmFindWidget::init() @@ -121,6 +125,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 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/fmmainwindow.cpp --- a/filemanager/src/filemanager/src/fmmainwindow.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/fmmainwindow.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/fmmainwindow.h --- a/filemanager/src/filemanager/src/fmmainwindow.h Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/fmmainwindow.h Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/fmviewbase.cpp --- a/filemanager/src/filemanager/src/fmviewbase.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/fmviewbase.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -34,14 +34,16 @@ void FmViewBase::init() { - mBackAction = new HbAction( Hb::BackNaviAction, this ); - mBackAction->setObjectName( "backAction" ); + mBackAction = new HbAction( Hb::BackNaviAction, this ); setNavigationAction( mBackAction ); + connect( mBackAction, SIGNAL( triggered() ), this, SLOT( onBackActionTriggered() ) ); } -void FmViewBase::on_backAction_triggered() +void FmViewBase::onBackActionTriggered() { - FmViewManager::viewManager()->popViewAndShow(); + if( offerBackEvent() == BackWasNotConsumed ) { + FmViewManager::viewManager()->popViewAndShow(); + } } /*! @@ -50,4 +52,13 @@ void FmViewBase::aboutToClose() { -} \ No newline at end of file +} + +/*! + respond to back action. +*/ +FmEventResponse FmViewBase::offerBackEvent() +{ + return BackWasNotConsumed; +} + diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/fmviewbase.h --- a/filemanager/src/filemanager/src/fmviewbase.h Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/fmviewbase.h Thu Sep 30 16:33:59 2010 +0800 @@ -20,7 +20,7 @@ #define FMVIEWBASE_H #include - +#include class HbAction; class FmViewBase : public HbView @@ -49,10 +49,13 @@ } virtual void aboutToClose(); private slots: - void on_backAction_triggered(); + void onBackActionTriggered(); signals: - void tryToExit(); + void tryToExit(); + +protected: + virtual FmEventResponse offerBackEvent(); private: void init(); diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/fmviewmanager.cpp --- a/filemanager/src/filemanager/src/fmviewmanager.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/fmviewmanager.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -30,19 +30,17 @@ #include "fmdrivewatcher.h" #include "fmdialog.h" #include "fmdlgutils.h" +#include "fmserviceutils.h" #include #include #include -#include #include #include #include -#include - FmViewManager *FmViewManager::mViewManager = 0; - +const QString FM_MAIN_VIEW = "FMMemoryStoragesList"; FmDlgCloseUnit::FmDlgCloseUnit( FmDialog *dialog ) : mDialog( dialog ) { @@ -75,13 +73,14 @@ return mDialog; } -FmViewManager::FmViewManager( FmMainWindow* mainWindow ) : mOperationService( 0 ), mShareUi( 0 ) +FmViewManager::FmViewManager( FmMainWindow* mainWindow ) + : mOperationService( 0 ), mServiceUtils( 0 ) { mMainWindow = mainWindow; mDriveWatcher = new FmDriveWatcher( this ); mDriveWatcher->setObjectName( "driveWatcher" ); mDriveWatcher->startWatch(); - + QMetaObject::connectSlotsByName( this ); } @@ -101,9 +100,8 @@ delete mDriveWatcher; mDriveWatcher = 0; - delete mShareUi; - mShareUi = 0; - + delete mServiceUtils; + mServiceUtils = 0; } FmViewManager *FmViewManager::CreateViewManager( FmMainWindow* mainWindow ) @@ -130,19 +128,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() @@ -203,8 +202,8 @@ mMainWindow->addView( driverView ); mMainWindow->setCurrentView( driverView ); - HbActivityManager* activityManager = qobject_cast(qApp)->activityManager(); - bool ok = activityManager->removeActivity("FMMemoryStoragesList"); + bool ok = serviceUtils()->removeActivity(FM_MAIN_VIEW); + Q_UNUSED( ok ); connect( this, SIGNAL( driveSpaceChanged() ), driverView, SLOT( refreshDrive() ) ); @@ -236,7 +235,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; } @@ -348,12 +347,11 @@ mScreenShot = QPixmap::grabWidget(mMainWindow, mMainWindow->rect()); } QVariantHash metadata; - metadata.insert("screenshot", mScreenShot); - HbActivityManager* activityManager = qobject_cast(qApp)->activityManager(); - // add the activity to the activity manager - bool ok = activityManager->addActivity("FMMemoryStoragesList", QVariant(), metadata); + metadata.insert("screenshot", mScreenShot); + // save the activity + bool ok = serviceUtils()->saveActivity(FM_MAIN_VIEW, QVariant(), metadata); // do not need check return value - + Q_UNUSED( ok ); } void FmViewManager::onAboutToChangeView(HbView * oldView, HbView *newView) diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/fmviewmanager.h --- a/filemanager/src/filemanager/src/fmviewmanager.h Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/fmviewmanager.h Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/operationservice/fmoperationcopyormove.cpp --- a/filemanager/src/filemanager/src/operationservice/fmoperationcopyormove.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/operationservice/fmoperationcopyormove.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/operationservice/fmoperationformat.h --- a/filemanager/src/filemanager/src/operationservice/fmoperationformat.h Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/operationservice/fmoperationformat.h Thu Sep 30 16:33:59 2010 +0800 @@ -35,7 +35,9 @@ signals: void driveSpaceChanged(); - +private: + void storeVolumeName( int drive ); + void restoreVolumeName( int drive ); private: QString mDriverName; diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/operationservice/fmoperationformat_s60.cpp --- a/filemanager/src/filemanager/src/operationservice/fmoperationformat_s60.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/operationservice/fmoperationformat_s60.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/operationservice/fmoperationremove.cpp --- a/filemanager/src/filemanager/src/operationservice/fmoperationremove.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/operationservice/fmoperationremove.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/operationservice/fmoperationresultprocesser.cpp --- a/filemanager/src/filemanager/src/operationservice/fmoperationresultprocesser.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/operationservice/fmoperationresultprocesser.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/filemanager/src/operationservice/fmoperationservice.cpp --- a/filemanager/src/filemanager/src/operationservice/fmoperationservice.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/filemanager/src/operationservice/fmoperationservice.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/fmbkupengine/group/fmbkupengine.mmp --- a/filemanager/src/fmbkupengine/group/fmbkupengine.mmp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/fmbkupengine/group/fmbkupengine.mmp Thu Sep 30 16:33:59 2010 +0800 @@ -49,3 +49,6 @@ // End of File + + +SMPSAFE diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/fmbkupenginewrapper/fmbkupenginewrapper.pro --- a/filemanager/src/fmbkupenginewrapper/fmbkupenginewrapper.pro Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/fmbkupenginewrapper/fmbkupenginewrapper.pro Thu Sep 30 16:33:59 2010 +0800 @@ -36,6 +36,10 @@ LIBS += -leikcore LIBS += -lcone LIBS += -lsysutil - LIBS += -lplatformenv + LIBS += -lplatformenv + LIBS += -lbafl } + + +symbian:MMP_RULES += SMPSAFE diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/fmbkupenginewrapper/src/fmbackupsettings.cpp --- a/filemanager/src/fmbkupenginewrapper/src/fmbackupsettings.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/fmbkupenginewrapper/src/fmbackupsettings.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/fmfiledialog/fmfiledialog.pri --- a/filemanager/src/fmfiledialog/fmfiledialog.pri Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/fmfiledialog/fmfiledialog.pri Thu Sep 30 16:33:59 2010 +0800 @@ -14,6 +14,12 @@ # Description: FmFileDialog project - source files # + +# API headers +HEADERS += ../../../files_plat/filemanager_api/inc/fmfiledialog.h +HEADERS += ../../../files_plat/filemanager_api/inc/fmglobal.h + +# normal headers and sources HEADERS += ./src/fmfiledialog_p.h \ ./src/fmfilewidget.h diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/fmfiledialog/fmfiledialog.pro --- a/filemanager/src/fmfiledialog/fmfiledialog.pro Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/fmfiledialog/fmfiledialog.pro Thu Sep 30 16:33:59 2010 +0800 @@ -18,8 +18,8 @@ include ( ../common.pri ) include ( ../inc/commoninc.pri ) include ( ../inc/commonutils.pri ) -include ( ../../filemanager_plat/inc/filemanager_plat.pri ) include ( fmfiledialog.pri ) + symbian { LIBS += -lplatformenv \ -lapmime \ @@ -29,15 +29,13 @@ -lefsrv \ -lapgrfx \ -lcone \ - -lsysutil + -lsysutil \ + -lbafl \ + -leikcore \ + -lafservice TARGET.UID3 = 0x2002BCC3 +} - # export headers to app - EXPORT_PLATFORM_HEADERS += \ - ../../filemanager_plat/inc/fmglobal.h \ - ../../filemanager_plat/inc/fmfiledialog.h - - 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 4167eb56f30d -r 12b82dc0e8db filemanager/src/fmfiledialog/src/fmfiledialog.cpp --- a/filemanager/src/fmfiledialog/src/fmfiledialog.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/fmfiledialog/src/fmfiledialog.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/fmfiledialog/src/fmfiledialog_p.cpp --- a/filemanager/src/fmfiledialog/src/fmfiledialog_p.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/fmfiledialog/src/fmfiledialog_p.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -28,7 +28,7 @@ #include #include -#define backButtonIcon ":image/qtg_indi_status_back.svg" +#define backButtonIcon "qtg_mono_app_exit" /*! constructor diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/fmfiledialog/src/fmfilewidget.cpp --- a/filemanager/src/fmfiledialog/src/fmfilewidget.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/fmfiledialog/src/fmfilewidget.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/fmfiledialog/src/fmfilewidget.h --- a/filemanager/src/fmfiledialog/src/fmfilewidget.h Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/fmfiledialog/src/fmfilewidget.h Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/inc/commonutils.pri --- a/filemanager/src/inc/commonutils.pri Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/inc/commonutils.pri Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/inc/fmdefine.h --- a/filemanager/src/inc/fmdefine.h Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/inc/fmdefine.h Thu Sep 30 16:33:59 2010 +0800 @@ -91,4 +91,22 @@ // 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( '\\' ) + +#define Pre_Suffix_Dot QChar('.') + +// used for handle back event +enum FmEventResponse +{ + BackWasNotConsumed = 0, + BackWasConsumed = 1 +}; + #endif diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/inc/fmfilesystemproxymodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/src/inc/fmfilesystemproxymodel.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/inc/fmfilesystemproxymodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/src/inc/fmfilesystemproxymodel.h Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/inc/fmfiletyperecognizer.cpp --- a/filemanager/src/inc/fmfiletyperecognizer.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/inc/fmfiletyperecognizer.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -49,6 +49,8 @@ mFileExtensionMap.insert( QString( "3g2" ), FileTypeVideo ); mFileExtensionMap.insert( QString( "rmvb" ),FileTypeVideo ); mFileExtensionMap.insert( QString( "mkv" ), FileTypeVideo ); + mFileExtensionMap.insert( QString( "3gpp" ),FileTypeVideo ); + mFileExtensionMap.insert( QString( "mpeg4"),FileTypeVideo ); mFileExtensionMap.insert( QString( "aac" ), FileTypeTone ); diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/inc/fmserviceutils/fmserviceutils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/src/inc/fmserviceutils/fmserviceutils.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,74 @@ +/* +* 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(); +} + +/*! + save acitivity for activity wrapper +*/ +bool FmServiceUtils::saveActivity(const QString &activityId, const QVariant &activityData, const QVariantHash &metadata) +{ + return d->saveActivity( activityId, activityData, metadata ); +} + +/*! + remove acitivity for activity wrapper +*/ +bool FmServiceUtils::removeActivity(const QString &activityId) +{ + return d->removeActivity( activityId ); +} diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/inc/fmserviceutils/fmserviceutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/src/inc/fmserviceutils/fmserviceutils.h Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,54 @@ +/* +* 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 +#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(); + + // activity wrapper + bool saveActivity(const QString &activityId, const QVariant &activityData, const QVariantHash &metadata); + bool removeActivity(const QString &activityId); + +private: + FmServiceUtilsPrivate *d; +}; + + +#endif diff -r 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -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: +* The source file of service utils private +*/ + +#include "fmserviceutilsprivate.h" +#include "fmserviceutilshandler.h" +#include "fmcommon.h" +#include +#include + +FmServiceUtilsPrivate::FmServiceUtilsPrivate() + :mShareUi( 0 ), mServiceUtilsHandler( 0 ), mActivityStorage( 0 ) +{ + +} + +FmServiceUtilsPrivate::~FmServiceUtilsPrivate() +{ + if( mShareUi ) { + delete mShareUi; + mShareUi = 0; + } + + if( mServiceUtilsHandler ) { + delete mServiceUtilsHandler; + mServiceUtilsHandler = 0; + } + + if( mActivityStorage ) { + delete mActivityStorage; + mActivityStorage = 0; + } +} + +/* + return \a shareUi which is used to send files. +*/ +ShareUi *FmServiceUtilsPrivate::shareUi() +{ + if( !mShareUi ) { + mShareUi = new ShareUi; + } + return mShareUi; +} + +/* + return \a AfActivityStorage which is used to save activity. +*/ +AfActivityStorage *FmServiceUtilsPrivate::activityStorage() +{ + if( !mActivityStorage ) { + mActivityStorage = new AfActivityStorage; + } + return mActivityStorage; +} + +/* + 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() ); + } +} + +/*! + call AfActivityStorage to save activity +*/ +bool FmServiceUtilsPrivate::saveActivity(const QString &activityId, const QVariant &activityData, const QVariantHash &metadata) +{ + return activityStorage()->saveActivity( activityId, activityData, metadata); +} + +/*! + call AfActivityStorage to remove activity +*/ +bool FmServiceUtilsPrivate::removeActivity(const QString &activityId) +{ + return activityStorage()->removeActivity( activityId ); +} + diff -r 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,66 @@ +/* +* 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 +#include +#include + +class ShareUi; +class AfActivityStorage; +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(); + + // activity implement + bool saveActivity(const QString &activityId, const QVariant &activityData, const QVariantHash &metadata); + bool removeActivity(const QString &activityId); + +private: + ShareUi *shareUi(); + AfActivityStorage *activityStorage(); + CFmServiceUtilsHandler *serviceUtilsHandler(); + +private: + // used to send files + ShareUi *mShareUi; + + // used for some service utils + CFmServiceUtilsHandler *mServiceUtilsHandler; + + //own used to save activity. + AfActivityStorage *mActivityStorage; +}; + +#endif diff -r 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,77 @@ +/* +* 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() +{ + +} + +/*! + dummy function for win32 build +*/ +bool FmServiceUtilsPrivate::saveActivity(const QString &activityId, const QVariant &activityData, const QVariantHash &metadata) +{ + Q_UNUSED( activityId ); + Q_UNUSED( activityData ); + Q_UNUSED( metadata ); + return false; +} + +/*! + dummy function +*/ +bool FmServiceUtilsPrivate::removeActivity(const QString &activityId) +{ + Q_UNUSED( activityId ); + return false; +} diff -r 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,41 @@ +/* +* 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 +#include +#include + +class FmServiceUtilsPrivate +{ +public: + FmServiceUtilsPrivate(); + virtual ~FmServiceUtilsPrivate(); + + void sendFile( const QStringList &filePathList ); + void closeApps(); + void restartApps(); + + // activity implement + bool saveActivity(const QString &activityId, const QVariant &activityData, const QVariantHash &metadata); + bool removeActivity(const QString &activityId); +}; + +#endif diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/src/inc/fmutils.cpp --- a/filemanager/src/inc/fmutils.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/inc/fmutils.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/inc/fmutils.h --- a/filemanager/src/inc/fmutils.h Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/inc/fmutils.h Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/inc/fmutils_s60.cpp --- a/filemanager/src/inc/fmutils_s60.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/inc/fmutils_s60.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/src/inc/fmutils_win.cpp --- a/filemanager/src/inc/fmutils_win.cpp Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/src/inc/fmutils_win.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/tsrc.pro --- a/filemanager/tsrc/tsrc.pro Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/tsrc/tsrc.pro Thu Sep 30 16:33:59 2010 +0800 @@ -15,7 +15,12 @@ # TEMPLATE = subdirs -SUBDIRS = unit/unit_backuprestoresettings +SUBDIRS = unit/unit_backuprestoresettings \ + unit/ut_fminternaldrivermodel \ + unit/ut_fminternalfmutils \ + unit/ut_fmfiletypeprovider \ + unit/ut_fmfiletyperecognizer \ + unit/ut_fmoprationserviceapi CONFIG += ordered #CONFIG += symbian_test diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/unit_backuprestoresettings/unit_backuprestoresettings.pro --- a/filemanager/tsrc/unit/unit_backuprestoresettings/unit_backuprestoresettings.pro Thu Sep 02 17:00:51 2010 +0800 +++ b/filemanager/tsrc/unit/unit_backuprestoresettings/unit_backuprestoresettings.pro Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_common.pri --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_common.pri Thu Sep 30 16:33:59 2010 +0800 @@ -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: +# + +LIBS += -lfmbkupenginewrapper +LIBS += -lfmfiledialog + +symbian { + LIBS += -lplatformenv \ + -lapmime \ + -lxqservice \ + -lxqutils \ + -lshareui \ + -lefsrv \ + -lapgrfx \ + -lcone \ + -ldirectorylocalizer \ + -lsysutil \ + -lbafl \ + -leikcore \ + -lafservice +} + +QMAKE_EXTRA_TARGETS += test autotest \ No newline at end of file diff -r 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Flash.swf Binary file filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Flash.swf has changed diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Install.sisx Binary file filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Install.sisx has changed diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Java.jar Binary file filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Java.jar has changed diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Tone.wav Binary file filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Tone.wav has changed diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Video.rm Binary file filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/Video.rm has changed diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/image.jpg Binary file filemanager/tsrc/unit/ut_fmfiletyperecognizer/data/image.jpg has changed diff -r 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fminternalfmutils/data/Image.jpg Binary file filemanager/tsrc/unit/ut_fminternalfmutils/data/Image.jpg has changed diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fminternalfmutils/data/Imageformove.jpg Binary file filemanager/tsrc/unit/ut_fminternalfmutils/data/Imageformove.jpg has changed diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fminternalfmutils/data/Tone.mp3 Binary file filemanager/tsrc/unit/ut_fminternalfmutils/data/Tone.mp3 has changed diff -r 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,1 @@ +unknow type \ No newline at end of file diff -r 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -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 4167eb56f30d -r 12b82dc0e8db 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 Thu Sep 30 16:33:59 2010 +0800 @@ -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)" +} diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmoprationserviceapi/data/dataforcopy.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmoprationserviceapi/data/dataforcopy.txt Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,1 @@ +for copy. \ No newline at end of file diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmoprationserviceapi/data/dataformove.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmoprationserviceapi/data/dataformove.txt Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,1 @@ +test data for asyncMove. \ No newline at end of file diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmoprationserviceapi/data/multifilesforcopy/copydata1.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmoprationserviceapi/data/multifilesforcopy/copydata1.txt Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,1 @@ +this is the data for copy muliti-files. \ No newline at end of file diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmoprationserviceapi/data/multifilesforcopy/copydata2.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmoprationserviceapi/data/multifilesforcopy/copydata2.txt Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,1 @@ +this is the data for copy muliti-files. \ No newline at end of file diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmoprationserviceapi/data/multifilesforcopy/copydata3.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmoprationserviceapi/data/multifilesforcopy/copydata3.txt Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,1 @@ +this is the data for copy muliti-files. \ No newline at end of file diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmoprationserviceapi/data/multifilesformove/movedata1.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmoprationserviceapi/data/multifilesformove/movedata1.txt Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,1 @@ +this file is for multi-move. \ No newline at end of file diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmoprationserviceapi/data/multifilesformove/movedata2.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmoprationserviceapi/data/multifilesformove/movedata2.txt Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,1 @@ +this file is for multi-move. \ No newline at end of file diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmoprationserviceapi/data/multifilesformove/movedata3.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmoprationserviceapi/data/multifilesformove/movedata3.txt Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,1 @@ +this file is for multi-move. \ No newline at end of file diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmoprationserviceapi/runtest.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmoprationserviceapi/runtest.bat Thu Sep 30 16:33:59 2010 +0800 @@ -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_fmoprationserviceapi.exe -xml -o c:\ut_fmoprationserviceapi.xml +copy \epoc32\winscw\c\ut_fmoprationserviceapi.xml +del \epoc32\winscw\c\ut_fmoprationserviceapi.xml \ No newline at end of file diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmoprationserviceapi/src/testviewmanager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmoprationserviceapi/src/testviewmanager.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,71 @@ +/* +* 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 filemanager view manager +* +*/ + +#include "testviewmanager.h" +#include "fmoperationservice.h" +#include "fmoperationbase.h" + +#include +#include +#include +#include + +#include + +TestViewManager *TestViewManager::mTestViewManager = 0; + +TestViewManager::TestViewManager( HbMainWindow* mainWindow ) : mOperationService( 0 ) +{ + mMainWindow = mainWindow; +} + +TestViewManager::~TestViewManager(void) +{ + delete mOperationService; + delete mMainWindow; +} + +TestViewManager *TestViewManager::CreateTestViewManager( HbMainWindow* mainWindow ) +{ + if( !mTestViewManager ){ + mTestViewManager = new TestViewManager( mainWindow ); + } + + return mTestViewManager; +} + +TestViewManager *TestViewManager::viewManager() +{ + return mTestViewManager; +} + +FmOperationService *TestViewManager::operationService() +{ + if ( !mOperationService ) { + mOperationService = new FmOperationService( this ); + mOperationService->setObjectName( "operationServicefortest" ); + } + return mOperationService; +} + +void TestViewManager::RemoveViewManager() +{ + delete mTestViewManager; + mTestViewManager = 0; +} + diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmoprationserviceapi/src/testviewmanager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmoprationserviceapi/src/testviewmanager.h Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,64 @@ +/* +* 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 filemanager view manager +* +*/ + +#ifndef TESTVIEWMANAGER_H +#define TESTVIEWMANAGER_H + +#include +#include +#include + +class HbView; +class FmViewManager; +class FmOperationService; +class FmOperationBase; +class HbMainWindow; + +/* + * this class is used to drive the test case. + */ + +class TestViewManager : public QObject +{ + Q_OBJECT + +public: + static TestViewManager *CreateTestViewManager( HbMainWindow* mainWindow ); + static TestViewManager *viewManager(); + FmOperationService *operationService(); + static void RemoveViewManager(); + +protected: + explicit TestViewManager( HbMainWindow* mainWindow ); + ~TestViewManager(); + +private: + static TestViewManager *mTestViewManager; + +private: + // main window + HbMainWindow *mMainWindow; + + // operation service, used to start operations such as copy, move, delete, format... + FmOperationService *mOperationService; +}; + +#endif + + + diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmoprationserviceapi/src/ut_fmoprationserviceapi.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmoprationserviceapi/src/ut_fmoprationserviceapi.cpp Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,431 @@ +/* + * 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 file manager operation service public apis. + */ + +#include "ut_fmoprationserviceapi.h" +#include "testviewmanager.h" +#include "fmoperationservice.h" +#include "fmviewmanager.h" +#include +#include +#include +#include + +/*! + \class TestFmOperationService + \brief describe the test case's goal, like: \n + class name: FmOperationService \n + class's description: The header file of the operation service of file manager \n + type of test case: unit api test\n + test cases' number totally: \n + */ + +/*! + Description of test data + */ +void TestFmOperationService::initTestCase() +{ + mMainWindow = new HbMainWindow(); + TestViewManager::CreateTestViewManager(mMainWindow); + mOperationService = TestViewManager::viewManager()->operationService(); + QVERIFY (mOperationService != 0); + + connect(mOperationService, SIGNAL(notifyFinish( FmOperationBase*)), + this, SLOT(onNotifyFinish( FmOperationBase*))); + connect(mOperationService, SIGNAL(notifyError( FmOperationBase*, int, QString)), + this, SLOT(onNotifyError( FmOperationBase*, int, QString))); + connect(mOperationService, SIGNAL(notifyCanceled( FmOperationBase* )), + this, SLOT(onNotifyCanceled( FmOperationBase* ))); + + // initialize public test data here + mPath = Drive_C + QString("data") + QDir::separator() + + QString( "dataforfmoperation" ) + QDir::separator(); + mDataPath = Drive_C + QString("data") + QDir::separator() + QString( "dataforfmoperation" ) + + QDir::separator() + QString( "data" ) + QDir::separator(); + mDataMultiCopyPath = mDataPath + QString("multifilesforcopy") + QDir::separator(); + mDataMultiMovePath = mDataPath + QString("multifilesformove") + QDir::separator(); +} + +/*! + Descrition of what you will do in this function + */ +void TestFmOperationService::cleanupTestCase() +{ +// mOperationService and mMainWindow are deleted in RemoveViewManager() too. + TestViewManager::RemoveViewManager(); + // release all test data +} + +/*! + Test Case Description:\n + 1. Fucntion Name: explicit FmOperationService( QObject *parent ); \n + 2. Case Descrition: test the constructor function. \n + 3. Input Parameters: \n    + <1> parent = 0;\n    + <2> parent = new QObject(); \n + 4. Expected result: \n    + <1> no crash \n    + <2> no crash \n + */ +void TestFmOperationService::testConstructor() +{ + FmOperationService *testOperationService = new FmOperationService(0); + QVERIFY (testOperationService != 0); + delete testOperationService; +} + +/*! + Test Case Description:\n + 1. Fucntion Name: int asyncViewDriveDetails( const QString driverName ); \n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> driverName = QString(XX);\n    + <2> driverName = QString(); \n + 4. Expected result: \n    + <1> no crash \n    + <2> no crash \n + */ +void TestFmOperationService::testAsyncViewDriveDetails() +{ +//blocked, because of the UI problem. +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + int asyncCopy( const QStringList &sourceList, const QString &targetPath ); \n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> sourceList = QString(XX), targetPath = QString(XX)\n + 4. Expected result: \n    + <1> the file is copied to the target path. \n + */ +void TestFmOperationService::testAsyncCopySingleFile() +{ + QStringList sourceData; + sourceData.append(mDataPath + "dataforcopy.txt"); + // make sure the copy file is not available in the target path. + QFile checkFile(mPath + "dataforcopy.txt"); + if(checkFile.exists()){ + checkFile.remove(); + } + //test the asyncCopy() function. + int retInfo = mOperationService->asyncCopy(sourceData, mPath); + + mTestEventLoop.exec(); + QVERIFY( checkFile.exists() ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + int asyncCopy( const QStringList &sourceList, const QString &targetPath ); \n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> sourceList = QString(XX), targetPath = QString(XX)\n + 4. Expected result: \n    + <1> All the files are copied to the target path. \n + */ +void TestFmOperationService::testAsyncCopyMultiFiles() +{ + QStringList sourceDataMultiCopy; + sourceDataMultiCopy.append(mDataMultiCopyPath + "copydata1.txt"); + sourceDataMultiCopy.append(mDataMultiCopyPath + "copydata2.txt"); + sourceDataMultiCopy.append(mDataMultiCopyPath + "copydata3.txt"); + // make sure the copy file is not available in the target path. + QFile checkFile1(mPath + "copydata1.txt"); + QFile checkFile2(mPath + "copydata2.txt"); + QFile checkFile3(mPath + "copydata3.txt"); + if(checkFile1.exists()){ + checkFile1.remove(); + } + if(checkFile2.exists()){ + checkFile2.remove(); + } + if(checkFile3.exists()){ + checkFile3.remove(); + } + //test the asyncCopy() function. + int retInfo = mOperationService->asyncCopy(sourceDataMultiCopy, mPath); + + mTestEventLoop.exec(); + QVERIFY( checkFile1.exists() ); + QVERIFY( checkFile2.exists() ); + QVERIFY( checkFile3.exists() ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + int asyncCopy( const QStringList &sourceList, const QString &targetPath ); \n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> sourceList = QString(XX), targetPath = QString(XX)\n + 4. Expected result: \n    + <1> the folder included its content is copied to the target path. \n + */ +void TestFmOperationService::testAsyncCopyFolder() +{ + QStringList sourceDataFolder; + sourceDataFolder.append( mDataPath + "multifilesforcopy" ); + // make sure the copy file is not available in the target path. + QStringList folderNeedRemove; + folderNeedRemove.append(mPath + "multifilesforcopy"); + QDir checkDir(mPath + "multifilesforcopy"); + if(checkDir.exists()){ + mOperationService->asyncRemove(folderNeedRemove); + mTestEventLoop.exec(); + } + //test the asyncCopy() function. + int retInfo = mOperationService->asyncCopy(sourceDataFolder, mPath); + + mTestEventLoop.exec(); + QVERIFY( checkDir.exists() ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + int asyncCopy( const QStringList &sourceList, const QString &targetPath ); \n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> sourceList = QString(), targetPath = QString(XX)\n + 4. Expected result: \n    + <1> no crash \n + */ +void TestFmOperationService::testAsyncCopyEmpty() +{ + QStringList sourceDataEmpty; + sourceDataEmpty.append(QString()); + int retInfo = mOperationService->asyncCopy(sourceDataEmpty, mPath); + + mTestEventLoop.exec(); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + int asyncMove( const QStringList &sourceList, const QString &targetPath ); \n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> sourceList = QString(XX), targetPath = QString(XX)\n + 4. Expected result: \n    + <1> the file is moved to the target path. \n + */ +void TestFmOperationService::testAsyncMoveSingleFile() +{ + QStringList sourceDataSingleMove; + sourceDataSingleMove.append(mDataPath + "dataformove.txt"); + // make sure the copy file is not available in the target path. + QFile checkFile(mPath + "dataformove.txt"); + if(checkFile.exists()){ + checkFile.remove(); + } + //test the asyncCopy() function. + int retInfo = mOperationService->asyncMove(sourceDataSingleMove, mPath); + + mTestEventLoop.exec(); + QVERIFY( checkFile.exists() ); + QFile checkSourceData(mDataPath + "dataformove.txt"); + QVERIFY( !checkSourceData.exists() ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + int asyncMove( const QStringList &sourceList, const QString &targetPath ); \n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> sourceList = QString(XX), targetPath = QString(XX)\n + 4. Expected result: \n    + <1> All the filea are moved to the target path. \n + */ +void TestFmOperationService::testAsyncMoveMultiFiles() +{ + QStringList sourceDataMultiMove; + sourceDataMultiMove.append(mDataMultiMovePath + "movedata1.txt"); + sourceDataMultiMove.append(mDataMultiMovePath + "movedata2.txt"); + // make sure the copy file is not available in the target path. + QFile checkFile1(mPath + "movedata1.txt"); + QFile checkFile2(mPath + "movedata2.txt"); + if(checkFile1.exists()){ + checkFile1.remove(); + } + if(checkFile2.exists()){ + checkFile2.remove(); + } + //test the asyncCopy() function. + int retInfo = mOperationService->asyncMove(sourceDataMultiMove, mPath); + mTestEventLoop.exec(); + //verify the files are copied to the target path. + QVERIFY( checkFile1.exists() ); + QVERIFY( checkFile2.exists() ); + //verify the files are not in the orignal path yet. + QFile checkSourceData1(mDataMultiMovePath + "movedata1.txt"); + QFile checkSourceData2(mDataMultiMovePath + "movedata2.txt"); + QVERIFY( !checkSourceData1.exists() ); + QVERIFY( !checkSourceData2.exists() ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + int asyncMove( const QStringList &sourceList, const QString &targetPath ); \n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> sourceList = QString(XX), targetPath = QString(XX)\n + 4. Expected result: \n    + <1> The folder is moved to the target path. \n + */ +void TestFmOperationService::testAsyncMoveFolder() +{ + QStringList sourceDataFolder; + sourceDataFolder.append( mDataPath + "multifilesforMove" ); + // make sure the copy file is not available in the target path. + QStringList folderNeedRemove; + folderNeedRemove.append(mPath + "multifilesforMove"); + QDir checkDir(mPath + "multifilesforMove"); + if(checkDir.exists()){ + mOperationService->asyncRemove(folderNeedRemove); + mTestEventLoop.exec(); + } + //test the asyncMove() function. + int retInfo = mOperationService->asyncMove(sourceDataFolder, mPath); + mTestEventLoop.exec(); + + QVERIFY( checkDir.exists() ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + int asyncMove( const QStringList &sourceList, const QString &targetPath ); \n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> sourceList = QString(), targetPath = QString(XX)\n + 4. Expected result: \n    + <1> no crash \n + */ +void TestFmOperationService::testAsyncMoveEmpty() +{ + QStringList sourceDataEmpty; + sourceDataEmpty.append(QString()); + int retInfo = mOperationService->asyncMove(sourceDataEmpty, mPath); + + mTestEventLoop.exec(); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + int asyncRemove( const QStringList &pathList ); \n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> pathList = QStringList(XX);\n + 4. Expected result: \n    + <1> The file is removed. \n + */ +void TestFmOperationService::testAsyncRemoveSingleFile() +{ + QStringList sourceData; + sourceData.append(mPath + "dataforcopy.txt"); + // make sure the copy file is available in the target path. + QFile checkFile(mPath + "dataforcopy.txt"); + if(checkFile.exists()){ + //test the asyncRemove() function. + int retInfo = mOperationService->asyncRemove(sourceData); + mTestEventLoop.exec(); + } + QVERIFY( !checkFile.exists() ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + int asyncRemove( const QStringList &pathList ); \n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> pathList = QStringList(XX);\n + 4. Expected result: \n    + <1> All the files are removed. \n + */ +void TestFmOperationService::testAsyncRemoveMultiFiles() +{ + QStringList multiRemoveData; + multiRemoveData.append(mPath + "copydata1.txt"); + multiRemoveData.append(mPath + "copydata2.txt"); + multiRemoveData.append(mPath + "movedata1.txt"); + // make sure the copy file is available in the target path. + QFile checkFile1(mPath + "copydata1.txt"); + QFile checkFile2(mPath + "copydata2.txt"); + QFile checkFile3(mPath + "movedata1.txt"); + if(checkFile1.exists() && checkFile2.exists() && checkFile3.exists()){ + //test the asyncRemove() function. + int retInfo = mOperationService->asyncRemove(multiRemoveData); + mTestEventLoop.exec(); + } + QVERIFY( !checkFile1.exists() ); + QVERIFY( !checkFile2.exists() ); + QVERIFY( !checkFile3.exists() ); +} + +/*! + Test Case Description:\n + 1. Fucntion Name: \n    + int asyncRemove( const QStringList &pathList ); \n + 2. Case Descrition: \n + 3. Input Parameters: \n    + <1> pathList = QStringList(XX);\n + 4. Expected result: \n    + <1> The specified folder is removed. \n + */ +void TestFmOperationService::testAsyncRemoveFolder() +{ + QStringList sourceDataFolder; + sourceDataFolder.append( mDataPath + "multifilesforMove" ); + // make sure the copy file is not available in the target path. + QStringList folderRemoveData; + folderRemoveData.append(mPath + "multifilesforMove"); + QDir checkDir(mPath + "multifilesforMove"); + + if(checkDir.exists()){ + mOperationService->asyncRemove(folderRemoveData); + mTestEventLoop.exec(); + } + //verify the folder is removed. + QVERIFY( !checkDir.exists() ); +} + +void TestFmOperationService::testAsyncBackup() +{ + // not implemented yet. +} + +void TestFmOperationService::onNotifyFinish(FmOperationBase* operationBase) +{ + mTestEventLoop.exit(); +} +void TestFmOperationService::onNotifyError(FmOperationBase* operationBase, + int error, QString errString) +{ + mTestEventLoop.exit(); +} +void TestFmOperationService::onNotifyCanceled(FmOperationBase* operationBase) +{ + mTestEventLoop.exit(); +} + +QTEST_MAIN(TestFmOperationService) diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmoprationserviceapi/src/ut_fmoprationserviceapi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmoprationserviceapi/src/ut_fmoprationserviceapi.h Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,73 @@ +/* +* 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_FMOPRATIONSERVICEAPI_H_ +#define UT_FMOPRATIONSERVICEAPI_H_ + +#include +#include +#include + +class HbMainWindow; +class FmOperationBase; +class FmOperationService; + +class TestFmOperationService :public QObject +{ + Q_OBJECT +private slots: + + void initTestCase(); + + void testConstructor(); //test the constructor function. + void testAsyncViewDriveDetails(); + + void testAsyncCopySingleFile(); + void testAsyncCopyMultiFiles(); + void testAsyncCopyFolder(); + void testAsyncCopyEmpty(); + + void testAsyncMoveSingleFile(); + void testAsyncMoveMultiFiles(); + void testAsyncMoveFolder(); + void testAsyncMoveEmpty(); + + void testAsyncRemoveSingleFile(); + void testAsyncRemoveMultiFiles(); + void testAsyncRemoveFolder(); +// void testAsyncRemoveEmpty(); + + void testAsyncBackup(); + + +// void testAsyncFormat(); + void cleanupTestCase(); + + // handle operation service event + void onNotifyFinish( FmOperationBase* operationBase ); + void onNotifyError( FmOperationBase* operationBase, int error, QString errString ); + void onNotifyCanceled( FmOperationBase* operationBase ); +private: + HbMainWindow *mMainWindow; + QEventLoop mTestEventLoop; + FmOperationService *mOperationService; + QString mPath; + QString mDataPath; + QString mDataMultiCopyPath; + QString mDataMultiMovePath; +}; +#endif /* UT_FMOPRATIONSERVICEAPI_H_ */ diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmoprationserviceapi/ut_fmoperationserviceapi.pri --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmoprationserviceapi/ut_fmoperationserviceapi.pri Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,126 @@ +# +# 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 \ + -lafservice +} + +# Input +HEADERS += src/ut_fmoprationserviceapi.h \ + src/testviewmanager.h \ + ../../../src/filemanager/src/fmdriverlistwidget.h \ +# ../../../src/filemanager/src/listviewitems.h \ + ../../../src/filemanager/src/fmfileview.h \ + ../../../src/filemanager/src/fmfilebrowsewidget.h \ + ../../../src/filemanager/src/fmdriverview.h \ + ../../../src/filemanager/src/fmmainwindow.h \ + ../../../src/filemanager/src/fmsplitview.h \ + ../../../src/filemanager/src/fmfindthread.h \ + ../../../src/filemanager/src/fmfindresultmodel.h \ + ../../../src/filemanager/src/fmfindview.h \ + ../../../src/filemanager/src/fmfindwidget.h \ + ../../../src/filemanager/src/fmviewmanager.h \ + ../../../src/filemanager/src/fmviewbase.h \ + ../../../src/filemanager/src/operationservice/fmoperationservice.h \ + ../../../src/filemanager/src/operationservice/fmoperationthread.h \ + ../../../src/filemanager/src/operationservice/fmoperationbase.h \ + ../../../src/filemanager/src/operationservice/fmoperationresultprocesser.h \ + ../../../src/filemanager/src/operationservice/fmoperationcopyormove.h \ + ../../../src/filemanager/src/operationservice/fmoperationviewdetails.h \ +# ../../../src/filemanager/src/operationservice/fmoperationmove.h \ + ../../../src/filemanager/src/operationservice/fmoperationremove.h \ + ../../../src/filemanager/src/operationservice/fmoperationformat.h \ + ../../../src/filemanager/src/backuprestore/fmbackupview.h \ + ../../../src/filemanager/src/backuprestore/fmbackupwidget.h \ + ../../../src/filemanager/src/backuprestore/fmrestoreview.h \ + ../../../src/filemanager/src/backuprestore/fmrestorewidget.h \ + ../../../src/filemanager/src/backuprestore/fmrestoreviewitem.h \ + ../../../src/filemanager/src/backuprestore/fmbackupconfigloader.h \ + ../../../src/filemanager/src/backuprestore/fmbackuprestorehandler.h \ + ../../../src/filemanager/src/backuprestore/fmdeletebackupview.h \ + ../../../src/filemanager/src/backuprestore/fmdeletebackupwidget.h \ + ../../../src/filemanager/src/components/fmcombinedquery.h \ + ../../../src/filemanager/src/components/fmdlgutils.h \ + ../../../src/filemanager/src/components/fmtimequery.h \ + ../../../src/filemanager/src/components/fmsingletextquery.h \ + ../../../src/filemanager/src/components/fmmultitextquery.h \ + ../../../src/filemanager/src/components/fmviewdetailsdialog.h \ + ../../../src/filemanager/src/components/fmviewdetailsitem.h \ + ../../../src/filemanager/src/components/fmdrivedetailstype.h \ + ../../../src/filemanager/src/components/fmmessagebox.h \ + ../../../src/filemanager/src/components/fmdialog.h \ + ../../../src/filemanager/src/components/fmdrivequery.h + +SOURCES += src/ut_fmoprationserviceapi.cpp \ + src/testviewmanager.cpp \ + ../../../src/filemanager/src/fmdriverlistwidget.cpp \ +# ../../../src/filemanager/src/listviewitems.cpp \ + ../../../src/filemanager/src/fmfileview.cpp \ + ../../../src/filemanager/src/fmfilebrowsewidget.cpp \ + ../../../src/filemanager/src/fmdriverview.cpp \ + ../../../src/filemanager/src/fmmainwindow.cpp \ + ../../../src/filemanager/src/fmsplitview.cpp \ + ../../../src/filemanager/src/fmfindthread.cpp \ + ../../../src/filemanager/src/fmfindresultmodel.cpp \ + ../../../src/filemanager/src/fmfindview.cpp \ + ../../../src/filemanager/src/fmfindwidget.cpp \ + ../../../src/filemanager/src/fmviewmanager.cpp \ + ../../../src/filemanager/src/fmviewbase.cpp \ + ../../../src/filemanager/src/operationservice/fmoperationservice.cpp \ + ../../../src/filemanager/src/operationservice/fmoperationthread.cpp \ + ../../../src/filemanager/src/operationservice/fmoperationbase.cpp \ + ../../../src/filemanager/src/operationservice/fmoperationresultprocesser.cpp \ + ../../../src/filemanager/src/operationservice/fmoperationcopyormove.cpp \ + ../../../src/filemanager/src/operationservice/fmoperationviewdetails.cpp \ + #../../../src/filemanager/src/operationservice/fmoperationmove.cpp \ + ../../../src/filemanager/src/operationservice/fmoperationremove.cpp \ + ../../../src/filemanager/src/operationservice/fmoperationformat_s60.cpp \ + ../../../src/filemanager/src/backuprestore/fmbackupview.cpp \ + ../../../src/filemanager/src/backuprestore/fmbackupwidget.cpp \ + ../../../src/filemanager/src/backuprestore/fmrestoreview.cpp \ + ../../../src/filemanager/src/backuprestore/fmrestorewidget.cpp \ + ../../../src/filemanager/src/backuprestore/fmrestoreviewitem.cpp \ + ../../../src/filemanager/src/backuprestore/fmbackupconfigloader.cpp \ + ../../../src/filemanager/src/backuprestore/fmbackuprestorehandler.cpp \ + ../../../src/filemanager/src/backuprestore/fmdeletebackupview.cpp \ + ../../../src/filemanager/src/backuprestore/fmdeletebackupwidget.cpp \ + ../../../src/filemanager/src/components/fmcombinedquery.cpp \ + ../../../src/filemanager/src/components/fmdlgutils.cpp \ + ../../../src/filemanager/src/components/fmtimequery.cpp \ + ../../../src/filemanager/src/components/fmsingletextquery.cpp \ + ../../../src/filemanager/src/components/fmmultitextquery.cpp \ + ../../../src/filemanager/src/components/fmviewdetailsdialog.cpp \ + ../../../src/filemanager/src/components/fmviewdetailsitem.cpp \ + ../../../src/filemanager/src/components/fmdrivedetailstype.cpp \ + ../../../src/filemanager/src/components/fmmessagebox.cpp \ + ../../../src/filemanager/src/components/fmdialog.cpp \ + ../../../src/filemanager/src/components/fmdrivequery.cpp \ No newline at end of file diff -r 4167eb56f30d -r 12b82dc0e8db filemanager/tsrc/unit/ut_fmoprationserviceapi/ut_fmoprationserviceapi.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filemanager/tsrc/unit/ut_fmoprationserviceapi/ut_fmoprationserviceapi.pro Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,50 @@ +# +# 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 += qtestlib +CONFIG += symbian_test +CONFIG += hb +TEMPLATE = app +TARGET = ut_fmoprationserviceapi + +include ( ../../../src/common.pri ) +include ( ../../../src/inc/commoninc.pri ) +include ( ../../../src/inc/commonutils.pri ) +include ( ut_fmoperationserviceapi.pri ) + +DEPENDPATH += . +INCLUDEPATH += ../../../src/fmbkupenginewrapper/inc +INCLUDEPATH += ../../../src/filemanager/src/operationservice +TARGET.CAPABILITY = ALL -TCB + +QMAKE_EXTRA_TARGETS += test autotest + +symbian { + deploy.path = C: + files1.sources += data/dataforcopy.txt \ + data/dataformove.txt + files2.sources += data/multifilesforcopy/copydata1.txt \ + data/multifilesforcopy/copydata2.txt \ + data/multifilesforcopy/copydata3.txt + files3.sources += data/multifilesformove/movedata1.txt \ + data/multifilesformove/movedata2.txt \ + data/multifilesformove/movedata3.txt + files1.path = /data/dataforfmoperation/data + files2.path = /data/dataforfmoperation/data/multifilesforcopy + files3.path = /data/dataforfmoperation/data/multifilesformove + DEPLOYMENT += files1 files2 files3 +} \ No newline at end of file diff -r 4167eb56f30d -r 12b82dc0e8db files_plat/filemanager_api/filemanager_api.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/files_plat/filemanager_api/filemanager_api.pro Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,31 @@ +# +# Copyright (c) 2010 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 = subdirs + +SYMBIAN_PLATFORMS = WINSCW ARMV5 + +CONFIG += ordered + +include ( fmfiledialog_api.pri ) + +symbian: { + BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include " + + #exports fmfiledialog header files + headers.sources = $$FMFILEDIALOG_PLAT_HEADERS + for(header, headers.sources):BLD_INF_RULES.prj_exports += "./$$header $$APP_LAYER_PLATFORM_EXPORT_PATH($$basename(header))" +} diff -r 4167eb56f30d -r 12b82dc0e8db files_plat/filemanager_api/fmfiledialog_api.pri --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/files_plat/filemanager_api/fmfiledialog_api.pri Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,19 @@ +# +# 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: +# + +FMFILEDIALOG_PLAT_HEADERS += \ + inc/fmglobal.h \ + inc/fmfiledialog.h \ No newline at end of file diff -r 4167eb56f30d -r 12b82dc0e8db files_plat/filemanager_api/inc/fmfiledialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/files_plat/filemanager_api/inc/fmfiledialog.h Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,126 @@ +/* +* 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 the file dialog +* +*/ + +#ifndef FMFILEDIALOG_H +#define FMFILEDIALOG_H + +#include "fmglobal.h" + + +#include + +class QString; +class QStringList; +class FmFileDialogPrivate; + +class FMFILEDIALOG_EXPORT FmFileDialog : public HbDialog +{ +Q_OBJECT +public: + + enum Option + { + /* + * Open dir as dialog's working directory and prevent user up to parent directory + */ + PreventDirUp = 0x00000001, + /* + * Ignore filter for dir, list all directory. Set this when need only filter filename. + */ + DisplayAllDirs = 0x00000002 + }; + Q_DECLARE_FLAGS(Options, Option) + + /** + * Static function that will return an existing directory selected by the user + * @param parent Parent widget + * @param title Title for dialog + * @param dir Dialog's working directory is set to dir + * @param nameFilters used for filter folder + * @param Options Options + * @return Directory path that user selected. + * user can select cancel to close dialog and empty string will be returned + */ + static QString getExistingDirectory( HbWidget *parent = 0, + const QString &title = QString(), + const QString &dir = QString(), + const QStringList &nameFilters = QStringList(), + Options options = 0 ); + + /** + * Static function that returns an existing file selected by the use + * @param parent Parent widget + * @param title Title for dialog + * @param dir Dialog's working directory is set to dir + * @param nameFilters used for filter file/folder, such as "*.jpg", "*.txt" + * Please set options with "DisplayAllDirs" to avoid folder be filtered when only filter filename. + * @param Options Options + * @return File path that user selected. It is an esisting file. + * user can select cancel to close dialog and empty string will be returned + */ + static QString getOpenFileName( HbWidget *parent = 0, + const QString &title = QString(), + const QString &dir = QString(), + const QStringList &nameFilters = QStringList(), + Options options = 0 ); + /** + * Static function that will return a file name selected by the user. The file does not have to exist. + * @param parent Parent widget + * @param title Title for dialog + * @param dir Dialog's working directory is set to dir + * @param nameFilters used for filter file/folder, such as "*.jpg", "*.txt" + * Please set options with "DisplayAllDirs" to avoid folder be filtered when only filter filename. + * @param Options Options + * @return File path that user selected or inputted in file name line edit. + * This file does not have to exist. + * user can select cancel to close dialog and empty string will be returned + */ + static QString getSaveFileName( HbWidget *parent = 0, + const QString &title = QString(), + const QString &dir = QString(), + const QStringList &nameFilters = QStringList(), + Options options = 0 ); + +private slots: + void dialogClosed(HbAction *action); + +private: + explicit FmFileDialog( QGraphicsItem *parent ); + ~FmFileDialog(); + + bool exec(); + HbAction *primaryAction() const; + void setPrimaryAction( HbAction *action ); + + HbAction *secondaryAction() const; + void setSecondaryAction( HbAction *action ); + + FmFileDialogPrivate *d_ptr; + + Q_DISABLE_COPY( FmFileDialog) + Q_DECLARE_PRIVATE_D(d_ptr,FmFileDialog) + Q_PRIVATE_SLOT(d_func(),void _q_handleUpButton()) + Q_PRIVATE_SLOT(d_func(),void _q_handleTextChanged(QString)) + Q_PRIVATE_SLOT(d_func(),void _q_handlePathChanged(QString)) + Q_PRIVATE_SLOT(d_func(),void _q_handleFileActivated(QString)) +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(FmFileDialog::Options) + +#endif // FMFILEDIALOG_H diff -r 4167eb56f30d -r 12b82dc0e8db files_plat/filemanager_api/inc/fmglobal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/files_plat/filemanager_api/inc/fmglobal.h Thu Sep 30 16:33:59 2010 +0800 @@ -0,0 +1,29 @@ +/* +* 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: +* +*/ + +#ifndef FMGLOBAL_H +#define FMGLOBAL_H + +#include + +#ifdef FMFILEDIALOG_LIBRARY +# define FMFILEDIALOG_EXPORT Q_DECL_EXPORT +#else +# define FMFILEDIALOG_EXPORT Q_DECL_IMPORT +#endif + +#endif diff -r 4167eb56f30d -r 12b82dc0e8db layers.sysdef.xml --- a/layers.sysdef.xml Thu Sep 02 17:00:51 2010 +0800 +++ b/layers.sysdef.xml Thu Sep 30 16:33:59 2010 +0800 @@ -7,6 +7,7 @@ + diff -r 4167eb56f30d -r 12b82dc0e8db package_definition.xml --- a/package_definition.xml Thu Sep 02 17:00:51 2010 +0800 +++ b/package_definition.xml Thu Sep 30 16:33:59 2010 +0800 @@ -1,9 +1,9 @@ - - - + + + @@ -21,6 +21,9 @@ + + +