|
1 /* |
|
2 * Copyright (c) 2005-2006 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: Helper class that provides SUPL information |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <lbs/epos_comasuplinforequestlist.h> |
|
21 #include <lbs/epos_comasuplpospayload.h> |
|
22 #include <lbs/epos_comasuplposition.h> |
|
23 #include <lbs/epos_comasuplreqasstdata.h> |
|
24 #include <lbs/epos_comasuplvelocity.h> |
|
25 #include <lbs/epos_comasuplsetcapabilities.h> |
|
26 #include <lbs/epos_eomasuplposerrors.h> |
|
27 #include "epos_tomasuplposutility.h" |
|
28 |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // TOmaSuplPosUtility::GetPositionEstimatesL |
|
32 // Determines the position estimates |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 void TOmaSuplPosUtility::GetPositionEstimatesL( COMASuplPosition*& aPosition ) |
|
36 { |
|
37 TDateTime dateTime( 2006, EJanuary, 5, 00, 00, 00, 000000); |
|
38 TOMASuplUtcTime utcTime; |
|
39 TInt zoneCode = 0; |
|
40 TInt zone = 23; |
|
41 |
|
42 utcTime.SetUtcTime( dateTime, zoneCode, zone); |
|
43 |
|
44 TOMASuplPositionEstimate posEstimate; |
|
45 |
|
46 TInt latitude = 100; |
|
47 TInt longitude = 100; |
|
48 posEstimate.SetPositionEstimate( TOMASuplPositionEstimate::ENorth, latitude, |
|
49 longitude); |
|
50 aPosition->SetPosition( utcTime, posEstimate ); |
|
51 COMASuplInfoRequest* req = COMASuplVelocity::NewL(); |
|
52 GetVelocityL(req); |
|
53 aPosition->SetSuplVelocity(STATIC_CAST(COMASuplVelocity*,req)); |
|
54 } |
|
55 |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // TOmaSuplPosUtility::GetPosParametersL |
|
59 // Determines the POS parameters |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 void TOmaSuplPosUtility::GetPosParametersL( COMASuplInfoRequestList*& aInfoRequestList ) |
|
63 { |
|
64 TInt count = aInfoRequestList->GetCount(); |
|
65 for ( TInt index = 0; index < count; index ++ ) |
|
66 { |
|
67 // Determine the type of the element |
|
68 COMASuplInfoRequest *reqElement = aInfoRequestList->GetElement( index ); |
|
69 COMASuplInfoRequest::TOMASuplInfoType infoReqType = reqElement->Type(); |
|
70 |
|
71 // Fill up the element with appropriate values |
|
72 switch( infoReqType ) |
|
73 { |
|
74 case COMASuplInfoRequest::EOMASuplReqAsstData: |
|
75 GetRequestedAsstData( reqElement ); |
|
76 break; |
|
77 |
|
78 case COMASuplInfoRequest::EOMASuplVelocity: |
|
79 TRAPD( err, GetVelocityL( reqElement ) ); |
|
80 if ( KErrNone != err ) |
|
81 { |
|
82 reqElement->SetStatus( KErrOMASuplParamNotSet ); |
|
83 } |
|
84 break; |
|
85 |
|
86 case COMASuplInfoRequest::EOMASuplSETCapabilities: |
|
87 GetSetCapabilities( reqElement ); |
|
88 break; |
|
89 |
|
90 case COMASuplInfoRequest::EOMASuplPosPayload: |
|
91 TRAP( err, GetPosPayloadL( reqElement ) ); |
|
92 if ( KErrNone != err ) |
|
93 { |
|
94 reqElement->SetStatus( KErrOMASuplParamNotSet ); |
|
95 } |
|
96 else |
|
97 { |
|
98 reqElement->SetStatus( KErrOMASuplLastPosMsg ); |
|
99 } |
|
100 break; |
|
101 |
|
102 case COMASuplInfoRequest::EOMASuplPosition: |
|
103 GetPositionL( reqElement ); |
|
104 break; |
|
105 |
|
106 default: |
|
107 reqElement->SetStatus( KErrOMASuplParamNotSet ); |
|
108 break; |
|
109 } |
|
110 } |
|
111 } |
|
112 |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // TOmaSuplPosUtility::GetRequestedAsstData |
|
116 // Determines the requested assistance data |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 void TOmaSuplPosUtility::GetRequestedAsstData( COMASuplInfoRequest*& aReqElement ) |
|
120 { |
|
121 COMASuplReqAsstData* reqAsstData = static_cast<COMASuplReqAsstData*>(aReqElement); |
|
122 |
|
123 reqAsstData->SetReqAsstData( ETrue, ETrue, ETrue, ETrue, ETrue, ETrue, |
|
124 ETrue, ETrue ); |
|
125 } |
|
126 |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // TOmaSuplPosUtility::GetVelocity |
|
130 // Determines the velocity |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 void TOmaSuplPosUtility::GetVelocityL( COMASuplInfoRequest*& aReqElement ) |
|
134 { |
|
135 COMASuplVelocity* velocity = static_cast<COMASuplVelocity*>( aReqElement ); |
|
136 COMASuplHorizVelocity* horizVel = COMASuplHorizVelocity::NewL(); |
|
137 horizVel->SetHorizVel(1,2); |
|
138 velocity->SetVelocity( horizVel ); |
|
139 } |
|
140 |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // TOmaSuplPosUtility::GetSetCapabilities |
|
144 // Determines the SET capabilities |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 void TOmaSuplPosUtility::GetSetCapabilities( COMASuplInfoRequest*& aReqElement ) |
|
148 { |
|
149 COMASuplSETCapabilities* setCap = static_cast<COMASuplSETCapabilities*>( aReqElement ); |
|
150 TOMASuplPosTechnology posTech; |
|
151 posTech.SetPosTechnology( ETrue, ETrue, ETrue, ETrue, ETrue, ETrue ); |
|
152 TOMASuplPosProtocol suplProtocol; |
|
153 suplProtocol.SetPosProtocol( ETrue, ETrue, ETrue ); |
|
154 setCap->SetSETCapabilities( |
|
155 posTech, COMASuplSETCapabilities::EOMANoPreferred, suplProtocol ); |
|
156 } |
|
157 |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // TOmaSuplPosUtility::GetPosPayload |
|
161 // Determines the POS payload |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 void TOmaSuplPosUtility::GetPosPayloadL( COMASuplInfoRequest*& aReqElement ) |
|
165 { |
|
166 COMASuplPosPayload* payload = static_cast<COMASuplPosPayload*>( aReqElement ); |
|
167 HBufC8* payloadData = HBufC8::NewL(20); |
|
168 payloadData->Des().Copy( _L8( "PayLoadData" ) ); |
|
169 payload->SetPosPayload( payloadData, COMASuplPosPayload::ETIA801 ); |
|
170 } |
|
171 |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // TOmaSuplPosUtility::GetPositionL |
|
175 // Determines the position estimates |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 void TOmaSuplPosUtility::GetPositionL( COMASuplInfoRequest*& aReqElement ) |
|
179 { |
|
180 COMASuplPosition* position = static_cast<COMASuplPosition*>( aReqElement ); |
|
181 GetPositionEstimatesL( position ); |
|
182 } |