imstutils/imconversationview/imcvuiengine/inc/cimcvenginefactory.h
branchRCL_3
changeset 28 3104fc151679
parent 27 2b7283837edb
child 29 9a48e301e94b
equal deleted inserted replaced
27:2b7283837edb 28:3104fc151679
     1 /*
       
     2 * Copyright (c) 2008-2009 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:  service engine factory class 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CIMCVENGINEFACTORY_H
       
    20 #define CIMCVENGINEFACTORY_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 #include "mimcvenginefactory.h"
       
    25 #include "mimcvengineopenchats.h"
       
    26 #include <mspnotifychangeobserver.h>
       
    27 #include "mimcvenginemessagehandlerobserver.h"
       
    28 #include "mimcvenginechatlistobserver.h"
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class CIMCVEngine;
       
    32 class MIMCVEngineConnectionHandler;
       
    33 class MIMCVEngineOpenChatsObserver;
       
    34 class CSPSettings;
       
    35 class MIMCVEngineMessageCreator;
       
    36 class CBSFactory;
       
    37 class CSPNotifyChange;
       
    38 class MIMCVEngineChatListObserver;
       
    39 class CIMCVEngineStorageListener;
       
    40 
       
    41 // CLASS DECLARATION
       
    42 /**
       
    43  *  Factory to create engine.
       
    44  *  This class implements the factory for creating engine
       
    45  *
       
    46  *  @lib vimpstengine.lib
       
    47  *  @since S60 5.0
       
    48  */
       
    49 
       
    50 class CIMCVEngineFactory : public CBase,
       
    51 						   public MIMCVEngineFactory,
       
    52 						   public MIMCVEngineOpenChatsObserver,
       
    53 						   public MSPNotifyChangeObserver,
       
    54 						   public MIMCVEngineMessageHandlerObserver,
       
    55 						   public MIMCVEngineChatListObserver
       
    56 	{
       
    57 	public:  // Two-phased constructors and destructor
       
    58 
       
    59 	   /**
       
    60 		* @returns a single instance of MVIMPSTEngineFactory
       
    61 		*/
       
    62 		IMPORT_C static MIMCVEngineFactory* InstanceL();
       
    63 		
       
    64 	   /**
       
    65 		* Release 
       
    66 		* dont call delete   
       
    67 		*/
       
    68 		IMPORT_C static void Release();
       
    69 		
       
    70 		/**
       
    71 		 * c++ default destructor
       
    72 		 * dont call delete 
       
    73 		 */
       
    74 		virtual ~CIMCVEngineFactory();
       
    75 		
       
    76 	private:	
       
    77 	
       
    78 	   	/**
       
    79 		 * NewLC two phase constructor.
       
    80 		 * dont call delete call close 
       
    81 		 */
       
    82 		static CIMCVEngineFactory* NewLC();
       
    83 
       
    84 		/**
       
    85 		 * Second phase construction
       
    86 		 * ConstructL
       
    87 		 */
       
    88 		void ConstructL();
       
    89 
       
    90 		/**
       
    91 		 * C++ constructor.
       
    92 		 */
       
    93 		CIMCVEngineFactory();
       
    94 		
       
    95 		
       
    96 		void CreateServiceEngineL( TInt aServiceId );
       
    97 		
       
    98 		
       
    99 		TBool CheckValidIMServiceL(CSPSettings& aSettings , TInt aServiceId) ;
       
   100 		
       
   101 		TUint32 ContactViewUidL(CSPSettings& aSettings, TUint32 aServiceId );
       
   102 		
       
   103 		void ReadAndCreateAllValidServiceL();
       
   104 		
       
   105 	
       
   106 	public: //From MVIMPSTEngineFactory
       
   107 			
       
   108 	    /**
       
   109 	     * return the engine instance for aServiceId.
       
   110 	     */
       
   111 	    CIMCVEngine& GetServiceEngineL( TInt aServiceId )  ;
       
   112 	    
       
   113 	    /**
       
   114 	     * find and release the engine instance for aServiceId.
       
   115 	     */
       
   116 	    void ReleaseServiceEngine( TInt aServiceId );
       
   117 	    
       
   118 	    /**
       
   119 	     * @see MVIMPSTEngineFactory
       
   120 	     */
       
   121 	    TPtrC GetDisplayNameL(TInt aIndex) const;
       
   122 
       
   123 
       
   124 	    /**
       
   125 	     * @see MVIMPSTEngineFactory
       
   126 	     */
       
   127 	    const TDesC& GetTargetIdL(TInt aIndex) const;
       
   128 
       
   129 
       
   130 	    /**
       
   131 	     * @see MVIMPSTEngineFactory
       
   132 	     */
       
   133 	    TInt Count() const;
       
   134 
       
   135 	    /**
       
   136 	     * @see MVIMPSTEngineFactory
       
   137 	     */     
       
   138 	    void SetActiveItemL( const TInt aIndex );
       
   139 
       
   140 	    /**
       
   141 	     * @see MVIMPSTEngineFactory
       
   142 	     */     
       
   143 	    const TDesC& GetActiveItemL() const;
       
   144 
       
   145 	    /**
       
   146 	     * @see MVIMPSTEngineFactory
       
   147 	     */     
       
   148 	    TBool IsMsgPendingL( const TInt aIndex ) const;
       
   149 
       
   150 	    /**
       
   151 	     * @see MVIMPSTEngineFactory
       
   152 	     */     
       
   153 	    TInt FindIndexL(const TDesC& aItem);
       
   154 	    
       
   155 	    /**
       
   156 	     * @see MVIMPSTEngineFactory
       
   157 	     */  
       
   158 	    void ResetL();
       
   159 	    
       
   160 	    /**
       
   161 	     * @see MVIMPSTEngineFactory
       
   162 	     */
       
   163 	    void RegisterOpenChatObserver(MIMCVEngineOpenChatsObserver* aChatObserver);
       
   164 
       
   165 	    /**
       
   166 	     * @see MVIMPSTEngineFactory
       
   167 	     */
       
   168 	    void UnRegisterOpenChatObserver();
       
   169 	 
       
   170 	    
       
   171 	    TInt GetActiveServiceId();
       
   172 		/*
       
   173 		* return all service engines array
       
   174 		*/
       
   175 	    RPointerArray<CIMCVEngine>&  GetServiceEngines();
       
   176 	   
       
   177 	    /**
       
   178 	     * @see MVIMPSTEngineFactory
       
   179 	     */
       
   180 	    void RegisterServiceObserver(MIMCVEngineServiceChangeObserver* aServiceObserver)  ;
       
   181 	    /**
       
   182 	     * @see MVIMPSTEngineFactory
       
   183 	     */
       
   184 	    void UnRegisterServiceObserver() ;
       
   185 	    
       
   186 	 
       
   187 	private :
       
   188 	    
       
   189 	    /**
       
   190 	     * @see handle the presence change notification
       
   191 	     * to handle the connection lost
       
   192 	     */
       
   193 	    void HandlePresenceChangedL(TInt aServiceId, const TDesC& aBuddyId )  ;
       
   194 
       
   195 	    /**
       
   196 	     * Handle message send operation completion.
       
   197 	     * @param aResult result  to handle.
       
   198 	     */
       
   199 	    void HandleOperationCompletdL(TInt aserviceId, MIMCVEngineMessage::TMessagerType aType , TInt aResult)  ;
       
   200 
       
   201 	    /**
       
   202 	     * @see HandleConnectionTerminatedL
       
   203 	     * to handle the connection lost
       
   204 	     * @param aReason, reason report
       
   205 	     */
       
   206 	    void HandleConnectionEventL(TInt aServiceId, TIMCVConnectionState aState, TInt aReason )    ;
       
   207 	    
       
   208 	    /**
       
   209 	     * Handle events.
       
   210 	     * @param aEvent Event to handle.
       
   211 	     * @param aContainerInfo, Container
       
   212 	     */
       
   213 	    void HandleChatListEvent(TInt aServiceId, TChatListEventType aEvent, 
       
   214 	            MIMCVEngineMessageReadInterface* aContainerInfo
       
   215 	             ) ;
       
   216 
       
   217 
       
   218 	private: // From MSPNotifyChangeObserver
       
   219 	    
       
   220 	    /**
       
   221 	     * From MSPNotifyChangeObserver 
       
   222 	     * Callback when service has changed
       
   223 	     *
       
   224 	     * @since S60 5.0
       
   225 	     * @param aServiceId changed service
       
   226 	     * @return None
       
   227 	     */
       
   228 	    void HandleNotifyChange( TServiceId aServiceId );
       
   229 
       
   230 	    /**
       
   231 	     * From MSPNotifyChangeObserver 
       
   232 	     * Callback when service error occures
       
   233 	     *
       
   234 	     * @since S60 5.0
       
   235 	     * @param aError error code
       
   236 	     * @return None
       
   237 	     */
       
   238 	    void HandleError( TInt aError );
       
   239 	    
       
   240 	    /*
       
   241 	     * end the cv process
       
   242 	     */
       
   243 	    void ShutDownConversationviewL();
       
   244 	        
       
   245 	private:
       
   246 	    /** 
       
   247 	     * @see MIMCVEngineOpenChatsObserver
       
   248 	     */
       
   249 	    void HandleChangeL(TInt aServiceId , TInt aIndex, TOpenChatsEventType aChangeType) ;
       
   250 
       
   251 	    /**
       
   252 	     * @see MIMCVEngineOpenChatsObserver
       
   253 	     */
       
   254 	    void SetStatusMsgL(TInt aServiceId, TInt aIndex,const TDesC & aMsg);
       
   255 	 
       
   256 	 private :
       
   257 	     /*
       
   258 	      * helper method to for service table change
       
   259 	      */
       
   260 	    void DoHandleServiceChangeL( TInt aServiceId );
       
   261 	    
       
   262  	private :	
       
   263 	    // Owns : message creater 
       
   264 	    MIMCVEngineMessageCreator* iMessageCreator;
       
   265 	    //owns array of services
       
   266 		RPointerArray<CIMCVEngine> iServiceEngines;	
       
   267 		// not owns
       
   268 		MIMCVEngineOpenChatsObserver* iChatObserver;
       
   269 		// active service Id
       
   270 		TInt iActiveServiceId;
       
   271 		// active chat index
       
   272 		TInt iActiveChatIndex;
       
   273 		//owns brandingfactory for service specific icons
       
   274 		CBSFactory* iBrandingFactory; 
       
   275 		// Own: service observer
       
   276 		CSPNotifyChange* iSpNotifyChange;  
       
   277 		// not own 
       
   278 		MIMCVEngineServiceChangeObserver* iServiceChangeObserver;
       
   279 	    };
       
   280 
       
   281 #endif      //CIMCVENGINEFACTORY_H
       
   282 
       
   283 //  End of File
       
   284 
       
   285