searcher/searchclient/src/ccpixsearcher.cpp
changeset 18 3e1f76dd2722
parent 15 cf5c74390b98
equal deleted inserted replaced
15:cf5c74390b98 18:3e1f76dd2722
    96 
    96 
    97 //
    97 //
    98 //
    98 //
    99 EXPORT_C void CCPixSearcher::OpenDatabaseL(const TDesC& aBaseAppClass)
    99 EXPORT_C void CCPixSearcher::OpenDatabaseL(const TDesC& aBaseAppClass)
   100 	{
   100 	{
       
   101 	OstTraceFunctionEntry0( CCPIXSEARCHER_OPENDATABASEL_ENTRY );
   101 	if ( IsActive() )
   102 	if ( IsActive() )
   102 		{
   103 		{
   103 		User::Leave(KErrInUse);
   104 		User::Leave(KErrInUse);
   104 		}
   105 		}
   105 
   106 
   110 	    iBaseAppClass = NULL;
   111 	    iBaseAppClass = NULL;
   111 	    }
   112 	    }
   112 	iBaseAppClass = aBaseAppClass.AllocL();
   113 	iBaseAppClass = aBaseAppClass.AllocL();
   113 	iSubSession.OpenDatabaseL(ETrue, *iBaseAppClass, *iDefaultSearchField);
   114 	iSubSession.OpenDatabaseL(ETrue, *iBaseAppClass, *iDefaultSearchField);
   114 	iIsDatabaseOpen = ETrue; 
   115 	iIsDatabaseOpen = ETrue; 
       
   116 	OstTraceFunctionExit0( CCPIXSEARCHER_OPENDATABASEL_EXIT );
   115 	}
   117 	}
   116 
   118 
   117 //
   119 //
   118 //
   120 //
   119 EXPORT_C void CCPixSearcher::OpenDatabaseL(MCPixOpenDatabaseRequestObserver& aObserver, const TDesC& aBaseAppClass)
   121 EXPORT_C void CCPixSearcher::OpenDatabaseL(MCPixOpenDatabaseRequestObserver& aObserver, const TDesC& aBaseAppClass)
   120 	{
   122 	{
       
   123 	OstTraceFunctionEntry0( DUP1_CCPIXSEARCHER_OPENDATABASEL_ENTRY );
   121 	if ( IsActive() )
   124 	if ( IsActive() )
   122 		{
   125 		{
   123 		User::Leave( KErrInUse);
   126 		User::Leave( KErrInUse);
   124 		}
   127 		}
   125 
   128 
   133 	    iBaseAppClass = NULL;
   136 	    iBaseAppClass = NULL;
   134 	    }
   137 	    }
   135 	iBaseAppClass = aBaseAppClass.AllocL();
   138 	iBaseAppClass = aBaseAppClass.AllocL();
   136 	iSubSession.OpenDatabase(ETrue, *iBaseAppClass, *iDefaultSearchField, iStatus); // Create if not found
   139 	iSubSession.OpenDatabase(ETrue, *iBaseAppClass, *iDefaultSearchField, iStatus); // Create if not found
   137 	SetActive(); 
   140 	SetActive(); 
       
   141 	OstTraceFunctionExit0( DUP1_CCPIXSEARCHER_OPENDATABASEL_EXIT );
   138 	}
   142 	}
   139 
   143 
   140 EXPORT_C void CCPixSearcher::SetAnalyzerL( const TDesC& aAnalyzer )
   144 EXPORT_C void CCPixSearcher::SetAnalyzerL( const TDesC& aAnalyzer )
   141 	{
   145 	{
       
   146 	OstTraceFunctionEntry0( CCPIXSEARCHER_SETANALYZERL_ENTRY );
   142 	if ( !iIsDatabaseOpen ) 	User::Leave(KErrNotReady);
   147 	if ( !iIsDatabaseOpen ) 	User::Leave(KErrNotReady);
   143 	if ( IsActive() ) 			User::Leave(KErrInUse);
   148 	if ( IsActive() ) 			User::Leave(KErrInUse);
   144 
   149 
   145 	iSubSession.SetAnalyzerL( aAnalyzer ); 
   150 	iSubSession.SetAnalyzerL( aAnalyzer ); 
       
   151 	OstTraceFunctionExit0( CCPIXSEARCHER_SETANALYZERL_EXIT );
   146 	}
   152 	}
   147 
   153 
   148 EXPORT_C void CCPixSearcher::SetAnalyzerL( MCPixSetAnalyzerRequestObserver& aObserver, const TDesC& aAnalyzer )
   154 EXPORT_C void CCPixSearcher::SetAnalyzerL( MCPixSetAnalyzerRequestObserver& aObserver, const TDesC& aAnalyzer )
   149 	{
   155 	{
       
   156 	OstTraceFunctionEntry0( DUP1_CCPIXSEARCHER_SETANALYZERL_ENTRY );
   150 	if ( !iIsDatabaseOpen ) 	User::Leave(KErrNotReady);
   157 	if ( !iIsDatabaseOpen ) 	User::Leave(KErrNotReady);
   151 	if ( IsActive() ) 			User::Leave(KErrInUse);
   158 	if ( IsActive() ) 			User::Leave(KErrInUse);
   152 	
   159 	
   153 	iAnalyzer = aAnalyzer.AllocL(); 
   160 	iAnalyzer = aAnalyzer.AllocL(); 
   154 
   161 
   155 	iObserver.iSetAnalyzer = &aObserver;
   162 	iObserver.iSetAnalyzer = &aObserver;
   156 	iState = EStateSetAnalyzer; 
   163 	iState = EStateSetAnalyzer; 
   157 	iSubSession.SetAnalyzer( aAnalyzer, iStatus );
   164 	iSubSession.SetAnalyzer( aAnalyzer, iStatus );
   158 	SetActive(); 
   165 	SetActive(); 
       
   166 	OstTraceFunctionExit0( DUP1_CCPIXSEARCHER_SETANALYZERL_EXIT );
   159 	}
   167 	}
   160 	
   168 	
   161 	EXPORT_C void CCPixSearcher::SetQueryParserL( TQueryParser aQueryParser ) 
   169 	EXPORT_C void CCPixSearcher::SetQueryParserL( TQueryParser aQueryParser ) 
   162 	{
   170 	{
   163 	if ( !iIsDatabaseOpen ) 	User::Leave(KErrNotReady);
   171 	if ( !iIsDatabaseOpen ) 	User::Leave(KErrNotReady);
   204 // Issues a new search
   212 // Issues a new search
   205 EXPORT_C TInt CCPixSearcher::SearchL(const TDesC& aQueryString, const TDesC& aDocumentField)
   213 EXPORT_C TInt CCPixSearcher::SearchL(const TDesC& aQueryString, const TDesC& aDocumentField)
   206 	{
   214 	{
   207 	OstTraceFunctionEntry0( CCPIXSEARCHER_SEARCHL_ENTRY );
   215 	OstTraceFunctionEntry0( CCPIXSEARCHER_SEARCHL_ENTRY );
   208 	PERFORMANCE_LOG_START("CCPixSearcher::SearchL");
   216 	PERFORMANCE_LOG_START("CCPixSearcher::SearchL");
   209 	
   217 	OstTraceExt2( TRACE_NORMAL, CCPIXSEARCHER_SEARCHL, "CCPixSearcher::SearchL::sync::;Search string =%S;field=%S", aQueryString, aDocumentField );
   210 	if ( !iIsDatabaseOpen ) 	
   218 	if ( !iIsDatabaseOpen ) 	
   211 		User::Leave( KErrNotReady );
   219 		User::Leave( KErrNotReady );
   212 	if ( IsActive() )
   220 	if ( IsActive() )
   213 		{
   221 		{
   214 		User::Leave(KErrInUse);
   222 		User::Leave(KErrInUse);
   227 EXPORT_C void CCPixSearcher::SearchL(MCPixSearchRequestObserver& aObserver, const TDesC& aQueryString, const TDesC& aDocumentField)
   235 EXPORT_C void CCPixSearcher::SearchL(MCPixSearchRequestObserver& aObserver, const TDesC& aQueryString, const TDesC& aDocumentField)
   228 	{
   236 	{
   229     OstTraceFunctionEntry0( DUP1_CCPIXSEARCHER_SEARCHL_ENTRY );
   237     OstTraceFunctionEntry0( DUP1_CCPIXSEARCHER_SEARCHL_ENTRY );
   230     PERFORMANCE_LOG_START("CCPixSearcher::SearchL");
   238     PERFORMANCE_LOG_START("CCPixSearcher::SearchL");
   231 
   239 
       
   240 	OstTraceExt2( TRACE_NORMAL, DUP1_CCPIXSEARCHER_SEARCHL, "CCPixSearcher::SearchL::Async::;Search string=%S;Field=%S", aQueryString, aDocumentField );
   232 	if ( !iIsDatabaseOpen ) 	User::Leave( KErrNotReady );
   241 	if ( !iIsDatabaseOpen ) 	User::Leave( KErrNotReady );
   233 	if ( IsActive() )
   242 	if ( IsActive() )
   234 		{
   243 		{
   235 		User::Leave(KErrInUse);
   244 		User::Leave(KErrInUse);
   236 		}
   245 		}
   249 EXPORT_C CSearchDocument* CCPixSearcher::GetDocumentL(TInt aIndex)
   258 EXPORT_C CSearchDocument* CCPixSearcher::GetDocumentL(TInt aIndex)
   250     {
   259     {
   251     OstTraceFunctionEntry0( CCPIXSEARCHER_GETDOCUMENTL_ENTRY );
   260     OstTraceFunctionEntry0( CCPIXSEARCHER_GETDOCUMENTL_ENTRY );
   252     PERFORMANCE_LOG_START("CCPixSearcher::GetDocumentL");
   261     PERFORMANCE_LOG_START("CCPixSearcher::GetDocumentL");
   253     
   262     
       
   263 	OstTrace1( TRACE_NORMAL, CCPIXSEARCHER_GETDOCUMENTL, "CCPixSearcher::GetDocumentL;aIndex=%d", aIndex );
   254 	if ( !iIsDatabaseOpen ) 	User::Leave( KErrNotReady );
   264 	if ( !iIsDatabaseOpen ) 	User::Leave( KErrNotReady );
   255 	if ( IsActive() )
   265 	if ( IsActive() )
   256 		{
   266 		{
   257 		User::Leave(KErrInUse);
   267 		User::Leave(KErrInUse);
   258 		}
   268 		}
   263 EXPORT_C void CCPixSearcher::GetDocumentL(TInt aIndex, MCPixNextDocumentRequestObserver& aObserver)
   273 EXPORT_C void CCPixSearcher::GetDocumentL(TInt aIndex, MCPixNextDocumentRequestObserver& aObserver)
   264     {
   274     {
   265     OstTraceFunctionEntry0( DUP1_CCPIXSEARCHER_GETDOCUMENTL_ENTRY );
   275     OstTraceFunctionEntry0( DUP1_CCPIXSEARCHER_GETDOCUMENTL_ENTRY );
   266     PERFORMANCE_LOG_START("CCPixSearcher::GetDocumentL");
   276     PERFORMANCE_LOG_START("CCPixSearcher::GetDocumentL");
   267     
   277     
       
   278     OstTrace1( TRACE_NORMAL, DUP1_CCPIXSEARCHER_GETDOCUMENTL, "CCPixSearcher::GetDocumentL::Async::;aIndex=%d", aIndex );
   268     if ( !iIsDatabaseOpen ) 	User::Leave( KErrNotReady );
   279     if ( !iIsDatabaseOpen ) 	User::Leave( KErrNotReady );
   269 	if ( IsActive() )
   280 	if ( IsActive() )
   270 		{
   281 		{
   271 		User::Leave(KErrInUse); // Need ::RunError to handle this
   282 		User::Leave(KErrInUse); // Need ::RunError to handle this
   272 		}
   283 		}
   281 
   292 
   282 EXPORT_C CSearchDocument** CCPixSearcher::GetBatchDocumentL(TInt aIndex, TInt& aReturnDoc, TInt aCount)
   293 EXPORT_C CSearchDocument** CCPixSearcher::GetBatchDocumentL(TInt aIndex, TInt& aReturnDoc, TInt aCount)
   283     {
   294     {
   284     PERFORMANCE_LOG_START("CCPixSearcher::GetBatchDocumentL");
   295     PERFORMANCE_LOG_START("CCPixSearcher::GetBatchDocumentL");
   285     
   296     
       
   297 	OstTraceExt2( TRACE_NORMAL, CCPIXSEARCHER_GETBATCHDOCUMENTL, "CCPixSearcher::GetBatchDocumentL;aIndex=%d;aCount=%d", aIndex, aCount );
   286 	if ( !iIsDatabaseOpen ) 	User::Leave( KErrNotReady );
   298 	if ( !iIsDatabaseOpen ) 	User::Leave( KErrNotReady );
   287 	if ( IsActive() )
   299 	if ( IsActive() )
   288 		{
   300 		{
   289 		User::Leave(KErrInUse);
   301 		User::Leave(KErrInUse);
   290 		}
   302 		}
   294 
   306 
   295 EXPORT_C void CCPixSearcher::GetBatchDocumentL(TInt aIndex, MCPixNextDocumentRequestObserver& aObserver, TInt aCount)
   307 EXPORT_C void CCPixSearcher::GetBatchDocumentL(TInt aIndex, MCPixNextDocumentRequestObserver& aObserver, TInt aCount)
   296     {
   308     {
   297     PERFORMANCE_LOG_START("CCPixSearcher::GetBatchDocumentL");
   309     PERFORMANCE_LOG_START("CCPixSearcher::GetBatchDocumentL");
   298     
   310     
       
   311     OstTraceExt2( TRACE_NORMAL, DUP1_CCPIXSEARCHER_GETBATCHDOCUMENTL, "CCPixSearcher::GetBatchDocumentL::Async::;aIndex=%d;aCount=%d", aIndex, aCount );
   299     if ( !iIsDatabaseOpen ) 	User::Leave( KErrNotReady );
   312     if ( !iIsDatabaseOpen ) 	User::Leave( KErrNotReady );
   300 	if ( IsActive() )
   313 	if ( IsActive() )
   301 		{
   314 		{
   302 		User::Leave(KErrInUse); // Need ::RunError to handle this
   315 		User::Leave(KErrInUse); // Need ::RunError to handle this
   303 		}
   316 		}
   379 		    CSearchDocument** document = 0;
   392 		    CSearchDocument** document = 0;
   380 		    TInt retCount = 0;
   393 		    TInt retCount = 0;
   381 		    TRAPD( err, document = iSubSession.GetBatchDocumentObjectL( retCount ) );
   394 		    TRAPD( err, document = iSubSession.GetBatchDocumentObjectL( retCount ) );
   382 		    if ( observer.iNextDocument )
   395 		    if ( observer.iNextDocument )
   383 		        {
   396 		        {
       
   397 		        OstTraceExt2( TRACE_NORMAL, CCPIXSEARCHER_RUNL, "CCPixSearcher::RunL::BatchgetDoc::;err=%d;retcount=%d", err, retCount );
   384 		        if ( err == KErrNone )
   398 		        if ( err == KErrNone )
   385 		            {
   399 		            {
   386 		            observer.iNextDocument->HandleBatchDocumentL(iStatus.Int(),retCount, document);
   400 		            observer.iNextDocument->HandleBatchDocumentL(iStatus.Int(),retCount, document);
   387 		            }
   401 		            }
   388 		        else
   402 		        else