imstutils/imconversationview/imcvuiapp/inc/cimcvappsmileiconutility.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:  Utility for selecting smile icon and converting
       
    15 *                between smile id and smile string.
       
    16 *  Description : Handles statuspane, context pane, navi pane
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef CIMCVAPPSMILEICONUTILITY_H
       
    22 #define CIMCVAPPSMILEICONUTILITY_H
       
    23 
       
    24 // INCLUDES
       
    25 #include <e32base.h>
       
    26 #include "mimcvappresourcechangeobserver.h"
       
    27 #include <gdi.h>
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CGulIcon;
       
    31 class CIMCVAppSmileString;
       
    32 class CIMCVAppSmileyInformation;
       
    33 class MIMCVUiAppSkinVariant;
       
    34 class CIMCVUiAppIconFileProvider;
       
    35 class CIMCVEngine;
       
    36 
       
    37 
       
    38 class MIMCVAppUi;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 * CIMCVAppSmileIconUtility
       
    44 *
       
    45 * Utility for selecting smile icon and mapping
       
    46 * between smile icons and smile strings.
       
    47 */
       
    48 class CIMCVAppSmileIconUtility : public CBase,
       
    49                             public MIMCVAppResourceChangeObserver
       
    50     {
       
    51     public:  // Constructors and destructor
       
    52 
       
    53         /**
       
    54         * Two-phased constructor using default smile icon array.
       
    55         *@param aAppUi : CIMCVAppUI reference
       
    56         */
       
    57         static CIMCVAppSmileIconUtility* NewL(
       
    58         					 MIMCVUiAppSkinVariant& aSkinVariant,
       
    59                              MIMCVAppUi& aAppUi,
       
    60                              CIMCVEngine& aServiceEngine );   
       
    61 
       
    62         /**
       
    63         * Destructor.
       
    64         */
       
    65         ~CIMCVAppSmileIconUtility();
       
    66 
       
    67 	public:
       
    68        
       
    69         /**
       
    70         * Launch pop-up dialog for selecting smile icon.
       
    71 		* @param aSelectedSmileIndex Returns selected smile icon index
       
    72 		* @return (TInt) Return dialog value
       
    73         */
       
    74 		TInt LaunchSmileIconDialogL( TInt& aSelectedSmileIndex );
       
    75 
       
    76         /**
       
    77         * Smile icon count.
       
    78 		* @return (TInt) Smile icon count
       
    79         */
       
    80 		TInt SmileIconCount() const;
       
    81 
       
    82         /**
       
    83         * Return needed smile icon pointer from icon array.
       
    84 		* @param aSmileIndex Smile icon index
       
    85         */
       
    86 		const CGulIcon* GetSmileIcon( TInt aSmileIndex ) const;
       
    87 
       
    88         /**
       
    89         * Return needed smile string reference from string array.
       
    90 		* @param aSmileIndex Smile icon index
       
    91         */
       
    92 		const TDesC& GetSmileString( TInt aSmileIndex ) const;
       
    93 
       
    94 		/**
       
    95         *   Search smileys from buffer. Replace every found smiley with KPuaCodeSmileyIconPadding 
       
    96         *   @param aStr String to search smiles from.
       
    97         *   @param aFixedStr, Target string where smileys are replaced with KPUaCodeSmileyIconPadding
       
    98 		*   @param aArray Array reference to icon array indexes in right order
       
    99         */
       
   100 		void SearchSmilesL( const TDesC& aStr, TDes& aFixedStr,
       
   101 									 RArray<TInt>* aArray );
       
   102 
       
   103         /**
       
   104         *   Search smileys from buffer.
       
   105         *   @param aStr String to search smiles from.
       
   106         *   @param aSmileyInfoArray Information of found smileys.
       
   107         *   @param aFixedStr, Target string where smileys are replaced with KPUaCodeSmileyIconPadding
       
   108         *   @param aStartPos, Absolute position of index 0 in source string. Used when position of smiley is calculated.
       
   109         */
       
   110         void SearchSmilesL( const TDesC& aStr, 
       
   111         					RPointerArray< CIMCVAppSmileyInformation >& aSmileyInfoArray, 
       
   112         					TDes* aFixedStr = NULL, TInt aStartPos = 0 ) const;
       
   113 
       
   114 		/**
       
   115 		* Compares two TSmileyInformation objects' position field.
       
   116 		* @param aFirst Reference to the first TSmileyInformation
       
   117 		* @param aSecond Reference to the second TSmileyInformation
       
   118 		* @return (TInt) Positive if aFirst > aSecond, negative if opposite,
       
   119 		*			     0 if aFirst == aSecond
       
   120 		*/
       
   121         static TInt Compare( const CIMCVAppSmileyInformation& aFirst,
       
   122                              const CIMCVAppSmileyInformation& aSecond );
       
   123         
       
   124 		/**
       
   125 		* Compares two CIMCVAppSmileString objects' smiley length.
       
   126 		* @param aFirst Reference to the first CIMCVAppSmileString
       
   127 		* @param aSecond Reference to the second CIMCVAppSmileString
       
   128 		* @return (TInt) Positive if aFirst(length) < aSecond(length), 
       
   129         *                negative if opposite, 0 if aFirst == aSecond
       
   130 		*/
       
   131         static TInt CompareSmileyLengthReversed( 
       
   132                              const CIMCVAppSmileString& aFirst,
       
   133                              const CIMCVAppSmileString& aSecond );
       
   134 		
       
   135 		/**
       
   136 		* Resizes all icons.
       
   137 		* @param aSize new icon size
       
   138 		*/
       
   139 		void ResizeIcons( const TSize& aSize );
       
   140 		
       
   141 	    
       
   142     	/**
       
   143          * @return aResourceId to use
       
   144         */
       
   145 		void ConstructSmileDialogIconArrayL( CIMCVEngine& aServiceEngine );
       
   146 		
       
   147 		/**
       
   148 		 * parses whole smiley string from branding and extracts each smiley code
       
   149 		 */		
       
   150 		void ParseAllSmileyStringL(RPointerArray<HBufC> aAllSmileyString);
       
   151 		
       
   152     public: // From MIMCVAppResourceChangeObserver
       
   153     
       
   154         /**
       
   155          * Reload all icons on resource change
       
   156          */
       
   157         void ResourceChangedL();
       
   158 
       
   159     private:  // Constructors and destructor
       
   160 
       
   161         /**
       
   162         * C++ constructor.
       
   163         */
       
   164         CIMCVAppSmileIconUtility( 
       
   165                              MIMCVUiAppSkinVariant& aSkinVariant, 
       
   166                              MIMCVAppUi& aAppUi );
       
   167 
       
   168         /**
       
   169         * Second-phased constructor
       
   170         */
       
   171         void ConstructL(CIMCVEngine& aServiceEngine );
       
   172 
       
   173 	private: // New methods		
       
   174 		
       
   175         /**
       
   176          * Seek the first smiley which points to a given icon.
       
   177          * This is slow method, and it should only be used to 
       
   178          * precalculate the index table.
       
   179          * @param aIconIndex index of icon in iIconArray
       
   180          * @return index of smiley in iStringArray
       
   181          */
       
   182         TInt GetFirstSmileyIndex( TInt aIconIndex ) const;
       
   183         
       
   184         
       
   185        
       
   186     private: // Data
       
   187 		// NOT Own
       
   188 		MIMCVUiAppSkinVariant& iSkinVariant;       
       
   189 		
       
   190 		// Own. Smiley strings with ref to icon array 
       
   191 		RPointerArray<CIMCVAppSmileString> iStringArray;
       
   192         
       
   193         // Own. Temporary array for searching the smileys.
       
   194         // This should be empty when not searching.
       
   195         RPointerArray<CIMCVAppSmileyInformation> iSmileArray;
       
   196         
       
   197         // Own. Icon reference to string smileys.
       
   198         // Using a precalculated array makes seeking a lot faster,
       
   199         RArray<TInt> iIconToSmileyPointers;
       
   200         
       
   201         // Cache length, so we don't need the seek this every time.
       
   202         TInt iLongestSmileyLength;
       
   203         
       
   204 		// does not own        
       
   205         MIMCVAppUi& iAppUi;       
       
   206         
       
   207          //Own. Smiley icons for SmileDialog
       
   208         RPointerArray<CGulIcon> iSmileDlgIconArray;
       
   209         
       
   210         //Owns
       
   211         RFile iFile;
       
   212         
       
   213       
       
   214     };
       
   215 
       
   216 #endif  // CIMCVAPPSMILEICONUTILITY_H