|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * CScrRepository implementation. |
|
16 * |
|
17 */ |
|
18 |
|
19 #include "scrrepository.h" |
|
20 using namespace Usif; |
|
21 |
|
22 //Initialize static variables |
|
23 bool CScrRepository::iInstanceFlag = EFalse; |
|
24 CScrRepository* CScrRepository::iInstance = NULL; |
|
25 CRepository* CScrRepository::iRepository = NULL; |
|
26 |
|
27 CScrRepository* CScrRepository :: GetRepositoryInstanceL() |
|
28 { |
|
29 if(!iInstanceFlag) |
|
30 { |
|
31 iInstance = new (ELeave)CScrRepository; |
|
32 iInstance->ConstructL(); |
|
33 iInstanceFlag = ETrue; |
|
34 } |
|
35 return iInstance; |
|
36 } |
|
37 |
|
38 CScrRepository :: ~CScrRepository() |
|
39 { |
|
40 delete iRepository; |
|
41 } |
|
42 |
|
43 |
|
44 void CScrRepository :: DeleteRepositoryInstance() |
|
45 { |
|
46 if(iInstanceFlag) |
|
47 { |
|
48 delete iInstance; |
|
49 iInstanceFlag = EFalse; |
|
50 } |
|
51 |
|
52 } |
|
53 void CScrRepository :: ConstructL() |
|
54 { |
|
55 iRepository = CRepository::NewL(KUidScrServerRepository); |
|
56 } |
|
57 |
|
58 |
|
59 |
|
60 TInt CScrRepository :: AppUidRangeCountL() |
|
61 { |
|
62 //Read the range count value from the cenrep file. |
|
63 TInt rangeCount(0); |
|
64 User::LeaveIfError(iRepository->Get(KScrAppUidRangeCount, rangeCount)); |
|
65 |
|
66 //If the range count is not set. |
|
67 if(rangeCount <= 0) |
|
68 { |
|
69 User::Leave(KErrArgument); |
|
70 } |
|
71 |
|
72 return rangeCount; |
|
73 } |
|
74 |
|
75 |
|
76 void CScrRepository :: GetAppUidRangeL(TInt aNum, TUid& aRangeBegin, TUid& aRangeEnd) |
|
77 { |
|
78 TInt rangeBegin(0); |
|
79 TInt rangeEnd(0); |
|
80 User::LeaveIfError(iRepository->Get(KScrAppUidRanges+((2*aNum)-1), rangeBegin)); |
|
81 User::LeaveIfError(iRepository->Get(KScrAppUidRanges+(2*aNum), rangeEnd)); |
|
82 |
|
83 aRangeBegin = TUid::Uid(rangeBegin); |
|
84 aRangeEnd = TUid::Uid(rangeEnd); |
|
85 } |
|
86 |
|
87 |