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 |
49 class MCreatorModuleBase |
52 class MCreatorModuleBase |
50 { |
53 { |
51 public: |
54 public: |
52 |
55 |
53 private: |
56 private: |
54 // constructs the module, add "iEngine = aEngine" and other construction stuff to the body |
57 // constructs the module, add "iEngine = aEngine" and other construction stuff to the body |
55 virtual void ConstructL(CCreatorEngine* aEngine) = 0; |
58 virtual void ConstructL( CCreatorEngine* aEngine ) = 0; |
56 |
59 |
57 public: |
60 public: |
58 // this one is called when user select some features directly from menu, not running a script |
61 // this one is called when user select some features directly from menu, not running a script |
59 // should call CreateRandomData() function |
62 // should call CreateRandomData() function |
60 // returns ETrue when success, EFalse when user has cancelled |
63 // returns ETrue when success, EFalse when user has cancelled |
61 virtual TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries) = 0; |
64 virtual TBool AskDataFromUserL( TInt aCommand ) = 0; |
62 virtual void DeleteAllL() = 0; |
65 virtual void DeleteAllL() = 0; |
63 virtual void DeleteAllCreatedByCreatorL() = 0; |
66 virtual void DeleteAllCreatedByCreatorL() = 0; |
|
67 }; |
|
68 |
|
69 |
|
70 class CCreatorModuleBase : public CBase, public MCreatorModuleBase, public MUIObserver |
|
71 { |
64 |
72 |
65 public: |
73 public: |
|
74 enum TCreatorModuleStatus |
|
75 { |
|
76 ECreatorModuleDelete = 0, |
|
77 ECreatorModuleStart |
|
78 }; |
|
79 |
|
80 CCreatorModuleBase(){ } |
|
81 |
|
82 virtual TBool AskDataFromUserL(TInt aCommand) |
|
83 { |
|
84 iCommand = aCommand; |
|
85 return EFalse;// will finish user interaction and engine will shutdown modules |
|
86 } |
|
87 |
|
88 virtual void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) |
|
89 { |
|
90 LOGSTRING("Creator: CCreatorModuleBase::QueryDialogClosedL"); |
|
91 |
|
92 if( aPositiveAction == EFalse ) |
|
93 { |
|
94 iEngine->ShutDownEnginesL(); |
|
95 return; |
|
96 } |
|
97 |
|
98 TBool finished(EFalse); |
|
99 TBool retval(ETrue); |
|
100 switch(aUserData) |
|
101 { |
|
102 case ECreatorModuleDelete: |
|
103 iEntriesToBeCreated = 1; |
|
104 finished = ETrue; |
|
105 break; |
|
106 case ECreatorModuleStart: |
|
107 finished = ETrue; |
|
108 break; |
|
109 default: |
|
110 //some error |
|
111 retval = EFalse; |
|
112 break; |
|
113 } |
|
114 if( retval == EFalse ) |
|
115 { |
|
116 iEngine->ShutDownEnginesL(); |
|
117 } |
|
118 else if( finished ) |
|
119 { |
|
120 // add this command to command array |
|
121 iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated); |
|
122 // started exucuting commands |
|
123 iEngine->ExecuteFirstCommandL( KSavingText ); |
|
124 } |
|
125 } |
|
126 |
|
127 protected: |
|
128 // constructs the module, add "iEngine = aEngine" and other construction stuff to the body |
|
129 virtual void ConstructL(CCreatorEngine* aEngine) |
|
130 { |
|
131 iEngine = aEngine; |
|
132 }; |
|
133 |
|
134 protected: |
66 CCreatorEngine* iEngine; |
135 CCreatorEngine* iEngine; |
67 |
136 TInt iCommand; |
68 private: |
137 TInt iEntriesToBeCreated; |
69 |
138 TInt iDummy; |
70 }; |
139 }; |
71 |
|
72 |
140 |
73 class MCreatorModuleBaseParameters |
141 class MCreatorModuleBaseParameters |
74 { |
142 { |
75 // a base class for the parameters, no default implementation |
143 // a base class for the parameters, no default implementation |
76 |
144 |