creator/engine/inc/creator_modulebase.h
branchGCC_SURGE
changeset 37 c20154ccf3c0
parent 23 c9bf25a20c9f
equal deleted inserted replaced
20:ba8a586c45f1 37:c20154ccf3c0
    14 * Description: 
    14 * Description: 
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 
       
    20 
       
    21 #ifndef __CREATOR_MODULEBASE_H__
    19 #ifndef __CREATOR_MODULEBASE_H__
    22 #define __CREATOR_MODULEBASE_H__
    20 #define __CREATOR_MODULEBASE_H__
    23 
    21 
    24 #include <e32base.h>
    22 #include <e32base.h>
       
    23 
       
    24 #include "engine.h"
       
    25 #include "creator_traces.h"
    25 
    26 
    26 // Dictionary uids for each Creator module.
    27 // Dictionary uids for each Creator module.
    27 // Dictionaries are for storing item identifiers created by Creator.
    28 // Dictionaries are for storing item identifiers created by Creator.
    28 // Item identifiers are for enabling deletion of only items created by Creator. 
    29 // Item identifiers are for enabling deletion of only items created by Creator. 
    29 const TUid KUidDictionaryUidContacts         = { 0x00 };
    30 const TUid KUidDictionaryUidContacts         = { 0x00 };
    44 
    45 
    45 class CCreatorEngine;
    46 class CCreatorEngine;
    46 class MCreatorModuleBaseParameters;
    47 class MCreatorModuleBaseParameters;
    47 class CCommandParser;
    48 class CCommandParser;
    48 
    49 
       
    50 _LIT(KSavingText, "Saving");
       
    51 _LIT(KDeletingText, "Deleting");
       
    52 
    49 class MCreatorModuleBase
    53 class MCreatorModuleBase
    50     {
    54     {
    51 public:
    55 public:
    52 
    56 
    53 private:
    57 private:
    54     // constructs the module, add "iEngine = aEngine" and other construction stuff to the body
    58     // constructs the module, add "iEngine = aEngine" and other construction stuff to the body
    55     virtual void ConstructL(CCreatorEngine* aEngine) = 0;
    59     virtual void ConstructL( CCreatorEngine* aEngine ) = 0;
    56 
    60 
    57 public:
    61 public:
    58     // this one is called when user select some features directly from menu, not running a script
    62     // this one is called when user select some features directly from menu, not running a script
    59     // should call CreateRandomData() function
    63     // should call CreateRandomData() function
    60     // returns ETrue when success, EFalse when user has cancelled
    64     // returns ETrue when success, EFalse when user has cancelled
    61     virtual TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries) = 0;
    65     virtual TBool AskDataFromUserL( TInt aCommand ) = 0;
    62     virtual void DeleteAllL() = 0;
    66     virtual void DeleteAllL() = 0;
    63     virtual void DeleteAllCreatedByCreatorL() = 0;
    67     virtual void DeleteAllCreatedByCreatorL() = 0;
       
    68     };
       
    69 
       
    70 
       
    71 class CCreatorModuleBase : public CBase, public MCreatorModuleBase, public MUIObserver
       
    72     {
    64 
    73 
    65 public:
    74 public:
       
    75     enum TCreatorModuleStatus
       
    76         {
       
    77         ECreatorModuleDelete = 0, 
       
    78         ECreatorModuleStart
       
    79         };
       
    80     
       
    81     CCreatorModuleBase()
       
    82         {
       
    83         iEntriesToBeCreated = 1; 
       
    84         }
       
    85     
       
    86     virtual TBool AskDataFromUserL(TInt aCommand)
       
    87         {
       
    88         iCommand = aCommand;
       
    89         return EFalse;// will finish user interaction and engine will shutdown modules
       
    90         }
       
    91     
       
    92     virtual void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData)
       
    93         {
       
    94         LOGSTRING("Creator: CCreatorModuleBase::QueryDialogClosedL");
       
    95         
       
    96         if( aPositiveAction == EFalse )
       
    97             {
       
    98             iEngine->ShutDownEnginesL();
       
    99             return;
       
   100             }
       
   101         const TDesC* showText = &KSavingText;
       
   102         TBool finished(EFalse);
       
   103         TBool retval(ETrue);
       
   104         switch(aUserData)
       
   105             {
       
   106             case ECreatorModuleDelete:
       
   107                 showText = &KDeletingText;
       
   108                 iEntriesToBeCreated = 1;
       
   109                 finished = ETrue;
       
   110                 break;
       
   111             case ECreatorModuleStart:
       
   112                 finished = ETrue;
       
   113                 break;
       
   114             default:
       
   115                 //some error
       
   116                 retval = EFalse;
       
   117                 break;
       
   118             }
       
   119         if( retval == EFalse )
       
   120             {
       
   121             iEngine->ShutDownEnginesL();
       
   122             }
       
   123         else if( finished )
       
   124             {
       
   125             // add this command to command array
       
   126             iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated);
       
   127             // started exucuting commands
       
   128             iEngine->ExecuteFirstCommandL( *showText );
       
   129             }
       
   130         }
       
   131 
       
   132 protected:
       
   133     // constructs the module, add "iEngine = aEngine" and other construction stuff to the body
       
   134     virtual void ConstructL(CCreatorEngine* aEngine)
       
   135         {
       
   136         iEngine = aEngine;
       
   137         };
       
   138     
       
   139 protected:
    66     CCreatorEngine* iEngine;
   140     CCreatorEngine* iEngine;
    67 
   141     TInt iCommand;
    68 private:
   142     TInt iEntriesToBeCreated;
    69 
   143     TInt iDummy;
    70     };
   144     };
    71 
       
    72 
   145 
    73 class MCreatorModuleBaseParameters
   146 class MCreatorModuleBaseParameters
    74     {
   147     {
    75     // a base class for the parameters, no default implementation
   148     // a base class for the parameters, no default implementation
    76     
   149