searchfw/plugins/notessearchplugin/src/notessearcher.cpp
changeset 89 b57382753122
parent 0 f979ecb2b13e
equal deleted inserted replaced
83:5aadd1120515 89:b57382753122
       
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Plugin for note information search. 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 //System includes
       
    22 #include <e32debug.h>
       
    23 #include <e32const.h>
       
    24 #include <e32base.h> 
       
    25 #include <avkon.rsg>
       
    26 #include <barsc.h> 
       
    27 #include <utf.h>
       
    28 #include <barsread.h> 
       
    29 #include <bautils.h>
       
    30 #include <e32std.h>
       
    31 
       
    32 //Search FW Common includes  
       
    33 #include <searchtextsearcher.h>
       
    34 #include <searchresult.h>
       
    35 #include <searchlightresult.h>
       
    36 #include <searchcommon.h>
       
    37 #include <searchdocumentid.h>
       
    38 #include <searchtextsnippet.h>
       
    39 #include <searchsnippetcreator.h>
       
    40 #include <searchpluginobserver.h>
       
    41 #include <data_caging_path_literals.hrh>
       
    42 
       
    43 //User includes
       
    44 #include "notessearchpluginpanic.h"
       
    45 #include "notessearcher.h"
       
    46 
       
    47 //Constants
       
    48 const TUint     KNoteIdLengthInHex( 8 );
       
    49 const TUid      KSecureUid = { 0x101F8878 };
       
    50 const TInt      KBufferLength( 60 );
       
    51 const TInt      KBigBufferLength( 120 );
       
    52 
       
    53 _LIT(KSecure,"SECURE" );
       
    54 _LIT(KNotepadFilenameAndPath,"c:Notepad.dat");
       
    55 _LIT(KNotepadSqlSelectCmd,"SELECT * FROM Table1");
       
    56 _LIT(KNotepadSqlFormatSeek,"SELECT * FROM Table1 WHERE key=%d");
       
    57 _LIT(KAvkonResFilePath,"avkon.Rsc" );
       
    58 _LIT8(KMimeType,"MIME/TEXT");
       
    59 
       
    60 
       
    61 
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // Constructor
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 CNotesSearcher::CNotesSearcher(const TUid&  aPluginId) 
       
    68 :   CActive(CActive::EPriorityStandard),
       
    69     iNotesPluginId(aPluginId),
       
    70     iSDbmsUp(EFalse)
       
    71     {
       
    72       CActiveScheduler::Add(this);
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // 1st Phase constructor
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 CNotesSearcher*  CNotesSearcher::NewL( const RArray<TUid>& aContentIdArray,
       
    80                                        const CSearchCondition& aCondition,
       
    81                                        const TUid& aPluginId,
       
    82                                        MSearchPluginObserver& aObserver )
       
    83     {
       
    84     CNotesSearcher* self = new( ELeave ) CNotesSearcher( aPluginId );
       
    85     CleanupStack::PushL(self);
       
    86     ( *self ).ConstructL(aContentIdArray,aCondition,aObserver);
       
    87     CleanupStack::Pop(self);
       
    88     return self;
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // Called to handle error when RunL leaves
       
    93 // -----------------------------------------------------------------------------
       
    94 // 
       
    95 TInt CNotesSearcher::RunError( TInt /*aError*/ ) 
       
    96 {
       
    97 	return KErrNone;
       
    98 }
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // Destructor
       
   102 // -----------------------------------------------------------------------------
       
   103 //  
       
   104 CNotesSearcher::~CNotesSearcher()
       
   105     {
       
   106 	
       
   107 
       
   108 	if ( iTextSearcher )
       
   109 	{
       
   110 		delete iTextSearcher;
       
   111 		iTextSearcher = NULL;	
       
   112     	}
       
   113 	
       
   114 	if(iDateFormat)
       
   115 	    {
       
   116 		
       
   117 		 delete iDateFormat;
       
   118 		 iDateFormat = NULL;
       
   119      	}
       
   120 	//if(0 < iHeavyResultsArray.Count())
       
   121 	//{
       
   122 	iHeavyResultsArray.ResetAndDestroy();
       
   123 	/*iSearchLightResult.Reset();
       
   124 		
       
   125 	}
       
   126 	else
       
   127 	{
       
   128 	iSearchLightResult.ResetAndDestroy();
       
   129 	} */
       
   130 	
       
   131 
       
   132 	
       
   133 	//Close the view
       
   134     iDbView.Close();
       
   135     
       
   136     //Close the database 
       
   137     iNamedDataBase.Close();
       
   138     
       
   139     //Close the session
       
   140     iDbSession.Close();
       
   141     
       
   142        	
       
   143 	}
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // CNotesSearcher::CheckIfEntryExists
       
   147 // Check if the entry exists in notes
       
   148 // -----------------------------------------------------------------------------
       
   149 
       
   150 TBool CNotesSearcher::CheckIfEntryExistsL (TInt aNoteKey)
       
   151     {
       
   152     
       
   153     TBuf<KBufferLength> sqlStatement;
       
   154     sqlStatement.Format(KNotepadSqlFormatSeek, aNoteKey);
       
   155     
       
   156     RDbView dbView;
       
   157     CleanupClosePushL(dbView);
       
   158     dbView.Prepare( iNamedDataBase , TDbQuery( sqlStatement ) , RDbView::EReadOnly  );
       
   159     dbView.EvaluateAll();
       
   160         
       
   161     TInt isAtRow(dbView.FirstL());
       
   162     CleanupStack::PopAndDestroy(); // dbView
       
   163     
       
   164     if(isAtRow)
       
   165     {
       
   166     	
       
   167     	return ETrue;
       
   168     }
       
   169     return EFalse;
       
   170    
       
   171 
       
   172    }
       
   173 // -----------------------------------------------------------------------------
       
   174 // Releases the resources
       
   175 // -----------------------------------------------------------------------------
       
   176 //      
       
   177 void CNotesSearcher::Destroy()
       
   178     {
       
   179     
       
   180     
       
   181     if( IsActive( ))
       
   182         {
       
   183         // If already active, then send cancel
       
   184          CActive::Cancel();
       
   185         }
       
   186      else
       
   187         {
       
   188         // Call the cleanup module
       
   189         CleanUp( ); 
       
   190         }  
       
   191         
       
   192     //if(0 < iHeavyResultsArray.Count())
       
   193 	//{
       
   194 //	iHeavyResultsArray.ResetAndDestroy();
       
   195 /*	iSearchLightResult.Reset();
       
   196 		
       
   197 	}
       
   198 	else
       
   199 	{
       
   200 	iSearchLightResult.ResetAndDestroy();
       
   201 	}     
       
   202   */  
       
   203   delete this;
       
   204         
       
   205     }
       
   206 
       
   207 
       
   208 // -----------------------------------------------------------------------------
       
   209 // for internal cleanup
       
   210 // -----------------------------------------------------------------------------
       
   211 //  
       
   212 void CNotesSearcher::CleanUp()
       
   213     {
       
   214     
       
   215     iKeyHitPos.Reset();  
       
   216     if(iContent)
       
   217         {
       
   218         delete iContent;
       
   219         iContent = NULL;
       
   220         }
       
   221     
       
   222     }
       
   223 
       
   224 // -----------------------------------------------------------------------------
       
   225 // second phase constructor.
       
   226 // -----------------------------------------------------------------------------
       
   227 //
       
   228 void  CNotesSearcher::ConstructL(const RArray<TUid>& /*aContentIdArray*/,
       
   229                                  const CSearchCondition& aCondition,
       
   230                                  MSearchPluginObserver& aObserver )
       
   231     {
       
   232     //Create the text searcher and set the parameters
       
   233     iObserver  = &aObserver;
       
   234     iTextSearcher = CSearchTextSearcher::NewL( *this );
       
   235     iTextSearcher->SetParametersL( aCondition  ); 
       
   236   
       
   237     //Initilize the database
       
   238     InitDbL();  
       
   239    
       
   240     
       
   241     RFs 		    	fsSession;
       
   242     TFileName 		resourceFileName;
       
   243     RResourceFile     resourceFile;
       
   244 
       
   245     User::LeaveIfError( fsSession.Connect() );
       
   246     resourceFileName.Copy( TParsePtrC( RProcess().FileName() ).Drive() );  
       
   247     resourceFileName.Append( KDC_RESOURCE_FILES_DIR );
       
   248     resourceFileName.Append( KAvkonResFilePath );
       
   249     	
       
   250     // Get language local file name of resource file.
       
   251     BaflUtils::NearestLanguageFile( fsSession, resourceFileName );
       
   252 	resourceFile.OpenL(fsSession, resourceFileName );
       
   253 	resourceFile.ConfirmSignatureL();
       
   254     
       
   255     //Read the short date format resource file 	
       
   256     HBufC8* readDateBuffer=resourceFile.AllocReadLC( R_QTN_DATE_SHORT );
       
   257 	const TPtrC16 ptrReadDateBuffer(( TText16*) readDateBuffer->Ptr(),
       
   258 							( readDateBuffer->Length()+1 )>>1 );
       
   259 								
       
   260 								
       
   261     iDateFormat = ptrReadDateBuffer.AllocL();
       
   262    
       
   263     CleanupStack::PopAndDestroy( readDateBuffer );	
       
   264 	resourceFile.Close();										
       
   265 
       
   266 
       
   267     }
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 // Initialize DB
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 void CNotesSearcher::InitDbL()
       
   274     {
       
   275     //Connect to the database session
       
   276     User::LeaveIfError( iDbSession.Connect() );
       
   277 
       
   278     TBuf<32> format;
       
   279     format.Copy(KSecure);
       
   280     format.Append(KSecureUid.Name());
       
   281     
       
   282     TInt err(iNamedDataBase.Open(iDbSession, KNotepadFilenameAndPath() ,format));
       
   283     if(err == KErrNone)
       
   284         {
       
   285         iNamedDataBase.Compact();
       
   286         User::LeaveIfError(iDbView.Prepare(iNamedDataBase,
       
   287                             TDbQuery(KNotepadSqlSelectCmd),RDbView::EReadOnly));
       
   288         User::LeaveIfError(iDbView.EvaluateAll());
       
   289         iSDbmsUp = ETrue;
       
   290         }
       
   291     }
       
   292 
       
   293 // -----------------------------------------------------------------------------
       
   294 // from CActive
       
   295 // -----------------------------------------------------------------------------
       
   296 //  
       
   297 void CNotesSearcher::RunL()
       
   298     {
       
   299     if( DoActualSearchL() )
       
   300         {
       
   301         TRequestStatus* status = &iStatus;
       
   302         User::RequestComplete( status, KErrNone );
       
   303         SetActive();
       
   304         }
       
   305     }
       
   306 
       
   307 // -----------------------------------------------------------------------------
       
   308 // Do actual search 
       
   309 // -----------------------------------------------------------------------------
       
   310 //  
       
   311 TBool CNotesSearcher::DoActualSearchL()
       
   312     {
       
   313     
       
   314     TUint  resultCounter = 1;
       
   315     TBool  exitStatus  = ETrue;
       
   316     
       
   317     while( ETrue )
       
   318         {
       
   319         iDbView.GetL();
       
   320         iTextSearcher->Cleanup();
       
   321         RDbColReadStream  blob;
       
   322         
       
   323         // get one memo 
       
   324         blob.OpenLC( iDbView, CNotesSearcher::ENotepadMemo );
       
   325         TInt colLength(iDbView.ColLength(CNotesSearcher::ENotepadMemo) );
       
   326         if( iContent )
       
   327             {
       
   328             delete iContent;
       
   329             iContent = NULL;
       
   330             }
       
   331         iContent = HBufC16::NewL(colLength);
       
   332         TPtr16  contentptr(iContent->Des());
       
   333         blob.ReadL(contentptr,colLength);
       
   334         CleanupStack::PopAndDestroy(); //blob for full memo  
       
   335 
       
   336         iStatusItemCounter = resultCounter;
       
   337         iTextSearcher->SearchL(*iContent);
       
   338         
       
   339         if(iTotalNumOfItems == iStatusItemCounter )
       
   340         {
       
   341         iObserver->SearchCompletedL(KErrNone,iTotalNumOfItems); 
       
   342         exitStatus = EFalse;
       
   343         break;
       
   344         }
       
   345         
       
   346         if( !iDbView.AtRow() ) 
       
   347         {
       
   348         iObserver->SearchCompletedL(KErrNotFound,KErrNotFound); 
       
   349         exitStatus = EFalse;
       
   350         break;
       
   351         }
       
   352         
       
   353         iDbView.NextL();
       
   354         resultCounter++;
       
   355         }
       
   356         
       
   357      return exitStatus;  
       
   358     
       
   359     }
       
   360 
       
   361 
       
   362 
       
   363 // -----------------------------------------------------------------------------
       
   364 // called by framework , when Close function is called
       
   365 // -----------------------------------------------------------------------------
       
   366 //  
       
   367 void CNotesSearcher::DoCancel()
       
   368     {
       
   369     //Call the clean up module
       
   370     CleanUp();
       
   371     }
       
   372 
       
   373 // -----------------------------------------------------------------------------
       
   374 // Does Searching of notes 
       
   375 // -----------------------------------------------------------------------------
       
   376 //  
       
   377 void CNotesSearcher::SearchL(void)
       
   378     {
       
   379     __ASSERT_DEBUG(!IsActive(),User::Panic(KNotesAlreadyActive,EPanicAlreadyActive));   
       
   380     
       
   381     
       
   382   //  if(0 < iHeavyResultsArray.Count())
       
   383 //	{
       
   384 	iHeavyResultsArray.ResetAndDestroy();
       
   385 /*	iSearchLightResult.Reset();
       
   386 		
       
   387 	}
       
   388 	else
       
   389 	{
       
   390 	iSearchLightResult.ResetAndDestroy();
       
   391 	}  
       
   392 */	iKeyHitPos.Reset();  
       
   393     //Check if DBMS is up or quit reporting search complete 
       
   394     if( !iSDbmsUp )
       
   395         {
       
   396         iObserver->SearchCompletedL(KErrNotFound,KErrNotFound);   
       
   397         return;
       
   398         }
       
   399     
       
   400     // Positions the cursor on the first row in the rowset.
       
   401     TRAPD( err , iDbView.FirstL() );
       
   402     if(err != KErrNone )
       
   403         {
       
   404         // Error, so complete the search
       
   405         iObserver->SearchCompletedL(KErrNotFound,KErrNotFound);     
       
   406         return;
       
   407         }
       
   408     if( iDbView.AtEnd() )
       
   409         {
       
   410         // Reached the end of the database view,
       
   411         // complete the search
       
   412         iObserver->SearchCompletedL(KErrNotFound,KErrNotFound); 
       
   413         return;   
       
   414         }
       
   415     
       
   416     iStatusItemCounter = 1;
       
   417     iTotalNumOfItems   = iDbView.CountL();
       
   418     
       
   419     if( 0 == iTotalNumOfItems )
       
   420         {
       
   421         // No items in the databse,complete the search
       
   422         iObserver->SearchCompletedL(KErrNotFound,KErrNotFound); 
       
   423         return; 
       
   424         }
       
   425        
       
   426     TRequestStatus* status = &iStatus;
       
   427     User::RequestComplete( status, KErrNone );
       
   428     SetActive();
       
   429     }
       
   430 
       
   431 // -----------------------------------------------------------------------------
       
   432 // This method gives final results , with snippet 
       
   433 // -----------------------------------------------------------------------------
       
   434 //  
       
   435 void CNotesSearcher::GetResultsL( const RPointerArray<CSearchDocumentId>& 
       
   436                                                         aDocumentIdArray )
       
   437     {
       
   438     
       
   439      
       
   440  
       
   441       RPointerArray<CSearchResult> searchResultArray; 
       
   442        
       
   443       TBufC8<KBufferLength> mineType(KMimeType);
       
   444        
       
   445       for(TInt i = 0 ; i < aDocumentIdArray.Count() ; i++ )
       
   446         {
       
   447            for(TInt j = 0 ; j < iHeavyResultsArray.Count() ; j++ )
       
   448             {
       
   449             
       
   450             if( (aDocumentIdArray[i]->DocumentId() == 
       
   451 	    				 (iHeavyResultsArray[j]->Result()).DocumentId().DocumentId() ) && 
       
   452 	    				 (aDocumentIdArray[i]->PluginId().iUid == iNotesPluginId.iUid ) &&
       
   453 	    				 (aDocumentIdArray[i]->RepositoryId() == KSearchCClassNotesUid.iUid)
       
   454 	    				 )
       
   455                 {
       
   456                 
       
   457                 
       
   458 	            CSearchResult* tempHeavy =  	iHeavyResultsArray[j];
       
   459 	            if((&tempHeavy->Title() != NULL) && (&tempHeavy->Snippet() != NULL))
       
   460 	            {
       
   461 	                 searchResultArray.Append( iHeavyResultsArray[j]);
       
   462 	                 continue;	
       
   463 	            }
       
   464 	            //TLex8 myDocId(aDocumentIdArray[i]->DocumentId() );
       
   465 	        
       
   466 	        	TInt noteKey = aDocumentIdArray[i]->DocumentId();
       
   467 	        //	TInt err = myDocId.Val(noteKey);
       
   468 	   
       
   469               //  if( KErrNone == err)
       
   470 	            {
       
   471 	               		
       
   472         		//CSearchResult* searchResult = CSearchResult::NewL( iHeavyResultsArray[j] );
       
   473         		//CleanupStack::PushL( searchResult );
       
   474         		HBufC* contentData = NULL;
       
   475         		TTime  timeLine; 
       
   476         		GetContentAndDateByKeyL(noteKey ,contentData, timeLine);
       
   477         		
       
   478                 TBufC<KBigBufferLength> dateString;
       
   479 		        TPtr tempDateStringPtr( dateString.Des() );
       
   480 		        timeLine.FormatL( tempDateStringPtr, *iDateFormat );
       
   481         		
       
   482 				CSearchSnippetCreator* SnippetCreator	= CSearchSnippetCreator::NewL();
       
   483 			    CleanupStack::PushL(SnippetCreator);
       
   484 			    CSearchTextSnippet* textSnippet = 
       
   485 			    	SnippetCreator->CreateTextSnippetL(*(contentData), iKeyHitPos[j] );
       
   486 			    	
       
   487 			    TBufC<KBufferLength> tempString1;
       
   488 				TPtr titlePtr( tempString1.Des() );
       
   489 				CnvUtfConverter::ConvertToUnicodeFromUtf8( titlePtr,
       
   490 										textSnippet->Snippet() );
       
   491 										
       
   492                 if(iKeyHitPos[j]  < 15)
       
   493                 {
       
   494                    
       
   495         		   TBufC8<KBufferLength> tempString;
       
   496 	               TPtr8 tempPtr8( tempString.Des() );
       
   497                    CnvUtfConverter::ConvertFromUnicodeToUtf8( tempPtr8,tempDateStringPtr );
       
   498         		   iHeavyResultsArray[j]->SetSnippetL( tempPtr8 ); 	
       
   499                 }
       
   500                 else
       
   501                 {
       
   502                     TBufC8<KBufferLength> tempString;
       
   503 	                TPtr8 tempPtr8( tempString.Des() );
       
   504                     CnvUtfConverter::ConvertFromUnicodeToUtf8( tempPtr8,titlePtr );
       
   505         		 
       
   506                 	iHeavyResultsArray[j]->SetSnippetL( tempPtr8 );  
       
   507                 }
       
   508                 
       
   509         		iHeavyResultsArray[j]->SetTitleL( *contentData );
       
   510         		
       
   511         		
       
   512         		iHeavyResultsArray[j]->SetSnippetFormatL( mineType );
       
   513         		
       
   514         		CleanupStack::PopAndDestroy( SnippetCreator );
       
   515         		  		
       
   516         		if( contentData)
       
   517         		    {
       
   518         		    delete contentData;
       
   519         		    contentData = NULL;
       
   520         		    }
       
   521         	
       
   522                 //CleanupStack::Pop( searchResult );
       
   523         	    	
       
   524         	    searchResultArray.Append( iHeavyResultsArray[j] );
       
   525         	    //iHeavyResultsArray.Append( searchResult );
       
   526         	    if(textSnippet)
       
   527         	    {
       
   528         	    	delete textSnippet;
       
   529         	    	textSnippet = NULL;
       
   530         	    }
       
   531         	    
       
   532         	    
       
   533 	            }
       
   534 	            
       
   535     	    	}
       
   536             
       
   537             }
       
   538       }
       
   539       
       
   540       //Complete the results retrival
       
   541       iObserver->ResultsRetrieveCompleteL( searchResultArray ); 
       
   542       searchResultArray.Reset() ;
       
   543       searchResultArray.Close();
       
   544 
       
   545     }
       
   546     
       
   547 // -----------------------------------------------------------------------------
       
   548 // CNotesSearcher::GetSearchProgressL
       
   549 // search progress
       
   550 // -----------------------------------------------------------------------------
       
   551 //      
       
   552 void CNotesSearcher::GetSearchProgressL(TUid& aContentClassId, 
       
   553                                          TInt& aCurrentDocument, 
       
   554                                          TInt& aTotalDocuments  )
       
   555     {
       
   556     if( aContentClassId == KSearchCClassNotesUid )
       
   557         {
       
   558         aCurrentDocument = iStatusItemCounter;
       
   559         aTotalDocuments = iTotalNumOfItems;
       
   560         }
       
   561     }
       
   562 
       
   563 // -----------------------------------------------------------------------------
       
   564 // CNotesSearcher::CancelResultsRetrieve()
       
   565 // -----------------------------------------------------------------------------
       
   566 //      
       
   567 void CNotesSearcher::CancelResultsRetrieve()
       
   568     {
       
   569       
       
   570     }
       
   571 // -----------------------------------------------------------------------------
       
   572 // CNotesSearcher::IsSearching
       
   573 // return TBool 
       
   574 // -----------------------------------------------------------------------------
       
   575 //  
       
   576 TBool CNotesSearcher::IsSearching()
       
   577     {
       
   578     return IsActive();  
       
   579     }
       
   580 
       
   581 // -----------------------------------------------------------------------------
       
   582 // CNotesSearcher::Cancel
       
   583 // Cancels searching 
       
   584 // -----------------------------------------------------------------------------
       
   585 //  
       
   586 void CNotesSearcher::CancelSearch()   
       
   587     {
       
   588     CActive::Cancel();    
       
   589     }
       
   590 
       
   591 
       
   592 // -----------------------------------------------------------------------------
       
   593 // notification from textsearcher , when keyword is found  
       
   594 // -----------------------------------------------------------------------------
       
   595 //      
       
   596 void CNotesSearcher::HitL( TInt aKeywordCharPos )
       
   597     {
       
   598     // get the key for memo     
       
   599     TInt key ( iDbView.ColInt( CNotesSearcher::ENotepadKey ) );
       
   600     TBuf8<KNoteIdLengthInHex> entryId;
       
   601     entryId.AppendNum( key/*, EHex*/ );
       
   602     
       
   603 	CSearchDocumentId*  documentid = CSearchDocumentId::NewL( key , iNotesPluginId );
       
   604 	documentid->SetRepositoryIdL( KSearchCClassNotesUid.iUid );
       
   605 	//Create the light result
       
   606 	CSearchLightResult* searchLightResult = CSearchLightResult::NewL( documentid );
       
   607 	searchLightResult->SetContentClassId( KSearchCClassNotesUid );
       
   608 	searchLightResult->SetSubContentId( 0 );
       
   609 	searchLightResult->SetServiceId( KNullUid );
       
   610 	
       
   611     // Append the lighresult to the  iSearchLightResult array
       
   612 	//iSearchLightResult.AppendL( searchLightResult );
       
   613 	
       
   614 	// Append the key hit position to the  to the  iKeyHitPos array
       
   615 	iKeyHitPos.AppendL( aKeywordCharPos );
       
   616 	
       
   617 	
       
   618 	CSearchResult* searchResult = CSearchResult::NewL( searchLightResult);
       
   619 
       
   620 	searchResult->SetSnippetL(KNullDesC8);
       
   621 	searchResult->SetTitleL(KNullDesC);
       
   622 	iHeavyResultsArray.Append( searchResult );
       
   623 	//Notify the observer about the found result
       
   624 	iObserver->ResultFoundL(searchLightResult ,iStatusItemCounter, iTotalNumOfItems );
       
   625 	
       
   626     }
       
   627     
       
   628     
       
   629  HBufC8* CNotesSearcher::LaunchInfoL( const CSearchDocumentId& aDocumentID )
       
   630  {
       
   631      if((aDocumentID.PluginId() == iNotesPluginId) &&
       
   632         (aDocumentID.RepositoryId() == KSearchCClassNotesUid.iUid))
       
   633          {
       
   634          
       
   635          
       
   636          //RAVI CHECK THIS 
       
   637          HBufC8 * launchInfo = HBufC8::NewL(256);
       
   638                   TPtr8 docIdPtr = launchInfo->Des();
       
   639          docIdPtr.AppendNum(aDocumentID.DocumentId());
       
   640          //docIdPtr = (aDocumentID.DocumentId()).AllocL();
       
   641          return launchInfo;
       
   642          }
       
   643      
       
   644      return NULL;
       
   645      
       
   646 	
       
   647 }
       
   648 // -----------------------------------------------------------------------------
       
   649 // To retrive note content and date of note from notepad db 
       
   650 // -----------------------------------------------------------------------------
       
   651 //      
       
   652 void  CNotesSearcher::GetContentAndDateByKeyL(const TInt& aKey,HBufC*& aContentDes,
       
   653                                               TTime&  aTime)
       
   654     {
       
   655     TBuf<KBufferLength> sqlStatement;
       
   656     sqlStatement.Format(KNotepadSqlFormatSeek, aKey);
       
   657     
       
   658     RDbView dbView;
       
   659     CleanupClosePushL(dbView);
       
   660     dbView.Prepare( iNamedDataBase , TDbQuery( sqlStatement ) , RDbView::EReadOnly  );
       
   661     dbView.EvaluateAll();
       
   662     
       
   663     TTime  timeData;
       
   664     TInt isAtRow(dbView.FirstL());
       
   665     User::LeaveIfError(isAtRow);
       
   666     if ( isAtRow )
       
   667         {
       
   668         dbView.GetL();
       
   669         
       
   670         HBufC* contentDes;
       
   671         RDbColReadStream blob;
       
   672         blob.OpenLC(dbView, CNotesSearcher::ENotepadMemo);
       
   673         TInt colLength( dbView.ColLength( CNotesSearcher::ENotepadMemo ) );
       
   674         
       
   675         contentDes = HBufC::NewL(colLength);
       
   676         TPtr ptr ( contentDes->Des() );
       
   677         blob.ReadL(ptr, colLength);
       
   678                   
       
   679         aContentDes = HBufC::NewL( colLength );
       
   680         aContentDes->Des().Append( ptr ); 
       
   681         CleanupStack::PopAndDestroy(); // blob
       
   682         delete contentDes;
       
   683         contentDes = NULL;
       
   684         
       
   685         timeData = iDbView.ColTime( CNotesSearcher::ENotepadUpdateTime );
       
   686         aTime = timeData;
       
   687         }
       
   688     CleanupStack::PopAndDestroy(); // dbView
       
   689     }
       
   690     
       
   691     
       
   692 
       
   693 //end of file
       
   694