email/emailnotificationhandler/inc/EMNHandler.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: An EMN handler WAP Push Plugin.
       
    15 *		
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef EMNHANDLER_H
       
    21 #define EMNHANDLER_H
       
    22 
       
    23 enum TEMNErrors
       
    24     {
       
    25     EEMNNoError = 0,
       
    26     EEMNMissingEMNElement,
       
    27     EEMNMissingMailboxAttribute,
       
    28     EEMNMissingTimestampAttribute,
       
    29     EEMNInvalidTimestampAttribute,
       
    30     EEMNInvalidYear,
       
    31     EEMNInvalidMonth,
       
    32     EEMNInvalidDay,
       
    33     EEMNInvalidHour,
       
    34     EEMNInvalidMinute,
       
    35     };
       
    36 
       
    37 #include <e32base.h>
       
    38 #include <push/cpushhandlerbase.h>
       
    39 #include <AlwaysOnlineManagerClient.h>
       
    40 #include "EMNXMLContentHandler.h"
       
    41 
       
    42 /** 
       
    43 * The CEMNHandler is a WAP Push Plugin. It registers for a email notification 
       
    44 * push message. It is invoked to do its work in when HandleMessage() API is 
       
    45 * called by the Push Watcher framework.
       
    46 * 
       
    47 * As a WAP Push Plugin, it must destroy itself when it is complete. The Watcher
       
    48 * does not hold a pointer to it, it is invoked and responsible for destroying 
       
    49 * itself.
       
    50 *   
       
    51 */ 
       
    52 class CEMNHandler : public CPushHandlerBase
       
    53 	{
       
    54     public:	// Methods
       
    55 
       
    56         /**
       
    57         * Creates object from CEMNHandler
       
    58         * @since S60 v3.1
       
    59         * @return, Constructed object
       
    60         */
       
    61     	static CEMNHandler* NewL();
       
    62     	
       
    63         /**
       
    64         * Destructor
       
    65         * @since S60 v3.1
       
    66         */
       
    67      	virtual ~CEMNHandler();
       
    68 
       
    69     public:	// Methods from CPushHandlerBase
       
    70 
       
    71         /**
       
    72         * Called by the Wap Push Framework to handle the message.
       
    73         * @since S60 v3.1
       
    74         * @param aPushMsg The push message delivered from the framework containing
       
    75     	*                 the Push Message.  Ownership is taken over.
       
    76         * @param aStatus  when this function is complete, this status is returned 
       
    77     	*                 with acompletion code.
       
    78         */
       
    79     	void HandleMessageL( CPushMessage* aPushMsg, TRequestStatus& aStatus );
       
    80 
       
    81         /**
       
    82         * Called by the Wap Push Framework to handle the message.
       
    83         * @since S60 v3.1
       
    84         * @param aPushMsg The push message delivered from the framework containing
       
    85     	*                 the Push Message.  Ownership is taken over.
       
    86         */
       
    87     	void HandleMessageL( CPushMessage* aPushMsg );
       
    88 
       
    89         /**
       
    90         * Called by the Wap Push Framework to cancel outstanding events.
       
    91         * @since S60 v3.1
       
    92         */
       
    93     	void CancelHandleMessage();
       
    94 
       
    95         /**
       
    96         * Reserved for ECOM for future expansion
       
    97         * @since S60 v3.1
       
    98         */
       
    99     	virtual void CPushHandlerBase_Reserved1();
       
   100 
       
   101         /**
       
   102         * Reserved for ECOM for future expansion
       
   103         * @since S60 v3.1
       
   104         */
       
   105     	virtual void CPushHandlerBase_Reserved2();
       
   106 
       
   107     private:	// Methods from CActive
       
   108 
       
   109         /**
       
   110         * Cancels the outstanding request.
       
   111         * @since S60 v3.1
       
   112         */
       
   113     	void DoCancel();
       
   114 
       
   115         /**
       
   116         * Called when object is active
       
   117         * @since S60 v3.1
       
   118         */
       
   119     	void RunL();
       
   120 
       
   121 
       
   122     private:	// Methods
       
   123 
       
   124         /**
       
   125         * Default constructor for class CEMNHandler
       
   126         * @since S60 v3.1
       
   127         * @return, Constructed object
       
   128         */
       
   129     	CEMNHandler();
       
   130 
       
   131         /**
       
   132         * Symbian 2-phase constructor
       
   133         * @since S60 v3.1
       
   134         */
       
   135     	void ConstructL();
       
   136 
       
   137 
       
   138         /**
       
   139         * Completes itself.
       
   140         * @since S60 v3.1
       
   141         */
       
   142     	void IdleComplete();
       
   143 
       
   144         /**
       
   145         * Handle the suicide.
       
   146         * @since S60 v3.1
       
   147         */
       
   148         void Done( TInt aError );
       
   149 
       
   150         /**
       
   151         * Handles the parsing of received EMN message.
       
   152         * @since S60 v3.1
       
   153         */
       
   154     	void ParsePushMsgL();
       
   155     	
       
   156         /**
       
   157         * Relays parsed message to always online client.
       
   158         * @since S60 v3.1
       
   159         */
       
   160     	void ProcessPushMsgL();
       
   161 
       
   162     private:	// Attributes
       
   163     	typedef enum TState { EParsing, EProcessing, EDone };  
       
   164     	TState iState;
       
   165 
       
   166     	// Push Message passed in
       
   167     	CPushMessage*	iMessage;
       
   168 
       
   169         // The body of the pushed message as HBufC8 descriptor
       
   170         HBufC8* iBody;
       
   171             
       
   172     	// Flag to indicate if this was called asynchonously
       
   173     	TBool			iAsyncHandling;
       
   174 
       
   175         // EMN element containing mailbox and timestamp
       
   176         TEMNElement     iElement;
       
   177 
       
   178         // Used to relay parsed message to always online client.
       
   179         RAlwaysOnlineClientSession  iAOClient;
       
   180 
       
   181 	};
       
   182 
       
   183 #endif	// EMNHANDLER_H