predictivesearch/PcsAlgorithm/Algorithm2/src/CPcsAlgorithm2.cpp
branchRCL_3
changeset 74 6b5524b4f673
parent 68 9da50d567e3c
child 85 38bb213f60ba
equal deleted inserted replaced
68:9da50d567e3c 74:6b5524b4f673
   200 // CPcsAlgorithm2::ReplaceZeroWithSpaceL
   200 // CPcsAlgorithm2::ReplaceZeroWithSpaceL
   201 // Replace first occurance of '0' in a sequence of '0's in ITU-T with space
   201 // Replace first occurance of '0' in a sequence of '0's in ITU-T with space
   202 // ----------------------------------------------------------------------------
   202 // ----------------------------------------------------------------------------
   203 TBool CPcsAlgorithm2::ReplaceZeroWithSpaceL(CPsQuery& aQuery)
   203 TBool CPcsAlgorithm2::ReplaceZeroWithSpaceL(CPsQuery& aQuery)
   204     {
   204     {
   205     PRINT ( _L("Enter CPcsAlgorithm1::ReplaceZeroWithSpaceL") );
   205     PRINT ( _L("Enter CPcsAlgorithm2::ReplaceZeroWithSpaceL") );
   206 
   206 
   207        //PRINTQUERY ( _L("CPcsAlgorithm1::ReplaceZeroWithSpaceL (BEFORE): "), aQuery );
   207        //PRINTQUERY ( _L("CPcsAlgorithm2::ReplaceZeroWithSpaceL (BEFORE): "), aQuery );
   208 
   208 
   209        TBool queryModified = EFalse;    
   209        TBool queryModified = EFalse;    
   210 
   210 
   211        /* In phones like E52 and E55, where the "0" and the " " characters are on
   211        /* In phones like E52 and E55, where the "0" and the " " characters are on
   212         * the same key, the "0"s have to be considered as possible separators.
   212         * the same key, the "0"s have to be considered as possible separators.
   236                item.SetCharacter(KSpace);
   236                item.SetCharacter(KSpace);
   237                queryModified = ETrue;
   237                queryModified = ETrue;
   238            }
   238            }
   239        }
   239        }
   240        
   240        
   241        //PRINTQUERY ( _L("CPcsAlgorithm1::ReplaceZeroWithSpaceL (AFTER): "), aQuery );
   241        //PRINTQUERY ( _L("CPcsAlgorithm2::ReplaceZeroWithSpaceL (AFTER): "), aQuery );
   242 
   242 
   243        PRINT1 ( _L("CPcsAlgorithm1::ReplaceZeroWithSpaceL: Query modified (0=not, 1=yes): %d"), queryModified );
   243        PRINT1 ( _L("CPcsAlgorithm2::ReplaceZeroWithSpaceL: Query modified (0=not, 1=yes): %d"), queryModified );
   244 
   244 
   245        PRINT ( _L("End CPcsAlgorithm1::ReplaceZeroWithSpaceL") );
   245        PRINT ( _L("End CPcsAlgorithm2::ReplaceZeroWithSpaceL") );
   246 
   246 
   247        return  queryModified;
   247        return  queryModified;
   248     }
   248     }
   249 
   249 
   250 // ----------------------------------------------------------------------------
   250 // ----------------------------------------------------------------------------
   265     CleanupResetAndDestroyPushL( searchUris );
   265     CleanupResetAndDestroyPushL( searchUris );
   266     aSettings.SearchUrisL(searchUris);
   266     aSettings.SearchUrisL(searchUris);
   267          
   267          
   268     if ( searchUris.Count() <= 0)
   268     if ( searchUris.Count() <= 0)
   269     {
   269     {
   270         PRINT ( _L("searchUris.Count() <= 0, Leave from CPcsAlgorithm1::PerformSearchL") );
   270         PRINT ( _L("searchUris.Count() <= 0, Leave from CPcsAlgorithm2::PerformSearchL") );
   271         User::Leave(KErrArgument); 
   271         User::Leave(KErrArgument); 
   272     }
   272     }
   273     CleanupStack::PopAndDestroy( &searchUris ); // ResetAndDestroy
   273     CleanupStack::PopAndDestroy( &searchUris ); // ResetAndDestroy
   274 
   274 
   275     // Local arrays to hold the search results 
   275     // Local arrays to hold the search results 
   487 
   487 
   488 // ----------------------------------------------------------------------------
   488 // ----------------------------------------------------------------------------
   489 // CPcsAlgorithm2::SearchMatchStringL
   489 // CPcsAlgorithm2::SearchMatchStringL
   490 // Search function for input string, result also as string
   490 // Search function for input string, result also as string
   491 // ----------------------------------------------------------------------------
   491 // ----------------------------------------------------------------------------
   492 void CPcsAlgorithm2::SearchMatchStringL( CPsQuery& /*aSearchQuery*/,
   492 void CPcsAlgorithm2::SearchMatchStringL( CPsQuery& aSearchQuery,
   493                                          TDesC& /*aSearchData*/,
   493                                          TDesC& aSearchData,
   494                                          TDes& /*aMatch*/ )
   494                                          TDes& aMatch )
   495     {
   495     {
   496     PRINT ( _L("Enter CPcsAlgorithm2::SearchMatchStringL") );
   496     PRINT ( _L("Enter CPcsAlgorithm2::SearchMatchStringL") );
   497 
   497 
   498     //__LATENCY_MARK ( _L("CPcsAlgorithm2::SearchMatchStringL") ); 
   498     __LATENCY_MARK ( _L("CPcsAlgorithm2::SearchMatchStringL") ); 
   499     
   499     
   500     // TODO: Implementation missing
   500     RemoveSpacesL(aSearchQuery);
       
   501     // ---------------------- Perform the initial search ----------------------
       
   502     iMultiSearchHelper->LookupMatchL( aSearchQuery, aSearchData, aMatch );
       
   503     PRINTQUERY ( _L("CPcsAlgorithm2::SearchMatchStringL: 1st search: "), aSearchQuery );
       
   504     PRINT1     ( _L("CPcsAlgorithm2::SearchMatchStringL: 1st search: Search Data: %S"), &aSearchData );
       
   505     PRINT1     ( _L("CPcsAlgorithm2::SearchMatchStringL: 1st search: Result: %S"), &aMatch );
       
   506     // ------------------------------------------------------------------------
   501     
   507     
   502     //__LATENCY_MARKEND ( _L("CPcsAlgorithm2::SearchMatchStringL") );
   508     // ---- Perform new search after "0" replacement if query is not empty ----
       
   509     /* Examples:
       
   510      * - If the original search string is "Abc0" then we will search again with "Abc".
       
   511      * - If the original search string is "00" then we will not search again.
       
   512      */
       
   513     if ( aMatch.Length() <= 0 )
       
   514     {
       
   515         TBool isQueryModified = ReplaceZeroWithSpaceL(aSearchQuery);
       
   516         RemoveSpacesL(aSearchQuery);
       
   517         if ( isQueryModified && (aSearchQuery.Count() > 0) )
       
   518         {
       
   519             iMultiSearchHelper->LookupMatchL( aSearchQuery, aSearchData, aMatch );
       
   520             PRINTQUERY ( _L("CPcsAlgorithm2::SearchMatchStringL: 2nd search: "), aSearchQuery );
       
   521             PRINT1     ( _L("CPcsAlgorithm2::SearchMatchStringL: 2nd search: Search Data: %S"), &aSearchData );
       
   522             PRINT1     ( _L("CPcsAlgorithm2::SearchMatchStringL: 2nd search: Result: %S"), &aMatch );            
       
   523         }
       
   524     }
       
   525     __LATENCY_MARKEND ( _L("CPcsAlgorithm2::SearchMatchStringL") );
   503 
   526 
   504     PRINT ( _L("End CPcsAlgorithm2::SearchMatchStringL") );
   527     PRINT ( _L("End CPcsAlgorithm2::SearchMatchStringL") );
   505     }
   528     }
   506 
   529 
   507 // ----------------------------------------------------------------------------
   530 // ----------------------------------------------------------------------------
  1319     // Request for data again
  1342     // Request for data again
  1320     TInt err = KErrNone;
  1343     TInt err = KErrNone;
  1321     TRAP(err, cache->ResortdataInPoolsL());
  1344     TRAP(err, cache->ResortdataInPoolsL());
  1322     if (err != KErrNone)
  1345     if (err != KErrNone)
  1323         {
  1346         {
  1324         PRINT ( _L("CPcsAlgorithm1::ChangeSortOrderL() Set Caching Error ") );
  1347         PRINT ( _L("CPcsAlgorithm2::ChangeSortOrderL() Set Caching Error ") );
  1325         SetCachingError(aURI, err);
  1348         SetCachingError(aURI, err);
  1326         UpdateCachingStatus(aURI, ECachingCompleteWithErrors);
  1349         UpdateCachingStatus(aURI, ECachingCompleteWithErrors);
  1327         return;
  1350         return;
  1328         }
  1351         }
  1329 
  1352