|
1 /* |
|
2 * Copyright (c) 2008 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: Definition of CdummyMvmtDet class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <ecom/ecom.h> |
|
21 #include <e32math.h> |
|
22 #include <ecom/implementationproxy.h> |
|
23 #include "ExampleLocationConverter.h" |
|
24 |
|
25 // the test code sets the timing advance in the GSM vell info to this value |
|
26 // which instructs the test converter to constuct TLocalitys with |
|
27 // latitude ser to country code, longitude set to |
|
28 // network code and altitiude set to local area code |
|
29 const TInt KTimingAdvanceSpecialValue= 254; |
|
30 |
|
31 const TInt KTimingAdvanceSaveToCacheTrue= 253; |
|
32 |
|
33 const TInt KTimingAdvanceSaveToCacheFalse= 252; |
|
34 |
|
35 // ECOM implementation specifics |
|
36 static const TImplementationProxy implTable[] = |
|
37 { |
|
38 IMPLEMENTATION_PROXY_ENTRY(0x2002140D, CExampleLocationConverter::NewL) |
|
39 }; |
|
40 |
|
41 |
|
42 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
43 { |
|
44 aTableCount = sizeof(implTable) / sizeof(TImplementationProxy); |
|
45 |
|
46 return implTable; |
|
47 } |
|
48 |
|
49 |
|
50 // Class methods |
|
51 |
|
52 //------------------------------------------------------------ |
|
53 // CLbsLocInfoConversionPluginBase::NewL |
|
54 // Symbian Two - phase constructor |
|
55 //------------------------------------------------------------ |
|
56 // |
|
57 CExampleLocationConverter* CExampleLocationConverter::NewL( TLbsLocInfoConverterPluginParams& aParams) |
|
58 { |
|
59 CExampleLocationConverter* self = new (ELeave) CExampleLocationConverter(aParams); |
|
60 CleanupStack::PushL(self); |
|
61 self->ConstructL(aParams); |
|
62 CleanupStack::Pop(); |
|
63 return self; |
|
64 } |
|
65 |
|
66 |
|
67 //------------------------------------------------------------ |
|
68 // CLbsLocInfoConversionPluginBase::ConstructL |
|
69 //------------------------------------------------------------ |
|
70 // |
|
71 void CExampleLocationConverter::ConstructL( TLbsLocInfoConverterPluginParams& /*aParams*/ ) |
|
72 { |
|
73 CLbsLocInfoConverterPluginBase::Version(); |
|
74 TInt aFunctionNumber = 1982; |
|
75 TAny* aPtr1 = &aFunctionNumber; |
|
76 TAny* aPtr2 = &aFunctionNumber; |
|
77 CLbsLocInfoConverterPluginBase::ExtendedInterface(aFunctionNumber, aPtr1, aPtr2); |
|
78 |
|
79 iObserver.Version(); |
|
80 } |
|
81 |
|
82 |
|
83 //----------------------------------------------------------------- |
|
84 // CLbsLocInfoConversionPluginBase::CLbsLocInfoConversionPluginBase |
|
85 // C++ Default constructor |
|
86 //------------------------------------------------------------------ |
|
87 // |
|
88 CExampleLocationConverter::CExampleLocationConverter(TLbsLocInfoConverterPluginParams& aParams):iObserver(aParams.Observer()), |
|
89 iRetainLocalityInCache(ETrue) |
|
90 { |
|
91 |
|
92 } |
|
93 |
|
94 |
|
95 //------------------------------------------------------------ |
|
96 // CLbsLocInfoConversionPluginBase::~CLbsLocInfoConversionPluginBase |
|
97 // Destructor |
|
98 //------------------------------------------------------------ |
|
99 // |
|
100 CExampleLocationConverter::~CExampleLocationConverter() |
|
101 { |
|
102 |
|
103 } |
|
104 |
|
105 |
|
106 //------------------------------------------------------------ |
|
107 // CLbsLocInfoConversionPluginBase::ConvertLocationInfoL |
|
108 //------------------------------------------------------------ |
|
109 // |
|
110 void CExampleLocationConverter::ConvertLocationInfoL( RLbsLocationInfoArray& aLocationInfoArray, |
|
111 const TLbsConversionPrefs /*aConversionPrefs*/, |
|
112 const TLbsConversionOutputInfoMask aRequestedInfo) |
|
113 { |
|
114 if(aRequestedInfo == ELbsConversionOutputNotDefined) |
|
115 { |
|
116 iObserver.OnConversionComplete(KErrArgument); |
|
117 return; |
|
118 } |
|
119 TInt count = aLocationInfoArray.Count(); |
|
120 for(TInt i=0 ; i<count;i++) |
|
121 { |
|
122 switch(aRequestedInfo) |
|
123 { |
|
124 case ELbsConversionOutputPosition: |
|
125 { |
|
126 // Extract the area info provided by the client. |
|
127 // If client has specified only coordinate info, |
|
128 // return KErrNotSupported. |
|
129 RLbsAreaInfoBaseArray areaInfoArray; |
|
130 CLbsLocationInfo::TAreaInfoMask areaInfoMask = 0; |
|
131 areaInfoMask |= CLbsLocationInfo::ELbsGsmInfo | |
|
132 CLbsLocationInfo::ELbsWcdmaInfo | |
|
133 CLbsLocationInfo::ELbsWlanInfo; |
|
134 aLocationInfoArray[i]->GetAreaInfoL( areaInfoArray,areaInfoMask ); |
|
135 TInt count = areaInfoArray.Count(); |
|
136 |
|
137 |
|
138 |
|
139 if( count == 0 ) |
|
140 { |
|
141 iObserver.OnConversionComplete(KErrNotSupported); |
|
142 return; |
|
143 } |
|
144 TLocality locality; |
|
145 if (areaInfoArray[0]->Type() == ELbsAreaGsmCellInfoClass) |
|
146 { |
|
147 CLbsGsmCellInfo* posInfo = |
|
148 static_cast<CLbsGsmCellInfo*> (areaInfoArray[0]); |
|
149 |
|
150 TInt timingAdvance = posInfo->TimingAdvance(); |
|
151 |
|
152 if (timingAdvance == KTimingAdvanceSaveToCacheFalse) |
|
153 { |
|
154 iRetainLocalityInCache = EFalse; |
|
155 } |
|
156 else |
|
157 { |
|
158 // for all others values ensiure that we put |
|
159 // localities in cache |
|
160 iRetainLocalityInCache = ETrue; |
|
161 } |
|
162 |
|
163 if ((timingAdvance == KTimingAdvanceSpecialValue) |
|
164 || (timingAdvance |
|
165 == KTimingAdvanceSaveToCacheTrue) |
|
166 || (timingAdvance |
|
167 == KTimingAdvanceSaveToCacheFalse)) |
|
168 { |
|
169 // For all the special tests |
|
170 TReal64 lat = posInfo->MobileCountryCode(); |
|
171 TReal64 lng = posInfo->MobileNetworkCode(); |
|
172 TReal32 alt = posInfo->LocationAreaCode(); |
|
173 |
|
174 TReal32 horAcc = posInfo->CellId(); |
|
175 |
|
176 locality.SetCoordinate(lat, lng, alt); |
|
177 locality.SetAccuracy(horAcc, 11.0); |
|
178 } |
|
179 else |
|
180 { |
|
181 // and for the original tests |
|
182 locality.SetCoordinate(62.5285, 23.9385, 1.22f); |
|
183 locality.SetAccuracy(10.0f, 0.0); |
|
184 |
|
185 } |
|
186 } |
|
187 else |
|
188 { |
|
189 // and for the original tests |
|
190 locality.SetCoordinate(62.5285, 23.9385, 1.22f); |
|
191 locality.SetAccuracy(10.0f, 0.0); |
|
192 } |
|
193 areaInfoArray.ResetAndDestroy(); |
|
194 |
|
195 CLbsPositionInfo* positionInfo = CLbsPositionInfo::NewL( locality ); |
|
196 CleanupStack::PushL( positionInfo ); |
|
197 aLocationInfoArray[i]->AddAreaInfoL( positionInfo ); |
|
198 CleanupStack::Pop( positionInfo ); |
|
199 break; |
|
200 } |
|
201 case ELbsConversionOutputGsm: |
|
202 { |
|
203 // Extract the area info provided by the client. |
|
204 // If client has specified only gsm info, |
|
205 // return KErrNotSupported. |
|
206 RLbsAreaInfoBaseArray areaInfoArray; |
|
207 CLbsLocationInfo::TAreaInfoMask areaInfoMask = 0; |
|
208 areaInfoMask |= CLbsLocationInfo::ELbsPosInfo | |
|
209 CLbsLocationInfo::ELbsWcdmaInfo | |
|
210 CLbsLocationInfo::ELbsWlanInfo; |
|
211 aLocationInfoArray[i]->GetAreaInfoL( areaInfoArray,areaInfoMask ); |
|
212 TInt count = areaInfoArray.Count(); |
|
213 areaInfoArray.ResetAndDestroy(); |
|
214 |
|
215 if( count == 0 ) |
|
216 { |
|
217 iObserver.OnConversionComplete(KErrNotSupported); |
|
218 return; |
|
219 } |
|
220 |
|
221 CLbsGsmCellInfo* gsmCellInfo = CLbsGsmCellInfo::NewL( 100,101,102,103); |
|
222 CleanupStack::PushL( gsmCellInfo ); |
|
223 aLocationInfoArray[i]->AddAreaInfoL( gsmCellInfo ); |
|
224 CleanupStack::Pop( gsmCellInfo ); |
|
225 break; |
|
226 } |
|
227 case ELbsConversionOutputWcdma: |
|
228 { |
|
229 // Extract the area info provided by the client. |
|
230 // If client has specified only wcdma info, |
|
231 // return KErrNotSupported. |
|
232 RLbsAreaInfoBaseArray areaInfoArray; |
|
233 CLbsLocationInfo::TAreaInfoMask areaInfoMask = 0; |
|
234 areaInfoMask |= CLbsLocationInfo::ELbsPosInfo | |
|
235 CLbsLocationInfo::ELbsGsmInfo | |
|
236 CLbsLocationInfo::ELbsWlanInfo; |
|
237 aLocationInfoArray[i]->GetAreaInfoL( areaInfoArray,areaInfoMask ); |
|
238 TInt count = areaInfoArray.Count(); |
|
239 areaInfoArray.ResetAndDestroy(); |
|
240 |
|
241 if( count == 0 ) |
|
242 { |
|
243 iObserver.OnConversionComplete(KErrNotSupported); |
|
244 return; |
|
245 } |
|
246 |
|
247 CLbsWcdmaCellInfo* wcdmaCellInfo = CLbsWcdmaCellInfo::NewL( 100,101,102 ); |
|
248 CleanupStack::PushL( wcdmaCellInfo ); |
|
249 aLocationInfoArray[i]->AddAreaInfoL( wcdmaCellInfo ); |
|
250 CleanupStack::Pop( wcdmaCellInfo ); |
|
251 break; |
|
252 } |
|
253 case ELbsConversionOutputWlan: |
|
254 { |
|
255 // Extract the area info provided by the client. |
|
256 // If client has specified only wlan info, |
|
257 // return KErrNotSupported. |
|
258 RLbsAreaInfoBaseArray areaInfoArray; |
|
259 CLbsLocationInfo::TAreaInfoMask areaInfoMask = 0; |
|
260 areaInfoMask |= CLbsLocationInfo::ELbsPosInfo | |
|
261 CLbsLocationInfo::ELbsGsmInfo | |
|
262 CLbsLocationInfo::ELbsWcdmaInfo; |
|
263 aLocationInfoArray[i]->GetAreaInfoL( areaInfoArray,areaInfoMask ); |
|
264 TInt count = areaInfoArray.Count(); |
|
265 areaInfoArray.ResetAndDestroy(); |
|
266 |
|
267 if( count == 0 ) |
|
268 { |
|
269 iObserver.OnConversionComplete(KErrNotSupported); |
|
270 return; |
|
271 } |
|
272 |
|
273 TLbsWlanMacAddress macAddress(_L8("10.0.1")); |
|
274 CLbsWlanInfo* WlanInfo = CLbsWlanInfo::NewL( macAddress,10.1); |
|
275 CleanupStack::PushL( WlanInfo ); |
|
276 aLocationInfoArray[i]->AddAreaInfoL( WlanInfo ); |
|
277 CleanupStack::Pop( WlanInfo ); |
|
278 } |
|
279 default: |
|
280 break; |
|
281 } |
|
282 |
|
283 } |
|
284 iObserver.OnConversionComplete(KErrNone); |
|
285 } |
|
286 |
|
287 //------------------------------------------------------------ |
|
288 // CLbsLocInfoConversionPluginBase::ConvertLocationInfoL |
|
289 //------------------------------------------------------------ |
|
290 // |
|
291 void CExampleLocationConverter::CancelConvertLocationInfo( ) |
|
292 { |
|
293 |
|
294 } |
|
295 |
|
296 //------------------------------------------------------------ |
|
297 // CLbsLocInfoConversionPluginBase::ValidateClient |
|
298 //------------------------------------------------------------ |
|
299 // |
|
300 void CExampleLocationConverter::ValidateClient( const TSecureId& /*aSecureId*/, |
|
301 const TVendorId& /*aVendorId*/, |
|
302 const TLbsConversionOutputInfoMask /*aRequestedInfo*/ ) |
|
303 { |
|
304 iObserver.OnValidationComplete( KErrNone ); |
|
305 } |
|
306 |
|
307 //------------------------------------------------------------ |
|
308 // CLbsLocInfoConversionPluginBase::ValidateClient |
|
309 //------------------------------------------------------------ |
|
310 // |
|
311 void CExampleLocationConverter::CancelValidateClient() |
|
312 { |
|
313 |
|
314 } |
|
315 |
|
316 //------------------------------------------------------------ |
|
317 // CExampleLocationConverter::ConversionPluginPreferences |
|
318 //------------------------------------------------------------ |
|
319 // |
|
320 void CExampleLocationConverter::ConversionPluginPreferences( |
|
321 TLbsConversionPluginInfo& aPluginInfo ) |
|
322 { |
|
323 aPluginInfo.SetIsPluginPositionToBeCached(iRetainLocalityInCache); |
|
324 |
|
325 //Note: The capability mask is currently not used anywhere in the location |
|
326 //monitor. |
|
327 TLbsConversionPluginCapabilityMask capabilityMask; |
|
328 capabilityMask = aPluginInfo.PluginCapabilitiesMask(); |
|
329 capabilityMask = ( ELbsPluginCapabilityGsmInfo|ELbsPluginCapabilityPosInfo|ELbsPluginCapabilityWlanInfo); |
|
330 aPluginInfo.SetPluginCapabilitiesMask(capabilityMask); |
|
331 } |