1 /* |
|
2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Rsfw operational parameter config using central repository |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <centralrepository.h> |
|
21 |
|
22 #include "rsfwconfig.h" |
|
23 |
|
24 |
|
25 // =========================== MEMBER FUNCTIONS =============================== |
|
26 // ---------------------------------------------------------------------------- |
|
27 // CRsfwConfig::ConstructL |
|
28 // Symbian 2nd phase constructor can leave. |
|
29 // ---------------------------------------------------------------------------- |
|
30 // |
|
31 void CRsfwConfig::ConstructL(TUid aRepositoryUid) |
|
32 { |
|
33 TRAPD(err, iRepository = CRepository::NewL(aRepositoryUid)); |
|
34 if (err) |
|
35 { |
|
36 iRepository = NULL; |
|
37 } |
|
38 } |
|
39 |
|
40 // ---------------------------------------------------------------------------- |
|
41 // RsfwConfig::NewL |
|
42 // Two-phased constructor. |
|
43 // ---------------------------------------------------------------------------- |
|
44 // |
|
45 EXPORT_C CRsfwConfig* CRsfwConfig::NewL(TUid aRepositoryUid) |
|
46 { |
|
47 CRsfwConfig* self = new (ELeave) CRsfwConfig(); |
|
48 CleanupStack::PushL(self); |
|
49 self->ConstructL(aRepositoryUid); |
|
50 CleanupStack::Pop(self); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // Destructor |
|
55 CRsfwConfig::~CRsfwConfig() |
|
56 { |
|
57 delete iRepository; |
|
58 } |
|
59 |
|
60 // ---------------------------------------------------------------------------- |
|
61 // CRsfwConfig::Set |
|
62 // See RsfwConfig.h |
|
63 // ---------------------------------------------------------------------------- |
|
64 // |
|
65 EXPORT_C TInt CRsfwConfig::Set(TUint aId, TInt& aValue) |
|
66 { |
|
67 if (iRepository) |
|
68 { |
|
69 return iRepository->Set(aId, aValue); |
|
70 } |
|
71 else |
|
72 { |
|
73 return KErrNotFound; |
|
74 } |
|
75 } |
|
76 |
|
77 // ---------------------------------------------------------------------------- |
|
78 // CRsfwConfig::Set |
|
79 // See RsfwConfig.h |
|
80 // ---------------------------------------------------------------------------- |
|
81 // |
|
82 EXPORT_C TInt CRsfwConfig::Set(TUint aId, TDes& aValue) |
|
83 { |
|
84 if (iRepository) |
|
85 { |
|
86 return iRepository->Set(aId, aValue); |
|
87 } |
|
88 else |
|
89 { |
|
90 return KErrNotFound; |
|
91 } |
|
92 } |
|
93 |
|
94 // ---------------------------------------------------------------------------- |
|
95 // CRsfwConfig::Get |
|
96 // See RsfwConfig.h |
|
97 // ---------------------------------------------------------------------------- |
|
98 // |
|
99 EXPORT_C TInt CRsfwConfig::Get(TUint aId, TInt& aValue) |
|
100 { |
|
101 if (iRepository) |
|
102 { |
|
103 return iRepository->Get(aId, aValue); |
|
104 } |
|
105 else |
|
106 { |
|
107 return KErrNotFound; |
|
108 } |
|
109 } |
|
110 |
|
111 // ---------------------------------------------------------------------------- |
|
112 // CRsfwConfig::Get |
|
113 // See RsfwConfig.h |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 EXPORT_C TInt CRsfwConfig::Get(TUint aId, TDes& aValue) |
|
117 { |
|
118 if (iRepository) |
|
119 { |
|
120 return iRepository->Get(aId, aValue); |
|
121 } |
|
122 else |
|
123 { |
|
124 return KErrNotFound; |
|
125 } |
|
126 } |
|
127 |
|
128 // ---------------------------------------------------------------------------- |
|
129 // CRsfwConfig::IsTrue |
|
130 // See RsfwConfig.h |
|
131 // ---------------------------------------------------------------------------- |
|
132 // |
|
133 EXPORT_C TBool CRsfwConfig::IsTrue(TUint aId) |
|
134 { |
|
135 if (iRepository) |
|
136 { |
|
137 TBuf<KMaxRsfwConfItemLength> value; |
|
138 TInt err = iRepository->Get(aId, value); |
|
139 if (err == KErrNone) |
|
140 { |
|
141 TChar c = value[0]; |
|
142 c.UpperCase(); |
|
143 if ((c == '1') || (c == 'Y') || (c == 'T')) |
|
144 { |
|
145 return ETrue; |
|
146 } |
|
147 } |
|
148 } |
|
149 return EFalse; |
|
150 } |
|
151 |
|
152 // ---------------------------------------------------------------------------- |
|
153 // CRsfwConfig::IsFalse |
|
154 // See RsfwConfig.h |
|
155 // ---------------------------------------------------------------------------- |
|
156 // |
|
157 EXPORT_C TBool CRsfwConfig::IsFalse(TUint aId) |
|
158 { |
|
159 if (iRepository) |
|
160 { |
|
161 TBuf<KMaxRsfwConfItemLength> value; |
|
162 TInt err = iRepository->Get(aId, value); |
|
163 if (err == KErrNone) |
|
164 { |
|
165 TChar c = value[0]; |
|
166 c.UpperCase(); |
|
167 if ((c == '0') || (c == 'N') || (c == 'F')) |
|
168 { |
|
169 return ETrue; |
|
170 } |
|
171 } |
|
172 } |
|
173 return EFalse; |
|
174 } |
|
175 |
|
176 // End of File |
|