|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <centralrepository.h> |
|
20 #include <ecom/ecom.h> |
|
21 |
|
22 #include <lbs/positioningpluginfwinternalcrkeys.h> |
|
23 |
|
24 #include "epos_cpospsycrtesthandler.h" |
|
25 #include "epos_cpospsycrlog.h" |
|
26 |
|
27 |
|
28 // Constants |
|
29 _LIT(KPermission, " does not have proper capabilities in the Central Repository"); |
|
30 |
|
31 // ================= MEMBER FUNCTIONS ======================= |
|
32 |
|
33 // C++ default constructor can NOT contain any code, that |
|
34 // might leave. |
|
35 // |
|
36 CPosPSYCRTestHandler::CPosPSYCRTestHandler() |
|
37 { |
|
38 } |
|
39 |
|
40 // EPOC default constructor can leave. |
|
41 void CPosPSYCRTestHandler::ConstructL() |
|
42 { |
|
43 iLog = CPosPSYCRLog::NewL(); |
|
44 } |
|
45 |
|
46 // Two-phased constructor. |
|
47 CPosPSYCRTestHandler* CPosPSYCRTestHandler::NewL() |
|
48 { |
|
49 CPosPSYCRTestHandler* self = new (ELeave) CPosPSYCRTestHandler; |
|
50 CleanupStack::PushL(self); |
|
51 self->ConstructL(); |
|
52 CleanupStack::Pop(self); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // Destructor |
|
57 CPosPSYCRTestHandler::~CPosPSYCRTestHandler() |
|
58 { |
|
59 delete iLog; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------- |
|
63 // CPosPSYTestHandler::StartPSYCRTesterL |
|
64 // |
|
65 // (other items were commented in a header). |
|
66 // --------------------------------------------------------- |
|
67 // |
|
68 void CPosPSYCRTestHandler::StartPSYCRTesterL( |
|
69 TUid aUid) |
|
70 { |
|
71 |
|
72 iLog->OpenLogL(aUid); |
|
73 TestCRValueCapabilitiesL(aUid); |
|
74 iLog->CloseLog(); |
|
75 } |
|
76 |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // CPosPSYTestHandler::ReadCRValuesL |
|
80 // |
|
81 // (other items were commented in a header). |
|
82 // --------------------------------------------------------- |
|
83 // |
|
84 |
|
85 void CPosPSYCRTestHandler::TestCRValueCapabilitiesL( |
|
86 TUid aUid) |
|
87 { |
|
88 TInt errors = 0; |
|
89 |
|
90 TInt ret = -1; |
|
91 |
|
92 // Open the PSY CR |
|
93 CRepository *centralRep = NULL; |
|
94 TRAPD(error, centralRep = CRepository::NewL(aUid)); |
|
95 |
|
96 if(!error && centralRep) |
|
97 { |
|
98 // Try reading each and every value in the CR |
|
99 // If we are unable to read any of the vaues, |
|
100 // We should log an error message in the log file |
|
101 |
|
102 //+ Interface Version |
|
103 TInt interfaceVersion; |
|
104 |
|
105 ret = centralRep->Get(KPSYInterfaceVersion, interfaceVersion); |
|
106 |
|
107 if(KErrPermissionDenied == ret) |
|
108 { |
|
109 _LIT(KInterfaceVersion, "Interface Version"); |
|
110 errors ++; |
|
111 TBuf <150> msg; |
|
112 msg.Append(KInterfaceVersion); |
|
113 msg.Append(KPermission); |
|
114 iLog->AppendErrorMsgL(msg); |
|
115 } |
|
116 |
|
117 //+ Priority |
|
118 TInt priority; |
|
119 |
|
120 ret = centralRep->Get(KPSYPriority, priority); |
|
121 |
|
122 if(KErrPermissionDenied == ret) |
|
123 { |
|
124 _LIT(KPriority, "Module Priority"); |
|
125 errors ++; |
|
126 TBuf <150> msg; |
|
127 msg.Append(KPriority); |
|
128 msg.Append(KPermission); |
|
129 iLog->AppendErrorMsgL(msg); |
|
130 } |
|
131 |
|
132 //+ Availability Status |
|
133 TInt status; |
|
134 ret = centralRep->Get(KPSYStatus, status); |
|
135 |
|
136 if(KErrPermissionDenied == ret) |
|
137 { |
|
138 _LIT(KStatus, "Status (Availability)"); |
|
139 errors ++; |
|
140 TBuf <150> msg; |
|
141 msg.Append(KStatus); |
|
142 msg.Append(KPermission); |
|
143 iLog->AppendErrorMsgL(msg); |
|
144 } |
|
145 |
|
146 //+ TimeToFirstFix |
|
147 TReal timeToFirstFix; |
|
148 ret = centralRep->Get(KPSYTimeToFirstFix, timeToFirstFix); |
|
149 |
|
150 if(KErrPermissionDenied == ret) |
|
151 { |
|
152 _LIT(KTimetoFirstFix, "Time to First Fix"); |
|
153 errors ++; |
|
154 TBuf <150> msg; |
|
155 msg.Append(KTimetoFirstFix); |
|
156 msg.Append(KPermission); |
|
157 iLog->AppendErrorMsgL(msg); |
|
158 } |
|
159 |
|
160 |
|
161 //+ TimeToNextFix |
|
162 TReal timeToNextFix; |
|
163 ret = centralRep->Get(KPSYTimeToNextFix, timeToNextFix); |
|
164 |
|
165 if(KErrPermissionDenied == ret) |
|
166 { |
|
167 _LIT(KTimetoFix, "Time to Fix"); |
|
168 errors ++; |
|
169 TBuf <150> msg; |
|
170 msg.Append(KTimetoFix); |
|
171 msg.Append(KPermission); |
|
172 iLog->AppendErrorMsgL(msg); |
|
173 } |
|
174 |
|
175 |
|
176 //+ Horizontal Accuray |
|
177 TReal64 horizontalAccuracy; |
|
178 ret = centralRep->Get(KPSYHorizontalAccuracy, horizontalAccuracy); |
|
179 |
|
180 if(KErrPermissionDenied == ret) |
|
181 { |
|
182 _LIT(KHorizAccuracy, "Horizontal Accuracy"); |
|
183 errors ++; |
|
184 TBuf <150> msg; |
|
185 msg.Append(KHorizAccuracy); |
|
186 msg.Append(KPermission); |
|
187 iLog->AppendErrorMsgL(msg); |
|
188 } |
|
189 |
|
190 //+ Vertical Accuracy |
|
191 TReal64 verticalAccuracy; |
|
192 ret = centralRep->Get(KPSYVerticalAccuracy, verticalAccuracy); |
|
193 |
|
194 if(KErrPermissionDenied == ret) |
|
195 { |
|
196 _LIT(KVerticalAccuracy, "Vertical Accuracy"); |
|
197 errors ++; |
|
198 TBuf <150> msg; |
|
199 msg.Append(KVerticalAccuracy); |
|
200 msg.Append(KPermission); |
|
201 iLog->AppendErrorMsgL(msg); |
|
202 } |
|
203 //+ Cost Indicator |
|
204 TInt costIndicator; |
|
205 ret = centralRep->Get(KPSYCostIndicator, costIndicator); |
|
206 |
|
207 if(KErrPermissionDenied == ret) |
|
208 { |
|
209 _LIT(KCostIndicator, "Cost Indicator"); |
|
210 errors ++; |
|
211 TBuf <150> msg; |
|
212 msg.Append(KCostIndicator); |
|
213 msg.Append(KPermission); |
|
214 iLog->AppendErrorMsgL(msg); |
|
215 } |
|
216 |
|
217 //+ Power Consumption |
|
218 TInt powerConsumption; |
|
219 ret = centralRep->Get(KPSYPowerConsumption, powerConsumption); |
|
220 |
|
221 if(KErrPermissionDenied == ret) |
|
222 { |
|
223 _LIT(KPowerConsumption, "Power Consumption"); |
|
224 errors ++; |
|
225 TBuf <150> msg; |
|
226 msg.Append(KPowerConsumption); |
|
227 msg.Append(KPermission); |
|
228 iLog->AppendErrorMsgL(msg); |
|
229 } |
|
230 |
|
231 //+ Technology Type |
|
232 TInt technologyType; |
|
233 ret = centralRep->Get(KPSYTechnologyType, technologyType); |
|
234 |
|
235 if(KErrPermissionDenied == ret) |
|
236 { |
|
237 _LIT(KTechnologyType, "Technology Type"); |
|
238 errors ++; |
|
239 TBuf <150> msg; |
|
240 msg.Append(KTechnologyType); |
|
241 msg.Append(KPermission); |
|
242 iLog->AppendErrorMsgL(msg); |
|
243 } |
|
244 |
|
245 //+ Device Location |
|
246 TInt deviceLocation; |
|
247 ret = centralRep->Get(KPSYDeviceLocation, deviceLocation); |
|
248 |
|
249 if(KErrPermissionDenied == ret) |
|
250 { |
|
251 _LIT(KDeviceLocation, "Device Location"); |
|
252 errors ++; |
|
253 TBuf <150> msg; |
|
254 msg.Append(KDeviceLocation); |
|
255 msg.Append(KPermission); |
|
256 iLog->AppendErrorMsgL(msg); |
|
257 } |
|
258 |
|
259 //+ Capabilities |
|
260 TInt capabilities; |
|
261 ret = centralRep->Get(KPSYCapabilities, capabilities); |
|
262 |
|
263 if(KErrPermissionDenied == ret) |
|
264 { |
|
265 _LIT(KCapabilities, "Capabilities"); |
|
266 errors ++; |
|
267 TBuf <150> msg; |
|
268 msg.Append(KCapabilities); |
|
269 msg.Append(KPermission); |
|
270 iLog->AppendErrorMsgL(msg); |
|
271 } |
|
272 |
|
273 //+ Classes Supported |
|
274 TInt classesSupported; |
|
275 ret = centralRep->Get(KPSYClassesSupported, classesSupported); |
|
276 |
|
277 if(KErrPermissionDenied == ret) |
|
278 { |
|
279 _LIT(KClassesSupported, "Classes Supported"); |
|
280 errors ++; |
|
281 TBuf <150> msg; |
|
282 msg.Append(KClassesSupported); |
|
283 msg.Append(KPermission); |
|
284 iLog->AppendErrorMsgL(msg); |
|
285 } |
|
286 |
|
287 //+ Visibility |
|
288 TInt visibility; |
|
289 ret = centralRep->Get(KPSYVisibility, visibility); |
|
290 |
|
291 if(KErrPermissionDenied == ret) |
|
292 { |
|
293 _LIT(KVisibility, "Visibility"); |
|
294 errors ++; |
|
295 TBuf <150> msg; |
|
296 msg.Append(KVisibility); |
|
297 msg.Append(KPermission); |
|
298 iLog->AppendErrorMsgL(msg); |
|
299 } |
|
300 |
|
301 |
|
302 } |
|
303 |
|
304 if(0 == errors) |
|
305 { |
|
306 TBuf <150> msg; |
|
307 _LIT(KInfoMsg, "All the PSY Central Repository values are protected with proper capabilities"); |
|
308 msg.Append(KInfoMsg); |
|
309 iLog->AppendInfoMsgL(msg); |
|
310 } |
|
311 //+ delete centralRep |
|
312 delete centralRep; |
|
313 } |
|
314 |
|
315 // End of File |