327 |
403 |
328 if (iOverrideStore && |
404 if (iOverrideStore && |
329 ((err = iOverrideStore->FindSetting(aId, aSetting)) == KErrNone)) |
405 ((err = iOverrideStore->FindSetting(aId, aSetting)) == KErrNone)) |
330 found = ETrue; |
406 found = ETrue; |
331 if ((err != KErrNone) && (err != KErrNotFound)) |
407 if ((err != KErrNone) && (err != KErrNotFound)) |
332 HCR_LOG_RETURN(err); |
408 HCR_TRACE_RETURN(err); |
333 |
409 |
334 if (!found && |
410 if (!found && |
335 iCoreImgStore && |
411 iCoreImgStore && |
336 ((err = iCoreImgStore->FindSetting(aId, aSetting)) == KErrNone)) |
412 ((err = iCoreImgStore->FindSetting(aId, aSetting)) == KErrNone)) |
337 found = ETrue; |
413 found = ETrue; |
338 if ((err != KErrNone) && (err != KErrNotFound)) |
414 if ((err != KErrNone) && (err != KErrNotFound)) |
339 HCR_LOG_RETURN(err); |
415 HCR_TRACE_RETURN(err); |
340 |
416 |
341 if (!found && |
417 if (!found && |
342 iVariantStore && |
418 iVariantStore && |
343 ((err = iVariantStore->FindSetting(aId, aSetting)) == KErrNone)) |
419 ((err = iVariantStore->FindSetting(aId, aSetting)) == KErrNone)) |
344 found = ETrue; |
420 found = ETrue; |
345 |
421 |
346 if ((err != KErrNone) && (err != KErrNotFound)) |
422 if ((err != KErrNone) && (err != KErrNotFound)) |
347 HCR_LOG_RETURN(err); |
423 HCR_TRACE_RETURN(err); |
348 |
424 |
349 HCR_TRACE3("--- Search results: %d, %d, %x", found, err, aSetting.iSet); |
425 HCR_TRACE3("--- Search results: %d, %d, %x", found, err, aSetting.iSet); |
350 |
426 |
351 if (!found || (aSetting.iSet == 0)) |
427 if (!found || (aSetting.iSet == 0)) |
352 HCR_LOG_RETURN(KErrNotFound); |
428 HCR_TRACE_RETURN(KErrNotFound); |
353 |
429 |
354 // Setting found at this point in the function |
430 // Setting found at this point in the function |
355 // |
431 // |
356 |
432 |
357 TSettingType type=static_cast<TSettingType>(aSetting.iRep->GetType(aSetting)); |
433 TSettingType type=static_cast<TSettingType>(aSetting.iRep->GetType(aSetting)); |
358 if (type & ~aType) |
434 if (type & ~aType) |
359 HCR_LOG_RETURN(KErrArgument); // Wrong setting type |
435 HCR_TRACE_RETURN(KErrArgument); // Wrong setting type |
360 |
436 |
361 HCR_TRACE3("--- Setting found! ID: (%d,%d) Type: %d", aId.iCat, aId.iKey, type); |
437 HCR_TRACE3("--- Setting found! ID: (%d,%d) Type: %d", aId.iCat, aId.iKey, type); |
362 |
438 |
363 return KErrNone; |
439 return KErrNone; |
364 } |
440 } |
365 |
441 |
366 TInt HCR::HCRInternal::FindWordSettings(TInt /*aNum*/, const TSettingId* /*aIds*/, |
442 |
367 TInt32* /*aValues*/, TSettingType* /*aTypes*/, TInt* /*aErrors*/) |
443 TInt HCR::HCRInternal::FindSettingWithType(const TSettingId& aId, TSettingType& aType, |
368 { |
444 TSettingRef& aSetting) |
369 HCR_FUNC("HCRInternal::FindWordSettings"); |
445 { |
370 |
446 HCR_FUNC("HCRInternal::FindSettingWithType"); |
371 return KErrNotSupported; |
447 TInt err = 0; |
372 } |
448 TBool found = EFalse; |
373 |
449 |
|
450 HCR_TRACE3("--- Repository state: %x, %x, %x", iOverrideStore, iCoreImgStore, iVariantStore); |
|
451 |
|
452 if (iOverrideStore && |
|
453 ((err = iOverrideStore->FindSetting(aId, aSetting)) == KErrNone)) |
|
454 found = ETrue; |
|
455 if ((err != KErrNone) && (err != KErrNotFound)) |
|
456 HCR_TRACE_RETURN(err); |
|
457 |
|
458 if (!found && |
|
459 iCoreImgStore && |
|
460 ((err = iCoreImgStore->FindSetting(aId, aSetting)) == KErrNone)) |
|
461 found = ETrue; |
|
462 if ((err != KErrNone) && (err != KErrNotFound)) |
|
463 HCR_TRACE_RETURN(err); |
|
464 |
|
465 if (!found && |
|
466 iVariantStore && |
|
467 ((err = iVariantStore->FindSetting(aId, aSetting)) == KErrNone)) |
|
468 found = ETrue; |
|
469 |
|
470 if ((err != KErrNone) && (err != KErrNotFound)) |
|
471 HCR_TRACE_RETURN(err); |
|
472 |
|
473 HCR_TRACE3("--- Search results: %d, %d, %x", found, err, aSetting.iSet); |
|
474 |
|
475 if (!found || (aSetting.iSet == 0)) |
|
476 { |
|
477 aType = ETypeUndefined; |
|
478 HCR_TRACE_RETURN(KErrNotFound); |
|
479 } |
|
480 |
|
481 // Setting found at this point in the function |
|
482 // |
|
483 |
|
484 aType=static_cast<TSettingType>(aSetting.iRep->GetType(aSetting)); |
|
485 |
|
486 HCR_TRACE3("--- Setting found! ID: (%d,%d) Type: %d", aId.iCat, aId.iKey, aType); |
|
487 |
|
488 return KErrNone; |
|
489 } |
|
490 |
|
491 |
|
492 TInt HCR::HCRInternal::GetWordSettings(TInt aNum, const SSettingId aIds[], |
|
493 TInt32 aValues[], TSettingType aTypes[], TInt aErrors[]) |
|
494 { |
|
495 HCR_FUNC("++ HCRInternal::GetWordSettings"); |
|
496 HCR_TRACE3("--- Repository state: %x, %x, %x", iOverrideStore, iCoreImgStore, iVariantStore); |
|
497 |
|
498 if(aNum <= 0 || aIds == NULL || aErrors == NULL) |
|
499 HCR_TRACE_RETURN(KErrArgument); |
|
500 |
|
501 TInt err = 0; |
|
502 //If the user only supplies a single setting then there is no reasons to |
|
503 //continue with multiple searach and it should be limited by internal |
|
504 //invocation of FindSettingWithType. |
|
505 if(aNum == 1) |
|
506 { |
|
507 TSettingRef sref(0,0); |
|
508 TSettingType* pTypes; |
|
509 |
|
510 //aTypes array is optional and user may not provided it for us. So we |
|
511 //need to be sure it's not a null pointer |
|
512 if(aTypes == NULL) |
|
513 { |
|
514 //If this is a null pointer then just create our own element and |
|
515 //assign it to the pTypes pointer |
|
516 TSettingType types[1]; |
|
517 pTypes = types; |
|
518 } |
|
519 else |
|
520 { |
|
521 //else we use the user supplied array |
|
522 pTypes = aTypes; |
|
523 } |
|
524 |
|
525 //Let's find this setting |
|
526 err = HCRSingleton->FindSettingWithType(aIds[0], *pTypes, sref); |
|
527 |
|
528 //and analyse the result of operation |
|
529 |
|
530 //If setting is not found or it's larger than 4 bytes then store this |
|
531 //error cause in the user error array |
|
532 if(err == KErrNotFound || err == KErrArgument) |
|
533 { |
|
534 //Indicate the error for the element and set the value to 0 |
|
535 aErrors[0] = err; |
|
536 aValues[0] = 0; |
|
537 return 0; |
|
538 } |
|
539 //fatal error here, nothing to do, just exit and return the error code |
|
540 else if(err == KErrNotReady || err != KErrNone) |
|
541 { |
|
542 HCR_TRACE_RETURN(err); |
|
543 } |
|
544 else //err == KErrNone |
|
545 { |
|
546 //Get the value of the setting |
|
547 err = sref.iRep->GetValue(sref, reinterpret_cast<UValueWord&>(aValues[0])); |
|
548 |
|
549 //The GetValue can only return either KErrArgument or KErrNone |
|
550 if(err == KErrArgument) |
|
551 { |
|
552 aErrors[0] = KErrArgument; |
|
553 aValues[0] = 0; |
|
554 return 0; |
|
555 } |
|
556 else //err == KErrNone |
|
557 { |
|
558 aErrors[0] = KErrNone; |
|
559 } |
|
560 |
|
561 } |
|
562 |
|
563 //This single setting was found so indicate it to the user |
|
564 return (1); |
|
565 } |
|
566 |
|
567 |
|
568 //Introducing a SafeArray of pointers to the settings, which is passed to ver- |
|
569 //sion of GetWordSettings() method declared in TRepository, and implemented |
|
570 //in TRepositoryCompiled and TRepositoryFile |
|
571 TSa<SSettingId*> ids; |
|
572 |
|
573 //SafeArray of pointers to the aValues user array elements |
|
574 TSa<TInt32*> values; |
|
575 |
|
576 //SafeArray of pointers to the aErrors user array elements |
|
577 TSa<TInt*> errors; |
|
578 |
|
579 //SafeArray of pointers to the aTypes user array elements |
|
580 TSa<TSettingType*> types; |
|
581 |
|
582 |
|
583 //Local replacement for the aTypes[] array if it's not provided by user |
|
584 TSa<TSettingType> typesHolder; |
|
585 |
|
586 //Allocate the arrays of pointers in the heap |
|
587 ids = new SSettingId*[aNum]; |
|
588 values = new TInt32*[aNum]; |
|
589 errors = new TInt*[aNum]; |
|
590 types = new TSettingType*[aNum]; |
|
591 |
|
592 |
|
593 //Check all arrays allocations |
|
594 if(!ids() || !values() || !errors() || !types()) |
|
595 { |
|
596 //One of the allocation was unsuccessful |
|
597 HCR_TRACE_RETURN(KErrNoMemory); |
|
598 } |
|
599 |
|
600 //If the user did not supply the aTypes array for us we need to create one |
|
601 //for ourself |
|
602 if(aTypes == NULL) |
|
603 { |
|
604 typesHolder = new TSettingType[aNum]; |
|
605 if(!typesHolder()) |
|
606 HCR_TRACE_RETURN(KErrNoMemory); |
|
607 } |
|
608 |
|
609 |
|
610 //Ininialize newly created array of pointers to the user supplied settings |
|
611 for (TInt index = 0; index < aNum; index++) |
|
612 { |
|
613 ids[index] = const_cast<SSettingId*>(&aIds[index]); |
|
614 values[index] = const_cast<TInt32*>(&aValues[index]); |
|
615 errors[index] = &aErrors[index]; |
|
616 |
|
617 if(aTypes == NULL) |
|
618 types[index] = &typesHolder[index]; |
|
619 else |
|
620 types[index] = &aTypes[index]; |
|
621 } |
|
622 |
|
623 |
|
624 //nfCount represents a total number of settings which were not found in all |
|
625 //repositories |
|
626 TInt nfCount = aNum; |
|
627 |
|
628 //nfReposCount represents a number of settings "not found - nf" in the searched |
|
629 //repository |
|
630 TInt nfReposCount = 0; |
|
631 |
|
632 //It represents a number of setting found in the repository |
|
633 TInt reposCount = 0; |
|
634 |
|
635 |
|
636 //First step through the Override store and gather all settings we need. |
|
637 //In the end of this procedure we'll have number of settings not found here |
|
638 //and found settings data are copied to the user arrays. |
|
639 if (iOverrideStore) |
|
640 { |
|
641 |
|
642 //Call the sibling method from the TRepositoryFile object |
|
643 err = iOverrideStore->GetWordSettings(aNum, ids(), |
|
644 values(), types(), errors()); |
|
645 |
|
646 //Analyse the err we've got |
|
647 if(err != KErrNone && err != KErrNotFound) |
|
648 { |
|
649 HCR_TRACE_RETURN(err); |
|
650 } |
|
651 else if(err == KErrNone) |
|
652 { |
|
653 //Search for number of not found parameters |
|
654 for(TInt index = 0; index < aNum; index ++) |
|
655 { |
|
656 switch(*(errors[index])) |
|
657 { |
|
658 //The setting was found or it's found but the type is larger |
|
659 //than 4 bytes then we just increase a counter of the found |
|
660 //settings in the repository |
|
661 case KErrNone: |
|
662 case KErrArgument: |
|
663 reposCount ++; |
|
664 break; |
|
665 |
|
666 |
|
667 //The setting was not found, then re-initialize all the |
|
668 //arrays of pointers with the pointer to this element. |
|
669 //nfReposCount depict the counter of not found element and |
|
670 //index shows the intial element position. |
|
671 //As nfReposCount is always less or equal to index then we |
|
672 //can easily make reassignment as nfReposCoun element was |
|
673 //already analysed. In the end the nfReposCount is increased. |
|
674 case KErrNotFound: |
|
675 ids[nfReposCount] = ids[index]; |
|
676 values[nfReposCount] = values[index]; |
|
677 types[nfReposCount] = types[index]; |
|
678 errors[nfReposCount] = errors[index]; |
|
679 nfReposCount ++; |
|
680 break; |
|
681 |
|
682 |
|
683 default: |
|
684 //No any action is needed |
|
685 break; |
|
686 } |
|
687 } |
|
688 |
|
689 } |
|
690 else //err == KErrNotFound |
|
691 { |
|
692 //No settings were found in the repository |
|
693 //reposCount is zero intialized, so nothing to do here |
|
694 } |
|
695 |
|
696 //Update the global counter only if there are some settings were found, |
|
697 //otherwise it can be situation when we overwrite the nfCount with zero |
|
698 //when either no any setting presents or no settings were found in the |
|
699 //repository |
|
700 if(reposCount > 0) |
|
701 nfCount = nfReposCount; |
|
702 } |
|
703 |
|
704 //Go through core image and search for the rest of settings |
|
705 nfReposCount = 0; |
|
706 reposCount = 0; |
|
707 |
|
708 if (iCoreImgStore && nfCount > 0) |
|
709 { |
|
710 |
|
711 err = iCoreImgStore->GetWordSettings(nfCount, ids(), |
|
712 values(), types(), errors()); |
|
713 |
|
714 if (err != KErrNone && err != KErrNotFound) |
|
715 { |
|
716 HCR_TRACE_RETURN(err); |
|
717 } |
|
718 else if(err == KErrNone) |
|
719 { |
|
720 //Search for number of errors |
|
721 for(TInt index = 0; index < nfCount; index ++) |
|
722 { |
|
723 switch(*(errors[index])) |
|
724 { |
|
725 //The setting was found or it's found but the type is larger |
|
726 //than 4 bytes then we just increase a counter of the found |
|
727 //settings in the repository |
|
728 case KErrNone: |
|
729 case KErrArgument: |
|
730 reposCount ++; |
|
731 break; |
|
732 |
|
733 //The setting was not found, then re-initialize all the |
|
734 //arrays of pointers with the pointer to this element. |
|
735 //nfReposCount depict the counter of not found element and |
|
736 //index shows the intial element position. |
|
737 //As nfReposCount is always less or equal to index then we |
|
738 //can easily make reassignment as nfReposCoun element was |
|
739 //already analysed. In the end the nfReposCount is increased. |
|
740 case KErrNotFound: |
|
741 ids[nfReposCount] = ids[index]; |
|
742 values[nfReposCount] = values[index]; |
|
743 types[nfReposCount] = types[index]; |
|
744 errors[nfReposCount] = errors[index]; |
|
745 nfReposCount ++; |
|
746 break; |
|
747 |
|
748 |
|
749 default: |
|
750 //No any action is needed |
|
751 break; |
|
752 |
|
753 } |
|
754 |
|
755 } |
|
756 |
|
757 } |
|
758 else //err == KErrNotFound |
|
759 { |
|
760 //No settings were found in the repository |
|
761 //reposCount is zero intialized, so nothing to do here |
|
762 } |
|
763 |
|
764 |
|
765 //Update the global counter only if there are some settings were found, |
|
766 //otherwise it can be situation when we overwrite the nfCount with zero |
|
767 //when either no any setting presents or no settings were found in the |
|
768 //repository |
|
769 if(reposCount > 0) |
|
770 nfCount = nfReposCount; |
|
771 } |
|
772 |
|
773 //let's go through the last Variant store |
|
774 nfReposCount = 0; |
|
775 reposCount = 0; |
|
776 if(iVariantStore && nfCount > 0) |
|
777 { |
|
778 err = iVariantStore->GetWordSettings(nfCount, ids(), values(), |
|
779 types(), errors()); |
|
780 |
|
781 if (err != KErrNone && err != KErrNotFound) |
|
782 { |
|
783 HCR_TRACE_RETURN(err); |
|
784 } |
|
785 else if(err == KErrNone) |
|
786 { |
|
787 //Search for number of errors |
|
788 for(TInt index = 0; index < nfCount; index ++) |
|
789 { |
|
790 switch(*(errors[index])) |
|
791 { |
|
792 //The setting was found or it's found but the type is larger |
|
793 //than 4 bytes then we just increase a counter of the found |
|
794 //settings in the repository |
|
795 case KErrNone: |
|
796 case KErrArgument: |
|
797 reposCount ++; |
|
798 break; |
|
799 |
|
800 //The setting was not found, then re-initialize all the |
|
801 //arrays of pointers with the pointer to this element. |
|
802 //nfReposCount depict the counter of not found element and |
|
803 //index shows the intial element position. |
|
804 //As nfReposCount is always less or equal to index then we |
|
805 //can easily make reassignment as nfReposCoun element was |
|
806 //already analysed. In the end the nfReposCount is increased. |
|
807 case KErrNotFound: |
|
808 *values[nfReposCount] = 0; |
|
809 *types[nfReposCount] = ETypeUndefined; |
|
810 *errors[nfReposCount] = KErrNotFound; |
|
811 nfReposCount ++; |
|
812 break; |
|
813 |
|
814 |
|
815 default: |
|
816 //No any action is needed |
|
817 break; |
|
818 |
|
819 } |
|
820 } |
|
821 |
|
822 } |
|
823 else //err == KErrNotFound |
|
824 { |
|
825 //No settings were found in the repository |
|
826 //reposCount is zero intialized, so nothing to do here |
|
827 } |
|
828 |
|
829 //Update the global counter only if there are some settings were found, |
|
830 //otherwise it can be situation when we overwrite the nfCount with zero |
|
831 //when either no any setting presents or no settings were found in the |
|
832 //repository |
|
833 if(reposCount > 0) |
|
834 nfCount = nfReposCount; |
|
835 } |
|
836 //Return the number of found elements |
|
837 return (aNum - nfCount); |
|
838 } |
|
839 |
|
840 |
|
841 |
|
842 |
|
843 |
|
844 TInt HCR::HCRInternal::FindNumSettingsInCategory (TCategoryUid aCatUid) |
|
845 { |
|
846 HCR_FUNC("++ HCRInternal::FindNumSettingsInCategory"); |
|
847 TInt err = 0; |
|
848 |
|
849 HCR_TRACE3("--- Repository state: %x, %x, %x", iOverrideStore, iCoreImgStore, iVariantStore); |
|
850 |
|
851 //First and last element index within category in the Override store |
|
852 TInt32 oLowIndex = 0; |
|
853 TInt32 oHighIndex = 0; |
|
854 TInt oCount = 0; |
|
855 |
|
856 //Find numOverride number of settings within the category in the OverrideStore |
|
857 //repository |
|
858 if(iOverrideStore) |
|
859 { |
|
860 err = iOverrideStore->FindNumSettingsInCategory(aCatUid, |
|
861 oLowIndex, oHighIndex); |
|
862 |
|
863 if(err == KErrNotFound) |
|
864 oCount = 0; |
|
865 else |
|
866 oCount = oHighIndex - oLowIndex + 1; |
|
867 |
|
868 //If CoreImg and Variant store are not activated so just return the |
|
869 //number of elements found in the Override store |
|
870 if(!iCoreImgStore && !iVariantStore) |
|
871 return oCount; |
|
872 } |
|
873 |
|
874 |
|
875 //First and last element index within category in the CoreImg store |
|
876 TInt32 cLowIndex = 0; |
|
877 TInt32 cHighIndex = 0; |
|
878 TInt32 cLength = 0; |
|
879 TInt cCount = 0; |
|
880 |
|
881 |
|
882 |
|
883 //Temproary holder for the found element position |
|
884 TInt32 elementPos; |
|
885 //Temproary holder for the low index, which is used to decrease the scope |
|
886 //of search |
|
887 TInt32 lowIndex = oLowIndex; |
|
888 |
|
889 //Setting data holders |
|
890 SSettingId setId; |
|
891 TSettingRef setRef; |
|
892 |
|
893 if(iCoreImgStore) |
|
894 { |
|
895 //Find numCoreImg number of settings within the category in the CoreImg re- |
|
896 //pository |
|
897 err = iCoreImgStore->FindNumSettingsInCategory(aCatUid, |
|
898 cLowIndex, cHighIndex); |
|
899 |
|
900 if(err == KErrNotFound) |
|
901 cLength = 0; |
|
902 else |
|
903 //Calculate the number of elements within category, in CoreImg store |
|
904 cLength = cHighIndex - cLowIndex + 1; |
|
905 |
|
906 if(oCount > 0) |
|
907 { |
|
908 //Find all elemnts from CoreImg store which are not redefined in the |
|
909 //Override store. When element is not found in the Override store |
|
910 //then cCount is increased. |
|
911 for(TInt element = 0; element < cLength; element ++) |
|
912 { |
|
913 //Find element in the repository by its index |
|
914 iCoreImgStore->GetSettingRef(cLowIndex + element, setRef); |
|
915 //and get its id |
|
916 iCoreImgStore->GetId(setRef, setId); |
|
917 |
|
918 //Check either this element is already redefined in the Override |
|
919 //store |
|
920 err = iOverrideStore->FindSetting( setId, setRef, |
|
921 elementPos, lowIndex, oHighIndex); |
|
922 |
|
923 if(err == KErrNone) |
|
924 { |
|
925 //if the element is found in the Override store, then store the posi- |
|
926 //tion of this element in lowIndex, to narrow next search procedure |
|
927 lowIndex = elementPos; |
|
928 } |
|
929 else if(err == KErrNotFound) |
|
930 { |
|
931 //if element is not found then it means it's not redefined in the |
|
932 //Override store and this element must be counted in the total number |
|
933 //of elemnts in all stores |
|
934 cCount ++; |
|
935 } |
|
936 else |
|
937 { |
|
938 return err; |
|
939 } |
|
940 } |
|
941 } |
|
942 else |
|
943 { |
|
944 cCount = cLength; |
|
945 } |
|
946 |
|
947 |
|
948 |
|
949 //Check if the Variant store is present if it's not then just return the |
|
950 //result |
|
951 if(!iVariantStore) |
|
952 return (oCount + cCount); |
|
953 |
|
954 } |
|
955 |
|
956 //First and last element index within giving category in the Variant store |
|
957 TInt32 vLowIndex = 0; |
|
958 TInt32 vHighIndex = 0; |
|
959 TInt32 vLength = 0; |
|
960 TInt vCount = 0; |
|
961 |
|
962 if(iVariantStore) |
|
963 { |
|
964 //Find numVariant number of settings within the category in the VariantStore |
|
965 //repository |
|
966 err = iVariantStore->FindNumSettingsInCategory(aCatUid, vLowIndex, |
|
967 vHighIndex); |
|
968 |
|
969 //Analyze returned error code |
|
970 |
|
971 if(err == KErrNotFound) |
|
972 vLength = 0; |
|
973 else |
|
974 //Calculate the number of elements within category, in CoreImg store |
|
975 vLength = vHighIndex - vLowIndex + 1; |
|
976 |
|
977 if(oCount == 0 && cCount == 0) |
|
978 { |
|
979 return vLength; |
|
980 } |
|
981 |
|
982 if(oCount > 0 || cCount >0) |
|
983 { |
|
984 //Find all elemnts from Variant store which are not redefined either in the |
|
985 //Override or CoreImg store. These elements are added to the total |
|
986 //count. |
|
987 |
|
988 // Some additional containers. They are needed because we |
|
989 // must check two stores Override and Variant in this iteration. Making a |
|
990 // decision of uniqueness of the element is made from the analyse of both |
|
991 // result. The element is only unique defined in the Variant store if it's |
|
992 // not redefined either in the Override or Variant store |
|
993 TSettingRef tmpRef; |
|
994 //Temproary holder for the found element position |
|
995 TInt32 elementPos2 = 0; |
|
996 //Temproary holder for the low index, which is used to decrease the scope |
|
997 //of search |
|
998 TInt32 lowIndex2 = cLowIndex; |
|
999 // This index contains Override low index and will be changed by the position |
|
1000 // of a new found element |
|
1001 lowIndex= oLowIndex; |
|
1002 |
|
1003 TBool isRedefined = EFalse; |
|
1004 |
|
1005 for(TInt element = 0; element < vLength; element ++) |
|
1006 { |
|
1007 //Find the setting in the repository by its index and |
|
1008 iVariantStore->GetSettingRef(vLowIndex + element, setRef); |
|
1009 //get its id |
|
1010 iVariantStore->GetId(setRef, setId); |
|
1011 |
|
1012 if(oCount > 0) |
|
1013 { |
|
1014 //Check either this element is already redefined in the Override store |
|
1015 err = iOverrideStore->FindSetting(setId, tmpRef, |
|
1016 elementPos, lowIndex, oHighIndex); |
|
1017 |
|
1018 if(err == KErrNone) |
|
1019 { |
|
1020 //if the element is found in the Override store, then store the posi- |
|
1021 //tion of this element in lowIndex, to narrow next search procedure |
|
1022 lowIndex = elementPos; |
|
1023 isRedefined = ETrue; |
|
1024 } |
|
1025 else if(err == KErrNotFound) |
|
1026 { |
|
1027 //the element is not presented in the Override store |
|
1028 //nothing to do here |
|
1029 } |
|
1030 else |
|
1031 { |
|
1032 return err; |
|
1033 } |
|
1034 |
|
1035 } |
|
1036 |
|
1037 |
|
1038 if(cCount > 0 && !isRedefined) |
|
1039 { |
|
1040 //Check either this element is already redefined in the CoreImg store |
|
1041 err = iCoreImgStore->FindSetting(setId, tmpRef, |
|
1042 elementPos2, lowIndex2, cHighIndex); |
|
1043 |
|
1044 |
|
1045 if(err == KErrNone) |
|
1046 { |
|
1047 //if the element is found in the Override store, then store the posi- |
|
1048 //tion of this element in lowIndex, to narrow next search procedure |
|
1049 lowIndex2 = elementPos2; |
|
1050 isRedefined = ETrue; |
|
1051 } |
|
1052 else if(err == KErrNotFound) |
|
1053 { |
|
1054 //the element is not presented in the Override store |
|
1055 //nothing to do here |
|
1056 } |
|
1057 else |
|
1058 { |
|
1059 return err; |
|
1060 } |
|
1061 } |
|
1062 |
|
1063 |
|
1064 if(!isRedefined) |
|
1065 vCount ++; |
|
1066 else |
|
1067 isRedefined = EFalse; |
|
1068 |
|
1069 }//for(TInt element = 0; element < vLength; element ++) |
|
1070 |
|
1071 } |
|
1072 else |
|
1073 { |
|
1074 vCount = vLength; |
|
1075 } |
|
1076 } |
|
1077 |
|
1078 //Return the total number of elements found in the category |
|
1079 return (oCount + cCount + vCount); |
|
1080 } |
|
1081 |
|
1082 |
|
1083 |
|
1084 |
|
1085 TInt HCR::HCRInternal::FindSettings(TCategoryUid aCatUid, |
|
1086 TInt aMaxNum, TElementId aIds[], |
|
1087 TSettingType aTypes[], TUint16 aLens[]) |
|
1088 { |
|
1089 HCR_FUNC("++ HCRInternal::FindSettings w/o patterns"); |
|
1090 |
|
1091 HCR_TRACE3("--- Repository state: %x, %x, %x", iOverrideStore, |
|
1092 iCoreImgStore, iVariantStore); |
|
1093 |
|
1094 //Error container |
|
1095 TInt err = KErrNone; |
|
1096 |
|
1097 //Total number of found elements |
|
1098 TInt numFound = 0; |
|
1099 //Number of found elements in the Override store |
|
1100 TInt oNumFound = 0; |
|
1101 |
|
1102 //Low and High indexes in the Override store |
|
1103 TInt32 oLoIndex = 0; |
|
1104 TInt32 oHiIndex = 0; |
|
1105 |
|
1106 //Temproary holder for the found element position |
|
1107 TInt32 elementPos = 0; |
|
1108 TInt32 lowIndex = 0; |
|
1109 |
|
1110 |
|
1111 //Tempoary type and length value holders if the |
|
1112 //user does not provide these arrays for us |
|
1113 TSettingType tmpType; |
|
1114 TUint16 tmpLen; |
|
1115 |
|
1116 |
|
1117 //Setting datat holders |
|
1118 TSettingRef setRef; |
|
1119 TSettingId setId; |
|
1120 |
|
1121 |
|
1122 //Find number of elements, low and hingh index in the Override store |
|
1123 if(iOverrideStore) |
|
1124 { |
|
1125 err = iOverrideStore->FindNumSettingsInCategory(aCatUid, oLoIndex, |
|
1126 oHiIndex); |
|
1127 if(err == KErrNone) |
|
1128 { |
|
1129 //If number of elements in the Override Store is larger than aMaxNum or |
|
1130 //CoreImage/Variant stores are not present then write all found |
|
1131 //settings into the user array, return the number of found elements and |
|
1132 //exit |
|
1133 oNumFound = (oHiIndex - oLoIndex + 1); |
|
1134 lowIndex = oLoIndex; |
|
1135 |
|
1136 if(oNumFound < aMaxNum) |
|
1137 { |
|
1138 for(TInt index = 0; index < oNumFound; index ++) |
|
1139 { |
|
1140 //Get setting reference data from the repository |
|
1141 iOverrideStore->GetSettingRef(oLoIndex + index, setRef); |
|
1142 |
|
1143 //Copy the settings data into the user arrays |
|
1144 iOverrideStore->GetSettingInfo(setRef, |
|
1145 aIds[index], |
|
1146 aTypes ? aTypes[index]:tmpType, |
|
1147 aLens ? aLens[index]:tmpLen); |
|
1148 |
|
1149 |
|
1150 } |
|
1151 } |
|
1152 else //oNumFound >= aMaxNum |
|
1153 { |
|
1154 //Copy data to the user array |
|
1155 for(TInt index = 0; index < aMaxNum; index++) |
|
1156 { |
|
1157 //Get setting reference data from the repository |
|
1158 iOverrideStore->GetSettingRef(oLoIndex + index, setRef); |
|
1159 //Copy the settings data into the user arrays |
|
1160 iOverrideStore->GetSettingInfo(setRef, |
|
1161 aIds[index], |
|
1162 aTypes ? aTypes[index]:tmpType, |
|
1163 aLens ? aLens[index]:tmpLen); |
|
1164 |
|
1165 } |
|
1166 return oNumFound; |
|
1167 } |
|
1168 } |
|
1169 else if(err == KErrNotFound) |
|
1170 { |
|
1171 //Nothing to do here, oNumFound is set to zero already |
|
1172 } |
|
1173 else |
|
1174 { |
|
1175 return err; |
|
1176 } |
|
1177 } |
|
1178 |
|
1179 |
|
1180 //Low/High index in the CoreImg |
|
1181 TInt32 cLoIndex = 0; |
|
1182 TInt32 cHiIndex = 0; |
|
1183 TInt cNumFound = 0; |
|
1184 |
|
1185 //Temproary setting reference holder |
|
1186 TSettingRef tmpRef; |
|
1187 |
|
1188 //Temproary holder for the found element position |
|
1189 elementPos = 0; |
|
1190 lowIndex = oLoIndex; |
|
1191 |
|
1192 //Redefined status flag, it's used to flag that the element is found in the |
|
1193 //upper stores |
|
1194 TBool isRedefined = EFalse; |
|
1195 |
|
1196 //User array index |
|
1197 TInt usrArrIndx = 0; |
|
1198 |
|
1199 //If the count is still less than aMaxNum then continue with searching |
|
1200 //settings in the CoreImage store |
|
1201 if(iCoreImgStore) |
|
1202 { |
|
1203 |
|
1204 //Find number of elements and low/high indexes |
|
1205 err = iCoreImgStore->FindNumSettingsInCategory(aCatUid, cLoIndex, |
|
1206 cHiIndex); |
|
1207 |
|
1208 if(err == KErrNone) |
|
1209 { |
|
1210 for(TInt index = 0; index < (cHiIndex - cLoIndex + 1); index ++) |
|
1211 { |
|
1212 //Get the setting data by its index in the repository |
|
1213 iCoreImgStore->GetSettingRef(cLoIndex + index, setRef); |
|
1214 //get setting id |
|
1215 iCoreImgStore->GetId(setRef, setId); |
|
1216 |
|
1217 if(oNumFound > 0) |
|
1218 { |
|
1219 //Check either this element is already redefined in the |
|
1220 err = iOverrideStore->FindSetting(setId, tmpRef, |
|
1221 elementPos, lowIndex, oHiIndex); |
|
1222 |
|
1223 |
|
1224 if(err == KErrNone) |
|
1225 { |
|
1226 lowIndex = elementPos + 1; |
|
1227 isRedefined = ETrue; |
|
1228 } |
|
1229 else if (err == KErrNotFound) |
|
1230 { |
|
1231 //Nothing to do hear, isRedefined flag is EFalse |
|
1232 //all analysis is done later in the code |
|
1233 } |
|
1234 else |
|
1235 { |
|
1236 return err; |
|
1237 } |
|
1238 } |
|
1239 |
|
1240 //Examine the redefined status flag |
|
1241 if(!isRedefined) |
|
1242 { |
|
1243 // If the element was not found then we need to copy to |
|
1244 // the pA array and increase the counter of setting data |
|
1245 // only if we did not reach the aMaxNum of found elements |
|
1246 |
|
1247 usrArrIndx = oNumFound + cNumFound; |
|
1248 if(usrArrIndx < aMaxNum) |
|
1249 { |
|
1250 //Copy the settings data into the user arrays |
|
1251 iCoreImgStore->GetSettingInfo(setRef, |
|
1252 aIds[usrArrIndx], |
|
1253 aTypes ? aTypes[usrArrIndx]:tmpType, |
|
1254 aLens ? aLens[usrArrIndx]:tmpLen); |
|
1255 cNumFound ++; |
|
1256 } |
|
1257 else |
|
1258 { |
|
1259 //All required elements were found! |
|
1260 //As vNumFound was used an index so it's value it runs |
|
1261 //from 0 to X-1, where X - number of found elements. To |
|
1262 //get number of elements found we need increase the last |
|
1263 //counter value by 1. |
|
1264 if(cNumFound != 0) |
|
1265 cNumFound ++; |
|
1266 //It reaches the goal, all required elements are found |
|
1267 //stop here and return the result |
|
1268 break; |
|
1269 } |
|
1270 } |
|
1271 else |
|
1272 //Element is found in other repositories, just reset a flag |
|
1273 isRedefined = EFalse; |
|
1274 } |
|
1275 } |
|
1276 else if (err == KErrNotFound) |
|
1277 { |
|
1278 //cNumFound is already set to zero during the initialization |
|
1279 //Nothing to do here |
|
1280 } |
|
1281 else //any other errors |
|
1282 { |
|
1283 return err; |
|
1284 } |
|
1285 } |
|
1286 |
|
1287 |
|
1288 //Low/High index in the CoreImg |
|
1289 TInt32 vLoIndex = 0; |
|
1290 TInt32 vHiIndex = 0; |
|
1291 TInt vNumFound = 0; |
|
1292 |
|
1293 //Temproary holder for the found element position |
|
1294 TInt32 elementPos2 = 0; |
|
1295 |
|
1296 TInt32 lowIndex2 = cLoIndex; |
|
1297 lowIndex = oLoIndex; |
|
1298 |
|
1299 isRedefined = EFalse; |
|
1300 |
|
1301 |
|
1302 //If the count is still less than aMaxNum then continue with searching |
|
1303 //settings in the CoreImage store |
|
1304 if(iVariantStore) |
|
1305 { |
|
1306 |
|
1307 //Find number of elements and low/high indexes |
|
1308 err = iVariantStore->FindNumSettingsInCategory(aCatUid, vLoIndex, |
|
1309 vHiIndex); |
|
1310 if(err == KErrNone) |
|
1311 { |
|
1312 |
|
1313 for(TInt index = 0; index < (vHiIndex - vLoIndex + 1); index ++) |
|
1314 { |
|
1315 //Get setting reference data by its index in the repository |
|
1316 iVariantStore->GetSettingRef(vLoIndex + index, setRef); |
|
1317 |
|
1318 //and get setting id |
|
1319 iVariantStore->GetId(setRef, setId); |
|
1320 |
|
1321 if(oNumFound > 0) |
|
1322 { |
|
1323 //Check either this element is already redefined in the |
|
1324 err = iOverrideStore->FindSetting(setId, tmpRef, elementPos, |
|
1325 lowIndex, oHiIndex); |
|
1326 |
|
1327 |
|
1328 //Also suppress the error checking due the reason described |
|
1329 //above |
|
1330 if(err == KErrNone) |
|
1331 { |
|
1332 lowIndex = elementPos + 1; |
|
1333 isRedefined = ETrue; |
|
1334 } |
|
1335 else if (err == KErrNotFound) |
|
1336 { |
|
1337 //Element is not found, nothing to proceed here |
|
1338 } |
|
1339 else |
|
1340 { |
|
1341 return err; |
|
1342 } |
|
1343 } |
|
1344 |
|
1345 if(cNumFound > 0 && !isRedefined) |
|
1346 { |
|
1347 //Check either this element is already redefined in the |
|
1348 err = iCoreImgStore->FindSetting(setId, tmpRef, elementPos2, |
|
1349 lowIndex2, cHiIndex); |
|
1350 |
|
1351 if(err == KErrNone) |
|
1352 { |
|
1353 lowIndex2 = elementPos2 + 1; |
|
1354 isRedefined = ETrue; |
|
1355 } |
|
1356 else if (err == KErrNotFound) |
|
1357 { |
|
1358 //Element is not found, nothing to proceed here |
|
1359 } |
|
1360 else |
|
1361 { |
|
1362 return err; |
|
1363 } |
|
1364 } |
|
1365 |
|
1366 if(!isRedefined) |
|
1367 { |
|
1368 usrArrIndx = oNumFound + cNumFound + vNumFound; |
|
1369 if(usrArrIndx < aMaxNum) |
|
1370 { |
|
1371 //Copy the settings data into the user arrays |
|
1372 iVariantStore->GetSettingInfo(setRef, |
|
1373 aIds[usrArrIndx], |
|
1374 aTypes ? aTypes[usrArrIndx]:tmpType, |
|
1375 aLens ? aLens[usrArrIndx]:tmpLen); |
|
1376 |
|
1377 vNumFound ++; |
|
1378 } |
|
1379 else |
|
1380 { |
|
1381 //All required elements were found! |
|
1382 //As vNumFound was used an index so it's value it runs |
|
1383 //from 0 to X-1, where X - number of found elements. To |
|
1384 //get number of elements found we need increase the last |
|
1385 //counter value by 1. |
|
1386 if(vNumFound != 0) |
|
1387 vNumFound ++; |
|
1388 //It reaches the goal, all required elements are found |
|
1389 //stop here and return the result |
|
1390 break; |
|
1391 } |
|
1392 } |
|
1393 else |
|
1394 { |
|
1395 isRedefined = EFalse; |
|
1396 } |
|
1397 } |
|
1398 } |
|
1399 else if (err == KErrNotFound) |
|
1400 { |
|
1401 //oNumFound is already set to zero during the initialization |
|
1402 //Nothing to do here |
|
1403 } |
|
1404 else |
|
1405 { |
|
1406 return err; |
|
1407 } |
|
1408 |
|
1409 } |
|
1410 |
|
1411 //Let's prepare the final data |
|
1412 numFound = oNumFound + cNumFound + vNumFound; |
|
1413 |
|
1414 //Return result to the user |
|
1415 return numFound; |
|
1416 } |
|
1417 |
|
1418 |
|
1419 |
|
1420 |
|
1421 |
|
1422 |
|
1423 |
|
1424 TInt HCR::HCRInternal::FindSettings(TCategoryUid aCat, TInt aMaxNum, |
|
1425 TUint32 aMask, TUint32 aPattern, |
|
1426 TElementId aIds[], TSettingType aTypes[], TUint16 aLens[]) |
|
1427 { |
|
1428 //Holder for errors and number of elements |
|
1429 TInt r = KErrNone; |
|
1430 //Total number of elements within the given category |
|
1431 TInt allInCatFound = 0; |
|
1432 //Number of elements which corresponds to the aMask and aPattern |
|
1433 TInt numFound = 0; |
|
1434 |
|
1435 //Find the number of elements within the category |
|
1436 r = FindNumSettingsInCategory(aCat); |
|
1437 |
|
1438 //Analyse the returned error |
|
1439 //if r < 0 - this is an error return to the user |
|
1440 //if r > 0 - number of found settings |
|
1441 if(r < 0) |
|
1442 { |
|
1443 HCR_TRACE_RETURN(r); |
|
1444 } |
|
1445 else if (r == 0) |
|
1446 //No any elements found for this category |
|
1447 return 0; |
|
1448 else |
|
1449 allInCatFound = r; |
|
1450 |
|
1451 //Result data array holder |
|
1452 TSa<TElementId> pIds; |
|
1453 TSa<TSettingType> pTypes; |
|
1454 TSa<TUint16> pLens; |
|
1455 |
|
1456 pIds = new TElementId[allInCatFound]; |
|
1457 pTypes = new TSettingType[allInCatFound]; |
|
1458 pLens = new TUint16[allInCatFound]; |
|
1459 |
|
1460 if(pIds() == NULL || pTypes() == NULL || pLens() == NULL) |
|
1461 //One of the allocation was unsuccessful |
|
1462 HCR_TRACE_RETURN(KErrNoMemory); |
|
1463 |
|
1464 r = FindSettings(aCat, allInCatFound, pIds(), pTypes(), pLens()); |
|
1465 |
|
1466 //Exit if we've got negative result just report error |
|
1467 if(r < 0) |
|
1468 HCR_TRACE_RETURN(r); |
|
1469 |
|
1470 //Somehow we'got less elements than it must be!!! |
|
1471 __NK_ASSERT_DEBUG(r == allInCatFound); |
|
1472 if(r < allInCatFound) |
|
1473 HCR_TRACE_RETURN(KErrGeneral); |
|
1474 |
|
1475 |
|
1476 //Choose the elements which satisfy this condition |
|
1477 //((elementID & aElementMask) == (aPattern & aElementMask)). The total num- |
|
1478 //ber of returned elements should not exceed the aMaxNum |
|
1479 for(TInt index = 0; index < allInCatFound; index++) |
|
1480 { |
|
1481 if(((pIds[index] & aMask) == (aPattern & aMask))) |
|
1482 { |
|
1483 aIds[numFound] = pIds[index]; |
|
1484 |
|
1485 if(aTypes) |
|
1486 aTypes[numFound] = pTypes[index]; |
|
1487 |
|
1488 if(aLens) |
|
1489 aLens[numFound] = pLens[index]; |
|
1490 |
|
1491 numFound ++; |
|
1492 } |
|
1493 else |
|
1494 continue; |
|
1495 |
|
1496 //Check either we already found or not enough elements |
|
1497 //If we did then break the loop |
|
1498 if(numFound == aMaxNum) |
|
1499 break; |
|
1500 } |
|
1501 |
|
1502 return numFound; |
|
1503 } |
374 |
1504 |
375 |
1505 |
376 // -- METHODS ----------------------------------------------------------------- |
1506 // -- METHODS ----------------------------------------------------------------- |
377 // |
1507 // |
378 // TRepository |
1508 // TRepository |
379 |
1509 |
|
1510 HCR::TRepository::~TRepository() |
|
1511 { |
|
1512 HCR_FUNC("~TRepository"); |
|
1513 } |
380 |
1514 |
381 TBool HCR::TRepository::IsWordValue(const TSettingRef& aRef) |
1515 TBool HCR::TRepository::IsWordValue(const TSettingRef& aRef) |
382 { |
1516 { |
383 HCR_FUNC("TRepository::IsWordValue"); |
1517 HCR_FUNC("TRepository::IsWordValue"); |
384 return ((aRef.iSet->iType & KMaskWordTypes) != 0); |
1518 return ((aRef.iSet->iType & KMaskWordTypes) != 0); |
507 |
1655 |
508 aSetting.iRep = 0; |
1656 aSetting.iRep = 0; |
509 aSetting.iSet = 0; |
1657 aSetting.iSet = 0; |
510 return KErrNotFound; |
1658 return KErrNotFound; |
511 } |
1659 } |
512 |
1660 |
|
1661 |
|
1662 |
|
1663 |
|
1664 TInt HCR::TRepositoryCompiled::FindSetting(const TSettingId& aId, |
|
1665 TSettingRef& aSetting, TInt32& aPosition, TInt32 aLow, TInt32 aHigh) |
|
1666 { |
|
1667 HCR_FUNC("TRepositoryCompiled::FindSetting within the given range"); |
|
1668 |
|
1669 |
|
1670 __NK_ASSERT_DEBUG(iRepos != 0); |
|
1671 __NK_ASSERT_DEBUG(iRepos->iHdr != 0); |
|
1672 |
|
1673 if ((iRepos->iHdr->iNumSettings == 0) || |
|
1674 (iRepos->iOrderedSettingList == 0)) |
|
1675 HCR_TRACE_RETURN(KErrNotFound); |
|
1676 |
|
1677 SSettingC* arr = iRepos->iOrderedSettingList; |
|
1678 TInt32 low = aLow; |
|
1679 TInt32 high = aHigh; |
|
1680 TInt32 mid; |
|
1681 TInt32 com; |
|
1682 |
|
1683 while (low<=high) |
|
1684 { |
|
1685 mid = (low+high) >> 1; |
|
1686 com = CompareSSettingIds(aId, arr[mid].iName.iId); |
|
1687 if (com < 0) |
|
1688 high = mid-1; |
|
1689 else if (com > 0) |
|
1690 low = mid+1; |
|
1691 else |
|
1692 { |
|
1693 aSetting.iRep = this; |
|
1694 aSetting.iSet = &((arr[mid]).iName); |
|
1695 aPosition = mid; |
|
1696 return KErrNone; |
|
1697 } |
|
1698 } |
|
1699 |
|
1700 aSetting.iRep = 0; |
|
1701 aSetting.iSet = 0; |
|
1702 aPosition = 0; |
|
1703 return KErrNotFound; |
|
1704 } |
|
1705 |
|
1706 |
|
1707 |
|
1708 TInt HCR::TRepositoryCompiled::GetWordSettings(TInt aNum, |
|
1709 SSettingId* aIds[], TInt32* aValues[], TSettingType* aTypes[], |
|
1710 TInt* aErrors[]) |
|
1711 { |
|
1712 HCR_FUNC("TRepositoryCompiled::GetWordSettings"); |
|
1713 |
|
1714 __NK_ASSERT_DEBUG(iRepos != 0); |
|
1715 __NK_ASSERT_DEBUG(iRepos->iHdr != 0); |
|
1716 |
|
1717 if ((iRepos->iHdr->iNumSettings == 0) || |
|
1718 (iRepos->iOrderedSettingList == 0)) |
|
1719 HCR_TRACE_RETURN(KErrNotFound); |
|
1720 |
|
1721 TInt err = KErrNone; |
|
1722 |
|
1723 TInt32 rMaxIndex = 0; |
|
1724 TInt32 rMinIndex = 0; |
|
1725 TInt32 uFirstIndex = 0; |
|
1726 TInt32 uLastIndex = 0; |
|
1727 TInt32 rIndex = 0; |
|
1728 TInt32 uIndex = 0; |
|
1729 |
|
1730 TSettingRef settingRef(NULL, NULL); |
|
1731 SSettingC* pSetting = NULL; |
|
1732 |
|
1733 |
|
1734 //Find position index within the repository for the first and last setting |
|
1735 //from user supplied array aIds[] |
|
1736 uIndex = 0; |
|
1737 TBool isRedefined = EFalse; |
|
1738 err = KErrNotFound; |
|
1739 uFirstIndex = 0; |
|
1740 while(!isRedefined && uIndex < aNum) |
|
1741 { |
|
1742 //Find first setting from user array. The importance here is that we |
|
1743 //should get value of first setting index in the repository in rMinIndex. |
|
1744 //This time the scope of search is whole repository. |
|
1745 err = this->FindSetting(*aIds[uIndex],settingRef, rMinIndex, |
|
1746 0, iRepos->iHdr->iNumSettings); |
|
1747 if(err == KErrNotFound) |
|
1748 { |
|
1749 *aErrors[uIndex] = err; |
|
1750 *aValues[uIndex] = 0; |
|
1751 //Copy type only if user provided aTypes array |
|
1752 if(aTypes) |
|
1753 *aTypes[uIndex] = ETypeUndefined; |
|
1754 |
|
1755 //As FindSetting did not find the element, let's challenge with |
|
1756 //the next one from aIds[] array |
|
1757 uIndex ++; |
|
1758 continue; |
|
1759 } |
|
1760 //fatal error here, nothing to do, just exit and return the error code |
|
1761 else if(err == KErrNotReady || err != KErrNone) |
|
1762 { |
|
1763 return err; |
|
1764 } |
|
1765 else // err == KErrNone |
|
1766 { |
|
1767 //Get the value and type |
|
1768 pSetting = (SSettingC*) settingRef.iSet; |
|
1769 //again copy the type value into the user array if it's provided |
|
1770 if(aTypes) |
|
1771 *aTypes[uIndex] = static_cast<TSettingType>(settingRef.iSet->iType); |
|
1772 |
|
1773 //Check for the found type is this word size? If it's not then |
|
1774 //indicate error for this setting |
|
1775 if(*aTypes[uIndex] > ETypeLinAddr) |
|
1776 { |
|
1777 *aErrors[uIndex] = KErrArgument; |
|
1778 *aValues[uIndex] = 0; |
|
1779 } |
|
1780 else |
|
1781 { |
|
1782 *aErrors[uIndex] = KErrNone; |
|
1783 *aValues[uIndex] = pSetting->iValue.iLit.iInt32; |
|
1784 } |
|
1785 |
|
1786 //Break the loop by setting the redefined status |
|
1787 isRedefined = ETrue; |
|
1788 } |
|
1789 } |
|
1790 |
|
1791 //At this point we should find at least one element from the user array, |
|
1792 //store this index in the local variable, it is used later in the code. |
|
1793 //Please be noticed we've also got rMinIndex - first setting index in the |
|
1794 //repository. |
|
1795 if(err == KErrNone) |
|
1796 uFirstIndex = uIndex; |
|
1797 //if we did not find any elements at all just return KErrNotFound |
|
1798 else |
|
1799 return KErrNotFound; |
|
1800 |
|
1801 |
|
1802 |
|
1803 //Now lets find the last setting |
|
1804 uIndex = aNum - 1; |
|
1805 isRedefined = EFalse; |
|
1806 err = KErrNotFound; |
|
1807 while(!isRedefined && uIndex > uFirstIndex) |
|
1808 { |
|
1809 //Find the last setting from user array. The importance here is that we |
|
1810 //should get value of first setting index in the repository in |
|
1811 //rMinIndex. This time the scope of search is whole repository. |
|
1812 err = this->FindSetting(*aIds[uIndex],settingRef, rMaxIndex, |
|
1813 rMinIndex, iRepos->iHdr->iNumSettings); |
|
1814 if(err == KErrNotFound) |
|
1815 { |
|
1816 *aErrors[uIndex] = err; |
|
1817 *aValues[uIndex] = 0; |
|
1818 if(aTypes) |
|
1819 *aTypes[uIndex] = ETypeUndefined; |
|
1820 |
|
1821 //As FindSetting did not find the element, let's challenge with |
|
1822 //previous one, as we are moving in reverse direction |
|
1823 uIndex --; |
|
1824 continue; |
|
1825 } |
|
1826 //fatal error here, nothing to do, just exit and return the error code |
|
1827 else if(err == KErrNotReady || err != KErrNone) |
|
1828 { |
|
1829 return err; |
|
1830 } |
|
1831 else //err == KErrNone |
|
1832 { |
|
1833 pSetting = (SSettingC*) settingRef.iSet; |
|
1834 if(aTypes) |
|
1835 *aTypes[uIndex] = static_cast<TSettingType>(settingRef.iSet->iType); |
|
1836 |
|
1837 //Check for the found type is this word size? If it's not then indicate |
|
1838 //error for this setting |
|
1839 if(*aTypes[uIndex] > ETypeLinAddr) |
|
1840 { |
|
1841 *aErrors[uIndex] = KErrArgument; |
|
1842 *aValues[uIndex] = 0; |
|
1843 } |
|
1844 else |
|
1845 { |
|
1846 *aErrors[uIndex] = KErrNone; |
|
1847 *aValues[uIndex] = pSetting->iValue.iLit.iInt32; |
|
1848 } |
|
1849 |
|
1850 isRedefined = ETrue; |
|
1851 } |
|
1852 } |
|
1853 |
|
1854 //At this point we found the last setting, store it's user array index in |
|
1855 //the local variable, it is used later in the code. Please be noticed |
|
1856 //we've also got rMaxIndex - last setting index in the repository. |
|
1857 if(err == KErrNone) |
|
1858 uLastIndex = uIndex; |
|
1859 else |
|
1860 //if we are here we did not find any other elements than was found |
|
1861 //in previous iteration then just stop here |
|
1862 return KErrNotFound; |
|
1863 |
|
1864 //The scope of user array settings in the repository is found. |
|
1865 //Let's find all other settings from user array. Bare in mind the low |
|
1866 //bound for the repository index is increased each iteration to optimize the |
|
1867 //search time. |
|
1868 for(uIndex = uFirstIndex + 1; uIndex < uLastIndex; uIndex ++) |
|
1869 { |
|
1870 err = this->FindSetting(*aIds[uIndex],settingRef, rIndex, |
|
1871 rMinIndex, rMaxIndex); |
|
1872 if(err == KErrNotFound) |
|
1873 { |
|
1874 *aErrors[uIndex] = err; |
|
1875 *aValues[uIndex] = 0; |
|
1876 if(aTypes) |
|
1877 *aTypes[uIndex] = ETypeUndefined; |
|
1878 |
|
1879 //As FindSetting did not find the element, let's challenge with |
|
1880 //another one |
|
1881 continue; |
|
1882 } |
|
1883 else if(err == KErrNotReady || err != KErrNone) |
|
1884 { |
|
1885 return err; |
|
1886 } |
|
1887 else //err == KErrNone |
|
1888 { |
|
1889 |
|
1890 pSetting = (SSettingC*) settingRef.iSet; |
|
1891 if(aTypes) |
|
1892 *aTypes[uIndex] = static_cast<TSettingType>(settingRef.iSet->iType); |
|
1893 |
|
1894 //Check for the found type is this word size? If it's not then indicate |
|
1895 //error for this setting |
|
1896 if(*aTypes[uIndex] > ETypeLinAddr) |
|
1897 { |
|
1898 *aErrors[uIndex] = KErrArgument; |
|
1899 *aValues[uIndex] = 0; |
|
1900 } |
|
1901 else |
|
1902 { |
|
1903 *aErrors[uIndex] = KErrNone; |
|
1904 *aValues[uIndex] = pSetting->iValue.iLit.iInt32; |
|
1905 } |
|
1906 |
|
1907 rMinIndex = rIndex + 1; |
|
1908 |
|
1909 } |
|
1910 |
|
1911 } |
|
1912 |
|
1913 return KErrNone; |
|
1914 } |
|
1915 |
|
1916 |
|
1917 |
|
1918 |
|
1919 |
|
1920 TInt HCR::TRepositoryCompiled::FindNumSettingsInCategory(TCategoryUid aCatUid, |
|
1921 TInt32& aFirst, TInt32& aLast) |
|
1922 { |
|
1923 HCR_FUNC("TRepositoryCompiled::FindNumSettingsInCategory"); |
|
1924 |
|
1925 __NK_ASSERT_DEBUG(iRepos != 0); |
|
1926 __NK_ASSERT_DEBUG(iRepos->iHdr != 0); |
|
1927 |
|
1928 if ((iRepos->iHdr->iNumSettings == 0) || (iRepos->iOrderedSettingList == 0)) |
|
1929 HCR_TRACE_RETURN(KErrNotFound); |
|
1930 |
|
1931 SSettingC* arr = iRepos->iOrderedSettingList; |
|
1932 int low = 0; |
|
1933 int high = iRepos->iHdr->iNumSettings-1; |
|
1934 int mid = 0; |
|
1935 int com = 0; |
|
1936 |
|
1937 //Let's find any setting within the category, mid will store the setting |
|
1938 //index in the repository |
|
1939 while (low<=high) |
|
1940 { |
|
1941 mid = (low+high) >> 1; |
|
1942 com = CompareByCategory(aCatUid, arr[mid].iName.iId); |
|
1943 if (com < 0) |
|
1944 high = mid-1; |
|
1945 else if (com > 0) |
|
1946 low = mid+1; |
|
1947 else |
|
1948 { |
|
1949 break; |
|
1950 } |
|
1951 } |
|
1952 |
|
1953 // If no one setting with the given category was found the return error |
|
1954 // to the user |
|
1955 if(low > high) |
|
1956 { |
|
1957 aFirst = 0; |
|
1958 aLast = 0; |
|
1959 return KErrNotFound; |
|
1960 } |
|
1961 |
|
1962 //Search the first element within the category |
|
1963 low = mid; |
|
1964 while(low > 0 && arr[low].iName.iId.iCat == aCatUid) |
|
1965 { |
|
1966 low --; |
|
1967 } |
|
1968 //Check the boundary conditions, there are two cases when we exit the loop |
|
1969 //either we found an element which category is not one we are looking for or |
|
1970 //we reach the beggining of the repository. If we reach the beggining of the |
|
1971 //repository we don't really know is it because this is last elment or it |
|
1972 //has required aCatUid, so we check these two conditions below |
|
1973 if(low == 0 && arr[low].iName.iId.iCat == aCatUid) |
|
1974 aFirst = low; |
|
1975 //We finish the loop either reaching the setting which category id is not |
|
1976 //what we need or this is first setting in the repository again with another |
|
1977 //category, so in both case we throw this element from the account. |
|
1978 else |
|
1979 aFirst = low + 1; |
|
1980 |
|
1981 //Search the last element within the category |
|
1982 high = mid; |
|
1983 while(high < iRepos->iHdr->iNumSettings && arr[high].iName.iId.iCat == aCatUid) |
|
1984 { |
|
1985 high ++; |
|
1986 } |
|
1987 |
|
1988 //Same situation as above, boundary conditions |
|
1989 if(high == (iRepos->iHdr->iNumSettings -1) && arr[high].iName.iId.iCat == aCatUid) |
|
1990 aLast = high; |
|
1991 else |
|
1992 aLast = high -1; |
|
1993 |
|
1994 |
|
1995 return KErrNone; |
|
1996 } |
|
1997 |
|
1998 |
|
1999 |
|
2000 void HCR::TRepositoryCompiled::GetSettingRef(TInt32 aIndex, |
|
2001 HCR::TSettingRef& aRef) |
|
2002 { |
|
2003 __NK_ASSERT_DEBUG(iRepos != 0); |
|
2004 __NK_ASSERT_DEBUG(iRepos->iHdr != 0); |
|
2005 __NK_ASSERT_DEBUG(aIndex >=0 && aIndex < iRepos->iHdr->iNumSettings); |
|
2006 |
|
2007 if ((iRepos->iHdr->iNumSettings == 0) || (iRepos->iOrderedSettingList == 0)) |
|
2008 { |
|
2009 aRef.iRep = NULL; |
|
2010 aRef.iSet = NULL; |
|
2011 } |
|
2012 |
|
2013 //Get the pointer to the repository data |
|
2014 SSettingC* arr = iRepos->iOrderedSettingList; |
|
2015 |
|
2016 aRef.iRep = this; |
|
2017 aRef.iSet = &(arr[aIndex].iName); |
|
2018 } |
|
2019 |
|
2020 |
513 TInt HCR::TRepositoryCompiled::GetValue(const TSettingRef& aRef, UValueWord& aValue) |
2021 TInt HCR::TRepositoryCompiled::GetValue(const TSettingRef& aRef, UValueWord& aValue) |
514 { |
2022 { |
515 HCR_FUNC("TRepositoryCompiled::GetValue"); |
2023 HCR_FUNC("TRepositoryCompiled::GetValue"); |
516 if (!IsWordValue(aRef)) |
2024 if (!IsWordValue(aRef)) |
517 HCR_LOG_RETURN(KErrArgument); |
2025 HCR_TRACE_RETURN(KErrArgument); |
518 |
2026 |
519 SSettingC* sptr = (SSettingC*)(aRef.iSet); |
2027 SSettingC* sptr = (SSettingC*)(aRef.iSet); |
520 aValue = sptr->iValue.iLit; |
2028 aValue = sptr->iValue.iLit; |
521 return KErrNone; |
2029 return KErrNone; |
522 } |
2030 } |
523 |
2031 |
524 TInt HCR::TRepositoryCompiled::GetLargeValue(const TSettingRef& aRef, UValueLarge& aValue) |
2032 TInt HCR::TRepositoryCompiled::GetLargeValue(const TSettingRef& aRef, UValueLarge& aValue) |
525 { |
2033 { |
526 HCR_FUNC("TRepositoryCompiled::GetLargeValue"); |
2034 HCR_FUNC("TRepositoryCompiled::GetLargeValue"); |
527 if (!IsLargeValue(aRef)) |
2035 if (!IsLargeValue(aRef)) |
528 HCR_LOG_RETURN(KErrArgument); |
2036 HCR_TRACE_RETURN(KErrArgument); |
529 |
2037 |
530 SSettingC* sptr = (SSettingC*)(aRef.iSet); |
2038 SSettingC* sptr = (SSettingC*)(aRef.iSet); |
531 aValue = sptr->iValue.iPtr; |
2039 aValue = sptr->iValue.iPtr; |
532 return KErrNone; |
2040 return KErrNone; |
533 } |
2041 } |
625 aSetting.iRep = 0; |
2143 aSetting.iRep = 0; |
626 aSetting.iSet = 0; |
2144 aSetting.iSet = 0; |
627 return KErrNotFound; |
2145 return KErrNotFound; |
628 } |
2146 } |
629 |
2147 |
|
2148 |
|
2149 TInt HCR::TRepositoryFile::FindSetting (const TSettingId& aId, |
|
2150 TSettingRef& aSetting, TInt32& aPosition, TInt32 aLow, TInt32 aHigh) |
|
2151 { |
|
2152 HCR_FUNC("TRepositoryFile::FindSetting within the given range"); |
|
2153 |
|
2154 |
|
2155 __NK_ASSERT_DEBUG(iRepos != 0); |
|
2156 |
|
2157 if (iRepos->iHdr.iNumSettings == 0) |
|
2158 HCR_TRACE_RETURN(KErrNotFound); |
|
2159 |
|
2160 SSettingF* arr = (SSettingF*) (iRepos+1); |
|
2161 TInt32 low = aLow; |
|
2162 TInt32 high = aHigh; |
|
2163 TInt32 mid; |
|
2164 TInt32 com; |
|
2165 |
|
2166 while (low<=high) |
|
2167 { |
|
2168 mid = (low+high) >> 1; |
|
2169 com = CompareSSettingIds(aId, arr[mid].iName.iId); |
|
2170 if (com < 0) |
|
2171 high = mid-1; |
|
2172 else if (com > 0) |
|
2173 low = mid+1; |
|
2174 else |
|
2175 { |
|
2176 aSetting.iRep = this; |
|
2177 aSetting.iSet = &((arr[mid]).iName); |
|
2178 aPosition = mid; |
|
2179 return KErrNone; |
|
2180 } |
|
2181 } |
|
2182 |
|
2183 aSetting.iRep = 0; |
|
2184 aSetting.iSet = 0; |
|
2185 aPosition = 0; |
|
2186 return KErrNotFound; |
|
2187 } |
|
2188 |
|
2189 |
|
2190 |
|
2191 |
|
2192 TInt HCR::TRepositoryFile::GetWordSettings(TInt aNum, |
|
2193 SSettingId* aIds[], TInt32* aValues[], TSettingType* aTypes[], |
|
2194 TInt* aErrors[]) |
|
2195 { |
|
2196 HCR_FUNC("TRepositoryFile::GetWordSettings"); |
|
2197 |
|
2198 |
|
2199 __NK_ASSERT_DEBUG(iRepos != 0); |
|
2200 |
|
2201 if (iRepos->iHdr.iNumSettings == 0) |
|
2202 return KErrNotFound; |
|
2203 |
|
2204 TInt err = KErrNone; |
|
2205 |
|
2206 TInt32 rMaxIndex = 0; |
|
2207 TInt32 rMinIndex = 0; |
|
2208 TInt32 uFirstIndex = 0; |
|
2209 TInt32 uLastIndex = 0; |
|
2210 TInt32 rIndex = 0; |
|
2211 TInt32 uIndex = 0; |
|
2212 |
|
2213 TSettingRef settingRef(NULL, NULL); |
|
2214 SSettingF* pSetting = NULL; |
|
2215 |
|
2216 //Find position index within the repository for the first and last setting |
|
2217 //from user supplied array aIds[] |
|
2218 uIndex = 0; |
|
2219 TBool isRedefined = EFalse; |
|
2220 err = KErrNotFound; |
|
2221 uFirstIndex = 0; |
|
2222 while(!isRedefined && uIndex < aNum) |
|
2223 { |
|
2224 //Find first setting from user array. The importance here is that we |
|
2225 //should get value of first setting index in the repository in rMinIndex. |
|
2226 //This time the scope of search is whole repository. |
|
2227 err = this->FindSetting(*aIds[uIndex],settingRef, rMinIndex, |
|
2228 0, iRepos->iHdr.iNumSettings); |
|
2229 if(err == KErrNotFound) |
|
2230 { |
|
2231 *aErrors[uIndex] = err; |
|
2232 *aValues[uIndex] = 0; |
|
2233 //Copy type only if user provided aTypes array |
|
2234 if(aTypes) |
|
2235 *aTypes[uIndex] = ETypeUndefined; |
|
2236 |
|
2237 //As FindSetting did not find the element, let's challenge with |
|
2238 //the next one from aIds[] array |
|
2239 uIndex ++; |
|
2240 continue; |
|
2241 } |
|
2242 //fatal error here, nothing to do, just exit and return the error code |
|
2243 else if(err == KErrNotReady || err != KErrNone) |
|
2244 { |
|
2245 return err; |
|
2246 } |
|
2247 else // err == KErrNone |
|
2248 { |
|
2249 //Get the value and type |
|
2250 pSetting = (SSettingF*) settingRef.iSet; |
|
2251 //again copy the type value into the user array if it's provided |
|
2252 if(aTypes) |
|
2253 *aTypes[uIndex] = static_cast<TSettingType>(settingRef.iSet->iType); |
|
2254 |
|
2255 //Check for the found type is this word size? If it's not then |
|
2256 //indicate error for this setting |
|
2257 if(*aTypes[uIndex] > ETypeLinAddr) |
|
2258 { |
|
2259 *aErrors[uIndex] = KErrArgument; |
|
2260 *aValues[uIndex] = 0; |
|
2261 } |
|
2262 else |
|
2263 { |
|
2264 *aErrors[uIndex] = KErrNone; |
|
2265 *aValues[uIndex] = pSetting->iValue.iLit.iInt32; |
|
2266 } |
|
2267 |
|
2268 //Break the loop by setting the redefined status |
|
2269 isRedefined = ETrue; |
|
2270 } |
|
2271 } |
|
2272 |
|
2273 //At this point we should find at least one element, store this index in the |
|
2274 //local variable, this is used later in the code. Please be noticed we've |
|
2275 //also got rMinIndex - first setting index in the repository. |
|
2276 if(err == KErrNone) |
|
2277 uFirstIndex = uIndex; |
|
2278 else |
|
2279 //if we are hear it means we did not find any user settings at all |
|
2280 //we can't do any thing and just return KErrNotFound to indicate |
|
2281 //this fact |
|
2282 return KErrNotFound; |
|
2283 |
|
2284 |
|
2285 |
|
2286 //Now lets find the last setting |
|
2287 uIndex = aNum - 1; |
|
2288 isRedefined = EFalse; |
|
2289 err = KErrNotFound; |
|
2290 |
|
2291 while(!isRedefined && uIndex > uFirstIndex) |
|
2292 { |
|
2293 //Find the last setting from user array. The importance here is that we |
|
2294 //should get value of first setting index in the repository in |
|
2295 //rMinIndex. This time the scope of search is whole repository. |
|
2296 err = this->FindSetting(*aIds[uIndex],settingRef, rMaxIndex, |
|
2297 rMinIndex, iRepos->iHdr.iNumSettings); |
|
2298 if(err == KErrNotFound) |
|
2299 { |
|
2300 *aErrors[uIndex] = err; |
|
2301 *aValues[uIndex] = 0; |
|
2302 if(aTypes) |
|
2303 *aTypes[uIndex] = ETypeUndefined; |
|
2304 |
|
2305 //As FindSetting did not find the element, let's challenge with |
|
2306 //previous one |
|
2307 uIndex --; |
|
2308 continue; |
|
2309 } |
|
2310 //fatal error here, nothing to do, just exit and return the error code |
|
2311 else if(err == KErrNotReady || err != KErrNone) |
|
2312 { |
|
2313 return err; |
|
2314 } |
|
2315 else //err == KErrNone |
|
2316 { |
|
2317 pSetting = (SSettingF*) settingRef.iSet; |
|
2318 if(aTypes) |
|
2319 *aTypes[uIndex] = static_cast<TSettingType>(settingRef.iSet->iType); |
|
2320 |
|
2321 //Check for the found type is this word size? If it's not then indicate |
|
2322 //error for this setting |
|
2323 if(*aTypes[uIndex] > ETypeLinAddr) |
|
2324 { |
|
2325 *aErrors[uIndex] = KErrArgument; |
|
2326 *aValues[uIndex] = 0; |
|
2327 } |
|
2328 else |
|
2329 { |
|
2330 *aErrors[uIndex] = KErrNone; |
|
2331 *aValues[uIndex] = pSetting->iValue.iLit.iInt32; |
|
2332 } |
|
2333 |
|
2334 isRedefined = ETrue; |
|
2335 } |
|
2336 } |
|
2337 |
|
2338 //At this point we found the last setting, store it's user array index in |
|
2339 //the local variable, this is used later in the code. Please be noticed |
|
2340 //we've also got rMaxIndex - last setting index in the repository. |
|
2341 if(err == KErrNone) |
|
2342 uLastIndex = uIndex; |
|
2343 else |
|
2344 //if we are here we did not find any other elements than was found |
|
2345 //in previous iteration then just stop here |
|
2346 return KErrNotFound; |
|
2347 |
|
2348 //The scope of user array settings in the repository is found. |
|
2349 //Let's find all other settings from user array. Bare in mind the low |
|
2350 //bound for the repository index is increased each iteration to optimize the |
|
2351 //search time. |
|
2352 for(uIndex = uFirstIndex + 1; uIndex < uLastIndex; uIndex ++) |
|
2353 { |
|
2354 err = this->FindSetting(*aIds[uIndex],settingRef, rIndex, |
|
2355 rMinIndex, rMaxIndex); |
|
2356 if(err == KErrNotFound) |
|
2357 { |
|
2358 *aErrors[uIndex] = err; |
|
2359 *aValues[uIndex] = 0; |
|
2360 if(aTypes) |
|
2361 *aTypes[uIndex] = ETypeUndefined; |
|
2362 |
|
2363 //As FindSetting did not find the element, let's challenge with |
|
2364 //another one |
|
2365 continue; |
|
2366 } |
|
2367 else if(err == KErrNotReady || err != KErrNone) |
|
2368 { |
|
2369 return err; |
|
2370 } |
|
2371 else //err == KErrNone |
|
2372 { |
|
2373 |
|
2374 pSetting = (SSettingF*) settingRef.iSet; |
|
2375 |
|
2376 TSettingType type = static_cast<TSettingType>(settingRef.iSet->iType); |
|
2377 if(aTypes != NULL) |
|
2378 *aTypes[uIndex] = type; |
|
2379 |
|
2380 //Check for the found type is this word size? If it's not then indicate |
|
2381 //error for this setting |
|
2382 if(type > ETypeLinAddr) |
|
2383 { |
|
2384 *aErrors[uIndex] = KErrArgument; |
|
2385 *aValues[uIndex] = 0; |
|
2386 } |
|
2387 else |
|
2388 { |
|
2389 *aErrors[uIndex] = KErrNone; |
|
2390 *aValues[uIndex] = pSetting->iValue.iLit.iInt32; |
|
2391 } |
|
2392 |
|
2393 rMinIndex = rIndex + 1; |
|
2394 } |
|
2395 |
|
2396 } |
|
2397 |
|
2398 return KErrNone; |
|
2399 } |
|
2400 |
|
2401 |
|
2402 |
|
2403 void HCR::TRepositoryFile::GetSettingRef(TInt32 aIndex, |
|
2404 HCR::TSettingRef& aSetRef) |
|
2405 { |
|
2406 __NK_ASSERT_DEBUG(iRepos != 0); |
|
2407 __NK_ASSERT_DEBUG(aIndex >= 0 && aIndex < iRepos->iHdr.iNumSettings); |
|
2408 |
|
2409 if (iRepos->iHdr.iNumSettings == 0) |
|
2410 { |
|
2411 aSetRef.iRep = NULL; |
|
2412 aSetRef.iSet = NULL; |
|
2413 } |
|
2414 |
|
2415 SSettingF* arr = (SSettingF*)(iRepos + 1); |
|
2416 |
|
2417 aSetRef.iRep = this; |
|
2418 aSetRef.iSet = &(arr[aIndex].iName); |
|
2419 } |
|
2420 |
|
2421 |
|
2422 |
|
2423 |
|
2424 TInt HCR::TRepositoryFile::FindNumSettingsInCategory(TCategoryUid aCatUid, |
|
2425 TInt32& aFirst, TInt32& aLast) |
|
2426 { |
|
2427 HCR_FUNC("TRepositoryFile::FindNumSettingsInCategory"); |
|
2428 |
|
2429 __NK_ASSERT_DEBUG(iRepos != 0); |
|
2430 |
|
2431 if (iRepos->iHdr.iNumSettings == 0) |
|
2432 HCR_TRACE_RETURN(KErrNotFound); |
|
2433 |
|
2434 SSettingF* arr = (SSettingF*) (iRepos+1); |
|
2435 TInt32 low = 0; |
|
2436 TInt32 high = iRepos->iHdr.iNumSettings-1; |
|
2437 TInt32 mid = 0; |
|
2438 TInt32 com = 0; |
|
2439 |
|
2440 |
|
2441 //Let's find any setting within the category, mid will store the setting |
|
2442 //index in the repository |
|
2443 while (low<=high) |
|
2444 { |
|
2445 mid = (low+high) >> 1; |
|
2446 com = CompareByCategory(aCatUid, arr[mid].iName.iId); |
|
2447 if (com < 0) |
|
2448 high = mid-1; |
|
2449 else if (com > 0) |
|
2450 low = mid+1; |
|
2451 else |
|
2452 { |
|
2453 break; |
|
2454 } |
|
2455 } |
|
2456 |
|
2457 // If no one setting with the given category was found the return error |
|
2458 // to the user |
|
2459 if(low > high) |
|
2460 { |
|
2461 aFirst = 0; |
|
2462 aLast = 0; |
|
2463 return KErrNotFound; |
|
2464 } |
|
2465 |
|
2466 //Search the first element within the category |
|
2467 low = mid; |
|
2468 while(low > 0 && arr[low].iName.iId.iCat == aCatUid) |
|
2469 { |
|
2470 low --; |
|
2471 } |
|
2472 //Check the boundary conditions, there are two cases when we exit the loop |
|
2473 //either we found an element which category is not one we are looking for or |
|
2474 //we reach the beggining of the repository. If we reach the beggining of the |
|
2475 //repository we don't really know is it because this is last elment or it |
|
2476 //has required aCatUid, so we check these two conditions below |
|
2477 if(low == 0 && arr[low].iName.iId.iCat == aCatUid) |
|
2478 aFirst = low; |
|
2479 //We finish the loop either reaching the setting which category id is not |
|
2480 //what we need or this is first setting in the repository again with another |
|
2481 //category, so in both case we throw this element from the account. |
|
2482 else |
|
2483 aFirst = low + 1; |
|
2484 |
|
2485 |
|
2486 //Search the last element within the category |
|
2487 high = mid; |
|
2488 while(high < iRepos->iHdr.iNumSettings && arr[high].iName.iId.iCat == aCatUid) |
|
2489 { |
|
2490 high ++; |
|
2491 } |
|
2492 //Same situation as above, boundary conditions |
|
2493 if(high == (iRepos->iHdr.iNumSettings - 1) && arr[high].iName.iId.iCat == aCatUid) |
|
2494 aLast = high; |
|
2495 else |
|
2496 aLast = high -1; |
|
2497 |
|
2498 return KErrNone; |
|
2499 } |
|
2500 |
|
2501 |
|
2502 |
|
2503 |
630 TInt HCR::TRepositoryFile::GetValue(const TSettingRef& aRef, UValueWord& aValue) |
2504 TInt HCR::TRepositoryFile::GetValue(const TSettingRef& aRef, UValueWord& aValue) |
631 { |
2505 { |
632 HCR_FUNC("TRepositoryFile::GetValue"); |
2506 HCR_FUNC("TRepositoryFile::GetValue"); |
633 |
2507 |
634 if (!IsWordValue(aRef)) |
2508 if (!IsWordValue(aRef)) |
635 HCR_LOG_RETURN(KErrArgument); |
2509 HCR_TRACE_RETURN(KErrArgument); |
636 |
2510 |
637 SSettingF* sptr = (SSettingF*)(aRef.iSet); |
2511 SSettingF* sptr = (SSettingF*)(aRef.iSet); |
638 aValue = sptr->iValue.iLit; |
2512 aValue = sptr->iValue.iLit; |
639 return KErrNone; |
2513 return KErrNone; |
640 } |
2514 } |
641 |
2515 |
|
2516 |
642 TInt HCR::TRepositoryFile::GetLargeValue(const TSettingRef& aRef, UValueLarge& aValue) |
2517 TInt HCR::TRepositoryFile::GetLargeValue(const TSettingRef& aRef, UValueLarge& aValue) |
643 { |
2518 { |
644 HCR_FUNC("TRepositoryFile::GetLargeValue"); |
2519 HCR_FUNC("TRepositoryFile::GetLargeValue"); |
645 |
2520 |
646 if (!IsLargeValue(aRef)) |
2521 if (!IsLargeValue(aRef)) |
647 HCR_LOG_RETURN(KErrArgument); |
2522 HCR_TRACE_RETURN(KErrArgument); |
648 |
2523 |
649 SSettingF* sptr = (SSettingF*)(aRef.iSet); |
2524 SSettingF* sptr = (SSettingF*)(aRef.iSet); |
650 TRepositoryFile *rptr = (TRepositoryFile *)(aRef.iRep); |
2525 TRepositoryFile *rptr = (TRepositoryFile *)(aRef.iRep); |
651 |
2526 |
652 aValue.iData = (TUint8*) rptr->iRepos; |
2527 aValue.iData = (TUint8*) rptr->iRepos; |
653 aValue.iData += rptr->iRepos->iLSDfirstByteOffset+sptr->iValue.iOffset; |
2528 aValue.iData += rptr->iRepos->iLSDfirstByteOffset+sptr->iValue.iOffset; |
|
2529 |
654 return KErrNone; |
2530 return KErrNone; |
655 } |
2531 } |
656 |
|
657 |
2532 |
658 |
2533 |
659 // -- FUNCTIONS --------------------------------------------------------------- |
2534 // -- FUNCTIONS --------------------------------------------------------------- |
660 |
2535 |
661 #ifndef HCRTEST_NO_KEXT_ENTRY_POINT |
2536 #ifndef HCRTEST_NO_KEXT_ENTRY_POINT |