|
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: Engine class for Events Management UI. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <lbt.h> |
|
19 |
|
20 #include "evtevent.h" |
|
21 #include "evtmgmtuilbtadapter.h" |
|
22 #include "evteventmanager.h" |
|
23 #include "evtmgmtuiengine.h" |
|
24 #include "evtdebug.h" |
|
25 #include "evttoneaction.h" |
|
26 |
|
27 // Constants |
|
28 static const TInt KHighAccValue = 500; |
|
29 static const TInt KMidAccValue = 1500; |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // CEvtMgmtUiModel::ConstructL() |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 void CEvtMgmtUiEngine::ConstructL() |
|
36 { |
|
37 EVTUIDEBUG("+ CEvtMgmtUiEngine::ConstructL()" ); |
|
38 |
|
39 iEventManager = CEvtEventManager::NewL(); |
|
40 iEventManager->SetObserver(this); |
|
41 |
|
42 EVTUIDEBUG("Create lbtadapter object" ); |
|
43 iLbtAdapter = CEvtMgmtUiLbtAdapter::NewL(*this); |
|
44 |
|
45 EVTUIDEBUG("- CEvtMgmtUiEngine::ConstructL()" ); |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // CEvtMgmtUiEngine::NewL() |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 EXPORT_C CEvtMgmtUiEngine* CEvtMgmtUiEngine::NewL() |
|
53 { |
|
54 CEvtMgmtUiEngine* self = CEvtMgmtUiEngine::NewLC(); |
|
55 CleanupStack::Pop( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // CEvtMgmtUiEngine::NewLC() |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 EXPORT_C CEvtMgmtUiEngine* CEvtMgmtUiEngine::NewLC() |
|
65 { |
|
66 CEvtMgmtUiEngine* self = new( ELeave ) CEvtMgmtUiEngine(); |
|
67 CleanupStack::PushL( self ); |
|
68 self->ConstructL(); |
|
69 return self; |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // CEvtMgmtUiEngine::CEvtMgmtUiEngine() |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 CEvtMgmtUiEngine::CEvtMgmtUiEngine() |
|
77 { |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CEvtMgmtUiEngine::~CEvtMgmtUiEngine() |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 CEvtMgmtUiEngine::~CEvtMgmtUiEngine() |
|
85 { |
|
86 // Reseting the Observer array |
|
87 iObserverArray.Reset(); |
|
88 iObserverArray.Close(); |
|
89 |
|
90 delete iEventManager; |
|
91 iEventManager = NULL; |
|
92 |
|
93 delete iLbtAdapter; |
|
94 iLbtAdapter = NULL; |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // CEvtMgmtUiEngine::SetObserver() |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 EXPORT_C void CEvtMgmtUiEngine::SetObserver(MEvtMgmtUiEngineObserver* aObserver) |
|
102 { |
|
103 // Append the observer to the observer array waiting for notifications |
|
104 iObserverArray.Append( aObserver ); |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // CEvtMgmtUiEngine::RemoveObserver() |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 EXPORT_C void CEvtMgmtUiEngine::RemoveObserver(MEvtMgmtUiEngineObserver* aObserver) |
|
112 { |
|
113 // Remove the observer from receiving notifications |
|
114 for( TInt i = 0; i < iObserverArray.Count(); i++ ) |
|
115 { |
|
116 if ( iObserverArray[i] == aObserver ) |
|
117 { |
|
118 iObserverArray.Remove( i ); |
|
119 break; |
|
120 } |
|
121 } |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // CEvtMgmtUiEngine::EventL() |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 EXPORT_C CEvtEvent* CEvtMgmtUiEngine::EventL( TEvtEventId aId ) |
|
129 { |
|
130 EVTUIDEBUG1("+ CEvtMgmtUiEngine::EventL() event id = %d", aId); |
|
131 |
|
132 CEvtEvent* evt = NULL; |
|
133 if( aId!= 0 ) |
|
134 { |
|
135 evt = iEventManager->GetEventL( aId ); |
|
136 CleanupStack::PushL( evt ); |
|
137 RetrieveLocationL( aId, evt->Location() ); |
|
138 CleanupStack::Pop(); |
|
139 } |
|
140 else |
|
141 { |
|
142 evt = CEvtEvent::NewL(); |
|
143 } |
|
144 |
|
145 EVTUIDEBUG("- CEvtMgmtUiEngine::EventL()" ); |
|
146 return evt; |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // CEvtMgmtUiEngine::AddEventL() |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 EXPORT_C void CEvtMgmtUiEngine::AddEventL( CEvtEvent& aEvtEvent ) |
|
154 { |
|
155 EVTUIDEBUG("+ CEvtMgmtUiEngine::AddEventL()" ); |
|
156 |
|
157 CLbtTriggerEntry::TLbtTriggerState state; |
|
158 if(aEvtEvent.EventStatus()==EActive) |
|
159 { |
|
160 state = CLbtTriggerEntry::EStateEnabled; |
|
161 } |
|
162 else |
|
163 { |
|
164 state = CLbtTriggerEntry::EStateDisabled; |
|
165 } |
|
166 |
|
167 iEvent = &aEvtEvent; |
|
168 |
|
169 //create trigger |
|
170 if(iEvent->Subject().Compare(KNullDesC) == 0) |
|
171 iLbtAdapter->CreateTrigger(iEvent->Location(),TReal(iEvent->Radius()),_L("Un Named Location Event"), state ); |
|
172 else |
|
173 iLbtAdapter->CreateTrigger(iEvent->Location(),TReal(iEvent->Radius()),iEvent->Subject(), state ); |
|
174 |
|
175 EVTUIDEBUG("- CEvtMgmtUiEngine::AddEventL()" ); |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // CEvtMgmtUiEngine::ModifyEventL() |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 EXPORT_C void CEvtMgmtUiEngine::ModifyEventL( CEvtEvent& aEvtEvent, TEvtEventAttributeMask aEventAttributeMask ) |
|
183 { |
|
184 EVTUIDEBUG("+ CEvtMgmtUiEngine::ModifyEventL()" ); |
|
185 |
|
186 //if loc and/or state information are changed |
|
187 if( (aEventAttributeMask & EEvtEventAttributeStatus) == EEvtEventAttributeStatus || |
|
188 (aEventAttributeMask & EEvtEventAttributePlace) == EEvtEventAttributePlace || |
|
189 (aEventAttributeMask & EEvtEventAttributeRadius) == EEvtEventAttributeRadius ) |
|
190 { |
|
191 CLbtTriggerEntry::TLbtTriggerState state; |
|
192 if( aEvtEvent.EventStatus() == EActive ) |
|
193 { |
|
194 state = CLbtTriggerEntry::EStateEnabled; |
|
195 } |
|
196 else |
|
197 { |
|
198 state = CLbtTriggerEntry::EStateDisabled; |
|
199 } |
|
200 |
|
201 iEvent = &aEvtEvent; |
|
202 |
|
203 iLbtAdapter->UpdateTriggerL(aEvtEvent.EventId(), aEvtEvent.Location(), |
|
204 aEvtEvent.Radius(), state ); |
|
205 } |
|
206 else |
|
207 { |
|
208 iEventManager->UpdateEventL(aEvtEvent); |
|
209 |
|
210 if ( iObserverArray.Count()) |
|
211 { |
|
212 for( TInt i = 0; i < iObserverArray.Count(); i++ ) |
|
213 { |
|
214 iObserverArray[i]->NotifyEventChangeL( KErrNone,CEvtMgmtUiLbtAdapter::ELbtAdapterUpdate ); |
|
215 } |
|
216 } |
|
217 } |
|
218 |
|
219 EVTUIDEBUG("- CEvtMgmtUiEngine::ModifyEventL()" ); |
|
220 } |
|
221 |
|
222 // --------------------------------------------------------------------------- |
|
223 // CEvtMgmtUiEngine::DeleteEventL() |
|
224 // --------------------------------------------------------------------------- |
|
225 // |
|
226 EXPORT_C void CEvtMgmtUiEngine::DeleteEventL( TEvtEventId aEventId ) |
|
227 { |
|
228 EVTUIDEBUG1("+ CEvtMgmtUiEngine::DeleteEventL() event id =%d", aEventId ); |
|
229 TInt err = KErrNone; |
|
230 if( aEventId!=0 ) //if it is present in lbt database |
|
231 { |
|
232 iLbtAdapter->DeleteTriggerL( aEventId ); |
|
233 iEventManager->RemoveEventL( aEventId ); |
|
234 } |
|
235 |
|
236 if ( iObserverArray.Count()) |
|
237 { |
|
238 for( TInt i = 0; i < iObserverArray.Count(); i++ ) |
|
239 { |
|
240 iObserverArray[i]->NotifyEventChangeL( err,CEvtMgmtUiLbtAdapter::ELbtAdapterDelete ); |
|
241 } |
|
242 } |
|
243 EVTUIDEBUG("- CEvtMgmtUiEngine::DeleteEventL()" ); |
|
244 } |
|
245 |
|
246 // --------------------------------------------------------------------------- |
|
247 // CEvtMgmtUiEngine::DeleteEventsL() |
|
248 // --------------------------------------------------------------------------- |
|
249 // |
|
250 EXPORT_C void CEvtMgmtUiEngine::DeleteEventsL( const RArray<TEvtEventId>* aEvtIdArray ) |
|
251 { |
|
252 iEvtIdArray = aEvtIdArray; |
|
253 iLbtAdapter->DeleteTriggersL( *aEvtIdArray ); |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------------------------- |
|
257 // CEvtMgmtUiEngine::SetEventStateL() |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 EXPORT_C void CEvtMgmtUiEngine::SetEventStateL( TEvtEventStatus aEvtStatus, TEvtEventId aEventId) |
|
261 { |
|
262 EVTUIDEBUG("+ CEvtMgmtUiEngine::SetEventStateL()" ); |
|
263 TInt err = KErrNone; |
|
264 if( aEventId != 0 ) |
|
265 { |
|
266 switch(aEvtStatus) |
|
267 { |
|
268 case EActive: |
|
269 { |
|
270 iLbtAdapter->SetTriggerStateL( aEventId, CLbtTriggerEntry::EStateEnabled); |
|
271 iEventManager->UpdateEventStatusL( aEventId, aEvtStatus ); |
|
272 break; |
|
273 } |
|
274 case EDraft: |
|
275 { |
|
276 iLbtAdapter->SetTriggerStateL( aEventId, CLbtTriggerEntry::EStateDisabled ); |
|
277 iEventManager->UpdateEventStatusL( aEventId, aEvtStatus ); |
|
278 break; |
|
279 } |
|
280 case ECompleted: |
|
281 { |
|
282 iEventManager->UpdateEventStatusL( aEventId, aEvtStatus ); |
|
283 iLbtAdapter->SetTriggerStateL( aEventId, CLbtTriggerEntry::EStateDisabled ); |
|
284 break; |
|
285 } |
|
286 default: |
|
287 break; |
|
288 } |
|
289 } |
|
290 |
|
291 if ( iObserverArray.Count()) |
|
292 { |
|
293 for( TInt i = 0; i < iObserverArray.Count(); i++ ) |
|
294 { |
|
295 iObserverArray[i]->NotifyEventChangeL( err,CEvtMgmtUiLbtAdapter::ELbtAdapterSetTriggerState ); |
|
296 } |
|
297 } |
|
298 EVTUIDEBUG("- CEvtMgmtUiEngine::SetEventStateL()" ); |
|
299 } |
|
300 |
|
301 // --------------------------------------------------------------------------- |
|
302 // CEvtMgmtUiEngine::SetEventsStateL() |
|
303 // --------------------------------------------------------------------------- |
|
304 // |
|
305 EXPORT_C void CEvtMgmtUiEngine::SetEventsStateL( TEvtEventStatus aEvtStatus, const RArray<TEvtEventId>* aEvtIdArray ) |
|
306 { |
|
307 EVTUIDEBUG("+ CEvtMgmtUiEngine::SetEventsStateL()" ); |
|
308 iEvtIdArray = aEvtIdArray; |
|
309 iEvtStatus = aEvtStatus; |
|
310 switch(aEvtStatus) |
|
311 { |
|
312 case EActive: |
|
313 { |
|
314 iLbtAdapter->SetTriggersStateL( *aEvtIdArray, CLbtTriggerEntry::EStateEnabled); |
|
315 break; |
|
316 } |
|
317 case EDraft: |
|
318 case ECompleted: |
|
319 { |
|
320 iLbtAdapter->SetTriggersStateL( *aEvtIdArray, CLbtTriggerEntry::EStateDisabled); |
|
321 break; |
|
322 } |
|
323 default: |
|
324 break; |
|
325 } |
|
326 EVTUIDEBUG("- CEvtMgmtUiEngine::SetEventsStateL()" ); |
|
327 } |
|
328 |
|
329 // --------------------------------------------------------------------------- |
|
330 // CEvtMgmtUiEngine::UpdateModelL() |
|
331 // --------------------------------------------------------------------------- |
|
332 // |
|
333 EXPORT_C void CEvtMgmtUiEngine::UpdateModelL( RPointerArray<CEvtBasicEventInfo>& aEventsArray, |
|
334 TEvtEventStatusFilter aEventStatusFilter ) |
|
335 { |
|
336 EVTUIDEBUG("+ CEvtMgmtUiEngine::UpdateModelL()" ); |
|
337 |
|
338 if( aEventsArray.Count() ) |
|
339 { |
|
340 aEventsArray.ResetAndDestroy(); |
|
341 } |
|
342 |
|
343 if( aEventStatusFilter == EEvtFilterAll ) |
|
344 iEventManager->GetEventsL( aEventsArray ); |
|
345 else |
|
346 iEventManager->GetEventsL( static_cast<TEvtEventStatus>(aEventStatusFilter), aEventsArray ); |
|
347 |
|
348 EVTUIDEBUG("- CEvtMgmtUiEngine::UpdateModelL()" ); |
|
349 } |
|
350 |
|
351 // --------------------------------------------------------------------------- |
|
352 // CEvtMgmtUiEngine::SyncDbsL() |
|
353 // --------------------------------------------------------------------------- |
|
354 // |
|
355 EXPORT_C void CEvtMgmtUiEngine::SyncDbsL() |
|
356 { |
|
357 EVTUIDEBUG("+ CEvtMgmtUiEngine::SyncDbsL()" ); |
|
358 TInt err; |
|
359 |
|
360 // Handle the Enabled and Disabled Trigger list from LBT |
|
361 RArray<TLbtTriggerId> enabledtriggerList; |
|
362 RArray<TLbtTriggerId> disabledtriggerList; |
|
363 |
|
364 TRAP(err, iLbtAdapter->GetTriggerListL(disabledtriggerList, CLbtTriggerEntry::EStateDisabled ) ); |
|
365 if(err != KErrNone) |
|
366 { |
|
367 EVTUIDEBUG1("CEvtMgmtUiEngine::SyncDbsL:Error while retrieving trigger ids = %d", err); |
|
368 disabledtriggerList.Close(); |
|
369 enabledtriggerList.Close(); |
|
370 User::Leave( err ); |
|
371 } |
|
372 |
|
373 TRAP(err, iLbtAdapter->GetTriggerListL(enabledtriggerList, CLbtTriggerEntry::EStateEnabled ) ); |
|
374 if(err != KErrNone) |
|
375 { |
|
376 EVTUIDEBUG1("CEvtMgmtUiEngine::SyncDbsL:Error while retrieving trigger ids = %d", err); |
|
377 disabledtriggerList.Close(); |
|
378 enabledtriggerList.Close(); |
|
379 User::Leave( err ); |
|
380 } |
|
381 |
|
382 // Get Events list from EvtStorage |
|
383 RPointerArray<CEvtBasicEventInfo> eventsArray; |
|
384 RArray<TEvtEventId> removeArray; |
|
385 iEventManager->GetEventsL( eventsArray ); |
|
386 |
|
387 // Compute |
|
388 TInt count = eventsArray.Count(); |
|
389 TInt index=KErrNotFound; |
|
390 for(TInt i=0; i<count; i++) |
|
391 { |
|
392 if( eventsArray[i]->EventStatus() == EActive ) |
|
393 { |
|
394 if( KErrNotFound != (index = disabledtriggerList.Find(eventsArray[i]->EventId())) ) |
|
395 { |
|
396 iEventManager->UpdateEventStatusL( eventsArray[i]->EventId(), EDraft ); |
|
397 disabledtriggerList.Remove(index); |
|
398 } |
|
399 else if( KErrNotFound == (index = enabledtriggerList.Find(eventsArray[i]->EventId())) ) |
|
400 { |
|
401 removeArray.Append(eventsArray[i]->EventId()); |
|
402 } |
|
403 else |
|
404 { |
|
405 enabledtriggerList.Remove(index); |
|
406 } |
|
407 } |
|
408 else |
|
409 { |
|
410 if( KErrNotFound != (index = enabledtriggerList.Find(eventsArray[i]->EventId())) ) |
|
411 { |
|
412 iEventManager->UpdateEventStatusL( eventsArray[i]->EventId(), EActive ); |
|
413 enabledtriggerList.Remove(index); |
|
414 } |
|
415 else if( KErrNotFound == (index = disabledtriggerList.Find(eventsArray[i]->EventId())) ) |
|
416 { |
|
417 removeArray.Append(eventsArray[i]->EventId()); |
|
418 } |
|
419 else |
|
420 { |
|
421 disabledtriggerList.Remove(index); |
|
422 } |
|
423 } |
|
424 } |
|
425 |
|
426 // Update the Storage Db for removed triggers. |
|
427 if( removeArray.Count() != 0 ) |
|
428 iEventManager->RemoveEventsL( removeArray ); |
|
429 |
|
430 // Update the LBT Db for non existant triggers. |
|
431 count = enabledtriggerList.Count(); |
|
432 for(TInt i=0; i<count; i++) |
|
433 disabledtriggerList.Append(enabledtriggerList[i]); |
|
434 |
|
435 // We Nullify iEvtIdArray to ensure that observers are not notified of this delete triggers |
|
436 iEvtIdArray = NULL; |
|
437 if( disabledtriggerList.Count() != 0 ) |
|
438 iLbtAdapter->DeleteTriggersL( disabledtriggerList ); |
|
439 |
|
440 removeArray.Close(); |
|
441 disabledtriggerList.Close(); |
|
442 enabledtriggerList.Close(); |
|
443 eventsArray.ResetAndDestroy(); |
|
444 eventsArray.Close(); |
|
445 EVTUIDEBUG("- CEvtMgmtUiEngine::SyncDbsL()" ); |
|
446 } |
|
447 |
|
448 // --------------------------------------------------------------------------- |
|
449 // CEvtMgmtUiEngine::CalculateFiredAccuracyL() |
|
450 // --------------------------------------------------------------------------- |
|
451 // |
|
452 EXPORT_C TEvtFireAccuracy CEvtMgmtUiEngine::CalculateFiredAccuracyL( |
|
453 const TEvtEventId aEventId ) |
|
454 { |
|
455 EVTUIDEBUG1("+ CEvtMgmtUiEngine::CalculateFiredAccuracyL() - %d", aEventId ); |
|
456 TEvtFireAccuracy accuracy = ELowAccuracy; |
|
457 TReal32 distance(KMidAccValue+1); |
|
458 iLbtAdapter->GetFiredTriggerAccuracyL(aEventId, distance); |
|
459 |
|
460 EVTUIDEBUG1("= CalculateFiredAccuracyL() distance = %d", distance ); |
|
461 |
|
462 if( distance <= KHighAccValue ) |
|
463 accuracy = EHighAccuracy; |
|
464 else if( distance <= KMidAccValue ) |
|
465 accuracy = EMidAccuracy; |
|
466 else |
|
467 accuracy = ELowAccuracy; |
|
468 |
|
469 EVTUIDEBUG("- CEvtMgmtUiEngine::CalculateFiredAccuracyL()" ); |
|
470 return accuracy; |
|
471 } |
|
472 |
|
473 // --------------------------------------------------------------------------- |
|
474 // CEvtMgmtUiEngine::HandleFiredTriggerStateL() |
|
475 // --------------------------------------------------------------------------- |
|
476 // |
|
477 EXPORT_C void CEvtMgmtUiEngine::HandleFiredTriggerStateL( |
|
478 const TEvtEventId aEventId ) |
|
479 { |
|
480 EVTUIDEBUG1("+ CEvtMgmtUiEngine::HandleFiredTriggerStateL() - %d", aEventId ); |
|
481 CEvtEvent* evt = NULL; |
|
482 if( aEventId!= 0 ) |
|
483 { |
|
484 evt = iEventManager->GetEventL( aEventId ); |
|
485 if( evt ) |
|
486 { |
|
487 CleanupStack::PushL( evt ); |
|
488 if( !evt->Repeat() ) |
|
489 { |
|
490 SetEventStateL( ECompleted, aEventId ); |
|
491 } |
|
492 CleanupStack::PopAndDestroy( evt ); |
|
493 } |
|
494 } |
|
495 EVTUIDEBUG("- CEvtMgmtUiEngine::HandleFiredTriggerStateL()" ); |
|
496 } |
|
497 |
|
498 // --------------------------------------------------------------------------- |
|
499 // CEvtMgmtUiEngine::CancelRequest() |
|
500 // --------------------------------------------------------------------------- |
|
501 // |
|
502 EXPORT_C void CEvtMgmtUiEngine::CancelRequest() |
|
503 { |
|
504 EVTUIDEBUG("+ CEvtMgmtUiEngine::CancelRequest()" ); |
|
505 if( iLbtAdapter->IsActive() ) |
|
506 iLbtAdapter->CancelRequest(); |
|
507 EVTUIDEBUG("- CEvtMgmtUiEngine::CancelRequest()" ); |
|
508 } |
|
509 |
|
510 // --------------------------------------------------------------------------- |
|
511 // CEvtMgmtUiEngine::HandleStorageDbChangedL() |
|
512 // --------------------------------------------------------------------------- |
|
513 // |
|
514 void CEvtMgmtUiEngine::HandleStorageDbChangedL() |
|
515 { |
|
516 // Notify all observers |
|
517 if ( iObserverArray.Count()) |
|
518 { |
|
519 for( TInt i = 0; i < iObserverArray.Count(); i++ ) |
|
520 { |
|
521 iObserverArray[i]->NotifyModelChangeL(); |
|
522 } |
|
523 } |
|
524 } |
|
525 |
|
526 // --------------------------------------------------------------------------- |
|
527 // CEvtMgmtUiEngine::RetrieveLocationL() |
|
528 // --------------------------------------------------------------------------- |
|
529 // |
|
530 EXPORT_C void CEvtMgmtUiEngine::RetrieveLocationL( TEvtEventId aEventId, TCoordinate& aCoordinate ) |
|
531 { |
|
532 EVTUIDEBUG("+ CEvtMgmtUiEngine::RetrieveLocationL()" ); |
|
533 iLbtAdapter->RetrieveLocationL( aEventId, aCoordinate); |
|
534 EVTUIDEBUG("- CEvtMgmtUiEngine::RetrieveLocationL()" ); |
|
535 } |
|
536 |
|
537 // --------------------------------------------------------------------------- |
|
538 // CEvtMgmtUiEngine::NotifyLbtChangeL() |
|
539 // --------------------------------------------------------------------------- |
|
540 // |
|
541 void CEvtMgmtUiEngine::NotifyLbtChangeL(TLbtTriggerId & aTriggerId, TInt aState ) |
|
542 { |
|
543 EVTUIDEBUG("+ CEvtMgmtUiEngine::NotifyLbtChangeL()" ); |
|
544 |
|
545 // Notify all observers |
|
546 if ( iObserverArray.Count() ) |
|
547 { |
|
548 for( TInt i = 0; i < iObserverArray.Count(); i++ ) |
|
549 { |
|
550 iObserverArray[i]->NotifyEventChangeL( KErrNone,aState ); |
|
551 } |
|
552 } |
|
553 |
|
554 //iState = aState; |
|
555 switch(aState) |
|
556 { |
|
557 case CEvtMgmtUiLbtAdapter::ELbtAdapterCreate: |
|
558 { |
|
559 EVTUIDEBUG1("Trigger is created TriggerId=%d", aTriggerId ); |
|
560 |
|
561 // Update the the command Line argument (Temporarily commented) |
|
562 iLbtAdapter->UpdateCmdLineArgL( aTriggerId, aTriggerId ); |
|
563 |
|
564 // Add the new Event to the Local Db. |
|
565 if( iEvent->EventId() == 0 ) |
|
566 { |
|
567 iEvent->SetEventId( aTriggerId ); |
|
568 |
|
569 EVTUIDEBUG("========== Event Details ============================" ); |
|
570 TBuf<256>debug; |
|
571 debug.Copy( iEvent->Subject() ); |
|
572 EVTUIDEBUG1("Subject: %S", &debug); |
|
573 debug.Copy( iEvent->Place() ); |
|
574 EVTUIDEBUG1("Place: %S", &debug); |
|
575 EVTUIDEBUG1("Radius: %f", iEvent->Radius()); |
|
576 EVTUIDEBUG1("Repeat: %d", iEvent->Repeat()); |
|
577 |
|
578 CEvtToneAction* tone = CEvtToneAction::NewLC(); |
|
579 if( iEvent->HasAction() ) |
|
580 { |
|
581 tone->InternalizeL( iEvent->Action() ); |
|
582 debug.Copy( tone->FileName() ); |
|
583 EVTUIDEBUG1("Ringtone: %S", &debug); |
|
584 EVTUIDEBUG1("Audio Loop: %d", tone->ToneLoop()); |
|
585 } |
|
586 CleanupStack::PopAndDestroy(tone); |
|
587 |
|
588 EVTUIDEBUG("==========End Event Details ============================" ); |
|
589 iEventManager->AddEventL( *iEvent ); |
|
590 |
|
591 EVTUIDEBUG1( "Event is added to local database eventid = %d" , iEvent->EventId() ); |
|
592 } |
|
593 break; |
|
594 } |
|
595 case CEvtMgmtUiLbtAdapter::ELbtAdapterUpdate: |
|
596 { |
|
597 iEventManager->UpdateEventL(*iEvent); |
|
598 break; |
|
599 } |
|
600 case CEvtMgmtUiLbtAdapter::ELbtAdapterDeleteTriggers: |
|
601 { |
|
602 if(iEvtIdArray && iEvtIdArray->Count()) |
|
603 { |
|
604 iEventManager->RemoveEventsL( *iEvtIdArray ); |
|
605 iEvtIdArray = NULL; |
|
606 } |
|
607 else |
|
608 { |
|
609 return; // This condition is satisfied by DeleteTriggers in SyncDbL |
|
610 } |
|
611 break; |
|
612 } |
|
613 case CEvtMgmtUiLbtAdapter::ELbtAdapterSetTriggersState: |
|
614 { |
|
615 if(iEvtIdArray && iEvtIdArray->Count()) |
|
616 { |
|
617 iEventManager->UpdateEventsStatusL( *iEvtIdArray, iEvtStatus ); |
|
618 iEvtIdArray = NULL; |
|
619 } |
|
620 } |
|
621 break; |
|
622 default: |
|
623 { |
|
624 //error |
|
625 break; |
|
626 } |
|
627 } |
|
628 |
|
629 EVTUIDEBUG("- CEvtMgmtUiEngine::NotifyLbtChangeL()" ); |
|
630 } |
|
631 |
|
632 // --------------------------------------------------------------------------- |
|
633 // CEvtMgmtUiEngine::NotifyLbtError() |
|
634 // --------------------------------------------------------------------------- |
|
635 // |
|
636 void CEvtMgmtUiEngine::NotifyLbtError(TInt aErrorCode, TInt aState ) |
|
637 { |
|
638 EVTUIDEBUG1("+ CEvtMgmtUiEngine::NotifyLbtErrorL() error =%d", aErrorCode); |
|
639 // Notify all observers |
|
640 if ( iObserverArray.Count()) |
|
641 { |
|
642 for( TInt i = 0; i < iObserverArray.Count(); i++ ) |
|
643 { |
|
644 TRAP_IGNORE( iObserverArray[i]->NotifyEventChangeL( aErrorCode, aState )); |
|
645 } |
|
646 } |
|
647 |
|
648 EVTUIDEBUG("- CEvtMgmtUiEngine::NotifyLbtErrorL()" ); |
|
649 } |
|
650 |
|
651 // --------------------------------------------------------------------------- |
|
652 // CEvtMgmtUiEngine::NotifyTriggerChangeL() |
|
653 // --------------------------------------------------------------------------- |
|
654 // |
|
655 void CEvtMgmtUiEngine::NotifyTriggerChangeL( const TLbtTriggerId & aTriggerId, |
|
656 TLbtTriggerChangeType aType ) |
|
657 { |
|
658 EVTUIDEBUG("+ CEvtMgmtUiEngine::NotifyTriggerChangeL()" ); |
|
659 CLbtTriggerEntry::TLbtTriggerState state = CLbtTriggerEntry::EStateDisabled; |
|
660 CEvtEvent* evt = NULL; |
|
661 switch( aType ) |
|
662 { |
|
663 case ETriggerMultipleModified: |
|
664 SyncDbsL(); |
|
665 break; |
|
666 case ETriggerModified: |
|
667 state = iLbtAdapter->GetTriggerStateL( aTriggerId ); |
|
668 |
|
669 evt = iEventManager->GetEventL( aTriggerId ); |
|
670 CleanupStack::PushL( evt ); |
|
671 if( evt->EventStatus() == EActive ) |
|
672 { |
|
673 if( CLbtTriggerEntry::EStateDisabled == state ) |
|
674 { |
|
675 iEventManager->UpdateEventStatusL( evt->EventId(), ECompleted ); |
|
676 } |
|
677 } |
|
678 else |
|
679 { |
|
680 if( CLbtTriggerEntry::EStateEnabled == state ) |
|
681 { |
|
682 iEventManager->UpdateEventStatusL( evt->EventId(), EActive ); |
|
683 } |
|
684 } |
|
685 CleanupStack::PopAndDestroy( evt ); |
|
686 break; |
|
687 case ETriggerDeleted: |
|
688 iEventManager->RemoveEventL( aTriggerId ); |
|
689 break; |
|
690 default: |
|
691 break; |
|
692 } |
|
693 EVTUIDEBUG("- CEvtMgmtUiEngine::NotifyTriggerChangeL()" ); |
|
694 } |
|
695 //End of file |