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