imstutils/imconversationview/imcvuiengine/inc/cimcvengine.h
changeset 15 81eeb8c83ce5
parent 0 5e5d6b214f4f
equal deleted inserted replaced
0:5e5d6b214f4f 15:81eeb8c83ce5
     1 /*
       
     2 * Copyright (c) 2007-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:  owner class of this dll
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CIMCVENGINE_H
       
    19 #define CIMCVENGINE_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include  <e32base.h>
       
    23 
       
    24 #include <ximpclient.h>
       
    25 #include <ximpcontext.h>
       
    26 #include <ximpcontextobserver.h>
       
    27 #include <ximpcontextstate.h>
       
    28 #include "mimcvenginecchhandler.h"
       
    29 #include "mimcvengineopenchats.h"
       
    30 #include "mimcvenginecchobserver.h"
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 
       
    34 class   MIMCVEngineChatInterface;
       
    35 class   CIMCVEngineMessageHandler;
       
    36 class   MIMCVEngineMessageCreator;
       
    37 class 	CIMCVEngineContextObserver;
       
    38 class 	MIMCVEngineMessageHandler;
       
    39 class 	MIMCVEngineConnectionHandler;
       
    40 class   CIMCVEngineCchHandler;
       
    41 class   MBSAccess;
       
    42 class   CBSFactory;
       
    43 class   CGulIcon;
       
    44 class   CFbsBitmap;
       
    45 class  CIMCVEngineFetchSmiley;
       
    46 /**
       
    47  *  CIMCVEngine provides one of the interfaces to the engine.
       
    48  *  This interface is used by UI to access network services i.e.
       
    49  *  sending messages and joining to groups e.g. This class is
       
    50  *  also used to get different interfaces to the services
       
    51  *  offered by the imcvengine.dll.
       
    52  *
       
    53  *  @lib imcvengine.lib
       
    54  *  @since 5.0
       
    55  */
       
    56 class CIMCVEngine : public CActive,
       
    57                     public MIMCVEngineCCHObserver
       
    58     {
       
    59     
       
    60     //from MIMCVEngineCCHObserver
       
    61     void ServiceStatusChanged( TInt aServiceId,     								   
       
    62 	                          TServiceState aServiceStatus );	                                 
       
    63     
       
    64     
       
    65     private:
       
    66 	/**
       
    67          * Issues Request
       
    68          */
       
    69     	void IssueRequest();
       
    70     	 		
       
    71     public:  // Constructors and destructor
       
    72 
       
    73         /**
       
    74          * Two-phased constructor.         
       
    75          */
       
    76         static CIMCVEngine* NewL(TInt aServiceId, 
       
    77                 MIMCVEngineMessageCreator& aMessageCreater, 
       
    78                 CBSFactory& aBrandingFactory);
       
    79 
       
    80         /**
       
    81          * Destructor.
       
    82          */
       
    83          virtual ~CIMCVEngine();
       
    84  
       
    85     
       
    86         /**
       
    87          * Get interface for chat interface.
       
    88          */         
       
    89         IMPORT_C MIMCVEngineChatInterface& ChatInterface() const;
       
    90         
       
    91         
       
    92         /**
       
    93          * Get interface to message handler 
       
    94          */
       
    95 		IMPORT_C MIMCVEngineMessageHandler& MessageHandler() const ;
       
    96    
       
    97 	    /**
       
    98          * IsLoggedIn 
       
    99          * Return ETrue if loggedin else EFalse
       
   100          */
       
   101         IMPORT_C TBool IsLoggedIn() const;
       
   102         
       
   103         /**
       
   104          * GetLoggedInUserId 
       
   105          * Return logged in user id 
       
   106          */
       
   107         IMPORT_C const TDesC& GetLoggedInUserId()  ;
       
   108         
       
   109         /**
       
   110          * ReleaseConnectionL 
       
   111          * Release the connection from server
       
   112          */
       
   113        	IMPORT_C void ReleaseConnectionL() ;
       
   114        
       
   115           
       
   116         /**
       
   117          * Checks engine if its ready for shutdown.
       
   118          * @return ETrue if ready.
       
   119          */
       
   120         IMPORT_C TBool ReadyForShutdown();
       
   121 
       
   122     	
       
   123 		/**
       
   124 		* DeleteContextL 
       
   125 		*/
       
   126  		void DeleteContextL() ;
       
   127 
       
   128 		/**
       
   129 		* CreateContextL 
       
   130 		*/
       
   131  		void CreateContextL() ;
       
   132 	
       
   133  		 /**
       
   134           * GetLoggedInUserId 
       
   135           * Return logged in user id 
       
   136           */
       
   137         IMPORT_C const TDesC8& GetBrandId()  ;
       
   138         
       
   139         /**
       
   140          * Get Service Specific Array of Smiley Strings 
       
   141          * Return array
       
   142          * ownership not transferred
       
   143          */
       
   144         IMPORT_C RPointerArray<HBufC> GetSmileStringArray();
       
   145         
       
   146         /**
       
   147          * Get Service Specific Icon Array of Smiley's 
       
   148          * Return array
       
   149          * ownership not transferred
       
   150          */        
       
   151         IMPORT_C RPointerArray<CGulIcon> GetSmileyIconArray();
       
   152         
       
   153         
       
   154         IMPORT_C CGulIcon* GetPresenceIconL(const TDesC8& aIconid);
       
   155  		        
       
   156        /**
       
   157         * GetLoggedInUserId 
       
   158         * Return logged in user id 
       
   159         */
       
   160         IMPORT_C TInt GetLanguageId()  ;
       
   161         
       
   162         
       
   163        /**
       
   164         * CCHHandler 
       
   165         * Returns handler to CCH 
       
   166         */
       
   167         IMPORT_C MIMCVEngineCchHandler& CCHHandler() ;
       
   168         
       
   169         
       
   170         /**
       
   171         * ServiceName 
       
   172         * Returns Name of the Service
       
   173         */                
       
   174 		IMPORT_C const TDesC& ServiceName() ;
       
   175 		
       
   176 		
       
   177 		/**
       
   178         * Returns the M-Interface class for list of Open Conversations 
       
   179         * Returns MIMCVEngineOpenChats
       
   180         */
       
   181 		IMPORT_C MIMCVEngineOpenChats& OpenChats() ;
       
   182 		
       
   183 		
       
   184 		/**
       
   185         * ServiceId 
       
   186         * Returns Service Id of the Engine
       
   187         */
       
   188 		IMPORT_C TInt GetServiceId() ;
       
   189 		
       
   190 		
       
   191 		/**
       
   192 		* Resolves the CCH service state to and does a bindl to
       
   193 		* ximpfw if required.
       
   194 		*/
       
   195 		IMPORT_C void ResolveServiceStateL();		
       
   196 		
       
   197 		/**
       
   198 		* Login to the Service
       
   199 		* 
       
   200 		*/
       
   201 		IMPORT_C TInt LoginL();
       
   202 		
       
   203 		/**
       
   204          * CreateConnectionL
       
   205         */
       
   206 		void CreateConnectionL() ;
       
   207 		
       
   208 		/*
       
   209 		 * close all open chats
       
   210 		 */
       
   211 		void CloseAllOpenChatsL();
       
   212 		
       
   213 	private:
       
   214 
       
   215         /**
       
   216          * By default Symbian OS constructor is private.
       
   217          */
       
   218         void ConstructL(MIMCVEngineMessageCreator& aMessageCreater );
       
   219 
       
   220         /**
       
   221          * C++ default constructor.
       
   222          * @see CIMCVEngine::NewL.
       
   223          */
       
   224         CIMCVEngine(TInt aServiceId,CBSFactory& aBrandingFactory);
       
   225 		
       
   226 		
       
   227 		/**
       
   228          * Returns property brand language.
       
   229          *
       
   230          * @since S60 5.0
       
   231          * @param aServiceId, service id
       
   232          * @return TLanguage, brand language
       
   233          */        
       
   234         TLanguage PropertyBrandLanguageL( 
       
   235             TUint32 aServiceId );
       
   236 
       
   237 
       
   238 		/**
       
   239          * Gets brand id
       
   240          *
       
   241          * @since S60 5.0
       
   242          * @param aServiceId service id
       
   243          * @param aBrandId brand id
       
   244          * @return None
       
   245          */
       
   246         void GetBrandIdL( TUint32 aServiceId, TDes8& aBrandId );
       
   247 
       
   248 		/**
       
   249          * Gets the Settings ID
       
   250          *
       
   251          * @since S60 5.0
       
   252          * @param aServiceId, service id         
       
   253          * @return settings id
       
   254          */						
       
   255 		TInt PropertySettingsIdL( TUint32 aServiceId );	
       
   256 		
       
   257 		
       
   258 		/**
       
   259          * Gets the User Id ID
       
   260          *
       
   261          * @since S60 5.0
       
   262          * @param aUserId holds the user id    
       
   263          * @return None
       
   264          */
       
   265 		void GetUserIdL(TPtr& aUserId ) ;
       
   266 		
       
   267 		/**
       
   268          * Gets the ServiceName
       
   269          *
       
   270          * @since S60 5.0
       
   271          * @param aServiceId, service id 
       
   272          * @param aServiceName holds the ServiceName    
       
   273          * @return None
       
   274          */
       
   275 		void GetServiceNameL( TUint32 aServiceId, TDes& aServiceName );
       
   276 		/**
       
   277 		 *consturct's the brandaccess specific to service engine
       
   278 		 */
       
   279 		void ConstructBrandL();
       
   280 		
       
   281 		/**
       
   282 		 *utility function to parse the smiley string received from branding server
       
   283 		 * for example if smiley string is  ":-) [8]"
       
   284 		 * it forms an array of each smiley string 
       
   285 		 */
       
   286 		void ParseAllSmileyStringL(TInt aTotalCount, const TDesC& aAllSmileyString);
       
   287 	
       
   288 	private: // From CActive
       
   289         void RunL();
       
   290         void DoCancel();
       
   291         TInt RunError(
       
   292                 TInt aError );
       
   293                 	
       
   294     private:    // Data
       
   295     
       
   296     	/// Process states
       
   297         enum TState
       
   298             {
       
   299             ELogin,                        
       
   300             EOperationComplete,
       
   301             EOperationInComplete
       
   302             };
       
   303         
       
   304                 
       
   305 		// service id to use
       
   306 		TInt iServiceId;
       
   307 		
       
   308 			// own user id
       
   309 		HBufC* iOwnUserId;
       
   310 		
       
   311 		//  Owns,Settings id of the service..
       
   312         HBufC8* iBrandId;
       
   313 
       
   314         // Language id
       
   315         TInt iLanguageId; 
       
   316 		
       
   317 	    // Owns , reference to message handler
       
   318         CIMCVEngineMessageHandler*      iMessageHandler;
       
   319        
       
   320       
       
   321         //owned, Chat interface
       
   322         MIMCVEngineChatInterface* iChatInterface;
       
   323         
       
   324         // own , client for ximp framework
       
   325 		MXIMPClient*               		  iClient;
       
   326 		// own ,presence context to ximp framework
       
   327 		MXIMPContext*     		  iPresenceContext;
       
   328 		
       
   329 		//owned, observre for ximp call back
       
   330 		CIMCVEngineContextObserver* iContextEventObserver;
       
   331 		
       
   332 		//Stores the XIMPFw EventTypes Subscribed for		
       
   333 		RArray< TInt32 > iAcceptedEventTypes;
       
   334 	
       
   335 		//owns the handler for CCH
       
   336 		CIMCVEngineCchHandler* iCCHHandler;
       
   337 		
       
   338 		//Owns the ServiceName
       
   339 		HBufC* iServiceName;
       
   340 		
       
   341 		/// Own: State of the command
       
   342         TState iState;  
       
   343         
       
   344         // own active sheduler 
       
   345         CActiveSchedulerWait    iWait;      
       
   346         //doesn't own
       
   347         CBSFactory& iBrandingFactory;
       
   348                   
       
   349         //owns: branding access specific to service
       
   350         MBSAccess* iBrandingAccess;
       
   351         // not owned array of smiley strings
       
   352         RPointerArray<HBufC> iSmileyArray; 
       
   353         // not owned ,array of smiley icons
       
   354         RPointerArray<CGulIcon> iSmileyDlgIconArray;
       
   355         // ETrue if array owned
       
   356         TBool iSmileyArrayOwned;
       
   357         // ETrue if array owned
       
   358         TBool iSmileyDlgIconArrayOwned;
       
   359     };
       
   360 
       
   361 #endif      // CIMCVENGINE_H
       
   362 
       
   363 // End of File