uifw/EikStd/coctlsrc/smileymodel.cpp
branchRCL_3
changeset 72 a5e7a4f63858
parent 64 85902f042028
equal deleted inserted replaced
64:85902f042028 72:a5e7a4f63858
    13 *
    13 *
    14 * Description:  smiely engine class
    14 * Description:  smiely engine class
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <AknSmileyUtils.h>
    18 //#include <streamlogger.h>
       
    19 
    19 #include "smileymanager.h"
    20 #include "smileymanager.h"
    20 #include "smileymodel.h"
    21 #include "smileymodel.h"
    21 
    22 
    22 const TText KSpace = ' ';
    23 const TText KSpace = ' ';
    23 const TInt KLinkIndexMark = 0x8000;
    24 const TInt KLinkIndexMark = 0x8000;
   202 // CSmileyModel::AddSimleyL
   203 // CSmileyModel::AddSimleyL
   203 // ---------------------------------------------------------------------------
   204 // ---------------------------------------------------------------------------
   204 //
   205 //
   205 void CSmileyModel::AddSimleyL( CSmileyInfo& aInfo )
   206 void CSmileyModel::AddSimleyL( CSmileyInfo& aInfo )
   206     {
   207     {
   207     if ( aInfo.iImageInfo.iCode < CAknSmileyManager::KSmileyCodeMin || 
   208     if ( aInfo.iImageInfo.iCode < CSmileyManager::KSmileyCodeMin || 
   208         aInfo.iImageInfo.iCode > CAknSmileyManager::KSmileyCodeMax || 
   209         aInfo.iImageInfo.iCode > CSmileyManager::KSmileyCodeMax || 
   209         aInfo.iStrArray.Count() == 0 )
   210         aInfo.iStrArray.Count() == 0 )
   210         {
   211         {
   211         return;
   212         return;
   212         }
   213         }
   213     for ( TInt i = 0; i < aInfo.iStrArray.Count(); i++ )
   214     for ( TInt i = 0; i < aInfo.iStrArray.Count(); i++ )
   380     {
   381     {
   381     TInt linkIndex( iStrArray[aNodeIndex].iChild & ~KLinkIndexMark );
   382     TInt linkIndex( iStrArray[aNodeIndex].iChild & ~KLinkIndexMark );
   382     TInt len( iLinkArray[linkIndex].iStrLength );
   383     TInt len( iLinkArray[linkIndex].iStrLength );
   383     TInt imageIndex( iLinkArray[linkIndex].iImageIndex );
   384     TInt imageIndex( iLinkArray[linkIndex].iImageIndex );
   384     aText[aDocPos] = iImageInfoArray[imageIndex].iCode;
   385     aText[aDocPos] = iImageInfoArray[imageIndex].iCode;
   385     aText[aDocPos + 1] = CAknSmileyManager::KCompensateChar;
   386     aText[aDocPos + 1] = CSmileyManager::KCompensateChar;
   386     const TInt KThirdIndex = 2;
   387     const TInt KThirdIndex = 2;
   387     for ( TInt i( KThirdIndex ); i < len; i++ )
   388     for ( TInt i( KThirdIndex ); i < len; i++ )
   388         {
   389         {
   389         aText[i + aDocPos] = CAknSmileyManager::KPlaceHolder;
   390         aText[i + aDocPos] = CSmileyManager::KPlaceHolder;
   390         }
   391         }
   391     }
   392     }
   392 
   393 
   393 
   394 
   394 /////////////////////////////////////////////////////////////////////////////////////////
   395 /////////////////////////////////////////////////////////////////////////////////////////
   444     const TInt end = aText.Length() - 1;
   445     const TInt end = aText.Length() - 1;
   445     TInt pos = end;
   446     TInt pos = end;
   446     while(pos > 0)
   447     while(pos > 0)
   447         {
   448         {
   448         const TUint16 word = aText[--pos];
   449         const TUint16 word = aText[--pos];
   449         // Since in most cases, URL is comprised of ASCII characters, 
   450         if(word == ' ' || word == 0x2029)
   450         // so if there is a character out of the ASCII printable characters, 
   451             {
   451         // we can stop the search.
       
   452         const TInt KMinPrintableAscIIChar( 0x21 ); // excluding space
       
   453         const TInt KMaxPrintableAscIIChar( 0x7e );
       
   454         if( word < KMinPrintableAscIIChar || word > KMaxPrintableAscIIChar )
       
   455             {
       
   456             pos++; // make the string begin with printable character.
       
   457             break;
   452             break;
   458             }
   453             }
   459         }
   454         }
   460     
   455     
   461     TInt length = end - pos;
   456     TInt length = end - pos;
   465         pos = field.Find(_L(":\\\\"));
   460         pos = field.Find(_L(":\\\\"));
   466         if(KErrNotFound == pos) pos = field.Find(_L("://"));
   461         if(KErrNotFound == pos) pos = field.Find(_L("://"));
   467         if(KErrNotFound != pos)
   462         if(KErrNotFound != pos)
   468             {
   463             {
   469             return ETrue;
   464             return ETrue;
   470             }
   465             }    
   471         else
       
   472             {
       
   473             // Although the string doesn't contain '://', it is also considered
       
   474             // as an URL if it contains 'www.'.
       
   475             HBufC* fieldTextBuf( field.Alloc() );
       
   476             if ( fieldTextBuf )
       
   477                 {
       
   478                 TPtr fieldText( fieldTextBuf->Des() );
       
   479                 // Use lower case for search to avoid case sensitive mismatch.
       
   480                 fieldText.LowerCase();
       
   481                 TBool result( fieldText.Find( _L("www.") ) != KErrNotFound );
       
   482                 delete fieldTextBuf;
       
   483                 return result;
       
   484                 }
       
   485             }
       
   486         }
   466         }
   487     
   467     
   488     return EFalse;
   468     return EFalse;
   489     }
   469     }
   490 
   470