filemanager/src/filemanager/src/operationservice/fmoperationformat_s60.cpp
changeset 33 328cf6fbe40c
parent 32 39cf9ced4cc4
child 47 12b82dc0e8db
equal deleted inserted replaced
32:39cf9ced4cc4 33:328cf6fbe40c
    24 
    24 
    25 #include <f32file.h>
    25 #include <f32file.h>
    26 #include <e32property.h>
    26 #include <e32property.h>
    27 #include <coreapplicationuisdomainpskeys.h>
    27 #include <coreapplicationuisdomainpskeys.h>
    28 
    28 
    29 FmOperationFormat::FmOperationFormat( QObject *parent, QString mDriverName ) : FmOperationBase( parent, FmOperationService::EOperationTypeFormat ),
    29 /* \fn  void driveSpaceChanged()
       
    30  * This signal is emitted when copy or move is completed, and used to update the drive size.
       
    31  */
       
    32 
       
    33 /*
       
    34  * Constructs a format operation with \a parent
       
    35  * \a mDriverName the drive to be formatted.
       
    36  */
       
    37 FmOperationFormat::FmOperationFormat( QObject *parent, const QString &mDriverName ) : FmOperationBase( parent, FmOperationService::EOperationTypeFormat ),
    30     mDriverName( mDriverName )
    38     mDriverName( mDriverName )
    31 {
    39 {
    32 }
    40     connect( this, SIGNAL( driveSpaceChanged() ),
       
    41             parent, SLOT( on_operation_driveSpaceChanged() ) );
       
    42 }
       
    43 
       
    44 /*
       
    45  * Destructs the operation.
       
    46  */
    33 FmOperationFormat::~FmOperationFormat()
    47 FmOperationFormat::~FmOperationFormat()
    34 {
    48 {
    35 }
    49 }
    36 
    50 
       
    51 /*
       
    52  * Returns the to be formatted drive name
       
    53  */
    37 QString FmOperationFormat::driverName()
    54 QString FmOperationFormat::driverName()
    38 {
    55 {
    39     return mDriverName;
    56     return mDriverName;
    40 }
    57 }
    41 
    58 
    42 int FmOperationFormat::start()
    59 /*
       
    60  * Starts to format.
       
    61  * \a isStopped not used
       
    62  */
       
    63 void FmOperationFormat::start( volatile bool */*isStopped*/ )
    43 { 
    64 { 
    44     QString logString = "FmOperationFormat::start";
    65     QString logString = "FmOperationFormat::start";
    45     FM_LOG( logString );
    66     FM_LOG( logString );
    46     
    67     
    47     emit notifyPreparing( false );
    68     emit notifyPreparing( false );
    48     
    69     
    49     if( mDriverName.isEmpty() ) {
    70     if( mDriverName.isEmpty() ) {
    50         return FmErrWrongParam;
    71         emit notifyError( FmErrWrongParam, QString() );
       
    72         return;
    51     }
    73     }
    52     
    74     
    53     RFormat format;
    75     RFormat format;
    54     
    76     
    55     RFs fs;
    77     RFs fs;
    56     int err = fs.Connect();
    78     int err = fs.Connect();
    57     
    79     
    58     if( err != KErrNone ){
    80     if( err != KErrNone ){
    59         return FmErrTypeFormatFailed;
    81         emit notifyError( FmErrTypeFormatFailed, QString() );
       
    82         return;
    60     }
    83     }
    61 
    84 
    62     TInt drive = 0;
    85     TInt drive = 0;
    63     drive = mDriverName[0].toUpper().toAscii() - 'A' + EDriveA;
    86     drive = mDriverName[0].toUpper().toAscii() - 'A' + EDriveA;
    64 
    87 
   175         
   198         
   176         FmUtils::createDefaultFolders( mDriverName );
   199         FmUtils::createDefaultFolders( mDriverName );
   177     }
   200     }
   178 
   201 
   179     if( err == KErrNone ){
   202     if( err == KErrNone ){
   180         return FmErrNone;
   203         emit notifyFinish();        
   181     }
   204     }
   182     else{
   205     else{
   183         return FmErrTypeFormatFailed;
   206         emit notifyError( FmErrTypeFormatFailed, QString() );
   184     }
   207     }
   185 }
   208     // refresh drive space no care if cancel, error or finished.
       
   209     // as filemanger cannot notify drive space changed
       
   210     // do not refresh path as QFileSystemModel will do auto-refresh
       
   211     emit driveSpaceChanged();    
       
   212     
       
   213 }