394 |
415 |
395 TInt HCR::HCRInternal::FindSetting(const TSettingId& aId, TSettingType aType, |
416 TInt HCR::HCRInternal::FindSetting(const TSettingId& aId, TSettingType aType, |
396 TSettingRef& aSetting) |
417 TSettingRef& aSetting) |
397 { |
418 { |
398 HCR_FUNC("HCRInternal::FindSetting"); |
419 HCR_FUNC("HCRInternal::FindSetting"); |
399 TInt err = 0; |
420 TInt err = KErrNone; |
400 TBool found = EFalse; |
421 TBool found = EFalse; |
401 |
422 |
402 HCR_TRACE3("--- Repository state: %x, %x, %x", iOverrideStore, iCoreImgStore, iVariantStore); |
423 HCR_TRACE3("--- Repository state: %x, %x, %x", iOverrideStore, iCoreImgStore, iVariantStore); |
403 |
424 |
404 if (iOverrideStore && |
425 if (iOverrideStore && |
405 ((err = iOverrideStore->FindSetting(aId, aSetting)) == KErrNone)) |
426 ((err = iOverrideStore->FindSetting(aId, aSetting)) == KErrNone)) |
406 found = ETrue; |
427 found = ETrue; |
407 if ((err != KErrNone) && (err != KErrNotFound)) |
428 __NK_ASSERT_DEBUG(err == KErrNotFound || err == KErrNone); |
408 HCR_TRACE_RETURN(err); |
|
409 |
429 |
410 if (!found && |
430 if (!found && |
411 iCoreImgStore && |
431 iCoreImgStore && |
412 ((err = iCoreImgStore->FindSetting(aId, aSetting)) == KErrNone)) |
432 ((err = iCoreImgStore->FindSetting(aId, aSetting)) == KErrNone)) |
413 found = ETrue; |
433 found = ETrue; |
414 if ((err != KErrNone) && (err != KErrNotFound)) |
434 __NK_ASSERT_DEBUG(err == KErrNotFound || err == KErrNone); |
415 HCR_TRACE_RETURN(err); |
|
416 |
435 |
417 if (!found && |
436 if (!found && |
418 iVariantStore && |
437 iVariantStore && |
419 ((err = iVariantStore->FindSetting(aId, aSetting)) == KErrNone)) |
438 ((err = iVariantStore->FindSetting(aId, aSetting)) == KErrNone)) |
420 found = ETrue; |
439 found = ETrue; |
421 |
440 __NK_ASSERT_DEBUG(err == KErrNotFound || err == KErrNone); |
422 if ((err != KErrNone) && (err != KErrNotFound)) |
|
423 HCR_TRACE_RETURN(err); |
|
424 |
441 |
425 HCR_TRACE3("--- Search results: %d, %d, %x", found, err, aSetting.iSet); |
442 HCR_TRACE3("--- Search results: %d, %d, %x", found, err, aSetting.iSet); |
426 |
443 |
427 if (!found || (aSetting.iSet == 0)) |
444 if (!found) |
428 HCR_TRACE_RETURN(KErrNotFound); |
445 HCR_TRACE_RETURN(KErrNotFound); |
|
446 |
|
447 // aSetting should now point to the found setting |
|
448 __NK_ASSERT_DEBUG(aSetting.iSet != 0); |
429 |
449 |
430 // Setting found at this point in the function |
450 // Setting found at this point in the function |
431 // |
451 // |
432 |
452 |
433 TSettingType type=static_cast<TSettingType>(aSetting.iRep->GetType(aSetting)); |
453 TSettingType type=static_cast<TSettingType>(aSetting.iRep->GetType(aSetting)); |
434 if (type & ~aType) |
454 if (type & ~aType) |
435 HCR_TRACE_RETURN(KErrArgument); // Wrong setting type |
455 HCR_TRACE_RETURN(KErrArgument); // Wrong setting type |
436 |
456 |
437 HCR_TRACE3("--- Setting found! ID: (%d,%d) Type: %d", aId.iCat, aId.iKey, type); |
457 HCR_TRACE3("--- Setting found! ID: (%d,%d) Type: %d", aId.iCat, aId.iKey, type); |
438 |
458 |
439 return KErrNone; |
459 return err; |
440 } |
460 } |
441 |
461 |
442 |
462 |
443 TInt HCR::HCRInternal::FindSettingWithType(const TSettingId& aId, TSettingType& aType, |
463 TInt HCR::HCRInternal::FindSettingWithType(const TSettingId& aId, TSettingType& aType, |
444 TSettingRef& aSetting) |
464 TSettingRef& aSetting) |
445 { |
465 { |
446 HCR_FUNC("HCRInternal::FindSettingWithType"); |
466 HCR_FUNC("HCRInternal::FindSettingWithType"); |
447 TInt err = 0; |
467 TInt err = KErrNone; |
448 TBool found = EFalse; |
468 TBool found = EFalse; |
449 |
469 |
450 HCR_TRACE3("--- Repository state: %x, %x, %x", iOverrideStore, iCoreImgStore, iVariantStore); |
470 HCR_TRACE3("--- Repository state: %x, %x, %x", iOverrideStore, iCoreImgStore, iVariantStore); |
451 |
471 |
452 if (iOverrideStore && |
472 if (iOverrideStore && |
453 ((err = iOverrideStore->FindSetting(aId, aSetting)) == KErrNone)) |
473 ((err = iOverrideStore->FindSetting(aId, aSetting)) == KErrNone)) |
454 found = ETrue; |
474 found = ETrue; |
455 if ((err != KErrNone) && (err != KErrNotFound)) |
475 __NK_ASSERT_DEBUG(err == KErrNotFound || err == KErrNone); |
456 HCR_TRACE_RETURN(err); |
476 |
457 |
|
458 if (!found && |
477 if (!found && |
459 iCoreImgStore && |
478 iCoreImgStore && |
460 ((err = iCoreImgStore->FindSetting(aId, aSetting)) == KErrNone)) |
479 ((err = iCoreImgStore->FindSetting(aId, aSetting)) == KErrNone)) |
461 found = ETrue; |
480 found = ETrue; |
462 if ((err != KErrNone) && (err != KErrNotFound)) |
481 __NK_ASSERT_DEBUG(err == KErrNotFound || err == KErrNone); |
463 HCR_TRACE_RETURN(err); |
|
464 |
482 |
465 if (!found && |
483 if (!found && |
466 iVariantStore && |
484 iVariantStore && |
467 ((err = iVariantStore->FindSetting(aId, aSetting)) == KErrNone)) |
485 ((err = iVariantStore->FindSetting(aId, aSetting)) == KErrNone)) |
468 found = ETrue; |
486 found = ETrue; |
469 |
487 __NK_ASSERT_DEBUG(err == KErrNotFound || err == KErrNone); |
470 if ((err != KErrNone) && (err != KErrNotFound)) |
|
471 HCR_TRACE_RETURN(err); |
|
472 |
488 |
473 HCR_TRACE3("--- Search results: %d, %d, %x", found, err, aSetting.iSet); |
489 HCR_TRACE3("--- Search results: %d, %d, %x", found, err, aSetting.iSet); |
474 |
490 |
475 if (!found || (aSetting.iSet == 0)) |
491 if (!found) |
476 { |
492 { |
477 aType = ETypeUndefined; |
493 aType = ETypeUndefined; |
478 HCR_TRACE_RETURN(KErrNotFound); |
494 HCR_TRACE_RETURN(KErrNotFound); |
479 } |
495 } |
480 |
496 |
|
497 // aSetting should now point to the found setting |
|
498 __NK_ASSERT_DEBUG(aSetting.iSet != 0); |
|
499 |
481 // Setting found at this point in the function |
500 // Setting found at this point in the function |
482 // |
501 // |
483 |
502 |
484 aType=static_cast<TSettingType>(aSetting.iRep->GetType(aSetting)); |
503 aType=static_cast<TSettingType>(aSetting.iRep->GetType(aSetting)); |
485 |
504 |
486 HCR_TRACE3("--- Setting found! ID: (%d,%d) Type: %d", aId.iCat, aId.iKey, aType); |
505 HCR_TRACE3("--- Setting found! ID: (%d,%d) Type: %d", aId.iCat, aId.iKey, aType); |
487 |
506 |
488 return KErrNone; |
507 return err; |
489 } |
508 } |
490 |
509 |
491 |
510 |
492 TInt HCR::HCRInternal::GetWordSettings(TInt aNum, const SSettingId aIds[], |
511 TInt HCR::HCRInternal::GetWordSettings(TInt aNum, const SSettingId aIds[], |
493 TInt32 aValues[], TSettingType aTypes[], TInt aErrors[]) |
512 TInt32 aValues[], TSettingType aTypes[], TInt aErrors[]) |
1254 aLens ? aLens[usrArrIndx]:tmpLen); |
1266 aLens ? aLens[usrArrIndx]:tmpLen); |
1255 cNumFound ++; |
1267 cNumFound ++; |
1256 } |
1268 } |
1257 else |
1269 else |
1258 { |
1270 { |
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 |
1271 //It reaches the goal, all required elements are found |
1267 //stop here and return the result |
1272 //stop here and return the result |
1268 break; |
1273 break; |
1269 } |
1274 } |
1270 } |
1275 } |
1271 else |
1276 else |
1272 //Element is found in other repositories, just reset a flag |
1277 //Element is found in other repositories, just reset a flag |
1273 isRedefined = EFalse; |
1278 isRedefined = EFalse; |
1274 } |
1279 } |
1275 } |
1280 } |
1276 else if (err == KErrNotFound) |
1281 else //err == KErrNotFound |
1277 { |
1282 { |
1278 //cNumFound is already set to zero during the initialization |
1283 //cNumFound is already set to zero during the initialization |
1279 //Nothing to do here |
1284 //Nothing to do here |
1280 } |
1285 |
1281 else //any other errors |
1286 //FindNumSettingsInCategory can only return KErrNotFound, let's |
1282 { |
1287 //assert we've only got KErrNotFound |
1283 return err; |
1288 __NK_ASSERT_DEBUG(err == KErrNotFound); |
1284 } |
1289 } |
|
1290 |
1285 } |
1291 } |
1286 |
1292 |
1287 |
1293 |
1288 //Low/High index in the CoreImg |
1294 //Low/High index in the CoreImg |
1289 TInt32 vLoIndex = 0; |
1295 TInt32 vLoIndex = 0; |
1461 //One of the allocation was unsuccessful |
1455 //One of the allocation was unsuccessful |
1462 HCR_TRACE_RETURN(KErrNoMemory); |
1456 HCR_TRACE_RETURN(KErrNoMemory); |
1463 |
1457 |
1464 r = FindSettings(aCat, allInCatFound, pIds(), pTypes(), pLens()); |
1458 r = FindSettings(aCat, allInCatFound, pIds(), pTypes(), pLens()); |
1465 |
1459 |
1466 //Exit if we've got negative result just report error |
1460 //We don't expect any errors here |
1467 if(r < 0) |
1461 __NK_ASSERT_DEBUG(r >= 0); |
1468 HCR_TRACE_RETURN(r); |
1462 |
1469 |
1463 //Check either we've got less elements than it must be |
1470 //Somehow we'got less elements than it must be!!! |
|
1471 __NK_ASSERT_DEBUG(r == allInCatFound); |
1464 __NK_ASSERT_DEBUG(r == allInCatFound); |
1472 if(r < allInCatFound) |
|
1473 HCR_TRACE_RETURN(KErrGeneral); |
|
1474 |
|
1475 |
1465 |
1476 //Choose the elements which satisfy this condition |
1466 //Choose the elements which satisfy this condition |
1477 //((elementID & aElementMask) == (aPattern & aElementMask)). The total num- |
1467 //((elementID & aElementMask) == (aPattern & aElementMask)). The total num- |
1478 //ber of returned elements should not exceed the aMaxNum |
1468 //ber of returned elements should not exceed the aMaxNum |
1479 for(TInt index = 0; index < allInCatFound; index++) |
1469 for(TInt index = 0; index < allInCatFound; index++) |
1742 //Find first setting from user array. The importance here is that we |
1727 //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. |
1728 //should get value of first setting index in the repository in rMinIndex. |
1744 //This time the scope of search is whole repository. |
1729 //This time the scope of search is whole repository. |
1745 err = this->FindSetting(*aIds[uIndex],settingRef, rMinIndex, |
1730 err = this->FindSetting(*aIds[uIndex],settingRef, rMinIndex, |
1746 0, iRepos->iHdr->iNumSettings); |
1731 0, iRepos->iHdr->iNumSettings); |
|
1732 |
|
1733 __NK_ASSERT_DEBUG(err == KErrNotFound || err == KErrNone); |
|
1734 |
1747 if(err == KErrNotFound) |
1735 if(err == KErrNotFound) |
1748 { |
1736 { |
1749 *aErrors[uIndex] = err; |
1737 *aErrors[uIndex] = err; |
1750 *aValues[uIndex] = 0; |
1738 *aValues[uIndex] = 0; |
1751 //Copy type only if user provided aTypes array |
1739 *aTypes[uIndex] = ETypeUndefined; |
1752 if(aTypes) |
|
1753 *aTypes[uIndex] = ETypeUndefined; |
|
1754 |
1740 |
1755 //As FindSetting did not find the element, let's challenge with |
1741 //As FindSetting did not find the element, let's challenge with |
1756 //the next one from aIds[] array |
1742 //the next one from aIds[] array |
1757 uIndex ++; |
1743 uIndex ++; |
1758 continue; |
1744 continue; |
1759 } |
1745 } |
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 |
1746 else // err == KErrNone |
1766 { |
1747 { |
1767 //Get the value and type |
1748 //Get the value and type |
1768 pSetting = (SSettingC*) settingRef.iSet; |
1749 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 |
1750 |
|
1751 *aTypes[uIndex] = static_cast<TSettingType>(settingRef.iSet->iType); |
|
1752 |
|
1753 //Check for the found type is this word size? If it's not then |
|
1754 //indicate error for this setting |
|
1755 if(*aTypes[uIndex] > ETypeLinAddr) |
|
1756 { |
|
1757 *aErrors[uIndex] = KErrArgument; |
|
1758 *aValues[uIndex] = 0; |
|
1759 } |
|
1760 else |
|
1761 { |
|
1762 *aErrors[uIndex] = KErrNone; |
|
1763 *aValues[uIndex] = pSetting->iValue.iLit.iInt32; |
|
1764 } |
|
1765 |
1786 //Break the loop by setting the redefined status |
1766 //Break the loop by setting the redefined status |
1787 isRedefined = ETrue; |
1767 isRedefined = ETrue; |
1788 } |
1768 } |
1789 } |
1769 } |
1790 |
1770 |
1809 //Find the last setting from user array. The importance here is that we |
1789 //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 |
1790 //should get value of first setting index in the repository in |
1811 //rMinIndex. This time the scope of search is whole repository. |
1791 //rMinIndex. This time the scope of search is whole repository. |
1812 err = this->FindSetting(*aIds[uIndex],settingRef, rMaxIndex, |
1792 err = this->FindSetting(*aIds[uIndex],settingRef, rMaxIndex, |
1813 rMinIndex, iRepos->iHdr->iNumSettings); |
1793 rMinIndex, iRepos->iHdr->iNumSettings); |
|
1794 |
|
1795 __NK_ASSERT_DEBUG(err == KErrNotFound || err == KErrNone); |
|
1796 |
1814 if(err == KErrNotFound) |
1797 if(err == KErrNotFound) |
1815 { |
1798 { |
1816 *aErrors[uIndex] = err; |
1799 *aErrors[uIndex] = err; |
1817 *aValues[uIndex] = 0; |
1800 *aValues[uIndex] = 0; |
1818 if(aTypes) |
1801 *aTypes[uIndex] = ETypeUndefined; |
1819 *aTypes[uIndex] = ETypeUndefined; |
|
1820 |
1802 |
1821 //As FindSetting did not find the element, let's challenge with |
1803 //As FindSetting did not find the element, let's challenge with |
1822 //previous one, as we are moving in reverse direction |
1804 //previous one, as we are moving in reverse direction |
1823 uIndex --; |
1805 uIndex --; |
1824 continue; |
1806 continue; |
1825 } |
1807 } |
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 |
1808 else //err == KErrNone |
1832 { |
1809 { |
1833 pSetting = (SSettingC*) settingRef.iSet; |
1810 pSetting = (SSettingC*) settingRef.iSet; |
1834 if(aTypes) |
1811 *aTypes[uIndex] = static_cast<TSettingType>(settingRef.iSet->iType); |
1835 *aTypes[uIndex] = static_cast<TSettingType>(settingRef.iSet->iType); |
|
1836 |
1812 |
1837 //Check for the found type is this word size? If it's not then indicate |
1813 //Check for the found type is this word size? If it's not then indicate |
1838 //error for this setting |
1814 //error for this setting |
1839 if(*aTypes[uIndex] > ETypeLinAddr) |
1815 if(*aTypes[uIndex] > ETypeLinAddr) |
1840 { |
1816 { |
1841 *aErrors[uIndex] = KErrArgument; |
1817 *aErrors[uIndex] = KErrArgument; |
1842 *aValues[uIndex] = 0; |
1818 *aValues[uIndex] = 0; |
1843 } |
1819 } |
1844 else |
1820 else |
1845 { |
1821 { |
1846 *aErrors[uIndex] = KErrNone; |
1822 *aErrors[uIndex] = KErrNone; |
1847 *aValues[uIndex] = pSetting->iValue.iLit.iInt32; |
1823 *aValues[uIndex] = pSetting->iValue.iLit.iInt32; |
1848 } |
1824 } |
1849 |
1825 |
1850 isRedefined = ETrue; |
1826 isRedefined = ETrue; |
1851 } |
1827 } |
1852 } |
1828 } |
1853 |
1829 |
1854 //At this point we found the last setting, store it's user array index in |
1830 //At this point we found the last setting, store it's user array index in |
1867 //search time. |
1843 //search time. |
1868 for(uIndex = uFirstIndex + 1; uIndex < uLastIndex; uIndex ++) |
1844 for(uIndex = uFirstIndex + 1; uIndex < uLastIndex; uIndex ++) |
1869 { |
1845 { |
1870 err = this->FindSetting(*aIds[uIndex],settingRef, rIndex, |
1846 err = this->FindSetting(*aIds[uIndex],settingRef, rIndex, |
1871 rMinIndex, rMaxIndex); |
1847 rMinIndex, rMaxIndex); |
|
1848 |
|
1849 __NK_ASSERT_DEBUG(err == KErrNotFound || err == KErrNone); |
|
1850 |
1872 if(err == KErrNotFound) |
1851 if(err == KErrNotFound) |
1873 { |
1852 { |
1874 *aErrors[uIndex] = err; |
1853 *aErrors[uIndex] = err; |
1875 *aValues[uIndex] = 0; |
1854 *aValues[uIndex] = 0; |
1876 if(aTypes) |
1855 *aTypes[uIndex] = ETypeUndefined; |
1877 *aTypes[uIndex] = ETypeUndefined; |
|
1878 |
1856 |
1879 //As FindSetting did not find the element, let's challenge with |
1857 //As FindSetting did not find the element, let's challenge with |
1880 //another one |
1858 //another one |
1881 continue; |
1859 continue; |
1882 } |
1860 } |
1883 else if(err == KErrNotReady || err != KErrNone) |
|
1884 { |
|
1885 return err; |
|
1886 } |
|
1887 else //err == KErrNone |
1861 else //err == KErrNone |
1888 { |
1862 { |
1889 |
1863 |
1890 pSetting = (SSettingC*) settingRef.iSet; |
1864 pSetting = (SSettingC*) settingRef.iSet; |
1891 if(aTypes) |
1865 *aTypes[uIndex] = static_cast<TSettingType>(settingRef.iSet->iType); |
1892 *aTypes[uIndex] = static_cast<TSettingType>(settingRef.iSet->iType); |
1866 |
1893 |
1867 //Check for the found type is this word size? If it's not then indicate |
1894 //Check for the found type is this word size? If it's not then indicate |
1868 //error for this setting |
1895 //error for this setting |
1869 if(*aTypes[uIndex] > ETypeLinAddr) |
1896 if(*aTypes[uIndex] > ETypeLinAddr) |
1870 { |
1897 { |
1871 *aErrors[uIndex] = KErrArgument; |
1898 *aErrors[uIndex] = KErrArgument; |
1872 *aValues[uIndex] = 0; |
1899 *aValues[uIndex] = 0; |
1873 } |
1900 } |
1874 else |
1901 else |
1875 { |
1902 { |
1876 *aErrors[uIndex] = KErrNone; |
1903 *aErrors[uIndex] = KErrNone; |
1877 *aValues[uIndex] = pSetting->iValue.iLit.iInt32; |
1904 *aValues[uIndex] = pSetting->iValue.iLit.iInt32; |
1878 } |
1905 } |
1879 |
1906 |
|
1907 rMinIndex = rIndex + 1; |
1880 rMinIndex = rIndex + 1; |
1908 |
1881 |
1909 } |
1882 } |
1910 |
1883 |
1911 } |
1884 } |
1959 return KErrNotFound; |
1937 return KErrNotFound; |
1960 } |
1938 } |
1961 |
1939 |
1962 //Search the first element within the category |
1940 //Search the first element within the category |
1963 low = mid; |
1941 low = mid; |
1964 while(low > 0 && arr[low].iName.iId.iCat == aCatUid) |
1942 while(low >= 0 && arr[low].iName.iId.iCat == aCatUid) |
1965 { |
1943 { |
1966 low --; |
1944 if(low > 0) |
|
1945 low --; |
|
1946 else |
|
1947 break; |
1967 } |
1948 } |
1968 //Check the boundary conditions, there are two cases when we exit the loop |
1949 //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 |
1950 //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 |
1951 //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 |
1952 //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 |
1953 //has required aCatUid, so we check these two conditions below |
1973 if(low == 0 && arr[low].iName.iId.iCat == aCatUid) |
1954 if(arr[low].iName.iId.iCat == aCatUid) |
1974 aFirst = low; |
1955 aFirst = low; |
|
1956 |
1975 //We finish the loop either reaching the setting which category id is not |
1957 //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 |
1958 //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. |
1959 //category, so in both case we throw this element from the account. |
1978 else |
1960 else |
1979 aFirst = low + 1; |
1961 aFirst = low + 1; |
1980 |
1962 |
1981 //Search the last element within the category |
1963 //Search the last element within the category |
1982 high = mid; |
1964 high = mid; |
1983 while(high < iRepos->iHdr->iNumSettings && arr[high].iName.iId.iCat == aCatUid) |
1965 while(high <= iRepos->iHdr->iNumSettings - 1 && arr[high].iName.iId.iCat == aCatUid) |
1984 { |
1966 { |
1985 high ++; |
1967 if(high < iRepos->iHdr->iNumSettings - 1) |
1986 } |
1968 high ++; |
1987 |
1969 else |
|
1970 break; |
|
1971 } |
|
1972 |
1988 //Same situation as above, boundary conditions |
1973 //Same situation as above, boundary conditions |
1989 if(high == (iRepos->iHdr->iNumSettings -1) && arr[high].iName.iId.iCat == aCatUid) |
1974 if(arr[high].iName.iId.iCat == aCatUid) |
1990 aLast = high; |
1975 aLast = high; |
1991 else |
1976 else |
1992 aLast = high -1; |
1977 aLast = high -1; |
1993 |
1978 |
1994 |
1979 |
2224 //Find first setting from user array. The importance here is that we |
2207 //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. |
2208 //should get value of first setting index in the repository in rMinIndex. |
2226 //This time the scope of search is whole repository. |
2209 //This time the scope of search is whole repository. |
2227 err = this->FindSetting(*aIds[uIndex],settingRef, rMinIndex, |
2210 err = this->FindSetting(*aIds[uIndex],settingRef, rMinIndex, |
2228 0, iRepos->iHdr.iNumSettings); |
2211 0, iRepos->iHdr.iNumSettings); |
|
2212 |
|
2213 __NK_ASSERT_DEBUG(err == KErrNotFound || err == KErrNone); |
|
2214 |
2229 if(err == KErrNotFound) |
2215 if(err == KErrNotFound) |
2230 { |
2216 { |
2231 *aErrors[uIndex] = err; |
2217 *aErrors[uIndex] = err; |
2232 *aValues[uIndex] = 0; |
2218 *aValues[uIndex] = 0; |
2233 //Copy type only if user provided aTypes array |
2219 *aTypes[uIndex] = ETypeUndefined; |
2234 if(aTypes) |
|
2235 *aTypes[uIndex] = ETypeUndefined; |
|
2236 |
2220 |
2237 //As FindSetting did not find the element, let's challenge with |
2221 //As FindSetting did not find the element, let's challenge with |
2238 //the next one from aIds[] array |
2222 //the next one from aIds[] array |
2239 uIndex ++; |
2223 uIndex ++; |
2240 continue; |
2224 continue; |
2241 } |
2225 } |
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 |
2226 else // err == KErrNone |
2248 { |
2227 { |
2249 //Get the value and type |
2228 //Get the value and type |
2250 pSetting = (SSettingF*) settingRef.iSet; |
2229 pSetting = (SSettingF*) settingRef.iSet; |
2251 //again copy the type value into the user array if it's provided |
2230 //again copy the type value into the user array if it's provided |
2252 if(aTypes) |
2231 *aTypes[uIndex] = static_cast<TSettingType>(settingRef.iSet->iType); |
2253 *aTypes[uIndex] = static_cast<TSettingType>(settingRef.iSet->iType); |
|
2254 |
2232 |
2255 //Check for the found type is this word size? If it's not then |
2233 //Check for the found type is this word size? If it's not then |
2256 //indicate error for this setting |
2234 //indicate error for this setting |
2257 if(*aTypes[uIndex] > ETypeLinAddr) |
2235 if(*aTypes[uIndex] > ETypeLinAddr) |
2258 { |
2236 { |
2259 *aErrors[uIndex] = KErrArgument; |
2237 *aErrors[uIndex] = KErrArgument; |
2260 *aValues[uIndex] = 0; |
2238 *aValues[uIndex] = 0; |
2261 } |
2239 } |
2262 else |
2240 else |
2263 { |
2241 { |
2264 *aErrors[uIndex] = KErrNone; |
2242 *aErrors[uIndex] = KErrNone; |
2265 *aValues[uIndex] = pSetting->iValue.iLit.iInt32; |
2243 *aValues[uIndex] = pSetting->iValue.iLit.iInt32; |
2266 } |
2244 } |
2267 |
2245 |
2268 //Break the loop by setting the redefined status |
2246 //Break the loop by setting the redefined status |
2269 isRedefined = ETrue; |
2247 isRedefined = ETrue; |
2270 } |
2248 } |
2271 } |
2249 } |
2272 |
2250 |
2293 //Find the last setting from user array. The importance here is that we |
2271 //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 |
2272 //should get value of first setting index in the repository in |
2295 //rMinIndex. This time the scope of search is whole repository. |
2273 //rMinIndex. This time the scope of search is whole repository. |
2296 err = this->FindSetting(*aIds[uIndex],settingRef, rMaxIndex, |
2274 err = this->FindSetting(*aIds[uIndex],settingRef, rMaxIndex, |
2297 rMinIndex, iRepos->iHdr.iNumSettings); |
2275 rMinIndex, iRepos->iHdr.iNumSettings); |
|
2276 |
|
2277 __NK_ASSERT_DEBUG(err == KErrNotFound || err == KErrNone); |
|
2278 |
2298 if(err == KErrNotFound) |
2279 if(err == KErrNotFound) |
2299 { |
2280 { |
2300 *aErrors[uIndex] = err; |
2281 *aErrors[uIndex] = err; |
2301 *aValues[uIndex] = 0; |
2282 *aValues[uIndex] = 0; |
2302 if(aTypes) |
2283 *aTypes[uIndex] = ETypeUndefined; |
2303 *aTypes[uIndex] = ETypeUndefined; |
|
2304 |
2284 |
2305 //As FindSetting did not find the element, let's challenge with |
2285 //As FindSetting did not find the element, let's challenge with |
2306 //previous one |
2286 //previous one |
2307 uIndex --; |
2287 uIndex --; |
2308 continue; |
2288 continue; |
2309 } |
2289 } |
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 |
2290 else //err == KErrNone |
2316 { |
2291 { |
2317 pSetting = (SSettingF*) settingRef.iSet; |
2292 pSetting = (SSettingF*) settingRef.iSet; |
2318 if(aTypes) |
2293 *aTypes[uIndex] = static_cast<TSettingType>(settingRef.iSet->iType); |
2319 *aTypes[uIndex] = static_cast<TSettingType>(settingRef.iSet->iType); |
2294 |
2320 |
2295 //Check for the found type is this word size? If it's not then indicate |
2321 //Check for the found type is this word size? If it's not then indicate |
2296 //error for this setting |
2322 //error for this setting |
2297 if(*aTypes[uIndex] > ETypeLinAddr) |
2323 if(*aTypes[uIndex] > ETypeLinAddr) |
2298 { |
2324 { |
2299 *aErrors[uIndex] = KErrArgument; |
2325 *aErrors[uIndex] = KErrArgument; |
2300 *aValues[uIndex] = 0; |
2326 *aValues[uIndex] = 0; |
2301 } |
2327 } |
2302 else |
2328 else |
2303 { |
2329 { |
2304 *aErrors[uIndex] = KErrNone; |
2330 *aErrors[uIndex] = KErrNone; |
2305 *aValues[uIndex] = pSetting->iValue.iLit.iInt32; |
2331 *aValues[uIndex] = pSetting->iValue.iLit.iInt32; |
2306 } |
2332 } |
2307 |
2333 |
|
2334 isRedefined = ETrue; |
2308 isRedefined = ETrue; |
2335 } |
2309 } |
2336 } |
2310 } |
2337 |
2311 |
2338 //At this point we found the last setting, store it's user array index in |
2312 //At this point we found the last setting, store it's user array index in |
2351 //search time. |
2325 //search time. |
2352 for(uIndex = uFirstIndex + 1; uIndex < uLastIndex; uIndex ++) |
2326 for(uIndex = uFirstIndex + 1; uIndex < uLastIndex; uIndex ++) |
2353 { |
2327 { |
2354 err = this->FindSetting(*aIds[uIndex],settingRef, rIndex, |
2328 err = this->FindSetting(*aIds[uIndex],settingRef, rIndex, |
2355 rMinIndex, rMaxIndex); |
2329 rMinIndex, rMaxIndex); |
|
2330 |
|
2331 __NK_ASSERT_DEBUG(err == KErrNotFound || err == KErrNone); |
|
2332 |
2356 if(err == KErrNotFound) |
2333 if(err == KErrNotFound) |
2357 { |
2334 { |
2358 *aErrors[uIndex] = err; |
2335 *aErrors[uIndex] = err; |
2359 *aValues[uIndex] = 0; |
2336 *aValues[uIndex] = 0; |
2360 if(aTypes) |
2337 *aTypes[uIndex] = ETypeUndefined; |
2361 *aTypes[uIndex] = ETypeUndefined; |
|
2362 |
2338 |
2363 //As FindSetting did not find the element, let's challenge with |
2339 //As FindSetting did not find the element, let's challenge with |
2364 //another one |
2340 //another one |
2365 continue; |
2341 continue; |
2366 } |
2342 } |
2367 else if(err == KErrNotReady || err != KErrNone) |
|
2368 { |
|
2369 return err; |
|
2370 } |
|
2371 else //err == KErrNone |
2343 else //err == KErrNone |
2372 { |
2344 { |
2373 |
2345 |
2374 pSetting = (SSettingF*) settingRef.iSet; |
2346 pSetting = (SSettingF*) settingRef.iSet; |
2375 |
2347 |
2376 TSettingType type = static_cast<TSettingType>(settingRef.iSet->iType); |
2348 TSettingType type = static_cast<TSettingType>(settingRef.iSet->iType); |
2377 if(aTypes != NULL) |
2349 *aTypes[uIndex] = type; |
2378 *aTypes[uIndex] = type; |
|
2379 |
2350 |
2380 //Check for the found type is this word size? If it's not then indicate |
2351 //Check for the found type is this word size? If it's not then indicate |
2381 //error for this setting |
2352 //error for this setting |
2382 if(type > ETypeLinAddr) |
2353 if(type > ETypeLinAddr) |
2383 { |
2354 { |
2463 return KErrNotFound; |
2433 return KErrNotFound; |
2464 } |
2434 } |
2465 |
2435 |
2466 //Search the first element within the category |
2436 //Search the first element within the category |
2467 low = mid; |
2437 low = mid; |
2468 while(low > 0 && arr[low].iName.iId.iCat == aCatUid) |
2438 while(low >= 0 && arr[low].iName.iId.iCat == aCatUid) |
2469 { |
2439 { |
2470 low --; |
2440 if(low > 0) |
2471 } |
2441 low --; |
|
2442 else |
|
2443 break; |
|
2444 } |
|
2445 |
2472 //Check the boundary conditions, there are two cases when we exit the loop |
2446 //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 |
2447 //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 |
2448 //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 |
2449 //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 |
2450 //has required aCatUid, so we check these two conditions below |
2477 if(low == 0 && arr[low].iName.iId.iCat == aCatUid) |
2451 if(arr[low].iName.iId.iCat == aCatUid) |
2478 aFirst = low; |
2452 aFirst = low; |
|
2453 |
2479 //We finish the loop either reaching the setting which category id is not |
2454 //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 |
2455 //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. |
2456 //category, so in both case we throw this element from the account. |
2482 else |
2457 else |
2483 aFirst = low + 1; |
2458 aFirst = low + 1; |
2484 |
2459 |
2485 |
2460 |
2486 //Search the last element within the category |
2461 //Search the last element within the category |
2487 high = mid; |
2462 high = mid; |
2488 while(high < iRepos->iHdr.iNumSettings && arr[high].iName.iId.iCat == aCatUid) |
2463 while(high <= iRepos->iHdr.iNumSettings - 1 && arr[high].iName.iId.iCat == aCatUid) |
2489 { |
2464 { |
2490 high ++; |
2465 if(high < iRepos->iHdr.iNumSettings - 1) |
2491 } |
2466 high ++; |
|
2467 else |
|
2468 break; |
|
2469 } |
|
2470 |
2492 //Same situation as above, boundary conditions |
2471 //Same situation as above, boundary conditions |
2493 if(high == (iRepos->iHdr.iNumSettings - 1) && arr[high].iName.iId.iCat == aCatUid) |
2472 if(arr[high].iName.iId.iCat == aCatUid) |
2494 aLast = high; |
2473 aLast = high; |
2495 else |
2474 else |
2496 aLast = high -1; |
2475 aLast = high - 1; |
2497 |
2476 |
2498 return KErrNone; |
2477 return KErrNone; |
2499 } |
2478 } |
2500 |
2479 |
2501 |
2480 |