89
|
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: Calendar alarm manager
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <calalarm.h>
|
|
20 |
#include <calentry.h>
|
|
21 |
#include <StringLoader.h>
|
|
22 |
#include <centralrepository.h>
|
|
23 |
#include <apgtask.h>
|
|
24 |
#include <aknViewAppUi.h>
|
|
25 |
#include <aknbutton.h>
|
|
26 |
#include <akntoolbar.h>
|
|
27 |
#include <missedalarm.h>
|
|
28 |
#include <missedalarmstore.h>
|
|
29 |
#include <missedalarmstorecrkeys.h>
|
|
30 |
#include <calenagendautils.h>
|
|
31 |
#include <calencommonui.rsg>
|
|
32 |
#include <CalendarInternalCRKeys.h>
|
|
33 |
#include <calendateutils.h>
|
|
34 |
#include <calencommands.hrh> // Calendar commands
|
|
35 |
#include <calencontext.h>
|
|
36 |
#include <calenservices.h>
|
|
37 |
#include <calentoolbar.h>
|
|
38 |
#include <GlobalWindowPriorities.h>
|
|
39 |
|
|
40 |
#include "calendarui_debug.h"
|
|
41 |
#include "calenalarmmanager.h"
|
|
42 |
#include "CalenUid.h"
|
|
43 |
#include "calencontroller.h"
|
|
44 |
#include "calendar.hrh"
|
|
45 |
#include "calenviewmanager.h"
|
|
46 |
#include "calensetting.h"
|
|
47 |
#include "calencontextfwlistener.h"
|
|
48 |
#include "CleanupResetAndDestroy.h"
|
|
49 |
#include "calenattachmentmodel.h"
|
|
50 |
|
|
51 |
static const TUint32 KMaxMissedAlarms = 10;
|
|
52 |
// Order of calendar window(at front) after Stop/Snooze of alarm from event viewer.
|
|
53 |
static const TInt KCalendarWindowOnFront(0);
|
|
54 |
|
|
55 |
// ----------------------------------------------------------------------------
|
|
56 |
// CCalenAlarmManager::NewL
|
|
57 |
// 1st phase of construction
|
|
58 |
// ----------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
CCalenAlarmManager* CCalenAlarmManager::NewL(CCalenController& aController)
|
|
61 |
{
|
|
62 |
TRACE_ENTRY_POINT;
|
|
63 |
|
|
64 |
CCalenAlarmManager* self = new( ELeave ) CCalenAlarmManager( aController );
|
|
65 |
CleanupStack::PushL( self );
|
|
66 |
self->ConstructL();
|
|
67 |
CleanupStack::Pop( self );
|
|
68 |
|
|
69 |
TRACE_EXIT_POINT;
|
|
70 |
return self;
|
|
71 |
}
|
|
72 |
|
|
73 |
// ----------------------------------------------------------------------------
|
|
74 |
// CCalenAlarmManager::CCalenAlarmManager
|
|
75 |
// C++ default Constructor.
|
|
76 |
// ----------------------------------------------------------------------------
|
|
77 |
//
|
|
78 |
CCalenAlarmManager::CCalenAlarmManager( CCalenController& aController )
|
|
79 |
: iController( aController ),iViewManager(aController.ViewManager()),
|
|
80 |
iContextFWListener(NULL)
|
|
81 |
{
|
|
82 |
TRACE_ENTRY_POINT;
|
|
83 |
TRACE_EXIT_POINT;
|
|
84 |
}
|
|
85 |
|
|
86 |
// ----------------------------------------------------------------------------
|
|
87 |
// CCalenAlarmManager::~CCalenAlarmManager
|
|
88 |
// Destructor.
|
|
89 |
// ----------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
CCalenAlarmManager::~CCalenAlarmManager()
|
|
92 |
{
|
|
93 |
TRACE_ENTRY_POINT;
|
|
94 |
|
|
95 |
if(iContextFWListener)
|
|
96 |
{
|
|
97 |
delete iContextFWListener;
|
|
98 |
iContextFWListener = NULL;
|
|
99 |
}
|
|
100 |
|
|
101 |
if(iCenRepChangeNotifier)
|
|
102 |
{
|
|
103 |
iCenRepChangeNotifier->StopListening();
|
|
104 |
delete iCenRepChangeNotifier;
|
|
105 |
}
|
|
106 |
delete iMissedAlarmStore;
|
|
107 |
|
|
108 |
|
|
109 |
iMissedAlarmList.Close();
|
|
110 |
|
|
111 |
|
|
112 |
TRACE_EXIT_POINT;
|
|
113 |
}
|
|
114 |
|
|
115 |
// ----------------------------------------------------------------------------
|
|
116 |
// CCalenAlarmManager::ConstructL
|
|
117 |
// 2nd phase of construction.
|
|
118 |
// (other items were commented in a header).
|
|
119 |
// ----------------------------------------------------------------------------
|
|
120 |
//
|
|
121 |
void CCalenAlarmManager::ConstructL()
|
|
122 |
{
|
|
123 |
TRACE_ENTRY_POINT;
|
|
124 |
|
|
125 |
iMissedAlarmStoreRepository = CRepository::NewL( KCRUidMissedAlarmStore );
|
|
126 |
|
|
127 |
// Create missed alarm store
|
|
128 |
iMissedAlarmStore = CMissedAlarmStore::NewL(*iMissedAlarmStoreRepository);
|
|
129 |
|
|
130 |
iCenRepChangeNotifier = CCenRepNotifyHandler::NewL( *this, *iMissedAlarmStoreRepository );
|
|
131 |
iCenRepChangeNotifier->StartListeningL();
|
|
132 |
|
|
133 |
iMissedAlarmStore->CountL(iMissedAlarmsCount);
|
|
134 |
if(iMissedAlarmsCount)
|
|
135 |
{
|
|
136 |
CreateMissedAlarmsListL();
|
|
137 |
}
|
|
138 |
|
|
139 |
TRACE_EXIT_POINT;
|
|
140 |
}
|
|
141 |
|
|
142 |
// ----------------------------------------------------------------------------
|
|
143 |
// CCalenAlarmManager::HandleCommandL
|
|
144 |
// Handles alarm manager commands.
|
|
145 |
// ----------------------------------------------------------------------------
|
|
146 |
//
|
|
147 |
TBool CCalenAlarmManager::HandleCommandL( const TCalenCommand& aCommand )
|
|
148 |
{
|
|
149 |
TRACE_ENTRY_POINT;
|
|
150 |
|
|
151 |
TBool continueCommand(EFalse);
|
|
152 |
switch( aCommand.Command() )
|
|
153 |
{
|
|
154 |
case ECalenMissedAlarmsView:
|
|
155 |
{
|
|
156 |
OnCmdMissedAlarmViewL();
|
|
157 |
}
|
|
158 |
break;
|
|
159 |
case ECalenMissedEventView:
|
|
160 |
{
|
|
161 |
OnCmdMissedEventViewL();
|
|
162 |
}
|
|
163 |
break;
|
|
164 |
case ECalenCmdClear:
|
|
165 |
{
|
|
166 |
OnCmdClearMissedAlarmL();
|
|
167 |
}
|
|
168 |
break;
|
|
169 |
case ECalenCmdClearAll:
|
|
170 |
{
|
|
171 |
OnCmdClearAllMissedAlarmsL();
|
|
172 |
}
|
|
173 |
break;
|
|
174 |
case ECalenCmdGotoCalendar:
|
|
175 |
{
|
|
176 |
// Handling of this command may be moved to viewmanager in future,
|
|
177 |
// as it is a general command not specific to missed alarms
|
|
178 |
OnCmdGoToCalendarL();
|
|
179 |
}
|
|
180 |
break;
|
|
181 |
case ECalenMissedAlarmsViewFromIdle:
|
|
182 |
{
|
|
183 |
RemoveAllViewedEventsL();
|
|
184 |
iViewManager.StartActiveStepL();
|
|
185 |
}
|
|
186 |
break;
|
|
187 |
case ECalenMissedEventViewFromIdle:
|
|
188 |
{
|
|
189 |
iLaunchedFromIdle = ETrue;
|
|
190 |
OnCmdLaunchFromIdleL();
|
|
191 |
}
|
|
192 |
break;
|
|
193 |
case ECalenEventViewFromAlarm:
|
|
194 |
{
|
|
195 |
TBool attachmentOpened = iController.Services().GetAttachmentData()->IsAttachmentOpen();
|
|
196 |
if(!attachmentOpened)
|
|
197 |
{
|
|
198 |
LaunchEventViewerL();
|
|
199 |
iViewManager.SetRepopulation(EFalse);
|
|
200 |
iController.ViewManager().RequestActivationL( KUidCalenEventView, KUidCalenShowAlarmCba );
|
|
201 |
}
|
|
202 |
}
|
|
203 |
break;
|
|
204 |
case ECalenEventViewFromAlarmStopOnly:
|
|
205 |
{
|
|
206 |
LaunchEventViewerL();
|
|
207 |
iViewManager.SetRepopulation(EFalse);
|
|
208 |
iController.ViewManager().RequestActivationL( KUidCalenEventView, KUidCalenShowAlarmStopOnlyCba );
|
|
209 |
}
|
|
210 |
break;
|
|
211 |
default:
|
|
212 |
break;
|
|
213 |
}
|
|
214 |
|
|
215 |
TRACE_EXIT_POINT;
|
|
216 |
return continueCommand;
|
|
217 |
}
|
|
218 |
|
|
219 |
// ----------------------------------------------------------------------------
|
|
220 |
// CCalenAlarmManager::CalenCommandHandlerExtensionL
|
|
221 |
// Dummy implementation.
|
|
222 |
// (other items were commented in a header).
|
|
223 |
// ----------------------------------------------------------------------------
|
|
224 |
//
|
|
225 |
TAny* CCalenAlarmManager::CalenCommandHandlerExtensionL( TUid /*aExtensionUid*/ )
|
|
226 |
{
|
|
227 |
TRACE_ENTRY_POINT;
|
|
228 |
TRACE_EXIT_POINT;
|
|
229 |
return NULL;
|
|
230 |
}
|
|
231 |
|
|
232 |
// ----------------------------------------------------------------------------
|
|
233 |
// CCalenAlarmManager::HandleNotification
|
|
234 |
// Calls back when notifications that it has been registered for are broadcast
|
|
235 |
// ----------------------------------------------------------------------------
|
|
236 |
//
|
|
237 |
void CCalenAlarmManager::HandleNotification(const TCalenNotification aNotification )
|
|
238 |
{
|
|
239 |
TRACE_ENTRY_POINT;
|
|
240 |
|
|
241 |
PIM_TRAPD_HANDLE( HandleNotificationL( aNotification ) );
|
|
242 |
|
|
243 |
TRACE_EXIT_POINT;
|
|
244 |
}
|
|
245 |
|
|
246 |
// ----------------------------------------------------------------------------
|
|
247 |
// CCalenAlarmManager::HandleNotificationL
|
|
248 |
// Called from HandleNotification() when notifications that it has been
|
|
249 |
// registered for are broadcast
|
|
250 |
// ----------------------------------------------------------------------------
|
|
251 |
//
|
|
252 |
void CCalenAlarmManager::HandleNotificationL( TCalenNotification aNotification )
|
|
253 |
{
|
|
254 |
TRACE_ENTRY_POINT;
|
|
255 |
|
|
256 |
switch(aNotification)
|
|
257 |
{
|
|
258 |
case ECalenNotifyLostAlarms:
|
|
259 |
{
|
|
260 |
HandleNotifyLostAlarmsL();
|
|
261 |
}
|
|
262 |
break;
|
|
263 |
case ECalenNotifyEntryDeleted:
|
|
264 |
case ECalenNotifyInstanceDeleted:
|
|
265 |
{
|
|
266 |
HandleBackEventL();
|
|
267 |
HandleEntryDeleteNotificationL();
|
|
268 |
}
|
|
269 |
break;
|
|
270 |
case ECalenNotifyEntrySaved:
|
|
271 |
{
|
|
272 |
HandleEntryDeleteNotificationL();
|
|
273 |
}
|
|
274 |
break;
|
|
275 |
case ECalenNotifyMultipleEntriesDeleted:
|
|
276 |
{
|
|
277 |
// clear all the missed alarms from central repository
|
|
278 |
iMissedAlarmStore->RemoveAllL();
|
|
279 |
|
|
280 |
// clear the missed alarms list
|
|
281 |
if(iMissedAlarmList.Count())
|
|
282 |
{
|
|
283 |
iMissedAlarmList.Close();
|
|
284 |
}
|
|
285 |
}
|
|
286 |
break;
|
|
287 |
case ECalenNotifyMissedAlarmViewClosed:
|
|
288 |
{
|
|
289 |
HandleMissedAlarmViewClosedL();
|
|
290 |
}
|
|
291 |
break;
|
|
292 |
case ECalenNotifyClearMissedAlarms:
|
|
293 |
{
|
|
294 |
TVwsViewId activeView;
|
|
295 |
iController.AppUi().GetActiveViewId(activeView);
|
|
296 |
if(activeView.iViewUid == KUidCalenMissedAlarmsView)
|
|
297 |
{
|
|
298 |
OnCmdClearAllMissedAlarmsL();
|
|
299 |
}
|
|
300 |
}
|
|
301 |
break;
|
|
302 |
case ECalenNotifyMissedEventViewClosed:
|
|
303 |
{
|
|
304 |
HandleMissedEventViewClosedL();
|
|
305 |
}
|
|
306 |
break;
|
|
307 |
case ECalenNotifySystemTimeChanged:
|
|
308 |
{
|
|
309 |
if(iMissedAlarmList.Count())
|
|
310 |
{
|
|
311 |
HandleSystemTimeChangedL();
|
|
312 |
}
|
|
313 |
}
|
|
314 |
break;
|
|
315 |
case ECalenNotifyAlarmStopped:
|
|
316 |
{
|
|
317 |
// notify alarmui through the context framework
|
|
318 |
iContextFWListener->AlarmStopL();
|
|
319 |
}
|
|
320 |
break;
|
|
321 |
case ECalenNotifyAlarmSnoozed:
|
|
322 |
{
|
|
323 |
// notify alarmui through the context framework
|
|
324 |
iContextFWListener->AlarmSnoozeL();
|
|
325 |
}
|
|
326 |
break;
|
|
327 |
case ECalenNotifyEntryClosed:
|
|
328 |
{
|
|
329 |
HandleBackEventL();
|
|
330 |
}
|
|
331 |
break;
|
|
332 |
|
|
333 |
case ECalenNotifyAppForegrounded:
|
|
334 |
{
|
|
335 |
if( iController.IsFasterAppFlagEnabled() )
|
|
336 |
{
|
|
337 |
iController.SetFasterAppFlag( EFalse );
|
|
338 |
}
|
|
339 |
}
|
|
340 |
break;
|
|
341 |
default:
|
|
342 |
break;
|
|
343 |
}
|
|
344 |
|
|
345 |
TRACE_EXIT_POINT;
|
|
346 |
}
|
|
347 |
|
|
348 |
// ----------------------------------------------------------------------------
|
|
349 |
// CCalenAlarmManager::HandleNotifyGeneric
|
|
350 |
// From MCenRepNotifyHandlerCallback
|
|
351 |
// Generic notification that one of our central repository keys has changed
|
|
352 |
// If any keys change we broadcast a settings changed notification
|
|
353 |
// (other items were commented in a header).
|
|
354 |
// ----------------------------------------------------------------------------
|
|
355 |
//
|
|
356 |
void CCalenAlarmManager::HandleNotifyGeneric( TUint32 aCenrepKeyId )
|
|
357 |
{
|
|
358 |
TRACE_ENTRY_POINT;
|
|
359 |
|
|
360 |
if( aCenrepKeyId <= KMissedAlarmsMaxValue)
|
|
361 |
{
|
|
362 |
iController.BroadcastNotification(ECalenNotifyLostAlarms);
|
|
363 |
}
|
|
364 |
|
|
365 |
TRACE_EXIT_POINT;
|
|
366 |
}
|
|
367 |
|
|
368 |
// ----------------------------------------------------------------------------
|
|
369 |
// CCalenAlarmManager::CreateMissedAlarmsListL
|
|
370 |
// Creates missed alarms list
|
|
371 |
// ----------------------------------------------------------------------------
|
|
372 |
void CCalenAlarmManager::CreateMissedAlarmsListL()
|
|
373 |
{
|
|
374 |
TRACE_ENTRY_POINT;
|
|
375 |
|
|
376 |
if(iMissedAlarmList.Count())
|
|
377 |
{
|
|
378 |
iMissedAlarmList.Reset();
|
|
379 |
}
|
|
380 |
|
|
381 |
RPointerArray<CMissedAlarm> missedAlarmStorelist;
|
|
382 |
CleanupResetAndDestroyPushL( missedAlarmStorelist );
|
|
383 |
|
|
384 |
iMissedAlarmStore->GetL(missedAlarmStorelist);
|
|
385 |
|
|
386 |
TCalenInstanceId instanceId;
|
|
387 |
TInt entryLocalUid;
|
|
388 |
TTime instanceTime;
|
|
389 |
|
|
390 |
for(TInt index=0;index < missedAlarmStorelist.Count();index++)
|
|
391 |
{
|
|
392 |
CMissedAlarm* missedAlarm = missedAlarmStorelist[index];
|
|
393 |
entryLocalUid = missedAlarm->iLuid;
|
|
394 |
instanceTime = missedAlarm->iInstanceTime;
|
|
395 |
|
|
396 |
CCalSession *session = NULL;
|
|
397 |
TRAPD(err,session = &iController.Services().SessionL( missedAlarm->iCalFileName ));
|
|
398 |
//missed alarm belongs to existing calendar
|
|
399 |
if(err != KErrNotFound)
|
|
400 |
{
|
|
401 |
// pack instance ids of the missed alarm instances
|
|
402 |
TRAP_IGNORE(instanceId = TCalenInstanceId::CreateL( entryLocalUid, instanceTime, 0 ));
|
|
403 |
instanceId.iColId = session->CollectionIdL();
|
|
404 |
iMissedAlarmList.Append(instanceId);
|
|
405 |
}
|
|
406 |
else
|
|
407 |
{
|
|
408 |
//missed alarm does not belong to any calendar so delete it, since user has deleted the calendar
|
|
409 |
iMissedAlarmStore->RemoveL(*missedAlarm);
|
|
410 |
}
|
|
411 |
}
|
|
412 |
|
|
413 |
CleanupStack::PopAndDestroy(); // missedAlarmStorelist
|
|
414 |
|
|
415 |
TRACE_EXIT_POINT;
|
|
416 |
}
|
|
417 |
|
|
418 |
// ----------------------------------------------------------------------------
|
|
419 |
// CCalenAlarmManager::GetMissedAlarmsList
|
|
420 |
// Get Missed alarms list with viewed inf
|
|
421 |
// ----------------------------------------------------------------------------
|
|
422 |
void CCalenAlarmManager::GetMissedAlarmsList(RArray<TCalenInstanceId>& aMissedAlarmsList)
|
|
423 |
{
|
|
424 |
TRACE_ENTRY_POINT;
|
|
425 |
|
|
426 |
if(!iMissedAlarmList.Count())
|
|
427 |
{
|
|
428 |
TRAP_IGNORE(CreateMissedAlarmsListL());
|
|
429 |
}
|
|
430 |
|
|
431 |
for(TInt index=0;index<iMissedAlarmList.Count();index++)
|
|
432 |
{
|
|
433 |
aMissedAlarmsList.Append(iMissedAlarmList[index]);
|
|
434 |
}
|
|
435 |
|
|
436 |
TRACE_EXIT_POINT;
|
|
437 |
}
|
|
438 |
|
|
439 |
// ----------------------------------------------------------------------------
|
|
440 |
// CCalenAlarmManager::StartAlarmContextListener
|
|
441 |
// Creates CCalenContextFWListener object for Alarm
|
|
442 |
// ----------------------------------------------------------------------------
|
|
443 |
void CCalenAlarmManager::StartAlarmContextListenerL()
|
|
444 |
{
|
|
445 |
TRACE_ENTRY_POINT;
|
|
446 |
|
|
447 |
//if in alarm viewer mode:
|
|
448 |
iContextFWListener = CCalenContextFWListener::NewL(*this);
|
|
449 |
// raise calendar priority as the topmost window (alarmui is left at the background)
|
|
450 |
RWindowGroup& windowGroup = CCoeEnv::Static()->RootWin();
|
|
451 |
iOrigWGPos = windowGroup.OrdinalPosition();
|
|
452 |
iOrigWGPrio = windowGroup.OrdinalPriority();
|
|
453 |
// move the window on top of the alarm notification window!
|
|
454 |
PIM_ASSERT( windowGroup.SetOrdinalPositionErr( 0, ECoeWinPriorityAlwaysAtFront +KGlobalWindowPriority_Alarm +1 ) );
|
|
455 |
|
|
456 |
TRACE_EXIT_POINT;
|
|
457 |
}
|
|
458 |
|
|
459 |
// ----------------------------------------------------------------------------
|
|
460 |
// CCalenAlarmManager::StopAlarmContextListener
|
|
461 |
// Destroys CCalenContextFWListener object for Alarm
|
|
462 |
// ----------------------------------------------------------------------------
|
|
463 |
void CCalenAlarmManager::StopAlarmContextListener(TBool aCloseEventView)
|
|
464 |
{
|
|
465 |
TRACE_ENTRY_POINT;
|
|
466 |
|
|
467 |
// restore window group priority
|
|
468 |
RWindowGroup& windowGroup = CCoeEnv::Static()->RootWin();
|
|
469 |
PIM_ASSERT( windowGroup.SetOrdinalPositionErr( KCalendarWindowOnFront, iOrigWGPrio ) );
|
|
470 |
|
|
471 |
//Close Event View
|
|
472 |
if(aCloseEventView)
|
|
473 |
{
|
|
474 |
MCalenToolbar* toolbarImpl = iController.ViewManager().ToolbarOrNull();
|
|
475 |
if(toolbarImpl) // If toolbar exists
|
|
476 |
{
|
|
477 |
CAknToolbar& toolbar = toolbarImpl->Toolbar();
|
|
478 |
|
|
479 |
// Remove the viewer toolbar buttons
|
|
480 |
toolbar.RemoveItem(ECalenDeleteCurrentEntry); // Delete button
|
|
481 |
toolbar.RemoveItem(ECalenEditCurrentEntry); // Edit button
|
|
482 |
toolbar.RemoveItem(ECalenSend); // Send button
|
|
483 |
}
|
|
484 |
iController.BroadcastNotification( ECalenNotifyEntryClosed );
|
|
485 |
}
|
|
486 |
|
|
487 |
TRACE_EXIT_POINT;
|
|
488 |
}
|
|
489 |
|
|
490 |
//---------------------------------------------------------
|
|
491 |
// CCalenAlarmManager::StopContextListenerForAutoSnooze
|
|
492 |
// Destroys CCalenContextFWListener object for autosnooze case
|
|
493 |
//---------------------------------------------------------
|
|
494 |
//
|
|
495 |
void CCalenAlarmManager::StopContextListenerForAutoSnooze()
|
|
496 |
{
|
|
497 |
TRACE_ENTRY_POINT;
|
|
498 |
|
|
499 |
// restore window group priority
|
|
500 |
RWindowGroup& windowGroup = CCoeEnv::Static()->RootWin();
|
|
501 |
PIM_ASSERT( windowGroup.SetOrdinalPositionErr( KCalendarWindowOnFront, iOrigWGPrio ) );
|
|
502 |
|
|
503 |
// After auto snooze, stop the alarm and open the event viewer in normal mode.
|
|
504 |
iController.BroadcastNotification( ECalenNotifyStopAlarm );
|
|
505 |
|
|
506 |
TRACE_EXIT_POINT;
|
|
507 |
}
|
|
508 |
|
|
509 |
// ----------------------------------------------------------------------------
|
|
510 |
// CCalenAlarmManager::MissedAlarmStore
|
|
511 |
// Returns a reference to the Missed Alarm Store
|
|
512 |
// ----------------------------------------------------------------------------
|
|
513 |
CMissedAlarmStore* CCalenAlarmManager::MissedAlarmStore()
|
|
514 |
{
|
|
515 |
TRACE_ENTRY_POINT;
|
|
516 |
TRACE_EXIT_POINT;
|
|
517 |
|
|
518 |
return iMissedAlarmStore;
|
|
519 |
}
|
|
520 |
|
|
521 |
//---------------------------------------------------------
|
|
522 |
// CCalenAlarmManager::OnCmdMissedAlarmViewL
|
|
523 |
// Handles the command ECalenMissedAlarmsView
|
|
524 |
//---------------------------------------------------------
|
|
525 |
//
|
|
526 |
void CCalenAlarmManager::OnCmdMissedAlarmViewL()
|
|
527 |
{
|
|
528 |
TRACE_ENTRY_POINT;
|
|
529 |
|
|
530 |
iViewManager.SetRepopulation(EFalse);
|
|
531 |
|
|
532 |
if(iMissedAlarmsCount == 1)
|
|
533 |
{
|
|
534 |
//Set the Context for missed event view
|
|
535 |
SetContextForMissedEventViewL();
|
|
536 |
|
|
537 |
iMissedAlarmStore->RemoveAllL();
|
|
538 |
|
|
539 |
iMissedAlarmList.Close();
|
|
540 |
|
|
541 |
iPreviousToMissedEventView.iViewUid = iViewManager.CurrentView();
|
|
542 |
|
|
543 |
// activate missed event view
|
|
544 |
iViewManager.RequestActivationL( KUidCalenMissedEventView );
|
|
545 |
}
|
|
546 |
else if(iMissedAlarmsCount > 1)
|
|
547 |
{
|
|
548 |
iPreviousToMissedAlarmView.iViewUid = iViewManager.CurrentView();
|
|
549 |
|
|
550 |
// activate missed alarms view
|
|
551 |
iViewManager.RequestActivationL( KUidCalenMissedAlarmsView,
|
|
552 |
KUidCalenShowBackCba );
|
|
553 |
}
|
|
554 |
|
|
555 |
TRACE_EXIT_POINT
|
|
556 |
}
|
|
557 |
|
|
558 |
//---------------------------------------------------------
|
|
559 |
// CCalenAlarmManager::OnCmdMissedEventViewL
|
|
560 |
// Handles the command ECalenMissedEventView
|
|
561 |
//---------------------------------------------------------
|
|
562 |
//
|
|
563 |
void CCalenAlarmManager::OnCmdMissedEventViewL()
|
|
564 |
{
|
|
565 |
TRACE_ENTRY_POINT;
|
|
566 |
|
|
567 |
//get the context
|
|
568 |
MCalenContext &context = iController.Services().Context();
|
|
569 |
TInt missedAlarmEntryUid = context.InstanceId().iEntryLocalUid;
|
|
570 |
TCalCollectionId colid = context.InstanceId().iColId;
|
|
571 |
|
|
572 |
ClearOneMissedAlarmL(missedAlarmEntryUid, colid);
|
|
573 |
SetMissedAlarmEventAsViewed();
|
|
574 |
|
|
575 |
iPreviousToMissedEventView.iViewUid = iViewManager.CurrentView();
|
|
576 |
|
|
577 |
iViewManager.SetRepopulation(EFalse);
|
|
578 |
|
|
579 |
// activate missed event view
|
|
580 |
iViewManager.RequestActivationL( KUidCalenMissedEventView, KUidCalenShowBackCba );
|
|
581 |
|
|
582 |
TRACE_EXIT_POINT;
|
|
583 |
}
|
|
584 |
|
|
585 |
//---------------------------------------------------------
|
|
586 |
// CCalenAlarmManager::OnCmdClearMissedAlarmL
|
|
587 |
// Clears a missed alarm
|
|
588 |
//---------------------------------------------------------
|
|
589 |
//
|
|
590 |
void CCalenAlarmManager::OnCmdClearMissedAlarmL()
|
|
591 |
{
|
|
592 |
TRACE_ENTRY_POINT;
|
|
593 |
|
|
594 |
// get the context
|
|
595 |
MCalenContext &context = iController.Services().Context();
|
|
596 |
TInt missedAlarmEntryUid = context.InstanceId().iEntryLocalUid;
|
|
597 |
TCalCollectionId colid = context.InstanceId().iColId;
|
|
598 |
// clear missed alarm from cenrep
|
|
599 |
|
|
600 |
ClearOneMissedAlarmL( missedAlarmEntryUid, colid );
|
|
601 |
for(TInt index = 0;index < iMissedAlarmList.Count();index++)
|
|
602 |
{
|
|
603 |
if( ( missedAlarmEntryUid == iMissedAlarmList[index].iEntryLocalUid ) &&
|
|
604 |
( colid == iMissedAlarmList[index].iColId ) )
|
|
605 |
{
|
|
606 |
// remove from missed alarms list
|
|
607 |
iMissedAlarmList.Remove(index);
|
|
608 |
break;
|
|
609 |
}
|
|
610 |
}
|
|
611 |
|
|
612 |
// Refresh the missed alarm view
|
|
613 |
iViewManager.StartActiveStepL();
|
|
614 |
|
|
615 |
TRACE_EXIT_POINT;
|
|
616 |
}
|
|
617 |
|
|
618 |
//---------------------------------------------------------
|
|
619 |
// CCalenAlarmManager::OnCmdClearAllMissedAlarmsL
|
|
620 |
// Clears all missed alarms
|
|
621 |
//---------------------------------------------------------
|
|
622 |
//
|
|
623 |
void CCalenAlarmManager::OnCmdClearAllMissedAlarmsL()
|
|
624 |
{
|
|
625 |
TRACE_ENTRY_POINT;
|
|
626 |
|
|
627 |
// Clear all the missed alarm events from cenrep
|
|
628 |
|
|
629 |
RPointerArray<CMissedAlarm> missedAlarmArray;
|
|
630 |
CleanupResetAndDestroyPushL( missedAlarmArray );
|
|
631 |
iMissedAlarmStore->GetL(missedAlarmArray);
|
|
632 |
for(TInt index = 0;index < missedAlarmArray.Count();index++)
|
|
633 |
{
|
|
634 |
// remove from cenrep
|
|
635 |
iMissedAlarmStore->RemoveL(*missedAlarmArray[index]);
|
|
636 |
}
|
|
637 |
|
|
638 |
CleanupStack::PopAndDestroy(); // aMissedAlarmArray
|
|
639 |
|
|
640 |
if(iMissedAlarmList.Count())
|
|
641 |
{
|
|
642 |
iMissedAlarmList.Close();
|
|
643 |
}
|
|
644 |
|
|
645 |
// Refresh the missed alarm view
|
|
646 |
iViewManager.StartActiveStepL();
|
|
647 |
|
|
648 |
TRACE_EXIT_POINT;
|
|
649 |
}
|
|
650 |
|
|
651 |
//---------------------------------------------------------
|
|
652 |
// CCalenAlarmManager::OnCmdGoToCalendar
|
|
653 |
// Handles goto calendar command in Missed alarm View
|
|
654 |
//---------------------------------------------------------
|
|
655 |
//
|
|
656 |
void CCalenAlarmManager::OnCmdGoToCalendarL()
|
|
657 |
{
|
|
658 |
TRACE_ENTRY_POINT;
|
|
659 |
|
|
660 |
iViewManager.SetRepopulation(EFalse);
|
|
661 |
|
|
662 |
// remove all the viewed events
|
|
663 |
RemoveAllViewedEventsL();
|
|
664 |
|
|
665 |
// if previous view set,activate the previous view
|
|
666 |
if(iPreviousToMissedAlarmView.iViewUid != KNullUid)
|
|
667 |
{
|
|
668 |
iViewManager.RequestActivationL(iPreviousToMissedAlarmView.iViewUid);
|
|
669 |
}
|
|
670 |
else
|
|
671 |
{
|
|
672 |
// if previous view is not set,activate the default view of the calendar
|
|
673 |
TUid defViewUid = iController.Settings().DefaultView();
|
|
674 |
iViewManager.RequestActivationL(defViewUid);
|
|
675 |
}
|
|
676 |
|
|
677 |
TRACE_EXIT_POINT;
|
|
678 |
}
|
|
679 |
|
|
680 |
// ----------------------------------------------------------------------------
|
|
681 |
// CCalenAlarmManager::OnCmdLaunchFromIdleL
|
|
682 |
// Handles the command ECalenMissedEventViewFromIdle
|
|
683 |
// for intialising the data before launching the
|
|
684 |
// missed event view from Idle(soft notification/indicator
|
|
685 |
// ----------------------------------------------------------------------------
|
|
686 |
//
|
|
687 |
void CCalenAlarmManager::OnCmdLaunchFromIdleL()
|
|
688 |
{
|
|
689 |
TRACE_ENTRY_POINT;
|
|
690 |
|
|
691 |
//get the missed alarms list from store
|
|
692 |
RPointerArray<CMissedAlarm> aMissedAlarmArray;
|
|
693 |
CleanupResetAndDestroyPushL( aMissedAlarmArray );
|
|
694 |
iMissedAlarmStore->GetL(aMissedAlarmArray);
|
|
695 |
if (aMissedAlarmArray.Count())
|
|
696 |
{
|
|
697 |
CCalSession &session = iController.Services().SessionL(aMissedAlarmArray[0]->iCalFileName);
|
|
698 |
CCalEntry* entry = iController.Services().EntryViewL(session.CollectionIdL())->FetchL(
|
|
699 |
aMissedAlarmArray[0]->iLuid);
|
|
700 |
User::LeaveIfNull( entry );
|
|
701 |
CleanupStack::PushL( entry );
|
|
702 |
|
|
703 |
TTime instanceTime;
|
|
704 |
TCalTime inscaltime;
|
|
705 |
instanceTime = CalenAgendaUtils::EntryTimeL( *entry );
|
|
706 |
inscaltime.SetTimeLocalL( instanceTime );
|
|
707 |
|
|
708 |
// set the context
|
|
709 |
MCalenContext &context = iController.Services().Context();
|
|
710 |
TCalenInstanceId id = TCalenInstanceId::CreateL( *entry, inscaltime );
|
|
711 |
id.iColId = session.CollectionIdL();
|
|
712 |
context.SetInstanceIdL( id, context.ViewId() );
|
|
713 |
CleanupStack::PopAndDestroy( entry );
|
|
714 |
iMissedAlarmList.Remove(0); //Clear the alarm list
|
|
715 |
iMissedAlarmStore->RemoveL(*aMissedAlarmArray[0]);
|
|
716 |
}
|
|
717 |
CleanupStack::PopAndDestroy(); // aMissedAlarmArray
|
|
718 |
|
|
719 |
iViewManager.StartActiveStepL();
|
|
720 |
|
|
721 |
TRACE_EXIT_POINT
|
|
722 |
}
|
|
723 |
|
|
724 |
// ----------------------------------------------------------------------------
|
|
725 |
// CCalenAlarmManager::HandleNotifyLostAlarmsL
|
|
726 |
// For handling notification ECalenNotifyLostAlarms
|
|
727 |
// which updates missed alarms list and missed alarms count
|
|
728 |
// ----------------------------------------------------------------------------
|
|
729 |
//
|
|
730 |
void CCalenAlarmManager::HandleNotifyLostAlarmsL()
|
|
731 |
{
|
|
732 |
TRACE_ENTRY_POINT;
|
|
733 |
|
|
734 |
TUint32 newCount;
|
|
735 |
// update the missed alarms count
|
|
736 |
iMissedAlarmStore->CountL(newCount);
|
|
737 |
|
|
738 |
if(newCount>=iMissedAlarmsCount)
|
|
739 |
{
|
|
740 |
UpdateMissedAlarmsListL();
|
|
741 |
}
|
|
742 |
else
|
|
743 |
{
|
|
744 |
CreateMissedAlarmsListL();
|
|
745 |
}
|
|
746 |
|
|
747 |
iMissedAlarmsCount = newCount;
|
|
748 |
// refresh the missed alarm view if it is current view
|
|
749 |
TUid currentViewId(iViewManager.CurrentView());
|
|
750 |
if(currentViewId == KUidCalenMissedAlarmsView)
|
|
751 |
{
|
|
752 |
iViewManager.StartActiveStepL();
|
|
753 |
}
|
|
754 |
|
|
755 |
TRACE_EXIT_POINT;
|
|
756 |
}
|
|
757 |
|
|
758 |
// ----------------------------------------------------------------------------
|
|
759 |
// CCalenAlarmManager::HandleMissedAlarmViewClosedL
|
|
760 |
// For handling notification ECalenNotifyMissedAlarmsViewClosed
|
|
761 |
// which activates the previous view or exits the application
|
|
762 |
// if launched from Idle
|
|
763 |
// ----------------------------------------------------------------------------
|
|
764 |
//
|
|
765 |
void CCalenAlarmManager::HandleMissedAlarmViewClosedL()
|
|
766 |
{
|
|
767 |
TRACE_ENTRY_POINT;
|
|
768 |
|
|
769 |
// remove all the missed alarms
|
|
770 |
OnCmdClearAllMissedAlarmsL();
|
|
771 |
|
|
772 |
if(iPreviousToMissedAlarmView.iViewUid!=KNullUid)
|
|
773 |
{
|
|
774 |
iViewManager.RequestActivationL( iPreviousToMissedAlarmView.iViewUid );
|
|
775 |
iPreviousToMissedAlarmView.iViewUid = KNullUid;
|
|
776 |
iPreviousToMissedEventView.iViewUid = KNullUid;
|
|
777 |
|
|
778 |
// set the default context of the view
|
|
779 |
MCalenContext &context = iController.Services().Context();
|
|
780 |
context.SetFocusDateAndTimeL( context.DefaultCalTimeForViewsL(),
|
|
781 |
iPreviousToMissedAlarmView );
|
|
782 |
}
|
|
783 |
else
|
|
784 |
{
|
|
785 |
iController.AppUi().ProcessCommandL(EAknSoftkeyExit);
|
|
786 |
}
|
|
787 |
|
|
788 |
TRACE_EXIT_POINT;
|
|
789 |
}
|
|
790 |
|
|
791 |
// ----------------------------------------------------------------------------
|
|
792 |
// CCalenAlarmManager::HandleMissedEventViewClosedL
|
|
793 |
// For handling notification ECalenNotifyMissedEventViewClosed
|
|
794 |
// which activates the previous view or exits the application
|
|
795 |
// if launched from Idle
|
|
796 |
// ----------------------------------------------------------------------------
|
|
797 |
//
|
|
798 |
void CCalenAlarmManager::HandleMissedEventViewClosedL()
|
|
799 |
{
|
|
800 |
TRACE_ENTRY_POINT;
|
|
801 |
|
|
802 |
if(iLaunchedFromIdle)
|
|
803 |
{
|
|
804 |
iLaunchedFromIdle = EFalse;
|
|
805 |
}
|
|
806 |
MCalenToolbar* toolbar = iController.Services().ToolbarOrNull();
|
|
807 |
if(iPreviousToMissedEventView.iViewUid!=KNullUid)
|
|
808 |
{
|
|
809 |
// if MAV is launched from soft notification/status pane indicator
|
|
810 |
// activate the missed alarms view with close as RSK
|
|
811 |
if(iPreviousToMissedEventView.iViewUid== KUidCalenMissedAlarmsView
|
|
812 |
&& iPreviousToMissedAlarmView.iViewUid == KNullUid )
|
|
813 |
{
|
|
814 |
iViewManager.RequestActivationL( iPreviousToMissedEventView.iViewUid ,
|
|
815 |
KUidCalenShowCloseCba );
|
|
816 |
}
|
|
817 |
else
|
|
818 |
{
|
|
819 |
if(toolbar)
|
|
820 |
{
|
|
821 |
toolbar->SetToolbarVisibilityL(ETrue);
|
|
822 |
}
|
|
823 |
iViewManager.RequestActivationL(iPreviousToMissedEventView.iViewUid);
|
|
824 |
}
|
|
825 |
iPreviousToMissedEventView.iViewUid = KNullUid;
|
|
826 |
}
|
|
827 |
else
|
|
828 |
{
|
|
829 |
if(toolbar)
|
|
830 |
{
|
|
831 |
toolbar->SetToolbarVisibilityL(ETrue);
|
|
832 |
}
|
|
833 |
iController.AppUi().ProcessCommandL(EAknSoftkeyExit);
|
|
834 |
}
|
|
835 |
|
|
836 |
TRACE_EXIT_POINT;
|
|
837 |
}
|
|
838 |
|
|
839 |
|
|
840 |
//---------------------------------------------------------
|
|
841 |
// CCalenViewManager::HandleEntryDeleteNotificationL
|
|
842 |
// Handle entry delete notification
|
|
843 |
//---------------------------------------------------------
|
|
844 |
//
|
|
845 |
void CCalenAlarmManager::HandleEntryDeleteNotificationL()
|
|
846 |
{
|
|
847 |
TRACE_ENTRY_POINT;
|
|
848 |
|
|
849 |
UpdateMissedAlarmsListOnDeleteL();
|
|
850 |
|
|
851 |
// if launched from soft notification/indicator
|
|
852 |
if(iLaunchedFromIdle)
|
|
853 |
{
|
|
854 |
iController.AppUi().ProcessCommandL(EAknSoftkeyExit);
|
|
855 |
iLaunchedFromIdle = EFalse;
|
|
856 |
}
|
|
857 |
|
|
858 |
TRACE_EXIT_POINT;
|
|
859 |
}
|
|
860 |
|
|
861 |
//---------------------------------------------------------
|
|
862 |
// CCalenViewManager::SetContextForMissedEventViewL
|
|
863 |
// Sets the context before launching missed event view
|
|
864 |
//---------------------------------------------------------
|
|
865 |
//
|
|
866 |
void CCalenAlarmManager::SetContextForMissedEventViewL()
|
|
867 |
{
|
|
868 |
TRACE_ENTRY_POINT;
|
|
869 |
|
|
870 |
CCalEntry* entry = iController.Services().EntryViewL(iMissedAlarmList[0].iColId)->FetchL(
|
|
871 |
iMissedAlarmList[0].iEntryLocalUid);
|
|
872 |
User::LeaveIfNull( entry );
|
|
873 |
CleanupStack::PushL( entry );
|
|
874 |
|
|
875 |
TTime instanceTime;
|
|
876 |
TCalTime inscaltime;
|
|
877 |
|
|
878 |
instanceTime = CalenAgendaUtils::EntryTimeL( *entry );
|
|
879 |
inscaltime.SetTimeLocalL( instanceTime );
|
|
880 |
|
|
881 |
// set the context
|
|
882 |
MCalenContext &context = iController.Services().Context();
|
|
883 |
TCalenInstanceId id = TCalenInstanceId::CreateL( *entry, inscaltime );
|
|
884 |
id.iColId = iMissedAlarmList[0].iColId;
|
|
885 |
context.SetInstanceIdL( id, context.ViewId() );
|
|
886 |
|
|
887 |
CleanupStack::PopAndDestroy( entry );
|
|
888 |
|
|
889 |
TRACE_EXIT_POINT;
|
|
890 |
}
|
|
891 |
|
|
892 |
//---------------------------------------------------------
|
|
893 |
// CCalenViewManager::SetMissedAlarmEventAsViewed
|
|
894 |
// Mark the missed alarm event as Viewed
|
|
895 |
//---------------------------------------------------------
|
|
896 |
//
|
|
897 |
void CCalenAlarmManager::SetMissedAlarmEventAsViewed()
|
|
898 |
{
|
|
899 |
TRACE_ENTRY_POINT;
|
|
900 |
|
|
901 |
// get the context
|
|
902 |
MCalenContext &context = iController.Services().Context();
|
|
903 |
TInt missedAlarmEntryUid = context.InstanceId().iEntryLocalUid;
|
|
904 |
TCalCollectionId colid = context.InstanceId().iColId;
|
|
905 |
|
|
906 |
for(TInt index = 0;index < iMissedAlarmList.Count();index++)
|
|
907 |
{
|
|
908 |
if((missedAlarmEntryUid == iMissedAlarmList[index].iEntryLocalUid ) &&
|
|
909 |
(colid == iMissedAlarmList[index].iColId))
|
|
910 |
{
|
|
911 |
// mark the missed alarm event as viewed
|
|
912 |
iMissedAlarmList[index].iInstanceViewed = 1;
|
|
913 |
break;
|
|
914 |
}
|
|
915 |
}
|
|
916 |
|
|
917 |
TRACE_EXIT_POINT;
|
|
918 |
}
|
|
919 |
|
|
920 |
//---------------------------------------------------------
|
|
921 |
// CCalenViewManager::RemoveAllViewedEventsL
|
|
922 |
// Remove all viewed events
|
|
923 |
//---------------------------------------------------------
|
|
924 |
//
|
|
925 |
void CCalenAlarmManager::RemoveAllViewedEventsL()
|
|
926 |
{
|
|
927 |
TRACE_ENTRY_POINT;
|
|
928 |
|
|
929 |
for(TInt index=0;index<iMissedAlarmList.Count();)
|
|
930 |
{
|
|
931 |
if(iMissedAlarmList[index].iInstanceViewed)
|
|
932 |
{
|
|
933 |
ClearOneMissedAlarmL( iMissedAlarmList[index].iEntryLocalUid, iMissedAlarmList[index].iColId );
|
|
934 |
iMissedAlarmList.Remove(index);
|
|
935 |
}
|
|
936 |
else
|
|
937 |
{
|
|
938 |
index++;
|
|
939 |
}
|
|
940 |
}
|
|
941 |
|
|
942 |
TRACE_EXIT_POINT;
|
|
943 |
}
|
|
944 |
|
|
945 |
//---------------------------------------------------------
|
|
946 |
// CCalenViewManager::ClearOneMissedAlarmL
|
|
947 |
// Clear one missed alarm
|
|
948 |
//---------------------------------------------------------
|
|
949 |
//
|
|
950 |
TBool CCalenAlarmManager::ClearOneMissedAlarmL( TInt aEntryLocalUid, TCalCollectionId aColid )
|
|
951 |
{
|
|
952 |
TRACE_ENTRY_POINT;
|
|
953 |
|
|
954 |
RPointerArray<CMissedAlarm> missedAlarmArray;
|
|
955 |
CleanupResetAndDestroyPushL( missedAlarmArray );
|
|
956 |
iMissedAlarmStore->GetL(missedAlarmArray);
|
|
957 |
TBool retValue = EFalse;
|
|
958 |
for(TInt index = 0;index < missedAlarmArray.Count();index++)
|
|
959 |
{
|
|
960 |
if( aEntryLocalUid == missedAlarmArray[index]->iLuid )
|
|
961 |
{
|
|
962 |
CCalSession &session = iController.Services().SessionL( missedAlarmArray[index]->iCalFileName );
|
|
963 |
TCalCollectionId colid = session.CollectionIdL();
|
|
964 |
if( colid == aColid)
|
|
965 |
{
|
|
966 |
// remove from cenrep
|
|
967 |
iMissedAlarmStore->RemoveL(*missedAlarmArray[index]);
|
|
968 |
retValue = ETrue;
|
|
969 |
break;
|
|
970 |
}
|
|
971 |
}
|
|
972 |
}
|
|
973 |
|
|
974 |
CleanupStack::PopAndDestroy(); // aMissedAlarmArray
|
|
975 |
TRACE_EXIT_POINT;
|
|
976 |
return retValue;
|
|
977 |
}
|
|
978 |
|
|
979 |
//---------------------------------------------------------
|
|
980 |
// CCalenViewManager::UpdateMissedAlarmsListL
|
|
981 |
// Update missed alarms list
|
|
982 |
//---------------------------------------------------------
|
|
983 |
//
|
|
984 |
void CCalenAlarmManager::UpdateMissedAlarmsListL()
|
|
985 |
{
|
|
986 |
TRACE_ENTRY_POINT;
|
|
987 |
|
|
988 |
TUint32 newCount;
|
|
989 |
// update the missed alarms count
|
|
990 |
iMissedAlarmStore->CountL(newCount);
|
|
991 |
|
|
992 |
// Need atleast one missed alarm to perform this
|
|
993 |
if(newCount>0)
|
|
994 |
{
|
|
995 |
RPointerArray<CMissedAlarm> missedAlarmStorelist;
|
|
996 |
CleanupResetAndDestroyPushL( missedAlarmStorelist );
|
|
997 |
TCalenInstanceId instanceId;
|
|
998 |
TInt entryLocalUid;
|
|
999 |
TTime instanceTime;
|
|
1000 |
|
|
1001 |
iMissedAlarmStore->GetL(missedAlarmStorelist);
|
|
1002 |
|
|
1003 |
//Retreiving the latest missed alarm array entry
|
|
1004 |
CMissedAlarm* missedAlarm = missedAlarmStorelist[newCount-1];
|
|
1005 |
entryLocalUid = missedAlarm->iLuid;
|
|
1006 |
instanceTime = missedAlarm->iInstanceTime;
|
|
1007 |
|
|
1008 |
CCalSession &session = iController.Services().SessionL( missedAlarm->iCalFileName );
|
|
1009 |
// pack instance ids of the missed alarm instances
|
|
1010 |
TRAP_IGNORE(instanceId = TCalenInstanceId::CreateL( entryLocalUid,
|
|
1011 |
instanceTime, 0 ));
|
|
1012 |
instanceId.iColId = session.CollectionIdL();
|
|
1013 |
iMissedAlarmList.Append(instanceId);
|
|
1014 |
CleanupStack::PopAndDestroy(); // missedAlarmStorelist
|
|
1015 |
|
|
1016 |
// if iMissedAlarmList count is greater than maximum missed alarms(10)
|
|
1017 |
// remove the old missed alarm(index = 0) from the list
|
|
1018 |
if(iMissedAlarmList.Count()>KMaxMissedAlarms)
|
|
1019 |
{
|
|
1020 |
iMissedAlarmList.Remove(0);
|
|
1021 |
}
|
|
1022 |
}
|
|
1023 |
TRACE_EXIT_POINT;
|
|
1024 |
}
|
|
1025 |
|
|
1026 |
// ----------------------------------------------------------------------------
|
|
1027 |
// CCalenAlarmManager::UpdateMissedAlarmsListOnDeleteL
|
|
1028 |
// For updating the missed alarms list when an entry is deleted
|
|
1029 |
// ----------------------------------------------------------------------------
|
|
1030 |
void CCalenAlarmManager::UpdateMissedAlarmsListOnDeleteL()
|
|
1031 |
{
|
|
1032 |
TRACE_ENTRY_POINT;
|
|
1033 |
// get the context
|
|
1034 |
MCalenContext &context = iController.Services().Context();
|
|
1035 |
TInt deletedEntryUid = context.InstanceId().iEntryLocalUid;
|
|
1036 |
TCalCollectionId colidFromContext = context.InstanceId().iColId;
|
|
1037 |
|
|
1038 |
if( EFalse == ClearOneMissedAlarmL( deletedEntryUid, colidFromContext ) )
|
|
1039 |
{
|
|
1040 |
TRACE_EXIT_POINT;
|
|
1041 |
return;
|
|
1042 |
}
|
|
1043 |
for(TInt index = 0;index < iMissedAlarmList.Count();index++)
|
|
1044 |
{
|
|
1045 |
if( ( deletedEntryUid == iMissedAlarmList[index].iEntryLocalUid ) && ( colidFromContext == iMissedAlarmList[index].iColId ) )
|
|
1046 |
{
|
|
1047 |
iMissedAlarmList.Remove(index);
|
|
1048 |
if(!iMissedAlarmList.Count())
|
|
1049 |
{
|
|
1050 |
iMissedAlarmList.Close();
|
|
1051 |
}
|
|
1052 |
break;
|
|
1053 |
}
|
|
1054 |
}
|
|
1055 |
TRACE_EXIT_POINT;
|
|
1056 |
}
|
|
1057 |
|
|
1058 |
// ----------------------------------------------------------------------------
|
|
1059 |
// CCalenAlarmManager::HandleSystemTimeChangedL
|
|
1060 |
// For updating the missed alarms list/cenrep when time is changed
|
|
1061 |
// ----------------------------------------------------------------------------
|
|
1062 |
void CCalenAlarmManager::HandleSystemTimeChangedL()
|
|
1063 |
{
|
|
1064 |
TRACE_ENTRY_POINT;
|
|
1065 |
|
|
1066 |
TTime currentTime = CalenDateUtils::Now();
|
|
1067 |
TTime entryAlarmTime(Time::NullTTime());
|
|
1068 |
RArray<TCalLocalUid> foundlocalUids;
|
|
1069 |
RArray<TCalCollectionId> foundColIds;
|
|
1070 |
TCalLocalUid entryLocalUid;
|
|
1071 |
|
|
1072 |
for(TInt i = 0;i<iMissedAlarmList.Count();i++)
|
|
1073 |
{
|
|
1074 |
entryLocalUid = iMissedAlarmList[i].iEntryLocalUid;
|
|
1075 |
TCalCollectionId colid = iMissedAlarmList[i].iColId;
|
|
1076 |
CCalEntry* entry = iController.Services().EntryViewL( colid )->FetchL(entryLocalUid);
|
|
1077 |
User::LeaveIfNull( entry );
|
|
1078 |
CleanupStack::PushL( entry );
|
|
1079 |
|
|
1080 |
GetAlarmDateTimeL( *entry, entryAlarmTime );
|
|
1081 |
|
|
1082 |
// clear future alarm
|
|
1083 |
if(entryAlarmTime>currentTime)
|
|
1084 |
{
|
|
1085 |
// clear missed alarm from cenrep
|
|
1086 |
if( ClearOneMissedAlarmL(entryLocalUid, colid ) )
|
|
1087 |
{
|
|
1088 |
foundlocalUids.Append(entryLocalUid);
|
|
1089 |
foundColIds.Append(colid);
|
|
1090 |
}
|
|
1091 |
}
|
|
1092 |
CleanupStack::PopAndDestroy( entry );
|
|
1093 |
}
|
|
1094 |
|
|
1095 |
for(TInt index = 0;index<foundlocalUids.Count();index++)
|
|
1096 |
{
|
|
1097 |
for(TInt j=0;j<iMissedAlarmList.Count();j++)
|
|
1098 |
{
|
|
1099 |
if( foundlocalUids[index]==iMissedAlarmList[j].iEntryLocalUid && foundColIds[index] == iMissedAlarmList[j].iColId )
|
|
1100 |
{
|
|
1101 |
// remove from local missed alarms list
|
|
1102 |
iMissedAlarmList.Remove(j);
|
|
1103 |
}
|
|
1104 |
break;
|
|
1105 |
}
|
|
1106 |
}
|
|
1107 |
foundlocalUids.Close();
|
|
1108 |
|
|
1109 |
// refresh the missed alarm view if it is current view
|
|
1110 |
TUid currentViewId(iViewManager.CurrentView());
|
|
1111 |
if(currentViewId == KUidCalenMissedAlarmsView)
|
|
1112 |
{
|
|
1113 |
iViewManager.StartActiveStepL();
|
|
1114 |
}
|
|
1115 |
|
|
1116 |
TRACE_EXIT_POINT;
|
|
1117 |
}
|
|
1118 |
|
|
1119 |
// ----------------------------------------------------------------------------
|
|
1120 |
// CCalenAlarmManager::GetAlarmDateTimeL
|
|
1121 |
// Get the alarm time for the entry
|
|
1122 |
// ----------------------------------------------------------------------------
|
|
1123 |
void CCalenAlarmManager::GetAlarmDateTimeL( const CCalEntry& aEntry,
|
|
1124 |
TTime& aAlarmDateTime)
|
|
1125 |
{
|
|
1126 |
TRACE_ENTRY_POINT;
|
|
1127 |
|
|
1128 |
// FIXME: leaving!
|
|
1129 |
CCalAlarm* alarm = aEntry.AlarmL();
|
|
1130 |
|
|
1131 |
if(alarm)
|
|
1132 |
{
|
|
1133 |
CleanupStack::PushL( alarm );
|
|
1134 |
|
|
1135 |
switch( aEntry.EntryTypeL() )
|
|
1136 |
{
|
|
1137 |
case CCalEntry::ETodo:
|
|
1138 |
aAlarmDateTime = aEntry.EndTimeL().TimeLocalL();
|
|
1139 |
break;
|
|
1140 |
|
|
1141 |
case CCalEntry::EAppt:
|
|
1142 |
case CCalEntry::EEvent:
|
|
1143 |
case CCalEntry::EAnniv:
|
|
1144 |
default:
|
|
1145 |
aAlarmDateTime = aEntry.StartTimeL().TimeLocalL();
|
|
1146 |
break;
|
|
1147 |
}
|
|
1148 |
aAlarmDateTime -= alarm->TimeOffset();
|
|
1149 |
|
|
1150 |
CleanupStack::PopAndDestroy( alarm );
|
|
1151 |
}
|
|
1152 |
|
|
1153 |
TRACE_EXIT_POINT;
|
|
1154 |
}
|
|
1155 |
|
|
1156 |
// ----------------------------------------------------------------------------
|
|
1157 |
// CCalenAlarmManager::LaunchEventViewerL
|
|
1158 |
// Rest of the detail are commented in header.
|
|
1159 |
// ----------------------------------------------------------------------------
|
|
1160 |
void CCalenAlarmManager::LaunchEventViewerL()
|
|
1161 |
{
|
|
1162 |
TRACE_ENTRY_POINT;
|
|
1163 |
|
|
1164 |
// launching Event View from alarm
|
|
1165 |
StartAlarmContextListenerL();
|
|
1166 |
|
|
1167 |
if(iController.IsFasterAppFlagEnabled())
|
|
1168 |
{
|
|
1169 |
iViewerLaunchedFromIdle = ETrue;
|
|
1170 |
iController.SetFasterAppFlag( EFalse );
|
|
1171 |
}
|
|
1172 |
else
|
|
1173 |
{
|
|
1174 |
iPreviousToEventViewUid = iViewManager.CurrentView();
|
|
1175 |
if(iPreviousToEventViewUid == KUidCalenEventView ||
|
|
1176 |
iPreviousToEventViewUid == KUidCalenMissedEventView )
|
|
1177 |
{
|
|
1178 |
iPreviousToEventViewUid = iViewManager.GetPreviousViewUid();
|
|
1179 |
}
|
|
1180 |
iController.SetExitOnDialogFlag( EFalse );
|
|
1181 |
}
|
|
1182 |
|
|
1183 |
TRACE_EXIT_POINT;
|
|
1184 |
}
|
|
1185 |
|
|
1186 |
// ----------------------------------------------------------------------------
|
|
1187 |
// CCalenAlarmManager::HandleBackEventL
|
|
1188 |
// Rest of the detail are commented in header.
|
|
1189 |
// ----------------------------------------------------------------------------
|
|
1190 |
void CCalenAlarmManager::HandleBackEventL()
|
|
1191 |
{
|
|
1192 |
TRACE_ENTRY_POINT;
|
|
1193 |
|
|
1194 |
MCalenToolbar* toolbarImpl = iController.ViewManager().ToolbarOrNull();
|
|
1195 |
if(toolbarImpl) // If toolbar exists
|
|
1196 |
{
|
|
1197 |
CAknToolbar& toolbar = toolbarImpl->Toolbar();
|
|
1198 |
|
|
1199 |
// Remove the viewer toolbar buttons
|
|
1200 |
toolbar.RemoveItem(ECalenDeleteCurrentEntry); // Delete button
|
|
1201 |
toolbar.RemoveItem(ECalenEditCurrentEntry); // Edit button
|
|
1202 |
toolbar.RemoveItem(ECalenSend); // Send button
|
|
1203 |
}
|
|
1204 |
if( iViewerLaunchedFromIdle )
|
|
1205 |
{
|
|
1206 |
iController.AppUi().ProcessCommandL(EAknSoftkeyExit);
|
|
1207 |
iViewerLaunchedFromIdle = EFalse;
|
|
1208 |
}
|
|
1209 |
else if( iPreviousToEventViewUid!=KNullUid &&
|
|
1210 |
( iPreviousToEventViewUid!= KUidCalenEventView || iPreviousToEventViewUid != KUidCalenMissedEventView ) )
|
|
1211 |
{
|
|
1212 |
iViewManager.SetRepopulation(EFalse);
|
|
1213 |
TVwsViewId previousViewId(KUidCalendar, iPreviousToEventViewUid) ;
|
|
1214 |
iController.ViewManager().RequestActivationL(previousViewId);
|
|
1215 |
iPreviousToEventViewUid = KNullUid;
|
|
1216 |
iViewManager.SetRepopulation(ETrue);
|
|
1217 |
}
|
|
1218 |
else
|
|
1219 |
{
|
|
1220 |
|
|
1221 |
}
|
|
1222 |
|
|
1223 |
TRACE_EXIT_POINT;
|
|
1224 |
}
|
|
1225 |
|
|
1226 |
// End of file
|