imservices/instantmessagingcache/imcacheserver/inc/ccacheserveractivehelper.h
changeset 0 e6b17d312c8b
child 18 b6f2a363adf7
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:  instantmessagingcache server class declaration
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CIMCACHESERVERACTIVEHELPER_H__
       
    19 #define __CIMCACHESERVERACTIVEHELPER_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 
       
    23 #include <imcachedefs.h>
       
    24 #include <cinstantmsgindicator.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class CIMCacheServer;
       
    28 class TIMCacheMessageFactory;
       
    29 class MIMCacheMessageHeader;
       
    30 class CIMCacheMessageBase;
       
    31 
       
    32 
       
    33 /**
       
    34 * This class is used by CIMCacheServer for dividing long running async.
       
    35 * tasks into smaller units. The instantmessagingcache session itself was not made 
       
    36 * active, since that results in c++ ambiguousness problems in CCacheServerActiveHelper
       
    37 * @since S60 v5.0
       
    38 */    
       
    39 class CCacheServerActiveHelper : public CBase
       
    40 	{
       
    41 	public: // public functions
       
    42 	
       
    43 	    /**
       
    44         * Default 1st phase factory method.
       
    45         * Creates an instance of CCacheServerActiveHelper
       
    46         * @return created instance of the CCacheServerActiveHelper
       
    47         */
       
    48         static CCacheServerActiveHelper* NewL(CIMCacheServer& aServer);
       
    49         
       
    50         /**
       
    51         * Destruct
       
    52         */
       
    53         ~CCacheServerActiveHelper( );
       
    54         
       
    55         	
       
    56 	private: // private functions
       
    57         
       
    58         /**
       
    59         * Constructor
       
    60         * @param aServer, server reference
       
    61         */
       
    62         CCacheServerActiveHelper(CIMCacheServer& aServer); 
       
    63 
       
    64         /**
       
    65         * ConstructL
       
    66         */
       
    67 		void ConstructL();
       
    68 		
       
    69 		/**
       
    70         * PackAndNotifyRecievedMessageL pack and notify about recieve message
       
    71         * @param aMsgHeader, header reference
       
    72         * @param aRecievedMsg, message reference
       
    73         */
       
    74 		void PackAndNotifyRecievedMessageL(MIMCacheMessageHeader* aMsgHeader,
       
    75 											CIMCacheMessageBase* aRecievedMsg);
       
    76 
       
    77 		/**
       
    78         * PackAndNotifyEventL pack and notify about message
       
    79         * @param aNotification, type of change
       
    80         * @param aMsgHeader, header reference
       
    81         * @param aMessage, message reference
       
    82         */
       
    83 		void PackAndNotifyEventL( TIMCacheOperationsCode aNotification, 
       
    84                                   TInt aServiceId,
       
    85 								  MIMCacheMessageHeader * aMsgHeader = NULL,
       
    86 								  CIMCacheMessageBase* aMessage = NULL );
       
    87 
       
    88 		/**
       
    89         * find and give the chat header pointer
       
    90         * @param aServiceId, service id
       
    91         * @param aBuddyId, buddy id
       
    92         * @return chat header ,if not found NULL
       
    93         */
       
    94 		MIMCacheMessageHeader* ChatHeaderL(const TInt& aServiceId, const TDesC& aBuddyId );
       
    95 		
       
    96 		 /**
       
    97           * Loads all the plugins
       
    98           */
       
    99 		 void LoadPluginL( );
       
   100 		 
       
   101 		 /**
       
   102           * publishes the message info to the plugins
       
   103           * @param aSenderId, buddy id
       
   104           * @param aServiceId, service id
       
   105           */
       
   106 		 void  PublishMessageInfoL(const TDesC& aSenderId,TInt aServiceId );
       
   107 
       
   108     										
       
   109 public:	
       
   110      	/**
       
   111         * reset all header chat started flag to EFalse
       
   112         */
       
   113     	void ResetHeaderInoformation();
       
   114         /**
       
   115         * gets unread message count corresponding to a particular sender
       
   116         */
       
   117 		void GetUnreadMessageCountL(const RMessage2& aMessage );
       
   118 		
       
   119 		/**
       
   120         * gets all unread message count from all open conversations
       
   121         */
       
   122 		void GetAllUnreadMessageCountL(const RMessage2& aMessage );		
       
   123 
       
   124 		/**
       
   125 		* start the new conversation
       
   126 		*/
       
   127         void StartNewConversationL( const RMessage2 &aMessage );
       
   128 
       
   129 		/**
       
   130 		* append the revieve new messgae 
       
   131 		*/
       
   132         void AppendReceiveMessageL( const RMessage2 &aMessage );
       
   133 
       
   134 		/**
       
   135 		* append the new send messgae  
       
   136 		*/
       
   137         void AppendSendMessageL( const RMessage2 &aMessage );
       
   138         
       
   139         /**
       
   140 		* append the information messgae  
       
   141 		*/
       
   142         void AppendMessageL( const RMessage2 &aMessage );
       
   143         
       
   144 	        
       
   145         /**
       
   146         * close conversations overloaded method.
       
   147         */
       
   148         void CloseConversationL( const RMessage2 &aMessage );
       
   149 
       
   150         /**
       
   151          * close All conversations availabe in service.
       
   152          */
       
   153         void CloseAllConversationL( TInt aServiceId );
       
   154         
       
   155 		/**
       
   156 		* Deactivate ongoing conversation
       
   157 		*/
       
   158         void DeactivateConversationL();
       
   159 			
       
   160 		/**
       
   161 		* check if conversation already exist write ETrue if exist at 3rd index of message
       
   162 		*/
       
   163 		void CheckConversationExistL( const RMessage2 &aMessage );
       
   164 		
       
   165       
       
   166 		/**
       
   167         * find the add contact header at given index
       
   168         * @return contact header , NULL if not found
       
   169         */
       
   170 		MIMCacheMessageHeader* ChatHeaderAt( TInt aIndex );
       
   171 
       
   172 		/**
       
   173         * total contact header counts
       
   174         * @return the count
       
   175         */
       
   176 		TInt ChatHeadersCount() ;
       
   177 		
       
   178 		/**
       
   179         * return array of chat headers corresponding to given service
       
   180         * @param aServiceId, service id
       
   181         * @param aServiceHeaderArray, filled with the headers corresponding to aServiceId,: out parameter.
       
   182         * @return array of chat headers
       
   183         */
       
   184 		void GetServiceChatHeaderArrayL(TInt aServiceId , RPointerArray<MIMCacheMessageHeader>& aServiceHeaderArray );
       
   185 private:
       
   186         /**
       
   187          * Internal class used as a wrapper around a plugin
       
   188          * and its uid.
       
   189          */
       
   190         class CPluginInfo : public CBase
       
   191             {
       
   192             public: // Constructor & Destructor
       
   193                 CPluginInfo( CInstantMsgIndicator* aPlugin, TUid aUid );
       
   194                 ~CPluginInfo();
       
   195 
       
   196             public: // New functions
       
   197                 CInstantMsgIndicator& Plugin();
       
   198             private: // Data
       
   199                 CInstantMsgIndicator* iPlugin;
       
   200                 TUid iPluginUid;
       
   201             };		
       
   202 private :		
       
   203         /**
       
   204         * pointer to CIMCacheServer& aServer doesnt own
       
   205         */
       
   206 		CIMCacheServer& iServer;
       
   207 		
       
   208 		// owned, main cache array		
       
   209 		RPointerArray<MIMCacheMessageHeader> iHeaderArray;
       
   210 		
       
   211 		// not owned, active conversation header
       
   212 		MIMCacheMessageHeader* iActiveHeader;
       
   213 		
       
   214 		//owned, pointer to msg factory
       
   215 		TIMCacheMessageFactory* iMessageFactory;
       
   216 		
       
   217         // takes ownership of the plugins
       
   218         RPointerArray<CPluginInfo> iPluginInfo; 
       
   219 	
       
   220 	};
       
   221 	
       
   222 #endif      //  __CIMCACHESERVERACTIVEHELPER_H__
       
   223 
       
   224 
       
   225 //  END OF FILE
       
   226 
       
   227