imstutils/imconversationview/imcvuiengine/inc/cimcvenginemessagecontainer.h
changeset 0 5e5d6b214f4f
equal deleted inserted replaced
-1:000000000000 0:5e5d6b214f4f
       
     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:  message container class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __CIMCVENGINEMESSAGECONTAINER_H__
       
    20 #define __CIMCVENGINEMESSAGECONTAINER_H__
       
    21 
       
    22 #include "mimcvenginemessagesreadinterface.h"
       
    23 #include "mimcvenginemessageswriteinterface.h"
       
    24 #include "mimcvenginemessagecontainerinfo.h"
       
    25 #include "mimcvenginemessageobserver.h"
       
    26 
       
    27 //	FORWARD CLASS DECLERATIONS
       
    28 class MIMCVEngineBufferMemoryHandler;
       
    29 class MIMCVEngineNewMsgObserver;
       
    30 class MCAMessage;
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35  *  Container class for messages.
       
    36  *
       
    37  *  @lib imcvengine.dll
       
    38  *  @since 5.0
       
    39  */
       
    40 
       
    41 
       
    42 class CIMCVEngineMessageContainer : public CBase, 
       
    43                             public MIMCVEngineMessageReadInterface, 
       
    44                             public MIMCVEngineMessageWriteInterface,
       
    45                             public MIMCVEngineMessageContainerInfo
       
    46     {
       
    47     public: // Construction
       
    48 		
       
    49 		/**
       
    50 		 * Construction
       
    51 		 * @param aServiceId - ServiceId
       
    52 		 * @param aTargetId, Identifier of container
       
    53 		 * @param aMemoryHandler Handles memory
       
    54 		 * @param aType Type of container. EChatContainer
       
    55 		 * @return Pointer to new created instance of CIMCVEngineMessageContainer
       
    56 		 */
       
    57 		static CIMCVEngineMessageContainer* NewL( 
       
    58                                       TInt aServiceId, 
       
    59                                       const TDesC& aTargetId,
       
    60                                       const TDesC& aDisplayName,  
       
    61                                       const TDesC8& aContactLink,
       
    62 	                                  MIMCVEngineBufferMemoryHandler& aMemoryHandler, 
       
    63 	                                  TContainerType aType );
       
    64 		
       
    65 		/**
       
    66 		 * Construction
       
    67 		 * @param aServiceId - ServiceId
       
    68 		 * @param aTargetId, Identifier of container
       
    69 		 * @param aMemoryHandler Handles memory
       
    70 		 * @param aType Type of container. EChatContainer
       
    71 		 * @return Pointer to new created instance of CIMCVEngineMessageContainer
       
    72 		 */
       
    73 		static CIMCVEngineMessageContainer* NewLC( 
       
    74                                        TInt aServiceId, 
       
    75                                        const TDesC& aTargetId, 
       
    76                                        const TDesC& aDisplayName, 
       
    77                                        const TDesC8& aContactLink,
       
    78 	                                   MIMCVEngineBufferMemoryHandler& aMemoryHandler, 
       
    79 	                                   TContainerType aType  );
       
    80 
       
    81 		/**
       
    82 		 * Destruction
       
    83 		 */
       
    84 		~CIMCVEngineMessageContainer();
       
    85 		
       
    86 	private: // Construction
       
    87 	
       
    88 		/**
       
    89 		 * Constructor
       
    90 		 * @param aMemoryHandler Handles memory
       
    91 		 */
       
    92 		CIMCVEngineMessageContainer( MIMCVEngineBufferMemoryHandler& aMemoryHandler );
       
    93 		
       
    94 		/**
       
    95 		 * Constructor
       
    96 		 * @param aServiceId - ServiceId
       
    97 		 * @param aTargetId, Identifier of container
       
    98 		 * @param aType Type of container. EChatContainer
       
    99 		 */
       
   100 		void ConstructL( 
       
   101                          TInt aServiceId, 
       
   102                          const TDesC& aTargetId,
       
   103                          const TDesC& aDisplayName,  
       
   104                          const TDesC8& aContactLink,
       
   105 		                 TContainerType aType );
       
   106 
       
   107 	private: // Methods from MIMCVEngineMessageReadInterface
       
   108 
       
   109 		/**
       
   110 		 * @see MIMCVEngineMessageReadInterface
       
   111 		 */
       
   112 		TInt UnreadCount( TUnreadFilter aUnreadFilter = EUnreadAll ) const;
       
   113 		
       
   114 		/**
       
   115 		 * @see MIMCVEngineMessageReadInterface
       
   116 		 */
       
   117 		TInt MessageCount() const;
       
   118 		
       
   119 		/**
       
   120 		 * @see MIMCVEngineMessageReadInterface
       
   121 		 */
       
   122 		void StoreEditerMessageL( const TDesC& aEditorMessage );
       
   123 		      
       
   124 		/**
       
   125 	     * @see MIMCVEngineMessageReadInterface
       
   126 		  */
       
   127 		 const TDesC& GetEditerMessage();
       
   128 		                
       
   129 		/**
       
   130 		 * @see MIMCVEngineMessageReadInterface
       
   131 		 */
       
   132 		void Read( TReadType aReadType, TInt aReadAmount = 0 );
       
   133 		
       
   134 		/**
       
   135 		 * @see MIMCVEngineMessageReadInterface
       
   136 		 */
       
   137 		MIMCVEngineMessage& Message( TInt aIndex ) const;
       
   138 		
       
   139 		/**
       
   140 		 * @see MIMCVEngineMessageReadInterface
       
   141 		 */
       
   142 		MIMCVEngineMessage& ReadNextUnread();
       
   143 
       
   144         /**
       
   145 		 * @see MIMCVEngineMessageReadInterface
       
   146 		 */
       
   147         MIMCVEngineMessage& ReadUnreadFromIndex( TInt aIndex );
       
   148 		
       
   149 		/**
       
   150 		 * @see MIMCVEngineMessageReadInterface
       
   151 		 */
       
   152 		void SetObserver( MIMCVEngineMessageObserver* aObserver );
       
   153 		
       
   154 		/**
       
   155 		 * @see MIMCVEngineMessageReadInterface
       
   156 		 */		
       
   157 		TPtrC Name() const;
       
   158 		
       
   159 		/**
       
   160          * @see MIMCVEngineMessageReadInterface
       
   161          */ 
       
   162 		TDesC DisplayName() const;
       
   163 
       
   164 	
       
   165 		/**
       
   166 		 * @see MIMCVEngineMessageReadInterface
       
   167 		 */		
       
   168         void DeleteMessage( TInt aIndex );       
       
   169    
       
   170         
       
   171 		/**
       
   172 		 * @see MIMCVEngineMessageReadInterface
       
   173 		 */		
       
   174         MIMCVEngineMessageContainerInfo& TargetId();
       
   175         
       
   176         /**
       
   177          * @see MIMCVEngineMessageReadInterface         
       
   178          */
       
   179         void Lock( TBool aLocked );   
       
   180         
       
   181         /**
       
   182          * @see MIMCVEngineMessageReadInterface         
       
   183          */
       
   184         void SetActive( TBool aActiveChat );   
       
   185         
       
   186         /**
       
   187          * @see MIMCVEngineMessageReadInterface         
       
   188          */
       
   189         TBool IsActive();  
       
   190         
       
   191 
       
   192         
       
   193 	private: // Methods from MIMCVEngineMessageWriteInterface
       
   194 	
       
   195 		/**
       
   196 		 * @see MIMCVEngineMessageWriteInterface
       
   197 		 */
       
   198 		void AppendL( MIMCVEngineMessage* aMessage, TBool aSharedOwnership );
       
   199 		 
       
   200 	
       
   201 
       
   202 
       
   203 		/**
       
   204 		 * @see MIMCVEngineMessageWriteInterface
       
   205 		 */
       
   206 		TTime Time();
       
   207 		
       
   208 		/**
       
   209          * sets the display name
       
   210          * @param aDispalyName. updated display name
       
   211          */
       
   212 		void SetNameL( const TDesC& aDispalyName );
       
   213 	public:       
       
   214 	    /**
       
   215 	     * sets the contactlink
       
   216 	     * @param aContactLink. updated contactlink
       
   217 	     */
       
   218 	    void  SetLinkL(const TDesC8& aContactLink);
       
   219 
       
   220 	    /**
       
   221 	     * @see MIMCVEngineMessageReadInterface
       
   222 	     */     
       
   223 	    TPtrC8 ContactLink() const;
       
   224 
       
   225 	private: // From MIMCVEngineMessageContainerInfo
       
   226 
       
   227         
       
   228         /**
       
   229          * @see MIMCVEngineMessageContainerInfo
       
   230          */
       
   231         const TDesC& Target() const;
       
   232         
       
   233         /**
       
   234          * Returns target id to be used for
       
   235          * comparisons.         
       
   236          * @return Target id.
       
   237          */
       
   238         const TDesC& ComparableTarget() const;
       
   239         
       
   240         
       
   241         
       
   242     
       
   243 	public: // New methods
       
   244 			
       
   245 		/**
       
   246 		 * Ordering function for ordering Message containers
       
   247 		 * @param aSourceA First compare item.
       
   248 		 * @param aSourceB Second compare item.
       
   249 		 * @return -1, 0 or +1, like CompareC.
       
   250 		 */
       
   251 		static TInt OrderUid( const CIMCVEngineMessageContainer& aSourceA, 
       
   252 		                      const CIMCVEngineMessageContainer& aSourceB );
       
   253 		                      
       
   254 		/**
       
   255 		 * Type of container
       
   256 		 * @return Type of container. EChatContainer
       
   257 		 */
       
   258 		TContainerType ContainerType() const;
       
   259 		
       
   260 		
       
   261 		/**
       
   262 		 * Set chat observer.
       
   263 		 * @param aObserver. Observer to set.
       
   264 		 */
       
   265 		void SetChatObserver( MIMCVEngineNewMsgObserver* aObserver );
       
   266 		
       
   267     private: // New helper methods
       
   268         
       
   269         /**
       
   270          * Resolve type of container by identifier.
       
   271 		 * @param aType, new type. If ENoneContainer, Resolved automaticly.         
       
   272          */
       
   273         void ResolveType( TContainerType aType );   
       
   274         
       
   275         /**
       
   276          * display id it remove the domain part if any 
       
   277          * @param aId id to extarct 
       
   278          * @param aDomainHiding , hiding the domain part 
       
   279          */
       
   280      	static TPtrC DisplayId( const TDesC& aId, TBool aDomainHiding = ETrue );
       
   281      
       
   282         
       
   283         
       
   284     public:
       
   285     
       
   286         /**
       
   287          * Get count of all messages. Unread and read.
       
   288          * @return Count of messages
       
   289          */
       
   290         TInt AllMessagesCount() const;
       
   291             
       
   292         /** 
       
   293          * Access to any message. Also unread.
       
   294          * @param aIndex Index of message
       
   295          * @return Reference to message.
       
   296          */
       
   297         MIMCVEngineMessage& MessageFromAll( TInt aIndex ) const;
       
   298         
       
   299         /**
       
   300          * Delete from all messages. Unread and read messages available.
       
   301          * @param aIndex. Index of message.
       
   302          */
       
   303         void DeleteMessageFromAll( TInt aIndex );
       
   304         
       
   305         /**
       
   306          * Is container locked or not. ETrue locked, EFalse not.
       
   307          * @return Locked status.
       
   308          */
       
   309         TBool IsLocked() const;
       
   310         
       
   311         /**
       
   312          * Sizes of messages in container in bytes.         
       
   313          * @return Size in bytes.
       
   314          */
       
   315         TInt ContainerSizeInBytes() const;
       
   316         
       
   317     private: // Member data
       
   318     
       
   319     	/// conversation party id Owns    	    	
       
   320     	HBufC* iTargetId;
       
   321     	
       
   322     	// Owns , conversation party name    	    	
       
   323     	HBufC* iBuddyDisplayName;
       
   324     	
       
   325     	// Owns ,contact link info of chat.
       
   326     	HBufC8* iContactLink;
       
   327 
       
   328     	// owns 
       
   329         HBufC* iDecodedTargetId;
       
   330         // owns : reference to previous entered message
       
   331         HBufC* iEditerMessge;
       
   332         
       
   333     	/// Offset to last unread message
       
   334     	TInt iUnreadOffset;
       
   335     	
       
   336     	/// Array of messages.
       
   337         RPointerArray< MIMCVEngineMessage > iMessageContainer;
       
   338         
       
   339         /// Reference to memory handler
       
   340         MIMCVEngineBufferMemoryHandler& iMemoryHandler;
       
   341         
       
   342         /// Observer class - Doesnt Own
       
   343         MIMCVEngineMessageObserver* iObserver;
       
   344         
       
   345         /// Type of container
       
   346         TContainerType iContainerType;
       
   347         
       
   348         /// Not own. Chat observer 
       
   349         MIMCVEngineNewMsgObserver* iChatObserver;        
       
   350         
       
   351         // Locked status
       
   352         TBool iLocked;
       
   353     
       
   354         
       
   355         // Size of contained messages in bytes
       
   356         TInt iContainerSizeInBytes;
       
   357         
       
   358         //Active Chat
       
   359         TBool iActiveChat;
       
   360         
       
   361     };
       
   362     
       
   363     
       
   364 #endif      // __CIMCVENGINEMESSAGECONTAINER_H__
       
   365 
       
   366 // End of File