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