diff -r 4f2773374eff -r 4b22a598b890 creator/engine/inc/creator_modulebase.h --- a/creator/engine/inc/creator_modulebase.h Fri May 14 15:53:02 2010 +0300 +++ b/creator/engine/inc/creator_modulebase.h Thu May 27 12:52:19 2010 +0300 @@ -16,13 +16,14 @@ */ - - #ifndef __CREATOR_MODULEBASE_H__ #define __CREATOR_MODULEBASE_H__ #include +#include "engine.h" +#include "creator_traces.h" + // Dictionary uids for each Creator module. // Dictionaries are for storing item identifiers created by Creator. // Item identifiers are for enabling deletion of only items created by Creator. @@ -46,30 +47,97 @@ class MCreatorModuleBaseParameters; class CCommandParser; +_LIT(KSavingText, "Saving"); + class MCreatorModuleBase { public: private: // constructs the module, add "iEngine = aEngine" and other construction stuff to the body - virtual void ConstructL(CCreatorEngine* aEngine) = 0; + virtual void ConstructL( CCreatorEngine* aEngine ) = 0; public: // this one is called when user select some features directly from menu, not running a script // should call CreateRandomData() function // returns ETrue when success, EFalse when user has cancelled - virtual TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries) = 0; + virtual TBool AskDataFromUserL( TInt aCommand ) = 0; virtual void DeleteAllL() = 0; virtual void DeleteAllCreatedByCreatorL() = 0; + }; + + +class CCreatorModuleBase : public CBase, public MCreatorModuleBase, public MUIObserver + { public: - CCreatorEngine* iEngine; + enum TCreatorModuleStatus + { + ECreatorModuleDelete = 0, + ECreatorModuleStart + }; + + CCreatorModuleBase(){ } + + virtual TBool AskDataFromUserL(TInt aCommand) + { + iCommand = aCommand; + return EFalse;// will finish user interaction and engine will shutdown modules + } + + virtual void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) + { + LOGSTRING("Creator: CCreatorModuleBase::QueryDialogClosedL"); + + if( aPositiveAction == EFalse ) + { + iEngine->ShutDownEnginesL(); + return; + } + + TBool finished(EFalse); + TBool retval(ETrue); + switch(aUserData) + { + case ECreatorModuleDelete: + iEntriesToBeCreated = 1; + finished = ETrue; + break; + case ECreatorModuleStart: + finished = ETrue; + break; + default: + //some error + retval = EFalse; + break; + } + if( retval == EFalse ) + { + iEngine->ShutDownEnginesL(); + } + else if( finished ) + { + // add this command to command array + iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated); + // started exucuting commands + iEngine->ExecuteFirstCommandL( KSavingText ); + } + } -private: - +protected: + // constructs the module, add "iEngine = aEngine" and other construction stuff to the body + virtual void ConstructL(CCreatorEngine* aEngine) + { + iEngine = aEngine; + }; + +protected: + CCreatorEngine* iEngine; + TInt iCommand; + TInt iEntriesToBeCreated; + TInt iDummy; }; - class MCreatorModuleBaseParameters { // a base class for the parameters, no default implementation @@ -112,4 +180,4 @@ #endif // __CREATOR_MODULEBASE_H__ - \ No newline at end of file +