|
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: It is adapter class to handle lbt operations |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef EVTMGMTUILBTADAPTER_H_ |
|
20 #define EVTMGMTUILBTADAPTER_H_ |
|
21 |
|
22 #include <e32base.h> // CBase |
|
23 |
|
24 #include <lbs.h> |
|
25 #include <lbtcommon.h> |
|
26 #include <lbtserver.h> |
|
27 #include <lbt.h> |
|
28 #include <lbttriggerchangeeventobserver.h> |
|
29 #include <lbttriggerdynamicinfo.h> |
|
30 |
|
31 #include "evtmgmtuilbtobserver.h" |
|
32 #include "evtdefs.h" |
|
33 |
|
34 class CLbtStartupTrigger; |
|
35 class CLbtGeoCircle; |
|
36 class CLbtTriggerConditionArea; |
|
37 class CLbtTriggerChangeEventNotifier; |
|
38 class CLbtTriggerFilterByAttribute; |
|
39 |
|
40 /** |
|
41 * @class CEvtMgmtUiLbtAdapter |
|
42 * Class that represents the adapter for lbt operation |
|
43 * |
|
44 * This class acts as an adapter for lbt engine. |
|
45 * It is used to create, update, delete, retrive triggers. |
|
46 * It is also used to change state of the trigger |
|
47 * |
|
48 * @since S60 v9.1 |
|
49 */ |
|
50 |
|
51 class CEvtMgmtUiLbtAdapter : public CActive, |
|
52 public MLbtTriggerChangeEventObserver |
|
53 { |
|
54 public: |
|
55 /* |
|
56 * state machine for lbt operation |
|
57 */ |
|
58 enum TLbtAdtapterState |
|
59 { |
|
60 /* |
|
61 * state for creating trigger |
|
62 */ |
|
63 ELbtAdapterCreate, |
|
64 |
|
65 /* |
|
66 * state for updating trigger |
|
67 */ |
|
68 ELbtAdapterUpdate, |
|
69 |
|
70 /* |
|
71 * state for updating command line argument of trigger |
|
72 */ |
|
73 ELbtAdapterUpdateCmdLineArg, |
|
74 |
|
75 /* |
|
76 * state for deleting trigger |
|
77 */ |
|
78 ELbtAdapterDelete, |
|
79 |
|
80 /* |
|
81 * state for deleting triggers |
|
82 */ |
|
83 ELbtAdapterDeleteTriggers, |
|
84 |
|
85 /* |
|
86 * state for changing state of the trigger |
|
87 */ |
|
88 ELbtAdapterSetTriggerState, |
|
89 |
|
90 /* |
|
91 * state for changing state of the triggers |
|
92 */ |
|
93 ELbtAdapterSetTriggersState, |
|
94 |
|
95 /** |
|
96 * Default option |
|
97 */ |
|
98 ENone |
|
99 }; |
|
100 |
|
101 public: // Constructor and destructor |
|
102 /** |
|
103 * Static Two phase constructor |
|
104 * |
|
105 */ |
|
106 static CEvtMgmtUiLbtAdapter* NewL(MEvtMgmtUiLbtObserver& aObserver); |
|
107 |
|
108 /** |
|
109 * Virtual destructor |
|
110 */ |
|
111 virtual ~CEvtMgmtUiLbtAdapter(); |
|
112 |
|
113 public: // new functions |
|
114 /* |
|
115 * It is the wrapper function to trap leaving function CreateTriggerL() |
|
116 * |
|
117 * @since S60 v9.1 |
|
118 * |
|
119 * @param [in] aCenter - location of the trigger. |
|
120 * @param [in] aRadiusInKiloMeters - radius of the trigger |
|
121 * @param [in] aTriggerName - name of the trigger |
|
122 * @param [in] aState - state of the trigger |
|
123 * @param [in] aTriggerId - trigger id of the trigger - |
|
124 * if it is zero, trigger will be created |
|
125 * othewise it will be updated |
|
126 * @param [in] aEventId - event id of the triggering event |
|
127 * It will be passed as command line argument. |
|
128 */ |
|
129 void CreateTrigger(const TCoordinate& aCenter, |
|
130 TReal aRadiusInKiloMeters, const TPtrC& aTriggerName, |
|
131 CLbtTriggerEntry::TLbtTriggerState aState ); |
|
132 |
|
133 |
|
134 /* |
|
135 * CEvtMgmtUiLbtAdapter ::UpdateCmdLineArgL() |
|
136 * Update the command line argument of the give trigger |
|
137 * @param[in] aTriggerId - id of the trigger |
|
138 * @param[in] aEventId - event id of the triggering event |
|
139 * It will be passed as command line argument. |
|
140 */ |
|
141 void UpdateCmdLineArgL( TLbtTriggerId aTriggerId, TEvtEventId aEventId ); |
|
142 |
|
143 /* |
|
144 * CEvtMgmtUiLbtAdapter ::UpdateLocationL() |
|
145 * Update the location of the give trigger |
|
146 * @param[in] aTriggerId - id of the trigger |
|
147 * @param [in] aCenter - location of the trigger. |
|
148 * @param [in] aRadiusInMeters - radius of the trigger |
|
149 * @param [in] aState - state of the trigger |
|
150 */ |
|
151 void UpdateTriggerL( TLbtTriggerId aTriggerId, |
|
152 const TCoordinate& aCenter, TReal aRadiusInKiloMeters, |
|
153 CLbtTriggerEntry::TLbtTriggerState aState ); |
|
154 /* |
|
155 * It is used to delete trigger from lbt database |
|
156 * |
|
157 * @since S60 v9.1 |
|
158 * |
|
159 * @param [in] aTriggerId - trigger id of the trigger |
|
160 * TODO: @param [in] aDeleteTriggerOnly remove |
|
161 * |
|
162 */ |
|
163 void DeleteTriggerL( TLbtTriggerId aTriggerId ); |
|
164 |
|
165 /* |
|
166 * It is used to delete triggers from lbt database |
|
167 * |
|
168 * @since S60 v9.1 |
|
169 * |
|
170 * @param [in] aTriggerIdList - id-list of triggers to be deleted. |
|
171 * |
|
172 */ |
|
173 void DeleteTriggersL( const RArray<TLbtTriggerId>& aTriggerIdList ); |
|
174 |
|
175 /* |
|
176 * It is used to change the state of the trigger. |
|
177 * |
|
178 * @since S60 v9.1 |
|
179 * |
|
180 * @param [in] aTriggerId - trigger id of the trigger |
|
181 * @param [in] aState - value to which given trigger's state should be changed |
|
182 * |
|
183 */ |
|
184 void SetTriggerStateL( TLbtTriggerId aTriggerId, |
|
185 CLbtTriggerEntry::TLbtTriggerState aState ); |
|
186 |
|
187 /* |
|
188 * It is used to change the state of the triggers. |
|
189 * |
|
190 * @since S60 v9.1 |
|
191 * |
|
192 * @param [in] aTriggerIdList - trigger id list of the triggers |
|
193 * @param [in] aState - value to which given trigger's state should be changed |
|
194 * |
|
195 */ |
|
196 void SetTriggersStateL( const RArray<TLbtTriggerId>& aTriggerIdList, |
|
197 CLbtTriggerEntry::TLbtTriggerState aState ) ; |
|
198 |
|
199 /* |
|
200 * It is used to retrieve location information of given trigger |
|
201 * from lbt database |
|
202 * |
|
203 * @since S60 v9.1 |
|
204 * |
|
205 * @param [in] aTriggerId - trigger id of the trigger |
|
206 * @param [out] aCenter - location details of the given trigger |
|
207 * |
|
208 */ |
|
209 void RetrieveLocationL( TLbtTriggerId aTriggerId, TCoordinate& aCenter ); |
|
210 |
|
211 /* |
|
212 * It is used to retrieve list of triggers created by EventsUi |
|
213 * |
|
214 * @since S60 v9.1 |
|
215 * |
|
216 * @param [in] triggerList - Reference to trigger array |
|
217 * @param [out] aState - Active/Inactive State of Trigger |
|
218 * |
|
219 */ |
|
220 void GetTriggerListL( RArray<TLbtTriggerId>& aTriggerList, |
|
221 CLbtTriggerEntry::TLbtTriggerState aState ); |
|
222 |
|
223 /* |
|
224 * It is used to retrieve list of triggers created by EventsUi |
|
225 * |
|
226 * @since S60 v9.1 |
|
227 * |
|
228 * @param [in] triggerList - Reference to trigger array |
|
229 * @param [out] aState - Valid/Invalid State of Trigger |
|
230 * |
|
231 */ |
|
232 void GetTriggerListL( RArray<TLbtTriggerId>& aTriggerList, |
|
233 TLbtTriggerDynamicInfo::TLbtTriggerValidity aValid ); |
|
234 /* |
|
235 * It is used to returns the Position Accuracy of Fired Trigger. |
|
236 * |
|
237 * @since S60 v9.1 |
|
238 * |
|
239 * @param [in] aPosition - Contains the Position Accuracy for Fired Trigger |
|
240 * @param [in] aTriggerId - Trigger Id |
|
241 * @param [out] TBool - Boolean value for Trigger Fired or Not. |
|
242 * |
|
243 */ |
|
244 TBool GetFiredPositionL( TPosition& aPosition, |
|
245 const TLbtTriggerId aTriggerId ); |
|
246 |
|
247 /* |
|
248 * It is used to get the distance accuracy for Fired trigger. |
|
249 * |
|
250 * @since S60 v9.1 |
|
251 * |
|
252 * @param [in] aTriggerId - Trigger Id |
|
253 * @param [out] aDistance - Accuracy in metres at which the trigger fired. |
|
254 * |
|
255 */ |
|
256 void GetFiredTriggerAccuracyL( TLbtTriggerId aTriggerId, TReal32& aDistance ); |
|
257 |
|
258 /* |
|
259 * It is used to retrieve State of given trigger |
|
260 * from lbt database |
|
261 * |
|
262 * @since S60 v9.1 |
|
263 * |
|
264 * @param [in] aTriggerId - trigger id of the trigger |
|
265 * @param [out] TLbtTriggerState - State of the given trigger |
|
266 * |
|
267 */ |
|
268 CLbtTriggerEntry::TLbtTriggerState GetTriggerStateL( |
|
269 TLbtTriggerId aTriggerId ); |
|
270 |
|
271 void CancelRequest(); |
|
272 |
|
273 public: //derived |
|
274 |
|
275 /* |
|
276 * Derived from CActive |
|
277 */ |
|
278 void RunL(); |
|
279 |
|
280 /* |
|
281 * Derived from CActive |
|
282 */ |
|
283 void DoCancel(); |
|
284 |
|
285 /* |
|
286 * Derived from CActive |
|
287 */ |
|
288 TInt RunError( TInt aError ); |
|
289 |
|
290 /* |
|
291 * Derived from MLbtTriggerChangeEventObserver |
|
292 */ |
|
293 void TriggerChangedL(const TLbtTriggerChangeEvent &aEvent); |
|
294 |
|
295 private: // Constructor |
|
296 /** |
|
297 * C++ Default constructor |
|
298 */ |
|
299 CEvtMgmtUiLbtAdapter(MEvtMgmtUiLbtObserver& aObserver); |
|
300 |
|
301 /** |
|
302 * Second phase of the two phase constructor |
|
303 */ |
|
304 void ConstructL(); |
|
305 |
|
306 private: // New functions |
|
307 /* |
|
308 * It is used to create of update trigger. |
|
309 * If trigger id is zero, it will create trigger. |
|
310 * If trigger id is non-zero, it will update the trigger. |
|
311 * |
|
312 * @since S60 v9.1 |
|
313 * |
|
314 * @param [in] aCenter - location of the trigger. |
|
315 * @param [in] aRadiusInKiloMeters - radius of the trigger |
|
316 * @param [in] aTriggerName - name of the trigger |
|
317 * @param [in] aState - state of the trigger |
|
318 * @param [in] aTriggerId - trigger id of the trigger - |
|
319 * if it is zero, trigger will be created |
|
320 * othewise it will be updated |
|
321 * @param [in] aEventId - event id of the triggering event |
|
322 * It will be passed as command line argument. |
|
323 */ |
|
324 void CreateTriggerL(const TCoordinate& aCenter, |
|
325 TReal aRadiusInKiloMeters, const TPtrC& aTriggerName, |
|
326 CLbtTriggerEntry::TLbtTriggerState aState ); |
|
327 |
|
328 /* |
|
329 * It is used to create the Codition Area for a trigger depending on the trigger type. |
|
330 * |
|
331 * @since S60 v9.1 |
|
332 * |
|
333 * @param [in] aCenter - location of the trigger. |
|
334 * @param [out] CLbtTriggerConditionArea - Condition Area for Trigger. |
|
335 */ |
|
336 CLbtTriggerConditionArea* GetConditionAreaL( |
|
337 const TCoordinate& aCenter, |
|
338 TReal aRadiusInKiloMeters ); |
|
339 private: |
|
340 /* |
|
341 * Handler to lbt session |
|
342 */ |
|
343 RLbt iLbt; |
|
344 |
|
345 /* |
|
346 * Handler to lbt session |
|
347 */ |
|
348 RLbt iLbtObserver; |
|
349 |
|
350 /* |
|
351 * Handler to lbt server |
|
352 */ |
|
353 RLbtServer iLbtServer; |
|
354 |
|
355 /** |
|
356 * Reference Trigger Change Notifier |
|
357 * |
|
358 */ |
|
359 CLbtTriggerChangeEventNotifier * iEventChangeObserver; |
|
360 |
|
361 /* |
|
362 * Id of a trigger |
|
363 */ |
|
364 TLbtTriggerId iTriggerId; |
|
365 |
|
366 /* |
|
367 * State machine's current state |
|
368 */ |
|
369 TLbtAdtapterState iState; |
|
370 |
|
371 /* |
|
372 * start up trigger object |
|
373 * owns |
|
374 */ |
|
375 CLbtStartupTrigger* iTrigger; |
|
376 |
|
377 /* |
|
378 * Observer to notify lbt changes or errors |
|
379 */ |
|
380 MEvtMgmtUiLbtObserver& iObserver; |
|
381 |
|
382 /* |
|
383 * Filter to do any lbt operation(Update State). |
|
384 * Does not own |
|
385 */ |
|
386 CLbtTriggerFilterByAttribute* iAttrFilter; |
|
387 }; |
|
388 |
|
389 #endif //EVTMGMTUILBTADAPTER_H_ |