1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
27 #include "ssmcommandlistinterface.h" |
27 #include "ssmcommandlistinterface.h" |
28 #include "ssmdebug.h" |
28 #include "ssmdebug.h" |
29 #include "ssmpanic.h" |
29 #include "ssmpanic.h" |
30 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
30 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
31 #include "ssmcommandlistimpl.h" |
31 #include "ssmcommandlistimpl.h" |
32 #endif |
32 #ifdef __WINS__ |
|
33 #include <u32hal.h> |
|
34 |
|
35 //Literal to be appended with the main folder path to get the extended folder path |
|
36 _LIT(KExtendedCommandListPath, "_ext\\"); |
|
37 |
|
38 //Used for checking the presence of keyword for using extended folder in epoc.ini |
|
39 static TBool IsExtendedFolderDisabled() |
|
40 { |
|
41 TBool isMinimalBootDisable = EFalse; |
|
42 |
|
43 //If the keyword "MINIMALSTART" is found in epoc.ini then only commands from main folder are |
|
44 //executed else commands from both main and extended folder are executed. |
|
45 UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalBoolProperty, (TAny*)"MINIMALSTART", &isMinimalBootDisable); |
|
46 return isMinimalBootDisable; |
|
47 } |
|
48 #endif // __WINS__ |
|
49 #endif //SYMBIAN_SSM_FLEXIBLE_MERGE |
|
50 |
33 |
51 |
34 CSsmCommandListResourceReaderImpl* CSsmCommandListResourceReaderImpl::NewL(RFs& aFs, const TDesC& aCommandListPath, MSsmConditionalCallback& aConditionalCallback) |
52 CSsmCommandListResourceReaderImpl* CSsmCommandListResourceReaderImpl::NewL(RFs& aFs, const TDesC& aCommandListPath, MSsmConditionalCallback& aConditionalCallback) |
35 { |
53 { |
36 CSsmCommandListResourceReaderImpl* self = new(ELeave) CSsmCommandListResourceReaderImpl(); |
54 CSsmCommandListResourceReaderImpl* self = new(ELeave) CSsmCommandListResourceReaderImpl(); |
37 CleanupStack::PushL(self); |
55 CleanupStack::PushL(self); |
178 //Breaking as it reached end of array or completed appending the mappings for |
196 //Breaking as it reached end of array or completed appending the mappings for |
179 //the given commandlist id |
197 //the given commandlist id |
180 break; |
198 break; |
181 } |
199 } |
182 } |
200 } |
183 DEBUGPRINT3(_L("Mapping Array for substate %d Contains %d entries"), iMappings[mappingIndex].iCommandListId, aMappingArray.Count()); |
201 DEBUGPRINT3(_L("Mapping Array for substate %04x Contains %d entries"), iMappings[mappingIndex].iCommandListId, aMappingArray.Count()); |
184 } |
202 } |
185 |
203 |
186 #else |
204 #else |
187 CSsmCommandListResourceReaderImpl::TMapping CSsmCommandListResourceReaderImpl::CResourcePool::MappingL(TInt aCommandListId) const |
205 CSsmCommandListResourceReaderImpl::TMapping CSsmCommandListResourceReaderImpl::CResourcePool::MappingL(TInt aCommandListId) const |
188 { |
206 { |
274 return self; |
292 return self; |
275 } |
293 } |
276 |
294 |
277 CSsmCommandListResourceReaderImpl::CInitialiser::CInitialiser(RFs& aFs, CResourcePool& aResourcePool) |
295 CSsmCommandListResourceReaderImpl::CInitialiser::CInitialiser(RFs& aFs, CResourcePool& aResourcePool) |
278 :CActiveBase(EPriorityStandard), iFs(aFs), iResourcePool(aResourcePool) |
296 :CActiveBase(EPriorityStandard), iFs(aFs), iResourcePool(aResourcePool) |
|
297 #if defined(SYMBIAN_SSM_FLEXIBLE_MERGE) && defined(__WINS__) |
|
298 , iExtendedEntryIndex(0) |
|
299 #endif //SYMBIAN_SSM_FLEXIBLE_MERGE && __WINS__ |
279 { |
300 { |
280 CActiveScheduler::Add(this); |
301 CActiveScheduler::Add(this); |
281 } |
302 } |
282 |
303 |
283 CSsmCommandListResourceReaderImpl::CInitialiser::~CInitialiser() |
304 CSsmCommandListResourceReaderImpl::CInitialiser::~CInitialiser() |
298 iResourcePool.Reset(); |
323 iResourcePool.Reset(); |
299 iAction = EIdle; |
324 iAction = EIdle; |
300 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
325 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
301 delete iRssFileEntriesInSysDrive; |
326 delete iRssFileEntriesInSysDrive; |
302 iRssFileEntriesInSysDrive = NULL; |
327 iRssFileEntriesInSysDrive = NULL; |
|
328 #ifdef __WINS__ |
|
329 delete iExtendedResourceFileEntries; |
|
330 iExtendedResourceFileEntries = NULL; |
|
331 #endif //__WINS__ |
303 #endif |
332 #endif |
304 } |
333 } |
305 |
334 |
306 void CSsmCommandListResourceReaderImpl::CInitialiser::ConstructL(const TDesC& aCommandListPath) |
335 void CSsmCommandListResourceReaderImpl::CInitialiser::ConstructL(const TDesC& aCommandListPath) |
307 { |
336 { |
349 DoInitialiseNextStepL(); |
378 DoInitialiseNextStepL(); |
350 break; |
379 break; |
351 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
380 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
352 case EInitialiseSysDriveStep: |
381 case EInitialiseSysDriveStep: |
353 DoInitialiseSysDriveStepL(); |
382 DoInitialiseSysDriveStepL(); |
354 break; |
383 break; |
|
384 #ifdef __WINS__ |
|
385 case EInitialiseExtFolderStep: |
|
386 DoInitialiseExtFolderStepL(); |
|
387 break; |
|
388 #endif //__WINS__ |
355 #endif |
389 #endif |
356 default: |
390 default: |
357 PanicNow(KPanicCmdResourceReader, EInvalidRunLAction); |
391 PanicNow(KPanicCmdResourceReader, EInvalidRunLAction); |
358 break; |
392 break; |
359 } |
393 } |
402 // User::LeaveIfError handles other error conditions |
436 // User::LeaveIfError handles other error conditions |
403 User::LeaveIfError(iFs.GetDir(path, TUidType(KUidResourceFile, TUid::Uid(KUidSsmCommandListResourceFile)), ESortNone, iResourceFileEntries)); |
437 User::LeaveIfError(iFs.GetDir(path, TUidType(KUidResourceFile, TUid::Uid(KUidSsmCommandListResourceFile)), ESortNone, iResourceFileEntries)); |
404 iEntryIndex = iResourceFileEntries->Count(); |
438 iEntryIndex = iResourceFileEntries->Count(); |
405 |
439 |
406 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
440 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
441 #ifdef __WINS__ |
|
442 if(!IsExtendedFolderDisabled()) |
|
443 { |
|
444 TFileName extPath(iPath); |
|
445 extPath.Replace(iPath.Length() - 1, 1, KExtendedCommandListPath); |
|
446 iExtendedPath.CreateL(extPath); |
|
447 DEBUGPRINT2(_L("Extended list path is %S"), &extPath); |
|
448 |
|
449 extPath.Append(KStar); |
|
450 const TInt extErr = (iFs.GetDir(extPath, TUidType(KUidResourceFile, TUid::Uid(KUidSsmCommandListResourceFile)), ESortNone, iExtendedResourceFileEntries)); |
|
451 if (KErrNone == extErr) |
|
452 { |
|
453 iExtendedEntryIndex = iExtendedResourceFileEntries->Count(); |
|
454 DEBUGPRINT2(_L("Number of resource files in extended folder : %d"), iExtendedEntryIndex); |
|
455 } |
|
456 } |
|
457 #endif //__WINS__ |
|
458 |
407 DEBUGPRINT2(_L("Number of resource files in ROM Drive : %d"),iEntryIndex ); |
459 DEBUGPRINT2(_L("Number of resource files in ROM Drive : %d"),iEntryIndex ); |
408 // Now, get list of command list resource filenames from system drive too |
460 // Now, get list of command list resource filenames from system drive too |
409 TFileName sysPath(iSystemDrivePath); |
461 TFileName sysPath(iSystemDrivePath); |
410 sysPath.Append(KStar); |
462 sysPath.Append(KStar); |
411 TInt err = (iFs.GetDir(sysPath, TUidType(KUidResourceFile, TUid::Uid(KUidSsmCommandListResourceFile)), ESortNone, iRssFileEntriesInSysDrive)); |
463 TInt err = (iFs.GetDir(sysPath, TUidType(KUidResourceFile, TUid::Uid(KUidSsmCommandListResourceFile)), ESortNone, iRssFileEntriesInSysDrive)); |
469 CResourceFile* const resourceFile = OpenResourceFileL(filename); |
521 CResourceFile* const resourceFile = OpenResourceFileL(filename); |
470 ParseFileL(resourceFile); |
522 ParseFileL(resourceFile); |
471 } |
523 } |
472 else |
524 else |
473 { |
525 { |
474 // initialisation complete |
526 iAction = EIdle; |
475 iAction = EIdle; |
527 delete iRssFileEntriesInSysDrive; |
476 delete iRssFileEntriesInSysDrive; |
528 iRssFileEntriesInSysDrive = NULL; |
477 iRssFileEntriesInSysDrive = NULL; |
529 |
478 } |
530 #ifdef __WINS__ |
479 } |
531 if(!IsExtendedFolderDisabled()) |
480 #endif |
532 { |
|
533 //Initialise the command list from extended list only if it is enabled |
|
534 iAction = EInitialiseExtFolderStep; |
|
535 } |
|
536 #endif //__WINS__ |
|
537 } |
|
538 } |
|
539 |
|
540 #ifdef __WINS__ |
|
541 void CSsmCommandListResourceReaderImpl::CInitialiser::DoInitialiseExtFolderStepL() |
|
542 { |
|
543 //Append the file names from the extended folder only if it is enabled |
|
544 if (iExtendedEntryIndex--) |
|
545 { |
|
546 TFileName filename(iExtendedPath); |
|
547 filename.Append((*iExtendedResourceFileEntries)[iExtendedEntryIndex].iName); |
|
548 CResourceFile* const resourceFile = OpenResourceFileL(filename); |
|
549 ParseFileL(resourceFile); |
|
550 } |
|
551 else |
|
552 { |
|
553 // initialisation complete |
|
554 iAction = EIdle; |
|
555 delete iExtendedResourceFileEntries; |
|
556 iExtendedResourceFileEntries = NULL; |
|
557 } |
|
558 } |
|
559 #endif //__WINS__ |
|
560 #endif //SYMBIAN_SSM_FLEXIBLE_MERGE |
|
561 |
481 CResourceFile* CSsmCommandListResourceReaderImpl::CInitialiser::OpenResourceFileL(const TDesC& aFileName) |
562 CResourceFile* CSsmCommandListResourceReaderImpl::CInitialiser::OpenResourceFileL(const TDesC& aFileName) |
482 { |
563 { |
483 |
|
484 // open the resource file |
564 // open the resource file |
485 RFile file; |
565 RFile file; |
486 CleanupClosePushL(file); |
566 CleanupClosePushL(file); |
487 User::LeaveIfError(file.Open(iFs, aFileName, EFileRead | EFileShareReadersOnly)); |
567 User::LeaveIfError(file.Open(iFs, aFileName, EFileRead | EFileShareReadersOnly)); |
488 |
568 |
719 { |
799 { |
720 // all command lists are processed. Set the inProgress flag to "EFalse" |
800 // all command lists are processed. Set the inProgress flag to "EFalse" |
721 inProgress = EFalse; |
801 inProgress = EFalse; |
722 break; |
802 break; |
723 } |
803 } |
|
804 else if((iCommandIndexInRssFile[iCurrentCommandListInMapping] == 0)) |
|
805 { |
|
806 //The current commandlist is empty |
|
807 //go to the next commandlist in the mapping. |
|
808 continue; |
|
809 } |
724 else |
810 else |
725 { |
811 { |
726 //open the next resource id and read the commands |
812 //open the next resource id and read the commands |
727 iListReader.Close(); |
813 iListReader.Close(); |
728 iListReader.OpenL(iMappingArray[iCurrentCommandListInMapping].iResourceFile, iMappingArray[iCurrentCommandListInMapping].iResourceId); |
814 iListReader.OpenL(iMappingArray[iCurrentCommandListInMapping].iResourceFile, iMappingArray[iCurrentCommandListInMapping].iResourceId); |
731 iCommandList->SetResourceFileNameL(iResourcePool.FileNameForResourceFileL(iMappingArray[iCurrentCommandListInMapping].iResourceFile)); |
817 iCommandList->SetResourceFileNameL(iResourcePool.FileNameForResourceFileL(iMappingArray[iCurrentCommandListInMapping].iResourceFile)); |
732 //skip reading command count again and jump to command resourceId |
818 //skip reading command count again and jump to command resourceId |
733 iListReader.AdvanceL(sizeof(TUint16)); |
819 iListReader.AdvanceL(sizeof(TUint16)); |
734 } |
820 } |
735 } |
821 } |
736 DEBUGPRINT2A("The value of RssFile's current command is %d ", iCommandIndexInRssFile[iCurrentCommandListInMapping]); |
|
737 #else |
822 #else |
738 while(iCommandIndex && iBatchIndex--) |
823 while(iCommandIndex && iBatchIndex--) |
739 { |
824 { |
740 --iCommandIndex; // Note: can't decrement in while expression above, incase iBatchIndex is zero |
825 --iCommandIndex; // Note: can't decrement in while expression above, incase iBatchIndex is zero |
741 #endif |
826 #endif |
742 // open command resource |
827 // open command resource |
743 const TInt commandResourceId = iListReader.ReadInt32L(); |
828 const TInt commandResourceId = iListReader.ReadInt32L(); |
744 DEBUGPRINT2A("Reading command resource id %x", commandResourceId); |
|
745 RResourceReader commandReader; |
829 RResourceReader commandReader; |
746 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
830 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
747 commandReader.OpenLC(iMappingArray[iCurrentCommandListInMapping].iResourceFile, commandResourceId); |
831 commandReader.OpenLC(iMappingArray[iCurrentCommandListInMapping].iResourceFile, commandResourceId); |
748 #else |
832 #else |
749 commandReader.OpenLC(iMapping.iResourceFile, commandResourceId); |
833 commandReader.OpenLC(iMapping.iResourceFile, commandResourceId); |