calendarui/controller/src/calenmapstate.cpp
author hgs
Wed, 03 Nov 2010 17:12:22 +0530
changeset 89 b57382753122
child 67 1539a383d7b6
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) 2007 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:   Map state for Calendar
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
hgs
parents:
diff changeset
    20
// includes
hgs
parents:
diff changeset
    21
#include "calenmapstate.h"
hgs
parents:
diff changeset
    22
#include "calendarui_debug.h"           // Debug macros
hgs
parents:
diff changeset
    23
#include "calencontroller.h"
hgs
parents:
diff changeset
    24
#include "calenstatemachine.h"
hgs
parents:
diff changeset
    25
#include "calennotifier.h"
hgs
parents:
diff changeset
    26
hgs
parents:
diff changeset
    27
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    28
// CCalenMapState::NewLC
hgs
parents:
diff changeset
    29
// First stage construction
hgs
parents:
diff changeset
    30
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    31
CCalenMapState* CCalenMapState::NewLC( CCalenController& aController,
hgs
parents:
diff changeset
    32
                                       RHashSet<TCalenNotification>& aOutstandingNotifications )
hgs
parents:
diff changeset
    33
    {
hgs
parents:
diff changeset
    34
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
    35
hgs
parents:
diff changeset
    36
    CCalenMapState* self = new ( ELeave ) CCalenMapState( aController,
hgs
parents:
diff changeset
    37
                                                          aOutstandingNotifications );
hgs
parents:
diff changeset
    38
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
    39
    self->ConstructL();
hgs
parents:
diff changeset
    40
hgs
parents:
diff changeset
    41
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
    42
    return self;
hgs
parents:
diff changeset
    43
    }
hgs
parents:
diff changeset
    44
hgs
parents:
diff changeset
    45
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    46
// CCalenMapState::ConstructL
hgs
parents:
diff changeset
    47
// Second stage construction
hgs
parents:
diff changeset
    48
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    49
void CCalenMapState::ConstructL()
hgs
parents:
diff changeset
    50
    {
hgs
parents:
diff changeset
    51
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
    52
    BaseConstructL();
hgs
parents:
diff changeset
    53
    
hgs
parents:
diff changeset
    54
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
    55
    }
hgs
parents:
diff changeset
    56
    
hgs
parents:
diff changeset
    57
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    58
// CCalenMapState::CCalenMapState
hgs
parents:
diff changeset
    59
// C++ Constructor
hgs
parents:
diff changeset
    60
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    61
CCalenMapState::CCalenMapState( CCalenController& aController, RHashSet<TCalenNotification>& aOutstandingNotifications )
hgs
parents:
diff changeset
    62
    : CCalenState( aController, aOutstandingNotifications )
hgs
parents:
diff changeset
    63
    {
hgs
parents:
diff changeset
    64
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
    65
    
hgs
parents:
diff changeset
    66
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
    67
    }
hgs
parents:
diff changeset
    68
    
hgs
parents:
diff changeset
    69
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    70
// CCalenMapState::CCalenMapState
hgs
parents:
diff changeset
    71
// Destructor
hgs
parents:
diff changeset
    72
// ----------------------------------------------------------------------------    
hgs
parents:
diff changeset
    73
CCalenMapState::~CCalenMapState()
hgs
parents:
diff changeset
    74
    {
hgs
parents:
diff changeset
    75
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
    76
    
hgs
parents:
diff changeset
    77
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
    78
    }
hgs
parents:
diff changeset
    79
hgs
parents:
diff changeset
    80
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    81
// CCalenMapState::HandleCommandL
hgs
parents:
diff changeset
    82
// From CCalenState
hgs
parents:
diff changeset
    83
// ----------------------------------------------------------------------------    
hgs
parents:
diff changeset
    84
TBool CCalenMapState::HandleCommandL( const TCalenCommand& aCommand,
hgs
parents:
diff changeset
    85
                                           CCalenStateMachine& aStateMachine )
