commonuis/CommonUi/src/ItemFinder.cpp
branchRCL_3
changeset 72 a5e7a4f63858
parent 59 978afdc0236f
equal deleted inserted replaced
64:85902f042028 72:a5e7a4f63858
    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>
       
    42 
    41 
    43 // CONSTANTS
    42 // CONSTANTS
    44 const TInt KMINTAGLENGTH(5);
    43 const TInt KMINTAGLENGTH(5);
    45 const TInt KDragTresholdDefault(20);
    44 const TInt KDragTresholdDefault(20);
    46 _LIT( KHTTPPREFIX, "http://");
    45 _LIT( KHTTPPREFIX, "http://");
   142     }
   141     }
   143 
   142 
   144 void CItemFinderAsyncParser::RunL()
   143 void CItemFinderAsyncParser::RunL()
   145     {
   144     {
   146     TInt fullLength = Min( iEditor->TextLength(), 0xffff );
   145     TInt fullLength = Min( iEditor->TextLength(), 0xffff );
   147     if ( fullLength <= 0 )
   146     const TDesC& text = iEditor->Text()->Read( 0, fullLength );
   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         }
       
   179     TInt searchAll = CFindItemEngine::EFindItemSearchURLBin
   147     TInt searchAll = CFindItemEngine::EFindItemSearchURLBin
   180         |CFindItemEngine::EFindItemSearchMailAddressBin
   148         |CFindItemEngine::EFindItemSearchMailAddressBin
   181         |CFindItemEngine::EFindItemSearchPhoneNumberBin
   149         |CFindItemEngine::EFindItemSearchPhoneNumberBin
   182         |CFindItemEngine::EFindItemSearchScheme;
   150         |CFindItemEngine::EFindItemSearchScheme;
   183     if ( !iFIE )
   151     if ( !iFIE )
   186         }
   154         }
   187     else
   155     else
   188         {
   156         {
   189         iFIE->DoNewSearchL( text, (CFindItemEngine::TFindItemSearchCase)searchAll, iMinDigitsToFind );
   157         iFIE->DoNewSearchL( text, (CFindItemEngine::TFindItemSearchCase)searchAll, iMinDigitsToFind );
   190         }
   158         }
   191     CleanupStack::PopAndDestroy( textBuf );
       
   192     delete iMarkedItems;
   159     delete iMarkedItems;
   193     iMarkedItems = 0;
   160     iMarkedItems = 0;
   194     iMarkedItems = new ( ELeave ) CArrayPtrFlat<CItemFinder::CFindItemExt>( 10 );
   161     iMarkedItems = new ( ELeave ) CArrayPtrFlat<CItemFinder::CFindItemExt>( 10 );
   195     iEditor->RefreshParsersL();
   162     iEditor->RefreshParsersL();
   196     if ( iObserver && iObserver->CallbackToExtObserver() == EFalse )
   163     if ( iObserver && iObserver->CallbackToExtObserver() == EFalse )