1 /* |
|
2 * Copyright (c) 2008 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 |
|
20 |
|
21 |
|
22 #ifndef __CREATORENGINE_H__ |
|
23 #define __CREATORENGINE_H__ |
|
24 |
|
25 |
|
26 #include "creator_appui.h" |
|
27 #include "creator.hrh" |
|
28 |
|
29 #include "creator_std.h" |
|
30 #include "creator_scriptentry.h" |
|
31 #include "creator_modulebase.h" |
|
32 #include "creator_browser.h" |
|
33 #include "creator_calendar.h" |
|
34 #include "creator_phonebookbase.h" |
|
35 #include "creator_note.h" |
|
36 #include "creator_log.h" |
|
37 #include "creator_connectionmethodbase.h" |
|
38 #include "creator_mailbox.h" |
|
39 #include "creator_imps.h" |
|
40 #include "creator_message.h" |
|
41 #include "creator_landmark.h" |
|
42 #include "creator_randomdataparser.h" |
|
43 |
|
44 #include <e32base.h> |
|
45 #include <aknenv.h> |
|
46 #include <coeutils.h> |
|
47 #include <apparc.h> |
|
48 #include <eikenv.h> |
|
49 #include <AknProgressDialog.h> |
|
50 #include <eikprogi.h> |
|
51 #include <bautils.h> |
|
52 #include <commdb.h> |
|
53 #include <imageconversion.h> //TFrameInfo |
|
54 |
|
55 class CCreatorAppUi; |
|
56 class TCommand; |
|
57 class CCreatorBrowser; |
|
58 class CCreatorCalendarBase; |
|
59 class CCreatorNotepad; |
|
60 class CCreatorLogs; |
|
61 class CCreatorAccessPoints; |
|
62 class CCreatorMailboxes; |
|
63 class CCreatorIMPS; |
|
64 class CCreatorFiles; |
|
65 class CCreatorMessages; |
|
66 class CCreatorLandmarks; |
|
67 class CDictionaryFileStore; |
|
68 class CImageDecoder; |
|
69 class CFbsBitmap; |
|
70 class CBitmapScaler; |
|
71 |
|
72 // Common constant for undefined integer value: |
|
73 const TInt KUndef = KErrNotFound; |
|
74 |
|
75 class CCreatorEngine : public CActive, public MProgressDialogCallback |
|
76 { |
|
77 public: |
|
78 |
|
79 enum TRandomStringType |
|
80 { |
|
81 EFirstName = 0, |
|
82 ESurname, |
|
83 ECompany, |
|
84 EAddress, |
|
85 EJobTitle, |
|
86 EPhoneNumber, |
|
87 EGroupName, |
|
88 EMeetingReason, |
|
89 EMeetingPlace, |
|
90 EMemoText, |
|
91 EAnniversaryReason, |
|
92 EToDoText, |
|
93 EReminderText, |
|
94 EMessageSubject, |
|
95 EMessageText, |
|
96 ECity, |
|
97 ECountry, |
|
98 EPostcode, |
|
99 EState, |
|
100 EPobox, |
|
101 EPrefix, |
|
102 ESuffix, |
|
103 ELandmarkName, |
|
104 ELandmarkDescription |
|
105 }; |
|
106 |
|
107 |
|
108 // note! changing order will cause regression in other modules |
|
109 |
|
110 enum TTestDataPath |
|
111 { |
|
112 EJPEG_25kB = 0, |
|
113 EJPEG_200kB, |
|
114 EJPEG_500kB, |
|
115 EPNG_15kB, |
|
116 EGIF_2kB, |
|
117 ERNG_1kB, |
|
118 EMIDI_10kB, |
|
119 EWAVE_20kB, |
|
120 EAMR_20kB, |
|
121 EExcel_15kB, |
|
122 EWord_20kB, |
|
123 EPowerPoint_40kB, |
|
124 EText_10kB, |
|
125 EText_70kB, |
|
126 E3GPP_70kB, |
|
127 EMP3_250kB, |
|
128 EAAC_100kB, |
|
129 ERM_95kB, |
|
130 EBMP_25kB, |
|
131 EHTML_20kB, |
|
132 EJAD_1kB, |
|
133 EJAR_10kB, |
|
134 EJP2_65kB, |
|
135 EMP4_200kB, |
|
136 EMXMF_40kB, |
|
137 ERAM_1kB, |
|
138 ESVG_15kB, |
|
139 ESWF_15kB, |
|
140 ETIF_25kB, |
|
141 EVCF_1kB, |
|
142 EVCS_1kB, |
|
143 ESISX_10kB, |
|
144 EWMA_50kB, |
|
145 EWMV_200kB, |
|
146 ESavedDeck_1kB, |
|
147 LAST_FILE_ID//When you add new items to enum, add them before last item, so random number generations does not need to be updated also |
|
148 }; |
|
149 |
|
150 enum TRandomDateType |
|
151 { |
|
152 EDatePast, |
|
153 EDateFuture |
|
154 }; |
|
155 |
|
156 public: |
|
157 static CCreatorEngine* NewL(CCreatorAppUi* aAppUi); |
|
158 ~CCreatorEngine(); |
|
159 |
|
160 private: |
|
161 CCreatorEngine(); |
|
162 void ConstructL(CCreatorAppUi* aAppUi); |
|
163 void Init(); |
|
164 void RunL(); |
|
165 TInt RunError(TInt aError); |
|
166 void DoCancel(); |
|
167 |
|
168 void ExecuteFirstCommandL(const TDesC& aText); |
|
169 void ExecuteCommand(); |
|
170 void StartEnginesL(); |
|
171 void ShutDownEnginesL(); |
|
172 void CheckForMoreCommandsL(); |
|
173 void DialogDismissedL(TInt aButtonId); //from MProgressDialogCallback |
|
174 |
|
175 TBool IsDeleteCommand( TInt aCommand ); |
|
176 |
|
177 TInt ReadRandomDataL(const TRandomStringType aRandomStringType, |
|
178 const TInt aResourceId, |
|
179 const TDesC& aFilename, |
|
180 const CCreatorRandomDataParser::TRandomDataType aRandomDataType); |
|
181 void GenerateSourceImageFileL( const TTestDataPath aFileType, const TDesC& aFileName ); |
|
182 void GenereteSourceTextFileL( const TDesC& aFileName, TInt aSize ); |
|
183 |
|
184 public: |
|
185 void ExecuteOptionsMenuCommandL(TInt aCommand); |
|
186 void RunScriptL(); |
|
187 TInt RunScriptL(const TDesC& aScriptFile); |
|
188 |
|
189 void AppendToCommandArrayL(TInt aCommand, CCreatorModuleBaseParameters* aParameters, TInt aNumberOfEntries = 1); |
|
190 TInt CommandArrayCount(); |
|
191 |
|
192 TBool EntriesQueryDialogL(TInt& aNumberOfEntries, const TDesC& aPrompt, TBool aAcceptsZero=EFalse); |
|
193 TBool TimeQueryDialogL(TTime& aTime, TInt aResourceId); |
|
194 TBool YesNoQueryDialogL(const TDesC& aPrompt); |
|
195 |
|
196 TPtrC TestDataPathL(enum TTestDataPath aTestDataPath); |
|
197 TPtrC RandomSoundFileL(); // Returns temporary path, which will be removed on shutdown |
|
198 TPtrC RandomPictureFileL(); // Returns temporary path, which will be removed on shutdown |
|
199 TPtrC CreateRandomSoundFileL(); // Copies file to new location and returns the new path |
|
200 TPtrC CreateSoundFileL(TTestDataPath aId); // Copies file to new location and returns the new path |
|
201 |
|
202 void CopyFileL(const TFileName& aSourceFile, const TFileName& aTargetFile, TBool aOverwrite = EFalse ); |
|
203 /* |
|
204 * Gets attacment file id based on the file id string |
|
205 * @return Attachment file id |
|
206 * @param aAttachmentIdStr Attachment file id string |
|
207 */ |
|
208 TInt GetAttachmentIdL( const TDesC& aAttachmentIdStr ) const; |
|
209 |
|
210 TUint32 GetDefaultIAPL(); |
|
211 TUint32 AccessPointNameToIdL(const TDesC& aAPName, TBool aAnyIfNotFound = EFalse ); |
|
212 |
|
213 TPtrC RandomString(enum TRandomStringType aRandomStringType); |
|
214 TInt RandomNumber(TInt aRange); |
|
215 TInt RandomNumber(TInt aMin, TInt aMax); |
|
216 TTime RandomDate(TRandomDateType type, TInt aMinDays = 0, TInt aMaxDays = 360 ); |
|
217 TTime RandomDate(TTime baseTime, TRandomDateType type, TInt aMinDays = 0, TInt aMaxDays = 360); |
|
218 TTime RandomTime(TTime baseTime, TRandomDateType type, TInt aMinHours=0, TInt aMaxHours=24, TInt aMinMinutes=0, TInt aMaxMinutes=60 ); |
|
219 CDesCArrayFlat* SoundFilesL(); |
|
220 CDesCArrayFlat* PictureFilesL(); |
|
221 |
|
222 HBufC* CreateEmailAddressLC(); |
|
223 HBufC* CreateHTTPUrlLC(); |
|
224 HBufC* CreateRandomStringLC(TInt aStrLen); |
|
225 |
|
226 HBufC* CreateEmailAddressLC( |
|
227 const TDesC& firstname, |
|
228 const TDesC& lastname, |
|
229 const TDesC& domain, |
|
230 const TDesC& country ) const; |
|
231 |
|
232 HBufC* CreateUrlLC( |
|
233 const TDesC& protocol, |
|
234 const TDesC& prefix, |
|
235 const TDesC& domain, |
|
236 const TDesC& country) const; |
|
237 |
|
238 void SetDefaultPathForFileCommandL(TInt aCommand, TFileName& aPath); |
|
239 |
|
240 TBool GetRandomDataFilenameL(TDes& aFilename); |
|
241 TBool GetRandomDataFromFileL(const TDesC& aFilename); |
|
242 void CancelComplete(); |
|
243 CDictionaryFileStore* FileStoreLC(); |
|
244 void ReadEntryIdsFromStoreL( RArray<TInt>& aEntryIds, const TUid aModuleUid ); |
|
245 void WriteEntryIdsToStoreL( RArray<TInt>& aEntryIds, const TUid aModuleUid ); |
|
246 void ReadEntryIdsFromStoreL( RArray<TUint32>& aEntryIds, const TUid aModuleUid ); |
|
247 void WriteEntryIdsToStoreL( RArray<TUint32>& aEntryIds, const TUid aModuleUid ); |
|
248 void RemoveStoreL( const TUid aModuleUid ); |
|
249 |
|
250 private: |
|
251 // needed by the engine itself |
|
252 RTimer iTimer; |
|
253 CEikonEnv* iEnv; |
|
254 CCreatorAppUi* iAppUi; |
|
255 TInt iCurrentEntry; |
|
256 TInt iEntriesToBeCreated; |
|
257 TInt iFailedCommands; |
|
258 |
|
259 CDesCArrayFlat* iSoundFileArray; |
|
260 CDesCArrayFlat* iPictureFileArray; |
|
261 CCommandArray* iCommandArray; |
|
262 RPointerArray<CCreatorModuleBaseParameters> iParameterArray; |
|
263 // progress bar |
|
264 CAknProgressDialog* iProgressDialog; |
|
265 CEikProgressInfo* iProgressInfo; |
|
266 |
|
267 // for the random data generator |
|
268 TInt64 iSeed; |
|
269 |
|
270 class TStringArrayPtr |
|
271 { |
|
272 public: |
|
273 TStringArrayPtr(TRandomStringType aType, CDesCArray* aPtr) |
|
274 { |
|
275 iStringType = aType; |
|
276 iArrayPtr = aPtr; |
|
277 }; |
|
278 TRandomStringType iStringType; |
|
279 CDesCArray* iArrayPtr; |
|
280 }; |
|
281 |
|
282 RArray<TStringArrayPtr> iStringArrays; |
|
283 |
|
284 // modules |
|
285 CCreatorBrowser* iBrowser; |
|
286 CCreatorCalendarBase* iCalendar; |
|
287 CCreatorPhonebookBase* iPhonebook; |
|
288 CCreatorNotepad* iNotepad; |
|
289 CCreatorLogs* iLogs; |
|
290 CCreatorConnectionSettingsBase* iAccessPoints; |
|
291 CCreatorMailboxes* iMailboxes; |
|
292 CCreatorIMPS* iIMPS; |
|
293 CCreatorFiles* iFiles; |
|
294 CCreatorMessages* iMessages; |
|
295 CCreatorLandmarks* iLandmarks; |
|
296 |
|
297 // options menu command home module |
|
298 MCreatorModuleBase* iUsedOptionsMenuModule; |
|
299 |
|
300 HBufC* iTempPath; |
|
301 |
|
302 RPointerArray<HBufC> iAllocatedFilePaths; |
|
303 TBool iUserCancelled; |
|
304 |
|
305 // For generating missing bitmaps |
|
306 HBufC8* iBitmapData; |
|
307 CFbsBitmap* iBitmap; |
|
308 CFbsBitmap* iScaledBitmap; |
|
309 CImageDecoder* iDecoder; |
|
310 TFrameInfo iFrameinfo; |
|
311 CImageEncoder* iEncoder; |
|
312 CFrameImageData* iFrameImageData; |
|
313 CBitmapScaler* iScaler; |
|
314 |
|
315 public: |
|
316 |
|
317 }; |
|
318 |
|
319 // this class contains a command which will be executed |
|
320 class TCommand |
|
321 { |
|
322 public: |
|
323 TInt iCommandId; |
|
324 CCreatorModuleBaseParameters* iParameters; |
|
325 public: |
|
326 TCommand(TInt aCommandId, CCreatorModuleBaseParameters* aParameters); |
|
327 ~TCommand(); |
|
328 |
|
329 }; |
|
330 |
|
331 |
|
332 // utility class for waiting for asychronous requests |
|
333 class CAsyncWaiter : public CActive |
|
334 { |
|
335 public: |
|
336 static CAsyncWaiter* NewL( TInt aPriority = EPriorityStandard ); |
|
337 static CAsyncWaiter* NewLC( TInt aPriority = EPriorityStandard ); |
|
338 ~CAsyncWaiter(); |
|
339 |
|
340 void StartAndWait(); |
|
341 TInt Result() const; |
|
342 |
|
343 private: |
|
344 CAsyncWaiter( TInt aPriority ); |
|
345 |
|
346 // from CActive |
|
347 void RunL(); |
|
348 void DoCancel(); |
|
349 |
|
350 private: |
|
351 CActiveSchedulerWait iWait; |
|
352 TInt iError; |
|
353 }; |
|
354 |
|
355 |
|
356 /* |
|
357 * Maps file id string (file name) to TTestDataPath (file id) and TCreatorIds (command id) |
|
358 */ |
|
359 // File ids: |
|
360 |
|
361 _LIT(K3GPP_70KB, "3GPP-70kB"); |
|
362 _LIT(KAAC_100KB, "AAC-100kB"); |
|
363 _LIT(KAMR_20KB, "AMR-20kB"); |
|
364 _LIT(KXLS_15KB, "XLS-15kB"); |
|
365 _LIT(KGIF_2KB, "GIF-2kB"); |
|
366 _LIT(KJPEG_200KB, "JPEG-200kB"); |
|
367 _LIT(KJPEG_25KB, "JPEG-25kB"); |
|
368 _LIT(KJPEG_500KB, "JPEG-500kB"); |
|
369 _LIT(KMIDI_10KB, "MIDI-10kB"); |
|
370 _LIT(KMP3_250KB, "MP3-250kB"); |
|
371 _LIT(KPNG_15KB, "PNG-15kB"); |
|
372 _LIT(KPPT_40KB, "PPT-40kB"); |
|
373 _LIT(KRM_95KB, "RM-95kB"); |
|
374 _LIT(KRNG_1KB, "RNG-1kB"); |
|
375 _LIT(KTXT_10KB, "TXT-10kB"); |
|
376 _LIT(KTXT_70KB, "TXT-70kB"); |
|
377 _LIT(KWAV_20KB, "WAV-20kB"); |
|
378 _LIT(KDOC_20KB, "DOC-20kB"); |
|
379 _LIT(KSWF_15KB, "SWF-15kB"); |
|
380 _LIT(KJAD_1KB, "JAD-1kB"); |
|
381 _LIT(KJAR_10KB, "JAR-10kB"); |
|
382 _LIT(KTIF_25KB, "TIF-25kB"); |
|
383 _LIT(KMXMF_40KB, "MXMF-40kB"); |
|
384 _LIT(KBMP_25KB, "BMP-25kB"); |
|
385 _LIT(KJP2_25KB, "JP2-25kB"); |
|
386 _LIT(KSVG_15KB, "SVG-15kB"); |
|
387 _LIT(KHTML_20KB, "HTML-20kB"); |
|
388 _LIT(KVCF_1KB, "VCF-1kB"); |
|
389 _LIT(KVCS_1KB, "VCS-1kB"); |
|
390 _LIT(KMP4_200KB, "MP4-200kB"); |
|
391 _LIT(KSISX_10KB, "SISX-10kB"); |
|
392 _LIT(KRAM_1KB, "RAM-1kB"); |
|
393 _LIT(KDECK_1KB, "DECK-1kB"); |
|
394 _LIT(KWMA_50KB, "WMA-50kB"); |
|
395 _LIT(KWMV_200KB, "WMV-200kB"); |
|
396 |
|
397 class FileMapping |
|
398 { |
|
399 public: |
|
400 FileMapping(const TDesC& aFileName, TInt aFileId, TInt aCommandId ); |
|
401 const TDesC& FileName() const; |
|
402 TInt FileId() const; |
|
403 TInt CommandId() const; |
|
404 |
|
405 private: |
|
406 const TDesC& iFileName; |
|
407 TInt iFileId; |
|
408 TInt iCommandId; |
|
409 }; |
|
410 |
|
411 /* |
|
412 * This table contains the string <-> TTestDataPath mappings for the file types |
|
413 */ |
|
414 static FileMapping FileMap[] = |
|
415 { |
|
416 |
|
417 FileMapping(K3GPP_70KB, CCreatorEngine::E3GPP_70kB, ECmdCreateFileEntry3GPP_70kB), |
|
418 FileMapping(KAAC_100KB, CCreatorEngine::EAAC_100kB, ECmdCreateFileEntryAAC_100kB), |
|
419 FileMapping(KAMR_20KB, CCreatorEngine::EAMR_20kB, ECmdCreateFileEntryAMR_20kB), |
|
420 FileMapping(KXLS_15KB, CCreatorEngine::EExcel_15kB, ECmdCreateFileEntryXLS_15kB), |
|
421 FileMapping(KGIF_2KB, CCreatorEngine::EGIF_2kB, ECmdCreateFileEntryGIF_2kB), |
|
422 FileMapping(KJPEG_200KB, CCreatorEngine::EJPEG_200kB, ECmdCreateFileEntryJPEG_200kB), |
|
423 FileMapping(KJPEG_25KB, CCreatorEngine::EJPEG_25kB, ECmdCreateFileEntryJPEG_25kB), |
|
424 FileMapping(KJPEG_500KB, CCreatorEngine::EJPEG_500kB, ECmdCreateFileEntryJPEG_500kB), |
|
425 FileMapping(KMIDI_10KB, CCreatorEngine::EMIDI_10kB, ECmdCreateFileEntryMIDI_10kB), |
|
426 FileMapping(KMP3_250KB, CCreatorEngine::EMP3_250kB, ECmdCreateFileEntryMP3_250kB), |
|
427 FileMapping(KPNG_15KB, CCreatorEngine::EPNG_15kB, ECmdCreateFileEntryPNG_15kB), |
|
428 FileMapping(KPPT_40KB, CCreatorEngine::EPowerPoint_40kB, ECmdCreateFileEntryPPT_40kB), |
|
429 FileMapping(KRM_95KB, CCreatorEngine::ERM_95kB, ECmdCreateFileEntryRM_95kB), |
|
430 FileMapping(KRNG_1KB, CCreatorEngine::ERNG_1kB, ECmdCreateFileEntryRNG_1kB), |
|
431 FileMapping(KTXT_10KB, CCreatorEngine::EText_10kB, ECmdCreateFileEntryTXT_10kB), |
|
432 FileMapping(KTXT_70KB, CCreatorEngine::EText_70kB, ECmdCreateFileEntryTXT_70kB), |
|
433 FileMapping(KWAV_20KB, CCreatorEngine::EWAVE_20kB, ECmdCreateFileEntryWAV_20kB), |
|
434 FileMapping(KDOC_20KB, CCreatorEngine::EWord_20kB, ECmdCreateFileEntryDOC_20kB), |
|
435 FileMapping(KBMP_25KB, CCreatorEngine::EBMP_25kB, ECmdCreateFileEntryBMP_25kB), |
|
436 FileMapping(KDECK_1KB, CCreatorEngine::ESavedDeck_1kB, ECmdCreateFileEntryDeck_1kB), |
|
437 FileMapping(KHTML_20KB, CCreatorEngine::EHTML_20kB, ECmdCreateFileEntryHTML_20kB), |
|
438 FileMapping(KJAD_1KB, CCreatorEngine::EJAD_1kB, ECmdCreateFileEntryJAD_1kB), |
|
439 FileMapping(KJAR_10KB, CCreatorEngine::EJAR_10kB, ECmdCreateFileEntryJAR_10kB), |
|
440 FileMapping(KJP2_25KB, CCreatorEngine::EJP2_65kB, ECmdCreateFileEntryJP2_65kB), |
|
441 FileMapping(KMP4_200KB, CCreatorEngine::EMP4_200kB, ECmdCreateFileEntryMP4_200kB), |
|
442 FileMapping(KMXMF_40KB, CCreatorEngine::EMXMF_40kB, ECmdCreateFileEntryMXMF_40kB), |
|
443 FileMapping(KRAM_1KB, CCreatorEngine::ERAM_1kB, ECmdCreateFileEntryRAM_1kB), |
|
444 FileMapping(KSVG_15KB, CCreatorEngine::ESVG_15kB, ECmdCreateFileEntrySVG_15kB), |
|
445 FileMapping(KSWF_15KB, CCreatorEngine::ESWF_15kB, ECmdCreateFileEntrySWF_15kB), |
|
446 FileMapping(KTIF_25KB, CCreatorEngine::ETIF_25kB, ECmdCreateFileEntryTIF_25kB), |
|
447 FileMapping(KVCF_1KB, CCreatorEngine::EVCF_1kB, ECmdCreateFileEntryVCF_1kB), |
|
448 FileMapping(KVCS_1KB, CCreatorEngine::EVCS_1kB, ECmdCreateFileEntryVCS_1kB), |
|
449 FileMapping(KSISX_10KB, CCreatorEngine::ESISX_10kB, ECmdCreateFileEntrySISX_10kB), |
|
450 FileMapping(KWMA_50KB, CCreatorEngine::EWMA_50kB, ECmdCreateFileEntryWMA_50kB), |
|
451 FileMapping(KWMV_200KB, CCreatorEngine::EWMV_200kB, ECmdCreateFileEntryWMV_200kB) |
|
452 }; |
|
453 |
|
454 #endif // __CREATORENGINE_H__ |
|
455 |
|