hgs
parents:
diff changeset
    86
    {
hgs
parents:
diff changeset
    87
    TRACE_ENTRY_POINT; 
hgs
parents:
diff changeset
    88
    
hgs
parents:
diff changeset
    89
    TInt cmd = aCommand.Command();
hgs
parents:
diff changeset
    90
    MCalenCommandHandler* handler = iController.GetCommandHandlerL( cmd );
hgs
parents:
diff changeset
    91
	    
hgs
parents:
diff changeset
    92
	ASSERT( handler );
hgs
parents:
diff changeset
    93
     
hgs
parents:
diff changeset
    94
    TBool cmdUsed = EFalse;
hgs
parents:
diff changeset
    95
    switch( cmd )
hgs
parents:
diff changeset
    96
    {
hgs
parents:
diff changeset
    97
    case ECalenFasterAppExit:
hgs
parents:
diff changeset
    98
    case ECalenDayView:    
hgs
parents:
diff changeset
    99
    case ECalenMissedEventViewFromIdle: 
hgs
parents:
diff changeset
   100
    case ECalenEventViewFromAlarm:
hgs
parents:
diff changeset
   101
    case ECalenEventViewFromAlarmStopOnly:
hgs
parents:
diff changeset
   102
        {
hgs
parents:
diff changeset
   103
        // Issue map launch cancel notification
hgs
parents:
diff changeset
   104
        iController.BroadcastNotification(ECalenNotifyCancelMapLaunch);
hgs
parents:
diff changeset
   105
        SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState );
hgs
parents:
diff changeset
   106
        ActivateCurrentStateL(aStateMachine);
hgs
parents:
diff changeset
   107
        cmdUsed = ETrue;
hgs
parents:
diff changeset
   108
        break;
hgs
parents:
diff changeset
   109
        }
hgs
parents:
diff changeset
   110
        
hgs
parents:
diff changeset
   111
    default:
hgs
parents:
diff changeset
   112
    		break;
hgs
parents:
diff changeset
   113
    }
hgs
parents:
diff changeset
   114
    
hgs
parents:
diff changeset
   115
    if(cmdUsed)
hgs
parents:
diff changeset
   116
		RequestCallbackL( handler, aCommand );
hgs
parents:
diff changeset
   117
	
hgs
parents:
diff changeset
   118
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   119
    
hgs
parents:
diff changeset
   120
    return cmdUsed;
hgs
parents:
diff changeset
   121
    }
hgs
parents:
diff changeset
   122
hgs
parents:
diff changeset
   123
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   124
// CCalenMapState::HandleNotificationL
hgs
parents:
diff changeset
   125
// From CCalenState
hgs
parents:
diff changeset
   126
// ----------------------------------------------------------------------------        
hgs
parents:
diff changeset
   127
void CCalenMapState::HandleNotificationL(const TCalenNotification& aNotification,
hgs
parents:
diff changeset
   128
                                                 CCalenStateMachine& aStateMachine )
hgs
parents:
diff changeset
   129
    {
hgs
parents:
diff changeset
   130
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   131
    
hgs
parents:
diff changeset
   132
    switch( aNotification )
hgs
parents:
diff changeset
   133
        {
hgs
parents:
diff changeset
   134
        case ECalenNotifyMapClosed:
hgs
parents:
diff changeset
   135
        case ECalenNotifyAppForegrounded:
hgs
parents:
diff changeset
   136
        	{
hgs
parents:
diff changeset
   137
        	SetCurrentState( aStateMachine, iPreviousState );
hgs
parents:
diff changeset
   138
        	// We set iOutstandingNotifications for two reasons.
hgs
parents:
diff changeset
   139
        	// 1. The new state i.e. the state we are moving back can have notification info.
hgs
parents:
diff changeset
   140
        	// 2. When we move to newstate we broadcast all notification from iOutstandingNotifications
hgs
parents:
diff changeset
   141
        	//     and inform the registered notifiers.
hgs
parents:
diff changeset
   142
        	iOutstandingNotifications.InsertL(aNotification);
hgs
parents:
diff changeset
   143
            ActivateCurrentStateL(aStateMachine);
hgs
parents:
diff changeset
   144
        	}
hgs
parents:
diff changeset
   145
            break;
hgs
parents:
diff changeset
   146
        default:
hgs
parents:
diff changeset
   147
            CCalenState::HandleNotificationL( aNotification, aStateMachine );
hgs
parents:
diff changeset
   148
            break;
hgs
parents:
diff changeset
   149
        }
hgs
parents:
diff changeset
   150
    
hgs
parents:
diff changeset
   151
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   152
    }
hgs
parents:
diff changeset
   153
hgs
parents:
diff changeset
   154
hgs
parents:
diff changeset
   155
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   156
// CCalenMapState::HandleStateActivationL
hgs
parents:
diff changeset
   157
// Behavior when state is activated.
hgs
parents:
diff changeset
   158
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   159
void CCalenMapState::HandleStateActivationL(CCalenStateMachine& /*aStateMachine*/)
hgs
parents:
diff changeset
   160
    {
hgs
parents:
diff changeset
   161
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   162
    
hgs
parents:
diff changeset
   163
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   164
    }
hgs
parents:
diff changeset
   165
hgs
parents:
diff changeset
   166
 // end of file