emailservices/emailstore/message_store/client/src/MsgStoreObserverHandler.cpp
branchRCL_3
changeset 24 d189ee25cf9d
parent 8 e1b6206813b4
child 25 3533d4323edc
equal deleted inserted replaced
23:dcf0eedfc1a3 24:d189ee25cf9d
    14 * Description:  Message store observer handler client implementation.
    14 * Description:  Message store observer handler client implementation.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include "msgstoreobserverhandler.h"
    19 #include "MsgStoreObserverHandler.h"
    20 #include "rmessagestoresession.h"
    20 #include "RMessageStoreSession.h"
    21 //<cmail>
    21 //<cmail>
    22 #include "msgstoreobserver.h"
    22 #include "MsgStoreObserver.h"
    23 //</cmail>
    23 //</cmail>
    24 
    24 
    25 
    25 
    26 
    26 
    27 // ------------------------
    27 // ------------------------
    43 CMsgStoreObserverHandler::CMsgStoreObserverHandler( RMessageStoreSession& aSession ) : 
    43 CMsgStoreObserverHandler::CMsgStoreObserverHandler( RMessageStoreSession& aSession ) : 
    44 	CActive( EPriorityStandard ),
    44 	CActive( EPriorityStandard ),
    45 	iSession( aSession )
    45 	iSession( aSession )
    46 	{
    46 	{
    47 	__LOG_CONSTRUCT( "MsgClient", "CMsgStoreObserverHandler" )
    47 	__LOG_CONSTRUCT( "MsgClient", "CMsgStoreObserverHandler" )
       
    48 	//initialize variable to false.
       
    49     iObjectDeleted = EFalse;
    48 	} // end constructor
    50 	} // end constructor
    49 
    51 
    50 // ==========================================================================
    52 // ==========================================================================
    51 // FUNCTION: Destructor
    53 // FUNCTION: Destructor
    52 // ==========================================================================
    54 // ==========================================================================
    55 	Cancel();
    57 	Cancel();
    56 	
    58 	
    57 	iMailBoxObservers.Close();
    59 	iMailBoxObservers.Close();
    58 	iObservers.Close();
    60 	iObservers.Close();
    59 		
    61 		
       
    62 	//object is being deleted. Mark variable as true to cover case where delete
       
    63 	//has come while RunL was running and "AccountEventNotify" was called and
       
    64 	//has not completed.
       
    65 	iObjectDeleted = ETrue;
    60 	__LOG_DESTRUCT
    66 	__LOG_DESTRUCT
    61 	} // end destructor
    67 	} // end destructor
    62 
    68 
    63 // ==========================================================================
    69 // ==========================================================================
    64 // FUNCTION: AddObserverL
    70 // FUNCTION: AddObserverL
   231     			}
   237     			}
   232     	    	
   238     	    	
   233     	    eventPtr++;
   239     	    eventPtr++;
   234             }
   240             }
   235             
   241             
   236     	// Get the next event(s).    	
   242         //check that "this" object was not deleted by client during "AccountEventNotify".
   237     	iSession.GetEvents( iStatus, iEventBuffer );
   243         //If object has been deleted there is no need to get session events and activate itself.
   238     	SetActive();
   244         if ( !iObjectDeleted )
       
   245             {
       
   246             // Get the next event(s).       
       
   247             iSession.GetEvents(iStatus, iEventBuffer);
       
   248             SetActive();
       
   249             }
       
   250     	
   239 	    }
   251 	    }
   240     else
   252     else
   241     	{
   253     	{
   242         __LOG_WRITE8_FORMAT1_ERROR( "error, iStatus=%d", iStatus.Int() );
   254         __LOG_WRITE8_FORMAT1_ERROR( "error, iStatus=%d", iStatus.Int() );
   243     	} // end if
   255     	} // end if