creator/src/engine.cpp
branchGCC_SURGE
changeset 37 c20154ccf3c0
parent 35 98924d2efce9
child 48 da3ec8478e66
equal deleted inserted replaced
20:ba8a586c45f1 37:c20154ccf3c0
    14 * Description: 
    14 * Description: 
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include <EIKENV.H>
    19 #include <eikenv.h>
    20 #include <S32FILE.H> 
    20 #include <s32file.h> 
    21 #include <coemain.h>
    21 #include <coemain.h>
       
    22 
       
    23 #include <driveinfo.h>
    22 
    24 
    23 #include <datacreator.rsg>
    25 #include <datacreator.rsg>
    24 
    26 
    25 #include "mainview.h"
    27 #include "mainview.h"
    26 #include "engine.h"
    28 #include "engine.h"
    27 #include "enginewrapper.h"
    29 #include "enginewrapper.h"
    28 
    30 
    29 
    31 
    30 #include <cntdb.h>//For Math
    32 #include <cntdb.h>//For Math
       
    33 
       
    34 #include "creator_scriptentry.h"
       
    35 #include "creator_modulebase.h"
       
    36 //#include "creator_browser.h"
       
    37 #include "creator_calendar.h"
       
    38 #include "creator_phonebookbase.h"
       
    39 #include "creator_note.h"
       
    40 #include "creator_log.h"
       
    41 //#include "creator_connectionmethodbase.h"
       
    42 #include "creator_mailbox.h"
       
    43 //#include "creator_imps.h"
       
    44 #include "creator_message.h"
       
    45 #include "creator_landmark.h"
    31 
    46 
    32 
    47 
    33 #include "creator_traces.h"
    48 #include "creator_traces.h"
    34 #include "creator_factory.h"
    49 #include "creator_factory.h"
    35 #include "creator_scriptparser.h"
    50 #include "creator_scriptparser.h"
    36 #include "creator_file.h"
    51 #include "creator_file.h"
    37 #include "creator_cmdscriptrun.h"
    52 #include "creator_cmdscriptrun.h"
    38 
    53 #include "creator_contactsetcache.h"
    39 
    54 
    40 #include <apparc.h>
    55 #include <apparc.h>
    41 #include <eikappui.h>
    56 #include <eikappui.h>
    42 #include <eikapp.h>
    57 #include <eikapp.h>
    43 #include <bitmaptransforms.h>
    58 #include <bitmaptransforms.h>
    44 
    59 
    45 _LIT(KEDriveError, "Not available");
    60 _LIT(KEDriveError, "Not available");
    46 _LIT(KTempPathDrive, "d");
    61 _LIT(KTempPathDrive, "d");
    47 _LIT(KTempPath, ":\\Creator\\");
    62 _LIT(KTempPath, ":\\Creator\\");
    48 _LIT(KSavingText, "Saving");
       
    49 _LIT(KDeletingText, "Deleting");
       
    50 const TInt KRegisterDrive = EDriveC;
    63 const TInt KRegisterDrive = EDriveC;
    51 _LIT(KRegisterFileName, "creator_created_items.dat");
    64 _LIT(KRegisterFileName, "creator_created_items.dat");
    52 _LIT(KResourceFileName, "z:\\Resource\\apps\\datacreator.RSC");
    65 _LIT(KResourceFileName, "z:\\Resource\\apps\\datacreator.RSC");
    53 
    66 
    54 
    67 
   127     iTimer.Close();
   140     iTimer.Close();
   128 
   141 
   129 
   142 
   130 	iEnv->DeleteResourceFile(iResourceFileId);
   143 	iEnv->DeleteResourceFile(iResourceFileId);
   131     
   144     
       
   145 	iMemoryDetailsList.Reset();
   132     delete iPictureFileArray;
   146     delete iPictureFileArray;
   133     delete iSoundFileArray;
   147     delete iSoundFileArray;
   134     delete iTempPath;
   148     delete iTempPath;
   135     delete iFrameImageData;
   149     delete iFrameImageData;
   136     delete iEncoder;
   150     delete iEncoder;
   139     delete iScaledBitmap;
   153     delete iScaledBitmap;
   140     delete iBitmap;
   154     delete iBitmap;
   141     delete iBitmapData;
   155     delete iBitmapData;
   142 	
   156 	
   143     delete iCmdScriptRun;
   157     delete iCmdScriptRun;
   144     iCmdScriptRun = NULL;	
   158     iCmdScriptRun = NULL;
       
   159     
       
   160     delete iCommandParser;
   145     }
   161     }
   146 
   162 
   147 void CCreatorEngine::CopyFileL(const TFileName& aSourceFile, const TFileName& aTargetFile, TBool aOverwrite )
   163 void CCreatorEngine::CopyFileL(const TFileName& aSourceFile, const TFileName& aTargetFile, TBool aOverwrite )
   148 	{
   164 	{
   149 	if( !aOverwrite && ConeUtils::FileExists(aTargetFile))
   165 	if( !aOverwrite && ConeUtils::FileExists(aTargetFile))
   159 
   175 
   160 // ---------------------------------------------------------------------------
   176 // ---------------------------------------------------------------------------
   161 	
   177 	
   162 void CCreatorEngine::RequestMemoryDetails() 
   178 void CCreatorEngine::RequestMemoryDetails() 
   163     {
   179     {
       
   180 
       
   181 	TDriveList dl;
   164     // variables for memory and disk handling
   182     // variables for memory and disk handling
   165     TDriveNumber cDrive=EDriveC;
       
   166     TDriveNumber dDrive=EDriveD;
       
   167     TDriveNumber eDrive=EDriveE;
       
   168     TVolumeInfo vinfo;
   183     TVolumeInfo vinfo;
   169     TBuf<16> cFree;
   184 
   170     TBuf<16> dFree;
   185     //*************************************************************************
   171     TBuf<16> eFree;
   186    
   172     TBuf<16> cSize;
   187     //*************************************************************************
   173     TBuf<16> dSize;
       
   174     TBuf<16> eSize;
       
   175 
       
   176     // get an access to file server
   188     // get an access to file server
   177     RFs& fsSession = CEikonEnv::Static()->FsSession();
   189     RFs& fsSession = CEikonEnv::Static()->FsSession();
   178 
   190 
   179     // check the C-drive
   191     fsSession.DriveList(dl);
   180     fsSession.Volume(vinfo, cDrive);
   192     
   181     iMemoryDetails.iCFree.Num(TInt64(vinfo.iFree/1024));
   193     for(TInt driveNum = EDriveC; driveNum <= EDriveZ ; driveNum ++ )
   182     iMemoryDetails.iCSize.Num(TInt64(vinfo.iSize/1024));
   194     	{
   183 
   195 		if( dl[driveNum] )
   184     // the same thing for D-drive
   196 			{
   185     fsSession.Volume(vinfo, dDrive);
   197 			TMemoryDetails *memDet = new TMemoryDetails;
   186 	iMemoryDetails.iDFree.Num(TInt64(vinfo.iFree/1024));
   198 			if(fsSession.Volume(vinfo, driveNum) == KErrNone)
   187 	iMemoryDetails.iDSize.Num(TInt64(vinfo.iSize/1024));
   199 				{
   188 
   200 				memDet->iFree.Num(TInt64(vinfo.iFree/1024));
   189     // the same thing for E-drive (MMC), if it exists 
   201 				memDet->iSize.Num(TInt64(vinfo.iSize/1024));
   190     if (MMC_OK())
   202 				}
   191         {
   203 			else
   192         fsSession.Volume(vinfo, eDrive);
   204 				{
   193         iMemoryDetails.iEFree.Num(TInt64(vinfo.iFree/1024));
   205 				memDet->iFree.Num( 0 );
   194 		iMemoryDetails.iESize.Num(TInt64(vinfo.iSize/1024));
   206 				memDet->iSize.Num( 0 );
   195 
   207 				}
   196         }
   208 			User::LeaveIfError(fsSession.DriveToChar(driveNum,memDet->iDriveLetter));
   197 	
   209 			iMemoryDetailsList.AppendL( memDet );
   198 	else {
   210 			}
   199 		iMemoryDetails.iEFree = KEDriveError;
   211     	}
   200 		iMemoryDetails.iENotAvailable = ETrue;
   212   
   201 		}
       
   202     // available work memory
   213     // available work memory
   203     TMemoryInfoV1Buf memory;
   214     TMemoryInfoV1Buf memory;
   204     UserHal::MemoryInfo(memory);
   215     UserHal::MemoryInfo(memory);
   205     TInt64 freeMemBytes=(TInt64)(memory().iFreeRamInBytes);
   216     TInt64 freeMemBytes=(TInt64)(memory().iFreeRamInBytes);
   206     TInt64 sizeMemBytes=(TInt64)(memory().iTotalRamInBytes);
   217     TInt64 sizeMemBytes=(TInt64)(memory().iTotalRamInBytes);
   207     TInt64 sizeWorkMemBytes = sizeMemBytes; 
   218     TInt64 sizeWorkMemBytes = sizeMemBytes; 
   208     iMemoryDetails.iHFree.Num(TInt64(freeMemBytes/1024));
   219     TInt64 sizeRomBytes = (TInt64)(memory().iTotalRomInBytes);
   209     iMemoryDetails.iHSize.Num(TInt64(sizeWorkMemBytes/1024));
   220     iMemoryDetails.iRamFree.Num(TInt64(freeMemBytes/1024));
       
   221     iMemoryDetails.iRamSize.Num(TInt64(sizeWorkMemBytes/1024));
       
   222     iMemoryDetails.iRomSize.Num(TInt64(sizeRomBytes/1024));
   210     }
   223     }
   211 
   224 
   212 // ---------------------------------------------------------------------------
   225 // ---------------------------------------------------------------------------
   213 	
   226 	
   214 TBool CCreatorEngine::MMC_OK() const
   227 TBool CCreatorEngine::MMC_OK() const
   289     // launch a command
   302     // launch a command
   290 
   303 
   291     TCreatorIds cmd = (TCreatorIds)iCommandArray->At(iCurrentEntry).iCommandId; 
   304     TCreatorIds cmd = (TCreatorIds)iCommandArray->At(iCurrentEntry).iCommandId; 
   292     switch( cmd )
   305     switch( cmd )
   293         {
   306         {
       
   307 /*        
   294 	    case ECmdCreateBrowserBookmarkEntries: { iBrowser->CreateBookmarkEntryL(reinterpret_cast<CBrowserParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   308 	    case ECmdCreateBrowserBookmarkEntries: { iBrowser->CreateBookmarkEntryL(reinterpret_cast<CBrowserParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   295 	    case ECmdCreateBrowserBookmarkFolderEntries: { iBrowser->CreateBookmarkFolderEntryL(reinterpret_cast<CBrowserParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   309 	    case ECmdCreateBrowserBookmarkFolderEntries: { iBrowser->CreateBookmarkFolderEntryL(reinterpret_cast<CBrowserParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   296 	    case ECmdCreateBrowserSavedPageEntries: { iBrowser->CreateSavedDeckEntryL(reinterpret_cast<CBrowserParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   310 	    case ECmdCreateBrowserSavedPageEntries: { iBrowser->CreateSavedDeckEntryL(reinterpret_cast<CBrowserParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   297 	    case ECmdCreateBrowserSavedPageFolderEntries: { iBrowser->CreateSavedDeckFolderEntryL(reinterpret_cast<CBrowserParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   311 	    case ECmdCreateBrowserSavedPageFolderEntries: { iBrowser->CreateSavedDeckFolderEntryL(reinterpret_cast<CBrowserParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   298 	    
   312 */	    
   299         case ECmdCreateCalendarEntryAppointments: { iCalendar->CreateAppointmentEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
   313         case ECmdCreateCalendarEntryAppointments: { iCalendar->CreateAppointmentEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
   300 	    case ECmdCreateCalendarEntryEvents: { iCalendar->CreateEventEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
   314 	    case ECmdCreateCalendarEntryEvents: { iCalendar->CreateEventEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
   301 	    case ECmdCreateCalendarEntryAnniversaries: { iCalendar->CreateAnniversaryEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
   315 	    case ECmdCreateCalendarEntryAnniversaries: { iCalendar->CreateAnniversaryEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
   302 	    case ECmdCreateCalendarEntryToDos: { iCalendar->CreateTodoEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
   316 	    case ECmdCreateCalendarEntryToDos: { iCalendar->CreateTodoEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
   303         case ECmdCreateCalendarEntryReminders: { iCalendar->CreateReminderEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
   317         case ECmdCreateCalendarEntryReminders: { iCalendar->CreateReminderEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
   310 	    case ECmdCreateMiscEntryNotes: { iNotepad->CreateNoteEntryL(reinterpret_cast<CNotepadParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   324 	    case ECmdCreateMiscEntryNotes: { iNotepad->CreateNoteEntryL(reinterpret_cast<CNotepadParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   311 
   325 
   312 	    case ECmdCreateLogEntryMissedCalls: { iLogs->CreateMissedCallEntryL(reinterpret_cast<CLogsParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   326 	    case ECmdCreateLogEntryMissedCalls: { iLogs->CreateMissedCallEntryL(reinterpret_cast<CLogsParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   313 	    case ECmdCreateLogEntryReceivedCalls: { iLogs->CreateReceivedCallEntryL(reinterpret_cast<CLogsParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   327 	    case ECmdCreateLogEntryReceivedCalls: { iLogs->CreateReceivedCallEntryL(reinterpret_cast<CLogsParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   314 	    case ECmdCreateLogEntryDialledNumbers: { iLogs->CreateDialledNumberEntryL(reinterpret_cast<CLogsParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   328 	    case ECmdCreateLogEntryDialledNumbers: { iLogs->CreateDialledNumberEntryL(reinterpret_cast<CLogsParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   315 
   329 /*
   316         case ECmdCreateMiscEntryAccessPoints: { iAccessPoints->CreateConnectionSettingsEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
   330         case ECmdCreateMiscEntryAccessPoints: { iAccessPoints->CreateConnectionSettingsEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break;
   317         case ECmdDeleteIAPs: { iAccessPoints->DeleteAllL(); } break;
   331         case ECmdDeleteIAPs: { iAccessPoints->DeleteAllL(); } break;
   318         case ECmdDeleteCreatorIAPs: { iAccessPoints->DeleteAllCreatedByCreatorL(); } break;
   332         case ECmdDeleteCreatorIAPs: { iAccessPoints->DeleteAllCreatedByCreatorL(); } break;
   319 
   333 */
   320         case ECmdCreateMiscEntryLandmarks: { iLandmarks->CreateLandmarkEntryL(reinterpret_cast<CLandmarkParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   334         case ECmdCreateMiscEntryLandmarks: { iLandmarks->CreateLandmarkEntryL(reinterpret_cast<CLandmarkParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   321         
   335         
   322 	    case ECmdCreateMessagingEntryMailboxes: { iMailboxes->CreateMailboxEntryL(reinterpret_cast<CMailboxesParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   336 	    case ECmdCreateMessagingEntryMailboxes: { iMailboxes->CreateMailboxEntryL(reinterpret_cast<CMailboxesParameters*>(iCommandArray->At(iCurrentEntry).iParameters)); } break;
   323 /*
   337 /*
   324         #ifdef __PRESENCE
   338         #ifdef __PRESENCE
   469         case ECmdDeleteNotes:
   483         case ECmdDeleteNotes:
   470             {
   484             {
   471             iNotepad->DeleteAllL();
   485             iNotepad->DeleteAllL();
   472             break;
   486             break;
   473             }
   487             }
   474 /*
   488 
   475         case ECmdDeleteIMPSs:
   489         case ECmdDeleteIMPSs:
   476             {
   490             {
   477             iIMPS->DeleteAllL();
   491 //            iIMPS->DeleteAllL();
   478             break;
   492             break;
   479             }
   493             }
   480         case ECmdDeleteCreatorIMPSs:
   494         case ECmdDeleteCreatorIMPSs:
   481             {
   495             {
   482             iIMPS->DeleteAllCreatedByCreatorL();
   496 //            iIMPS->DeleteAllCreatedByCreatorL();
   483             break;
   497             break;
   484             }
   498             }
   485 */
   499 /*            
   486         case ECmdDeleteBrowserBookmarks:
   500         case ECmdDeleteBrowserBookmarks:
   487             {
   501             {
   488             iBrowser->DeleteAllBookmarksL();
   502             iBrowser->DeleteAllBookmarksL();
   489             break;
   503             break;
   490             }
   504             }
   521         case ECmdDeleteCreatorBrowserSavedPageFolders:
   535         case ECmdDeleteCreatorBrowserSavedPageFolders:
   522             {
   536             {
   523             iBrowser->DeleteAllSavedPageFoldersCreatedByCreatorL();
   537             iBrowser->DeleteAllSavedPageFoldersCreatedByCreatorL();
   524             break;
   538             break;
   525             }
   539             }
       
   540 */            
   526         case ECmdDeleteCreatorFiles:
   541         case ECmdDeleteCreatorFiles:
   527             {
   542             {
   528             iFiles->DeleteAllCreatedByCreatorL();
   543             iFiles->DeleteAllCreatedByCreatorL();
   529             break;
   544             break;
   530             }
   545             }
   635         ExecuteCommand();
   650         ExecuteCommand();
   636 		}
   651 		}
   637     }
   652     }
   638 
   653 
   639 // ---------------------------------------------------------------------------
   654 // ---------------------------------------------------------------------------
       
   655 void CCreatorEngine::SortCommands()
       
   656 	{
       
   657 	TKeyArrayFix iBufKey(_FOFF(TCommand, iCommandId),ECmpTInt);
       
   658 	iCommandArray->Sort(iBufKey);
       
   659 	}
       
   660 // ---------------------------------------------------------------------------
   640 
   661 
   641 // This callback function is called when cancel button of the progress bar was pressed
   662 // This callback function is called when cancel button of the progress bar was pressed
   642 
   663 
   643 void CCreatorEngine::ProgressDialogCancelledL()
   664 void CCreatorEngine::ProgressDialogCancelledL()
   644     {
   665     {
   697     iUserCancelled = EFalse;
   718     iUserCancelled = EFalse;
   698     
   719     
   699     // start from the beginning
   720     // start from the beginning
   700     iCurrentEntry = 0;
   721     iCurrentEntry = 0;
   701 
   722 
   702     // we'll retrieve a correct number for this later
       
   703     iEntriesToBeCreated = 0;
       
   704 
       
   705     // init the command array
   723     // init the command array
   706     __ASSERT_ALWAYS(!iCommandArray, User::Panic(_L("iCommandArray"), 701));
   724     __ASSERT_ALWAYS(!iCommandArray, User::Panic(_L("iCommandArray"), 701));
   707     iCommandArray = new(ELeave) CCommandArray(10000);
   725     iCommandArray = new(ELeave) CCommandArray(10000);
   708 
   726 
   709     // init all modules here
   727     // init all modules here
   710     TInt err(KErrNone);
   728     TInt err(KErrNone);
   711     TRAP(err, iBrowser = CCreatorBrowser::NewL(this));
   729 //    TRAP(err, iBrowser = CCreatorBrowser::NewL(this));
   712     TRAP(err, iCalendar = CCreatorInterimCalendar::NewL(this));
   730     TRAP(err, iCalendar = CCreatorInterimCalendar::NewL(this));
   713     TRAP(err, iPhonebook = (CCreatorPhonebookBase*)TCreatorFactory::CreatePhoneBookL(this)); 
   731     TRAP(err, iPhonebook = (CCreatorPhonebookBase*)TCreatorFactory::CreatePhoneBookL(this)); 
   714     TRAP(err, iNotepad = CCreatorNotepad::NewL(this));
   732     TRAP(err, iNotepad = CCreatorNotepad::NewL(this));
   715     TRAP(err, iLogs = CCreatorLogs::NewL(this));
   733     TRAP(err, iLogs = CCreatorLogs::NewL(this));
   716     TRAP(err, iAccessPoints = (CCreatorConnectionSettingsBase*)TCreatorFactory::CreateConnectionSettingsL(this));
   734 //    TRAP(err, iAccessPoints = (CCreatorConnectionSettingsBase*)TCreatorFactory::CreateConnectionSettingsL(this));
   717     TRAP(err, iMailboxes = CCreatorMailboxes::NewL(this));
   735     TRAP(err, iMailboxes = CCreatorMailboxes::NewL(this));
   718     TRAP(err, iFiles = CCreatorFiles::NewL(this));
   736     TRAP(err, iFiles = CCreatorFiles::NewL(this));
   719     TRAP(err, iMessages = CCreatorMessages::NewL(this));
   737     TRAP(err, iMessages = CCreatorMessages::NewL(this));
   720     TRAP(err, iLandmarks = CCreatorLandmarks::NewL(this));
   738     TRAP(err, iLandmarks = CCreatorLandmarks::NewL(this));
       
   739     ContactLinkCache::InitializeL();
   721 /*
   740 /*
   722     #ifdef __PRESENCE
   741     #ifdef __PRESENCE
   723       TRAP(err, iIMPS = CCreatorIMPS::NewL(this));
   742       TRAP(err, iIMPS = CCreatorIMPS::NewL(this));
   724     #endif 
   743     #endif 
   725 */
   744 */
   749     iMessages = NULL;
   768     iMessages = NULL;
   750     delete iFiles;
   769     delete iFiles;
   751     iFiles = NULL;
   770     iFiles = NULL;
   752     delete iMailboxes;
   771     delete iMailboxes;
   753     iMailboxes = NULL;
   772     iMailboxes = NULL;
   754     delete iAccessPoints;
   773  //   delete iAccessPoints;
   755     iAccessPoints = NULL;
   774 //    iAccessPoints = NULL;
   756     delete iLogs;
   775     delete iLogs;
   757     iLogs = NULL;
   776     iLogs = NULL;
   758     delete iNotepad;
   777     delete iNotepad;
   759     iNotepad = NULL;
   778     iNotepad = NULL;
   760     delete iPhonebook;
   779     delete iPhonebook;
   761     iPhonebook = NULL;
   780     iPhonebook = NULL;
   762     delete iCalendar;
   781     delete iCalendar;
   763     iCalendar = NULL;
   782     iCalendar = NULL;
   764     delete iBrowser;
   783  //   delete iBrowser;
   765     iBrowser = NULL;
   784  //   iBrowser = NULL;
   766     delete iLandmarks;
   785     delete iLandmarks;
   767     iLandmarks = NULL;
   786     iLandmarks = NULL;
   768 
   787 
       
   788     ContactLinkCache::DestroyL();
   769     // now delete the command array
   789     // now delete the command array
   770     delete iCommandArray;
   790     delete iCommandArray;
   771     iCommandArray = NULL;
   791     iCommandArray = NULL;
   772 	
   792 	
   773 	// delete parameter array
   793 	// delete parameter array
   774 	iParameterArray.ResetAndDestroy();
   794 	iParameterArray.ResetAndDestroy();
   775 	iParameterArray.Close();
   795 	iParameterArray.Close();
       
   796 	
       
   797 	if(iCommandParser)
       
   798 	    {
       
   799         delete iCommandParser;
       
   800 	    iCommandParser = NULL;
       
   801 	    }
       
   802     
   776     
   803     
   777 	// clear temp drive
   804 	// clear temp drive
   778 	CFileMan* fileMan = CFileMan::NewL( iEnv->FsSession() );
   805 	CFileMan* fileMan = CFileMan::NewL( iEnv->FsSession() );
   779 	CleanupStack::PushL( fileMan );
   806 	CleanupStack::PushL( fileMan );
   780 	fileMan->RmDir( iTempPath->Des() );
   807 	fileMan->RmDir( iTempPath->Des() );
   788     LOGSTRING("Creator: CCreatorEngine::DoCancel");
   815     LOGSTRING("Creator: CCreatorEngine::DoCancel");
   789 
   816 
   790     iTimer.Cancel();
   817     iTimer.Cancel();
   791     }
   818     }
   792 
   819 
   793 // ---------------------------------------------------------------------------
   820 void CCreatorEngine::ScriptChosenL( TBool aSuccess, const TDesC& aFileName )
   794 
   821     {
   795 void CCreatorEngine::RunScriptL()
   822     if( aSuccess )
   796     {
   823         {
   797     LOGSTRING("Creator: CCreatorEngine::RunScriptL");
   824         // open the file for reading
   798 
   825         RFile scriptFile;
   799     // startup modules (also inits the command array):
   826         User::LeaveIfError( scriptFile.Open( iEnv->FsSession(), aFileName, EFileRead ) );
   800     StartEnginesL();
   827         CleanupClosePushL(scriptFile);
   801 
   828     
   802     // use the command parser module to init the command array from a script file
   829         
   803     CCommandParser* commandParser = CCommandParser::NewLC(this);
       
   804     RFile scriptFile;
       
   805     TBool ret = commandParser->OpenScriptL(scriptFile);
       
   806     CleanupClosePushL(scriptFile);
       
   807     if( ret )
       
   808         {
       
   809         // wait dialog
   830         // wait dialog
   810 		/* TODO
   831         /* TODO
   811         CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC();
   832         CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC();
   812         waitDialog->SetSoftkeys( R_AVKON_SOFTKEYS_CANCEL );
   833         waitDialog->SetSoftkeys( R_AVKON_SOFTKEYS_CANCEL );
   813         TInt dialogId = waitDialog->ShowNoteL( EAknGlobalWaitNote, _L("Parsing") );
   834         TInt dialogId = waitDialog->ShowNoteL( EAknGlobalWaitNote, _L("Parsing") );
   814         */
   835         */
   815         TInt parseErr( KErrNone );
   836         TInt parseErr( KErrNone );
   816         TRAPD( parserErr,
   837         CCreatorScriptParser* scriptParser = CCreatorScriptParser::NewLC(this);
   817                CCreatorScriptParser* scriptParser = CCreatorScriptParser::NewLC(this);
   838         scriptParser->ParseL(scriptFile);
   818                scriptParser->ParseL(scriptFile);
   839         parseErr = scriptParser->GetError();
   819                parseErr = scriptParser->GetError();
   840         CleanupStack::PopAndDestroy( scriptParser );
   820                CleanupStack::PopAndDestroy( scriptParser );
   841     
   821              );
   842         CleanupStack::PopAndDestroy( &scriptFile );
       
   843     
   822         //waitDialog->CancelNoteL( dialogId );
   844         //waitDialog->CancelNoteL( dialogId );
   823         //CleanupStack::PopAndDestroy( waitDialog );
   845         //CleanupStack::PopAndDestroy( waitDialog );
   824         User::LeaveIfError( parserErr );
   846     
   825         
       
   826         if(parseErr != KErrNone)
   847         if(parseErr != KErrNone)
   827             {
   848             {
   828 			
       
   829             // show error note
   849             // show error note
   830             _LIT(KErrMsg, "Parser error: %d");
   850             _LIT(KErrMsg, "Parser error: %d");
   831             TBuf<32> msgBuf;
   851             TBuf<32> msgBuf;
   832             msgBuf.Format(KErrMsg, parseErr);
   852             msgBuf.Format(KErrMsg, parseErr);
   833             iEngineWrapper->ShowNote(msgBuf);
   853             iEngineWrapper->ShowErrorMessage(msgBuf);
   834             CleanupStack::PopAndDestroy(); //commandParser   
       
   835             ShutDownEnginesL();
   854             ShutDownEnginesL();
   836             return;
   855             return;
   837             }         
   856             }         
   838         }
   857         }
   839     CleanupStack::PopAndDestroy( &scriptFile );
       
   840     CleanupStack::PopAndDestroy( commandParser );   
       
   841 
   858 
   842     // start executing commands if commands in the command array
   859     // start executing commands if commands in the command array
   843     if (CommandArrayCount() > 0)
   860     if (CommandArrayCount() > 0)
   844         {
   861         {
   845         ExecuteFirstCommandL( KSavingText );
   862         ExecuteFirstCommandL( KSavingText );
   846         }
   863         }
   847     else
   864     else
   848         {
   865         {
   849         ShutDownEnginesL();
   866         ShutDownEnginesL();
   850         }
   867         }
   851 
   868     }
       
   869 // ---------------------------------------------------------------------------
       
   870 
       
   871 void CCreatorEngine::RunScriptL()
       
   872     {
       
   873     LOGSTRING("Creator: CCreatorEngine::RunScriptL");
       
   874 
       
   875     // startup modules (also inits the command array):
       
   876     StartEnginesL();
       
   877 
       
   878     // use the command parser module to init the command array from a script file
       
   879     delete iCommandParser;
       
   880     iCommandParser = NULL;
       
   881     iCommandParser = CCommandParser::NewL(this);
       
   882     TBool ret = EFalse;
       
   883     TRAPD(err, ret = iCommandParser->OpenScriptL( this ) );
       
   884     if( err != KErrNone || ret == EFalse)
       
   885         {
       
   886         ShutDownEnginesL();
       
   887         User::LeaveIfError(err);
       
   888         }
   852     }
   889     }
   853 
   890 
   854 // ---------------------------------------------------------------------------
   891 // ---------------------------------------------------------------------------
   855 
   892 
   856 TInt CCreatorEngine::RunScriptL(const TDesC& aScriptFile)
   893 TInt CCreatorEngine::RunScriptL(const TDesC& aScriptFile)
   893         return KErrCompletion; // nothing to do
   930         return KErrCompletion; // nothing to do
   894         }
   931         }
   895     }
   932     }
   896 
   933 
   897 // ---------------------------------------------------------------------------
   934 // ---------------------------------------------------------------------------
       
   935 void CCreatorEngine::QueryDialogClosedL( TBool aPositiveAction, TInt aUserData )
       
   936     {
       
   937     LOGSTRING("Creator: CCreatorEngine::QueryDialogClosedL");
       
   938     
       
   939     if( aPositiveAction == EFalse )
       
   940         {
       
   941         ShutDownEnginesL();
       
   942         return;
       
   943         }
       
   944 
       
   945     switch(aUserData)
       
   946         {
       
   947         case ECreatorEngineDeleteAllEntries:
       
   948             AppendToCommandArrayL( ECmdDeleteContacts, NULL, 1 );
       
   949             AppendToCommandArrayL( ECmdDeleteContactGroups, NULL, 1 );
       
   950             AppendToCommandArrayL( ECmdDeleteCalendarEntries, NULL, 1 );
       
   951             //AppendToCommandArrayL( ECmdDeleteBrowserBookmarks, NULL, 1 );
       
   952             //AppendToCommandArrayL( ECmdDeleteBrowserBookmarkFolders, NULL, 1 );
       
   953             //AppendToCommandArrayL( ECmdDeleteBrowserSavedPages, NULL, 1 );
       
   954             //AppendToCommandArrayL( ECmdDeleteBrowserSavedPageFolders, NULL, 1 );
       
   955             AppendToCommandArrayL( ECmdDeleteLogs, NULL, 1 );
       
   956             AppendToCommandArrayL( ECmdDeleteMessages, NULL, 1 );
       
   957             //AppendToCommandArrayL( ECmdDeleteIAPs, NULL, 1 );
       
   958             //AppendToCommandArrayL( ECmdDeleteIMPSs, NULL, 1 );
       
   959             AppendToCommandArrayL( ECmdDeleteNotes, NULL, 1 );
       
   960             AppendToCommandArrayL( ECmdDeleteLandmarks, NULL, 1 );
       
   961             AppendToCommandArrayL( ECmdDeleteCreatorFiles, NULL, 1 );
       
   962             
       
   963             // started exucuting delete commands
       
   964             ExecuteFirstCommandL( KDeletingText );
       
   965             break;
       
   966         case ECreatorEngineDeleteAllCreatorEntries:
       
   967             AppendToCommandArrayL( ECmdDeleteCreatorContacts, NULL, 1 );
       
   968             AppendToCommandArrayL( ECmdDeleteCreatorContactGroups, NULL, 1 );
       
   969             AppendToCommandArrayL( ECmdDeleteCreatorCalendarEntries, NULL, 1 );
       
   970             /*
       
   971             AppendToCommandArrayL( ECmdDeleteCreatorBrowserBookmarks, NULL, 1 );
       
   972             AppendToCommandArrayL( ECmdDeleteCreatorBrowserBookmarkFolders, NULL, 1 );
       
   973             AppendToCommandArrayL( ECmdDeleteCreatorBrowserSavedPages, NULL, 1 );
       
   974             AppendToCommandArrayL( ECmdDeleteCreatorBrowserSavedPageFolders, NULL, 1 );
       
   975             */
       
   976             AppendToCommandArrayL( ECmdDeleteCreatorFiles, NULL, 1 );
       
   977             AppendToCommandArrayL( ECmdDeleteCreatorLogs, NULL, 1 );
       
   978             AppendToCommandArrayL( ECmdDeleteCreatorMessages, NULL, 1 );
       
   979             //AppendToCommandArrayL( ECmdDeleteCreatorIAPs, NULL, 1 );
       
   980             //AppendToCommandArrayL( ECmdDeleteCreatorIMPSs, NULL, 1 );
       
   981             AppendToCommandArrayL( ECmdDeleteCreatorLandmarks, NULL, 1 );
       
   982             
       
   983             // started exucuting delete commands
       
   984             ExecuteFirstCommandL( KDeletingText );
       
   985             break;
       
   986         default:
       
   987             //some error
       
   988              ShutDownEnginesL();
       
   989             break;
       
   990         }
       
   991     }
       
   992 
       
   993 // ---------------------------------------------------------------------------
   898 
   994 
   899 void CCreatorEngine::ExecuteOptionsMenuCommandL(TInt aCommand)
   995 void CCreatorEngine::ExecuteOptionsMenuCommandL(TInt aCommand)
   900     {
   996     {
   901     LOGSTRING("Creator: CCreatorEngine::ExecuteOptionsMenuCommandL");
   997     LOGSTRING("Creator: CCreatorEngine::ExecuteOptionsMenuCommandL");
   902 
   998 
   904     StartEnginesL();
  1000     StartEnginesL();
   905 
  1001 
   906     // set the home module
  1002     // set the home module
   907     switch(aCommand)
  1003     switch(aCommand)
   908         {
  1004         {
   909 	    case ECmdCreateBrowserBookmarkEntries:
  1005 /*
       
  1006         case ECmdCreateBrowserBookmarkEntries:
   910 	    case ECmdCreateBrowserBookmarkFolderEntries:
  1007 	    case ECmdCreateBrowserBookmarkFolderEntries:
   911 	    case ECmdCreateBrowserSavedPageEntries:
  1008 	    case ECmdCreateBrowserSavedPageEntries:
   912 	    case ECmdCreateBrowserSavedPageFolderEntries:
  1009 	    case ECmdCreateBrowserSavedPageFolderEntries:
   913 	    case ECmdDeleteBrowserBookmarks:
  1010 	    case ECmdDeleteBrowserBookmarks:
   914 	    case ECmdDeleteBrowserBookmarkFolders:
  1011 	    case ECmdDeleteBrowserBookmarkFolders:
   920         case ECmdDeleteCreatorBrowserSavedPageFolders:
  1017         case ECmdDeleteCreatorBrowserSavedPageFolders:
   921             {
  1018             {
   922             iUsedOptionsMenuModule = iBrowser;
  1019             iUsedOptionsMenuModule = iBrowser;
   923             }
  1020             }
   924             break;
  1021             break;
   925 	    
  1022 */	    
   926         case ECmdCreateCalendarEntryAppointments:
  1023         case ECmdCreateCalendarEntryAppointments:
   927 	    case ECmdCreateCalendarEntryEvents:
  1024 	    case ECmdCreateCalendarEntryEvents:
   928 	    case ECmdCreateCalendarEntryAnniversaries:
  1025 	    case ECmdCreateCalendarEntryAnniversaries:
   929 	    case ECmdCreateCalendarEntryToDos:
  1026 	    case ECmdCreateCalendarEntryToDos:
   930 	    case ECmdCreateCalendarEntryReminders:
  1027 	    case ECmdCreateCalendarEntryReminders:
   961 	    case ECmdDeleteCreatorLogs:
  1058 	    case ECmdDeleteCreatorLogs:
   962             {
  1059             {
   963             iUsedOptionsMenuModule = iLogs;
  1060             iUsedOptionsMenuModule = iLogs;
   964             }
  1061             }
   965             break;
  1062             break;
   966 
  1063 /*
   967 	    case ECmdCreateMiscEntryAccessPoints:
  1064 	    case ECmdCreateMiscEntryAccessPoints:
   968 	    case ECmdDeleteIAPs:
  1065 	    case ECmdDeleteIAPs:
   969 	    case ECmdDeleteCreatorIAPs:
  1066 	    case ECmdDeleteCreatorIAPs:
   970             {
  1067             {
   971             iUsedOptionsMenuModule = iAccessPoints;
  1068             iUsedOptionsMenuModule = iAccessPoints;
   972             }
  1069             }
   973             break;
  1070             break;
   974 
  1071 */
   975 	    case ECmdCreateMessagingEntryMailboxes:
  1072 	    case ECmdCreateMessagingEntryMailboxes:
   976 	    case ECmdDeleteMailboxes:
  1073 	    case ECmdDeleteMailboxes:
   977 	    case ECmdDeleteCreatorMailboxes:
  1074 	    case ECmdDeleteCreatorMailboxes:
   978             {
  1075             {
   979             iUsedOptionsMenuModule = iMailboxes;
  1076             iUsedOptionsMenuModule = iMailboxes;
  1063     //If it's a delete command, asking do you really want to delete
  1160     //If it's a delete command, asking do you really want to delete
  1064     if( IsDeleteCommand( aCommand ) )
  1161     if( IsDeleteCommand( aCommand ) )
  1065         {
  1162         {
  1066         if ( aCommand == ECmdDeleteAllEntries )
  1163         if ( aCommand == ECmdDeleteAllEntries )
  1067             {
  1164             {
  1068             if ( iEngineWrapper->YesNoQueryDialog( _L("Delete all entries?") ) )
  1165             if ( !iEngineWrapper->YesNoQueryDialog( _L("Delete all entries?"), this, ECreatorEngineDeleteAllEntries) )
  1069                 {
       
  1070                 AppendToCommandArrayL( ECmdDeleteContacts, NULL, 1 );
       
  1071                 AppendToCommandArrayL( ECmdDeleteContactGroups, NULL, 1 );
       
  1072                 AppendToCommandArrayL( ECmdDeleteCalendarEntries, NULL, 1 );
       
  1073                 AppendToCommandArrayL( ECmdDeleteBrowserBookmarks, NULL, 1 );
       
  1074                 AppendToCommandArrayL( ECmdDeleteBrowserBookmarkFolders, NULL, 1 );
       
  1075                 AppendToCommandArrayL( ECmdDeleteBrowserSavedPages, NULL, 1 );
       
  1076                 AppendToCommandArrayL( ECmdDeleteBrowserSavedPageFolders, NULL, 1 );
       
  1077                 AppendToCommandArrayL( ECmdDeleteLogs, NULL, 1 );
       
  1078                 AppendToCommandArrayL( ECmdDeleteMessages, NULL, 1 );
       
  1079                 AppendToCommandArrayL( ECmdDeleteIAPs, NULL, 1 );
       
  1080                 AppendToCommandArrayL( ECmdDeleteIMPSs, NULL, 1 );
       
  1081                 AppendToCommandArrayL( ECmdDeleteNotes, NULL, 1 );
       
  1082                 AppendToCommandArrayL( ECmdDeleteLandmarks, NULL, 1 );
       
  1083                 AppendToCommandArrayL( ECmdDeleteCreatorFiles, NULL, 1 );
       
  1084                 
       
  1085                 // started exucuting delete commands
       
  1086                 ExecuteFirstCommandL( KDeletingText );
       
  1087                 }
       
  1088             else
       
  1089                 {
  1166                 {
  1090                 // cancelled, free resources
  1167                 // cancelled, free resources
  1091                 ShutDownEnginesL();
  1168                 ShutDownEnginesL();
  1092                 }
  1169                 }
  1093             }
  1170             }
  1094         else if ( aCommand == ECmdDeleteAllCreatorEntries )
  1171         else if ( aCommand == ECmdDeleteAllCreatorEntries )
  1095             {
  1172             {
  1096             if ( iEngineWrapper->YesNoQueryDialog( _L("Delete all entries created with Creator?") ) )
  1173             if ( !iEngineWrapper->YesNoQueryDialog( _L("Delete all entries created with Creator?"), this, ECreatorEngineDeleteAllCreatorEntries ) )
  1097                 {
       
  1098                 AppendToCommandArrayL( ECmdDeleteCreatorContacts, NULL, 1 );
       
  1099                 AppendToCommandArrayL( ECmdDeleteCreatorContactGroups, NULL, 1 );
       
  1100                 AppendToCommandArrayL( ECmdDeleteCreatorCalendarEntries, NULL, 1 );
       
  1101                 AppendToCommandArrayL( ECmdDeleteCreatorBrowserBookmarks, NULL, 1 );
       
  1102                 AppendToCommandArrayL( ECmdDeleteCreatorBrowserBookmarkFolders, NULL, 1 );
       
  1103                 AppendToCommandArrayL( ECmdDeleteCreatorBrowserSavedPages, NULL, 1 );
       
  1104                 AppendToCommandArrayL( ECmdDeleteCreatorBrowserSavedPageFolders, NULL, 1 );
       
  1105                 AppendToCommandArrayL( ECmdDeleteCreatorFiles, NULL, 1 );
       
  1106                 AppendToCommandArrayL( ECmdDeleteCreatorLogs, NULL, 1 );
       
  1107                 AppendToCommandArrayL( ECmdDeleteCreatorMessages, NULL, 1 );
       
  1108                 AppendToCommandArrayL( ECmdDeleteCreatorIAPs, NULL, 1 );
       
  1109                 AppendToCommandArrayL( ECmdDeleteCreatorIMPSs, NULL, 1 );
       
  1110                 AppendToCommandArrayL( ECmdDeleteCreatorLandmarks, NULL, 1 );
       
  1111                 
       
  1112                 // started exucuting delete commands
       
  1113                 ExecuteFirstCommandL( KDeletingText );
       
  1114                 }
       
  1115             else
       
  1116                 {
  1174                 {
  1117                 // cancelled, free resources
  1175                 // cancelled, free resources
  1118                 ShutDownEnginesL();
  1176                 ShutDownEnginesL();
  1119                 }
  1177                 }
  1120             }
  1178             }
  1121         else if ( iUsedOptionsMenuModule->AskDataFromUserL( aCommand, iEntriesToBeCreated )  )
  1179         else if ( !iUsedOptionsMenuModule->AskDataFromUserL( aCommand )  )
  1122             {
  1180             {
  1123             // add this command to command array
  1181             // cancelled or error, free resources
  1124             AppendToCommandArrayL( aCommand, NULL, 1 );
       
  1125     
       
  1126             // started exucuting commands
       
  1127             ExecuteFirstCommandL( KDeletingText );        
       
  1128             }
       
  1129         else
       
  1130             {
       
  1131             // cancelled, free resources
       
  1132             ShutDownEnginesL();
  1182             ShutDownEnginesL();
  1133             }
  1183             }
  1134         }
  1184         }
  1135 
  1185 
  1136     // ask user data, if query accepted start processing...
  1186     // ask user data, if query accepted start processing...
  1137     else if (iUsedOptionsMenuModule->AskDataFromUserL(aCommand, iEntriesToBeCreated))
  1187     else if (!iUsedOptionsMenuModule->AskDataFromUserL(aCommand))
  1138         {
  1188         {
  1139         // add this command to command array
  1189         // cancelled or error, free resources
  1140         AppendToCommandArrayL(aCommand, NULL, iEntriesToBeCreated);
       
  1141 
       
  1142         // started exucuting commands
       
  1143         ExecuteFirstCommandL( KSavingText );
       
  1144         }
       
  1145      else
       
  1146         {
       
  1147         // cancelled, free resources
       
  1148         ShutDownEnginesL();
  1190         ShutDownEnginesL();
  1149         }
  1191         }
  1150     }
  1192     }
  1151 
  1193 
  1152 
  1194 
  1197             return EFalse;
  1239             return EFalse;
  1198             }
  1240             }
  1199         }
  1241         }
  1200      
  1242      
  1201     }
  1243     }
  1202 
  1244 // ---------------------------------------------------------------------------
  1203 // ---------------------------------------------------------------------------
  1245 void CCreatorEngine::RandomDataFileChosenL( TBool aSuccess, const TDesC& aFileName )
  1204 
  1246     {
  1205 TBool CCreatorEngine::GetRandomDataFilenameL(TDes& aFilename)
  1247     if( aSuccess )
       
  1248         {
       
  1249         GetRandomDataFromFileL( aFileName );
       
  1250         }
       
  1251     }
       
  1252 
       
  1253 // ---------------------------------------------------------------------------
       
  1254 
       
  1255 TBool CCreatorEngine::GetRandomDataL()
  1206 	{
  1256 	{
  1207     CCommandParser* commandParser = CCommandParser::NewLC(this);
  1257     delete iCommandParser;
  1208 	TBool ret = commandParser->GetRandomDataFilenameL(aFilename);
  1258     iCommandParser = NULL;
  1209     CleanupStack::PopAndDestroy(commandParser);
  1259     iCommandParser = CCommandParser::NewL( this );
  1210     return ret;
  1260 	return iCommandParser->GetRandomDataFilenameL( this );
  1211 	}
  1261 	}
  1212 
  1262 
  1213 // ---------------------------------------------------------------------------
  1263 // ---------------------------------------------------------------------------
  1214 
  1264 
  1215 TBool CCreatorEngine::GetRandomDataFromFileL(const TDesC& aFilename)
  1265 TBool CCreatorEngine::GetRandomDataFromFileL(const TDesC& aFilename)
  1789 
  1839 
  1790 TUint32 CCreatorEngine::AccessPointNameToIdL(const TDesC& aAPName, TBool aAnyIfNotFound )
  1840 TUint32 CCreatorEngine::AccessPointNameToIdL(const TDesC& aAPName, TBool aAnyIfNotFound )
  1791     {
  1841     {
  1792     LOGSTRING("Creator: CCreatorEngine::AccessPointNameToIdL");
  1842     LOGSTRING("Creator: CCreatorEngine::AccessPointNameToIdL");
  1793     // Accespoint impl moved from engine to accespoint implementations for supporting 3.0-3.1 and 3.2->
  1843     // Accespoint impl moved from engine to accespoint implementations for supporting 3.0-3.1 and 3.2->
  1794     return iAccessPoints->AccessPointNameToIdL(aAPName, aAnyIfNotFound );
  1844     //return iAccessPoints->AccessPointNameToIdL(aAPName, aAnyIfNotFound );
       
  1845     return 0;
  1795     }
  1846     }
  1796 
  1847 
  1797 static CCreatorEngine::TTestDataPath SoundFiles[] = {
  1848 static CCreatorEngine::TTestDataPath SoundFiles[] = {
  1798         CCreatorEngine::EMIDI_10kB,
  1849         CCreatorEngine::EMIDI_10kB,
  1799         CCreatorEngine::EWAVE_20kB,  
  1850         CCreatorEngine::EWAVE_20kB,