creator/engine/inc/creator_modulebase.h
changeset 55 2d9cac8919d3
parent 53 819e59dfc032
child 56 392f7045e621
equal deleted inserted replaced
53:819e59dfc032 55:2d9cac8919d3
     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 
       
    19 #ifndef __CREATOR_MODULEBASE_H__
       
    20 #define __CREATOR_MODULEBASE_H__
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 #include "engine.h"
       
    25 #include "creator_traces.h"
       
    26 
       
    27 // Dictionary uids for each Creator module.
       
    28 // Dictionaries are for storing item identifiers created by Creator.
       
    29 // Item identifiers are for enabling deletion of only items created by Creator. 
       
    30 const TUid KUidDictionaryUidContacts         = { 0x00 };
       
    31 const TUid KUidDictionaryUidContactGroups    = { 0x01 };
       
    32 const TUid KUidDictionaryUidCalendar         = { 0x02 };
       
    33 const TUid KUidDictionaryUidBrowserBookmarks = { 0x03 };
       
    34 const TUid KUidDictionaryUidFiles            = { 0x04 };
       
    35 const TUid KUidDictionaryUidLogs             = { 0x05 };
       
    36 const TUid KUidDictionaryUidMessages         = { 0x06 };
       
    37 const TUid KUidDictionaryUidMailbox          = { 0x07 };
       
    38 const TUid KUidDictionaryUidIAP              = { 0x08 };
       
    39 const TUid KUidDictionaryUidIMPS             = { 0x09 };
       
    40 const TUid KUidDictionaryUidNotes            = { 0x0A };
       
    41 const TUid KUidDictionaryUidLandmarks        = { 0x0B };
       
    42 const TUid KUidDictionaryUidBrowserSavedPg   = { 0x0C };
       
    43 const TUid KUidDictionaryUidBrowserBookmarkF = { 0x0D };
       
    44 const TUid KUidDictionaryUidBrowserSavedPgF  = { 0x0E };
       
    45 
       
    46 class CCreatorEngine;
       
    47 class MCreatorModuleBaseParameters;
       
    48 class CCommandParser;
       
    49 
       
    50 _LIT(KSavingText, "Saving");
       
    51 _LIT(KDeletingText, "Deleting");
       
    52 
       
    53 class MCreatorModuleBase
       
    54     {
       
    55 public:
       
    56 
       
    57 private:
       
    58     // constructs the module, add "iEngine = aEngine" and other construction stuff to the body
       
    59     virtual void ConstructL( CCreatorEngine* aEngine ) = 0;
       
    60 
       
    61 public:
       
    62     // this one is called when user select some features directly from menu, not running a script
       
    63     // should call CreateRandomData() function
       
    64     // returns ETrue when success, EFalse when user has cancelled
       
    65     virtual TBool AskDataFromUserL( TInt aCommand ) = 0;
       
    66     virtual void DeleteAllL() = 0;
       
    67     virtual void DeleteAllCreatedByCreatorL() = 0;
       
    68     };
       
    69 
       
    70 
       
    71 class CCreatorModuleBase : public CBase, public MCreatorModuleBase, public MUIObserver
       
    72     {
       
    73 
       
    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:
       
   140     CCreatorEngine* iEngine;
       
   141     TInt iCommand;
       
   142     TInt iEntriesToBeCreated;
       
   143     TInt iDummy;
       
   144     };
       
   145 
       
   146 class MCreatorModuleBaseParameters
       
   147     {
       
   148     // a base class for the parameters, no default implementation
       
   149     
       
   150     public:
       
   151     	enum TParseParams
       
   152     	{
       
   153     	EParamNone = 0,
       
   154     	ECalendarMeeting,
       
   155     	ECalendarMemo,
       
   156     	ECalendarAnniv,
       
   157     	ECalendarTodo
       
   158     	};
       
   159     
       
   160 public:
       
   161 	virtual void ParseL(CCommandParser* /*aParser*/, TParseParams /*aCase = 0*/) = 0;
       
   162 
       
   163 	
       
   164     };
       
   165     
       
   166 // Following struct represents the parameters that links for example contact groups
       
   167 // to contac-sets.
       
   168 typedef struct 
       
   169     {
       
   170     TInt iLinkId; // ID
       
   171     TInt iLinkAmount; // Amount of elements in linked set 
       
   172     } TLinkIdParam;
       
   173 
       
   174         
       
   175 class CCreatorModuleBaseParameters : public CBase, public MCreatorModuleBaseParameters
       
   176         {
       
   177         public:
       
   178         virtual void ParseL(CCommandParser* /*aParser*/, TParseParams /*aCase = 0*/){};
       
   179         virtual TInt ScriptLinkId() const {return -1;};
       
   180         virtual void SetScriptLinkId(TInt) {};
       
   181         // a base class for the parameters, no default implementation
       
   182         };
       
   183         
       
   184 
       
   185 
       
   186 
       
   187 #endif  // __CREATOR_MODULEBASE_H__
       
   188