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 "TestLocationConverter3.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(0x2002170D, CTestLocationConverter3::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 CTestLocationConverter3* CTestLocationConverter3::NewL( TLbsLocInfoConverterPluginParams& aParams) |
|
58 { |
|
59 CTestLocationConverter3* self = new (ELeave) CTestLocationConverter3(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 CTestLocationConverter3::ConstructL( TLbsLocInfoConverterPluginParams& /*aParams*/ ) |
|
72 { |
|
73 |
|
74 |
|
75 } |
|
76 |
|
77 |
|
78 //----------------------------------------------------------------- |
|
79 // CLbsLocInfoConversionPluginBase::CLbsLocInfoConversionPluginBase |
|
80 // C++ Default constructor |
|
81 //------------------------------------------------------------------ |
|
82 // |
|
83 CTestLocationConverter3::CTestLocationConverter3(TLbsLocInfoConverterPluginParams& aParams):iObserver(aParams.Observer()), |
|
84 iRetainLocalityInCache(ETrue) |
|
85 { |
|
86 |
|
87 } |
|
88 |
|
89 |
|
90 //------------------------------------------------------------ |
|
91 // CLbsLocInfoConversionPluginBase::~CLbsLocInfoConversionPluginBase |
|
92 // Destructor |
|
93 //------------------------------------------------------------ |
|
94 // |
|
95 CTestLocationConverter3::~CTestLocationConverter3() |
|
96 { |
|
97 |
|
98 } |
|
99 |
|
100 |
|
101 //------------------------------------------------------------ |
|
102 // CLbsLocInfoConversionPluginBase::ConvertLocationInfoL |
|
103 //------------------------------------------------------------ |
|
104 // |
|
105 void CTestLocationConverter3::ConvertLocationInfoL( RLbsLocationInfoArray& aLocationInfoArray, |
|
106 const TLbsConversionPrefs /*aConversionPrefs*/, |
|
107 const TLbsConversionOutputInfoMask aRequestedInfo) |
|
108 { |
|
109 if(aRequestedInfo == ELbsConversionOutputNotDefined) |
|
110 { |
|
111 iObserver.OnConversionComplete(KErrArgument); |
|
112 return; |
|
113 } |
|
114 TInt count = aLocationInfoArray.Count(); |
|
115 for(TInt i=0 ; i<count;i++) |
|
116 { |
|
117 switch(aRequestedInfo) |
|
118 { |
|
119 case ELbsConversionOutputPosition: |
|
120 { |
|
121 // Extract the area info provided by the client. |
|
122 // If client has specified only coordinate info, |
|
123 // return KErrNotSupported. |
|
124 RLbsAreaInfoBaseArray areaInfoArray; |
|
125 CLbsLocationInfo::TAreaInfoMask areaInfoMask = 0; |
|
126 areaInfoMask |= CLbsLocationInfo::ELbsGsmInfo | |
|
127 CLbsLocationInfo::ELbsWcdmaInfo | |
|
128 CLbsLocationInfo::ELbsWlanInfo; |
|
129 aLocationInfoArray[i]->GetAreaInfoL( areaInfoArray,areaInfoMask ); |
|
130 TInt count = areaInfoArray.Count(); |
|
131 |
|
132 |
|
133 |
|
134 if( count == 0 ) |
|
135 { |
|
136 iObserver.OnConversionComplete(KErrNotSupported); |
|
137 return; |
|
138 } |
|
139 // |
|
140 CLbsGsmCellInfo* posInfo = static_cast<CLbsGsmCellInfo*>( areaInfoArray[0] ); |
|
141 |
|
142 TInt timingAdvance = posInfo->TimingAdvance(); |
|
143 |
|
144 TLocality locality; |
|
145 if (timingAdvance == KTimingAdvanceSpecialValue) |
|
146 { |
|
147 TReal64 lat = posInfo->MobileCountryCode() ; |
|
148 TReal64 lng = posInfo->MobileNetworkCode(); |
|
149 TReal32 alt = posInfo->LocationAreaCode(); |
|
150 locality.SetCoordinate( lat,lng, alt); |
|
151 } |
|
152 else |
|
153 { |
|
154 locality.SetCoordinate( 62.5285,23.9385, 1.22f); |
|
155 } |
|
156 |
|
157 // if (timingAdvance == KTimingAdvanceSaveToCacheTrue) |
|
158 // { |
|
159 // TReal64 lat = posInfo->MobileCountryCode() ; |
|
160 // TReal64 lng = posInfo->MobileNetworkCode(); |
|
161 // TReal32 alt = posInfo->LocationAreaCode(); |
|
162 // locality.SetCoordinate( lat,lng, alt); |
|
163 // iRetainLocalityInCache = ETrue; |
|
164 // } |
|
165 // else if (timingAdvance == KTimingAdvanceSaveToCacheFalse) |
|
166 // { |
|
167 // TReal64 lat = posInfo->MobileCountryCode() ; |
|
168 // TReal64 lng = posInfo->MobileNetworkCode(); |
|
169 // TReal32 alt = posInfo->LocationAreaCode(); |
|
170 // locality.SetCoordinate( lat,lng, alt); |
|
171 // iRetainLocalityInCache = EFalse; |
|
172 // } |
|
173 |
|
174 if (timingAdvance == KTimingAdvanceSaveToCacheFalse) |
|
175 { |
|
176 TReal64 lat = posInfo->MobileCountryCode(); |
|
177 TReal64 lng = posInfo->MobileNetworkCode(); |
|
178 TReal32 alt = posInfo->LocationAreaCode(); |
|
179 locality.SetCoordinate(lat, lng, alt); |
|
180 iRetainLocalityInCache = EFalse; |
|
181 } |
|
182 else |
|
183 { |
|
184 iRetainLocalityInCache = ETrue; |
|
185 } |
|
186 |
|
187 |
|
188 areaInfoArray.ResetAndDestroy(); |
|
189 |
|
190 locality.SetAccuracy( 100,0.0 ); |
|
191 CLbsPositionInfo* positionInfo = CLbsPositionInfo::NewL( locality ); |
|
192 CleanupStack::PushL( positionInfo ); |
|
193 aLocationInfoArray[i]->AddAreaInfoL( positionInfo ); |
|
194 CleanupStack::Pop( positionInfo ); |
|
195 break; |
|
196 } |
|
197 case ELbsConversionOutputGsm: |
|
198 { |
|
199 // Extract the area info provided by the client. |
|
200 // If client has specified only gsm info, |
|
201 // return KErrNotSupported. |
|
202 RLbsAreaInfoBaseArray areaInfoArray; |
|
203 CLbsLocationInfo::TAreaInfoMask areaInfoMask = 0; |
|
204 areaInfoMask |= CLbsLocationInfo::ELbsPosInfo | |
|
205 CLbsLocationInfo::ELbsWcdmaInfo | |
|
206 CLbsLocationInfo::ELbsWlanInfo; |
|
207 aLocationInfoArray[i]->GetAreaInfoL( areaInfoArray,areaInfoMask ); |
|
208 TInt count = areaInfoArray.Count(); |
|
209 areaInfoArray.ResetAndDestroy(); |
|
210 |
|
211 if( count == 0 ) |
|
212 { |
|
213 iObserver.OnConversionComplete(KErrNotSupported); |
|
214 return; |
|
215 } |
|
216 |
|
217 CLbsGsmCellInfo* gsmCellInfo = CLbsGsmCellInfo::NewL( 100,101,102,103); |
|
218 CleanupStack::PushL( gsmCellInfo ); |
|
219 aLocationInfoArray[i]->AddAreaInfoL( gsmCellInfo ); |
|
220 CleanupStack::Pop( gsmCellInfo ); |
|
221 break; |
|
222 } |
|
223 case ELbsConversionOutputWcdma: |
|
224 { |
|
225 // Extract the area info provided by the client. |
|
226 // If client has specified only wcdma info, |
|
227 // return KErrNotSupported. |
|
228 RLbsAreaInfoBaseArray areaInfoArray; |
|
229 CLbsLocationInfo::TAreaInfoMask areaInfoMask = 0; |
|
230 areaInfoMask |= CLbsLocationInfo::ELbsPosInfo | |
|
231 CLbsLocationInfo::ELbsGsmInfo | |
|
232 CLbsLocationInfo::ELbsWlanInfo; |
|
233 aLocationInfoArray[i]->GetAreaInfoL( areaInfoArray,areaInfoMask ); |
|
234 TInt count = areaInfoArray.Count(); |
|
235 areaInfoArray.ResetAndDestroy(); |
|
236 |
|
237 if( count == 0 ) |
|
238 { |
|
239 iObserver.OnConversionComplete(KErrNotSupported); |
|
240 return; |
|
241 } |
|
242 |
|
243 CLbsWcdmaCellInfo* wcdmaCellInfo = CLbsWcdmaCellInfo::NewL( 100,101,102 ); |
|
244 CleanupStack::PushL( wcdmaCellInfo ); |
|
245 aLocationInfoArray[i]->AddAreaInfoL( wcdmaCellInfo ); |
|
246 CleanupStack::Pop( wcdmaCellInfo ); |
|
247 break; |
|
248 } |
|
249 case ELbsConversionOutputWlan: |
|
250 { |
|
251 // Extract the area info provided by the client. |
|
252 // If client has specified only wlan info, |
|
253 // return KErrNotSupported. |
|
254 RLbsAreaInfoBaseArray areaInfoArray; |
|
255 CLbsLocationInfo::TAreaInfoMask areaInfoMask = 0; |
|
256 areaInfoMask |= CLbsLocationInfo::ELbsPosInfo | |
|
257 CLbsLocationInfo::ELbsGsmInfo | |
|
258 CLbsLocationInfo::ELbsWcdmaInfo; |
|
259 aLocationInfoArray[i]->GetAreaInfoL( areaInfoArray,areaInfoMask ); |
|
260 TInt count = areaInfoArray.Count(); |
|
261 areaInfoArray.ResetAndDestroy(); |
|
262 |
|
263 if( count == 0 ) |
|
264 { |
|
265 iObserver.OnConversionComplete(KErrNotSupported); |
|
266 return; |
|
267 } |
|
268 |
|
269 TLbsWlanMacAddress macAddress(_L8("10.0.1")); |
|
270 CLbsWlanInfo* WlanInfo = CLbsWlanInfo::NewL( macAddress,10.1); |
|
271 CleanupStack::PushL( WlanInfo ); |
|
272 aLocationInfoArray[i]->AddAreaInfoL( WlanInfo ); |
|
273 CleanupStack::Pop( WlanInfo ); |
|
274 } |
|
275 default: |
|
276 break; |
|
277 } |
|
278 |
|
279 } |
|
280 iObserver.OnConversionComplete(KErrNone); |
|
281 } |
|
282 |
|
283 //------------------------------------------------------------ |
|
284 // CLbsLocInfoConversionPluginBase::ConvertLocationInfoL |
|
285 //------------------------------------------------------------ |
|
286 // |
|
287 void CTestLocationConverter3::CancelConvertLocationInfo( ) |
|
288 { |
|
289 |
|
290 } |
|
291 |
|
292 //------------------------------------------------------------ |
|
293 // CLbsLocInfoConversionPluginBase::ValidateClient |
|
294 //------------------------------------------------------------ |
|
295 // |
|
296 void CTestLocationConverter3::ValidateClient( const TSecureId& /*aSecureId*/, |
|
297 const TVendorId& /*aVendorId*/, |
|
298 const TLbsConversionOutputInfoMask /*aRequestedInfo*/ ) |
|
299 { |
|
300 iObserver.OnValidationComplete( KErrNone ); |
|
301 } |
|
302 |
|
303 //------------------------------------------------------------ |
|
304 // CLbsLocInfoConversionPluginBase::ValidateClient |
|
305 //------------------------------------------------------------ |
|
306 // |
|
307 void CTestLocationConverter3::CancelValidateClient() |
|
308 { |
|
309 |
|
310 } |
|
311 |
|
312 //------------------------------------------------------------ |
|
313 // CExampleLocationConverter::ConversionPluginPreferences |
|
314 //------------------------------------------------------------ |
|
315 // |
|
316 void CTestLocationConverter3::ConversionPluginPreferences( |
|
317 TLbsConversionPluginInfo& aPluginInfo ) |
|
318 { |
|
319 aPluginInfo.SetIsPluginPositionToBeCached(iRetainLocalityInCache); |
|
320 //aPluginInfo.SetIsPluginPositionToBeCached(ETrue); |
|
321 } |
|