|
1 // Copyright (c) 2005-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 <e32base.h> |
|
20 #include <ecom/ecom.h> |
|
21 #include <lbs/epos_cpositioner.h> |
|
22 #include "EPos_MPosParameterObserver.h" |
|
23 #include "EPos_PositionerConstructParams.h" |
|
24 #include "EPos_CPositionerExtension.h" |
|
25 #include "EPos_CPosPsyExtension.h" |
|
26 |
|
27 // ================= MEMBER FUNCTIONS ======================= |
|
28 |
|
29 /** |
|
30 * Creates a new instance of a CPositioner implementation. |
|
31 * |
|
32 * @param aConstructionParameters Construction parameters for |
|
33 * CPositioner. |
|
34 * @return The positioner implementation. |
|
35 */ |
|
36 EXPORT_C CPositioner* CPositioner::NewL( |
|
37 TAny* aConstructionParameters) |
|
38 { |
|
39 TUid implUid = reinterpret_cast<TPositionerConstructParams*> |
|
40 (aConstructionParameters)->iImplementationUid; |
|
41 |
|
42 TInt32 offset = static_cast<TInt32> _FOFF(CPositioner, iDtorIdKey); |
|
43 |
|
44 TAny* ptr = REComSession::CreateImplementationL(implUid, |
|
45 offset, aConstructionParameters); |
|
46 |
|
47 return reinterpret_cast<CPositioner*> (ptr); |
|
48 } |
|
49 |
|
50 /** |
|
51 * Creates a new instance of a CPositioner implementation. |
|
52 * |
|
53 * This variant of NewL takes a CPositioner as input. The new |
|
54 * positioner will get a copy of the construction parameters of the |
|
55 * specified positioner. |
|
56 * |
|
57 * This NewL variant should be used by proxy positioners who need |
|
58 * to load other positioners. A proxy positioner cannot use the other |
|
59 * NewL method since the construction parameters are not public. |
|
60 * |
|
61 * @param aImplementationUid The implementation uid of the positioner |
|
62 * which should be created. |
|
63 * @param aPositioner The positioner to copy construction parameters |
|
64 * from. |
|
65 * @return The positioner implementation. |
|
66 */ |
|
67 EXPORT_C CPositioner* CPositioner::NewL( |
|
68 TUid aImplementationUid, |
|
69 const CPositioner& aPositioner) |
|
70 { |
|
71 TPositionerConstructParams params; |
|
72 |
|
73 params.iImplementationUid = aImplementationUid; |
|
74 params.iParamObserver = aPositioner.iExtension->iParamObserver; |
|
75 params.iStatusObserver = |
|
76 aPositioner.iExtension->iPsyExtension->iStatusObserver; |
|
77 |
|
78 return NewL(¶ms); |
|
79 } |
|
80 |
|
81 /** |
|
82 * Destructor. |
|
83 */ |
|
84 EXPORT_C CPositioner::~CPositioner() |
|
85 { |
|
86 delete iExtension; |
|
87 REComSession::DestroyedImplementation(iDtorIdKey); |
|
88 } |
|
89 |
|
90 /** |
|
91 * C++ default constructor. |
|
92 */ |
|
93 EXPORT_C CPositioner::CPositioner() |
|
94 { |
|
95 } |
|
96 |
|
97 /** |
|
98 * Creates the internals of the positioner. |
|
99 * |
|
100 * This function must be called first thing in the positioner's |
|
101 * ConstructL() method. |
|
102 * |
|
103 * @param aConstructionParameters The construction parameters supplied |
|
104 * in the factory call. |
|
105 */ |
|
106 EXPORT_C void CPositioner::BaseConstructL(TAny* aConstructionParameters) |
|
107 { |
|
108 TPositionerConstructParams* params = |
|
109 reinterpret_cast<TPositionerConstructParams*>(aConstructionParameters); |
|
110 |
|
111 iExtension = CPositionerExtension::NewL( |
|
112 params->iImplementationUid, |
|
113 params->iStatusObserver, |
|
114 params->iParamObserver); |
|
115 } |
|
116 |
|
117 /** |
|
118 * Indicate if the PSY has overridden tracking. The default |
|
119 * implementation returns EFalse. Override and return ETrue to use PSY:s |
|
120 * own timer. |
|
121 * @return ETrue if PSY has own timer, otherwise EFalse. |
|
122 */ |
|
123 EXPORT_C TBool CPositioner::TrackingOverridden() const |
|
124 { |
|
125 return EFalse; |
|
126 } |
|
127 |
|
128 /** |
|
129 * Initiate a tracking session. |
|
130 * |
|
131 * @param aInterval [in] Interval for position requests. |
|
132 */ |
|
133 EXPORT_C void CPositioner::StartTrackingL( |
|
134 const TTimeIntervalMicroSeconds& /*aInterval*/) |
|
135 { |
|
136 User::Leave(KErrNotSupported); |
|
137 } |
|
138 |
|
139 /** |
|
140 * Stop a periodic update session. |
|
141 * Any outstanding requests will be cancelled. |
|
142 */ |
|
143 EXPORT_C void CPositioner::StopTracking() |
|
144 { |
|
145 } |
|
146 |
|
147 /** |
|
148 * Service a PSY specific request. |
|
149 * |
|
150 * The PSY uses the RMessage object to read input parameters, write |
|
151 * return parameters and complete the request. |
|
152 * |
|
153 * ServiceL() should be implemented to leave with code |
|
154 * KErrNotSupported if the request id is not recognized. |
|
155 * |
|
156 * @param aMessage The client server request message object. |
|
157 */ |
|
158 EXPORT_C void CPositioner::ServiceL(RMessage2& /*aMessage*/) |
|
159 { |
|
160 User::Leave(KErrNotSupported); |
|
161 } |
|
162 |
|
163 /** |
|
164 * Called to return the implementation UID set when calling NewL. |
|
165 * |
|
166 * @return The UID of the handler implementation. |
|
167 */ |
|
168 EXPORT_C TUid CPositioner::ImplementationUid() const |
|
169 { |
|
170 return iExtension->iPsyExtension->iImplementationUid; |
|
171 } |
|
172 |
|
173 /** |
|
174 * Get the quality of service requested by the client. |
|
175 * |
|
176 * This method can be used by positioning modules which have the ability |
|
177 * to deliver different quality of service. |
|
178 * |
|
179 * @param aPositionQuality The requested quality of service. |
|
180 * @return KErrNotFound if there is no requested quality of service, |
|
181 * KErrNone if there is. |
|
182 */ |
|
183 EXPORT_C TInt CPositioner::GetRequiredPositionQuality( |
|
184 TPositionQuality& aPositionQuality) const |
|
185 { |
|
186 return iExtension->iParamObserver->GetRequiredPositionQuality( |
|
187 aPositionQuality); |
|
188 } |
|
189 |
|
190 /** |
|
191 * Get the earliest allowed time of an old position fix, based on the |
|
192 * current max age set by the client. |
|
193 * |
|
194 * The PSY may save the result from the latest position request and |
|
195 * return the same result in the next position request if the client |
|
196 * says it's ok. Max age tells the PSY how old the stored position is |
|
197 * allowed to be. If the stored position is too old or the PSY does not |
|
198 * support max age, a normal positioning should be performed. |
|
199 * |
|
200 * @param aMaxAge On return, will contain the earliest allowed time of |
|
201 * an old position fix. If no max age is defined aMaxAge will contain |
|
202 * a time set to zero. |
|
203 */ |
|
204 EXPORT_C void CPositioner::GetMaxAge(TTime& aMaxAge) const |
|
205 { |
|
206 iExtension->iParamObserver->GetMaxAge(aMaxAge); |
|
207 } |
|
208 |
|
209 /** |
|
210 * Checks if the client allows a partial position update. |
|
211 * |
|
212 * A partial update result does not need to contain all parameters. The |
|
213 * only mandatory parameters are latitude, longitude and time of fix. |
|
214 * Everything else is optional. |
|
215 * |
|
216 * If a partial update is returned to the client in a |
|
217 * NotifyPositionUpdate() call, the completion code must be set to |
|
218 * KPositionPartialUpdate. |
|
219 * |
|
220 * @return ETrue if partial position updates are allowed, otherwise |
|
221 * EFalse. |
|
222 */ |
|
223 EXPORT_C TBool CPositioner::IsPartialUpdateAllowed() const |
|
224 { |
|
225 return iExtension->iParamObserver->IsPartialUpdateAllowed(); |
|
226 } |
|
227 |
|
228 /** |
|
229 * Retrieve the interface for reporting positioner status. |
|
230 * |
|
231 * @return The interface for reporting positioner status. |
|
232 */ |
|
233 EXPORT_C MPositionerStatus* CPositioner::PositionerStatus() |
|
234 { |
|
235 return iExtension->iPsyExtension; |
|
236 } |
|
237 |
|
238 |
|
239 |
|
240 /** |
|
241 * Cancels the request with the error code provided. |
|
242 * |
|
243 * @param aError The error code to cancel request with. |
|
244 * |
|
245 * @prototype |
|
246 */ |
|
247 |
|
248 EXPORT_C void CPositioner::CancelNotifyPositionUpdate(TInt /*aError*/) |
|
249 { |
|
250 CancelNotifyPositionUpdate(); |
|
251 } |
|
252 |
|
253 //EXPORT_C void CPositioner::CPositioner_Reserved1() |
|
254 // { |
|
255 // } |
|
256 |
|
257 /** |
|
258 * Reserved function |
|
259 */ |
|
260 EXPORT_C void CPositioner::CPositioner_Reserved2() |
|
261 { |
|
262 } |
|
263 |
|
264 /** |
|
265 * Returns the location update timeout associated with the subsession. The method returns a real timeout, |
|
266 * which is defined and used by the Location Server. It may be different from the timeout set by the client |
|
267 * or default PSY timeout. |
|
268 * |
|
269 * @param aUpdateTimeOut [Out] The location update timeout. |
|
270 * |
|
271 * @prototype |
|
272 */ |
|
273 EXPORT_C void CPositioner::GetUpdateTimeOut(TTimeIntervalMicroSeconds& aUpdateTimeOut) const |
|
274 { |
|
275 iExtension->iParamObserver->GetUpdateTimeOut(aUpdateTimeOut); |
|
276 } |
|
277 |
|
278 /** |
|
279 * Called to inform the Location Server about the PSY default update timeout. The Location |
|
280 * Server may use this value to calculate the update timeout it uses. |
|
281 * When this method is called, it does not affect the currect request. So, it must be called in advance |
|
282 * before a request comes from the Location Server. |
|
283 * |
|
284 * @param aUpdateTimeOut [In] The PSY default location update timeout. |
|
285 * |
|
286 * @prototype |
|
287 */ |
|
288 EXPORT_C void CPositioner::SetPsyDefaultUpdateTimeOut(const TTimeIntervalMicroSeconds& aUpdateTimeOut) |
|
289 { |
|
290 iExtension->iParamObserver->SetPsyDefaultUpdateTimeOut(aUpdateTimeOut); |
|
291 } |
|
292 |
|
293 /** |
|
294 * Extends the active request timeout by the value specified. Only the current active request is |
|
295 * affected and the changes are not stored. That is the value returned by GetUpdateTimeOut and |
|
296 * the default PSY timeout set by SetPsyDefaultUpdateTimeOut are not changed. |
|
297 * This method is used, for example, to apply FNP lag. |
|
298 * |
|
299 * @param aUpdateTimeOut [In] The time to extend timeout for. |
|
300 * |
|
301 * @prototype |
|
302 */ |
|
303 EXPORT_C void CPositioner::ExtendUpdateTimeOut(const TTimeIntervalMicroSeconds& aAdditionalTime) |
|
304 { |
|
305 iExtension->iParamObserver->ExtendUpdateTimeOut(aAdditionalTime); |
|
306 } |
|
307 |
|
308 |
|
309 |
|
310 // End of File |