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 |
|
20 #include <aknlists.h> |
|
21 #include <AknsSkinInstance.h> |
|
22 #include <data_caging_path_literals.hrh> |
|
23 |
|
24 #include "engine.h" |
|
25 #include "enginewrapper.h" |
|
26 #include "creator_traces.h" |
|
27 #include "creator_factory.h" |
|
28 #include "creator_scriptentry.h" |
|
29 |
|
30 |
|
31 |
|
32 const TInt KReadBufSize = 8192; |
|
33 |
|
34 // Creator random data file filter |
|
35 _LIT(KRandomDataFileFilter, "*.creatordataxml"); |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 |
|
39 |
|
40 CCommandParser* CCommandParser::NewL(CCreatorEngine* aEngine) |
|
41 { |
|
42 CCommandParser* self = CCommandParser::NewLC(aEngine); |
|
43 CleanupStack::Pop(self); |
|
44 return self; |
|
45 } |
|
46 |
|
47 CCommandParser* CCommandParser::NewLC(CCreatorEngine* aEngine) |
|
48 { |
|
49 CCommandParser* self = new (ELeave) CCommandParser; |
|
50 CleanupStack::PushL(self); |
|
51 self->ConstructL(aEngine); |
|
52 return self; |
|
53 } |
|
54 |
|
55 CCommandParser::CCommandParser() |
|
56 { |
|
57 } |
|
58 |
|
59 void CCommandParser::ConstructL(CCreatorEngine* aEngine) |
|
60 { |
|
61 LOGSTRING("Creator: CCommandParser::ConstructL"); |
|
62 |
|
63 iEngine = aEngine; |
|
64 |
|
65 iReadBuf = HBufC8::NewL(KReadBufSize); |
|
66 } |
|
67 |
|
68 CCommandParser::~CCommandParser() |
|
69 { |
|
70 LOGSTRING("Creator: CCommandParser::~CCommandParser"); |
|
71 |
|
72 if (iSearchArray){ |
|
73 delete iSearchArray; |
|
74 iSearchArray = NULL; |
|
75 } |
|
76 |
|
77 if (iReadBuf) |
|
78 delete iReadBuf; |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 |
|
83 void CCommandParser::QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) |
|
84 { |
|
85 User::LeaveIfNull(iSearchArray); |
|
86 |
|
87 if( aUserData == EGetingScript ) |
|
88 { |
|
89 if(aPositiveAction) |
|
90 { |
|
91 iObserver->ScriptChosenL( ETrue, iSearchArray->MdcaPoint(iSelectedItem) ); |
|
92 } |
|
93 else |
|
94 { |
|
95 iObserver->ScriptChosenL( EFalse ); |
|
96 } |
|
97 } |
|
98 else if( aUserData == EGetingRandomDataFile && aPositiveAction && iSearchArray->Count() ) |
|
99 { |
|
100 if(aPositiveAction) |
|
101 { |
|
102 TFileName fileName; |
|
103 if (iSelectedItem == (iSearchArray->Count() - 1)) |
|
104 { |
|
105 // "default" (resource file) selected |
|
106 fileName.Copy(KNullDesC); |
|
107 } |
|
108 else |
|
109 { |
|
110 // xml file selected |
|
111 fileName.Copy(iSearchArray->MdcaPoint(iSelectedItem)); |
|
112 } |
|
113 iObserver->RandomDataFileChosenL( ETrue, fileName ); |
|
114 } |
|
115 else |
|
116 { |
|
117 iObserver->RandomDataFileChosenL( EFalse ); |
|
118 } |
|
119 } |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 //#if(!defined __SERIES60_30__ && !defined __SERIES60_31__) |
|
124 void CCommandParser::OpenScriptL() {} |
|
125 TBool CCommandParser::OpenScriptL(MCommandParserObserver* aObserver) |
|
126 { |
|
127 LOGSTRING("Creator: CCommandParser::OpenScriptL"); |
|
128 |
|
129 User::LeaveIfNull( aObserver ); |
|
130 iObserver = aObserver; |
|
131 iSelectedItem = 0; |
|
132 |
|
133 TBool ret = EFalse; |
|
134 |
|
135 // init the search array |
|
136 delete iSearchArray; |
|
137 iSearchArray = NULL; |
|
138 iSearchArray = new(ELeave) CDesCArrayFlat(20); |
|
139 |
|
140 // wait dialog |
|
141 // TODO |
|
142 //CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC(); |
|
143 //waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL); |
|
144 //TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Searching")); |
|
145 |
|
146 |
|
147 // search all the .creator files from the phone |
|
148 TInt err; |
|
149 TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\"))); |
|
150 |
|
151 TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\system\\apps\\Creator\\"))); |
|
152 |
|
153 TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\data\\"))); |
|
154 TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\data\\"))); |
|
155 |
|
156 TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\documents\\"))); |
|
157 TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\documents\\"))); |
|
158 |
|
159 TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\creator\\"))); |
|
160 TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\creator\\"))); |
|
161 |
|
162 TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\scripts\\"))); |
|
163 TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\scripts\\"))); |
|
164 |
|
165 TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\temp\\"))); |
|
166 TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\temp\\"))); |
|
167 |
|
168 TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\system\\temp\\"))); |
|
169 TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\system\\temp\\"))); |
|
170 |
|
171 TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\private\\20011383\\"))); |
|
172 TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\private\\20011383\\"))); |
|
173 |
|
174 TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\private\\1000484b\\"))); |
|
175 |
|
176 |
|
177 // remove the wait dialog |
|
178 // TODO |
|
179 //waitDialog->CancelNoteL(dialogId); |
|
180 //CleanupStack::PopAndDestroy(); //waitDialog; |
|
181 |
|
182 |
|
183 if ( iSearchArray->MdcaCount() > 0) |
|
184 { |
|
185 // create a file name array based on the iSearchArray |
|
186 CDesCArray* fileNameArray = new(ELeave) CDesCArrayFlat(iSearchArray->MdcaCount()); |
|
187 CleanupStack::PushL(fileNameArray); |
|
188 |
|
189 for (TInt i=0; i<iSearchArray->MdcaCount(); i++) |
|
190 { |
|
191 |
|
192 TParse filename; // file name parser |
|
193 filename.Set(iSearchArray->MdcaPoint(i), NULL, NULL); |
|
194 |
|
195 if ( filename.Drive()[0] == 'e' || filename.Drive()[0] == 'E') // MMC |
|
196 { |
|
197 TFileName nameMMC; |
|
198 nameMMC.Append(filename.Name()); |
|
199 nameMMC.Append(_L("\t0")); // MMC icon |
|
200 fileNameArray->AppendL(nameMMC); |
|
201 } |
|
202 else |
|
203 { |
|
204 fileNameArray->AppendL(filename.Name()); |
|
205 } |
|
206 } |
|
207 |
|
208 ret = iEngine->GetEngineWrapper()->PopupListDialog(_L("Select script"), fileNameArray, &iSelectedItem, this, EGetingScript); |
|
209 CleanupStack::PopAndDestroy(fileNameArray); |
|
210 } |
|
211 else // no scripts found from the search paths |
|
212 { |
|
213 iEngine->GetEngineWrapper()->ShowNote(_L("No scripts found")); |
|
214 delete iSearchArray; |
|
215 iSearchArray = NULL; |
|
216 } |
|
217 |
|
218 |
|
219 return ret; |
|
220 } |
|
221 /* |
|
222 #else |
|
223 // --------------------------------------------------------------------------- |
|
224 void CCommandParser::OpenScriptL() |
|
225 { |
|
226 LOGSTRING("Creator: CCommandParser::OpenScriptL"); |
|
227 |
|
228 // init the search array |
|
229 iSearchArray = new(ELeave) CDesCArrayFlat(500); |
|
230 |
|
231 // wait dialog |
|
232 CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC(); |
|
233 waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL); |
|
234 TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Searching")); |
|
235 |
|
236 |
|
237 // search all the .creator files from the phone |
|
238 TInt err; |
|
239 TRAP(err, FindFiles(_L("*.creator"), _L("\\"))); |
|
240 |
|
241 TRAP(err, FindFiles(_L("*.creator"), _L("\\system\\apps\\Creator\\"))); |
|
242 |
|
243 TRAP(err, FindFiles(_L("*.creator"), _L("\\data\\"))); |
|
244 TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\data\\"))); |
|
245 |
|
246 TRAP(err, FindFiles(_L("*.creator"), _L("\\documents\\"))); |
|
247 TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\documents\\"))); |
|
248 |
|
249 TRAP(err, FindFiles(_L("*.creator"), _L("\\creator\\"))); |
|
250 TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\creator\\"))); |
|
251 |
|
252 TRAP(err, FindFiles(_L("*.creator"), _L("\\scripts\\"))); |
|
253 TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\scripts\\"))); |
|
254 |
|
255 TRAP(err, FindFiles(_L("*.creator"), _L("\\temp\\"))); |
|
256 TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\temp\\"))); |
|
257 |
|
258 TRAP(err, FindFiles(_L("*.creator"), _L("\\system\\temp\\"))); |
|
259 TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\system\\temp\\"))); |
|
260 |
|
261 TRAP(err, FindFiles(_L("*.creator"), _L("\\private\\101FA751\\"))); |
|
262 TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\private\\101FA751\\"))); |
|
263 |
|
264 TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\private\\1000484b\\"))); |
|
265 |
|
266 |
|
267 // remove the wait dialog |
|
268 waitDialog->CancelNoteL(dialogId); |
|
269 CleanupStack::PopAndDestroy(); //waitDialog; |
|
270 |
|
271 |
|
272 if ( iSearchArray->MdcaCount() > 0) |
|
273 { |
|
274 // create a file name array based on the iSearchArray |
|
275 CDesCArray* fileNameArray = new(ELeave) CDesCArrayFlat(iSearchArray->MdcaCount()); |
|
276 CleanupStack::PushL(fileNameArray); |
|
277 |
|
278 for (TInt i=0; i<iSearchArray->MdcaCount(); i++) |
|
279 { |
|
280 |
|
281 TParse filename; // file name parser |
|
282 filename.Set(iSearchArray->MdcaPoint(i), NULL, NULL); |
|
283 |
|
284 if ( filename.Drive()[0] == 'e' || filename.Drive()[0] == 'E') // MMC |
|
285 { |
|
286 TFileName nameMMC; |
|
287 nameMMC.Append(filename.Name()); |
|
288 nameMMC.Append(_L("\t0")); // MMC icon |
|
289 fileNameArray->AppendL(nameMMC); |
|
290 } |
|
291 else |
|
292 { |
|
293 fileNameArray->AppendL(filename.Name()); |
|
294 } |
|
295 } |
|
296 CleanupStack::Pop(fileNameArray); |
|
297 |
|
298 |
|
299 // create a popup list |
|
300 CAknSinglePopupMenuStyleListBox* listBox = new(ELeave) CAknSinglePopupMenuStyleListBox; |
|
301 CleanupStack::PushL(listBox); |
|
302 CAknPopupList* popupList = CAknPopupList::NewL( listBox, R_AVKON_SOFTKEYS_SELECT_CANCEL, AknPopupLayouts::EMenuWindow ); |
|
303 CleanupStack::PushL(popupList); |
|
304 popupList->SetTitleL(_L("Select script")); |
|
305 listBox->ConstructL( popupList, EAknListBoxSelectionList|EAknListBoxLoopScrolling ); |
|
306 listBox->CreateScrollBarFrameL( ETrue ); |
|
307 listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); |
|
308 listBox->Model()->SetItemTextArray( fileNameArray ); |
|
309 listBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); // !!! |
|
310 listBox->HandleItemAdditionL(); |
|
311 |
|
312 |
|
313 // define MMC icon |
|
314 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
315 _LIT( KFLDMemoryCardUiBitmapFile, "z:aknmemorycardui.mbm" ); |
|
316 CAknIconArray* iconArray = new( ELeave ) CAknIconArray( 1 ); |
|
317 listBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray ); |
|
318 |
|
319 TParse* fp = new(ELeave) TParse(); |
|
320 fp->Set(KFLDMemoryCardUiBitmapFile, &KDC_APP_BITMAP_DIR, NULL); |
|
321 TFileName resourceFileName( fp->FullName() ); |
|
322 delete fp; |
|
323 |
|
324 CGulIcon* icon = AknsUtils::CreateGulIconL( skin, KAknsIIDQgnIndiMmcAdd, |
|
325 resourceFileName, |
|
326 EMbmAknmemorycarduiQgn_indi_mmc_add, |
|
327 EMbmAknmemorycarduiQgn_indi_mmc_add_mask ); |
|
328 CleanupStack::PushL( icon ); |
|
329 iconArray->AppendL( icon ); |
|
330 CleanupStack::Pop( icon ); |
|
331 |
|
332 |
|
333 // execute dialog |
|
334 TBool result = popupList->ExecuteLD(); |
|
335 CleanupStack::Pop(); // popupList |
|
336 |
|
337 if ( result ) |
|
338 { |
|
339 // open the file for reading |
|
340 RFile file; |
|
341 User::LeaveIfError(file.Open(CEikonEnv::Static()->FsSession(), iSearchArray->MdcaPoint(listBox->CurrentItemIndex()), EFileRead)); |
|
342 while (ReadLineFromFileL(file) == KErrNone) |
|
343 { |
|
344 iReadBuf->Des().Trim(); // delete leading and trailing white space |
|
345 |
|
346 if (iReadBuf->Length() < 5) // command too short, ignoring... |
|
347 { |
|
348 //CEikonEnv::Static()->InfoMsg(_L("Corrupted line")); |
|
349 } |
|
350 |
|
351 // check it's a valid line: first char is A-Z and the line ends to ';' |
|
352 else if (iReadBuf->Des()[0] >= 'A' && iReadBuf->Des()[0] <= 'Z' && iReadBuf->Des()[iReadBuf->Length()-1] == ';') |
|
353 { |
|
354 // this line is valid -> parse the command |
|
355 ParseCommandFromDescriptorL(); |
|
356 } |
|
357 else |
|
358 { |
|
359 //CEikonEnv::Static()->InfoMsg(_L("Not a valid line")); |
|
360 } |
|
361 |
|
362 } |
|
363 |
|
364 file.Close(); |
|
365 |
|
366 // show a note if there were no valid commands in the script |
|
367 if (iEngine->CommandArrayCount() == 0) |
|
368 { |
|
369 CAknInformationNote* note = new(ELeave) CAknInformationNote; |
|
370 note->ExecuteLD(_L("No valid commands in this script")); |
|
371 } |
|
372 |
|
373 } |
|
374 |
|
375 CleanupStack::PopAndDestroy(); //listBox |
|
376 } |
|
377 |
|
378 else // no scripts found from the search paths |
|
379 { |
|
380 CAknInformationNote* note = new (ELeave) CAknInformationNote; |
|
381 note->ExecuteLD(_L("No scripts found")); |
|
382 } |
|
383 |
|
384 |
|
385 delete iSearchArray; |
|
386 iSearchArray = NULL; |
|
387 |
|
388 } |
|
389 #endif |
|
390 */ |
|
391 |
|
392 TBool CCommandParser::GetRandomDataFilenameL(MCommandParserObserver *aObserver) |
|
393 { |
|
394 LOGSTRING("Creator: CCommandParser::GetRandomDataFilenameL"); |
|
395 TBool ret = EFalse; |
|
396 |
|
397 User::LeaveIfNull( aObserver ); |
|
398 iObserver = aObserver; |
|
399 iSelectedItem = 0; |
|
400 |
|
401 // init the search array |
|
402 if (iSearchArray) |
|
403 { |
|
404 delete iSearchArray; |
|
405 iSearchArray = NULL; |
|
406 } |
|
407 iSearchArray = new(ELeave) CDesCArrayFlat(500); |
|
408 |
|
409 /* TODO: |
|
410 // wait dialog |
|
411 CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC(); |
|
412 waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL); |
|
413 TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Searching")); |
|
414 */ |
|
415 |
|
416 |
|
417 // search all the creator random data files from the phone |
|
418 TInt err; |
|
419 TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\"))); |
|
420 |
|
421 TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\system\\apps\\Creator\\"))); |
|
422 |
|
423 TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\data\\"))); |
|
424 TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\data\\"))); |
|
425 |
|
426 TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\documents\\"))); |
|
427 TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\documents\\"))); |
|
428 |
|
429 TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\creator\\"))); |
|
430 TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\creator\\"))); |
|
431 |
|
432 TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\scripts\\"))); |
|
433 TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\scripts\\"))); |
|
434 |
|
435 TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\temp\\"))); |
|
436 TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\temp\\"))); |
|
437 |
|
438 TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\system\\temp\\"))); |
|
439 TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\system\\temp\\"))); |
|
440 |
|
441 TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\private\\20011383\\"))); |
|
442 TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\private\\20011383\\"))); |
|
443 |
|
444 TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\private\\1000484b\\"))); |
|
445 |
|
446 |
|
447 // remove the wait dialog |
|
448 // TODO |
|
449 //waitDialog->CancelNoteL(dialogId); |
|
450 //CleanupStack::PopAndDestroy(); //waitDialog; |
|
451 |
|
452 |
|
453 if (iSearchArray->MdcaCount() > 0) |
|
454 { |
|
455 // create a file name array based on the iSearchArray |
|
456 CDesCArray* fileNameArray = new(ELeave) CDesCArrayFlat(iSearchArray->MdcaCount() + 1); |
|
457 CleanupStack::PushL(fileNameArray); |
|
458 |
|
459 for (TInt i=0; i<iSearchArray->MdcaCount(); i++) |
|
460 { |
|
461 |
|
462 TParse filename; // file name parser |
|
463 filename.Set(iSearchArray->MdcaPoint(i), NULL, NULL); |
|
464 |
|
465 if ( filename.Drive()[0] == 'e' || filename.Drive()[0] == 'E') // MMC |
|
466 { |
|
467 TFileName nameMMC; |
|
468 nameMMC.Append(filename.Name()); |
|
469 nameMMC.Append(_L("\t0")); // MMC icon |
|
470 fileNameArray->AppendL(nameMMC); |
|
471 } |
|
472 else |
|
473 { |
|
474 fileNameArray->AppendL(filename.Name()); |
|
475 } |
|
476 } |
|
477 |
|
478 // add "default" (resource file) to list |
|
479 fileNameArray->AppendL(_L("Default")); |
|
480 |
|
481 ret = iEngine->GetEngineWrapper()->PopupListDialog(_L("Select random data file"), fileNameArray, &iSelectedItem, this, EGetingRandomDataFile); |
|
482 CleanupStack::PopAndDestroy(fileNameArray); |
|
483 } |
|
484 else // no random data files found from the search paths |
|
485 { |
|
486 iEngine->GetEngineWrapper()->ShowNote(_L("No random data files found")); |
|
487 delete iSearchArray; |
|
488 iSearchArray = NULL; |
|
489 } |
|
490 |
|
491 return ret; |
|
492 } |
|
493 |
|
494 TInt CCommandParser::FindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath) |
|
495 { |
|
496 return CreatorFileUtils::FindFilesRecursiveL(iSearchArray, aFileName, aPath); |
|
497 } |
|
498 TInt CreatorFileUtils::FindFilesRecursiveL(CDesCArrayFlat* aFileArray, const TDesC& aFileName, const TDesC& aPath) |
|
499 { |
|
500 TInt err = KErrNone; |
|
501 CDirScan* scan = CDirScan::NewLC(CEikonEnv::Static()->FsSession()); |
|
502 scan->SetScanDataL(aPath, KEntryAttDir, ESortNone); |
|
503 CDir* dirEntries = NULL; |
|
504 |
|
505 for(;;) |
|
506 { |
|
507 TRAP(err, scan->NextL(dirEntries)); |
|
508 if (!dirEntries || (err!=KErrNone)) |
|
509 break; |
|
510 |
|
511 for (TInt i=0; i<dirEntries->Count(); i++) |
|
512 { |
|
513 TFileName path(scan->FullPath()); |
|
514 path.Append((*dirEntries)[i].iName); |
|
515 path.Append(_L("\\")); |
|
516 FindFiles(aFileArray, aFileName, path); |
|
517 } |
|
518 delete(dirEntries); |
|
519 } |
|
520 |
|
521 CleanupStack::PopAndDestroy(scan); |
|
522 return err; |
|
523 } |
|
524 |
|
525 TInt CreatorFileUtils::FindFiles(CDesCArrayFlat* aFileArray, const TDesC& aFileName, const TDesC& aPath) |
|
526 { |
|
527 TFindFile fileFinder(CEikonEnv::Static()->FsSession()); |
|
528 CDir* fileList; |
|
529 TInt err = fileFinder.FindWildByDir(aFileName, aPath, fileList); |
|
530 |
|
531 while (err == KErrNone) |
|
532 { |
|
533 for (TInt i=0; i<fileList->Count(); i++) |
|
534 { |
|
535 TParse fullentry; |
|
536 fullentry.Set((*fileList)[i].iName, &fileFinder.File(), NULL); |
|
537 |
|
538 TRAP(err, aFileArray->AppendL(fullentry.FullName())); |
|
539 } |
|
540 |
|
541 delete fileList; |
|
542 err = fileFinder.FindWild(fileList); |
|
543 } |
|
544 return err; |
|
545 } |
|
546 // --------------------------------------------------------------------------- |
|
547 |
|
548 TInt CCommandParser::FindFiles(const TDesC& aFileName, const TDesC& aPath) |
|
549 { |
|
550 return CreatorFileUtils::FindFiles(iSearchArray, aFileName, aPath); |
|
551 } |
|
552 |
|
553 // --------------------------------------------------------------------------- |
|
554 |
|
555 TInt CCommandParser::ReadLineFromFileL(RFile& aInputFile) |
|
556 { |
|
557 LOGSTRING("Creator: CCommandParser::ReadLineFromFile"); |
|
558 |
|
559 _LIT8(KImcvCRLF, "\r\n"); |
|
560 |
|
561 TInt err = KErrNone; |
|
562 |
|
563 // Read into the buffer |
|
564 HBufC8* tempLine = HBufC8::NewLC(KReadBufSize); |
|
565 TPtr8 buffer = tempLine->Des(); |
|
566 |
|
567 // clear the targer |
|
568 iReadBuf->Des().Copy(_L("")); |
|
569 |
|
570 // Get the current file position |
|
571 TInt filePos = 0; |
|
572 aInputFile.Seek(ESeekCurrent, filePos); |
|
573 |
|
574 // Read the buffer |
|
575 err = aInputFile.Read(buffer); |
|
576 |
|
577 //end of file? |
|
578 TInt s = buffer.Length(); |
|
579 if ( s == 0) |
|
580 err = KErrEof; |
|
581 |
|
582 if (err == KErrNone) |
|
583 { |
|
584 // Copy to the lfcr and then set the file pointer to the point after that |
|
585 TInt pos = buffer.Find(KImcvCRLF); |
|
586 if ( pos != -1) |
|
587 { |
|
588 iReadBuf->Des().Justify(buffer, pos, ELeft, ' '); |
|
589 filePos += (pos+2); |
|
590 |
|
591 // Set the file pointer back to after the lfcr |
|
592 aInputFile.Seek(ESeekStart, filePos); |
|
593 } |
|
594 // Else fill the whole buffer |
|
595 else |
|
596 { |
|
597 iReadBuf->Des().Copy(buffer); |
|
598 } |
|
599 } |
|
600 |
|
601 CleanupStack::PopAndDestroy(); // tempLine |
|
602 return err; |
|
603 } |
|
604 |
|
605 // --------------------------------------------------------------------------- |
|
606 |
|
607 void CCommandParser::StrParserL(HBufC*& aDestinationBuf, TUint aToken) |
|
608 { |
|
609 // store old position |
|
610 iParserOldPosition = iParserPosition; |
|
611 |
|
612 // make sure we are not reading outside of buffer |
|
613 if (iParserPosition >= iReadBuf->Length() - 1) |
|
614 return; |
|
615 |
|
616 // read until asked token |
|
617 do |
|
618 { |
|
619 iParserPosition++; |
|
620 } |
|
621 while (iReadBuf->Des()[iParserPosition] != aToken && iParserPosition < iReadBuf->Des().Length()-1); |
|
622 |
|
623 // calculate length of the destination buffer |
|
624 TInt bufferLength = iParserPosition-iParserOldPosition-1; |
|
625 |
|
626 // reset the destination buffer |
|
627 if (aDestinationBuf) |
|
628 { |
|
629 delete aDestinationBuf; |
|
630 aDestinationBuf = NULL; |
|
631 } |
|
632 |
|
633 // allocate memory for the destination buffer |
|
634 aDestinationBuf = HBufC::NewL(bufferLength); |
|
635 |
|
636 // copy data from the read buffer to the destination buffer |
|
637 aDestinationBuf->Des().Copy(iReadBuf->Des().Mid(iParserOldPosition+1, bufferLength)); |
|
638 } |
|
639 |
|
640 // --------------------------------------------------------------------------- |
|
641 |
|
642 void CCommandParser::StrParserL(HBufC8*& aDestinationBuf, TUint aToken) |
|
643 { |
|
644 // store old position |
|
645 iParserOldPosition = iParserPosition; |
|
646 |
|
647 // make sure we are not reading outside of buffer |
|
648 if (iParserPosition >= iReadBuf->Length() - 1) |
|
649 return; |
|
650 |
|
651 // read until asked token |
|
652 do |
|
653 { |
|
654 iParserPosition++; |
|
655 } |
|
656 while (iReadBuf->Des()[iParserPosition] != aToken && iParserPosition < iReadBuf->Des().Length()-1); |
|
657 |
|
658 // calculate length of the destination buffer |
|
659 TInt bufferLength = iParserPosition-iParserOldPosition-1; |
|
660 |
|
661 // reset the destination buffer |
|
662 if (aDestinationBuf) |
|
663 { |
|
664 delete aDestinationBuf; |
|
665 aDestinationBuf = NULL; |
|
666 } |
|
667 |
|
668 // allocate memory for the destination buffer |
|
669 aDestinationBuf = HBufC8::NewL(bufferLength); |
|
670 |
|
671 // copy data from the read buffer to the destination buffer |
|
672 aDestinationBuf->Des().Copy(iReadBuf->Des().Mid(iParserOldPosition+1, bufferLength)); |
|
673 } |
|
674 |
|
675 //---------------------------------------------------------------------------- |
|
676 |
|
677 void CCommandParser::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) // from MMsvSessionObserver |
|
678 { |
|
679 } |
|
680 |
|
681 //---------------------------------------------------------------------------- |
|
682 |
|