imstutils/imconversationview/imcvuiapp/inc/cimcvappviewcontainer.h
branchRCL_3
changeset 23 9a48e301e94b
parent 0 5e5d6b214f4f
equal deleted inserted replaced
22:3104fc151679 23:9a48e301e94b
       
     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:  main view container class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef _CIMCVAPPVIEWCONTAINER_H
       
    21 #define _CIMCVAPPVIEWCONTAINER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include "cimcvapprichtextcontainercache.h"
       
    25 #include "mimcvapplayoutchangeobserver.h"
       
    26 #include "mimcvtapeventobserver.h"
       
    27 #include "cimcvappmessageeditor.h"
       
    28 
       
    29 #include <badesca.h> //For the CDesCArray
       
    30 #include <AknWaitDialog.h>
       
    31 #include "cimcvengine.h"
       
    32 // FORWARD DECLARATIONS
       
    33 class CIMCVAppMessageExtensionsHandler;
       
    34 class CIMCVAppViewControl;
       
    35 class MIMCVEngineMessageReadInterface;
       
    36 class MIMCVEngineMessageWriteInterface;
       
    37 class MIMCVEngineMessage;
       
    38 class CIMCVAppUi;
       
    39 class MIMCVUiAppSkinVariant;  
       
    40 class MIMCVRecipientObserver;
       
    41 class CIMCVAppLoginEventListener;
       
    42 class CIMCVAppView;
       
    43 class CIMCVAppMessageEditor;
       
    44 class MIMCVEngineFactory;
       
    45 
       
    46 // CLASS DECLARATION
       
    47 
       
    48 /**
       
    49 *  This is container class for conversation view
       
    50 */
       
    51 class CIMCVAppViewContainer : public CCoeControl,
       
    52 								  public MEikEdwinSizeObserver,
       
    53 								  public MIMCVAppLayoutChangeObserver,
       
    54 								  public MCoeControlObserver,
       
    55 								  public MIMCVAppMessageEditorObserver,
       
    56 								   public MIMCVTapEventObserver
       
    57     {
       
    58     public: // Enumerations
       
    59     
       
    60         /** 
       
    61          * Observed controls 
       
    62          */
       
    63         enum TTouchableControls
       
    64             {
       
    65             EMessageList = 1,
       
    66             EMessageEditor
       
    67             };
       
    68 
       
    69     public:  // Constructors and destructor
       
    70 
       
    71         /**
       
    72         * Symbian OS default constructor.
       
    73         * @param aRect Frame rectangle for container.
       
    74         * @param aEngine, refence to engine
       
    75         * @param aReadInterface to read the messages
       
    76 		* @param aWriteInterface for writing the messages
       
    77 		* @param aParent Context access mechanism.
       
    78 		* @param aMessageHandler Handling messages
       
    79 		* @param aCba Pointer to cba of view.
       
    80 		* @param aRecipientId, recipient user id
       
    81 		* @param aBrandingAccess, brand accessor
       
    82 	    */
       
    83 		static CIMCVAppViewContainer* NewL( const TRect& aRect,
       
    84 			CIMCVEngine* aEngine,
       
    85 			MIMCVEngineMessageReadInterface* aReadInterface,
       
    86 		    MIMCVEngineMessageWriteInterface* aWriteInterface,
       
    87 		    CIMCVAppView* aParent,
       
    88             CIMCVAppMessageExtensionsHandler& aMessageHandler,
       
    89 			CEikButtonGroupContainer* aCba,					
       
    90 			const TDesC& aRecipientId,			
       
    91 			MIMCVRecipientObserver* aRecipientObserver,
       
    92             CIMCVAppRichTextContainerCache* aRTContainerCache,
       
    93             CGulIcon* aFromMe, CGulIcon* aToMe);
       
    94 
       
    95 	
       
    96 	    /**
       
    97         * Destructor.
       
    98         */
       
    99         virtual ~CIMCVAppViewContainer();
       
   100 
       
   101 
       
   102 	private:
       
   103 
       
   104         /**
       
   105         * Symbian OS default constructor.
       
   106         * @param aRect Frame rectangle for container.
       
   107 		* @param aParent Context access mechanism.
       
   108         */
       
   109         void ConstructL( const TRect& aRect, MObjectProvider* aParent,
       
   110                 CGulIcon* aFromMe, CGulIcon* aToMe ,
       
   111                 const TDesC& aRecipientId );
       
   112 
       
   113 
       
   114     public: // New functions
       
   115         const TRect TextRect() const;        
       
   116         
       
   117         
       
   118         /**
       
   119         * Switches the Containers ReadInterface & WriteInterface
       
   120         * @param aReadInterface to read the messages
       
   121 		* @param aWriteInterface for writing the messages
       
   122 		*/
       
   123         void SwitchViewL( MIMCVEngineMessageReadInterface* aReadInterface,
       
   124         						MIMCVEngineMessageWriteInterface* aWriteInterface,
       
   125         						const TDesC& aRecipientId );        
       
   126         
       
   127         /*
       
   128          * assigned new engine instance
       
   129          */
       
   130         void SetServiceParametersL(CIMCVEngine* aNewEngine ) ; 
       
   131         /**
       
   132          * Returns buffer containing the currently selected text
       
   133          * (or empty buffer if nothing selected)
       
   134          */
       
   135         HBufC* SelectedItemL();
       
   136         
       
   137         /**
       
   138          * @return Type of selected item
       
   139          */
       
   140         TInt SelectedItemType();
       
   141 
       
   142        
       
   143 		/**
       
   144         * This method starts scrolling
       
   145 		* @since 5.0
       
   146         */
       
   147         void StartScrollingL();
       
   148 
       
   149 		/**
       
   150 		 * This method stops scrolling
       
   151 		 * @since 5.0
       
   152 		 */
       
   153 		void StopScrollingL();
       
   154 
       
   155 		void StartConversationL();
       
   156 
       
   157 			
       
   158 		/**
       
   159         * This closes the active conversation 
       
   160 		* @since 5.0
       
   161         */
       
   162 		TInt CloseConversationL(const TDesC& aBuddyId );
       
   163 		
       
   164 		/**
       
   165         * This will deactivate the active conversation 
       
   166 		* @since 5.0
       
   167         */
       
   168 		TInt DeactivateConversationL();
       
   169 		
       
   170 		/**
       
   171         * This method handles message sending
       
   172 		* @since 5.0
       
   173         */
       
   174         void SendMessageL();
       
   175         
       
   176         /**
       
   177         * This method insert a message about the presence status changes
       
   178 		* @since 5.0
       
   179         */
       
   180         void InsertStatusChangedMessageL(CIMCVEngine& aEngine, TInt aServiceId,const TDesC& aBuddyId );
       
   181         
       
   182 		/**
       
   183 		 * Return reference of CIMCVAppMessageEditor object.
       
   184 		 */
       
   185         CIMCVAppMessageEditor& Editor()	const ;
       
   186         
       
   187         /**
       
   188         * This checks if scroll mode is on or off
       
   189 		* @since 3.2
       
   190         * @return Returns if scrolling is stopped or not (TBool)
       
   191         */
       
   192         TBool IsStopped() const;
       
   193         
       
   194         /**
       
   195          * Sets item highlighting on or off (automatic find)
       
   196          * @param aHihghlight ETrue to set finder on
       
   197          */
       
   198         void SetItemHighlightL( TBool aHighlight );
       
   199         
       
   200         
       
   201         /**
       
   202          * Should we fetch new messages or not
       
   203          * @param aFetch ETrue if this chat is in foreground and should receive 
       
   204          *               messages, EFalse otherwise.
       
   205          */
       
   206         void FetchMessages( TBool aFetch );
       
   207         
       
   208       	      
       
   209          /**
       
   210          * Method to force refresh in the rich text editor,
       
   211          * called from view when adding a smiley.
       
   212          * @since 3.0
       
   213          */
       
   214         void RefreshEditorL();
       
   215 
       
   216          /**
       
   217          * Loads fome/tome icons 
       
   218          * @param aId, Id of the element required by the brnading server
       
   219          * aBitmapId, id of the icon
       
   220          * aMaskId of the icon
       
   221          */
       
   222         CGulIcon* LoadBitmapL(const TDesC8& aId, const TInt aBitmapId,const TInt aMaskId );
       
   223         
       
   224 		/**
       
   225 		* IsLoggedIn
       
   226 		* @return ETrue if logged in else EFalse
       
   227 		* @since 5.0
       
   228 		*/                             
       
   229 		TBool IsLoggedIn() const;
       
   230 		
       
   231 		        
       
   232         /**
       
   233          * Update the CBA labels
       
   234          */
       
   235         void UpdateCbaL();
       
   236         
       
   237         /*
       
   238          * Saves the message typed in the message editor of 
       
   239          * container
       
   240          */
       
   241         void StoreEditorMessageL();
       
   242 		void SmileyDialogLaunched (TBool aLaunched);
       
   243 		void UpdateChatViewL ();
       
   244 	                                  
       
   245     private: 
       
   246         
       
   247         /**
       
   248          * This function does basic clearing after the message is sent
       
   249          */
       
   250         void ResetAfterSendL();
       
   251         
       
   252 		/**
       
   253 		 * This function displays information notes
       
   254 		 * @param aResourceId Resource ID of note
       
   255 		 */
       
   256 		void DisplayInfoNoteL( const TInt aResourceId );
       
   257 
       
   258         void ResizeIcons( TRect aParentRect ) ;
       
   259         
       
   260         
       
   261 	private:
       
   262 	
       
   263 		void MapFromBitmapIdToAknsItemId( TInt aBitmapId, 
       
   264                                 TAknsItemID& aItemId, TInt& aColorGroupId );
       
   265                                 	
       
   266    		//does not Owns. "From me" icon
       
   267 		CGulIcon* iFromMe;
       
   268 		
       
   269 		//does n0t Owns. "To me" icon
       
   270 		CGulIcon* iToMe;
       
   271 		
       
   272 
       
   273     private: // Functions from base classes    
       
   274 
       
   275 		/**
       
   276 		 * From MIMCVAppLayoutChangeObserver, for layout change observing
       
   277 		 */
       
   278 		void LayoutChangedL( TInt aType );
       
   279         
       
   280 		
       
   281 		/**
       
   282          * From MEikEdwinSizeObserver, This method handles edwin's size change
       
   283          * @param aEdwin The edwin for which the size event is being handled
       
   284 		 * @param aEventType The event type
       
   285 		 * @param aDesirableEdwinSize The desired size for the edwin identified 
       
   286 		 *                            by aEdwin
       
   287          * @return The return value depends on your implementation. 
       
   288          *         Return ETrue if you wish to redraw the edwin. 
       
   289          *         EFalse otherwise
       
   290          */
       
   291         TBool HandleEdwinSizeEventL( CEikEdwin* aEdwin,
       
   292 			TEdwinSizeEvent aEventType, TSize aDesirableEdwinSize );
       
   293 		
       
   294   
       
   295         
       
   296     private: // From MCoeControlObserver
       
   297 
       
   298 		/**
       
   299          * @see MCoeControlObserver
       
   300          */
       
   301         void HandleControlEventL( CCoeControl* aControl,TCoeEvent aEventType );
       
   302 
       
   303 	private: // Functions CCoeControl
       
   304 
       
   305         /**
       
   306         * From CoeControl, Handles "size changed"-events..
       
   307         */
       
   308         void SizeChanged();
       
   309 
       
   310         /**
       
   311         * From CoeControl, 
       
   312         * Returns the number of control contained by this class.
       
   313 		* @return Number of controls contained
       
   314         */
       
   315         TInt CountComponentControls() const;
       
   316 
       
   317         /**
       
   318         * From CCoeControl, Returns handle to control pointed by aIndex
       
   319         * @param aIndex Wanted control's index [0..n]
       
   320         * @return Handle to wanted control
       
   321         */
       
   322         CCoeControl* ComponentControl( TInt aIndex ) const;
       
   323 
       
   324        /**
       
   325         * From CCoeControl, Gets called when drawing is needed (by framework)
       
   326         * @param aRect Rect that needs to be drawed
       
   327         */
       
   328         void Draw( const TRect& aRect ) const;
       
   329 
       
   330         /**
       
   331         * From CCoeControl, Handles key-events
       
   332         * @param aKeyEvent Event that occured
       
   333 		* @param aType Type of key-event 
       
   334 		*              (EEventKey, EEventKeyUp or EEventKeyDown)
       
   335         * @return Containers response to event 
       
   336         *                    (EKeyWasNotConsumed/ EKeyWasConsumed)
       
   337         */
       
   338 		TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, 
       
   339 		                             TEventCode aType );
       
   340 
       
   341 		
       
   342 	private:    // From MIMCVAppMessageEditorObserver
       
   343 	
       
   344 	    /**
       
   345          * Handle editor event.
       
   346          */
       
   347         void HandleMessageEditorEventL( TEditorEvent aEvent );
       
   348         	
       
   349     private:    // new functions
       
   350     		/**
       
   351         * Constructor
       
   352         * @param aEngine, refence to engine
       
   353         * @param aReadInterface to read the messages
       
   354 		* @param aWriteInterface for writing the messages
       
   355 		* @param aMessageHandler Handling messages
       
   356 		* @param aCba Pointer to cba of view.
       
   357 		* @param aRecipientId, recipient user id
       
   358 	    */
       
   359 		CIMCVAppViewContainer( 
       
   360 			CIMCVEngine* aEngine,
       
   361 		    MIMCVEngineMessageReadInterface* aReadInterface,
       
   362 		    MIMCVEngineMessageWriteInterface* aWriteInterface,
       
   363 		    CIMCVAppMessageExtensionsHandler& aMessageHandler,
       
   364 			CEikButtonGroupContainer* aCba,
       
   365 			MIMCVRecipientObserver* aRecipientObserver,
       
   366 			CIMCVAppView& aAppView,
       
   367 			CIMCVAppRichTextContainerCache* aRTContainerCache
       
   368 			);
       
   369 			
       
   370     private: // From MIMCVTapEventObserver
       
   371 
       
   372 		/**
       
   373          * @see MIMCVTapEventObserver
       
   374          */
       
   375         void HandleTapEventL( TTapEvent aEvent, TUint aControlId );
       
   376             
       
   377       
       
   378     private:    // Data
       
   379         // not owned, reference to uiengine
       
   380         CIMCVEngine* iActiveEngine ;
       
   381         
       
   382         // not owned., reference to appui	
       
   383         CIMCVAppUi* iAppUi;
       
   384         // Owns. Chat view control
       
   385         CIMCVAppViewControl* iChatView;
       
   386         // not owned, message read interface
       
   387         MIMCVEngineMessageReadInterface* iReadInterface;
       
   388         // not owned, message witre interface
       
   389 		MIMCVEngineMessageWriteInterface* iWriteInterface;
       
   390        	
       
   391 
       
   392 		// owned, outer line
       
   393 		TAknLayoutRect iOutLine;
       
   394 		// owned, horizontal  line
       
   395 		TAknLayoutRect iHoriline;
       
   396 		// owned, vertical line
       
   397 		TAknLayoutRect iVertLine;
       
   398 			
       
   399 
       
   400 		// not owned, message extention handler
       
   401         CIMCVAppMessageExtensionsHandler& iMessageExtensionsHandler;
       
   402         
       
   403                
       
   404         // Does not own. Pointer to cba of view.
       
   405         CEikButtonGroupContainer* iCba;
       
   406         
       
   407               
       
   408         //holds the reference to the contact to which 
       
   409         //conversation has been established.
       
   410         HBufC* iRecipientId;
       
   411               
       
   412         // owned, message content
       
   413         HBufC* iEditorMessage;
       
   414         
       
   415         // not owned
       
   416         MIMCVUiAppSkinVariant* iSkinVaiant;       
       
   417       
       
   418         
       
   419         //Doesn't own. Handle to recipient observer
       
   420 		MIMCVRecipientObserver* iRecipientObserver;  
       
   421         
       
   422         //Reference to the AppView object
       
   423        	CIMCVAppView& iAppView;
       
   424        	//owns. meesage editor
       
   425        	CIMCVAppMessageEditor* iMsgEditor;
       
   426        	//Does nt Owns. Cache to store CIMCVAppRichTextContainer objects
       
   427        	CIMCVAppRichTextContainerCache* iRTContainerCache;
       
   428     };
       
   429 
       
   430 #endif      // _CIMCVAPPVIEWCONTAINER_H
       
   431 
       
   432 // End of File