commonuis/CommonUi/src/ItemFinder.cpp
branchRCL_3
changeset 21 978afdc0236f
parent 20 d48ab3b357f1
equal deleted inserted replaced
20:d48ab3b357f1 21:978afdc0236f
    36 #include <ecom/implementationinformation.h>
    36 #include <ecom/implementationinformation.h>
    37 #include <coemain.h>
    37 #include <coemain.h>
    38 
    38 
    39 #include <centralrepository.h>
    39 #include <centralrepository.h>
    40 #include <CommonUiInternalCRKeys.h>
    40 #include <CommonUiInternalCRKeys.h>
       
    41 #include <AknSmileyUtils.h>
    41 
    42 
    42 // CONSTANTS
    43 // CONSTANTS
    43 const TInt KMINTAGLENGTH(5);
    44 const TInt KMINTAGLENGTH(5);
    44 const TInt KDragTresholdDefault(20);
    45 const TInt KDragTresholdDefault(20);
    45 _LIT( KHTTPPREFIX, "http://");
    46 _LIT( KHTTPPREFIX, "http://");
   141     }
   142     }
   142 
   143 
   143 void CItemFinderAsyncParser::RunL()
   144 void CItemFinderAsyncParser::RunL()
   144     {
   145     {
   145     TInt fullLength = Min( iEditor->TextLength(), 0xffff );
   146     TInt fullLength = Min( iEditor->TextLength(), 0xffff );
   146     const TDesC& text = iEditor->Text()->Read( 0, fullLength );
   147     if ( fullLength <= 0 )
       
   148         {
       
   149         return;
       
   150         }
       
   151     // If editor enables smiley feature, then smiley string shouldn't be included
       
   152     // in the search string. Normally a smiley string comprises 3 parts: a smiley code,
       
   153     // a smiley compensating character to expand smiley icon area, and several invisible 
       
   154     // smiley placeholder characters if the length of the smiley string is longer than 2 
       
   155     // characters. Since smiley codes are in reserved Unicode range and smiley placeholder 
       
   156     // is 0xfff0, they won't be counted in search string, but the compensating character 
       
   157     // is a valid english character so it needs to be replaced with smiley placeholder 
       
   158     // otherwise it will mess the search string.
       
   159     HBufC* textBuf( iEditor->Text()->Read( 0, fullLength ).Alloc() );
       
   160     if( !textBuf )
       
   161         {
       
   162         return;
       
   163         }
       
   164     CleanupStack::PushL( textBuf );
       
   165     TPtr text( textBuf->Des() );
       
   166     for ( TInt i( 0 ); i < fullLength; i++ )
       
   167         {
       
   168         // Check if current character is a smiley code, if so, the character 
       
   169         // following the code is a smiley compensating character and it needs to 
       
   170         // be replaced.
       
   171         if ( text[i] >= CAknSmileyManager::KSmileyCodeMin && 
       
   172              text[i] <= CAknSmileyManager::KSmileyCodeMax &&
       
   173              ( i + 1 < fullLength ) )
       
   174             {
       
   175             i++;
       
   176             text[i] = CAknSmileyManager::KPlaceHolder; 
       
   177             }
       
   178         }
   147     TInt searchAll = CFindItemEngine::EFindItemSearchURLBin
   179     TInt searchAll = CFindItemEngine::EFindItemSearchURLBin
   148         |CFindItemEngine::EFindItemSearchMailAddressBin
   180         |CFindItemEngine::EFindItemSearchMailAddressBin
   149         |CFindItemEngine::EFindItemSearchPhoneNumberBin
   181         |CFindItemEngine::EFindItemSearchPhoneNumberBin
   150         |CFindItemEngine::EFindItemSearchScheme;
   182         |CFindItemEngine::EFindItemSearchScheme;
   151     if ( !iFIE )
   183     if ( !iFIE )
   154         }
   186         }
   155     else
   187     else
   156         {
   188         {
   157         iFIE->DoNewSearchL( text, (CFindItemEngine::TFindItemSearchCase)searchAll, iMinDigitsToFind );
   189         iFIE->DoNewSearchL( text, (CFindItemEngine::TFindItemSearchCase)searchAll, iMinDigitsToFind );
   158         }
   190         }
       
   191     CleanupStack::PopAndDestroy( textBuf );
   159     delete iMarkedItems;
   192     delete iMarkedItems;
   160     iMarkedItems = 0;
   193     iMarkedItems = 0;
   161     iMarkedItems = new ( ELeave ) CArrayPtrFlat<CItemFinder::CFindItemExt>( 10 );
   194     iMarkedItems = new ( ELeave ) CArrayPtrFlat<CItemFinder::CFindItemExt>( 10 );
   162     iEditor->RefreshParsersL();
   195     iEditor->RefreshParsersL();
   163     if ( iObserver && iObserver->CallbackToExtObserver() == EFalse )
   196     if ( iObserver && iObserver->CallbackToExtObserver() == EFalse )