imservices/instantmessagingcache/imcacheclient/inc/cimcacheeventhandler.h
changeset 0 e6b17d312c8b
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  cache message change observer
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __CIMCACHEEVENTHANDLER_H__
       
    20 #define __CIMCACHEEVENTHANDLER_H__
       
    21 
       
    22 #include <e32std.h>
       
    23 #include <e32base.h>
       
    24 #include <s32mem.h>
       
    25 
       
    26 #include <imcachedefs.h>
       
    27 
       
    28 class MIMCacheClient;
       
    29 class MIMCacheEventHandler;
       
    30 
       
    31 /**
       
    32  * a class to listen to server cache message change
       
    33  */
       
    34 NONSHARABLE_CLASS( CIMCacheEventHandler ): public CActive
       
    35     {
       
    36 	public:
       
    37 		/**
       
    38 		* Two-phased constructor.
       
    39 		* @param aRegistrar ,client refence
       
    40 		* @param aHandler a handler to send data to ui client
       
    41 		*/
       
    42 		static CIMCacheEventHandler* NewL( MIMCacheClient& aRegistrar ,
       
    43 													 MIMCacheEventHandler& aHandler  );
       
    44 		/**
       
    45 		*  ~CIMCacheEventHandler.
       
    46 		*/
       
    47     	virtual ~CIMCacheEventHandler();
       
    48 
       
    49     public: // From CActive
       
    50 
       
    51 		/**
       
    52 		*  RunL
       
    53 		*/
       
    54         void RunL();  
       
    55         
       
    56         /**
       
    57 		*  DoCancel
       
    58 		*/
       
    59 		void DoCancel();
       
    60 		
       
    61 		 /**
       
    62           *  RunError
       
    63           */
       
    64 		TInt RunError( TInt /* aError */);
       
    65 		
       
    66 			
       
    67 	public : // new functions
       
    68 			/**
       
    69 			*  UnRegisterObserver from server
       
    70 			*/
       
    71 			void UnRegisterObserver();
       
    72 	private:
       
    73 	
       
    74 		/**
       
    75 		* default CIMCacheEventHandler
       
    76 		* @param aRegistrar ,client refence
       
    77 		* @param aHandler a handler to send data to ui client
       
    78 		*/
       
    79 		CIMCacheEventHandler( MIMCacheClient& aRegistrar, 
       
    80 							  MIMCacheEventHandler& aHandler );
       
    81 		/**
       
    82 		*  default ConstructL
       
    83 		*/
       
    84     	void ConstructL();
       
    85     	
       
    86     	/**
       
    87     	* Gets called when data update is available.
       
    88     	* get data buffer from server
       
    89     	*/
       
    90     	void GetBufferChatDataL() ;
       
    91       
       
    92       	/**
       
    93     	* Gets called when data update is available.
       
    94     	* extract the data and send to client
       
    95     	* @param aChatDataBuffer structure of SIMCacheMessageData type
       
    96     	* @param aMore indicate more packets pending at server side
       
    97     	*/
       
    98     	void InternalizeChatDataL( TPtr8 aChatDataBuffer , 
       
    99     							   TBool& aMore );
       
   100 		
       
   101     	/**
       
   102     	* Gets called when data update is available.
       
   103     	* get data buffer from server
       
   104 		* @param aEventType, type of data
       
   105     	*/	
       
   106         void GetBufferedChatItemL( TIMCacheEventType aEventType );
       
   107         
       
   108         /**
       
   109     	* read the stream and write into buffer
       
   110     	* @param aEventType, type of data
       
   111     	* @param aChatItemBuffer structure of SIMCacheContactData type
       
   112        	*/
       
   113           	
       
   114     	void InternalizeChatItemL( TIMCacheEventType aEventType, 
       
   115     							   TPtr8 aChatItemBuffer );
       
   116 	
       
   117 	private: // data
       
   118 	
       
   119 			
       
   120 		// doesn't own: registrar
       
   121 		MIMCacheClient& iRegistrar;
       
   122 		// owned , need to observer to server or not
       
   123 		TBool iContinueObserving ;
       
   124 		// client side observer event 
       
   125 		MIMCacheEventHandler& iUpdateHandler;
       
   126 	
       
   127 		
       
   128     };
       
   129 
       
   130 #endif      //  __CIMCACHEEVENTHANDLER_H__
       
   131 
       
   132 
       
   133 //  END OF FILE
       
   134