|         |      1 /* | 
|         |      2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). | 
|         |      3 * All rights reserved. | 
|         |      4 * This component and the accompanying materials are made available | 
|         |      5 * under the terms of "Eclipse Public License v1.0" | 
|         |      6 * which accompanies this distribution, and is available | 
|         |      7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". | 
|         |      8 * | 
|         |      9 * Initial Contributors: | 
|         |     10 * Nokia Corporation - initial contribution. | 
|         |     11 * | 
|         |     12 * Contributors: | 
|         |     13 * | 
|         |     14 * Description: | 
|         |     15 * | 
|         |     16 */ | 
|         |     17  | 
|         |     18 // INCLUDE FILES | 
|         |     19 #include "FBFileUtils.h" | 
|         |     20 #include "FBFileOps.h" | 
|         |     21 #include "engine.h" | 
|         |     22 #include "FB.hrh" | 
|         |     23 #include <filebrowser.rsg> | 
|         |     24  | 
|         |     25 #include <textresolver.h>  | 
|         |     26 #include <eikprogi.h> | 
|         |     27 #include <f32file.h> | 
|         |     28 #include <eikfutil.h> | 
|         |     29 #include <apparc.h> | 
|         |     30 #include <eikenv.h> | 
|         |     31 #include <bautils.h> | 
|         |     32 #include <gulicon.h> | 
|         |     33 #include <aknconsts.h> | 
|         |     34 #include <babackup.h>  | 
|         |     35 #include <aknmemorycardui.mbg> | 
|         |     36 #include <sendui.h> | 
|         |     37 #include <CMessageData.h> | 
|         |     38 #include <ezgzip.h> | 
|         |     39 #include <e32hal.h> | 
|         |     40 #include <pathinfo.h> | 
|         |     41 #include <apgcli.h> | 
|         |     42 #include <apmstd.h> | 
|         |     43 #include <apgtask.h> | 
|         |     44 #include <apacmdln.h> | 
|         |     45 #include <DocumentHandler.h> | 
|         |     46 #include <msvapi.h> | 
|         |     47 #include <msvids.h> | 
|         |     48 #include <msvstd.h> | 
|         |     49 #include <msvstore.h> | 
|         |     50 #include <mmsvattachmentmanager.h> | 
|         |     51 #include <cmsvattachment.h> | 
|         |     52 #include <hash.h> | 
|         |     53 //#include <sbeclient.h> | 
|         |     54 #include <e32property.h> | 
|         |     55 #if (!defined __SERIES60_30__ && !defined __SERIES60_31__)  | 
|         |     56 #include <driveinfo.h> | 
|         |     57 #endif // !defined __SERIES60_30__ && !defined __SERIES60_31__ | 
|         |     58  | 
|         |     59 #ifndef __SERIES60_30__ | 
|         |     60 //  #include <akniconconfig.h> | 
|         |     61 #endif | 
|         |     62  | 
|         |     63 //_LIT(KGZipExt, ".gz"); | 
|         |     64 _LIT8(KFileNewLine, "\r\n"); | 
|         |     65 const TInt KForcedFormatTimeout = 1000000; | 
|         |     66  | 
|         |     67 // copied from coreapplicationuisdomainpskeys.h | 
|         |     68 const TUid KPSUidCoreApplicationUIs = { 0x101F8767 }; | 
|         |     69 const TUint32 KCoreAppUIsMmcRemovedWithoutEject = 0x00000109; | 
|         |     70 enum TCoreAppUIsMmcRemovedWithoutEject | 
|         |     71     { | 
|         |     72     ECoreAppUIsEjectCommandUsedUninitialized = 0, | 
|         |     73     ECoreAppUIsEjectCommandNotUsed, | 
|         |     74     ECoreAppUIsEjectCommandUsed, | 
|         |     75     ECoreAppUIsEjectCommandUsedToDrive // Low 16-bits contain this value and high 16-bits TDriveNumber to eject | 
|         |     76     }; | 
|         |     77 const TInt KDriveLetterStringLength = 3; // e.g. C:\ | 
|         |     78  | 
|         |     79 // ================= MEMBER FUNCTIONS ======================= | 
|         |     80  | 
|         |     81 CFileBrowserFileUtils* CFileBrowserFileUtils::NewL(CEngine* aEngine) | 
|         |     82 	{ | 
|         |     83 	CFileBrowserFileUtils* self = new(ELeave) CFileBrowserFileUtils(aEngine); | 
|         |     84 	CleanupStack::PushL(self); | 
|         |     85 	self->ConstructL(); | 
|         |     86 	CleanupStack::Pop(); | 
|         |     87 	return self; | 
|         |     88 	} | 
|         |     89  | 
|         |     90 // -------------------------------------------------------------------------------------------- | 
|         |     91  | 
|         |     92 CFileBrowserFileUtils::CFileBrowserFileUtils(CEngine* aEngine) : CActive(EPriorityStandard), iEngine(aEngine) | 
|         |     93 	{ | 
|         |     94 	} | 
|         |     95  | 
|         |     96 // -------------------------------------------------------------------------------------------- | 
|         |     97  | 
|         |     98 void CFileBrowserFileUtils::ConstructL() | 
|         |     99 	{ | 
|         |    100     User::LeaveIfError(iTimer.CreateLocal()); | 
|         |    101     User::LeaveIfError(iFs.Connect()); | 
|         |    102     User::LeaveIfError(iTz.Connect()); | 
|         |    103      | 
|         |    104     iState = EIdle; | 
|         |    105     iListingMode = ENormalEntries; | 
|         |    106  | 
|         |    107     iSortMode = EFileBrowserCmdViewSortByName; | 
|         |    108     iOrderMode = EFileBrowserCmdViewOrderAscending; | 
|         |    109     iCurrentPath = KNullDesC; | 
|         |    110      | 
|         |    111     iFileOps = CFileBrowserFileOps::NewL(iEngine); | 
|         |    112      | 
|         |    113     iDriveEntryList = new(ELeave) CDriveEntryList(8); | 
|         |    114     iFileEntryList = new(ELeave) CFileEntryList(64); | 
|         |    115     iFindFileEntryList = new(ELeave) CFileEntryList(64); | 
|         |    116     iAppIconList = new(ELeave) CAppIconList(16); | 
|         |    117     iClipBoardList = new(ELeave) CFileEntryList(64); | 
|         |    118     iCurrentSelectionList = new(ELeave) CFileEntryList(64); | 
|         |    119  | 
|         |    120     iDocHandler = CDocumentHandler::NewL(); | 
|         |    121     iDocHandler->SetExitObserver(this); | 
|         |    122      | 
|         |    123     // set defaults to the search settings | 
|         |    124     iSearchAttributes.iSearchDir = KNullDesC; | 
|         |    125     iSearchAttributes.iWildCards = _L("*.jpg"); | 
|         |    126     iSearchAttributes.iTextInFile = KNullDesC; | 
|         |    127     iSearchAttributes.iMinSize = 0; | 
|         |    128     iSearchAttributes.iMaxSize = 999999999; | 
|         |    129     iSearchAttributes.iMinDate = TDateTime(1980, EJanuary,   0,0,0,0,0); | 
|         |    130     iSearchAttributes.iMaxDate = TDateTime(2060, EDecember, 30,0,0,0,0); | 
|         |    131     iSearchAttributes.iRecurse = ETrue; | 
|         |    132      | 
|         |    133     // init the command array | 
|         |    134     iCommandArray = new(ELeave) CCommandArray(64); | 
|         |    135          | 
|         |    136     // get current path from settings | 
|         |    137     if (iEngine->Settings().iRememberLastPath) | 
|         |    138         { | 
|         |    139         TFileName settingPath = iEngine->Settings().iLastPath; | 
|         |    140         if (BaflUtils::PathExists(iFs, settingPath)) | 
|         |    141             iCurrentPath = settingPath; | 
|         |    142          | 
|         |    143         if (iCurrentPath != KNullDesC) | 
|         |    144             GetDriveListL(); | 
|         |    145         } | 
|         |    146  | 
|         |    147     CActiveScheduler::Add(this); | 
|         |    148     } | 
|         |    149  | 
|         |    150 // -------------------------------------------------------------------------------------------- | 
|         |    151  | 
|         |    152 CFileBrowserFileUtils::~CFileBrowserFileUtils() | 
|         |    153 	{ | 
|         |    154 	Cancel(); | 
|         |    155 	 | 
|         |    156 	// save current path from settings | 
|         |    157     if (iEngine->Settings().iRememberLastPath) | 
|         |    158         { | 
|         |    159         iEngine->Settings().iLastPath = iCurrentPath; | 
|         |    160         TRAP_IGNORE(iEngine->SaveSettingsL(EFalse)); | 
|         |    161         } | 
|         |    162  | 
|         |    163 //    if (iWaitDialog) | 
|         |    164 //        TRAP_IGNORE(iWaitDialog->ProcessFinishedL());  | 
|         |    165 //      | 
|         |    166 //    if (iProgressDialog) | 
|         |    167 //        TRAP_IGNORE(iProgressDialog->ProcessFinishedL()); | 
|         |    168      | 
|         |    169         delete iFileOps; | 
|         |    170  | 
|         |    171         delete iDocHandler; | 
|         |    172 	 | 
|         |    173 //	if (iOpenFileService) | 
|         |    174 //	    delete iOpenFileService; | 
|         |    175 	 | 
|         |    176         delete iCurrentSelectionList; | 
|         |    177         delete iClipBoardList; | 
|         |    178         delete iAppIconList; | 
|         |    179         delete iFindFileEntryList; | 
|         |    180         delete iFileEntryList; | 
|         |    181         delete iDriveEntryList; | 
|         |    182  | 
|         |    183         delete iFileMan; | 
|         |    184  | 
|         |    185         if (iCommandArray) | 
|         |    186             { | 
|         |    187             ResetCommandArray(); | 
|         |    188             delete iCommandArray; | 
|         |    189             } | 
|         |    190  | 
|         |    191         iTz.Close(); | 
|         |    192         iFs.Close(); | 
|         |    193         iTimer.Close(); | 
|         |    194         } | 
|         |    195  | 
|         |    196 // -------------------------------------------------------------------------------------------- | 
|         |    197  | 
|         |    198 void CFileBrowserFileUtils::DoCancel() | 
|         |    199 	{ | 
|         |    200     iTimer.Cancel(); | 
|         |    201 	} | 
|         |    202  | 
|         |    203 // -------------------------------------------------------------------------------------------- | 
|         |    204  | 
|         |    205 void CFileBrowserFileUtils::StartExecutingCommandsL(const TDesC& /*aLabel*/) | 
|         |    206     { | 
|         |    207     if (iCommandArray->Count() >= 2) | 
|         |    208         { | 
|         |    209         // init progress bar | 
|         |    210 //        iProgressDialog = new(ELeave) CAknProgressDialog((reinterpret_cast<CEikDialog**>(&iProgressDialog)), ETrue); | 
|         |    211 //        iProgressDialog->SetCallback(this); | 
|         |    212 //        iProgressDialog->PrepareLC(R_GENERAL_PROGRESS_NOTE); | 
|         |    213 //        iProgressDialog->SetCurrentLabelL( EAknCtNote, aLabel ); | 
|         |    214 //        iProgressInfo = iProgressDialog->GetProgressInfoL(); | 
|         |    215 //        iProgressInfo->SetFinalValue( CommandArrayCount() ); | 
|         |    216 //        iProgressDialog->RunLD(); | 
|         |    217 //        iProgressDialog->MakeVisible( ETrue );         | 
|         |    218         } | 
|         |    219     else if (iCommandArray->Count() >= 1) | 
|         |    220         { | 
|         |    221         // init wait dialog | 
|         |    222 //        iWaitDialog = new(ELeave) CAknWaitDialog((reinterpret_cast<CEikDialog**>(&iWaitDialog)), ETrue); | 
|         |    223 //        iWaitDialog->SetCallback(this); | 
|         |    224 //        iWaitDialog->PrepareLC(R_GENERAL_WAIT_NOTE); | 
|         |    225 //        iWaitDialog->SetTextL( aLabel ); | 
|         |    226 //        iWaitDialog->RunLD(); | 
|         |    227         } | 
|         |    228     else | 
|         |    229         { | 
|         |    230         // no commands, just do nothing | 
|         |    231         return; | 
|         |    232         } | 
|         |    233  | 
|         |    234  | 
|         |    235     // start with the first operation | 
|         |    236     iCurrentEntry = 0; | 
|         |    237     iSucceededOperations = 0; | 
|         |    238     iFailedOperations = 0; | 
|         |    239  | 
|         |    240     // starts executing commands | 
|         |    241     ExecuteCommand(); | 
|         |    242     } | 
|         |    243      | 
|         |    244 // -------------------------------------------------------------------------------------------- | 
|         |    245  | 
|         |    246 void CFileBrowserFileUtils::ExecuteCommand() | 
|         |    247     { | 
|         |    248     // make sure the engine isn't active, should never happen | 
|         |    249     __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("FileUtils:IsActive"), 333)); | 
|         |    250  | 
|         |    251     // execute a command after a very short delay (25ms) | 
|         |    252     iTimer.After(iStatus, 25); | 
|         |    253     SetActive(); | 
|         |    254     } | 
|         |    255  | 
|         |    256 // -------------------------------------------------------------------------------------------- | 
|         |    257      | 
|         |    258 void CFileBrowserFileUtils::RunL() | 
|         |    259     { | 
|         |    260     TInt err(KErrNone); | 
|         |    261     TInt currentCommand = iCommandArray->At(iCurrentEntry).iCommandId; | 
|         |    262  | 
|         |    263     // execute a command from the queue | 
|         |    264     switch(currentCommand) | 
|         |    265         { | 
|         |    266         case EFileBrowserFileOpCommandAttribs: | 
|         |    267             { | 
|         |    268             CCommandParamsAttribs* params = static_cast<CCommandParamsAttribs*>(iCommandArray->At(iCurrentEntry).iParameters); | 
|         |    269             err = iFileOps->Attribs(params->iSourceEntry, params->iSetMask, params->iClearMask, params->iTime, params->iSwitch); | 
|         |    270             } | 
|         |    271             break; | 
|         |    272              | 
|         |    273         case EFileBrowserFileOpCommandCopy: | 
|         |    274             { | 
|         |    275             CCommandParamsCopyOrMove* params = static_cast<CCommandParamsCopyOrMove*>(iCommandArray->At(iCurrentEntry).iParameters); | 
|         |    276             err = iFileOps->Copy(params->iSourceEntry, params->iTargetPath, params->iSwitch); | 
|         |    277             } | 
|         |    278             break; | 
|         |    279              | 
|         |    280         case EFileBrowserFileOpCommandMove: | 
|         |    281             { | 
|         |    282             CCommandParamsCopyOrMove* params = static_cast<CCommandParamsCopyOrMove*>(iCommandArray->At(iCurrentEntry).iParameters); | 
|         |    283             err = iFileOps->Copy(params->iSourceEntry, params->iTargetPath, params->iSwitch, ETrue); | 
|         |    284             } | 
|         |    285             break; | 
|         |    286                  | 
|         |    287         case EFileBrowserFileOpCommandRename: | 
|         |    288             { | 
|         |    289             CCommandParamsRename* params = static_cast<CCommandParamsRename*>(iCommandArray->At(iCurrentEntry).iParameters); | 
|         |    290             err = iFileOps->Rename(params->iSourceEntry, params->iTargetPath, params->iSwitch); | 
|         |    291             } | 
|         |    292             break; | 
|         |    293  | 
|         |    294         case EFileBrowserFileOpCommandDelete: | 
|         |    295             { | 
|         |    296             CCommandParamsDelete* params = static_cast<CCommandParamsDelete*>(iCommandArray->At(iCurrentEntry).iParameters); | 
|         |    297             err = iFileOps->Delete(params->iSourceEntry, params->iSwitch); | 
|         |    298             } | 
|         |    299             break; | 
|         |    300  | 
|         |    301         case EFileBrowserFileOpCommandDriveSnapShot: | 
|         |    302             { | 
|         |    303             CCommandParamsDriveSnapShot* params = static_cast<CCommandParamsDriveSnapShot*>(iCommandArray->At(iCurrentEntry).iParameters); | 
|         |    304             err = iFileOps->DriveSnapShot(params->iSourceDriveLetter, params->iTargetDriveLetter); | 
|         |    305             } | 
|         |    306             break; | 
|         |    307                                                  | 
|         |    308         default: | 
|         |    309             User::Panic (_L("Unknown command"), 400); | 
|         |    310             break; | 
|         |    311         } | 
|         |    312  | 
|         |    313      | 
|         |    314     if (err == KErrNone) | 
|         |    315         { | 
|         |    316         iSucceededOperations++; | 
|         |    317         } | 
|         |    318     else if ( err != KErrCancel ) | 
|         |    319         { | 
|         |    320         iFailedOperations++; | 
|         |    321         } | 
|         |    322          | 
|         |    323     iLastError = err;             | 
|         |    324  | 
|         |    325     // check for more commands in queue | 
|         |    326     TRAP_IGNORE( CheckForMoreCommandsL() ); | 
|         |    327     } | 
|         |    328  | 
|         |    329 // --------------------------------------------------------------------------- | 
|         |    330  | 
|         |    331 TInt CFileBrowserFileUtils::RunError(TInt aError) | 
|         |    332     { | 
|         |    333     _LIT(KMessage, "Command error %d"); | 
|         |    334     TBuf<128> noteMsg; | 
|         |    335     noteMsg.Format(KMessage, aError); | 
|         |    336              | 
|         |    337     iEngine->EikonEnv()->InfoMsg(noteMsg); | 
|         |    338      | 
|         |    339     TRAP_IGNORE( CheckForMoreCommandsL() ); | 
|         |    340      | 
|         |    341     return KErrNone; | 
|         |    342     } | 
|         |    343  | 
|         |    344 // --------------------------------------------------------------------------- | 
|         |    345  | 
|         |    346 void CFileBrowserFileUtils::CheckForMoreCommandsL() | 
|         |    347     { | 
|         |    348     //LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL"); | 
|         |    349      | 
|         |    350     // update the progress bar | 
|         |    351     if (iProgressInfo) | 
|         |    352         iProgressInfo->IncrementAndDraw(1); | 
|         |    353  | 
|         |    354 	// check if we have more commands to be executed | 
|         |    355 	if (iCurrentEntry >= CommandArrayCount() - 1) | 
|         |    356 		{ | 
|         |    357         //LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL all done"); | 
|         |    358  | 
|         |    359         // all done, free resources | 
|         |    360         ResetCommandArray(); | 
|         |    361          | 
|         |    362         // deactive secure backup if it was activated by a file command | 
|         |    363         iFileOps->DeActivateSecureBackUpViaFileOp(); | 
|         |    364  | 
|         |    365         // dismiss any wait/progress dialogs         | 
|         |    366 //        if (iWaitDialog) | 
|         |    367 //            { | 
|         |    368 //            TRAP_IGNORE(iWaitDialog->ProcessFinishedL());  | 
|         |    369 //            iWaitDialog = NULL; | 
|         |    370 //            } | 
|         |    371 //        if (iProgressDialog) | 
|         |    372 //            { | 
|         |    373 //            TRAP_IGNORE(iProgressDialog->ProcessFinishedL()); | 
|         |    374 //            iProgressDialog = NULL; | 
|         |    375 //            } | 
|         |    376  | 
|         |    377  | 
|         |    378         // show result note | 
|         |    379         if ( iSucceededOperations == 0 && iFailedOperations == 0 ) | 
|         |    380             { | 
|         |    381             // single operation cancelled -> show nothing | 
|         |    382             } | 
|         |    383         else if (iSucceededOperations == 1 && iFailedOperations == 0)     | 
|         |    384             { | 
|         |    385 //            _LIT(KMessage, "Operation succeeded"); | 
|         |    386 //            iEngine->FileBrowserUI()->ShowConfirmationNote(KMessage); | 
|         |    387             } | 
|         |    388         else if (iSucceededOperations > 0 && iFailedOperations == 0)     | 
|         |    389             { | 
|         |    390 //            _LIT(KMessage, "%d operations succeeded"); | 
|         |    391 //            TBuf<128> noteMsg; | 
|         |    392 //            noteMsg.Format(KMessage, iSucceededOperations); | 
|         |    393 //            iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg); | 
|         |    394             } | 
|         |    395         else if (iSucceededOperations == 0 && iFailedOperations > 1)     | 
|         |    396             { | 
|         |    397             _LIT(KMessage, "%d operations failed"); | 
|         |    398             TBuf<128> noteMsg; | 
|         |    399             noteMsg.Format(KMessage, iFailedOperations); | 
|         |    400  | 
|         |    401             iEngine->FileBrowserUI()->ShowErrorNote(noteMsg); | 
|         |    402             } | 
|         |    403         else if (iSucceededOperations > 0 && iFailedOperations > 0)     | 
|         |    404             { | 
|         |    405             _LIT(KMessage, "%d operations succeeded, %d failed"); | 
|         |    406             TBuf<128> noteMsg; | 
|         |    407             noteMsg.Format(KMessage, iSucceededOperations, iFailedOperations); | 
|         |    408  | 
|         |    409             iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); | 
|         |    410             } | 
|         |    411         else     | 
|         |    412             { | 
|         |    413             CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); | 
|         |    414  | 
|         |    415             iEngine->FileBrowserUI()->ShowErrorNote( | 
|         |    416                     textResolver->ResolveErrorString(iLastError, CTextResolver::ECtxNoCtxNoSeparator) ); | 
|         |    417  | 
|         |    418             CleanupStack::PopAndDestroy();  //textResolver | 
|         |    419             } | 
|         |    420  | 
|         |    421         RefreshViewL(); | 
|         |    422  | 
|         |    423 		} | 
|         |    424 	else | 
|         |    425 		{ | 
|         |    426 		// maintain requests | 
|         |    427 		iCurrentEntry++; | 
|         |    428  | 
|         |    429         //LOGSTRING2("Creator: CCreatorEngine::CheckForMoreCommandsL iCurrentEntry=%d", iCurrentEntry); | 
|         |    430  | 
|         |    431         ExecuteCommand(); | 
|         |    432 		} | 
|         |    433     }     | 
|         |    434 // -------------------------------------------------------------------------------------------- | 
|         |    435  | 
|         |    436 // This callback function is called when cancel button of the progress bar was pressed | 
|         |    437 void CFileBrowserFileUtils::DialogDismissedL(TInt aButtonId) | 
|         |    438     { | 
|         |    439 //    iProgressDialog = NULL; | 
|         |    440 //    iProgressInfo = NULL; | 
|         |    441 //    iWaitDialog = NULL; | 
|         |    442      | 
|         |    443     // check if cancel button was pressed | 
|         |    444     if (aButtonId == EAknSoftkeyCancel) | 
|         |    445         { | 
|         |    446         // cancel the active object, command executer  | 
|         |    447         Cancel(); | 
|         |    448          | 
|         |    449         iFileOps->CancelOp(); | 
|         |    450          | 
|         |    451         ResetCommandArray(); | 
|         |    452  | 
|         |    453         iEngine->FileBrowserUI()->ShowInformationNote(_L("Cancelled"), _L("")); | 
|         |    454         } | 
|         |    455     } | 
|         |    456      | 
|         |    457 // -------------------------------------------------------------------------------------------- | 
|         |    458  | 
|         |    459 void CFileBrowserFileUtils::AppendToCommandArrayL(TInt aCommand, CCommandParamsBase* aParameters) | 
|         |    460     { | 
|         |    461     if (iCommandArray) | 
|         |    462         iCommandArray->AppendL( TCommand(aCommand, aParameters) ); | 
|         |    463     else | 
|         |    464         User::Leave(KErrNotReady); | 
|         |    465     } | 
|         |    466  | 
|         |    467 // -------------------------------------------------------------------------------------------- | 
|         |    468  | 
|         |    469 TInt CFileBrowserFileUtils::CommandArrayCount() const | 
|         |    470     { | 
|         |    471     TInt count(0); | 
|         |    472      | 
|         |    473     if (iCommandArray) | 
|         |    474         count = iCommandArray->Count(); | 
|         |    475      | 
|         |    476     return count; | 
|         |    477     } | 
|         |    478  | 
|         |    479 // -------------------------------------------------------------------------------------------- | 
|         |    480  | 
|         |    481 void CFileBrowserFileUtils::ResetCommandArray() | 
|         |    482     { | 
|         |    483     // delete params first | 
|         |    484     for (TInt i=0; i<CommandArrayCount(); i++) | 
|         |    485         { | 
|         |    486         if ( iCommandArray->At(i).iParameters ) | 
|         |    487             { | 
|         |    488             delete iCommandArray->At(i).iParameters; | 
|         |    489             iCommandArray->At(i).iParameters = NULL; | 
|         |    490             } | 
|         |    491         } | 
|         |    492  | 
|         |    493     // reset the entries | 
|         |    494     iCommandArray->Reset(); | 
|         |    495     } | 
|         |    496                      | 
|         |    497 // -------------------------------------------------------------------------------------------- | 
|         |    498  | 
|         |    499 void CFileBrowserFileUtils::HandleSettingsChangeL() | 
|         |    500     { | 
|         |    501 	// TODO | 
|         |    502  | 
|         |    503 //    if (iEngine->FileListContainer()) | 
|         |    504 //        { | 
|         |    505 //        iEngine->FileListContainer()->SetScreenLayoutL(iEngine->Settings().iDisplayMode); | 
|         |    506 //        iEngine->FileListContainer()->CreateListBoxL(iEngine->Settings().iFileViewMode); | 
|         |    507         //iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); | 
|         |    508         RefreshViewL(); | 
|         |    509 //        } | 
|         |    510     } | 
|         |    511  | 
|         |    512 // -------------------------------------------------------------------------------------------- | 
|         |    513  | 
|         |    514 void CFileBrowserFileUtils::SetSortModeL(TInt aSortMode) | 
|         |    515     { | 
|         |    516     iSortMode = aSortMode; | 
|         |    517     RefreshViewL(); | 
|         |    518     } | 
|         |    519      | 
|         |    520 // -------------------------------------------------------------------------------------------- | 
|         |    521  | 
|         |    522 void CFileBrowserFileUtils::SetOrderModeL(TInt aOrderMode) | 
|         |    523     { | 
|         |    524     iOrderMode = aOrderMode; | 
|         |    525     RefreshViewL(); | 
|         |    526     } | 
|         |    527  | 
|         |    528 // -------------------------------------------------------------------------------------------- | 
|         |    529  | 
|         |    530 TKeyResponse CFileBrowserFileUtils::HandleOfferKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) | 
|         |    531     { | 
|         |    532 	// TODO | 
|         |    533 	/* | 
|         |    534     if(aType != EEventKey) | 
|         |    535         return EKeyWasNotConsumed; | 
|         |    536      | 
|         |    537     TBool shiftKeyPressed = (aKeyEvent.iModifiers & EModifierShift) || | 
|         |    538                             (aKeyEvent.iModifiers & EModifierLeftShift) || | 
|         |    539                             (aKeyEvent.iModifiers & EModifierRightShift); | 
|         |    540     TBool controlKeyPressed = (aKeyEvent.iModifiers & EModifierCtrl) ||  | 
|         |    541                               (aKeyEvent.iModifiers & EModifierRightCtrl);  | 
|         |    542      | 
|         |    543     // handle left arrow key press | 
|         |    544     if (aKeyEvent.iCode == EKeyLeftArrow) | 
|         |    545         { | 
|         |    546         MoveUpOneLevelL(); | 
|         |    547         return EKeyWasConsumed; | 
|         |    548         } | 
|         |    549      | 
|         |    550     // handle right arrow key press | 
|         |    551     else if (aKeyEvent.iCode == EKeyRightArrow) | 
|         |    552         { | 
|         |    553         if (IsDriveListViewActive() && iDriveEntryList->Count() > 0) | 
|         |    554             { | 
|         |    555             MoveDownToDirectoryL(); | 
|         |    556             return EKeyWasConsumed; | 
|         |    557             } | 
|         |    558         else if (iFileEntryList->Count() > 0) | 
|         |    559             { | 
|         |    560             MoveDownToDirectoryL(); | 
|         |    561             return EKeyWasConsumed; | 
|         |    562             }         | 
|         |    563         }     | 
|         |    564  | 
|         |    565     // skip OK/Enter keys when shift or ctrl is pressed because those are needed by the listbox | 
|         |    566     else if ((aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) && (shiftKeyPressed || controlKeyPressed)) | 
|         |    567         { | 
|         |    568         return EKeyWasNotConsumed; | 
|         |    569         } | 
|         |    570      | 
|         |    571     // handle OK/Enter keys | 
|         |    572     else if (aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) | 
|         |    573         { | 
|         |    574         if (IsDriveListViewActive() && iDriveEntryList->Count() > 0) | 
|         |    575             { | 
|         |    576             MoveDownToDirectoryL(); | 
|         |    577             return EKeyWasConsumed; | 
|         |    578             } | 
|         |    579         else if (iFileEntryList->Count() > 0) | 
|         |    580             { | 
|         |    581             TFileEntry fileEntry = iFileEntryList->At(iEngine->FileListContainer()->CurrentListBoxItemIndex()); | 
|         |    582              | 
|         |    583             if (fileEntry.iEntry.IsDir()) | 
|         |    584                 MoveDownToDirectoryL(); | 
|         |    585             else | 
|         |    586                 OpenCommonFileActionQueryL(); | 
|         |    587              | 
|         |    588             return EKeyWasConsumed; | 
|         |    589             }  | 
|         |    590         } | 
|         |    591      | 
|         |    592     // handle Delete/Backspace keys | 
|         |    593     else if (!iEngine->FileListContainer()->SearchField() && (aKeyEvent.iCode == EKeyBackspace || aKeyEvent.iCode == EKeyDelete) && | 
|         |    594              !iEngine->FileUtils()->IsCurrentDriveReadOnly() && !iEngine->FileUtils()->IsDriveListViewActive()) | 
|         |    595         { | 
|         |    596         DeleteL(); | 
|         |    597         return EKeyWasConsumed; | 
|         |    598         } | 
|         |    599     */                       | 
|         |    600     return EKeyWasNotConsumed; | 
|         |    601     }         | 
|         |    602 // -------------------------------------------------------------------------------------------- | 
|         |    603  | 
|         |    604 void CFileBrowserFileUtils::RefreshViewL() | 
|         |    605     { | 
|         |    606 	// TODO | 
|         |    607  | 
|         |    608 //    if (iEngine->FileListContainer()) | 
|         |    609 //        { | 
|         |    610         // update navi pane text         | 
|         |    611 //        if (iListingMode == ENormalEntries) | 
|         |    612 //            iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); | 
|         |    613 //        else if (iListingMode == ESearchResults) | 
|         |    614 //            iEngine->FileListContainer()->SetNaviPaneTextL(_L("Search results")); | 
|         |    615 //        else if (iListingMode == EOpenFiles) | 
|         |    616 //            iEngine->FileListContainer()->SetNaviPaneTextL(_L("Open files")); | 
|         |    617 //        else if (iListingMode == EMsgAttachmentsInbox) | 
|         |    618 //            iEngine->FileListContainer()->SetNaviPaneTextL(_L("Attachments in Inbox")); | 
|         |    619 //        else if (iListingMode == EMsgAttachmentsDrafts) | 
|         |    620 //            iEngine->FileListContainer()->SetNaviPaneTextL(_L("Attachments in Drafts")); | 
|         |    621 //        else if (iListingMode == EMsgAttachmentsSentItems) | 
|         |    622 //            iEngine->FileListContainer()->SetNaviPaneTextL(_L("Attachments in Sent Items")); | 
|         |    623 //        else if (iListingMode == EMsgAttachmentsOutbox) | 
|         |    624 //            iEngine->FileListContainer()->SetNaviPaneTextL(_L("Attachments in Outbox")); | 
|         |    625 // | 
|         |    626 //        // create a list box if it doesn't already exist | 
|         |    627 //        if (!iEngine->FileListContainer()->ListBox()) | 
|         |    628 //            iEngine->FileListContainer()->CreateListBoxL(iEngine->Settings().iFileViewMode); | 
|         |    629 // | 
|         |    630 //        // clear selections if any | 
|         |    631 //        iEngine->FileListContainer()->ListBox()->ClearSelection(); | 
|         |    632 // | 
|         |    633 //        // make sure that the search field is disabled | 
|         |    634 //        iEngine->FileListContainer()->DisableSearchFieldL(); | 
|         |    635          | 
|         |    636         // read directory listing | 
|         |    637         GenerateDirectoryDataL(); | 
|         |    638          | 
|         |    639 //        // set an icon array | 
|         |    640 //        iEngine->FileListContainer()->SetListBoxIconArrayL(GenerateIconArrayL()); | 
|         |    641 // | 
|         |    642 //        // set text items | 
|         |    643 //        iEngine->FileListContainer()->SetListBoxTextArrayL(GenerateItemTextArrayL()); | 
|         |    644  | 
|         |    645 //        // make sure that the current item index is not out of array | 
|         |    646 //        if (iEngine->FileListContainer()->CurrentListBoxItemIndex() == -1 && // -1 is a hardcoded value meaning that no current item index | 
|         |    647 //                iEngine->FileListContainer()->ListBox()->Model()->NumberOfItems() > 0) | 
|         |    648 //            iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex( iEngine->FileListContainer()->ListBox()->Model()->NumberOfItems() - 1 ); | 
|         |    649 // | 
|         |    650 //        } | 
|         |    651      | 
|         |    652 //        iEngine->FileListContainer()->UpdateToolbar(); | 
|         |    653  | 
|         |    654         } | 
|         |    655      | 
|         |    656 // -------------------------------------------------------------------------------------------- | 
|         |    657  | 
|         |    658 /*CAknIconArray* CFileBrowserFileUtils::GenerateIconArrayL(TBool aGenerateNewBasicIconArray) | 
|         |    659     { | 
|         |    660 	// TODO | 
|         |    661 	 | 
|         |    662     CAknIconArray* iconArray = NULL; | 
|         |    663  | 
|         |    664     if (aGenerateNewBasicIconArray) | 
|         |    665         { | 
|         |    666         iconArray = new(ELeave) CAknIconArray(16);     | 
|         |    667         } | 
|         |    668     else | 
|         |    669         { | 
|         |    670         if (iEngine->FileListContainer()) | 
|         |    671             iconArray = iEngine->FileListContainer()->ListBoxIconArrayL(); | 
|         |    672          | 
|         |    673         if (!iconArray)     | 
|         |    674             iconArray = new(ELeave) CAknIconArray(16); | 
|         |    675         } | 
|         |    676  | 
|         |    677          | 
|         |    678     CleanupStack::PushL(iconArray); | 
|         |    679      | 
|         |    680     // generate basic items if not already existing | 
|         |    681     if (iconArray->Count() < EFixedIconListLength) | 
|         |    682         { | 
|         |    683         // reset arrays | 
|         |    684         iconArray->Reset(); | 
|         |    685         iAppIconList->Reset(); | 
|         |    686          | 
|         |    687         // get default control color | 
|         |    688         TRgb defaultColor; | 
|         |    689         defaultColor = iEngine->EikonEnv()->Color(EColorControlText); | 
|         |    690          | 
|         |    691         // create a color icon of the marking indicator | 
|         |    692         CFbsBitmap* markBitmap = NULL; | 
|         |    693         CFbsBitmap* markBitmapMask = NULL; | 
|         |    694  | 
|         |    695         AknsUtils::CreateColorIconL(AknsUtils::SkinInstance(), | 
|         |    696                 KAknsIIDQgnIndiMarkedAdd, | 
|         |    697                 KAknsIIDQsnIconColors, | 
|         |    698                 EAknsCIQsnIconColorsCG13, | 
|         |    699                 markBitmap, | 
|         |    700                 markBitmapMask, | 
|         |    701                 AknIconUtils::AvkonIconFileName(), | 
|         |    702                 EMbmAvkonQgn_indi_marked_add, | 
|         |    703                 EMbmAvkonQgn_indi_marked_add_mask, | 
|         |    704                 defaultColor | 
|         |    705                 ); | 
|         |    706           | 
|         |    707         // 0 marking indicator | 
|         |    708         CGulIcon* markIcon = CGulIcon::NewL(markBitmap, markBitmapMask); | 
|         |    709         iconArray->AppendL(markIcon);                        | 
|         |    710  | 
|         |    711         // 1 empty | 
|         |    712         AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), | 
|         |    713                                   EMbmAvkonQgn_prop_empty, EMbmAvkonQgn_prop_empty_mask, KAknsIIDQgnPropEmpty); | 
|         |    714         // 2 phone memory | 
|         |    715         AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), | 
|         |    716                                   EMbmAvkonQgn_prop_phone_memc, EMbmAvkonQgn_prop_phone_memc_mask, KAknsIIDQgnPropPhoneMemc); | 
|         |    717         // 3 memory card | 
|         |    718         AppendGulIconToIconArrayL(iconArray, KMemoryCardUiBitmapFile, | 
|         |    719                                   EMbmAknmemorycarduiQgn_prop_mmc_memc, EMbmAknmemorycarduiQgn_prop_mmc_memc_mask, KAknsIIDQgnPropMmcMemc); | 
|         |    720         // 4 memory card disabled | 
|         |    721         AppendGulIconToIconArrayL(iconArray, KMemoryCardUiBitmapFile, | 
|         |    722                                   EMbmAknmemorycarduiQgn_prop_mmc_non, EMbmAknmemorycarduiQgn_prop_mmc_non_mask, KAknsIIDQgnPropMmcNon); | 
|         |    723         // 5 folder | 
|         |    724         AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), | 
|         |    725                                   EMbmAvkonQgn_prop_folder_small, EMbmAvkonQgn_prop_folder_small_mask, KAknsIIDQgnPropFolderSmall); | 
|         |    726         // 6 folder with subfolders | 
|         |    727         AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), | 
|         |    728                                   EMbmAvkonQgn_prop_folder_sub_small, EMbmAvkonQgn_prop_folder_sub_small_mask, KAknsIIDQgnPropFolderSubSmall); | 
|         |    729         // 7 current folder | 
|         |    730         AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), | 
|         |    731                                   EMbmAvkonQgn_prop_folder_current, EMbmAvkonQgn_prop_folder_current_mask, KAknsIIDQgnPropFolderCurrent); | 
|         |    732         } | 
|         |    733  | 
|         |    734     // append custom icons if not in drive list view and setting is enabled | 
|         |    735     if (!aGenerateNewBasicIconArray && !IsDriveListViewActive() && iEngine->Settings().iShowAssociatedIcons) | 
|         |    736         { | 
|         |    737         // init id counter | 
|         |    738         TInt idCounter(EFixedIconListLength + iAppIconList->Count()); | 
|         |    739          | 
|         |    740         // loop all items in the file list | 
|         |    741         for (TInt i=0; i<iFileEntryList->Count(); i++) | 
|         |    742             { | 
|         |    743             TFileEntry& fileEntry = iFileEntryList->At(i); | 
|         |    744  | 
|         |    745             // just check for normal files             | 
|         |    746             if (!fileEntry.iEntry.IsDir())      | 
|         |    747                 { | 
|         |    748                 TUid appUid = GetAppUid(fileEntry); | 
|         |    749                 TInt iconId = AppIconIdForUid(appUid); | 
|         |    750                  | 
|         |    751                 if (appUid != KNullUid && iconId == KErrNotFound) | 
|         |    752                     { | 
|         |    753                     // icon not found from the icon array, generate it | 
|         |    754                     CFbsBitmap* bitmap = NULL; | 
|         |    755                     CFbsBitmap* mask = NULL; | 
|         |    756                     CGulIcon* appIcon = NULL; | 
|         |    757          | 
|         |    758                     TRAPD(err,  | 
|         |    759                         AknsUtils::CreateAppIconLC(AknsUtils::SkinInstance(), appUid, EAknsAppIconTypeList, bitmap, mask); | 
|         |    760                         appIcon = CGulIcon::NewL(bitmap, mask); | 
|         |    761                         CleanupStack::Pop(2); //bitmap, mask | 
|         |    762                         ); | 
|         |    763                           | 
|         |    764                     if (err == KErrNone) | 
|         |    765                         { | 
|         |    766                         TAppIcon appIconEntry; | 
|         |    767                         appIconEntry.iId = idCounter; | 
|         |    768                         appIconEntry.iUid = appUid; | 
|         |    769                          | 
|         |    770                         appIcon->SetBitmapsOwnedExternally(EFalse); | 
|         |    771                         iconArray->AppendL(appIcon); | 
|         |    772                         iAppIconList->AppendL(appIconEntry); | 
|         |    773  | 
|         |    774                         fileEntry.iIconId = idCounter; | 
|         |    775                                                  | 
|         |    776                         idCounter++;       | 
|         |    777                         } | 
|         |    778                     else | 
|         |    779                         { | 
|         |    780                         delete bitmap; | 
|         |    781                         delete mask; | 
|         |    782 		 | 
|         |    783                         TAppIcon appIconEntry; | 
|         |    784                         appIconEntry.iId = EFixedIconEmpty; | 
|         |    785                         appIconEntry.iUid = appUid; | 
|         |    786                          | 
|         |    787                         iAppIconList->AppendL(appIconEntry); | 
|         |    788                         } | 
|         |    789                     } | 
|         |    790  | 
|         |    791                 else if (appUid != KNullUid && iconId >= 0) | 
|         |    792                     { | 
|         |    793                     // we already have already generated an icon for this uid, use it | 
|         |    794                     fileEntry.iIconId = iconId; | 
|         |    795                     } | 
|         |    796                 } | 
|         |    797             } | 
|         |    798         } | 
|         |    799  | 
|         |    800     CleanupStack::Pop(); //iconArray | 
|         |    801 	return iconArray; | 
|         |    802      | 
|         |    803 	} | 
|         |    804 */ | 
|         |    805 // -------------------------------------------------------------------------------------------- | 
|         |    806  | 
|         |    807 //void CFileBrowserFileUtils::AppendGulIconToIconArrayL(CAknIconArray* aIconArray, const TDesC& aIconFile, TInt aIconId, TInt aMaskId, const TAknsItemID aAknsItemId) | 
|         |    808 //    { | 
|         |    809 //    CGulIcon* icon = AknsUtils::CreateGulIconL( | 
|         |    810 //            AknsUtils::SkinInstance(), | 
|         |    811 //            aAknsItemId, | 
|         |    812 //            aIconFile, | 
|         |    813 //            aIconId, | 
|         |    814 //            aMaskId); | 
|         |    815 //    CleanupStack::PushL(icon); | 
|         |    816 //	 | 
|         |    817 //	icon->SetBitmapsOwnedExternally(EFalse); | 
|         |    818 //	aIconArray->AppendL(icon); | 
|         |    819 //	 | 
|         |    820 //	CleanupStack::Pop(); //icon           | 
|         |    821 //    } | 
|         |    822  | 
|         |    823 // -------------------------------------------------------------------------------------------- | 
|         |    824  | 
|         |    825 TInt CFileBrowserFileUtils::AppIconIdForUid(TUid aUid) | 
|         |    826     { | 
|         |    827     TInt result(KErrNotFound); | 
|         |    828      | 
|         |    829     for (TInt i=0; i<iAppIconList->Count(); i++) | 
|         |    830         { | 
|         |    831         if (iAppIconList->At(i).iUid == aUid) | 
|         |    832             { | 
|         |    833             result = iAppIconList->At(i).iId; | 
|         |    834             break; | 
|         |    835             } | 
|         |    836         } | 
|         |    837      | 
|         |    838     return result; | 
|         |    839     } | 
|         |    840  | 
|         |    841 // -------------------------------------------------------------------------------------------- | 
|         |    842  | 
|         |    843 TUid CFileBrowserFileUtils::GetAppUid(TFileEntry aFileEntry) | 
|         |    844     { | 
|         |    845     TFileName fullPath; | 
|         |    846     fullPath.Copy(aFileEntry.iPath); | 
|         |    847     fullPath.Append(aFileEntry.iEntry.iName); | 
|         |    848      | 
|         |    849     TParse parsedName; | 
|         |    850     parsedName.Set(fullPath, NULL, NULL); | 
|         |    851  | 
|         |    852     // this will boost performance in \sys\bin folder     | 
|         |    853     if (parsedName.Ext().CompareF(_L(".dll")) == 0 || parsedName.Ext().CompareF(_L(".rsc")) == 0) | 
|         |    854         return KNullUid; | 
|         |    855      | 
|         |    856     TInt err1(KErrNone), err2(KErrNone); | 
|         |    857     TUid appUid; | 
|         |    858     TDataType dataType; | 
|         |    859     TBool isProgram; | 
|         |    860      | 
|         |    861     err1 = iEngine->LsSession().AppForDocument(fullPath, appUid, dataType); | 
|         |    862     err2 = iEngine->LsSession().IsProgram(fullPath, isProgram); | 
|         |    863          | 
|         |    864     if (err1 == KErrNone && err2 == KErrNone) | 
|         |    865         { | 
|         |    866         if (isProgram) | 
|         |    867             { | 
|         |    868             // get the real app Uid from the app list | 
|         |    869             TApaAppInfo appInfo; | 
|         |    870             iEngine->LsSession().GetAllApps(); | 
|         |    871  | 
|         |    872             while (iEngine->LsSession().GetNextApp(appInfo) == KErrNone) | 
|         |    873                 { | 
|         |    874                 if (fullPath.CompareF(appInfo.iFullName) == 0) | 
|         |    875                     return appInfo.iUid; | 
|         |    876                 } | 
|         |    877             } | 
|         |    878         else | 
|         |    879             { | 
|         |    880             // return the app Uid associated for it | 
|         |    881             return appUid; | 
|         |    882             }             | 
|         |    883         } | 
|         |    884  | 
|         |    885     return KNullUid; | 
|         |    886     } | 
|         |    887  | 
|         |    888  | 
|         |    889 CFileEntryList* CFileBrowserFileUtils::FileEntries() const | 
|         |    890 { | 
|         |    891     return iFileEntryList; | 
|         |    892 } | 
|         |    893 CDriveEntryList* CFileBrowserFileUtils::DriveEntries() const | 
|         |    894 { | 
|         |    895     return iDriveEntryList; | 
|         |    896 } | 
|         |    897  | 
|         |    898 //// -------------------------------------------------------------------------------------------- | 
|         |    899 // | 
|         |    900 //CDesCArray* CFileBrowserFileUtils::GenerateItemTextArrayL() | 
|         |    901 //    { | 
|         |    902 //    iTextArray = new(ELeave) CDesCArrayFlat(64); | 
|         |    903 ////    CleanupStack::PushL(textArray); | 
|         |    904 // | 
|         |    905 //    if (IsDriveListViewActive()) | 
|         |    906 //        { | 
|         |    907 //        _LIT(KSimpleDriveEntry, "%d\t%c: <%S>\t\t"); | 
|         |    908 //        _LIT(KExtendedDriveEntry, "%d\t%c: <%S>\t%LD / %LD kB\t"); | 
|         |    909 // | 
|         |    910 //        for (TInt i=0; i<iDriveEntryList->Count(); i++) | 
|         |    911 //            { | 
|         |    912 //            TFileName textEntry; | 
|         |    913 //            TDriveEntry driveEntry = iDriveEntryList->At(i); | 
|         |    914 // | 
|         |    915 //            if (iEngine->Settings().iFileViewMode == EFileViewModeSimple) | 
|         |    916 //                { | 
|         |    917 //                textEntry.Format(KSimpleDriveEntry, driveEntry.iIconId, TUint(driveEntry.iLetter), &driveEntry.iMediaTypeDesc); | 
|         |    918 //                } | 
|         |    919 //            else if (iEngine->Settings().iFileViewMode == EFileViewModeExtended) | 
|         |    920 //                { | 
|         |    921 //                textEntry.Format(KExtendedDriveEntry, driveEntry.iIconId, TUint(driveEntry.iLetter), &driveEntry.iMediaTypeDesc, driveEntry.iVolumeInfo.iFree/1024, driveEntry.iVolumeInfo.iSize/1024); | 
|         |    922 //                } | 
|         |    923 // | 
|         |    924 //            iTextArray->AppendL(textEntry); | 
|         |    925 //            } | 
|         |    926 //        } | 
|         |    927 // | 
|         |    928 //    else | 
|         |    929 //        { | 
|         |    930 //        _LIT(KSimpleFileEntry, "%d\t%S\t\t"); | 
|         |    931 //        _LIT(KExtendedFileEntry, "%d\t%S\t%S\t"); | 
|         |    932 // | 
|         |    933 //        for (TInt i=0; i<iFileEntryList->Count(); i++) | 
|         |    934 //            { | 
|         |    935 //            TFileName textEntry; | 
|         |    936 //            TFileEntry fileEntry = iFileEntryList->At(i); | 
|         |    937 // | 
|         |    938 //            // format text line entries | 
|         |    939 //            if (iEngine->Settings().iFileViewMode == EFileViewModeSimple) | 
|         |    940 //                { | 
|         |    941 //                textEntry.Format(KSimpleFileEntry, fileEntry.iIconId, &fileEntry.iEntry.iName); | 
|         |    942 //                } | 
|         |    943 //            else if (iEngine->Settings().iFileViewMode == EFileViewModeExtended) | 
|         |    944 //                { | 
|         |    945 //                TBuf<128> extraData; | 
|         |    946 // | 
|         |    947 //                // append entry date | 
|         |    948 //                TTime entryModified = fileEntry.iEntry.iModified; | 
|         |    949 //                if ( iTz.ConvertToLocalTime( entryModified ) == KErrNone ) | 
|         |    950 //                    { | 
|         |    951 //                    entryModified = fileEntry.iEntry.iModified; | 
|         |    952 //                    } | 
|         |    953 // | 
|         |    954 //                _LIT(KCurrentDate,"%D%M%*Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B"); | 
|         |    955 //                entryModified.FormatL(extraData, KCurrentDate); | 
|         |    956 // | 
|         |    957 //                // for a directory append number of entries and for a file the file size | 
|         |    958 //                if (fileEntry.iEntry.IsDir() && fileEntry.iDirEntries >= 0) | 
|         |    959 //                    { | 
|         |    960 //                    extraData.Append(_L(" - ")); | 
|         |    961 //                    extraData.AppendNum(fileEntry.iDirEntries); | 
|         |    962 // | 
|         |    963 //                    if (fileEntry.iDirEntries == 1) | 
|         |    964 //                        extraData.Append(_L(" entry")); | 
|         |    965 //                    else | 
|         |    966 //                        extraData.Append(_L(" entries")); | 
|         |    967 //                    } | 
|         |    968 // | 
|         |    969 //                // normal file entry | 
|         |    970 //                else if (!fileEntry.iEntry.IsDir()) | 
|         |    971 //                    { | 
|         |    972 //                    extraData.Append(_L(" - ")); | 
|         |    973 // | 
|         |    974 //                    if (fileEntry.iEntry.iSize < 1024) | 
|         |    975 //                        { | 
|         |    976 //                        extraData.AppendNum(fileEntry.iEntry.iSize); | 
|         |    977 //                        extraData.Append(_L(" B")); | 
|         |    978 //                        } | 
|         |    979 //                    else if (fileEntry.iEntry.iSize < 1024*1024) | 
|         |    980 //                        { | 
|         |    981 //                        TReal sizeKB = (TReal)fileEntry.iEntry.iSize / 1024; | 
|         |    982 //                        extraData.AppendNum(sizeKB, TRealFormat(KDefaultRealWidth, 1)); | 
|         |    983 //                        extraData.Append(_L(" kB")); | 
|         |    984 //                        } | 
|         |    985 //                    else | 
|         |    986 //                        { | 
|         |    987 //                        TReal sizeMB = (TReal)fileEntry.iEntry.iSize / (1024*1024); | 
|         |    988 //                        extraData.AppendNum(sizeMB, TRealFormat(KDefaultRealWidth, 1)); | 
|         |    989 //                        extraData.Append(_L(" MB")); | 
|         |    990 //                        } | 
|         |    991 //                    } | 
|         |    992 // | 
|         |    993 //                // append attribute flags if any | 
|         |    994 //                TBuf<4> atts; | 
|         |    995 //                if (fileEntry.iEntry.IsArchive()) | 
|         |    996 //                    atts.Append(_L("A")); | 
|         |    997 //                if (fileEntry.iEntry.IsHidden()) | 
|         |    998 //                    atts.Append(_L("H")); | 
|         |    999 //                if (fileEntry.iEntry.IsReadOnly()) | 
|         |   1000 //                    atts.Append(_L("R")); | 
|         |   1001 //                if (fileEntry.iEntry.IsSystem()) | 
|         |   1002 //                    atts.Append(_L("S")); | 
|         |   1003 // | 
|         |   1004 //                if (atts.Length() > 0) | 
|         |   1005 //                    { | 
|         |   1006 //                    extraData.Append(_L(" - [")); | 
|         |   1007 //                    extraData.Append(atts); | 
|         |   1008 //                    extraData.Append(_L("]")); | 
|         |   1009 //                    } | 
|         |   1010 // | 
|         |   1011 //                // format | 
|         |   1012 //                textEntry.Format(KExtendedFileEntry, fileEntry.iIconId, &fileEntry.iEntry.iName, &extraData); | 
|         |   1013 //                } | 
|         |   1014 // | 
|         |   1015 //            iTextArray->AppendL(textEntry); | 
|         |   1016 //            } | 
|         |   1017 //        } | 
|         |   1018 // | 
|         |   1019 ////    CleanupStack::Pop(); //textArray | 
|         |   1020 //    return iTextArray; | 
|         |   1021 //    } | 
|         |   1022      | 
|         |   1023 // -------------------------------------------------------------------------------------------- | 
|         |   1024  | 
|         |   1025 void CFileBrowserFileUtils::GenerateDirectoryDataL() | 
|         |   1026     { | 
|         |   1027     if (iListingMode == ENormalEntries) | 
|         |   1028         { | 
|         |   1029         if (IsDriveListViewActive()) | 
|         |   1030             GetDriveListL();     | 
|         |   1031         else | 
|         |   1032             GetDirectoryListingL();         | 
|         |   1033         } | 
|         |   1034     } | 
|         |   1035  | 
|         |   1036 // -------------------------------------------------------------------------------------------- | 
|         |   1037  | 
|         |   1038 void CFileBrowserFileUtils::GetDriveListL() | 
|         |   1039     { | 
|         |   1040     TDriveList driveList; | 
|         |   1041      | 
|         |   1042     // get drive listing depending of the support for network drives | 
|         |   1043     if (iEngine->Settings().iSupportNetworkDrives) | 
|         |   1044         { | 
|         |   1045         #ifndef __SERIES60_30__ | 
|         |   1046             #ifndef __SERIES60_31__ | 
|         |   1047                 User::LeaveIfError(iFs.DriveList(driveList, KDriveAttAll)); | 
|         |   1048             #endif | 
|         |   1049         #else     | 
|         |   1050             User::LeaveIfError(iFs.DriveList(driveList)); | 
|         |   1051         #endif         | 
|         |   1052         } | 
|         |   1053     else | 
|         |   1054         { | 
|         |   1055         User::LeaveIfError(iFs.DriveList(driveList)); | 
|         |   1056         } | 
|         |   1057      | 
|         |   1058     iDriveEntryList->Reset();         | 
|         |   1059      | 
|         |   1060     for (TInt i=0; i<KMaxDrives; i++) | 
|         |   1061         { | 
|         |   1062         if (driveList[i]) | 
|         |   1063             { | 
|         |   1064             TDriveEntry driveEntry; | 
|         |   1065              | 
|         |   1066             // set default icon | 
|         |   1067             driveEntry.iIconId = EFixedIconPhoneMemory; | 
|         |   1068  | 
|         |   1069             // get drive letter and number  | 
|         |   1070             driveEntry.iLetter = 'A' + i; | 
|         |   1071             iFs.CharToDrive(driveEntry.iLetter, driveEntry.iNumber); | 
|         |   1072              | 
|         |   1073             // get volume info and check errors | 
|         |   1074             if (iFs.Volume(driveEntry.iVolumeInfo, driveEntry.iNumber) == KErrNone) | 
|         |   1075                 { | 
|         |   1076                 // set media type descriptor | 
|         |   1077                 TInt mediaType = driveEntry.iVolumeInfo.iDrive.iType; | 
|         |   1078                 TBool extMountable( EFalse ); | 
|         |   1079                  | 
|         |   1080                 if (mediaType == EMediaNotPresent) | 
|         |   1081                     driveEntry.iMediaTypeDesc = _L("Not present"); | 
|         |   1082                 else if (mediaType ==EMediaUnknown ) | 
|         |   1083                     driveEntry.iMediaTypeDesc = _L("Unknown"); | 
|         |   1084                 else if (mediaType ==EMediaFloppy ) | 
|         |   1085                     driveEntry.iMediaTypeDesc = _L("Floppy"); | 
|         |   1086                 else if (mediaType == EMediaHardDisk) | 
|         |   1087                     driveEntry.iMediaTypeDesc = _L("Mass storage"); | 
|         |   1088                 else if (mediaType == EMediaCdRom) | 
|         |   1089                     driveEntry.iMediaTypeDesc = _L("CD-ROM"); | 
|         |   1090                 else if (mediaType == EMediaRam) | 
|         |   1091                     driveEntry.iMediaTypeDesc = _L("RAM"); | 
|         |   1092                 else if (mediaType == EMediaFlash) | 
|         |   1093                     driveEntry.iMediaTypeDesc = _L("Flash"); | 
|         |   1094                 else if (mediaType == EMediaRom) | 
|         |   1095                     driveEntry.iMediaTypeDesc = _L("ROM"); | 
|         |   1096                 else if (mediaType == EMediaRemote) | 
|         |   1097                     driveEntry.iMediaTypeDesc = _L("Remote"); | 
|         |   1098                 else if (mediaType == EMediaNANDFlash) | 
|         |   1099                     driveEntry.iMediaTypeDesc = _L("NAND flash"); | 
|         |   1100                  | 
|         |   1101                 // get real size of the ROM drive | 
|         |   1102                 if (mediaType == EMediaRom) | 
|         |   1103                     { | 
|         |   1104                     TMemoryInfoV1Buf ramMemory; | 
|         |   1105                     UserHal::MemoryInfo(ramMemory); | 
|         |   1106                     driveEntry.iVolumeInfo.iSize = ramMemory().iTotalRomInBytes; | 
|         |   1107                     } | 
|         |   1108                  | 
|         |   1109                 // set attribute descripitions | 
|         |   1110                 if (driveEntry.iVolumeInfo.iDrive.iBattery == EBatNotSupported) | 
|         |   1111                     driveEntry.iAttributesDesc.Append(_L("Battery not supported")); | 
|         |   1112                 else if (driveEntry.iVolumeInfo.iDrive.iBattery == EBatGood) | 
|         |   1113                     driveEntry.iAttributesDesc.Append(_L("Battery good")); | 
|         |   1114                 else if (driveEntry.iVolumeInfo.iDrive.iBattery == EBatLow) | 
|         |   1115                     driveEntry.iAttributesDesc.Append(_L("Battery low")); | 
|         |   1116                 else | 
|         |   1117                     driveEntry.iAttributesDesc.Append(_L("Battery state unknown")); | 
|         |   1118                  | 
|         |   1119                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttLocal) | 
|         |   1120                     driveEntry.iAttributesDesc.Append(_L(" + Local")); | 
|         |   1121                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRom) | 
|         |   1122                     driveEntry.iAttributesDesc.Append(_L(" + ROM")); | 
|         |   1123                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRedirected) | 
|         |   1124                     driveEntry.iAttributesDesc.Append(_L("+ Redirected")); | 
|         |   1125                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttSubsted) | 
|         |   1126                     driveEntry.iAttributesDesc.Append(_L(" + Substed")); | 
|         |   1127                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttInternal) | 
|         |   1128                     driveEntry.iAttributesDesc.Append(_L(" + Internal")); | 
|         |   1129                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRemovable) | 
|         |   1130                     { | 
|         |   1131                     driveEntry.iAttributesDesc.Append(_L(" + Removable")); | 
|         |   1132 #if (!defined __SERIES60_30__ && !defined __SERIES60_31__) | 
|         |   1133                     TUint drvStatus( 0 ); | 
|         |   1134                     if ( !DriveInfo::GetDriveStatus( iFs, driveEntry.iNumber, drvStatus ) && | 
|         |   1135                          drvStatus & DriveInfo::EDriveExternallyMountable && | 
|         |   1136                          drvStatus & DriveInfo::EDriveInternal ) | 
|         |   1137                         { | 
|         |   1138                         extMountable = ETrue; | 
|         |   1139                         // iMediaTypeDesc already set as "Mass storage"  | 
|         |   1140                         } | 
|         |   1141                     else | 
|         |   1142                         { | 
|         |   1143                         driveEntry.iMediaTypeDesc = _L("Memory card"); | 
|         |   1144                         } | 
|         |   1145 #else | 
|         |   1146                     driveEntry.iMediaTypeDesc = _L("Memory card"); | 
|         |   1147 #endif | 
|         |   1148                     } | 
|         |   1149                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRemote) | 
|         |   1150                     driveEntry.iAttributesDesc.Append(_L(" + Remote")); | 
|         |   1151                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttTransaction) | 
|         |   1152                     driveEntry.iAttributesDesc.Append(_L(" + Transaction")); | 
|         |   1153                                  | 
|         |   1154                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttVariableSize) | 
|         |   1155                     driveEntry.iAttributesDesc.Append(_L(" + Variable size")); | 
|         |   1156                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttDualDensity) | 
|         |   1157                     driveEntry.iAttributesDesc.Append(_L(" + Dual density")); | 
|         |   1158                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttFormattable) | 
|         |   1159                     driveEntry.iAttributesDesc.Append(_L(" + Formattable")); | 
|         |   1160                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttWriteProtected) | 
|         |   1161                     driveEntry.iAttributesDesc.Append(_L(" + Write protected")); | 
|         |   1162                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLockable) | 
|         |   1163                     driveEntry.iAttributesDesc.Append(_L(" + Lockable")); | 
|         |   1164                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLocked) | 
|         |   1165                     driveEntry.iAttributesDesc.Append(_L(" + Locked")); | 
|         |   1166                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttHasPassword) | 
|         |   1167                     driveEntry.iAttributesDesc.Append(_L(" + Has password")); | 
|         |   1168                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttReadWhileWrite) | 
|         |   1169                     driveEntry.iAttributesDesc.Append(_L(" + Read while write")); | 
|         |   1170                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttDeleteNotify) | 
|         |   1171                     driveEntry.iAttributesDesc.Append(_L(" + Supports DeleteNotify")); | 
|         |   1172                  | 
|         |   1173                  | 
|         |   1174                 // mark a removable media with memory card icon | 
|         |   1175                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRemovable && !extMountable) | 
|         |   1176                     { | 
|         |   1177                     if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLocked || driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAbsent) | 
|         |   1178                         {                 | 
|         |   1179                         driveEntry.iIconId = EFixedIconMemoryCardDisabled; | 
|         |   1180                         }                  | 
|         |   1181                     else | 
|         |   1182                         {                 | 
|         |   1183                         driveEntry.iIconId = EFixedIconMemoryCard; | 
|         |   1184                         }  | 
|         |   1185                     } | 
|         |   1186                 }    | 
|         |   1187              | 
|         |   1188             // if this fails, likely it's a memory card which is not present | 
|         |   1189             else | 
|         |   1190                 { | 
|         |   1191                 TVolumeInfo volumeInfo; | 
|         |   1192                 volumeInfo.iSize = 0; | 
|         |   1193                 volumeInfo.iFree = 0; | 
|         |   1194                 volumeInfo.iDrive.iDriveAtt = KDriveAttRemovable; | 
|         |   1195                 volumeInfo.iDrive.iMediaAtt = KMediaAttWriteProtected; | 
|         |   1196                 driveEntry.iVolumeInfo = volumeInfo; | 
|         |   1197  | 
|         |   1198                 driveEntry.iMediaTypeDesc = _L("Not ready"); | 
|         |   1199                 driveEntry.iIconId = EFixedIconMemoryCardDisabled; | 
|         |   1200                 } | 
|         |   1201              | 
|         |   1202             if ( iPrevFolderName != KNullDesC && iPrevFolderName[0] == driveEntry.iLetter ) | 
|         |   1203                 { | 
|         |   1204                 iPrevFolderIndex = iDriveEntryList->Count(); | 
|         |   1205                 } | 
|         |   1206              | 
|         |   1207             iDriveEntryList->AppendL(driveEntry); | 
|         |   1208             } | 
|         |   1209         } | 
|         |   1210      | 
|         |   1211     } | 
|         |   1212  | 
|         |   1213 // -------------------------------------------------------------------------------------------- | 
|         |   1214  | 
|         |   1215 void CFileBrowserFileUtils::GetDirectoryListingL() | 
|         |   1216     { | 
|         |   1217     iFileEntryList->Reset(); | 
|         |   1218  | 
|         |   1219     TInt sortMode(ESortByName); | 
|         |   1220     if (iSortMode == EFileBrowserCmdViewSortByExtension)     | 
|         |   1221         sortMode = ESortByExt;  | 
|         |   1222     else if (iSortMode == EFileBrowserCmdViewSortBySize)     | 
|         |   1223         sortMode = ESortBySize;  | 
|         |   1224     else if (iSortMode == EFileBrowserCmdViewSortByDate)     | 
|         |   1225         sortMode = ESortByDate;  | 
|         |   1226      | 
|         |   1227     TInt orderMode(EAscending); | 
|         |   1228     if (iOrderMode == EFileBrowserCmdViewOrderDescending)     | 
|         |   1229         orderMode = EDescending;  | 
|         |   1230      | 
|         |   1231     CDir* dir = NULL; | 
|         |   1232     if (iFs.GetDir(iCurrentPath, KEntryAttMatchMask, sortMode | orderMode | EDirsFirst, dir) == KErrNone) | 
|         |   1233         { | 
|         |   1234         CleanupStack::PushL(dir); | 
|         |   1235          | 
|         |   1236         for (TInt i=0; i<dir->Count(); i++) | 
|         |   1237             { | 
|         |   1238             TFileEntry fileEntry; | 
|         |   1239             fileEntry.iPath = iCurrentPath; | 
|         |   1240             fileEntry.iEntry = (*dir)[i]; | 
|         |   1241             fileEntry.iDirEntries = KErrNotFound; | 
|         |   1242             fileEntry.iIconId = EFixedIconEmpty; | 
|         |   1243              | 
|         |   1244             if ( iPrevFolderName != KNullDesC && iPrevFolderName == fileEntry.iEntry.iName ) | 
|         |   1245                 { | 
|         |   1246                 iPrevFolderIndex = i; | 
|         |   1247                 } | 
|         |   1248              | 
|         |   1249             // check for directory entries | 
|         |   1250             if (fileEntry.iEntry.IsDir()) | 
|         |   1251                 { | 
|         |   1252                 fileEntry.iIconId = EFixedIconFolder; | 
|         |   1253  | 
|         |   1254                 TFileName subPath = fileEntry.iPath; | 
|         |   1255                 subPath.Append(fileEntry.iEntry.iName); | 
|         |   1256                 subPath.Append(_L("\\")); | 
|         |   1257                                  | 
|         |   1258                 // get number of entries in this directory if extended info about sub directories enabled | 
|         |   1259                 if (iEngine->Settings().iShowSubDirectoryInfo && iEngine->Settings().iFileViewMode == EFileViewModeExtended) | 
|         |   1260                     { | 
|         |   1261                     CDir* subDir = NULL; | 
|         |   1262                     if (iFs.GetDir(subPath, KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone) | 
|         |   1263                         { | 
|         |   1264                         fileEntry.iDirEntries = subDir->Count(); | 
|         |   1265                         delete subDir;     | 
|         |   1266                         } | 
|         |   1267                     } | 
|         |   1268                  | 
|         |   1269                 // apply subfolder icon for known directories (speed improvement) | 
|         |   1270                 if (subPath[0]=='Z' && (subPath.CompareF(_L("Z:\\data\\"))==0 || subPath.CompareF(_L("Z:\\Nokia\\"))==0 | 
|         |   1271                     || subPath.Compare(_L("Z:\\private\\"))==0 || subPath.Compare(_L("Z:\\resource\\"))==0 | 
|         |   1272                     || subPath.Compare(_L("Z:\\sys\\"))==0 || subPath.Compare(_L("Z:\\system\\"))==0)) | 
|         |   1273                     { | 
|         |   1274                     fileEntry.iIconId = EFixedIconFolderSub; | 
|         |   1275                     } | 
|         |   1276                 else if (subPath[0]=='Z' && (subPath.CompareF(_L("Z:\\sys\\bin\\"))==0)) | 
|         |   1277                     { | 
|         |   1278                     // normal folder icon for these ones | 
|         |   1279                     fileEntry.iIconId = EFixedIconFolder; | 
|         |   1280                     } | 
|         |   1281                 else | 
|         |   1282                     { | 
|         |   1283                     // check if this folder has subdirectories | 
|         |   1284                     CDir* subDir = NULL; | 
|         |   1285                     if (iFs.GetDir(subPath, KEntryAttDir|KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone) | 
|         |   1286                         { | 
|         |   1287                         for (TInt j=0; j<subDir->Count(); j++) | 
|         |   1288                             { | 
|         |   1289                             TEntry entry = (*subDir)[j]; | 
|         |   1290  | 
|         |   1291                             if (entry.IsDir()) | 
|         |   1292                                 { | 
|         |   1293                                 fileEntry.iIconId = EFixedIconFolderSub; | 
|         |   1294                                 break;     | 
|         |   1295                                 } | 
|         |   1296                             } | 
|         |   1297  | 
|         |   1298                         delete subDir;     | 
|         |   1299                         }                     | 
|         |   1300                     } | 
|         |   1301                 } | 
|         |   1302  | 
|         |   1303             iFileEntryList->AppendL(fileEntry); | 
|         |   1304             } | 
|         |   1305          | 
|         |   1306         CleanupStack::PopAndDestroy(); //dir     | 
|         |   1307         } | 
|         |   1308     } | 
|         |   1309  | 
|         |   1310 // -------------------------------------------------------------------------------------------- | 
|         |   1311  | 
|         |   1312 void CFileBrowserFileUtils::MoveUpOneLevelL() | 
|         |   1313     { | 
|         |   1314     iPrevFolderIndex = KErrNotFound; | 
|         |   1315     iPrevFolderName.Zero(); | 
|         |   1316      | 
|         |   1317     // change back to normal mode or move up | 
|         |   1318     if (iListingMode != ENormalEntries) | 
|         |   1319         { | 
|         |   1320         iListingMode = ENormalEntries; | 
|         |   1321         } | 
|         |   1322     else | 
|         |   1323         { | 
|         |   1324         // do nothing if displaying drive list view | 
|         |   1325         if (IsDriveListViewActive()) | 
|         |   1326             return; | 
|         |   1327          | 
|         |   1328         if (iCurrentPath.Length() <= KDriveLetterStringLength) | 
|         |   1329             { | 
|         |   1330             if ( iCurrentPath.Length() > 0 ) | 
|         |   1331                 { | 
|         |   1332                 iPrevFolderName.Append( iCurrentPath[0] ); | 
|         |   1333                 } | 
|         |   1334             // move to drive list view if the current path is already short enough | 
|         |   1335             iCurrentPath = KNullDesC; | 
|         |   1336             } | 
|         |   1337         else | 
|         |   1338             { | 
|         |   1339             // move one directory up | 
|         |   1340             TInt marker(iCurrentPath.Length()); | 
|         |   1341              | 
|         |   1342             // find second last dir marker | 
|         |   1343             for (TInt i=iCurrentPath.Length()-2; i>=0; i--) | 
|         |   1344                 { | 
|         |   1345                 if (iCurrentPath[i] == '\\') | 
|         |   1346                     { | 
|         |   1347                     marker = i; | 
|         |   1348                     break; | 
|         |   1349                     } | 
|         |   1350                      | 
|         |   1351                 } | 
|         |   1352              | 
|         |   1353             // update iPrevDir with the directory name that we just left  | 
|         |   1354             iPrevFolderName.Copy( iCurrentPath.RightTPtr( iCurrentPath.Length() -  marker - 1 ) ); | 
|         |   1355             iPrevFolderName.Delete( iPrevFolderName.Length() -1, 2 ); // remove extra '\\' | 
|         |   1356              | 
|         |   1357             iCurrentPath = iCurrentPath.LeftTPtr(marker+1); | 
|         |   1358             }     | 
|         |   1359         } | 
|         |   1360  | 
|         |   1361 //    if (iEngine->FileListContainer()) | 
|         |   1362 //        { | 
|         |   1363         //iEngine->FileListContainer()->DisableSearchFieldL(); | 
|         |   1364         //iEngine->FileListContainer()->ListBox()->ClearSelection(); | 
|         |   1365         //iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex(0); | 
|         |   1366         //iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); | 
|         |   1367 //        } | 
|         |   1368      | 
|         |   1369     // update view | 
|         |   1370     RefreshViewL(); | 
|         |   1371      | 
|         |   1372     if ( iEngine->Settings().iRememberFolderSelection && | 
|         |   1373          iEngine->FileListContainer() && iPrevFolderIndex > KErrNotFound ) | 
|         |   1374         { | 
|         |   1375          | 
|         |   1376 //        TInt visibleItems = iEngine->FileListContainer()->ListBox()->Rect().Height() / | 
|         |   1377 //                            iEngine->FileListContainer()->ListBox()->ItemHeight() | 
|         |   1378 //                            - 1; // for the title row | 
|         |   1379 // | 
|         |   1380 //        // By default, the selected item would be the last visible item on the listbox. | 
|         |   1381 //        // We want the selected item be displayed at the middle of the listbox, so we | 
|         |   1382 //        // select one of the successor items first to scroll down a bit | 
|         |   1383 //        iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex( | 
|         |   1384 //            Min( iEngine->FileListContainer()->ListBox()->Model()->ItemTextArray()->MdcaCount() -1, | 
|         |   1385 //                 iPrevFolderIndex + visibleItems / 2 ) ); | 
|         |   1386 // | 
|         |   1387 //        // ...and after that we select the the correct item. | 
|         |   1388 //        iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex( iPrevFolderIndex ); | 
|         |   1389          | 
|         |   1390         // update view | 
|         |   1391         RefreshViewL(); | 
|         |   1392         } | 
|         |   1393     } | 
|         |   1394  | 
|         |   1395 // -------------------------------------------------------------------------------------------- | 
|         |   1396  | 
|         |   1397 void CFileBrowserFileUtils::MoveDownToDirectoryL(TInt aIndex) | 
|         |   1398     { | 
|         |   1399  | 
|         |   1400     // change back to normal mode | 
|         |   1401     if (iListingMode != ENormalEntries) | 
|         |   1402         { | 
|         |   1403         iListingMode = ENormalEntries; | 
|         |   1404         } | 
|         |   1405      | 
|         |   1406     if (aIndex >= 0) | 
|         |   1407         { | 
|         |   1408         TBool needsRefresh(EFalse); | 
|         |   1409  | 
|         |   1410         if (IsDriveListViewActive()) | 
|         |   1411             { | 
|         |   1412             // currently in a drive list view, move to root of selected drive | 
|         |   1413             if (iDriveEntryList->Count() > aIndex) | 
|         |   1414                 { | 
|         |   1415                 TDriveEntry driveEntry = iDriveEntryList->At(aIndex); | 
|         |   1416                  | 
|         |   1417                 iCurrentPath.Append(driveEntry.iLetter);     | 
|         |   1418                 iCurrentPath.Append(_L(":\\")); | 
|         |   1419                  | 
|         |   1420                 needsRefresh = ETrue;     | 
|         |   1421                 } | 
|         |   1422             } | 
|         |   1423         else | 
|         |   1424             { | 
|         |   1425             // otherwise just append the new directory | 
|         |   1426             if (iFileEntryList->Count() > aIndex) | 
|         |   1427                 { | 
|         |   1428                 TFileEntry fileEntry = iFileEntryList->At(aIndex); | 
|         |   1429                  | 
|         |   1430                 if (fileEntry.iEntry.IsDir()) | 
|         |   1431                     { | 
|         |   1432                     iCurrentPath.Copy(fileEntry.iPath); | 
|         |   1433                     iCurrentPath.Append(fileEntry.iEntry.iName); | 
|         |   1434                     iCurrentPath.Append(_L("\\")); | 
|         |   1435  | 
|         |   1436                     needsRefresh = ETrue;     | 
|         |   1437                     } | 
|         |   1438                 } | 
|         |   1439             } | 
|         |   1440  | 
|         |   1441         if (needsRefresh /*&& iEngine->FileListContainer()*/) | 
|         |   1442             { | 
|         |   1443             //iEngine->FileListContainer()->DisableSearchFieldL(); | 
|         |   1444             //iEngine->FileListContainer()->ListBox()->ClearSelection(); | 
|         |   1445             //iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex(0); | 
|         |   1446             //iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); | 
|         |   1447  | 
|         |   1448             // update view | 
|         |   1449             RefreshViewL(); | 
|         |   1450             } | 
|         |   1451         } | 
|         |   1452     } | 
|         |   1453      | 
|         |   1454 // -------------------------------------------------------------------------------------------- | 
|         |   1455  | 
|         |   1456 TBool CFileBrowserFileUtils::IsCurrentDriveReadOnly() | 
|         |   1457     { | 
|         |   1458     if (iListingMode !=ENormalEntries || iCurrentPath.Length() < 2) | 
|         |   1459         return EFalse; | 
|         |   1460     else | 
|         |   1461         { | 
|         |   1462         for (TInt i=0; i<iDriveEntryList->Count(); i++) | 
|         |   1463             { | 
|         |   1464             TDriveEntry driveEntry = iDriveEntryList->At(i); | 
|         |   1465              | 
|         |   1466             if (driveEntry.iLetter == iCurrentPath[0]) | 
|         |   1467                 { | 
|         |   1468                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt == KMediaAttWriteProtected || driveEntry.iVolumeInfo.iDrive.iMediaAtt == KMediaAttLocked || driveEntry.iVolumeInfo.iDrive.iDriveAtt == KDriveAbsent) | 
|         |   1469                     return ETrue;     | 
|         |   1470                 else | 
|         |   1471                     return EFalse; | 
|         |   1472                 } | 
|         |   1473             } | 
|         |   1474         } | 
|         |   1475  | 
|         |   1476     return EFalse; | 
|         |   1477     } | 
|         |   1478  | 
|         |   1479 // -------------------------------------------------------------------------------------------- | 
|         |   1480  | 
|         |   1481 TBool CFileBrowserFileUtils::IsItemDirectory(TInt aCurrentItemIndex) | 
|         |   1482     { | 
|         |   1483     if (aCurrentItemIndex < 0) | 
|         |   1484         { | 
|         |   1485         return EFalse; | 
|         |   1486         } | 
|         |   1487     else | 
|         |   1488         { | 
|         |   1489         if (iFileEntryList->Count() > aCurrentItemIndex) | 
|         |   1490             { | 
|         |   1491             TFileEntry fileEntry = iFileEntryList->At(aCurrentItemIndex) ; | 
|         |   1492             return fileEntry.iEntry.IsDir(); | 
|         |   1493             } | 
|         |   1494         else | 
|         |   1495             { | 
|         |   1496             return EFalse; | 
|         |   1497             } | 
|         |   1498         } | 
|         |   1499     } | 
|         |   1500  | 
|         |   1501 // -------------------------------------------------------------------------------------------- | 
|         |   1502  | 
|         |   1503 TInt CFileBrowserFileUtils::SetSelectedItemsOrCurrentItemL(const CArrayFix<TInt>* selectionIndexes, | 
|         |   1504                                                            CFileEntryList* aFileEntryList) | 
|         |   1505     { | 
|         |   1506     aFileEntryList->Reset(); | 
|         |   1507  | 
|         |   1508     // by default use selected items | 
|         |   1509     if (selectionIndexes && selectionIndexes->Count() > 0) | 
|         |   1510         { | 
|         |   1511         TInt ref(0); | 
|         |   1512         TKeyArrayFix key(0, ECmpTUint16); | 
|         |   1513         TInt index(0); | 
|         |   1514  | 
|         |   1515         for (TInt i=0; i<iFileEntryList->Count(); i++) | 
|         |   1516             { | 
|         |   1517             ref = i; | 
|         |   1518  | 
|         |   1519             if (selectionIndexes->Find(ref, key, index) == 0) | 
|         |   1520                 { | 
|         |   1521                 aFileEntryList->AppendL(iFileEntryList->At(i)); | 
|         |   1522                 } | 
|         |   1523             } | 
|         |   1524         } | 
|         |   1525     return aFileEntryList->Count(); | 
|         |   1526     } | 
|         |   1527  | 
|         |   1528 // -------------------------------------------------------------------------------------------- | 
|         |   1529 //TInt CFileBrowserFileUtils::GetSelectedItemsOrCurrentItemL(CFileEntryList* aFileEntryList) | 
|         |   1530 //    { | 
|         |   1531 //    aFileEntryList->Reset(); | 
|         |   1532 // | 
|         |   1533 //    const CArrayFix<TInt>* selectionIndexes = iEngine->GetSelectedIndices(); | 
|         |   1534 //    // by default use selected items | 
|         |   1535 //    if (selectionIndexes && selectionIndexes->Count() > 0) | 
|         |   1536 //        { | 
|         |   1537 //        TInt ref(0); | 
|         |   1538 //        TKeyArrayFix key(0, ECmpTUint16); | 
|         |   1539 //        TInt index(0); | 
|         |   1540 // | 
|         |   1541 //        for (TInt i=0; i<iFileEntryList->Count(); i++) | 
|         |   1542 //            { | 
|         |   1543 //            ref = i; | 
|         |   1544 // | 
|         |   1545 //            if (selectionIndexes->Find(ref, key, index) == 0) | 
|         |   1546 //                { | 
|         |   1547 //                aFileEntryList->AppendL(iFileEntryList->At(i)); | 
|         |   1548 //                } | 
|         |   1549 //            } | 
|         |   1550 //        } | 
|         |   1551 // | 
|         |   1552 //    // or if none selected, use the current item index | 
|         |   1553 //    else | 
|         |   1554 //        { | 
|         |   1555 ////        TInt currentItemIndex = iEngine->FileListContainer()->CurrentListBoxItemIndex(); | 
|         |   1556 //        TInt currentItemIndex = iEngine->QueryCurrentItemIndex(); | 
|         |   1557 //        if (iFileEntryList->Count() > currentItemIndex && currentItemIndex >= 0) | 
|         |   1558 //            { | 
|         |   1559 //            aFileEntryList->AppendL(iFileEntryList->At(currentItemIndex)); | 
|         |   1560 //            } | 
|         |   1561 //        } | 
|         |   1562 // | 
|         |   1563 //    return aFileEntryList->Count(); | 
|         |   1564 //    } | 
|         |   1565  | 
|         |   1566 // -------------------------------------------------------------------------------------------- | 
|         |   1567  | 
|         |   1568 TInt CFileBrowserFileUtils::ClipboardCutL(const CArrayFix<TInt>* aSelectionIndices) | 
|         |   1569     { | 
|         |   1570 	 | 
|         |   1571     iClipBoardMode = EClipBoardModeCut; | 
|         |   1572     //TInt operations = GetSelectedItemsOrCurrentItemL(iClipBoardList); | 
|         |   1573     TInt operations = SetSelectedItemsOrCurrentItemL(aSelectionIndices, iClipBoardList); | 
|         |   1574     return operations; | 
|         |   1575     } | 
|         |   1576  | 
|         |   1577 // -------------------------------------------------------------------------------------------- | 
|         |   1578  | 
|         |   1579 TInt CFileBrowserFileUtils::ClipboardCopyL(const CArrayFix<TInt>* aSelectionIndices) | 
|         |   1580     { | 
|         |   1581     iClipBoardMode = EClipBoardModeCopy; | 
|         |   1582     //TInt operations = GetSelectedItemsOrCurrentItemL(iClipBoardList); | 
|         |   1583     TInt operations = SetSelectedItemsOrCurrentItemL(aSelectionIndices, iClipBoardList); | 
|         |   1584     return operations; | 
|         |   1585     } | 
|         |   1586  | 
|         |   1587 // -------------------------------------------------------------------------------------------- | 
|         |   1588  | 
|         |   1589 void CFileBrowserFileUtils::ClipboardPasteL(const TOverwriteOptions &aOverwriteOptions) | 
|         |   1590     { | 
|         |   1591     if (iClipBoardMode == EClipBoardModeCut) | 
|         |   1592         { | 
|         |   1593         DoCopyToFolderL(iClipBoardList, iCurrentPath, aOverwriteOptions, ETrue ); | 
|         |   1594         iClipBoardList->Reset(); | 
|         |   1595         } | 
|         |   1596     else if (iClipBoardMode == EClipBoardModeCopy) | 
|         |   1597         { | 
|         |   1598         DoCopyToFolderL(iClipBoardList, iCurrentPath, aOverwriteOptions, EFalse); | 
|         |   1599         } | 
|         |   1600     } | 
|         |   1601  | 
|         |   1602 // -------------------------------------------------------------------------------------------- | 
|         |   1603  | 
|         |   1604 TInt CFileBrowserFileUtils::SetCurrentSelection(const CArrayFix<TInt>* aSelectionIndices) | 
|         |   1605     { | 
|         |   1606     TInt operations = SetSelectedItemsOrCurrentItemL(aSelectionIndices, iCurrentSelectionList); | 
|         |   1607     return operations; | 
|         |   1608     } | 
|         |   1609  | 
|         |   1610 // -------------------------------------------------------------------------------------------- | 
|         |   1611  | 
|         |   1612 void CFileBrowserFileUtils::CopyToFolderL(TFileName aTargetDir, | 
|         |   1613                                           const TOverwriteOptions &aOverwriteOptions, | 
|         |   1614                                           TBool aMove) | 
|         |   1615     { | 
|         |   1616  | 
|         |   1617     //	TFileName destinationFolder; | 
|         |   1618  | 
|         |   1619     // generate an icon array | 
|         |   1620     // CAknIconArray* iconArray = GenerateIconArrayL(ETrue); | 
|         |   1621     //    CleanupStack::PushL(iconArray); | 
|         |   1622  | 
|         |   1623     // run folder selection dialog | 
|         |   1624     //    CFileBrowserDestinationFolderSelectionDlg* dlg = CFileBrowserDestinationFolderSelectionDlg::NewL(destinationFolder, iDriveEntryList, iconArray); | 
|         |   1625  | 
|         |   1626     // get entry list | 
|         |   1627     //CFileEntryList* entryList = new(ELeave) CFileEntryList(32); | 
|         |   1628     //GetSelectedItemsOrCurrentItemL(entryList); | 
|         |   1629     //CleanupStack::PushL(entryList); | 
|         |   1630  | 
|         |   1631     // do the file operations | 
|         |   1632     //DoCopyToFolderL(entryList, aTargetDir, aOverwriteOptions, aMove); | 
|         |   1633     DoCopyToFolderL(iCurrentSelectionList, aTargetDir, aOverwriteOptions, aMove); | 
|         |   1634  | 
|         |   1635     //CleanupStack::PopAndDestroy(); // entryList | 
|         |   1636  | 
|         |   1637     //    CleanupStack::Pop(); //iconArray | 
|         |   1638     } | 
|         |   1639  | 
|         |   1640 // -------------------------------------------------------------------------------------------- | 
|         |   1641  | 
|         |   1642 TBool CFileBrowserFileUtils::IsDestinationEntriesExists(const TDesC& aTargetDir) | 
|         |   1643     { | 
|         |   1644     TBool someEntryExists(EFalse); | 
|         |   1645     if (iCurrentSelectionList && iCurrentSelectionList->Count() > 0) | 
|         |   1646         { | 
|         |   1647         // check if some destination entries also exists | 
|         |   1648         for (TInt i=0; i<iCurrentSelectionList->Count(); i++) | 
|         |   1649             { | 
|         |   1650             TFileEntry fileEntry = iCurrentSelectionList->At(i); | 
|         |   1651  | 
|         |   1652             TFileName targetEntry = aTargetDir; | 
|         |   1653             targetEntry.Append(fileEntry.iEntry.iName); | 
|         |   1654  | 
|         |   1655             if (fileEntry.iEntry.IsDir()) | 
|         |   1656                 { | 
|         |   1657                 targetEntry.Append(_L("\\")); | 
|         |   1658  | 
|         |   1659                 if (BaflUtils::PathExists(iFs, targetEntry)) | 
|         |   1660                     { | 
|         |   1661                     someEntryExists = ETrue; | 
|         |   1662                     break; | 
|         |   1663                     } | 
|         |   1664                 } | 
|         |   1665             else | 
|         |   1666                 { | 
|         |   1667                 if (BaflUtils::FileExists(iFs, targetEntry)) | 
|         |   1668                     { | 
|         |   1669                     someEntryExists = ETrue; | 
|         |   1670                     break; | 
|         |   1671                     } | 
|         |   1672                 } | 
|         |   1673             } | 
|         |   1674         } | 
|         |   1675     return someEntryExists; | 
|         |   1676     } | 
|         |   1677  | 
|         |   1678 // -------------------------------------------------------------------------------------------- | 
|         |   1679  | 
|         |   1680 void CFileBrowserFileUtils::DoCopyToFolderL(CFileEntryList* aEntryList, | 
|         |   1681                                             const TDesC& aTargetDir, | 
|         |   1682                                             const TOverwriteOptions &aOverwriteOptions, | 
|         |   1683                                             TBool aDeleteSource) | 
|         |   1684     { | 
|         |   1685     if (aEntryList && aEntryList->Count() > 0) | 
|         |   1686         { | 
|         |   1687         if (aOverwriteOptions.iDoFileOperations) | 
|         |   1688             { | 
|         |   1689             // set correct command id depending if we are copying or moving | 
|         |   1690             TInt commandId(EFileBrowserFileOpCommandCopy); | 
|         |   1691             if (aDeleteSource) | 
|         |   1692                 commandId = EFileBrowserFileOpCommandMove; | 
|         |   1693              | 
|         |   1694             // do the file operations for each entry | 
|         |   1695             for (TInt i=0; i<aEntryList->Count(); i++) | 
|         |   1696                 { | 
|         |   1697                 TFileEntry fileEntry = aEntryList->At(i); | 
|         |   1698                  | 
|         |   1699                 TFileName targetEntry = aTargetDir; | 
|         |   1700                 targetEntry.Append(fileEntry.iEntry.iName); | 
|         |   1701                  | 
|         |   1702                 if (aOverwriteOptions.iQueryIndex == EFileActionGenerateUniqueFilenames) | 
|         |   1703                     { | 
|         |   1704                     CApaApplication::GenerateFileName(iFs, targetEntry); | 
|         |   1705                     } | 
|         |   1706                 else if (aOverwriteOptions.iQueryIndex == EFileActionQueryPostFix) | 
|         |   1707                     { | 
|         |   1708                     targetEntry.Append(aOverwriteOptions.iPostFix); | 
|         |   1709                     } | 
|         |   1710  | 
|         |   1711                  | 
|         |   1712                 // append the new command to the command array | 
|         |   1713                 if (fileEntry.iEntry.IsDir()) | 
|         |   1714                     { | 
|         |   1715                     AppendToCommandArrayL(commandId, | 
|         |   1716                                           new(ELeave)CCommandParamsCopyOrMove(fileEntry, targetEntry, aOverwriteOptions.iOverWriteFlags|CFileMan::ERecurse) | 
|         |   1717                                          ); | 
|         |   1718                     } | 
|         |   1719                 else | 
|         |   1720                     { | 
|         |   1721                     AppendToCommandArrayL(commandId, | 
|         |   1722                                           new(ELeave)CCommandParamsCopyOrMove(fileEntry, targetEntry, aOverwriteOptions.iOverWriteFlags) | 
|         |   1723                                          ); | 
|         |   1724                     } | 
|         |   1725  | 
|         |   1726                 } | 
|         |   1727  | 
|         |   1728             // execute all operations | 
|         |   1729             if (aDeleteSource) | 
|         |   1730                 StartExecutingCommandsL(_L("Moving")); | 
|         |   1731             else | 
|         |   1732                 StartExecutingCommandsL(_L("Copying")); | 
|         |   1733             } | 
|         |   1734         } | 
|         |   1735     } | 
|         |   1736  | 
|         |   1737 // -------------------------------------------------------------------------------------------- | 
|         |   1738  | 
|         |   1739 void CFileBrowserFileUtils::DeleteL() | 
|         |   1740     { | 
|         |   1741     // do the file operations for each entry | 
|         |   1742     for (TInt i=0; i<iCurrentSelectionList->Count(); i++) | 
|         |   1743         { | 
|         |   1744         TFileEntry fileEntry = iCurrentSelectionList->At(i); | 
|         |   1745  | 
|         |   1746         // append the new command to the command array | 
|         |   1747         if (fileEntry.iEntry.IsDir()) | 
|         |   1748             { | 
|         |   1749             AppendToCommandArrayL(EFileBrowserFileOpCommandDelete, | 
|         |   1750                                   new(ELeave)CCommandParamsDelete(fileEntry, CFileMan::ERecurse) | 
|         |   1751                                  ); | 
|         |   1752             } | 
|         |   1753         else | 
|         |   1754             { | 
|         |   1755             AppendToCommandArrayL(EFileBrowserFileOpCommandDelete, | 
|         |   1756                                   new(ELeave)CCommandParamsDelete(fileEntry, 0) | 
|         |   1757                                  ); | 
|         |   1758             } | 
|         |   1759  | 
|         |   1760         } | 
|         |   1761  | 
|         |   1762     // execute all operations | 
|         |   1763     StartExecutingCommandsL(_L("Deleting")); | 
|         |   1764     } | 
|         |   1765  | 
|         |   1766  | 
|         |   1767 // -------------------------------------------------------------------------------------------- | 
|         |   1768  | 
|         |   1769 TBool CFileBrowserFileUtils::SelectionHasDirs() | 
|         |   1770 { | 
|         |   1771     TBool isDir(EFalse); | 
|         |   1772  | 
|         |   1773     // check if any directories and ask recursion | 
|         |   1774     for (TInt i=0; i<iCurrentSelectionList->Count(); i++) | 
|         |   1775         { | 
|         |   1776         TFileEntry fileEntry = iCurrentSelectionList->At(i); | 
|         |   1777  | 
|         |   1778         if (fileEntry.iEntry.IsDir()) | 
|         |   1779             { | 
|         |   1780             isDir = ETrue; | 
|         |   1781             break; | 
|         |   1782             } | 
|         |   1783         } | 
|         |   1784     return isDir; | 
|         |   1785 } | 
|         |   1786  | 
|         |   1787 // -------------------------------------------------------------------------------------------- | 
|         |   1788  | 
|         |   1789 void CFileBrowserFileUtils::TouchL(TBool aRecurse) | 
|         |   1790     { | 
|         |   1791     // now go through all entries | 
|         |   1792     for (TInt i=0; i<iCurrentSelectionList->Count(); i++) | 
|         |   1793         { | 
|         |   1794         TFileEntry fileEntry = iCurrentSelectionList->At(i); | 
|         |   1795  | 
|         |   1796         // touch to current time | 
|         |   1797         TTime now; | 
|         |   1798         now.UniversalTime(); | 
|         |   1799  | 
|         |   1800  | 
|         |   1801         // append the new command to the command array | 
|         |   1802         if (fileEntry.iEntry.IsDir() && aRecurse) | 
|         |   1803             { | 
|         |   1804             AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs, | 
|         |   1805                                   new(ELeave)CCommandParamsAttribs(fileEntry, NULL, NULL, now, CFileMan::ERecurse) | 
|         |   1806                                  ); | 
|         |   1807             } | 
|         |   1808         else | 
|         |   1809             { | 
|         |   1810             AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs, | 
|         |   1811                                   new(ELeave)CCommandParamsAttribs(fileEntry, NULL, NULL, now, 0) | 
|         |   1812                                  ); | 
|         |   1813             } | 
|         |   1814         } | 
|         |   1815  | 
|         |   1816     // execute all operations | 
|         |   1817     StartExecutingCommandsL(_L("Touching")); | 
|         |   1818     } | 
|         |   1819  | 
|         |   1820 TBool CFileBrowserFileUtils::TargetExists(const TInt aIndex, const TFileName &newName) | 
|         |   1821     { | 
|         |   1822     TBool alreadyExists(EFalse); | 
|         |   1823     if (iDriveEntryList->Count() > aIndex && aIndex >= 0) | 
|         |   1824         { | 
|         |   1825  | 
|         |   1826         TFileEntry fileEntry = iFileEntryList->At(aIndex); | 
|         |   1827         TFileName targetEntry = fileEntry.iPath; | 
|         |   1828         targetEntry.Append(newName); | 
|         |   1829         if (fileEntry.iEntry.IsDir()) | 
|         |   1830             { | 
|         |   1831             //targetEntry.Append(_L("\\")); | 
|         |   1832             alreadyExists = BaflUtils::PathExists(iFs, targetEntry); | 
|         |   1833             } | 
|         |   1834         else | 
|         |   1835             { | 
|         |   1836             alreadyExists = BaflUtils::FileExists(iFs, targetEntry); | 
|         |   1837             } | 
|         |   1838         } | 
|         |   1839     return alreadyExists; | 
|         |   1840     } | 
|         |   1841  | 
|         |   1842 // -------------------------------------------------------------------------------------------- | 
|         |   1843  | 
|         |   1844 void CFileBrowserFileUtils::RenameL(const TInt aIndex, const TFileName &newName) | 
|         |   1845     { | 
|         |   1846         if (iDriveEntryList->Count() > aIndex && aIndex >= 0) | 
|         |   1847         { | 
|         |   1848             TFileEntry fileEntry = iFileEntryList->At(aIndex); | 
|         |   1849  | 
|         |   1850             TFileName targetEntry = fileEntry.iPath; | 
|         |   1851             targetEntry.Append(newName); | 
|         |   1852  | 
|         |   1853             // append the new command to the command array | 
|         |   1854             AppendToCommandArrayL(EFileBrowserFileOpCommandRename, | 
|         |   1855                                   new(ELeave)CCommandParamsRename(fileEntry, targetEntry, CFileMan::EOverWrite) | 
|         |   1856                                  ); | 
|         |   1857         } | 
|         |   1858     // execute all operations done from caller | 
|         |   1859     // StartExecutingCommandsL(_L("Renaming")); | 
|         |   1860     } | 
|         |   1861  | 
|         |   1862 // -------------------------------------------------------------------------------------------- | 
|         |   1863  | 
|         |   1864 void CFileBrowserFileUtils::SetAttributesL() | 
|         |   1865     { | 
|         |   1866 //    CFileEntryList* entries = new(ELeave) CFileEntryList(16); | 
|         |   1867 //    GetSelectedItemsOrCurrentItemL(entries); | 
|         |   1868 //    CleanupStack::PushL(entries); | 
|         |   1869 // | 
|         |   1870 //    if (entries->Count() > 0) | 
|         |   1871 //        { | 
|         |   1872 //        TFileName naviText = _L("Multiple entries"); | 
|         |   1873 // | 
|         |   1874 //        TUint setAttMask(0); | 
|         |   1875 //        TUint clearAttMask(0); | 
|         |   1876 //        //TBool recurse(EFalse); | 
|         |   1877 // | 
|         |   1878 //        // set default masks if only one file selected | 
|         |   1879 //        if (entries->Count() == 1) | 
|         |   1880 //            { | 
|         |   1881 //            TFileEntry fileEntry = entries->At(0); | 
|         |   1882 // | 
|         |   1883 //            naviText.Copy(fileEntry.iEntry.iName); | 
|         |   1884 // | 
|         |   1885 //            if (fileEntry.iEntry.IsArchive()) | 
|         |   1886 //                setAttMask |= KEntryAttArchive; | 
|         |   1887 //            else | 
|         |   1888 //                clearAttMask |= KEntryAttArchive; | 
|         |   1889 // | 
|         |   1890 //            if (fileEntry.iEntry.IsHidden()) | 
|         |   1891 //                setAttMask |= KEntryAttHidden; | 
|         |   1892 //            else | 
|         |   1893 //                clearAttMask |= KEntryAttHidden; | 
|         |   1894 // | 
|         |   1895 //            if (fileEntry.iEntry.IsReadOnly()) | 
|         |   1896 //                setAttMask |= KEntryAttReadOnly; | 
|         |   1897 //            else | 
|         |   1898 //                clearAttMask |= KEntryAttReadOnly; | 
|         |   1899 // | 
|         |   1900 //            if (fileEntry.iEntry.IsSystem()) | 
|         |   1901 //                setAttMask |= KEntryAttSystem; | 
|         |   1902 //            else | 
|         |   1903 //                clearAttMask |= KEntryAttSystem; | 
|         |   1904 //            } | 
|         |   1905 // | 
|         |   1906         //iEngine->FileListContainer()->SetScreenLayoutL(EDisplayModeNormal); | 
|         |   1907         //iEngine->FileListContainer()->SetNaviPaneTextL(naviText); | 
|         |   1908  | 
|         |   1909         //CFileBrowserAttributeEditorDlg* dlg = CFileBrowserAttributeEditorDlg::NewL(setAttMask, clearAttMask, recurse); | 
|         |   1910         //TBool dlgResult = dlg->RunEditorLD(); | 
|         |   1911  | 
|         |   1912         //iEngine->FileListContainer()->SetScreenLayoutL(iEngine->Settings().iDisplayMode); | 
|         |   1913         //iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath);         | 
|         |   1914 // | 
|         |   1915 //        if (dlgResult && (setAttMask > 0 || clearAttMask > 0)) | 
|         |   1916 //            { | 
|         |   1917 //            for (TInt i=0; i<entries->Count(); i++) | 
|         |   1918 //                { | 
|         |   1919 //                TFileEntry fileEntry = entries->At(i); | 
|         |   1920 // | 
|         |   1921 //                // append the new command to the command array | 
|         |   1922 //                if (fileEntry.iEntry.IsDir() && recurse) | 
|         |   1923 //                    { | 
|         |   1924 //                    AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs, | 
|         |   1925 //                                          new(ELeave)CCommandParamsAttribs(fileEntry, setAttMask, clearAttMask, fileEntry.iEntry.iModified, CFileMan::ERecurse) | 
|         |   1926 //                                         ); | 
|         |   1927 //                    } | 
|         |   1928 //                else | 
|         |   1929 //                    { | 
|         |   1930 //                    AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs, | 
|         |   1931 //                                          new(ELeave)CCommandParamsAttribs(fileEntry, setAttMask, clearAttMask, fileEntry.iEntry.iModified, 0) | 
|         |   1932 //                                         ); | 
|         |   1933 //                    } | 
|         |   1934 //                } | 
|         |   1935 // | 
|         |   1936 //            // execute all operations | 
|         |   1937 //            StartExecutingCommandsL(_L("Changing attributes")); | 
|         |   1938 //            } | 
|         |   1939 // | 
|         |   1940 //        } | 
|         |   1941 // | 
|         |   1942 //    CleanupStack::PopAndDestroy(); //entries | 
|         |   1943     } | 
|         |   1944         | 
|         |   1945 // -------------------------------------------------------------------------------------------- | 
|         |   1946  | 
|         |   1947 void CFileBrowserFileUtils::SearchL() | 
|         |   1948     { | 
|         |   1949 //    iEngine->FileListContainer()->SetScreenLayoutL(EDisplayModeNormal); | 
|         |   1950 //    iEngine->FileListContainer()->SetNaviPaneTextL(KNullDesC); | 
|         |   1951 // | 
|         |   1952 //    iSearchAttributes.iSearchDir = iCurrentPath; | 
|         |   1953 // | 
|         |   1954 //    CFileBrowserSearchQueryDlg* dlg = CFileBrowserSearchQueryDlg::NewL(iSearchAttributes); | 
|         |   1955 //    TBool dlgResult = dlg->RunQueryLD(); | 
|         |   1956 // | 
|         |   1957 //    iEngine->FileListContainer()->SetScreenLayoutL(iEngine->Settings().iDisplayMode); | 
|         |   1958 //    iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); | 
|         |   1959 // | 
|         |   1960 //    if (dlgResult) | 
|         |   1961 //        { | 
|         |   1962 //        iEngine->EikonEnv()->BusyMsgL(_L("** Searching **"), TGulAlignment(EHCenterVTop)); | 
|         |   1963 // | 
|         |   1964 //        iFileEntryList->Reset(); | 
|         |   1965 // | 
|         |   1966 //        // if search dir is empty, find from all drives | 
|         |   1967 //        if (iSearchAttributes.iSearchDir == KNullDesC) | 
|         |   1968 //            { | 
|         |   1969 //            for (TInt i=0; i<iDriveEntryList->Count(); i++) | 
|         |   1970 //                { | 
|         |   1971 //                TDriveEntry driveEntry = iDriveEntryList->At(i); | 
|         |   1972 // | 
|         |   1973 //                TBuf<10> driveRoot; | 
|         |   1974 //                driveRoot.Append(driveEntry.iLetter); | 
|         |   1975 //                driveRoot.Append(_L(":\\")); | 
|         |   1976 // | 
|         |   1977 //                DoSearchFiles(iSearchAttributes.iWildCards, driveRoot); | 
|         |   1978 // | 
|         |   1979 //                if (iSearchAttributes.iRecurse) | 
|         |   1980 //                    DoSearchFilesRecursiveL(iSearchAttributes.iWildCards, driveRoot); | 
|         |   1981 // | 
|         |   1982 //                } | 
|         |   1983 // | 
|         |   1984 //            } | 
|         |   1985 // | 
|         |   1986 //        // otherwise just search from the selected directory | 
|         |   1987 //        else | 
|         |   1988 //            { | 
|         |   1989 //            DoSearchFiles(iSearchAttributes.iWildCards, iSearchAttributes.iSearchDir); | 
|         |   1990 // | 
|         |   1991 //            if (iSearchAttributes.iRecurse) | 
|         |   1992 //                DoSearchFilesRecursiveL(iSearchAttributes.iWildCards, iSearchAttributes.iSearchDir); | 
|         |   1993 //            } | 
|         |   1994 // | 
|         |   1995 //        iEngine->EikonEnv()->BusyMsgCancel(); | 
|         |   1996 // | 
|         |   1997 //        TInt operations = iFileEntryList->Count(); | 
|         |   1998 // | 
|         |   1999 //        iListingMode = ESearchResults; | 
|         |   2000 //        iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex(0); | 
|         |   2001 //        RefreshViewL(); | 
|         |   2002 // | 
|         |   2003 //        _LIT(KMessage, "%d entries found"); | 
|         |   2004 //        TFileName noteMsg; | 
|         |   2005 //        noteMsg.Format(KMessage, operations); | 
|         |   2006 // | 
|         |   2007 //        iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); | 
|         |   2008 //        } | 
|         |   2009     } | 
|         |   2010  | 
|         |   2011 // -------------------------------------------------------------------------------------------- | 
|         |   2012  | 
|         |   2013 TInt CFileBrowserFileUtils::DoSearchFiles(const TDesC& aFileName, const TDesC& aPath) | 
|         |   2014     { | 
|         |   2015     TFindFile fileFinder(iFs); | 
|         |   2016     CDir* dir; | 
|         |   2017     TInt err = fileFinder.FindWildByPath(aFileName, &aPath, dir); | 
|         |   2018  | 
|         |   2019     while (err == KErrNone) | 
|         |   2020         { | 
|         |   2021         for (TInt i=0; i<dir->Count(); i++) | 
|         |   2022             { | 
|         |   2023             TEntry entry = (*dir)[i]; | 
|         |   2024              | 
|         |   2025             TTime entryModified = entry.iModified; | 
|         |   2026             // convert from universal time | 
|         |   2027             if ( iTz.ConvertToLocalTime( entryModified ) == KErrNone ) | 
|         |   2028                 { | 
|         |   2029                 entryModified = entry.iModified; | 
|         |   2030                 } | 
|         |   2031             if ((entry.IsDir() && entryModified >= iSearchAttributes.iMinDate && entryModified <= iSearchAttributes.iMaxDate) || | 
|         |   2032                 (!entry.IsDir() &&entry.iSize >= iSearchAttributes.iMinSize && entry.iSize <= iSearchAttributes.iMaxSize && | 
|         |   2033                  entryModified >= iSearchAttributes.iMinDate && entryModified <= iSearchAttributes.iMaxDate)) | 
|         |   2034                 { | 
|         |   2035                 TParse parsedName; | 
|         |   2036                 parsedName.Set(entry.iName, &fileFinder.File(), NULL); | 
|         |   2037                  | 
|         |   2038                 if (parsedName.Drive().Length() && aPath.Length() && parsedName.Drive()[0] == aPath[0]) | 
|         |   2039                     { | 
|         |   2040                     TFileEntry fileEntry; | 
|         |   2041                     fileEntry.iPath = parsedName.DriveAndPath(); | 
|         |   2042                     fileEntry.iEntry = entry; | 
|         |   2043                     fileEntry.iDirEntries = KErrNotFound; | 
|         |   2044                      | 
|         |   2045                     TBool appendToArray(EFalse); | 
|         |   2046                      | 
|         |   2047                     // append directories always | 
|         |   2048                     if (entry.IsDir() && !iSearchAttributes.iTextInFile.Length()) | 
|         |   2049                         { | 
|         |   2050                         fileEntry.iIconId = EFixedIconFolder; | 
|         |   2051                         appendToArray = ETrue;     | 
|         |   2052                         } | 
|         |   2053                      | 
|         |   2054                     // normal file | 
|         |   2055                     else | 
|         |   2056                         { | 
|         |   2057                         fileEntry.iIconId = EFixedIconEmpty; | 
|         |   2058                          | 
|         |   2059                         // check if a string needs to be found inside the file | 
|         |   2060                         if (iSearchAttributes.iTextInFile.Length()) | 
|         |   2061                             { | 
|         |   2062                             // currently only 8-bit searching, so convert from 16-bit | 
|         |   2063                             TBuf8<256> searchText; | 
|         |   2064                             searchText.Copy(iSearchAttributes.iTextInFile); | 
|         |   2065                              | 
|         |   2066                             // specify buffer size and create a buffer | 
|         |   2067                             const TInt KReadBufSize = 1024*1024; | 
|         |   2068                             HBufC8* buffer = HBufC8::NewLC(KReadBufSize); | 
|         |   2069                             TPtr8 bufferPtr = buffer->Des(); | 
|         |   2070  | 
|         |   2071                             // open the file for reading | 
|         |   2072                             RFile file; | 
|         |   2073                             if (file.Open(iFs, parsedName.FullName(), EFileRead) == KErrNone) | 
|         |   2074                                 { | 
|         |   2075                                 TInt currentPos(0); | 
|         |   2076                                  | 
|         |   2077                                 for (;;) | 
|         |   2078                                     { | 
|         |   2079                                     // read from the file | 
|         |   2080                                     file.Read(currentPos, bufferPtr, KReadBufSize); | 
|         |   2081  | 
|         |   2082                                     // stop looping if the read buffer isn't long enough | 
|         |   2083                                     if (bufferPtr.Length() < searchText.Length()) | 
|         |   2084                                         { | 
|         |   2085                                         break; | 
|         |   2086                                         } | 
|         |   2087                                          | 
|         |   2088                                     // try to find the text | 
|         |   2089                                     if (bufferPtr.FindF(searchText) >= 0) | 
|         |   2090                                         { | 
|         |   2091                                         // match found! | 
|         |   2092                                         appendToArray = ETrue; | 
|         |   2093                                         break; | 
|         |   2094                                         } | 
|         |   2095                                          | 
|         |   2096                                     // calculate the next position | 
|         |   2097                                     currentPos += KReadBufSize - searchText.Length();     | 
|         |   2098                                     } | 
|         |   2099                                  | 
|         |   2100                                 file.Close(); | 
|         |   2101                                 } | 
|         |   2102                              | 
|         |   2103                             CleanupStack::PopAndDestroy(); //buffer | 
|         |   2104                             } | 
|         |   2105                         else | 
|         |   2106                             { | 
|         |   2107                             appendToArray = ETrue; | 
|         |   2108                             } | 
|         |   2109                         } | 
|         |   2110  | 
|         |   2111                     if (appendToArray) | 
|         |   2112                         TRAP(err, iFileEntryList->AppendL(fileEntry));     | 
|         |   2113                     } | 
|         |   2114                 } | 
|         |   2115             } | 
|         |   2116  | 
|         |   2117         delete dir; | 
|         |   2118         err = fileFinder.FindWild(dir); | 
|         |   2119         } | 
|         |   2120  | 
|         |   2121     return err; | 
|         |   2122     } | 
|         |   2123  | 
|         |   2124 // -------------------------------------------------------------------------------------------- | 
|         |   2125  | 
|         |   2126 TInt CFileBrowserFileUtils::DoSearchFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath) | 
|         |   2127 	{ | 
|         |   2128     TInt err(KErrNone); | 
|         |   2129     CDirScan* scan = CDirScan::NewLC(iFs); | 
|         |   2130     scan->SetScanDataL(aPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst); | 
|         |   2131     CDir* dir = NULL; | 
|         |   2132  | 
|         |   2133     for(;;) | 
|         |   2134         { | 
|         |   2135         TRAP(err, scan->NextL(dir)); | 
|         |   2136         if (!dir  || (err != KErrNone)) | 
|         |   2137             break; | 
|         |   2138  | 
|         |   2139         for (TInt i=0; i<dir->Count(); i++) | 
|         |   2140             { | 
|         |   2141             TEntry entry = (*dir)[i]; | 
|         |   2142              | 
|         |   2143             if (entry.IsDir()) | 
|         |   2144                 { | 
|         |   2145                 TFileName path(scan->FullPath()); | 
|         |   2146                  | 
|         |   2147                 if (path.Length()) | 
|         |   2148                     { | 
|         |   2149                     path.Append(entry.iName); | 
|         |   2150                     path.Append(_L("\\")); | 
|         |   2151                     DoSearchFiles(aFileName, path); | 
|         |   2152                     } | 
|         |   2153                 } | 
|         |   2154             } | 
|         |   2155         delete(dir); | 
|         |   2156         } | 
|         |   2157  | 
|         |   2158     CleanupStack::PopAndDestroy(scan); | 
|         |   2159     return err; | 
|         |   2160     } | 
|         |   2161           | 
|         |   2162 // -------------------------------------------------------------------------------------------- | 
|         |   2163  | 
|         |   2164 void CFileBrowserFileUtils::NewFileL(const TFileName &aNewFileName) | 
|         |   2165     { | 
|         |   2166     TFileName fullPath = iCurrentPath; | 
|         |   2167     fullPath.Append(aNewFileName); | 
|         |   2168  | 
|         |   2169     TParse nameParser; | 
|         |   2170     TInt err = nameParser.SetNoWild(fullPath, NULL, NULL); | 
|         |   2171  | 
|         |   2172     if (err == KErrNone) | 
|         |   2173         { | 
|         |   2174         // do not try to recreate the file if it already exists | 
|         |   2175         if (BaflUtils::PathExists(iFs, nameParser.DriveAndPath())) | 
|         |   2176             { | 
|         |   2177             err = iFileOps->CreateEmptyFile(fullPath); | 
|         |   2178             } | 
|         |   2179         else | 
|         |   2180             err = KErrAlreadyExists; | 
|         |   2181         } | 
|         |   2182  | 
|         |   2183     if (err == KErrNone) | 
|         |   2184         { | 
|         |   2185         iEngine->FileBrowserUI()->ShowConfirmationNote(_L("New file created")); | 
|         |   2186         } | 
|         |   2187  | 
|         |   2188     else if (err == KErrAlreadyExists) | 
|         |   2189         { | 
|         |   2190         iEngine->FileBrowserUI()->ShowInformationNote(_L("File already exists"), _L("")); | 
|         |   2191         } | 
|         |   2192  | 
|         |   2193     else | 
|         |   2194         { | 
|         |   2195         CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); | 
|         |   2196  | 
|         |   2197         iEngine->FileBrowserUI()->ShowErrorNote( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); | 
|         |   2198  | 
|         |   2199         CleanupStack::PopAndDestroy();  //textResolver | 
|         |   2200         } | 
|         |   2201  | 
|         |   2202     RefreshViewL(); | 
|         |   2203     } | 
|         |   2204  | 
|         |   2205 // -------------------------------------------------------------------------------------------- | 
|         |   2206  | 
|         |   2207 void CFileBrowserFileUtils::NewDirectoryL(const TFileName &aNewDirectoryName) | 
|         |   2208     {        | 
|         |   2209     TFileName fullPath = iCurrentPath; | 
|         |   2210     fullPath.Append(aNewDirectoryName); | 
|         |   2211     fullPath.Append(_L("\\")); | 
|         |   2212  | 
|         |   2213     TInt err = iFileOps->MkDirAll(fullPath, 0, ETrue); | 
|         |   2214  | 
|         |   2215     if (err == KErrNone) | 
|         |   2216         { | 
|         |   2217         iEngine->FileBrowserUI()->ShowConfirmationNote(_L("New directory created")); | 
|         |   2218         } | 
|         |   2219  | 
|         |   2220     else if (err == KErrAlreadyExists) | 
|         |   2221         { | 
|         |   2222         iEngine->FileBrowserUI()->ShowInformationNote(_L("Directory already exists"), _L("")); | 
|         |   2223         } | 
|         |   2224  | 
|         |   2225     else | 
|         |   2226         { | 
|         |   2227         CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); | 
|         |   2228  | 
|         |   2229         iEngine->FileBrowserUI()->ShowErrorNote( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); | 
|         |   2230  | 
|         |   2231         CleanupStack::PopAndDestroy();  //textResolver | 
|         |   2232         } | 
|         |   2233  | 
|         |   2234     RefreshViewL(); | 
|         |   2235     } | 
|         |   2236  | 
|         |   2237 // -------------------------------------------------------------------------------------------- | 
|         |   2238  | 
|         |   2239 void CFileBrowserFileUtils::SendToL() | 
|         |   2240     { | 
|         |   2241 //    CFileEntryList* entries = new(ELeave) CFileEntryList(32); | 
|         |   2242 //    GetSelectedItemsOrCurrentItemL(entries); | 
|         |   2243 //    CleanupStack::PushL(entries); | 
|         |   2244 // | 
|         |   2245 //    TInt operations(0); | 
|         |   2246 // | 
|         |   2247 //    CSendUi* sendUi = CSendUi::NewL(); | 
|         |   2248 //    CleanupStack::PushL(sendUi); | 
|         |   2249 //    CMessageData* messageData = CMessageData::NewL(); | 
|         |   2250 //    CleanupStack::PushL(messageData); | 
|         |   2251 // | 
|         |   2252 //    for (TInt i=0; i<entries->Count(); i++) | 
|         |   2253 //        { | 
|         |   2254 //        TFileEntry fileEntry = entries->At(i); | 
|         |   2255 // | 
|         |   2256 //        // only supported for normal file entries | 
|         |   2257 //        if (!fileEntry.iEntry.IsDir()) | 
|         |   2258 //            { | 
|         |   2259 //            TFileName fullPath = fileEntry.iPath; | 
|         |   2260 //            fullPath.Append(fileEntry.iEntry.iName); | 
|         |   2261 // | 
|         |   2262 //            messageData->AppendAttachmentL(fullPath); | 
|         |   2263 //            operations++; | 
|         |   2264 // | 
|         |   2265 //            } | 
|         |   2266 //        } | 
|         |   2267 // | 
|         |   2268 //    if (operations > 0) | 
|         |   2269 //        { | 
|         |   2270 //        sendUi->ShowQueryAndSendL(messageData, TSendingCapabilities(0, 0, TSendingCapabilities::ESupportsAttachments)); | 
|         |   2271 // | 
|         |   2272 //        // I guess this note is not needed.. | 
|         |   2273 ////        _LIT(KMessage, "%d entries sent"); | 
|         |   2274 ////        TFileName noteMsg; | 
|         |   2275 ////        noteMsg.Format(KMessage, operations); | 
|         |   2276 //// | 
|         |   2277 ////        iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg); | 
|         |   2278 //        } | 
|         |   2279 //    else | 
|         |   2280 //        { | 
|         |   2281 //        _LIT(KMessage, "Nothing to send"); | 
|         |   2282 //        iEngine->FileBrowserUI()->ShowInformationNote(KMessage, _L("")); | 
|         |   2283 //        } | 
|         |   2284 // | 
|         |   2285 //    CleanupStack::PopAndDestroy(3); // entries, sendUi, messageData | 
|         |   2286     } | 
|         |   2287  | 
|         |   2288 // -------------------------------------------------------------------------------------------- | 
|         |   2289  | 
|         |   2290 void CFileBrowserFileUtils::CompressL() | 
|         |   2291     { | 
|         |   2292 //    CFileEntryList* entries = new(ELeave) CFileEntryList(16); | 
|         |   2293 //    GetSelectedItemsOrCurrentItemL(entries); | 
|         |   2294 //    CleanupStack::PushL(entries); | 
|         |   2295 // | 
|         |   2296 //    for (TInt i=0; i<entries->Count(); i++) | 
|         |   2297 //        { | 
|         |   2298 //        TFileEntry fileEntry = entries->At(i); | 
|         |   2299 // | 
|         |   2300 //        TFileName sourceEntry = fileEntry.iPath; | 
|         |   2301 //        sourceEntry.Append(fileEntry.iEntry.iName); | 
|         |   2302 // | 
|         |   2303 //        TFileName targetEntry = sourceEntry; | 
|         |   2304 //        targetEntry.Append(KGZipExt); | 
|         |   2305 // | 
|         |   2306 //        TFileName targetEntryShort; | 
|         |   2307 //        targetEntryShort.Copy(fileEntry.iEntry.iName); | 
|         |   2308 //        targetEntryShort.Append(KGZipExt); | 
|         |   2309 // | 
|         |   2310 //        if (BaflUtils::FileExists(iFs, targetEntry)) | 
|         |   2311 //            { | 
|         |   2312 //            _LIT(KMessage, "%S already exists"); | 
|         |   2313 //            TFileName noteMsg; | 
|         |   2314 //            noteMsg.Format(KMessage, &targetEntryShort); | 
|         |   2315 // | 
|         |   2316 //            iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); | 
|         |   2317 //            } | 
|         |   2318 //        else | 
|         |   2319 //            { | 
|         |   2320 //            TRAPD(err, | 
|         |   2321 //                RFile inputFile; | 
|         |   2322 //                User::LeaveIfError(inputFile.Open(iFs, sourceEntry, EFileStream | EFileRead | EFileShareAny)); | 
|         |   2323 //                CleanupClosePushL(inputFile); | 
|         |   2324 // | 
|         |   2325 //                CEZFileToGZip* gZip = CEZFileToGZip::NewLC(iFs, targetEntry, inputFile); | 
|         |   2326 // | 
|         |   2327 //                while (gZip->DeflateL()) | 
|         |   2328 //                    ; | 
|         |   2329 // | 
|         |   2330 //                CleanupStack::PopAndDestroy(2); //inputFile, gZip | 
|         |   2331 //                ); | 
|         |   2332 // | 
|         |   2333 //             if (err == KErrNone) | 
|         |   2334 //                { | 
|         |   2335 //                _LIT(KMessage, "%S created succesfully"); | 
|         |   2336 //                TFileName noteMsg; | 
|         |   2337 //                noteMsg.Format(KMessage, &targetEntryShort); | 
|         |   2338 // | 
|         |   2339 //                iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg); | 
|         |   2340 //                } | 
|         |   2341 //             else | 
|         |   2342 //                { | 
|         |   2343 //                _LIT(KMessage, "Unable to create %S"); | 
|         |   2344 //                TFileName noteMsg; | 
|         |   2345 //                noteMsg.Format(KMessage, &targetEntryShort); | 
|         |   2346 // | 
|         |   2347 //                iEngine->FileBrowserUI()->ShowErrorNote(noteMsg); | 
|         |   2348 //                } | 
|         |   2349 // | 
|         |   2350 //            RefreshViewL(); | 
|         |   2351 //            } | 
|         |   2352 //        } | 
|         |   2353 // | 
|         |   2354 //    CleanupStack::PopAndDestroy(); //entries | 
|         |   2355     } | 
|         |   2356  | 
|         |   2357 // -------------------------------------------------------------------------------------------- | 
|         |   2358  | 
|         |   2359 void CFileBrowserFileUtils::DecompressL() | 
|         |   2360     { | 
|         |   2361 //    CFileEntryList* entries = new(ELeave) CFileEntryList(16); | 
|         |   2362 //    GetSelectedItemsOrCurrentItemL(entries); | 
|         |   2363 //    CleanupStack::PushL(entries); | 
|         |   2364 // | 
|         |   2365 //    for (TInt i=0; i<entries->Count(); i++) | 
|         |   2366 //        { | 
|         |   2367 //        TFileEntry fileEntry = entries->At(i); | 
|         |   2368 // | 
|         |   2369 //        TFileName sourceEntry = fileEntry.iPath; | 
|         |   2370 //        sourceEntry.Append(fileEntry.iEntry.iName); | 
|         |   2371 // | 
|         |   2372 //        TFileName targetEntry; | 
|         |   2373 //        TFileName targetEntryShort; | 
|         |   2374 // | 
|         |   2375 //        TInt sourceNameLen = fileEntry.iEntry.iName.Length(); | 
|         |   2376 //        TInt gZipExtLen = KGZipExt().Length(); | 
|         |   2377 // | 
|         |   2378 //        if (sourceNameLen > gZipExtLen && sourceEntry.Right(gZipExtLen).CompareF(KGZipExt) == 0) | 
|         |   2379 //            { | 
|         |   2380 //            targetEntry = sourceEntry.Left(sourceEntry.Length() - gZipExtLen); | 
|         |   2381 //            targetEntryShort = fileEntry.iEntry.iName.Left(sourceNameLen - gZipExtLen); | 
|         |   2382 // | 
|         |   2383 //            if (BaflUtils::FileExists(iFs, targetEntry)) | 
|         |   2384 //                { | 
|         |   2385 //                _LIT(KMessage, "%S already exists"); | 
|         |   2386 //                TFileName noteMsg; | 
|         |   2387 //                noteMsg.Format(KMessage, &targetEntryShort); | 
|         |   2388 // | 
|         |   2389 //                iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); | 
|         |   2390 //                } | 
|         |   2391 //            else | 
|         |   2392 //                { | 
|         |   2393 //                TRAPD(err, | 
|         |   2394 //                    RFile outputFile; | 
|         |   2395 //                    User::LeaveIfError(outputFile.Create(iFs, targetEntry, EFileStream | EFileWrite | EFileShareExclusive)); | 
|         |   2396 //                    CleanupClosePushL(outputFile); | 
|         |   2397 // | 
|         |   2398 //                    CEZGZipToFile* gZip = CEZGZipToFile::NewLC(iFs, sourceEntry, outputFile); | 
|         |   2399 // | 
|         |   2400 //                    while (gZip->InflateL()) | 
|         |   2401 //                        ; | 
|         |   2402 // | 
|         |   2403 //                    CleanupStack::PopAndDestroy(2); //outputFile, gZip | 
|         |   2404 //                    ); | 
|         |   2405 // | 
|         |   2406 //                 if (err == KErrNone) | 
|         |   2407 //                    { | 
|         |   2408 //                    _LIT(KMessage, "%S decompressed succesfully"); | 
|         |   2409 //                    TFileName noteMsg; | 
|         |   2410 //                    noteMsg.Format(KMessage, &fileEntry.iEntry.iName); | 
|         |   2411 // | 
|         |   2412 //                    iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg); | 
|         |   2413 //                    } | 
|         |   2414 //                 else | 
|         |   2415 //                    { | 
|         |   2416 //                    _LIT(KMessage, "Unable to decompress %S"); | 
|         |   2417 //                    TFileName noteMsg; | 
|         |   2418 //                    noteMsg.Format(KMessage, &fileEntry.iEntry.iName); | 
|         |   2419 // | 
|         |   2420 //                    iEngine->FileBrowserUI()->ShowErrorNote(noteMsg); | 
|         |   2421 //                    } | 
|         |   2422 // | 
|         |   2423 //                RefreshViewL(); | 
|         |   2424 //                } | 
|         |   2425 //            } | 
|         |   2426 //        else | 
|         |   2427 //            { | 
|         |   2428 //            _LIT(KMessage, "%S does not have %S extension"); | 
|         |   2429 //            TFileName noteMsg; | 
|         |   2430 //            noteMsg.Format(KMessage, &fileEntry.iEntry.iName, &KGZipExt); | 
|         |   2431 // | 
|         |   2432 //            iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); | 
|         |   2433 //            } | 
|         |   2434 //        } | 
|         |   2435 // | 
|         |   2436 //    CleanupStack::PopAndDestroy(); //entries | 
|         |   2437     } | 
|         |   2438  | 
|         |   2439 // -------------------------------------------------------------------------------------------- | 
|         |   2440  | 
|         |   2441 bool CFileBrowserFileUtils::PropertiesL(TInt aCurrentItemIndex, CDesCArray* entryLines, TFileName &titleText) | 
|         |   2442     { | 
|         |   2443  | 
|         |   2444     TBool showDialog(EFalse); | 
|         |   2445      | 
|         |   2446     _LIT(KPropertiesEntryStr,       "%S\t%S"); | 
|         |   2447     _LIT(KPropertiesEntryInt,       "%S\t%d"); | 
|         |   2448     _LIT(KPropertiesEntryUintHex,   "%S\t0x%x"); | 
|         |   2449      | 
|         |   2450     _LIT(KDateFormat,               "%D%M%Y%/0%1%/1%2%/2%3%/3"); | 
|         |   2451     _LIT(KTimeFormat,               "%-B%:0%J%:1%T%:2%S%:3%+B"); | 
|         |   2452      | 
|         |   2453     _LIT(KMediaType,                "Media"); | 
|         |   2454     _LIT(KAttributes,               "Atts"); | 
|         |   2455     _LIT(KVolumeName,               "Name"); | 
|         |   2456     _LIT(KUniqueID,                 "ID"); | 
|         |   2457     _LIT(KNumberOfEntries,          "Entries"); | 
|         |   2458     _LIT(KNumberOfFiles,            "Files"); | 
|         |   2459     _LIT(KUsed,                     "Used (B)"); | 
|         |   2460     _LIT(KFree,                     "Free (B)"); | 
|         |   2461     _LIT(KSize,                     "Size (B)"); | 
|         |   2462     _LIT(KPath,                     "Path"); | 
|         |   2463     _LIT(KDate,                     "Date"); | 
|         |   2464     _LIT(KTime,                     "Time"); | 
|         |   2465     _LIT(KMimeType,                 "Mime"); | 
|         |   2466     _LIT(KOpensWith,                "Opens"); | 
|         |   2467   | 
|         |   2468  | 
|         |   2469     // create an array for the items | 
|         |   2470 //    CDesCArray* entryLines = new(ELeave) CDesCArrayFlat(16); | 
|         |   2471 //    CleanupStack::PushL(entryLines); | 
|         |   2472 //    TFileName titleText; | 
|         |   2473      | 
|         |   2474     // just get current item | 
|         |   2475 //    TInt currentItemIndex = iEngine->QueryCurrentItemIndex(); | 
|         |   2476      | 
|         |   2477     if (IsDriveListViewActive() && iDriveEntryList->Count() > aCurrentItemIndex && aCurrentItemIndex >= 0) | 
|         |   2478         { | 
|         |   2479         // it is a drive entry | 
|         |   2480         TDriveEntry driveEntry = iDriveEntryList->At(aCurrentItemIndex); | 
|         |   2481         TFileName textEntry; | 
|         |   2482          | 
|         |   2483         // set title | 
|         |   2484         titleText.Append(driveEntry.iLetter); | 
|         |   2485         titleText.Append(_L(":")); | 
|         |   2486          | 
|         |   2487         // media type | 
|         |   2488         textEntry.Format(KPropertiesEntryStr, &KMediaType, &driveEntry.iMediaTypeDesc); | 
|         |   2489         entryLines->AppendL(textEntry); | 
|         |   2490  | 
|         |   2491         // attributes | 
|         |   2492         textEntry.Format(KPropertiesEntryStr, &KAttributes, &driveEntry.iAttributesDesc); | 
|         |   2493         entryLines->AppendL(textEntry); | 
|         |   2494  | 
|         |   2495         // volume name | 
|         |   2496         if (driveEntry.iVolumeInfo.iName.Length()) | 
|         |   2497             { | 
|         |   2498             textEntry.Format(KPropertiesEntryStr, &KVolumeName, &driveEntry.iVolumeInfo.iName); | 
|         |   2499             entryLines->AppendL(textEntry); | 
|         |   2500             } | 
|         |   2501  | 
|         |   2502         // unique id | 
|         |   2503         textEntry.Format(KPropertiesEntryUintHex, &KUniqueID, driveEntry.iVolumeInfo.iUniqueID); | 
|         |   2504         entryLines->AppendL(textEntry); | 
|         |   2505          | 
|         |   2506         // number of files | 
|         |   2507         if (iEngine->Settings().iShowSubDirectoryInfo) | 
|         |   2508             { | 
|         |   2509             iFindFileEntryList->Reset(); | 
|         |   2510              | 
|         |   2511             TBuf<10> driveRoot; | 
|         |   2512             driveRoot.Append(driveEntry.iLetter); | 
|         |   2513             driveRoot.Append(_L(":\\")); | 
|         |   2514  | 
|         |   2515             DoFindFiles(_L("*"), driveRoot); | 
|         |   2516             DoFindFilesRecursiveL(_L("*"), driveRoot); | 
|         |   2517              | 
|         |   2518             textEntry.Format(KPropertiesEntryInt, &KNumberOfFiles, iFindFileEntryList->Count()); | 
|         |   2519             entryLines->AppendL(textEntry); | 
|         |   2520              | 
|         |   2521             iFindFileEntryList->Reset(); | 
|         |   2522             } | 
|         |   2523        | 
|         |   2524         // used | 
|         |   2525         TBuf<32> usedBuf; | 
|         |   2526         usedBuf.AppendNum(driveEntry.iVolumeInfo.iSize-driveEntry.iVolumeInfo.iFree, TRealFormat(KDefaultRealWidth, 0)); | 
|         |   2527         textEntry.Format(KPropertiesEntryStr, &KUsed, &usedBuf); | 
|         |   2528         entryLines->AppendL(textEntry);         | 
|         |   2529  | 
|         |   2530         // free | 
|         |   2531         TBuf<32> freeBuf; | 
|         |   2532         freeBuf.AppendNum(driveEntry.iVolumeInfo.iFree, TRealFormat(KDefaultRealWidth, 0)); | 
|         |   2533         textEntry.Format(KPropertiesEntryStr, &KFree, &freeBuf); | 
|         |   2534         entryLines->AppendL(textEntry); | 
|         |   2535                  | 
|         |   2536         // size | 
|         |   2537         TBuf<32> sizeBuf; | 
|         |   2538         sizeBuf.AppendNum(driveEntry.iVolumeInfo.iSize, TRealFormat(KDefaultRealWidth, 0)); | 
|         |   2539         textEntry.Format(KPropertiesEntryStr, &KSize, &sizeBuf); | 
|         |   2540         entryLines->AppendL(textEntry);    | 
|         |   2541  | 
|         |   2542         showDialog = ETrue; | 
|         |   2543         } | 
|         |   2544      | 
|         |   2545     else if (iFileEntryList->Count() > aCurrentItemIndex && aCurrentItemIndex >= 0) | 
|         |   2546         { | 
|         |   2547         // it is a file or a directory entry | 
|         |   2548         TFileEntry fileEntry = iFileEntryList->At(aCurrentItemIndex); | 
|         |   2549         TFileName textEntry; | 
|         |   2550          | 
|         |   2551         // set title | 
|         |   2552         titleText.Append(fileEntry.iEntry.iName); | 
|         |   2553          | 
|         |   2554         // path | 
|         |   2555         textEntry.Format(KPropertiesEntryStr, &KPath, &fileEntry.iPath); | 
|         |   2556         entryLines->AppendL(textEntry); | 
|         |   2557  | 
|         |   2558         // date | 
|         |   2559         TTime entryModified = fileEntry.iEntry.iModified; | 
|         |   2560          | 
|         |   2561         // convert from universal time | 
|         |   2562         if ( iTz.ConvertToLocalTime( entryModified ) == KErrNone ) | 
|         |   2563             { | 
|         |   2564             entryModified = fileEntry.iEntry.iModified; // use universal time | 
|         |   2565             } | 
|         |   2566          | 
|         |   2567         TBuf<32> dateBuf; | 
|         |   2568         entryModified.FormatL(dateBuf, KDateFormat); | 
|         |   2569         textEntry.Format(KPropertiesEntryStr, &KDate, &dateBuf); | 
|         |   2570         entryLines->AppendL(textEntry); | 
|         |   2571  | 
|         |   2572         // time | 
|         |   2573         TBuf<32> timeBuf; | 
|         |   2574         entryModified.FormatL(timeBuf, KTimeFormat); | 
|         |   2575         textEntry.Format(KPropertiesEntryStr, &KTime, &timeBuf); | 
|         |   2576         entryLines->AppendL(textEntry); | 
|         |   2577  | 
|         |   2578         if (!fileEntry.iEntry.IsDir()) | 
|         |   2579             { | 
|         |   2580             // size | 
|         |   2581             TBuf<32> sizeBuf; | 
|         |   2582             sizeBuf.AppendNum(fileEntry.iEntry.iSize, TRealFormat(KDefaultRealWidth, 0)); | 
|         |   2583             textEntry.Format(KPropertiesEntryStr, &KSize, &sizeBuf); | 
|         |   2584             entryLines->AppendL(textEntry);             | 
|         |   2585             } | 
|         |   2586         else if (fileEntry.iEntry.IsDir() && iEngine->Settings().iShowSubDirectoryInfo) | 
|         |   2587             { | 
|         |   2588             iFindFileEntryList->Reset(); | 
|         |   2589              | 
|         |   2590             TFileName fullPath; | 
|         |   2591             fullPath.Append(fileEntry.iPath); | 
|         |   2592             fullPath.Append(fileEntry.iEntry.iName); | 
|         |   2593             fullPath.Append(_L("\\")); | 
|         |   2594              | 
|         |   2595             // number of entries | 
|         |   2596             CDir* subDir = NULL; | 
|         |   2597             if (iFs.GetDir(fullPath, KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone) | 
|         |   2598                 { | 
|         |   2599                 CleanupStack::PushL(subDir); | 
|         |   2600                 textEntry.Format(KPropertiesEntryInt, &KNumberOfEntries, subDir->Count()); | 
|         |   2601                 entryLines->AppendL(textEntry); | 
|         |   2602                 CleanupStack::PopAndDestroy(); //subDir  | 
|         |   2603                 } | 
|         |   2604              | 
|         |   2605             // number of files | 
|         |   2606             DoFindFiles(_L("*"), fullPath); | 
|         |   2607             DoFindFilesRecursiveL(_L("*"), fullPath); | 
|         |   2608             textEntry.Format(KPropertiesEntryInt, &KNumberOfFiles, iFindFileEntryList->Count()); | 
|         |   2609             entryLines->AppendL(textEntry); | 
|         |   2610              | 
|         |   2611             // size | 
|         |   2612             TInt64 size(0); | 
|         |   2613             for (TInt i=0; i<iFindFileEntryList->Count(); i++) | 
|         |   2614                 { | 
|         |   2615                 TFileEntry fileEntry = iFindFileEntryList->At(i); | 
|         |   2616                 size += fileEntry.iEntry.iSize; | 
|         |   2617                 } | 
|         |   2618              | 
|         |   2619             TBuf<32> sizeBuf; | 
|         |   2620             sizeBuf.AppendNum(size, TRealFormat(KDefaultRealWidth, 0)); | 
|         |   2621             textEntry.Format(KPropertiesEntryStr, &KSize, &sizeBuf); | 
|         |   2622             entryLines->AppendL(textEntry);  | 
|         |   2623              | 
|         |   2624             iFindFileEntryList->Reset();             | 
|         |   2625             } | 
|         |   2626          | 
|         |   2627         // attributes | 
|         |   2628         TBuf<32> attBuf; | 
|         |   2629         if (fileEntry.iEntry.IsArchive()) | 
|         |   2630             attBuf.Append(_L("Arc ")); | 
|         |   2631         if (fileEntry.iEntry.IsHidden()) | 
|         |   2632             attBuf.Append(_L("Hid ")); | 
|         |   2633         if (fileEntry.iEntry.IsReadOnly()) | 
|         |   2634             attBuf.Append(_L("R/O ")); | 
|         |   2635         if (fileEntry.iEntry.IsSystem()) | 
|         |   2636             attBuf.Append(_L("Sys")); | 
|         |   2637         textEntry.Format(KPropertiesEntryStr, &KAttributes, &attBuf); | 
|         |   2638         entryLines->AppendL(textEntry);             | 
|         |   2639  | 
|         |   2640         if (!fileEntry.iEntry.IsDir()) | 
|         |   2641             { | 
|         |   2642             // mime type | 
|         |   2643             TFileName fullPath = fileEntry.iPath; | 
|         |   2644             fullPath.Append(fileEntry.iEntry.iName); | 
|         |   2645             TDataType dataType; | 
|         |   2646             TUid appUid; | 
|         |   2647             if (iEngine->LsSession().AppForDocument(fullPath, appUid, dataType) == KErrNone) | 
|         |   2648                 { | 
|         |   2649                 TBuf<128> mimeTypeBuf; | 
|         |   2650                 mimeTypeBuf.Copy(dataType.Des8()); | 
|         |   2651                 if (mimeTypeBuf == KNullDesC) | 
|         |   2652                     mimeTypeBuf.Copy(_L("N/A")); | 
|         |   2653                 textEntry.Format(KPropertiesEntryStr, &KMimeType, &mimeTypeBuf); | 
|         |   2654                 entryLines->AppendL(textEntry);  | 
|         |   2655                 } | 
|         |   2656  | 
|         |   2657             // opens with | 
|         |   2658             TApaAppInfo appInfo; | 
|         |   2659             if (iEngine->LsSession().GetAppInfo(appInfo, appUid) == KErrNone) | 
|         |   2660                 { | 
|         |   2661                 TFileName opensWithBuf; | 
|         |   2662                 _LIT(KOpensWithFormat, "%S (0x%08X)"); | 
|         |   2663                 opensWithBuf.Format(KOpensWithFormat, &appInfo.iCaption, appInfo.iUid); | 
|         |   2664                 textEntry.Format(KPropertiesEntryStr, &KOpensWith, &opensWithBuf); | 
|         |   2665                 entryLines->AppendL(textEntry);  | 
|         |   2666                 } | 
|         |   2667             } | 
|         |   2668          | 
|         |   2669         showDialog = ETrue; | 
|         |   2670         }    | 
|         |   2671     return showDialog; | 
|         |   2672  | 
|         |   2673 //    if (showDialog) | 
|         |   2674 //        { | 
|         |   2675 //        CAknSingleHeadingPopupMenuStyleListBox* listBox = new(ELeave) CAknSingleHeadingPopupMenuStyleListBox; | 
|         |   2676 //        CleanupStack::PushL(listBox); | 
|         |   2677 // | 
|         |   2678 //        CAknPopupList* popupList = CAknPopupList::NewL(listBox, R_AVKON_SOFTKEYS_OK_EMPTY, AknPopupLayouts::EMenuDoubleWindow); | 
|         |   2679 //        CleanupStack::PushL(popupList); | 
|         |   2680 // | 
|         |   2681 //        listBox->ConstructL(popupList, CEikListBox::ELeftDownInViewRect); | 
|         |   2682 //        listBox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue); | 
|         |   2683 //        listBox->CreateScrollBarFrameL(ETrue); | 
|         |   2684 //        listBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); | 
|         |   2685 //        listBox->Model()->SetItemTextArray(entryLines); | 
|         |   2686 //        listBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray); | 
|         |   2687 //        listBox->HandleItemAdditionL(); | 
|         |   2688 // | 
|         |   2689 //        popupList->SetTitleL(titleText); | 
|         |   2690 //        popupList->ExecuteLD(); | 
|         |   2691 // | 
|         |   2692 //        CleanupStack::Pop(); // popupList | 
|         |   2693 //        CleanupStack::PopAndDestroy(); // listBox | 
|         |   2694 //        } | 
|         |   2695 // | 
|         |   2696 //        CleanupStack::PopAndDestroy(); //entryLines | 
|         |   2697 	} | 
|         |   2698      | 
|         |   2699 // -------------------------------------------------------------------------------------------- | 
|         |   2700  | 
|         |   2701 void CFileBrowserFileUtils::OpenWithApparcL(TFileName aFileName) | 
|         |   2702     { | 
|         |   2703         | 
|         |   2704         TFileName fullPath = aFileName; | 
|         |   2705         TInt err1(KErrNone), err2(KErrNone); | 
|         |   2706         TUid appUid; | 
|         |   2707         TDataType dataType; | 
|         |   2708         TBool isProgram; | 
|         |   2709          | 
|         |   2710 	 | 
|         |   2711         err1 = iEngine->LsSession().AppForDocument(fullPath, appUid, dataType); | 
|         |   2712         err2 = iEngine->LsSession().IsProgram(fullPath, isProgram); | 
|         |   2713          | 
|         |   2714         if (err1 == KErrNone && err2 == KErrNone) | 
|         |   2715             { | 
|         |   2716             if (appUid != KNullUid) | 
|         |   2717                 { | 
|         |   2718                 // found an app, run using it | 
|         |   2719                 TApaTaskList taskList(CEikonEnv::Static()->WsSession()); | 
|         |   2720                 TApaTask task = (taskList.FindApp(appUid)); | 
|         |   2721                 if (task.Exists()) | 
|         |   2722                     { | 
|         |   2723                     User::LeaveIfError(task.SwitchOpenFile(fullPath)); | 
|         |   2724                     task.BringToForeground(); | 
|         |   2725                     } | 
|         |   2726                 else | 
|         |   2727                     { | 
|         |   2728                     TThreadId id; | 
|         |   2729                     iEngine->LsSession().StartDocument(fullPath, appUid, id, RApaLsSession::ESwitchFiles); | 
|         |   2730                     } | 
|         |   2731                 } | 
|         |   2732             else if (isProgram) | 
|         |   2733                 { | 
|         |   2734                 LaunchProgramL(fullPath); | 
|         |   2735                 }             | 
|         |   2736             } | 
|         |   2737         //}    | 
|         |   2738     } | 
|         |   2739 	 | 
|         |   2740 // -------------------------------------------------------------------------------------------- | 
|         |   2741  | 
|         |   2742 void CFileBrowserFileUtils::HandleServerAppExit(TInt aReason) | 
|         |   2743 	{ | 
|         |   2744 //	if (iOpenFileService) | 
|         |   2745 //		{ | 
|         |   2746 //		delete iOpenFileService; | 
|         |   2747 //		iOpenFileService = NULL; | 
|         |   2748 //		} | 
|         |   2749 	MAknServerAppExitObserver::HandleServerAppExit(aReason); | 
|         |   2750 	} | 
|         |   2751  | 
|         |   2752 // -------------------------------------------------------------------------------------------- | 
|         |   2753  | 
|         |   2754 void CFileBrowserFileUtils::OpenWithDocHandlerL(TFileName aFileName, TBool aEmbed) | 
|         |   2755     { | 
|         |   2756         TFileName fullPath = aFileName; | 
|         |   2757         RFile sharableFile; | 
|         |   2758         iDocHandler->OpenTempFileL(fullPath, sharableFile); | 
|         |   2759         CleanupClosePushL(sharableFile); | 
|         |   2760         TDataType dataType; | 
|         |   2761         if (aEmbed)  | 
|         |   2762             { | 
|         |   2763     	    iDocHandler->OpenFileEmbeddedL(sharableFile, dataType); | 
|         |   2764             } | 
|         |   2765         else | 
|         |   2766             { | 
|         |   2767     	    iDocHandler->OpenFileL(sharableFile, dataType); | 
|         |   2768             } | 
|         |   2769         CleanupStack::PopAndDestroy();  //sharableFile | 
|         |   2770     //    }    | 
|         |   2771     } | 
|         |   2772  | 
|         |   2773 	// -------------------------------------------------------------------------------------------- | 
|         |   2774  | 
|         |   2775 void CFileBrowserFileUtils::OpenWithFileServiceL(TInt aCurrentItemIndex) | 
|         |   2776     { | 
|         |   2777     if (iFileEntryList->Count() > aCurrentItemIndex && aCurrentItemIndex >= 0) | 
|         |   2778         { | 
|         |   2779         TFileEntry fileEntry = iFileEntryList->At(aCurrentItemIndex); | 
|         |   2780          | 
|         |   2781         TFileName fullPath = fileEntry.iPath; | 
|         |   2782         fullPath.Append(fileEntry.iEntry.iName); | 
|         |   2783  | 
|         |   2784     	TBool itemSelected(EFalse); | 
|         |   2785         RFile sharableFile; | 
|         |   2786 //        TUid appUidExtracted; | 
|         |   2787          | 
|         |   2788         TRAPD(err, | 
|         |   2789             | 
|         |   2790         	// use doc handler to get a sharable file handle | 
|         |   2791             iDocHandler->OpenTempFileL(fullPath, sharableFile); | 
|         |   2792             CleanupClosePushL(sharableFile); | 
|         |   2793              | 
|         |   2794             // find the data type | 
|         |   2795             TDataRecognitionResult dataType; | 
|         |   2796         	User::LeaveIfError(iEngine->LsSession().RecognizeData(sharableFile, dataType)); | 
|         |   2797  | 
|         |   2798         	// get all apps that support OpenFileService for this datatype | 
|         |   2799         	CApaAppServiceInfoArray* apps = iEngine->LsSession().GetServiceImplementationsLC(KOpenServiceUid, dataType.iDataType); | 
|         |   2800         	TArray<TApaAppServiceInfo> appServiceInfos = apps->Array(); | 
|         |   2801     	 | 
|         |   2802         	if (appServiceInfos.Count() > 0) | 
|         |   2803         		{ | 
|         |   2804         		// build an array of the app names | 
|         |   2805         		CDesCArray* names = new (ELeave) CDesCArrayFlat(16); | 
|         |   2806         		CleanupStack::PushL(names); | 
|         |   2807         		for (TInt ii=0; ii<appServiceInfos.Count(); ii++) | 
|         |   2808         			{ | 
|         |   2809         			TUid appUid = appServiceInfos[ii].Uid(); | 
|         |   2810         			TApaAppInfo appInfo; | 
|         |   2811         			if (iEngine->LsSession().GetAppInfo(appInfo, appUid) == KErrNone) | 
|         |   2812         				{ | 
|         |   2813         				names->AppendL(appInfo.iCaption); | 
|         |   2814         				} | 
|         |   2815         			else | 
|         |   2816         				{ | 
|         |   2817         				TBuf<10> buf; | 
|         |   2818         				buf.Format(_L("0x%08x"), appUid); | 
|         |   2819         				names->AppendL(buf); | 
|         |   2820         				} | 
|         |   2821         			} | 
|         |   2822     		 | 
|         |   2823         		// use a list query to select the app | 
|         |   2824 //        		TInt index(0); | 
|         |   2825 //        		CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog(&index); | 
|         |   2826 //        		dlg->PrepareLC(R_APP_SELECTION_QUERY); | 
|         |   2827 //        		dlg->SetItemTextArray(names); | 
|         |   2828 //        		dlg->SetOwnershipType(ELbmDoesNotOwnItemArray); | 
|         |   2829 // | 
|         |   2830 //        		if(dlg->RunLD()) | 
|         |   2831 //        			{ | 
|         |   2832 //        			// extract the chosen UID | 
|         |   2833 //        			appUidExtracted = appServiceInfos[index].Uid(); | 
|         |   2834 //        			itemSelected = ETrue; | 
|         |   2835 //        			} | 
|         |   2836     		 | 
|         |   2837         		CleanupStack::PopAndDestroy(); // names | 
|         |   2838         		} | 
|         |   2839  | 
|         |   2840             if (itemSelected) | 
|         |   2841                 { | 
|         |   2842                 // start OpenFileService for the selected app | 
|         |   2843                 CAiwGenericParamList& paramList = iDocHandler->InParamListL(); | 
|         |   2844                  | 
|         |   2845 //                if (iOpenFileService) | 
|         |   2846 //                    { | 
|         |   2847 //                    delete iOpenFileService; | 
|         |   2848 //                    iOpenFileService = NULL; | 
|         |   2849 //                    } | 
|         |   2850  | 
|         |   2851 //                iOpenFileService = CAknOpenFileService::NewL(appUidExtracted, sharableFile, this, ¶mList); | 
|         |   2852                 } | 
|         |   2853  | 
|         |   2854             CleanupStack::PopAndDestroy(2); // sharableFile, apps | 
|         |   2855  | 
|         |   2856             ); // TRAPD | 
|         |   2857  | 
|         |   2858         if (err != KErrNone) | 
|         |   2859             { | 
|         |   2860             _LIT(KMessage, "No file service available for %S"); | 
|         |   2861             TFileName noteMsg; | 
|         |   2862             noteMsg.Format(KMessage, &fileEntry.iEntry.iName); | 
|         |   2863              | 
|         |   2864             iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); | 
|         |   2865             } | 
|         |   2866         }    | 
|         |   2867     } | 
|         |   2868      | 
|         |   2869 // -------------------------------------------------------------------------------------------- | 
|         |   2870  | 
|         |   2871 TBool CFileBrowserFileUtils::FileExists(const TDesC& aPath) | 
|         |   2872     { | 
|         |   2873     return BaflUtils::FileExists(iFs, aPath); | 
|         |   2874     } | 
|         |   2875  | 
|         |   2876 // -------------------------------------------------------------------------------------------- | 
|         |   2877  | 
|         |   2878 TInt CFileBrowserFileUtils::LaunchProgramL(const TDesC& aPath) | 
|         |   2879     { | 
|         |   2880     CApaCommandLine* commandLine = CApaCommandLine::NewLC(); | 
|         |   2881     commandLine->SetExecutableNameL(aPath); | 
|         |   2882     commandLine->SetCommandL(EApaCommandRun); | 
|         |   2883     TInt err = iEngine->LsSession().StartApp(*commandLine); | 
|         |   2884     CleanupStack::PopAndDestroy(); //commandLine | 
|         |   2885     return err; | 
|         |   2886     } | 
|         |   2887  | 
|         |   2888 // -------------------------------------------------------------------------------------------- | 
|         |   2889  | 
|         |   2890 void CFileBrowserFileUtils::MemoryInfoPopupL() | 
|         |   2891     { | 
|         |   2892     _LIT(KUsedBytesEntry, "Used: %S bytes\n"); | 
|         |   2893     _LIT(KFreeBytesEntry, "Free: %S bytes\n"); | 
|         |   2894     _LIT(KSizeBytesEntry, "Size: %S bytes\n"); | 
|         |   2895          | 
|         |   2896     HBufC* messageBuf = HBufC::NewLC(2048); | 
|         |   2897     TPtr messagePtr = messageBuf->Des(); | 
|         |   2898     TBuf<128> entryLine; | 
|         |   2899  | 
|         |   2900     // RAM | 
|         |   2901     TMemoryInfoV1Buf ramMemory; | 
|         |   2902     UserHal::MemoryInfo(ramMemory); | 
|         |   2903     messagePtr.Append(_L("RAM\n")); | 
|         |   2904  | 
|         |   2905     // used | 
|         |   2906     TBuf<32> usedBuf; | 
|         |   2907     usedBuf.AppendNum(ramMemory().iMaxFreeRamInBytes-ramMemory().iFreeRamInBytes, TRealFormat(KDefaultRealWidth, 0)); | 
|         |   2908     entryLine.Format(KUsedBytesEntry, &usedBuf); | 
|         |   2909     messagePtr.Append(entryLine);         | 
|         |   2910  | 
|         |   2911     // free | 
|         |   2912     TBuf<32> freeBuf; | 
|         |   2913     freeBuf.AppendNum(ramMemory().iFreeRamInBytes, TRealFormat(KDefaultRealWidth, 0)); | 
|         |   2914     entryLine.Format(KFreeBytesEntry, &freeBuf); | 
|         |   2915     messagePtr.Append(entryLine); | 
|         |   2916              | 
|         |   2917     // size | 
|         |   2918     TBuf<32> sizeBuf; | 
|         |   2919     sizeBuf.AppendNum(ramMemory().iMaxFreeRamInBytes, TRealFormat(KDefaultRealWidth, 0)); | 
|         |   2920     entryLine.Format(KSizeBytesEntry, &sizeBuf); | 
|         |   2921     messagePtr.Append(entryLine);  | 
|         |   2922      | 
|         |   2923     // All drives | 
|         |   2924     for (TInt i=0; i<iDriveEntryList->Count(); i++) | 
|         |   2925         { | 
|         |   2926         TDriveEntry driveEntry = iDriveEntryList->At(i); | 
|         |   2927  | 
|         |   2928         messagePtr.Append(_L("\n")); | 
|         |   2929         messagePtr.Append(driveEntry.iLetter); | 
|         |   2930         messagePtr.Append(_L(":\n")); | 
|         |   2931  | 
|         |   2932         // used | 
|         |   2933         TBuf<32> usedBuf; | 
|         |   2934         usedBuf.AppendNum(driveEntry.iVolumeInfo.iSize-driveEntry.iVolumeInfo.iFree, TRealFormat(KDefaultRealWidth, 0)); | 
|         |   2935         entryLine.Format(KUsedBytesEntry, &usedBuf); | 
|         |   2936         messagePtr.Append(entryLine);         | 
|         |   2937  | 
|         |   2938         // free | 
|         |   2939         TBuf<32> freeBuf; | 
|         |   2940         freeBuf.AppendNum(driveEntry.iVolumeInfo.iFree, TRealFormat(KDefaultRealWidth, 0)); | 
|         |   2941         entryLine.Format(KFreeBytesEntry, &freeBuf); | 
|         |   2942         messagePtr.Append(entryLine); | 
|         |   2943                  | 
|         |   2944         // size | 
|         |   2945         TBuf<32> sizeBuf; | 
|         |   2946         sizeBuf.AppendNum(driveEntry.iVolumeInfo.iSize, TRealFormat(KDefaultRealWidth, 0)); | 
|         |   2947         entryLine.Format(KSizeBytesEntry, &sizeBuf); | 
|         |   2948         messagePtr.Append(entryLine);  | 
|         |   2949         } | 
|         |   2950  | 
|         |   2951 //    CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog; | 
|         |   2952 //    dialog->PrepareLC(R_MEMORYINFO_DIALOG); | 
|         |   2953 //    dialog->SetMessageTextL(messagePtr); | 
|         |   2954 //    dialog->RunLD(); | 
|         |   2955      | 
|         |   2956     CleanupStack::PopAndDestroy(); //messageBuf | 
|         |   2957     } | 
|         |   2958  | 
|         |   2959 // -------------------------------------------------------------------------------------------- | 
|         |   2960  | 
|         |   2961 void CFileBrowserFileUtils::ShowFileCheckSumsL(TInt aCurrentItemIndex, TInt aType) | 
|         |   2962     { | 
|         |   2963     if (iFileEntryList->Count() > aCurrentItemIndex && aCurrentItemIndex >= 0) | 
|         |   2964         { | 
|         |   2965         TFileEntry fileEntry = iFileEntryList->At(aCurrentItemIndex); | 
|         |   2966         TFileName fullPath = fileEntry.iPath; | 
|         |   2967         fullPath.Append(fileEntry.iEntry.iName); | 
|         |   2968          | 
|         |   2969         // try to open the file for reading | 
|         |   2970         RFile fileP; | 
|         |   2971         TInt err = fileP.Open(iEngine->EikonEnv()->FsSession(), fullPath, EFileRead|EFileShareReadersOnly); | 
|         |   2972          | 
|         |   2973         if (err == KErrNone) | 
|         |   2974             { | 
|         |   2975             CleanupClosePushL(fileP); | 
|         |   2976  | 
|         |   2977             TBuf<128> checkSum; | 
|         |   2978             HBufC* messageBuf = HBufC::NewLC(2048); | 
|         |   2979             TPtr messagePtr = messageBuf->Des(); | 
|         |   2980              | 
|         |   2981             // get MD5 checksum | 
|         |   2982             if (aType == EFileChecksumsMD5) | 
|         |   2983                 { | 
|         |   2984                 CMD5* md5 = CMD5::NewL(); | 
|         |   2985                 CleanupStack::PushL(md5); | 
|         |   2986                 HBufC8* md5Buf = MessageDigestInHexLC(md5, fileP); | 
|         |   2987                 checkSum.Copy(*md5Buf); | 
|         |   2988                 messagePtr.Append(_L("MD5\n")); | 
|         |   2989                 messagePtr.Append(checkSum); | 
|         |   2990                 CleanupStack::PopAndDestroy(2); // md5, md5Buf | 
|         |   2991                 } | 
|         |   2992  | 
|         |   2993             // get MD2 checksum | 
|         |   2994             else if (aType == EFileChecksumsMD2) | 
|         |   2995                 {                 | 
|         |   2996                 CMD2* md2 = CMD2::NewL(); | 
|         |   2997                 CleanupStack::PushL(md2); | 
|         |   2998                 HBufC8* md2Buf = MessageDigestInHexLC(md2, fileP); | 
|         |   2999                 checkSum.Copy(*md2Buf); | 
|         |   3000                 messagePtr.Append(_L("MD2\n")); | 
|         |   3001                 messagePtr.Append(checkSum); | 
|         |   3002                 CleanupStack::PopAndDestroy(2); // md2, md2Buf | 
|         |   3003                 } | 
|         |   3004  | 
|         |   3005             // get SHA-1 checksum | 
|         |   3006             else if (aType == EFileChecksumsSHA1) | 
|         |   3007                 { | 
|         |   3008                 CSHA1* sha1 = CSHA1::NewL(); | 
|         |   3009                 CleanupStack::PushL(sha1); | 
|         |   3010                 HBufC8* sha1Buf = MessageDigestInHexLC(sha1, fileP); | 
|         |   3011                 checkSum.Copy(*sha1Buf); | 
|         |   3012                 messagePtr.Append(_L("SHA-1\n")); | 
|         |   3013                 messagePtr.Append(checkSum); | 
|         |   3014                 CleanupStack::PopAndDestroy(2); // sha1, sha1Buf | 
|         |   3015                 } | 
|         |   3016              | 
|         |   3017             else | 
|         |   3018                 { | 
|         |   3019                 User::Panic(_L("Inv.CS.Type"), 723); | 
|         |   3020                 } | 
|         |   3021                              | 
|         |   3022             // show dialog | 
|         |   3023             iEngine->FileBrowserUI()->ShowInformationNote(messagePtr, fileEntry.iEntry.iName); | 
|         |   3024  | 
|         |   3025             CleanupStack::PopAndDestroy(2); // messageBuf, fileP | 
|         |   3026             } | 
|         |   3027         else | 
|         |   3028             { | 
|         |   3029             // open failed, show an error note | 
|         |   3030             CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); | 
|         |   3031  | 
|         |   3032             iEngine->FileBrowserUI()->ShowErrorNote( | 
|         |   3033                     textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); | 
|         |   3034  | 
|         |   3035             CleanupStack::PopAndDestroy();  //textResolver | 
|         |   3036             } | 
|         |   3037         } | 
|         |   3038     } | 
|         |   3039  | 
|         |   3040 // -------------------------------------------------------------------------------------------- | 
|         |   3041  | 
|         |   3042 HBufC8* CFileBrowserFileUtils::MessageDigestInHexLC(CMessageDigest* aMD, RFile& aFile) | 
|         |   3043     { | 
|         |   3044     // seek to file start | 
|         |   3045     TInt startPos(0); | 
|         |   3046     aFile.Seek(ESeekStart, startPos); | 
|         |   3047  | 
|         |   3048     // create result buffer | 
|         |   3049     HBufC8* result = HBufC8::NewLC(128); | 
|         |   3050  | 
|         |   3051     const TInt KBufSize(1024); | 
|         |   3052     TInt fileSize(0); | 
|         |   3053     TInt fileOffset(0); | 
|         |   3054  | 
|         |   3055     // get file size | 
|         |   3056     aFile.Size(fileSize); | 
|         |   3057  | 
|         |   3058     HBufC8* buf = HBufC8::NewMaxLC(KBufSize); | 
|         |   3059     TPtr8 bufPtr(buf->Des()); | 
|         |   3060  | 
|         |   3061     // read to buffer | 
|         |   3062     while (fileOffset < fileSize - KBufSize) | 
|         |   3063         { | 
|         |   3064         aFile.Read(bufPtr, KBufSize); | 
|         |   3065         aMD->Hash(bufPtr); | 
|         |   3066         fileOffset += bufPtr.Length(); | 
|         |   3067         } | 
|         |   3068  | 
|         |   3069     aFile.Read(bufPtr, fileSize - fileOffset); | 
|         |   3070     bufPtr.SetLength(fileSize - fileOffset); | 
|         |   3071      | 
|         |   3072     // get final message digest | 
|         |   3073     TPtrC8 hashedSig(aMD->Final(bufPtr)); | 
|         |   3074      | 
|         |   3075     // change size of the result buffer | 
|         |   3076     result->ReAllocL(hashedSig.Length() * 2); | 
|         |   3077     TPtr8 resultPtr = result->Des(); | 
|         |   3078  | 
|         |   3079     // convert to hex format | 
|         |   3080     for (TInt i=0; i<hashedSig.Length(); i++) | 
|         |   3081         { | 
|         |   3082         resultPtr.AppendFormat(_L8("%+02x"), hashedSig[i]); | 
|         |   3083         } | 
|         |   3084                      | 
|         |   3085     CleanupStack::PopAndDestroy(); // buf | 
|         |   3086      | 
|         |   3087     return result; | 
|         |   3088     } | 
|         |   3089          | 
|         |   3090 // -------------------------------------------------------------------------------------------- | 
|         |   3091  | 
|         |   3092 void CFileBrowserFileUtils::SetErrRdL(TBool aEnable) | 
|         |   3093     { | 
|         |   3094     #ifndef FILEBROWSER_LITE | 
|         |   3095     if (iEngine->Settings().iBypassPlatformSecurity) | 
|         |   3096         { | 
|         |   3097         TInt err(KErrNone); | 
|         |   3098          | 
|         |   3099         if (aEnable) | 
|         |   3100             { | 
|         |   3101             // make sure that the directory exists | 
|         |   3102             iFileOps->MkDirAll(KErrRdPath);         | 
|         |   3103  | 
|         |   3104             // create the file | 
|         |   3105             err = iFileOps->CreateEmptyFile(KErrRdPath); | 
|         |   3106             } | 
|         |   3107         else     | 
|         |   3108             { | 
|         |   3109             // get TEntry of ErrRd | 
|         |   3110             TEntry entry; | 
|         |   3111             err = iFs.Entry(KErrRdPath, entry); | 
|         |   3112              | 
|         |   3113             if (err == KErrNone) | 
|         |   3114                 { | 
|         |   3115                 TFileEntry fileEntry; | 
|         |   3116                 fileEntry.iPath = KErrRdDir; | 
|         |   3117                 fileEntry.iEntry = entry; | 
|         |   3118                  | 
|         |   3119                 err = iFileOps->Delete(fileEntry);                 | 
|         |   3120                 } | 
|         |   3121             }         | 
|         |   3122  | 
|         |   3123         // update view | 
|         |   3124         RefreshViewL();  | 
|         |   3125      | 
|         |   3126         if (err == KErrNone)     | 
|         |   3127             { | 
|         |   3128             iEngine->FileBrowserUI()->ShowConfirmationNote(_L("State changed")); | 
|         |   3129             } | 
|         |   3130         else     | 
|         |   3131             { | 
|         |   3132             iEngine->FileBrowserUI()->ShowErrorNote(_L("Cannot change the state")); | 
|         |   3133             }         | 
|         |   3134         } | 
|         |   3135     else | 
|         |   3136         { | 
|         |   3137         iEngine->FileBrowserUI()->ShowInformationNote(_L("Enable \"bypass platform security\" from the settings first"), _L("")); | 
|         |   3138         } | 
|         |   3139     #else | 
|         |   3140         aEnable = aEnable; | 
|         |   3141         iEngine->FileBrowserUI()->ShowInformationNote(_L("Not supported in lite version"), _L("")); | 
|         |   3142     #endif | 
|         |   3143     } | 
|         |   3144  | 
|         |   3145 // -------------------------------------------------------------------------------------------- | 
|         |   3146  | 
|         |   3147 //void CFileBrowserFileUtils::EnableAvkonIconCacheL(TBool aEnable) | 
|         |   3148 //    { | 
|         |   3149 //#ifndef __SERIES60_30__ | 
|         |   3150 //    if (AknIconConfig::EnableAknIconSrvCache(aEnable) == KErrNone) | 
|         |   3151 //        { | 
|         |   3152 //        iEngine->FileBrowserUI()->ShowConfirmationNote(_L("State changed")); | 
|         |   3153 //        } | 
|         |   3154 //    else | 
|         |   3155 //        { | 
|         |   3156 //        iEngine->FileBrowserUI()->ShowErrorNote(_L("Unknown error occured")); | 
|         |   3157 //        } | 
|         |   3158 // #else | 
|         |   3159 //    aEnable = aEnable; | 
|         |   3160 //    iEngine->FileBrowserUI()->ShowInformationNote(_L("Not supported in S60 3.0"), _L("")); | 
|         |   3161 // #endif | 
|         |   3162 //  | 
|         |   3163 //    } | 
|         |   3164  | 
|         |   3165 // -------------------------------------------------------------------------------------------- | 
|         |   3166  | 
|         |   3167 void CFileBrowserFileUtils::SimulateLeaveL(TInt aLeaveCode) | 
|         |   3168     { | 
|         |   3169     User::Leave(aLeaveCode); | 
|         |   3170     } | 
|         |   3171  | 
|         |   3172 // -------------------------------------------------------------------------------------------- | 
|         |   3173  | 
|         |   3174 void CFileBrowserFileUtils::SimulatePanicL(const TDesC& aPanicCategory, TInt aPanicCode) | 
|         |   3175     { | 
|         |   3176     User::Panic(aPanicCategory, aPanicCode); | 
|         |   3177     } | 
|         |   3178  | 
|         |   3179 // -------------------------------------------------------------------------------------------- | 
|         |   3180  | 
|         |   3181 void CFileBrowserFileUtils::SimulateExceptionL(TInt aExceptionCode) | 
|         |   3182     { | 
|         |   3183     User::RaiseException((TExcType)aExceptionCode); | 
|         |   3184     } | 
|         |   3185  | 
|         |   3186 // -------------------------------------------------------------------------------------------- | 
|         |   3187  | 
|         |   3188 TUint32 CFileBrowserFileUtils::GetDebugMask() | 
|         |   3189     { | 
|         |   3190     return UserSvr::DebugMask(); | 
|         |   3191     } | 
|         |   3192  | 
|         |   3193 // -------------------------------------------------------------------------------------------- | 
|         |   3194  | 
|         |   3195 void CFileBrowserFileUtils::SetDebugMaskL(TUint32 aDbgMask) | 
|         |   3196     { | 
|         |   3197     User::SetDebugMask(aDbgMask); | 
|         |   3198     } | 
|         |   3199      | 
|         |   3200 // -------------------------------------------------------------------------------------------- | 
|         |   3201  | 
|         |   3202 void CFileBrowserFileUtils::WriteAllAppsL() | 
|         |   3203     { | 
|         |   3204     _LIT(KAllAppsFileName, "AllApps.txt"); | 
|         |   3205     TFileName allAppsPath = PathInfo::PhoneMemoryRootPath(); | 
|         |   3206     allAppsPath.Append(KAllAppsFileName); | 
|         |   3207  | 
|         |   3208     RFile file; | 
|         |   3209     if (file.Replace(iFs, allAppsPath, EFileWrite) == KErrNone) | 
|         |   3210         { | 
|         |   3211         CleanupClosePushL(file); | 
|         |   3212          | 
|         |   3213         CDesC8Array* appsArray = new(ELeave) CDesC8ArrayFlat(192); | 
|         |   3214         CleanupStack::PushL(appsArray); | 
|         |   3215          | 
|         |   3216         TBuf8<KMaxFileName> fileEntry; | 
|         |   3217         TBuf8<KMaxFileName> appFullPath; | 
|         |   3218         _LIT8(KAppEntryFormat, "%S (0x%08X)%S"); | 
|         |   3219         TApaAppInfo appInfo; | 
|         |   3220  | 
|         |   3221         iEngine->LsSession().GetAllApps();         | 
|         |   3222  | 
|         |   3223         while (iEngine->LsSession().GetNextApp(appInfo) == KErrNone) | 
|         |   3224             { | 
|         |   3225             appFullPath.Copy(appInfo.iFullName); | 
|         |   3226             fileEntry.Format(KAppEntryFormat, &appFullPath, appInfo.iUid, &KFileNewLine); | 
|         |   3227             appsArray->AppendL(fileEntry);     | 
|         |   3228             } | 
|         |   3229          | 
|         |   3230         appsArray->Sort(); | 
|         |   3231          | 
|         |   3232         for (TInt i=0; i<appsArray->Count(); i++) | 
|         |   3233             { | 
|         |   3234             file.Write(appsArray->MdcaPoint(i)); | 
|         |   3235             } | 
|         |   3236          | 
|         |   3237         CleanupStack::PopAndDestroy(2); //appsArray, file | 
|         |   3238          | 
|         |   3239         _LIT(KMessage, "App list written to %S"); | 
|         |   3240         TFileName noteMsg; | 
|         |   3241         noteMsg.Format(KMessage, &allAppsPath); | 
|         |   3242  | 
|         |   3243         iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg, ETrue); // NoTimeout | 
|         |   3244         } | 
|         |   3245     else | 
|         |   3246         { | 
|         |   3247         _LIT(KMessage, "Failed writing to %S"); | 
|         |   3248         TFileName noteMsg; | 
|         |   3249         noteMsg.Format(KMessage, &allAppsPath); | 
|         |   3250  | 
|         |   3251         iEngine->FileBrowserUI()->ShowErrorNote(noteMsg, ETrue); // NoTimeout | 
|         |   3252         }     | 
|         |   3253     } | 
|         |   3254  | 
|         |   3255 // -------------------------------------------------------------------------------------------- | 
|         |   3256  | 
|         |   3257 void CFileBrowserFileUtils::WriteAllFilesL() | 
|         |   3258     { | 
|         |   3259     _LIT(KAllFilesFileName, "AllFiles.txt"); | 
|         |   3260     TFileName allFilesPath = PathInfo::PhoneMemoryRootPath(); | 
|         |   3261     allFilesPath.Append(KAllFilesFileName); | 
|         |   3262  | 
|         |   3263     RFile file; | 
|         |   3264     if (file.Replace(iFs, allFilesPath, EFileWrite) == KErrNone) | 
|         |   3265         { | 
|         |   3266         CleanupClosePushL(file); | 
|         |   3267         iFindFileEntryList->Reset(); | 
|         |   3268          | 
|         |   3269         iEngine->EikonEnv()->BusyMsgL(_L("** Generating **"), TGulAlignment(EHCenterVTop)); | 
|         |   3270          | 
|         |   3271         for (TInt i=0; i<iDriveEntryList->Count(); i++) | 
|         |   3272             { | 
|         |   3273             TDriveEntry driveEntry = iDriveEntryList->At(i); | 
|         |   3274  | 
|         |   3275             TBuf<10> driveRoot; | 
|         |   3276             driveRoot.Append(driveEntry.iLetter); | 
|         |   3277             driveRoot.Append(_L(":\\")); | 
|         |   3278  | 
|         |   3279             // current dir | 
|         |   3280             DoFindFiles(_L("*"), driveRoot); | 
|         |   3281              | 
|         |   3282             // recurse into sub directories | 
|         |   3283             DoFindFilesRecursiveL(_L("*"), driveRoot); | 
|         |   3284             } | 
|         |   3285          | 
|         |   3286         // write entries | 
|         |   3287         TBuf8<KMaxFileName> writeBuf; | 
|         |   3288         for (TInt i=0; i<iFindFileEntryList->Count(); i++) | 
|         |   3289             { | 
|         |   3290             TFileEntry fileEntry = iFindFileEntryList->At(i); | 
|         |   3291              | 
|         |   3292             writeBuf.Copy(fileEntry.iPath); | 
|         |   3293             writeBuf.Append(fileEntry.iEntry.iName); | 
|         |   3294             writeBuf.Append(KFileNewLine); | 
|         |   3295              | 
|         |   3296             file.Write(writeBuf); | 
|         |   3297             } | 
|         |   3298          | 
|         |   3299         iEngine->EikonEnv()->BusyMsgCancel(); | 
|         |   3300          | 
|         |   3301         CleanupStack::PopAndDestroy(); //file | 
|         |   3302         iFindFileEntryList->Reset(); | 
|         |   3303          | 
|         |   3304         _LIT(KMessage, "File list written to %S"); | 
|         |   3305         TFileName noteMsg; | 
|         |   3306         noteMsg.Format(KMessage, &allFilesPath); | 
|         |   3307  | 
|         |   3308         iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg, ETrue); // NoTimeout | 
|         |   3309         } | 
|         |   3310     else | 
|         |   3311         { | 
|         |   3312         _LIT(KMessage, "Failed writing to %S"); | 
|         |   3313         TFileName noteMsg; | 
|         |   3314         noteMsg.Format(KMessage, &allFilesPath); | 
|         |   3315  | 
|         |   3316         iEngine->FileBrowserUI()->ShowErrorNote(noteMsg, ETrue); // NoTimeout | 
|         |   3317         }     | 
|         |   3318     } | 
|         |   3319  | 
|         |   3320 // -------------------------------------------------------------------------------------------- | 
|         |   3321  | 
|         |   3322 TInt CFileBrowserFileUtils::DoFindFiles(const TDesC& aFileName, const TDesC& aPath) | 
|         |   3323     { | 
|         |   3324     TFindFile fileFinder(iFs); | 
|         |   3325     CDir* dir; | 
|         |   3326     TInt err = fileFinder.FindWildByPath(aFileName, &aPath, dir); | 
|         |   3327  | 
|         |   3328     while (err == KErrNone) | 
|         |   3329         { | 
|         |   3330         for (TInt i=0; i<dir->Count(); i++) | 
|         |   3331             { | 
|         |   3332             TEntry entry = (*dir)[i]; | 
|         |   3333  | 
|         |   3334             // ignore any directory entries | 
|         |   3335             if (!entry.IsDir() && entry.iName.Length() && aPath.Length()) | 
|         |   3336                 { | 
|         |   3337                 TParse parsedName; | 
|         |   3338                 parsedName.Set(entry.iName, &fileFinder.File(), NULL); | 
|         |   3339                  | 
|         |   3340                 if (parsedName.Drive().Length() && aPath.Length() && parsedName.Drive()[0] == aPath[0]) | 
|         |   3341                     { | 
|         |   3342                     TFileEntry fileEntry; | 
|         |   3343                     fileEntry.iPath = parsedName.DriveAndPath(); | 
|         |   3344                     fileEntry.iEntry = entry; | 
|         |   3345                     fileEntry.iDirEntries = KErrNotFound; | 
|         |   3346                     fileEntry.iIconId = EFixedIconEmpty; | 
|         |   3347                      | 
|         |   3348                     TRAP(err, iFindFileEntryList->AppendL(fileEntry));              | 
|         |   3349                     } | 
|         |   3350                 } | 
|         |   3351             } | 
|         |   3352  | 
|         |   3353         delete dir; | 
|         |   3354         dir = NULL; | 
|         |   3355         err = fileFinder.FindWild(dir); | 
|         |   3356         } | 
|         |   3357  | 
|         |   3358     return err; | 
|         |   3359     } | 
|         |   3360  | 
|         |   3361 // -------------------------------------------------------------------------------------------- | 
|         |   3362  | 
|         |   3363 TInt CFileBrowserFileUtils::DoFindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath) | 
|         |   3364 	{ | 
|         |   3365     TInt err(KErrNone); | 
|         |   3366     CDirScan* scan = CDirScan::NewLC(iFs); | 
|         |   3367     scan->SetScanDataL(aPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst); | 
|         |   3368     CDir* dir = NULL; | 
|         |   3369  | 
|         |   3370     for(;;) | 
|         |   3371         { | 
|         |   3372         TRAP(err, scan->NextL(dir)); | 
|         |   3373         if (!dir  || (err != KErrNone)) | 
|         |   3374             break; | 
|         |   3375  | 
|         |   3376         for (TInt i=0; i<dir->Count(); i++) | 
|         |   3377             { | 
|         |   3378             TEntry entry = (*dir)[i]; | 
|         |   3379              | 
|         |   3380             if (entry.IsDir()) | 
|         |   3381                 { | 
|         |   3382                 TFileName path(scan->FullPath()); | 
|         |   3383                  | 
|         |   3384                 if (path.Length()) | 
|         |   3385                     { | 
|         |   3386                     path.Append(entry.iName); | 
|         |   3387                     path.Append(_L("\\")); | 
|         |   3388                     DoFindFiles(aFileName, path); | 
|         |   3389                     } | 
|         |   3390                 } | 
|         |   3391             } | 
|         |   3392         delete(dir); | 
|         |   3393         } | 
|         |   3394  | 
|         |   3395     CleanupStack::PopAndDestroy(scan); | 
|         |   3396     return err; | 
|         |   3397     } | 
|         |   3398  | 
|         |   3399 // -------------------------------------------------------------------------------------------- | 
|         |   3400  | 
|         |   3401 void CFileBrowserFileUtils::ListOpenFilesL() | 
|         |   3402     { | 
|         |   3403     iFileEntryList->Reset(); | 
|         |   3404  | 
|         |   3405     CFileList* dir = NULL; | 
|         |   3406     TOpenFileScan fileScan(iFs); | 
|         |   3407     fileScan.NextL(dir); | 
|         |   3408      | 
|         |   3409     while (dir) | 
|         |   3410         { | 
|         |   3411         for (TInt i=0; i<dir->Count(); i++) | 
|         |   3412             { | 
|         |   3413             TEntry entry = (*dir)[i]; | 
|         |   3414             TFileName fullPath; | 
|         |   3415  | 
|         |   3416             // TOpenFileScan does not return drive letters for the entries, so try to guess it | 
|         |   3417             if (entry.iName.Length() > 2 && entry.iName[1] != ':') | 
|         |   3418                 { | 
|         |   3419                 for (TInt i=0; i<iDriveEntryList->Count(); i++) | 
|         |   3420                     { | 
|         |   3421                     TDriveEntry driveEntry = iDriveEntryList->At(i); | 
|         |   3422                      | 
|         |   3423                     TFileName guessPath; | 
|         |   3424                     guessPath.Append(driveEntry.iLetter); | 
|         |   3425                     guessPath.Append(_L(":")); | 
|         |   3426                     guessPath.Append(entry.iName); | 
|         |   3427                      | 
|         |   3428                     // check if the file exists | 
|         |   3429                     if (BaflUtils::FileExists(iFs, guessPath)) | 
|         |   3430                         { | 
|         |   3431                         // if it's on read only drive, then take it or check if it's really in use | 
|         |   3432                         TBool readOnlyDrive(ETrue); | 
|         |   3433                         BaflUtils::DiskIsReadOnly(iFs, guessPath, readOnlyDrive); | 
|         |   3434                          | 
|         |   3435                         if (readOnlyDrive || iFs.SetEntry(guessPath, entry.iModified, NULL, NULL) == KErrInUse) | 
|         |   3436                             { | 
|         |   3437                             fullPath = guessPath; | 
|         |   3438                             break; | 
|         |   3439                             } | 
|         |   3440                         } | 
|         |   3441                     } | 
|         |   3442                 } | 
|         |   3443             else | 
|         |   3444                 { | 
|         |   3445                 fullPath = entry.iName;    | 
|         |   3446                 } | 
|         |   3447  | 
|         |   3448             TParse nameParser; | 
|         |   3449             if (fullPath.Length() && nameParser.SetNoWild(fullPath, NULL, NULL) == KErrNone) | 
|         |   3450                 { | 
|         |   3451                 entry.iName = nameParser.NameAndExt(); | 
|         |   3452                  | 
|         |   3453                 TFileEntry fileEntry; | 
|         |   3454                 fileEntry.iPath = nameParser.DriveAndPath(); | 
|         |   3455                 fileEntry.iEntry = entry; | 
|         |   3456                 fileEntry.iDirEntries = KErrNotFound; | 
|         |   3457                 fileEntry.iIconId = EFixedIconEmpty; | 
|         |   3458                  | 
|         |   3459                 iFileEntryList->AppendL(fileEntry);                 | 
|         |   3460                 } | 
|         |   3461             } | 
|         |   3462              | 
|         |   3463         delete dir; | 
|         |   3464         dir = NULL; | 
|         |   3465         fileScan.NextL(dir); | 
|         |   3466         } | 
|         |   3467  | 
|         |   3468     TInt operations = iFileEntryList->Count(); | 
|         |   3469      | 
|         |   3470     iListingMode = EOpenFiles; | 
|         |   3471 	// TODO | 
|         |   3472     //iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex(0); | 
|         |   3473     RefreshViewL();             | 
|         |   3474  | 
|         |   3475     _LIT(KMessage, "%d open files found"); | 
|         |   3476     TFileName noteMsg; | 
|         |   3477     noteMsg.Format(KMessage, operations); | 
|         |   3478  | 
|         |   3479     iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); | 
|         |   3480     } | 
|         |   3481  | 
|         |   3482 // -------------------------------------------------------------------------------------------- | 
|         |   3483  | 
|         |   3484 void CFileBrowserFileUtils::ListMessageAttachmentsL(TInt aType) | 
|         |   3485     { | 
|         |   3486     iFileEntryList->Reset(); | 
|         |   3487  | 
|         |   3488     CMsvSession* session = CMsvSession::OpenSyncL(*this); | 
|         |   3489     CleanupStack::PushL(session); | 
|         |   3490      | 
|         |   3491     CMsvEntry* context = NULL; | 
|         |   3492      | 
|         |   3493     if (aType == EFileBrowserCmdToolsMsgAttachmentsInbox) | 
|         |   3494         context = session->GetEntryL(KMsvGlobalInBoxIndexEntryId); | 
|         |   3495     else if (aType == EFileBrowserCmdToolsMsgAttachmentsDrafts) | 
|         |   3496         context = session->GetEntryL(KMsvDraftEntryId); | 
|         |   3497     else if (aType == EFileBrowserCmdToolsMsgAttachmentsSentItems) | 
|         |   3498         context = session->GetEntryL(KMsvSentEntryId); | 
|         |   3499     else if (aType == EFileBrowserCmdToolsMsgAttachmentsOutbox) | 
|         |   3500         context = session->GetEntryL(KMsvGlobalOutBoxIndexEntryId); | 
|         |   3501     else | 
|         |   3502         User::Panic(_L("MsgAtt.Mode"), 100); | 
|         |   3503      | 
|         |   3504     CleanupStack::PushL(context); | 
|         |   3505      | 
|         |   3506     CDesCArray* attPaths = new(ELeave) CDesCArrayFlat(128); | 
|         |   3507     CleanupStack::PushL(attPaths); | 
|         |   3508      | 
|         |   3509     // read attachment paths | 
|         |   3510     ReadAttachmentPathsRecursiveL(session, context, attPaths); | 
|         |   3511      | 
|         |   3512     // create file entries of the paths | 
|         |   3513     for (TInt i=0; i<attPaths->MdcaCount(); i++) | 
|         |   3514         { | 
|         |   3515         TFileEntry fileEntry; | 
|         |   3516         TEntry entry; | 
|         |   3517         TParse nameParser; | 
|         |   3518          | 
|         |   3519         if (attPaths->MdcaPoint(i).Length() && | 
|         |   3520             nameParser.SetNoWild(attPaths->MdcaPoint(i), NULL, NULL) == KErrNone && | 
|         |   3521             iFs.Entry(attPaths->MdcaPoint(i), entry) == KErrNone) | 
|         |   3522             { | 
|         |   3523             TFileEntry fileEntry; | 
|         |   3524             fileEntry.iPath = nameParser.DriveAndPath(); | 
|         |   3525             fileEntry.iEntry = entry; | 
|         |   3526             fileEntry.iDirEntries = KErrNotFound; | 
|         |   3527             fileEntry.iIconId = EFixedIconEmpty; | 
|         |   3528  | 
|         |   3529             iFileEntryList->AppendL(fileEntry);                 | 
|         |   3530             } | 
|         |   3531         } | 
|         |   3532      | 
|         |   3533     CleanupStack::PopAndDestroy(3); //session, context, attPaths | 
|         |   3534              | 
|         |   3535     TInt operations = iFileEntryList->Count(); | 
|         |   3536      | 
|         |   3537     if (aType == EFileBrowserCmdToolsMsgAttachmentsInbox) | 
|         |   3538         iListingMode = EMsgAttachmentsInbox; | 
|         |   3539     else if (aType == EFileBrowserCmdToolsMsgAttachmentsDrafts) | 
|         |   3540         iListingMode = EMsgAttachmentsDrafts; | 
|         |   3541     else if (aType == EFileBrowserCmdToolsMsgAttachmentsSentItems) | 
|         |   3542         iListingMode = EMsgAttachmentsSentItems; | 
|         |   3543     else if (aType == EFileBrowserCmdToolsMsgAttachmentsOutbox) | 
|         |   3544         iListingMode = EMsgAttachmentsOutbox; | 
|         |   3545 	 | 
|         |   3546     // TODO | 
|         |   3547     //iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex(0); | 
|         |   3548     RefreshViewL();             | 
|         |   3549  | 
|         |   3550     _LIT(KMessage, "%d files found"); | 
|         |   3551     TFileName noteMsg; | 
|         |   3552     noteMsg.Format(KMessage, operations); | 
|         |   3553  | 
|         |   3554     iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); | 
|         |   3555     } | 
|         |   3556  | 
|         |   3557 // -------------------------------------------------------------------------------------------- | 
|         |   3558  | 
|         |   3559 void CFileBrowserFileUtils::ReadAttachmentPathsRecursiveL(CMsvSession* aSession, CMsvEntry* aContext, CDesCArray* aAttPaths) | 
|         |   3560     { | 
|         |   3561     CMsvEntrySelection* entrySelection = aContext->ChildrenL();  | 
|         |   3562     CleanupStack::PushL(entrySelection); | 
|         |   3563      | 
|         |   3564     for (TInt i=0; i<entrySelection->Count(); i++) | 
|         |   3565         { | 
|         |   3566         CMsvEntry* entry = aSession->GetEntryL((*entrySelection)[i]); | 
|         |   3567         CleanupStack::PushL(entry); | 
|         |   3568          | 
|         |   3569         CMsvStore* store = NULL; | 
|         |   3570         TRAPD(err, store = entry->ReadStoreL()); | 
|         |   3571          | 
|         |   3572         if (err == KErrNone) | 
|         |   3573             { | 
|         |   3574             CleanupStack::PushL(store); | 
|         |   3575  | 
|         |   3576             for (TInt j=0; j<store->AttachmentManagerL().AttachmentCount(); j++) | 
|         |   3577                 { | 
|         |   3578                 CMsvAttachment* attachment = store->AttachmentManagerL().GetAttachmentInfoL(j); | 
|         |   3579                 CleanupStack::PushL(attachment); | 
|         |   3580                  | 
|         |   3581                 aAttPaths->AppendL(attachment->FilePath()); | 
|         |   3582                  | 
|         |   3583                 CleanupStack::PopAndDestroy(); //attachment | 
|         |   3584                 } | 
|         |   3585             CleanupStack::PopAndDestroy(); // store | 
|         |   3586             } | 
|         |   3587  | 
|         |   3588         // recurse into children | 
|         |   3589         if (entry->Count() > 0) | 
|         |   3590             { | 
|         |   3591             ReadAttachmentPathsRecursiveL(aSession, entry, aAttPaths); | 
|         |   3592             } | 
|         |   3593  | 
|         |   3594         CleanupStack::PopAndDestroy(); // entry | 
|         |   3595         }       | 
|         |   3596     } | 
|         |   3597  | 
|         |   3598 // -------------------------------------------------------------------------------------------- | 
|         |   3599  | 
|         |   3600 void CFileBrowserFileUtils::WriteMsgStoreWalkL() | 
|         |   3601     { | 
|         |   3602     _LIT(KAllAppsFileName, "MsgStoreWalk.txt"); | 
|         |   3603     TFileName allAppsPath = PathInfo::PhoneMemoryRootPath(); | 
|         |   3604     allAppsPath.Append(KAllAppsFileName); | 
|         |   3605  | 
|         |   3606     if (iMsgStoreWalkFile.Replace(iFs, allAppsPath, EFileWrite) == KErrNone) | 
|         |   3607         { | 
|         |   3608         CMsvSession* session = CMsvSession::OpenSyncL(*this); | 
|         |   3609         CleanupStack::PushL(session); | 
|         |   3610          | 
|         |   3611         CMsvEntry* context = session->GetEntryL(KMsvRootIndexEntryId); | 
|         |   3612         CleanupStack::PushL(context); | 
|         |   3613          | 
|         |   3614         iMsgStoreWalkFile.Write(_L8("id  service_id  related_id  type  mtm  date  size  error  biotype  mtmdata1  mtmdata2  mtmdata3  description  details\r\n\r\n")); | 
|         |   3615          | 
|         |   3616         // write details about the root entry | 
|         |   3617         DoWriteMessageEntryInfoL(context, iMsgStoreWalkFile, 0); | 
|         |   3618          | 
|         |   3619         // get and write info recursively | 
|         |   3620         TInt level(1);         | 
|         |   3621         WriteMessageEntryInfoRecursiveL(session, context, iMsgStoreWalkFile, level); | 
|         |   3622  | 
|         |   3623         CleanupStack::PopAndDestroy(2); //session, context | 
|         |   3624          | 
|         |   3625         iMsgStoreWalkFile.Flush(); | 
|         |   3626         iMsgStoreWalkFile.Close(); | 
|         |   3627          | 
|         |   3628         _LIT(KMessage, "Msg. store walk written to %S"); | 
|         |   3629         TFileName noteMsg; | 
|         |   3630         noteMsg.Format(KMessage, &allAppsPath); | 
|         |   3631  | 
|         |   3632         iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg, ETrue); // NoTimeout | 
|         |   3633         } | 
|         |   3634     else | 
|         |   3635         { | 
|         |   3636         _LIT(KMessage, "Failed writing to %S"); | 
|         |   3637         TFileName noteMsg; | 
|         |   3638         noteMsg.Format(KMessage, &allAppsPath); | 
|         |   3639  | 
|         |   3640         iEngine->FileBrowserUI()->ShowErrorNote(noteMsg, ETrue); // NoTimeout | 
|         |   3641         }     | 
|         |   3642     } | 
|         |   3643  | 
|         |   3644 // -------------------------------------------------------------------------------------------- | 
|         |   3645  | 
|         |   3646 void CFileBrowserFileUtils::WriteMessageEntryInfoRecursiveL(CMsvSession* aSession, CMsvEntry* aContext, RFile& aFile, TInt& aLevel) | 
|         |   3647     { | 
|         |   3648     CMsvEntrySelection* entrySelection = aContext->ChildrenL();  | 
|         |   3649     CleanupStack::PushL(entrySelection); | 
|         |   3650      | 
|         |   3651     for (TInt i=0; i<entrySelection->Count(); i++) | 
|         |   3652         { | 
|         |   3653         CMsvEntry* entry = aSession->GetEntryL((*entrySelection)[i]); | 
|         |   3654         CleanupStack::PushL(entry); | 
|         |   3655          | 
|         |   3656         DoWriteMessageEntryInfoL(entry, aFile, aLevel); | 
|         |   3657  | 
|         |   3658         // recurse into children | 
|         |   3659         if (entry->Count() > 0) | 
|         |   3660             { | 
|         |   3661             aLevel++; | 
|         |   3662             WriteMessageEntryInfoRecursiveL(aSession, entry, aFile, aLevel); | 
|         |   3663             aLevel--; | 
|         |   3664             } | 
|         |   3665  | 
|         |   3666         CleanupStack::PopAndDestroy(); // entry | 
|         |   3667         }       | 
|         |   3668     } | 
|         |   3669  | 
|         |   3670 // -------------------------------------------------------------------------------------------- | 
|         |   3671  | 
|         |   3672 void CFileBrowserFileUtils::DoWriteMessageEntryInfoL(CMsvEntry* aContext, RFile& aFile, TInt aLevel) | 
|         |   3673     { | 
|         |   3674     TMsvEntry messageEntry = aContext->Entry(); | 
|         |   3675      | 
|         |   3676     for (TInt j=0; j<aLevel; j++) | 
|         |   3677         { | 
|         |   3678         aFile.Write(_L8("     ")); | 
|         |   3679         } | 
|         |   3680  | 
|         |   3681     TBuf8<256> desc; | 
|         |   3682     desc.Copy(messageEntry.iDescription); | 
|         |   3683  | 
|         |   3684     TBuf8<256> details; | 
|         |   3685     details.Copy(messageEntry.iDetails); | 
|         |   3686  | 
|         |   3687     _LIT8(KLine, "-> %d  %d  %d  %d  %d  %Ld  %d  %d  %d  %d  %d  %d  %S  %S\r\n"); | 
|         |   3688     TBuf8<1024> buf; | 
|         |   3689     buf.Format(KLine, messageEntry.Id(), messageEntry.iServiceId, messageEntry.iRelatedId, messageEntry.iType.iUid, | 
|         |   3690         messageEntry.iMtm.iUid, messageEntry.iDate.Int64(), messageEntry.iSize, messageEntry.iError, messageEntry.iBioType, | 
|         |   3691         messageEntry.iMtmData1, messageEntry.iMtmData2, messageEntry.iMtmData3, &desc, &details); | 
|         |   3692  | 
|         |   3693     aFile.Write(buf); | 
|         |   3694     } | 
|         |   3695  | 
|         |   3696 // -------------------------------------------------------------------------------------------- | 
|         |   3697  | 
|         |   3698 void CFileBrowserFileUtils::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) | 
|         |   3699     { | 
|         |   3700     } | 
|         |   3701  | 
|         |   3702 // -------------------------------------------------------------------------------------------- | 
|         |   3703  | 
|         |   3704 void CFileBrowserFileUtils::FileEditorL(TInt aCurrentItemIndex, TInt /*aType*/) | 
|         |   3705     { | 
|         |   3706     // TODO | 
|         |   3707     // just get current item  | 
|         |   3708     //TInt currentItemIndex = iEngine->QueryCurrentItemIndex(); | 
|         |   3709      | 
|         |   3710     if (iFileEntryList->Count() > aCurrentItemIndex && aCurrentItemIndex >= 0) | 
|         |   3711         { | 
|         |   3712         TFileEntry fileEntry = iFileEntryList->At(aCurrentItemIndex); | 
|         |   3713          | 
|         |   3714         // only valid for files | 
|         |   3715         if (!fileEntry.iEntry.IsDir()) | 
|         |   3716             { | 
|         |   3717             TFileName fullPath = fileEntry.iPath; | 
|         |   3718             fullPath.Append(fileEntry.iEntry.iName); | 
|         |   3719  | 
|         |   3720 //            iEngine->FileListContainer()->SetNaviPaneTextL(fileEntry.iEntry.iName); | 
|         |   3721 // | 
|         |   3722 //            TInt editorMode(0); | 
|         |   3723 // | 
|         |   3724 //            if (aType == EFileBrowserCmdFileViewText) | 
|         |   3725 //                editorMode = EFileEditorViewAsText; | 
|         |   3726 //            else if (aType == EFileBrowserCmdFileViewHex) | 
|         |   3727 //                editorMode = EFileEditorViewAsHex; | 
|         |   3728 //            else if (aType == EFileBrowserCmdFileEditText) | 
|         |   3729 //                editorMode = EFileEditorEditAsText; | 
|         |   3730 //            else if (aType == EFileBrowserCmdFileEditHex) | 
|         |   3731 //                editorMode = EFileEditorEditAsHex; | 
|         |   3732 //            else | 
|         |   3733 //                User::Panic(_L("Inv.Ed.Mode"), 843); | 
|         |   3734 // | 
|         |   3735 //            // launch dialog | 
|         |   3736 //            CFileBrowserFileEditorDlg* dlg = CFileBrowserFileEditorDlg::NewL(fullPath, editorMode); | 
|         |   3737 //            dlg->RunDlgLD(); | 
|         |   3738 // | 
|         |   3739 //            iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); | 
|         |   3740 // | 
|         |   3741 //            if (aType == EFileBrowserCmdFileEditText || aType == EFileBrowserCmdFileEditHex) | 
|         |   3742 //                { | 
|         |   3743 //                RefreshViewL(); | 
|         |   3744 //                } | 
|         |   3745             } | 
|         |   3746         } | 
|         |   3747     } | 
|         |   3748  | 
|         |   3749 // -------------------------------------------------------------------------------------------- | 
|         |   3750  | 
|         |   3751 TBool CFileBrowserFileUtils::DriveSnapShotPossible() | 
|         |   3752     { | 
|         |   3753 //    // TODO | 
|         |   3754 //    // check that E-drive is available | 
|         |   3755 //    TBool EDriveIsOK(EFalse); | 
|         |   3756 // | 
|         |   3757 //    for (TInt i=0; i<iDriveEntryList->Count(); i++) | 
|         |   3758 //        { | 
|         |   3759 //        TDriveEntry driveEntry = iDriveEntryList->At(i); | 
|         |   3760 // | 
|         |   3761 //        if (driveEntry.iNumber == EDriveE) | 
|         |   3762 //            { | 
|         |   3763 //            if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLocked || driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAbsent) | 
|         |   3764 //                EDriveIsOK = EFalse; | 
|         |   3765 //            else | 
|         |   3766 //                EDriveIsOK = ETrue; | 
|         |   3767 //            } | 
|         |   3768 //        } | 
|         |   3769 // | 
|         |   3770 //    if (!EDriveIsOK) | 
|         |   3771 //        return EFalse; | 
|         |   3772 // | 
|         |   3773 //    // get current item | 
|         |   3774 //    TInt currentItemIndex = iEngine->QueryCurrentItemIndex(); | 
|         |   3775 // | 
|         |   3776 //    if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0) | 
|         |   3777 //        { | 
|         |   3778 //        TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex); | 
|         |   3779 // | 
|         |   3780 //        // drive snapshot not possible when E-drive is highlighted, since that's where we are copying | 
|         |   3781 //        if (driveEntry.iNumber == EDriveE) | 
|         |   3782 //            return EFalse; | 
|         |   3783 //        else | 
|         |   3784 //            return ETrue; | 
|         |   3785 //        } | 
|         |   3786     return EFalse; | 
|         |   3787     } | 
|         |   3788  | 
|         |   3789 // -------------------------------------------------------------------------------------------- | 
|         |   3790  | 
|         |   3791 void CFileBrowserFileUtils::DriveSnapShotL() | 
|         |   3792     { | 
|         |   3793 //    if (iEngine->Settings().iBypassPlatformSecurity) | 
|         |   3794 //        { | 
|         |   3795 //        // get current item | 
|         |   3796 //        TInt currentItemIndex = iEngine->QueryCurrentItemIndex(); | 
|         |   3797 // | 
|         |   3798 //        if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0) | 
|         |   3799 //            { | 
|         |   3800 //            TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex); | 
|         |   3801 // | 
|         |   3802 //            TChar sourceDriveLetter = driveEntry.iLetter; | 
|         |   3803 //            TChar targetDriveLetter = 'E';  // hardcoded drive letter, could be better if would be queried from the user | 
|         |   3804 // | 
|         |   3805 //            // append to the command array | 
|         |   3806 //            AppendToCommandArrayL(EFileBrowserFileOpCommandDriveSnapShot, | 
|         |   3807 //                                  new(ELeave)CCommandParamsDriveSnapShot(sourceDriveLetter, targetDriveLetter) | 
|         |   3808 //                                 ); | 
|         |   3809 // | 
|         |   3810 //            // execute the operation | 
|         |   3811 //            StartExecutingCommandsL(_L("Copying")); | 
|         |   3812 //            } | 
|         |   3813 //        } | 
|         |   3814 //    else | 
|         |   3815 //        { | 
|         |   3816 //        iEngine->FileBrowserUI()->ShowInformationNote(_L("Enable \"bypass platform security\" from the settings first"), _L("")); | 
|         |   3817 //        } | 
|         |   3818     } | 
|         |   3819      | 
|         |   3820 // -------------------------------------------------------------------------------------------- | 
|         |   3821  | 
|         |   3822 void CFileBrowserFileUtils::SetDrivePasswordL(TInt aIndex, | 
|         |   3823                                               const TFileName &aOldPassword, | 
|         |   3824                                               const TFileName &aNewPassword) | 
|         |   3825     {     | 
|         |   3826     if (iDriveEntryList->Count() > aIndex && aIndex >= 0) | 
|         |   3827         { | 
|         |   3828         TMediaPassword oldPassword; | 
|         |   3829         TMediaPassword newPassword; | 
|         |   3830  | 
|         |   3831         TDriveEntry driveEntry = iDriveEntryList->At(aIndex); | 
|         |   3832  | 
|         |   3833         ConvertCharsToPwd(aOldPassword, oldPassword); | 
|         |   3834         ConvertCharsToPwd(aNewPassword, newPassword); | 
|         |   3835  | 
|         |   3836         // set the password, does not actually lock the drive | 
|         |   3837         TInt err = iFs.LockDrive(driveEntry.iNumber, oldPassword, newPassword, ETrue); | 
|         |   3838  | 
|         |   3839         if (err == KErrNone) | 
|         |   3840             { | 
|         |   3841             iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Password set")); | 
|         |   3842             } | 
|         |   3843         else if (err == KErrNotSupported) | 
|         |   3844             { | 
|         |   3845             iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); | 
|         |   3846             } | 
|         |   3847         else | 
|         |   3848             { | 
|         |   3849             CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); | 
|         |   3850  | 
|         |   3851             iEngine->FileBrowserUI()->ShowErrorNote( | 
|         |   3852                     textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); | 
|         |   3853  | 
|         |   3854             CleanupStack::PopAndDestroy();  //textResolver | 
|         |   3855             } | 
|         |   3856  | 
|         |   3857         RefreshViewL(); | 
|         |   3858         } | 
|         |   3859     } | 
|         |   3860  | 
|         |   3861 // -------------------------------------------------------------------------------------------- | 
|         |   3862  | 
|         |   3863 void CFileBrowserFileUtils::UnlockDriveL(TInt aIndex, const TFileName &aOldPassword) | 
|         |   3864     { | 
|         |   3865     if (iDriveEntryList->Count() > aIndex && aIndex >= 0) | 
|         |   3866         { | 
|         |   3867         TDriveEntry driveEntry = iDriveEntryList->At(aIndex); | 
|         |   3868  | 
|         |   3869         TMediaPassword oldPassword; | 
|         |   3870         ConvertCharsToPwd(aOldPassword, oldPassword); | 
|         |   3871  | 
|         |   3872         // unlock the drive | 
|         |   3873         TInt err = iFs.UnlockDrive(driveEntry.iNumber, oldPassword, ETrue) == KErrNone; | 
|         |   3874  | 
|         |   3875         if (err == KErrNone) | 
|         |   3876             { | 
|         |   3877             iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Drive unlocked")); | 
|         |   3878             } | 
|         |   3879         else if (err == KErrNotSupported) | 
|         |   3880             { | 
|         |   3881             iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); | 
|         |   3882             } | 
|         |   3883         else | 
|         |   3884             { | 
|         |   3885             CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); | 
|         |   3886  | 
|         |   3887             iEngine->FileBrowserUI()->ShowErrorNote( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); | 
|         |   3888  | 
|         |   3889             CleanupStack::PopAndDestroy();  //textResolver | 
|         |   3890             } | 
|         |   3891  | 
|         |   3892         RefreshViewL(); | 
|         |   3893         } | 
|         |   3894     } | 
|         |   3895  | 
|         |   3896 // -------------------------------------------------------------------------------------------- | 
|         |   3897  | 
|         |   3898 void CFileBrowserFileUtils::ClearDrivePasswordL(TInt aIndex, const TFileName &aOldPassword) | 
|         |   3899     { | 
|         |   3900     if (iDriveEntryList->Count() > aIndex && aIndex >= 0) | 
|         |   3901         { | 
|         |   3902         TDriveEntry driveEntry = iDriveEntryList->At(aIndex); | 
|         |   3903  | 
|         |   3904         TMediaPassword oldPassword; | 
|         |   3905  | 
|         |   3906         ConvertCharsToPwd(aOldPassword, oldPassword); | 
|         |   3907  | 
|         |   3908         // clear the password from the drive | 
|         |   3909         TInt err = iFs.ClearPassword(driveEntry.iNumber, oldPassword); | 
|         |   3910  | 
|         |   3911         if (err == KErrNone) | 
|         |   3912             { | 
|         |   3913             iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Password cleared")); | 
|         |   3914             } | 
|         |   3915         else if (err == KErrNotSupported) | 
|         |   3916             { | 
|         |   3917             iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); | 
|         |   3918             } | 
|         |   3919         else | 
|         |   3920             { | 
|         |   3921             CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); | 
|         |   3922  | 
|         |   3923             iEngine->FileBrowserUI()->ShowErrorNote( | 
|         |   3924                     textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); | 
|         |   3925  | 
|         |   3926             CleanupStack::PopAndDestroy();  //textResolver | 
|         |   3927             } | 
|         |   3928  | 
|         |   3929         RefreshViewL(); | 
|         |   3930         } | 
|         |   3931     } | 
|         |   3932  | 
|         |   3933 // -------------------------------------------------------------------------------------------- | 
|         |   3934  | 
|         |   3935 void CFileBrowserFileUtils::EraseDrivePasswordL(TInt aIndex) | 
|         |   3936     { | 
|         |   3937     if (iDriveEntryList->Count() > aIndex && aIndex >= 0) | 
|         |   3938         { | 
|         |   3939         TDriveEntry driveEntry = iDriveEntryList->At(aIndex); | 
|         |   3940          | 
|         |   3941         // erase the password from the drive | 
|         |   3942         TInt err(KErrNone); | 
|         |   3943         err = iFs.ErasePassword(driveEntry.iNumber); | 
|         |   3944  | 
|         |   3945         if (err == KErrNone) | 
|         |   3946             { | 
|         |   3947             iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Password erased")); | 
|         |   3948             } | 
|         |   3949         else if (err == KErrNotSupported) | 
|         |   3950             { | 
|         |   3951             iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); | 
|         |   3952             } | 
|         |   3953         else | 
|         |   3954             { | 
|         |   3955             iEngine->FileBrowserUI()->ShowErrorNote(_L("Cannot erase, you may have to format the drive first")); | 
|         |   3956             } | 
|         |   3957  | 
|         |   3958         RefreshViewL(); | 
|         |   3959         } | 
|         |   3960     } | 
|         |   3961  | 
|         |   3962 // -------------------------------------------------------------------------------------------- | 
|         |   3963  | 
|         |   3964 void CFileBrowserFileUtils::FormatDriveL(TInt aIndex, TBool aQuickFormat) | 
|         |   3965     {     | 
|         |   3966     if (iDriveEntryList->Count() > aIndex && aIndex >= 0) | 
|         |   3967         { | 
|         |   3968         TDriveEntry driveEntry = iDriveEntryList->At(aIndex); | 
|         |   3969  | 
|         |   3970         TInt err(KErrNone); | 
|         |   3971         TInt formatCount(0); | 
|         |   3972  | 
|         |   3973         TBuf<10> driveRoot; | 
|         |   3974         driveRoot.Append(driveEntry.iLetter); | 
|         |   3975         driveRoot.Append(_L(":")); | 
|         |   3976  | 
|         |   3977         TUint formatMode(0); | 
|         |   3978         if (aQuickFormat) | 
|         |   3979             formatMode = ESpecialFormat|EQuickFormat; | 
|         |   3980         else | 
|         |   3981             formatMode = ESpecialFormat|EFullFormat; | 
|         |   3982  | 
|         |   3983         // set as system application to prevent getting shut down events | 
|         |   3984         iEngine->EikonEnv()->SetSystem(ETrue); | 
|         |   3985  | 
|         |   3986         // first close any open applications | 
|         |   3987         CBaBackupSessionWrapper* BSWrapper = CBaBackupSessionWrapper::NewL(); | 
|         |   3988         CleanupStack::PushL(BSWrapper); | 
|         |   3989  | 
|         |   3990         TBackupOperationAttributes atts(MBackupObserver::EReleaseLockNoAccess, MBackupOperationObserver::EStart); | 
|         |   3991         BSWrapper->NotifyBackupOperationL(atts); | 
|         |   3992  | 
|         |   3993         CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); | 
|         |   3994         BSWrapper->CloseAll( MBackupObserver::EReleaseLockNoAccess, waiter->iStatus ); | 
|         |   3995         waiter->StartAndWait(); | 
|         |   3996         CleanupStack::PopAndDestroy(); //waiter | 
|         |   3997  | 
|         |   3998         // some delay to make sure all applications have been closed | 
|         |   3999         User::After(1000000); | 
|         |   4000  | 
|         |   4001         // format the drive | 
|         |   4002         RFormat format; | 
|         |   4003         err = format.Open(iFs, driveRoot, formatMode, formatCount); | 
|         |   4004  | 
|         |   4005         // Forced format for locked card | 
|         |   4006         if ( err == KErrLocked ) | 
|         |   4007             { | 
|         |   4008             // Erase password and try again | 
|         |   4009             err = iFs.ErasePassword( driveEntry.iNumber ); | 
|         |   4010             if ( !err ) | 
|         |   4011                 { | 
|         |   4012                 err = format.Open(iFs, driveRoot, formatMode, formatCount); | 
|         |   4013                 } | 
|         |   4014             } | 
|         |   4015  | 
|         |   4016         if( err != KErrNone &&  err != KErrLocked ) | 
|         |   4017             { | 
|         |   4018 //            CAknQueryDialog* lockQuery = CAknQueryDialog::NewL(); | 
|         |   4019 //            if ( lockQuery->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, _L("Memory card in use by other application. Proceed anyway?"))) | 
|         |   4020             // TODO Dialog should be opened in UI part | 
|         |   4021             if (iEngine->FileBrowserUI()->ShowConfirmationQuery(_L("Memory card in use by other application. Proceed anyway?"))) | 
|         |   4022                 { | 
|         |   4023                 // If format could not be started, someone is still keeping | 
|         |   4024                 // files open on media. Let's try to dismount file system, then | 
|         |   4025                 // remount with own extension embedded and try again. | 
|         |   4026  | 
|         |   4027                 TFullName fsName; | 
|         |   4028                 err = iFs.FileSystemName( fsName, driveEntry.iNumber ); | 
|         |   4029  | 
|         |   4030                 if ( err == KErrNone && fsName.Length() > 0 ) | 
|         |   4031                     { | 
|         |   4032                     // Prevent SysAp shutting down applications | 
|         |   4033                     RProperty::Set( | 
|         |   4034                         KPSUidCoreApplicationUIs, | 
|         |   4035                         KCoreAppUIsMmcRemovedWithoutEject, | 
|         |   4036                         ECoreAppUIsEjectCommandUsed ); | 
|         |   4037  | 
|         |   4038                     TRequestStatus stat; | 
|         |   4039                     iFs.NotifyDismount( driveEntry.iNumber, stat, EFsDismountForceDismount ); | 
|         |   4040                     User::WaitForRequest( stat ); | 
|         |   4041  | 
|         |   4042                     // Unfortunately, at the moment we have to wait until clients have received | 
|         |   4043                     // notification about card dismount. Otherwise at least causes problems with | 
|         |   4044                     // theme selected from card. In future clients should use new notify-API. | 
|         |   4045                     User::After( KForcedFormatTimeout ); | 
|         |   4046  | 
|         |   4047                     // Let's set priority higher than normally. This is done to decrease the chance | 
|         |   4048                     // that someone reopens files on memory card after mandatory file system | 
|         |   4049                     // remounting hence preventing formatting again. | 
|         |   4050                     TThreadPriority priority( RThread().Priority() ); | 
|         |   4051                     RThread().SetPriority( EPriorityAbsoluteHigh ); | 
|         |   4052  | 
|         |   4053                     // Mount file system back... | 
|         |   4054                     err = iFs.MountFileSystem( fsName, driveEntry.iNumber ); | 
|         |   4055                     err = format.Open(iFs, driveRoot, formatMode, formatCount); | 
|         |   4056                     RThread().SetPriority( priority ); | 
|         |   4057                     } | 
|         |   4058                 } | 
|         |   4059             } | 
|         |   4060  | 
|         |   4061  | 
|         |   4062         if (err == KErrNone) | 
|         |   4063             { | 
|         |   4064             // needs to be implemented with active objects | 
|         |   4065             // CAknProgressDialog* dlg = new(ELeave) CAknProgressDialog(formatCount, 1, 1, NULL); | 
|         |   4066             // dlg->SetTone(CAknNoteDialog::ENoTone); | 
|         |   4067             // dlg->ExecuteLD(R_FORMAT_PROGRESS_NOTE); | 
|         |   4068  | 
|         |   4069             while (formatCount && err == KErrNone) | 
|         |   4070                 { | 
|         |   4071                 err = format.Next(formatCount); | 
|         |   4072                 } | 
|         |   4073             } | 
|         |   4074  | 
|         |   4075         format.Close(); | 
|         |   4076  | 
|         |   4077         // restart closed applications | 
|         |   4078         TBackupOperationAttributes atts2(MBackupObserver::ETakeLock, MBackupOperationObserver::EEnd); | 
|         |   4079         BSWrapper->NotifyBackupOperationL(atts2); | 
|         |   4080         BSWrapper->RestartAll(); | 
|         |   4081         CleanupStack::PopAndDestroy(); //BSWrapper | 
|         |   4082  | 
|         |   4083         // system status not needed anymore | 
|         |   4084         iEngine->EikonEnv()->SetSystem(EFalse); | 
|         |   4085  | 
|         |   4086  | 
|         |   4087         if (err == KErrNone) | 
|         |   4088             { | 
|         |   4089             iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Format succeeded")); | 
|         |   4090             } | 
|         |   4091         else if (err == KErrNotSupported) | 
|         |   4092             { | 
|         |   4093             iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); | 
|         |   4094             } | 
|         |   4095         else | 
|         |   4096             { | 
|         |   4097             CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); | 
|         |   4098  | 
|         |   4099             iEngine->FileBrowserUI()->ShowErrorNote( | 
|         |   4100                     textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); | 
|         |   4101  | 
|         |   4102             CleanupStack::PopAndDestroy();  //textResolver | 
|         |   4103             } | 
|         |   4104  | 
|         |   4105         RefreshViewL(); | 
|         |   4106         } | 
|         |   4107     } | 
|         |   4108  | 
|         |   4109 // -------------------------------------------------------------------------------------------- | 
|         |   4110  | 
|         |   4111 void CFileBrowserFileUtils::EraseMBRL(TInt aIndex) | 
|         |   4112     { | 
|         |   4113     // TODO | 
|         |   4114     #ifndef FILEBROWSER_LITE | 
|         |   4115     if (iEngine->Settings().iBypassPlatformSecurity) | 
|         |   4116         {         | 
|         |   4117         if (iDriveEntryList->Count() > aIndex && aIndex >= 0) | 
|         |   4118             { | 
|         |   4119             TDriveEntry driveEntry = iDriveEntryList->At(aIndex); | 
|         |   4120  | 
|         |   4121             TInt err(KErrNone); | 
|         |   4122  | 
|         |   4123             iEngine->FileBrowserUI()->ShowInformationNote(_L("Please wait, this may take 30 seconds"), _L("")); | 
|         |   4124  | 
|         |   4125             // set as system application to prevent getting shut down events | 
|         |   4126             iEngine->EikonEnv()->SetSystem(ETrue); | 
|         |   4127  | 
|         |   4128             // first close any open applications | 
|         |   4129             CBaBackupSessionWrapper* BSWrapper = CBaBackupSessionWrapper::NewL(); | 
|         |   4130             CleanupStack::PushL(BSWrapper); | 
|         |   4131  | 
|         |   4132             TBackupOperationAttributes atts(MBackupObserver::EReleaseLockNoAccess, MBackupOperationObserver::EStart); | 
|         |   4133             BSWrapper->NotifyBackupOperationL(atts); | 
|         |   4134  | 
|         |   4135             CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); | 
|         |   4136             BSWrapper->CloseAll( MBackupObserver::EReleaseLockNoAccess, waiter->iStatus ); | 
|         |   4137             waiter->StartAndWait(); | 
|         |   4138             CleanupStack::PopAndDestroy(); //waiter | 
|         |   4139  | 
|         |   4140             // some delay to make sure all applications have been closed | 
|         |   4141             User::After(1000000); | 
|         |   4142  | 
|         |   4143  | 
|         |   4144             // do the erase MBR operation | 
|         |   4145             err = iFileOps->EraseMBR(driveEntry.iNumber); | 
|         |   4146  | 
|         |   4147  | 
|         |   4148             // restart closed applications | 
|         |   4149             TBackupOperationAttributes atts2(MBackupObserver::ETakeLock, MBackupOperationObserver::EEnd); | 
|         |   4150             BSWrapper->NotifyBackupOperationL(atts2); | 
|         |   4151             BSWrapper->RestartAll(); | 
|         |   4152             CleanupStack::PopAndDestroy(); //BSWrapper | 
|         |   4153  | 
|         |   4154             // system status not needed anymore | 
|         |   4155             iEngine->EikonEnv()->SetSystem(EFalse); | 
|         |   4156  | 
|         |   4157  | 
|         |   4158             if (err == KErrNone) | 
|         |   4159                 { | 
|         |   4160                 iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Erase MBR succeeded")); | 
|         |   4161                 } | 
|         |   4162             else if (err == KErrNotSupported) | 
|         |   4163                 { | 
|         |   4164                 iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); | 
|         |   4165                 } | 
|         |   4166             else | 
|         |   4167                 { | 
|         |   4168                 CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); | 
|         |   4169  | 
|         |   4170                 iEngine->FileBrowserUI()->ShowErrorNote( | 
|         |   4171                         textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); | 
|         |   4172  | 
|         |   4173                 CleanupStack::PopAndDestroy();  //textResolver | 
|         |   4174                 } | 
|         |   4175  | 
|         |   4176             RefreshViewL(); | 
|         |   4177             } | 
|         |   4178         } | 
|         |   4179     else | 
|         |   4180         { | 
|         |   4181         iEngine->FileBrowserUI()->ShowInformationNote(_L("Enable \"bypass platform security\" from the settings first"), _L("")); | 
|         |   4182         } | 
|         |   4183     #else | 
|         |   4184         iEngine->FileBrowserUI()->ShowInformationNote(_L("Not supported in lite version"), _L("")); | 
|         |   4185     #endif | 
|         |   4186     } | 
|         |   4187      | 
|         |   4188 // -------------------------------------------------------------------------------------------- | 
|         |   4189  | 
|         |   4190 void CFileBrowserFileUtils::PartitionDriveL(TInt aIndex, TBool aEraseMBR, TInt aAmountOfPartitions) | 
|         |   4191     { | 
|         |   4192     // TODO | 
|         |   4193     #ifndef FILEBROWSER_LITE | 
|         |   4194     if (iEngine->Settings().iBypassPlatformSecurity) | 
|         |   4195         { | 
|         |   4196         if (iDriveEntryList->Count() > aIndex && aIndex >= 0) | 
|         |   4197             { | 
|         |   4198             TDriveEntry driveEntry = iDriveEntryList->At(aIndex); | 
|         |   4199  | 
|         |   4200             TInt err(KErrNone); | 
|         |   4201  | 
|         |   4202             iEngine->FileBrowserUI()->ShowInformationNote(_L("Please wait, this may take 30 seconds"), _L("")); | 
|         |   4203  | 
|         |   4204             // set as system application to prevent getting shut down events | 
|         |   4205             iEngine->EikonEnv()->SetSystem(ETrue); | 
|         |   4206  | 
|         |   4207             // first close any open applications | 
|         |   4208             CBaBackupSessionWrapper* BSWrapper = CBaBackupSessionWrapper::NewL(); | 
|         |   4209             CleanupStack::PushL(BSWrapper); | 
|         |   4210  | 
|         |   4211             TBackupOperationAttributes atts(MBackupObserver::EReleaseLockNoAccess, MBackupOperationObserver::EStart); | 
|         |   4212             BSWrapper->NotifyBackupOperationL(atts); | 
|         |   4213  | 
|         |   4214             CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); | 
|         |   4215             BSWrapper->CloseAll( MBackupObserver::EReleaseLockNoAccess, waiter->iStatus ); | 
|         |   4216             waiter->StartAndWait(); | 
|         |   4217             CleanupStack::PopAndDestroy(); //waiter | 
|         |   4218  | 
|         |   4219             // some delay to make sure all applications have been closed | 
|         |   4220             User::After(1000000); | 
|         |   4221  | 
|         |   4222             // do the erase operation | 
|         |   4223             if (aEraseMBR) | 
|         |   4224                 { | 
|         |   4225                 err = iFileOps->EraseMBR(driveEntry.iNumber); | 
|         |   4226  | 
|         |   4227                 if (err != KErrNone) | 
|         |   4228                     { | 
|         |   4229                     iEngine->FileBrowserUI()->ShowErrorNote(_L("Erase MBR failed")); | 
|         |   4230                     } | 
|         |   4231  | 
|         |   4232                 User::After(500000); | 
|         |   4233                 } | 
|         |   4234  | 
|         |   4235  | 
|         |   4236             // do the partition operation | 
|         |   4237             err = iFileOps->PartitionDrive(driveEntry.iNumber, aAmountOfPartitions); | 
|         |   4238  | 
|         |   4239  | 
|         |   4240             // restart closed applications | 
|         |   4241             TBackupOperationAttributes atts2(MBackupObserver::ETakeLock, MBackupOperationObserver::EEnd); | 
|         |   4242             BSWrapper->NotifyBackupOperationL(atts2); | 
|         |   4243             BSWrapper->RestartAll(); | 
|         |   4244             CleanupStack::PopAndDestroy(); //BSWrapper | 
|         |   4245  | 
|         |   4246             // system status not needed anymore | 
|         |   4247             iEngine->EikonEnv()->SetSystem(EFalse); | 
|         |   4248  | 
|         |   4249  | 
|         |   4250             if (err == KErrNone) | 
|         |   4251                 { | 
|         |   4252                 iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Partition succeeded")); | 
|         |   4253                 } | 
|         |   4254             else if (err == KErrNotSupported) | 
|         |   4255                 { | 
|         |   4256                 iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); | 
|         |   4257                 } | 
|         |   4258             else | 
|         |   4259                 { | 
|         |   4260                 CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); | 
|         |   4261  | 
|         |   4262                 iEngine->FileBrowserUI()->ShowErrorNote( | 
|         |   4263                         textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); | 
|         |   4264  | 
|         |   4265                 CleanupStack::PopAndDestroy();  //textResolver | 
|         |   4266                 } | 
|         |   4267  | 
|         |   4268             RefreshViewL(); | 
|         |   4269             } | 
|         |   4270         } | 
|         |   4271     else | 
|         |   4272         { | 
|         |   4273         iEngine->FileBrowserUI()->ShowInformationNote(_L("Enable \"bypass platform security\" from the settings first"), _L("")); | 
|         |   4274         } | 
|         |   4275     #else | 
|         |   4276         iEngine->FileBrowserUI()->ShowInformationNote(_L("Not supported in lite version"), _L("")); | 
|         |   4277     #endif | 
|         |   4278 	} | 
|         |   4279      | 
|         |   4280 // -------------------------------------------------------------------------------------------- | 
|         |   4281  | 
|         |   4282 void CFileBrowserFileUtils::CheckDiskL(TInt aIndex) | 
|         |   4283     {     | 
|         |   4284     if (iDriveEntryList->Count() > aIndex && aIndex >= 0) | 
|         |   4285         { | 
|         |   4286         TDriveEntry driveEntry = iDriveEntryList->At(aIndex); | 
|         |   4287          | 
|         |   4288         TBuf<10> driveRoot; | 
|         |   4289         driveRoot.Append(driveEntry.iLetter); | 
|         |   4290         driveRoot.Append(_L(":")); | 
|         |   4291          | 
|         |   4292         // check disk | 
|         |   4293         TInt err = iFs.CheckDisk(driveRoot); | 
|         |   4294  | 
|         |   4295         if (err == KErrNone) | 
|         |   4296             { | 
|         |   4297             iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Integrity of the disk is ok")); | 
|         |   4298             } | 
|         |   4299         else if (err == KErrNotReady) | 
|         |   4300             { | 
|         |   4301             iEngine->FileBrowserUI()->ShowInformationNote(_L("Disk is empty"), _L("")); | 
|         |   4302             } | 
|         |   4303         else if (err == KErrNotSupported) | 
|         |   4304             { | 
|         |   4305             iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); | 
|         |   4306             } | 
|         |   4307         else | 
|         |   4308             { | 
|         |   4309             iEngine->FileBrowserUI()->ShowErrorNote(_L("Disk is corrupted")); | 
|         |   4310             }         | 
|         |   4311  | 
|         |   4312         RefreshViewL(); | 
|         |   4313         } | 
|         |   4314     } | 
|         |   4315  | 
|         |   4316 // -------------------------------------------------------------------------------------------- | 
|         |   4317  | 
|         |   4318 void CFileBrowserFileUtils::ScanDriveL(TInt aIndex) | 
|         |   4319     { | 
|         |   4320     if (iDriveEntryList->Count() > aIndex && aIndex >= 0) | 
|         |   4321         { | 
|         |   4322         TDriveEntry driveEntry = iDriveEntryList->At(aIndex); | 
|         |   4323  | 
|         |   4324         TBuf<10> driveRoot; | 
|         |   4325         driveRoot.Append(driveEntry.iLetter); | 
|         |   4326         driveRoot.Append(_L(":")); | 
|         |   4327  | 
|         |   4328         // scan disk | 
|         |   4329         TInt err = iFs.ScanDrive(driveRoot); | 
|         |   4330  | 
|         |   4331         if (err == KErrNone) | 
|         |   4332             { | 
|         |   4333             iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Run succesfully")); | 
|         |   4334             } | 
|         |   4335         else if (err == KErrNotSupported) | 
|         |   4336             { | 
|         |   4337             iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); | 
|         |   4338             } | 
|         |   4339         else | 
|         |   4340             { | 
|         |   4341             CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); | 
|         |   4342  | 
|         |   4343             iEngine->FileBrowserUI()->ShowErrorNote( | 
|         |   4344                     textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); | 
|         |   4345  | 
|         |   4346             CleanupStack::PopAndDestroy();  //textResolver | 
|         |   4347             } | 
|         |   4348  | 
|         |   4349         RefreshViewL(); | 
|         |   4350         } | 
|         |   4351     } | 
|         |   4352  | 
|         |   4353 // -------------------------------------------------------------------------------------------- | 
|         |   4354  | 
|         |   4355 void CFileBrowserFileUtils::GetDriveName(TInt aIndex, TFileName &aDriveName) | 
|         |   4356     { | 
|         |   4357     if (iDriveEntryList->Count() > aIndex && aIndex >= 0) | 
|         |   4358         { | 
|         |   4359         TDriveEntry driveEntry = iDriveEntryList->At(aIndex); | 
|         |   4360  | 
|         |   4361         // get existing drive name | 
|         |   4362         iFs.GetDriveName(driveEntry.iNumber, aDriveName); | 
|         |   4363         } | 
|         |   4364     } | 
|         |   4365  | 
|         |   4366 // -------------------------------------------------------------------------------------------- | 
|         |   4367  | 
|         |   4368 void CFileBrowserFileUtils::SetDriveNameL(TInt aIndex, const TFileName &aDriveName) | 
|         |   4369     { | 
|         |   4370     if (iDriveEntryList->Count() > aIndex && aIndex >= 0) | 
|         |   4371         { | 
|         |   4372         TDriveEntry driveEntry = iDriveEntryList->At(aIndex); | 
|         |   4373  | 
|         |   4374         // set drive name | 
|         |   4375         TInt err = iFs.SetDriveName(driveEntry.iNumber, aDriveName); | 
|         |   4376  | 
|         |   4377         if (err == KErrNone) | 
|         |   4378             { | 
|         |   4379             iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Name changed")); | 
|         |   4380             } | 
|         |   4381         else if (err == KErrNotSupported) | 
|         |   4382             { | 
|         |   4383             iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); | 
|         |   4384             } | 
|         |   4385         else | 
|         |   4386             { | 
|         |   4387             CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); | 
|         |   4388  | 
|         |   4389             iEngine->FileBrowserUI()->ShowErrorNote( | 
|         |   4390                     textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); | 
|         |   4391  | 
|         |   4392             CleanupStack::PopAndDestroy();  //textResolver | 
|         |   4393             } | 
|         |   4394  | 
|         |   4395         RefreshViewL(); | 
|         |   4396         } | 
|         |   4397     } | 
|         |   4398  | 
|         |   4399 // -------------------------------------------------------------------------------------------- | 
|         |   4400  | 
|         |   4401 void CFileBrowserFileUtils::GetDriveVolumeLabel(TInt aIndex, TFileName &aVolumeLabel) | 
|         |   4402     { | 
|         |   4403     if (iDriveEntryList->Count() > aIndex && aIndex >= 0) | 
|         |   4404         { | 
|         |   4405         TDriveEntry driveEntry = iDriveEntryList->At(aIndex); | 
|         |   4406  | 
|         |   4407         // get existing volume label | 
|         |   4408         aVolumeLabel.Copy(driveEntry.iVolumeInfo.iName); | 
|         |   4409         } | 
|         |   4410     } | 
|         |   4411  | 
|         |   4412 // -------------------------------------------------------------------------------------------- | 
|         |   4413  | 
|         |   4414 void CFileBrowserFileUtils::SetDriveVolumeLabelL(TInt aIndex, const TFileName &aVolumeLabel) | 
|         |   4415     { | 
|         |   4416     if (iDriveEntryList->Count() > aIndex && aIndex >= 0) | 
|         |   4417         { | 
|         |   4418         TDriveEntry driveEntry = iDriveEntryList->At(aIndex); | 
|         |   4419  | 
|         |   4420         // set volume label | 
|         |   4421         TInt err = iFs.SetVolumeLabel(aVolumeLabel, driveEntry.iNumber); | 
|         |   4422  | 
|         |   4423         if (err == KErrNone) | 
|         |   4424             { | 
|         |   4425             iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Volume label changed")); | 
|         |   4426             } | 
|         |   4427         else if (err == KErrNotSupported) | 
|         |   4428             { | 
|         |   4429             iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); | 
|         |   4430             } | 
|         |   4431         else | 
|         |   4432             { | 
|         |   4433             CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); | 
|         |   4434  | 
|         |   4435             iEngine->FileBrowserUI()->ShowErrorNote( | 
|         |   4436                     textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); | 
|         |   4437  | 
|         |   4438             CleanupStack::PopAndDestroy();  //textResolver | 
|         |   4439             } | 
|         |   4440  | 
|         |   4441         RefreshViewL(); | 
|         |   4442         } | 
|         |   4443     } | 
|         |   4444  | 
|         |   4445 // -------------------------------------------------------------------------------------------- | 
|         |   4446  | 
|         |   4447 void CFileBrowserFileUtils::EjectDriveL(TInt aIndex) | 
|         |   4448     { | 
|         |   4449     if (iDriveEntryList->Count() > aIndex && aIndex >= 0) | 
|         |   4450         { | 
|         |   4451         TDriveEntry driveEntry = iDriveEntryList->At(aIndex); | 
|         |   4452          | 
|         |   4453         TInt err(KErrNone); | 
|         |   4454          | 
|         |   4455         // get current filesystem name | 
|         |   4456         TFileName fileSystemName; | 
|         |   4457         err = iFs.FileSystemName(fileSystemName, driveEntry.iNumber); | 
|         |   4458          | 
|         |   4459         if (err == KErrNone) | 
|         |   4460             { | 
|         |   4461             // Prevent SysAp shutting down applications | 
|         |   4462             RProperty::Set( | 
|         |   4463                 KPSUidCoreApplicationUIs, | 
|         |   4464                 KCoreAppUIsMmcRemovedWithoutEject, | 
|         |   4465                 ECoreAppUIsEjectCommandUsed ); | 
|         |   4466              | 
|         |   4467             // dismount the file system | 
|         |   4468             err = iFs.DismountFileSystem(fileSystemName, driveEntry.iNumber); | 
|         |   4469              | 
|         |   4470             if (err == KErrNone) | 
|         |   4471                 { | 
|         |   4472                 // remount the file system | 
|         |   4473                 err = iFs.MountFileSystem(fileSystemName, driveEntry.iNumber); | 
|         |   4474                  | 
|         |   4475                 if (err == KErrInUse) | 
|         |   4476                     { | 
|         |   4477                     // try to remount after a while if locked | 
|         |   4478                     User::After(1000000); | 
|         |   4479                     err = iFs.MountFileSystem(fileSystemName, driveEntry.iNumber); | 
|         |   4480                     }                 | 
|         |   4481                 } | 
|         |   4482             } | 
|         |   4483  | 
|         |   4484         if (err == KErrNone) | 
|         |   4485             { | 
|         |   4486             iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Ejected succesfully")); | 
|         |   4487             } | 
|         |   4488         else if (err == KErrNotSupported) | 
|         |   4489             { | 
|         |   4490             iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); | 
|         |   4491             } | 
|         |   4492         else | 
|         |   4493             { | 
|         |   4494             CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); | 
|         |   4495  | 
|         |   4496             iEngine->FileBrowserUI()->ShowErrorNote( | 
|         |   4497                     textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); | 
|         |   4498  | 
|         |   4499             CleanupStack::PopAndDestroy();  //textResolver | 
|         |   4500             }               | 
|         |   4501  | 
|         |   4502         RefreshViewL(); | 
|         |   4503         } | 
|         |   4504     } | 
|         |   4505      | 
|         |   4506 // -------------------------------------------------------------------------------------------- | 
|         |   4507  | 
|         |   4508 void CFileBrowserFileUtils::DismountFileSystemL(TInt aIndex) | 
|         |   4509     { | 
|         |   4510     if (iDriveEntryList->Count() > aIndex && aIndex >= 0) | 
|         |   4511         { | 
|         |   4512         TDriveEntry driveEntry = iDriveEntryList->At(aIndex); | 
|         |   4513  | 
|         |   4514         TInt err(KErrNone); | 
|         |   4515  | 
|         |   4516         // get current filesystem name | 
|         |   4517         TFileName fileSystemName; | 
|         |   4518         err = iFs.FileSystemName(fileSystemName, driveEntry.iNumber); | 
|         |   4519  | 
|         |   4520         if (err == KErrNone) | 
|         |   4521             { | 
|         |   4522             // Prevent SysAp shutting down applications | 
|         |   4523             RProperty::Set( | 
|         |   4524                 KPSUidCoreApplicationUIs, | 
|         |   4525                 KCoreAppUIsMmcRemovedWithoutEject, | 
|         |   4526                 ECoreAppUIsEjectCommandUsed ); | 
|         |   4527  | 
|         |   4528             // dismount the file system | 
|         |   4529             err = iFs.DismountFileSystem(fileSystemName, driveEntry.iNumber); | 
|         |   4530             } | 
|         |   4531  | 
|         |   4532         if (err == KErrNone) | 
|         |   4533             { | 
|         |   4534             iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Dismounted succesfully")); | 
|         |   4535             } | 
|         |   4536         else if (err == KErrNotSupported) | 
|         |   4537             { | 
|         |   4538             iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); | 
|         |   4539             } | 
|         |   4540         else | 
|         |   4541             { | 
|         |   4542             CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); | 
|         |   4543  | 
|         |   4544             iEngine->FileBrowserUI()->ShowErrorNote( | 
|         |   4545                     textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); | 
|         |   4546  | 
|         |   4547             CleanupStack::PopAndDestroy();  //textResolver | 
|         |   4548             } | 
|         |   4549  | 
|         |   4550         RefreshViewL(); | 
|         |   4551         } | 
|         |   4552     } | 
|         |   4553      | 
|         |   4554 // -------------------------------------------------------------------------------------------- | 
|         |   4555  | 
|         |   4556 void CFileBrowserFileUtils::ConvertCharsToPwd(const TDesC& aWord, TDes8& aConverted) const | 
|         |   4557     { | 
|         |   4558     aConverted.FillZ(aConverted.MaxLength()); | 
|         |   4559     aConverted.Zero(); | 
|         |   4560      | 
|         |   4561     if (aWord.Length()) | 
|         |   4562         { | 
|         |   4563         aConverted.Copy( (TUint8*)(&aWord[0]), aWord.Size() ); | 
|         |   4564         } | 
|         |   4565     } | 
|         |   4566  | 
|         |   4567 // -------------------------------------------------------------------------------------------- | 
|         |   4568  | 
|         |   4569 void CFileBrowserFileUtils::EditDataTypesL() | 
|         |   4570     { | 
|         |   4571 	// TODO | 
|         |   4572 	/* | 
|         |   4573     iEngine->FileListContainer()->SetScreenLayoutL(EDisplayModeNormal); | 
|         |   4574     iEngine->FileListContainer()->SetNaviPaneTextL(KNullDesC); | 
|         |   4575      | 
|         |   4576     CFileBrowserDataTypesDlg* dlg = CFileBrowserDataTypesDlg::NewL(); | 
|         |   4577     dlg->RunQueryLD(); | 
|         |   4578  | 
|         |   4579     iEngine->FileListContainer()->SetScreenLayoutL(iEngine->Settings().iDisplayMode); | 
|         |   4580     iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath);   | 
|         |   4581 	*/	 | 
|         |   4582     } | 
|         |   4583  | 
|         |   4584 // -------------------------------------------------------------------------------------------- | 
|         |   4585  | 
|         |   4586 void CFileBrowserFileUtils::SecureBackupL(TInt aType) | 
|         |   4587     { | 
|         |   4588     TInt err(KErrNone); | 
|         |   4589     TInt showStatus(EFalse); | 
|         |   4590      | 
|         |   4591     if (aType == EFileBrowserCmdToolsSecureBackupStartBackup || aType == EFileBrowserCmdToolsSecureBackupStartRestore) | 
|         |   4592         { | 
|         |   4593 //        TInt queryIndexState(0); | 
|         |   4594 //        TInt queryIndexType(0); | 
|         |   4595          | 
|         |   4596 //        CAknListQueryDialog* listQueryDlgState = new(ELeave) CAknListQueryDialog(&queryIndexState); | 
|         |   4597 //        if (listQueryDlgState->ExecuteLD(R_SECUREBACKUP_STATE_QUERY)) | 
|         |   4598 //            { | 
|         |   4599 // | 
|         |   4600 //            CAknListQueryDialog* listQueryDlgType = new(ELeave) CAknListQueryDialog(&queryIndexType); | 
|         |   4601 //            if (listQueryDlgType->ExecuteLD(R_SECUREBACKUP_TYPE_QUERY)) | 
|         |   4602 //                { | 
|         |   4603 //                conn::TBURPartType partType = conn::EBURNormal; | 
|         |   4604 //                conn::TBackupIncType backupIncType = conn::ENoBackup; | 
|         |   4605 //                 | 
|         |   4606 //                if (aType == EFileBrowserCmdToolsSecureBackupStartBackup) | 
|         |   4607 //                    { | 
|         |   4608 //                    if (queryIndexState == ESecureBackupStateFull) | 
|         |   4609 //                        partType = conn::EBURBackupFull; | 
|         |   4610 //                    else if (queryIndexState == ESecureBackupStatePartial) | 
|         |   4611 //                        partType = conn::EBURBackupPartial; | 
|         |   4612 //                    } | 
|         |   4613 //                else if (aType == EFileBrowserCmdToolsSecureBackupStartRestore) | 
|         |   4614 //                    { | 
|         |   4615 //                    if (queryIndexState == ESecureBackupStateFull) | 
|         |   4616 //                        partType = conn::EBURRestoreFull; | 
|         |   4617 //                    else if (queryIndexState == ESecureBackupStatePartial) | 
|         |   4618 //                        partType = conn::EBURRestorePartial; | 
|         |   4619 //                    } | 
|         |   4620 //                     | 
|         |   4621 //                if (queryIndexType == ESecureBackupTypeBase) | 
|         |   4622 //                    backupIncType = conn::EBackupBase; | 
|         |   4623 //                else if (queryIndexType == ESecureBackupTypeIncremental)     | 
|         |   4624 //                    backupIncType = conn::EBackupIncrement;     | 
|         |   4625 // | 
|         |   4626 //                // start secure backup | 
|         |   4627 //                err = iFileOps->ActivateSecureBackUp(partType, backupIncType); | 
|         |   4628 //                showStatus = ETrue; | 
|         |   4629 //                } | 
|         |   4630 //            } | 
|         |   4631         } | 
|         |   4632  | 
|         |   4633     else if (aType == EFileBrowserCmdToolsSecureBackupStop) | 
|         |   4634         { | 
|         |   4635         err = iFileOps->DeActivateSecureBackUp(); | 
|         |   4636         showStatus = ETrue; | 
|         |   4637         } | 
|         |   4638  | 
|         |   4639     else | 
|         |   4640         User::Panic(_L("Sec.br.mode"), 101); | 
|         |   4641      | 
|         |   4642      | 
|         |   4643     if (showStatus) | 
|         |   4644         { | 
|         |   4645         if (err == KErrNone) | 
|         |   4646             { | 
|         |   4647             iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Succeeded")); | 
|         |   4648             } | 
|         |   4649         else | 
|         |   4650             { | 
|         |   4651             CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); | 
|         |   4652  | 
|         |   4653             iEngine->FileBrowserUI()->ShowErrorNote( | 
|         |   4654                     textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); | 
|         |   4655  | 
|         |   4656             CleanupStack::PopAndDestroy();  //textResolver | 
|         |   4657             }   | 
|         |   4658         } | 
|         |   4659     } | 
|         |   4660  | 
|         |   4661 // -------------------------------------------------------------------------------------------- | 
|         |   4662  | 
|         |   4663 void CFileBrowserFileUtils::OpenCommonFileActionQueryL(TInt aCurrentItemIndex) | 
|         |   4664     { | 
|         |   4665     // TODO | 
|         |   4666     // just get current item | 
|         |   4667 //    TInt currentItemIndex = iEngine->QueryCurrentItemIndex(); | 
|         |   4668  | 
|         |   4669     if (iFileEntryList->Count() > aCurrentItemIndex && aCurrentItemIndex >= 0) | 
|         |   4670         { | 
|         |   4671 //        TInt queryIndex(0); | 
|         |   4672 // | 
|         |   4673 //        CAknListQueryDialog* listQueryDlg = new(ELeave) CAknListQueryDialog(&queryIndex); | 
|         |   4674 // | 
|         |   4675 //        if (listQueryDlg->ExecuteLD(R_COMMON_FILE_ACTION_QUERY)) | 
|         |   4676 //            { | 
|         |   4677 //            if (queryIndex == ECommonFileActionViewAsTextHex) | 
|         |   4678 //                { | 
|         |   4679 //                TFileEntry fileEntry = iFileEntryList->At(aCurrentItemIndex); | 
|         |   4680 // | 
|         |   4681 //                TFileName fullPath = fileEntry.iPath; | 
|         |   4682 //                fullPath.Append(fileEntry.iEntry.iName); | 
|         |   4683 // | 
|         |   4684 //                TInt viewerType(EFileBrowserCmdFileViewHex); | 
|         |   4685 // | 
|         |   4686 //                // check from mime type if it's text | 
|         |   4687 //                TDataType dataType; | 
|         |   4688 //                TUid appUid; | 
|         |   4689 //                if (iEngine->LsSession().AppForDocument(fullPath, appUid, dataType) == KErrNone) | 
|         |   4690 //                    { | 
|         |   4691 //                    TBuf<128> mimeTypeBuf; | 
|         |   4692 //                    mimeTypeBuf.Copy(dataType.Des8()); | 
|         |   4693 //                    if (mimeTypeBuf == KNullDesC) | 
|         |   4694 //                        mimeTypeBuf.Copy(_L("N/A")); | 
|         |   4695 // | 
|         |   4696 //                    if (mimeTypeBuf.CompareF(_L("text/plain")) == 0) | 
|         |   4697 //                        viewerType = EFileBrowserCmdFileViewText; | 
|         |   4698 //                    } | 
|         |   4699 // | 
|         |   4700 //                FileEditorL(viewerType); | 
|         |   4701 //                } | 
|         |   4702 // | 
|         |   4703 //            else if (queryIndex == ECommonFileActionOpenWithApparc) | 
|         |   4704 //                { | 
|         |   4705 //                // TODO | 
|         |   4706 //                //OpenWithApparcL(); | 
|         |   4707 //                } | 
|         |   4708 // | 
|         |   4709 //            else if (queryIndex == ECommonFileActionOpenWithDocHandlerEmbed) | 
|         |   4710 //                { | 
|         |   4711 //                // TODO | 
|         |   4712 //                //OpenWithDocHandlerL(ETrue); | 
|         |   4713 //                } | 
|         |   4714 // | 
|         |   4715 //            else | 
|         |   4716 //                User::Panic(_L("Unk.Com.Act"), 221); | 
|         |   4717 //            } | 
|         |   4718         } | 
|         |   4719     } | 
|         |   4720      | 
|         |   4721 // -------------------------------------------------------------------------------------------- | 
|         |   4722 	             | 
|         |   4723 // End of File |