searchfw/plugins/messagingplugin/src/messagessearcher.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     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 messagingplugin information search.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19   
       
    20 // Includes
       
    21 #include <smuthdr.h>
       
    22 #include <mtclreg.h>	
       
    23 #include <smsclnt.h>
       
    24 #include <mmsvattachmentmanager.h> 
       
    25 #include <searchtextsearcher.h>
       
    26 #include <searchpluginobserver.h>
       
    27 #include <msgentrydetails.h>
       
    28 #include <SenduiMtmUids.h>
       
    29 #include <btmsgtypeuid.h>
       
    30 #include <utf.h>
       
    31 #include <msvids.h>
       
    32 #include <mtmuibas.h>
       
    33 #include <mtmuidef.hrh>
       
    34 #include <searchdocumentid.h>
       
    35 #include <searchlightresult.h>
       
    36 #include <searchcondition.h>
       
    37 #include <searchpluginobserver.h>
       
    38 #include <searchresult.h>
       
    39 #include <searchcommon.h>
       
    40 #include <searchsnippetcreator.h>
       
    41 #include <searchtextsnippet.h>
       
    42 
       
    43 //USER INCLUDES
       
    44 #include "messagessearcher.h"
       
    45 #include "messagessearchplugindefines.h"
       
    46 
       
    47 // Definition of service
       
    48 const TUid KMuiuMsgEditorServiceUid = { 0x101F8820 };
       
    49 
       
    50 // Service types
       
    51 const TInt KMsgServiceView = 0x00000001;
       
    52 const TInt KMsgServiceEdit = 0x00000002;
       
    53 //
       
    54 
       
    55 // ------------------------------------------------------------------------------------------------
       
    56 // CMessagesSearcher::NewL()
       
    57 // Symbian 1st phase constructor
       
    58 // ------------------------------------------------------------------------------------------------
       
    59 //
       
    60 
       
    61 CMessagesSearcher*  CMessagesSearcher::NewL( const RArray<TUid>& aContentIdArray, 
       
    62 								                    const CSearchCondition& aCondition, 
       
    63 								                    const TUid& aPluginId,
       
    64 								                    MSearchPluginObserver& aObserver )
       
    65 {
       
    66     CMessagesSearcher* self = new( ELeave )CMessagesSearcher( aPluginId);
       
    67 
       
    68     CleanupStack::PushL ( self );
       
    69     self->ConstructL( aContentIdArray, aCondition,aObserver );
       
    70     CleanupStack::Pop( self );
       
    71 
       
    72     return self;
       
    73 }
       
    74 
       
    75 
       
    76 // ------------------------------------------------------------------------------------------------
       
    77 // CMessagesSearcher::ConstructL()
       
    78 // Symbian 2nd phase constructor
       
    79 // ------------------------------------------------------------------------------------------------
       
    80 //   
       
    81 
       
    82 void CMessagesSearcher::ConstructL( const RArray<TUid>& aContentIdArray, 
       
    83 								    const CSearchCondition& aCondition,
       
    84 								    MSearchPluginObserver& aObserver )
       
    85 {
       
    86 	iObserver = &aObserver;
       
    87 	iSession = CMsvSession::OpenSyncL( *this );
       
    88 	iMtmReg = CClientMtmRegistry::NewL( *iSession );
       
    89 
       
    90 	iSmsMtm = STATIC_CAST ( CSmsClientMtm*, iMtmReg->NewMtmL( KUidMsgTypeSMS ) );
       
    91 	iMmsMtm = STATIC_CAST ( CMmsClientMtm*, iMtmReg->NewMtmL( KUidMsgTypeMultimedia ) );
       
    92 	
       
    93 	SetPriority( EPriorityStandard );
       
    94 	iTextSearcher = CSearchTextSearcher::NewL( *this );	
       
    95 	iTextSearcher->SetParametersL( aCondition ); 
       
    96 		    
       
    97     iFolderEntry = NULL;
       
    98     iSearchNotCancelled = ETrue;
       
    99 
       
   100 	User::LeaveIfError( iFs.Connect() );		// Connect to the filesystem:RFileSystem
       
   101 	iHitFound = EFalse;
       
   102 
       
   103 } // ConstructL
       
   104 
       
   105 // ------------------------------------------------------------------------------------------------
       
   106 // CMessagesSearcher::CMessagesSearcher()
       
   107 // C++ default constructor
       
   108 // ------------------------------------------------------------------------------------------------
       
   109 //
       
   110 CMessagesSearcher::CMessagesSearcher( const TUid&  aPluginId)
       
   111 : iPluginId( aPluginId ),
       
   112 CActive(EPriorityStandard)
       
   113 {
       
   114     CActiveScheduler::Add( this );
       
   115 }
       
   116 
       
   117 // ------------------------------------------------------------------------------------------------
       
   118 // CMessagesSearcher::IsEntryDeleted()
       
   119 // Checks the deltion of the entry before launching
       
   120 // ------------------------------------------------------------------------------------------------
       
   121 //
       
   122 TBool CMessagesSearcher::IsEntryDeleted( TMsvId& aMsgEntryId )
       
   123 {
       
   124 	if( iEntryDeleted )
       
   125 	{	
       
   126 		if( iEntryDeleted->Find( aMsgEntryId ) == KErrNotFound )
       
   127 			return EFalse;
       
   128 		else
       
   129 			return ETrue;
       
   130 	}
       
   131 	else
       
   132 	{
       
   133 		return EFalse;
       
   134 	}
       
   135 }
       
   136 // ------------------------------------------------------------------------------------------------
       
   137 // CMessagesSearcher::~CMessagesSearcher()
       
   138 // Destructor
       
   139 // ------------------------------------------------------------------------------------------------
       
   140 //
       
   141 CMessagesSearcher::~CMessagesSearcher()
       
   142 {	    
       
   143 
       
   144 
       
   145 delete iMsvStore;
       
   146     
       
   147     iMsgDesCArray.ResetAndDestroy();
       
   148  	iHeavyResultsArray.ResetAndDestroy();  
       
   149  	if(iTextSearcher)
       
   150     {
       
   151     	delete iTextSearcher;
       
   152     	iTextSearcher = NULL;
       
   153     }
       
   154   
       
   155 	if( iSmsMtm )
       
   156 	    {
       
   157 		delete iSmsMtm;
       
   158 		iSmsMtm = NULL;
       
   159 	    }
       
   160 	
       
   161     if( iMmsMtm )
       
   162 	    {
       
   163 		delete iMmsMtm;
       
   164 		iMmsMtm = NULL;
       
   165      	}
       
   166 
       
   167 	if( iGenericMtm )
       
   168 	{
       
   169 		delete iGenericMtm;	
       
   170 		iGenericMtm = NULL;
       
   171 	}
       
   172      
       
   173     if( iSession )
       
   174 	{
       
   175 		delete iSession;
       
   176 		iSession = NULL;	
       
   177 	} 
       
   178     if( iEntryDeleted )
       
   179 	    delete iEntryDeleted;
       
   180 	
       
   181 											// check for the members that are to be cleaned up...
       
   182 }  // ~CMessagesSearcher
       
   183 
       
   184 // ------------------------------------------------------------------------------------------------
       
   185 // CMessagesSearcher::Destroy()
       
   186 // Search FW calls this function when it no longer needs this searcher.
       
   187 // ------------------------------------------------------------------------------------------------
       
   188 //
       
   189 void CMessagesSearcher::Destroy()
       
   190 {
       
   191 	iSearchNotCancelled = EFalse;
       
   192 	
       
   193 	if( IsActive() ) 
       
   194 	{
       
   195 		CActive::Cancel();
       
   196 	}
       
   197 	else
       
   198 	{
       
   199 	CleanUp();	
       
   200 	}	
       
   201 	delete this;
       
   202 }
       
   203 
       
   204 // ------------------------------------------------------------------------------------------------
       
   205 // CMessagesSearcher::CancelSearch()
       
   206 // Cancels the search operation and then does the Cleanup stuff...
       
   207 // ------------------------------------------------------------------------------------------------
       
   208 //
       
   209 void CMessagesSearcher::CancelSearch()
       
   210 {
       
   211 	iSearchNotCancelled = EFalse;
       
   212 	CleanUp();
       
   213 }	
       
   214 
       
   215 // ------------------------------------------------------------------------------------------------
       
   216 // CMessagesSearcher::DoCancel()
       
   217 // Cancels the search.
       
   218 // ------------------------------------------------------------------------------------------------
       
   219 //
       
   220 void CMessagesSearcher::DoCancel()
       
   221 {
       
   222 CleanUp();
       
   223 	
       
   224 }
       
   225 
       
   226 
       
   227 // ------------------------------------------------------------------------------------------------
       
   228 // CMessagesSearcher::Cleanup()
       
   229 // For CleanUp resources
       
   230 // ------------------------------------------------------------------------------------------------
       
   231 //
       
   232 
       
   233 void CMessagesSearcher::CleanUp()
       
   234 {                	
       
   235 	if( iFolderEntry )
       
   236 	{
       
   237 		delete iFolderEntry;
       
   238 		iFolderEntry = NULL;
       
   239 	}
       
   240 	
       
   241 
       
   242 	if( iMessageEntry )
       
   243 	{	
       
   244 		delete iMessageEntry;
       
   245 		iMessageEntry = NULL;
       
   246 	}
       
   247 	
       
   248 	if( iMessageEntries )
       
   249 	{
       
   250 		delete iMessageEntries;	
       
   251 		iMessageEntries = NULL;
       
   252 	}
       
   253 					
       
   254 	
       
   255 	iToBeSearchedFolders.Close();
       
   256 
       
   257 
       
   258 	iFs.Close();
       
   259     iMtmArray.Reset();
       
   260 		
       
   261    if(iCurrentTextBeingSearched)
       
   262      {
       
   263      delete iCurrentTextBeingSearched;
       
   264      iCurrentTextBeingSearched = NULL;
       
   265 	 } 
       
   266 	if(iSenderReciever)
       
   267 	{
       
   268 	   	delete iSenderReciever;
       
   269 	   	iSenderReciever = NULL;
       
   270 	   }
       
   271 	iMsgEntriesInFoldersArray.Reset();
       
   272 }
       
   273     
       
   274 // ------------------------------------------------------------------------------------------------
       
   275 // Starts the search. Progress of the search is notified through aObserver. This call must be asynchronous.
       
   276 // ------------------------------------------------------------------------------------------------
       
   277 //
       
   278 void CMessagesSearcher::SearchL( )
       
   279 {
       
   280 
       
   281     
       
   282 	iHeavyResultsArray.ResetAndDestroy();
       
   283 	iMsgDesCArray.ResetAndDestroy();
       
   284     CMessagesSearcher::SetTargetFolderL();
       
   285     iHitFound = EFalse;
       
   286 
       
   287 	
       
   288 	__ASSERT_ALWAYS( this != NULL, User::Panic( KMessagesSearchPlugIn,
       
   289             EMessageSearchPlugInWrongConstructionParameters ) );
       
   290 
       
   291 	 if( iTextSearcher == NULL) 
       
   292 		 {
       
   293 		   ReportFinishedL( KErrNone );
       
   294 		    return;
       
   295 		 }
       
   296 	// condition that checks if ready for searching and if there's 
       
   297 	// any message entry in any of the desired folders. If no entries, no results found
       
   298 	if(!PrepareForSearchL())
       
   299 		{
       
   300 		iObserver->SearchCompletedL( KErrNone, KErrNone );
       
   301 		return;
       
   302 		}
       
   303 				
       
   304 	else	
       
   305 		{   
       
   306 		//start the search
       
   307 		iTotalNumOfItems = 0;
       
   308 	    iStatusItemCounter = 1;
       
   309 	    TRequestStatus* status = &iStatus;
       
   310 	    User::RequestComplete( status, KErrNone );
       
   311 	    SetActive();
       
   312 		}
       
   313 }
       
   314 
       
   315 // ------------------------------------------------------------------------------------------------
       
   316 // CMessagesSearcher::NoEntriesInAllFolders()
       
   317 // ------------------------------------------------------------------------------------------------
       
   318 //
       
   319 
       
   320 TBool CMessagesSearcher::AnyEntriesInAllFolders()
       
   321 {
       
   322 
       
   323 for(TInt i= 0; i <iMsgEntriesInFoldersArray.Count(); i++)	
       
   324 {
       
   325 	if(0 != iMsgEntriesInFoldersArray[i])	
       
   326 		return ETrue;
       
   327 
       
   328 }
       
   329 return EFalse;
       
   330 }
       
   331 
       
   332 
       
   333 // ------------------------------------------------------------------------------------------------
       
   334 // CMessagesSearcher::GetResultsL( RPointerArray<CSearchResult> aResults )
       
   335 // Gets the results got so far. A call to this function must flush the plugins internal buffer,
       
   336 // ------------------------------------------------------------------------------------------------
       
   337 //
       
   338 void CMessagesSearcher::GetResultsL( const RPointerArray<CSearchDocumentId>& aDocumentIdArray )
       
   339 {
       
   340     RPointerArray<CSearchResult> aSearchResultArray;  
       
   341       	
       
   342 
       
   343 	TBufC8<KBufferLength> tempBuf(KText);
       
   344 		
       
   345 	 for(TInt i = 0 ; i < aDocumentIdArray.Count() ; i++ )
       
   346         {
       
   347            for(TInt j = 0 ; j < iHeavyResultsArray.Count() ; j++ )
       
   348             {
       
   349             
       
   350             	CSearchResult* tempHeavy =  	iHeavyResultsArray[j];
       
   351             if( (aDocumentIdArray[i]->DocumentId() == 
       
   352 	    				 (iHeavyResultsArray[j]->Result()).DocumentId().DocumentId() ) && 
       
   353 	    				 (aDocumentIdArray[i]->PluginId().iUid == iPluginId.iUid ) &&
       
   354 	    				 (aDocumentIdArray[i]->RepositoryId() == KSearchCClassMessagesUid.iUid)
       
   355 	    				 )
       
   356                 {
       
   357                	if((&tempHeavy->Title() != NULL) && (&tempHeavy->Snippet() != NULL))
       
   358 	                 {
       
   359 	                        aSearchResultArray.Append( iHeavyResultsArray[j]);
       
   360 	                        continue;	
       
   361 	                 }
       
   362 				if ( 0 < (*(iMsgDesCArray[j]->GetTitle())).Size() ) 	  
       
   363 				{
       
   364 					tempHeavy->SetTitleL( *(iMsgDesCArray[j]->GetTitle()));
       
   365 				} 
       
   366 			
       
   367 		         	
       
   368 
       
   369 					TInt KeyHitPos = iMsgDesCArray[j]->GetKeywordHitPosition();
       
   370 					if(KeyHitPos != -1)
       
   371 					{
       
   372 						
       
   373 					
       
   374 					CSearchSnippetCreator* SnippetCreator = CSearchSnippetCreator::NewL();
       
   375 			    	CleanupStack::PushL(SnippetCreator);
       
   376 			    	CSearchTextSnippet* textSnippet = 
       
   377 			    		SnippetCreator->CreateTextSnippetL(*( iMsgDesCArray[j]->GetBody()), KeyHitPos);
       
   378 					
       
   379 
       
   380 					
       
   381 			    	tempHeavy->SetSnippetL( textSnippet->Snippet() );    		
       
   382 			    	
       
   383 			    	
       
   384 			       	CleanupStack::PopAndDestroy(SnippetCreator);
       
   385 			       	delete textSnippet;
       
   386 			    	textSnippet = NULL;
       
   387 					}
       
   388 					else
       
   389 					{
       
   390 					HBufC8 * msgSnippet = HBufC8::NewL( iMsgDesCArray[j]->GetBody()->Des().Length() ) ;
       
   391                     TPtr8 ptr8(msgSnippet->Des()) ;
       
   392                     TPtr16 ptr16(iMsgDesCArray[j]->GetBody()->Des()) ;
       
   393 	                CnvUtfConverter::ConvertFromUnicodeToUtf8( ptr8,ptr16 );	
       
   394                     if( msgSnippet->Length() == 0 ) 
       
   395                     {
       
   396                         _LIT8( KSpace, " " );
       
   397                         TBufC8<5>  tmpBufTitle( KSpace );
       
   398                         msgSnippet = tmpBufTitle.AllocL();
       
   399                     }	
       
   400 					tempHeavy->SetSnippetL( *msgSnippet );  
       
   401 					delete msgSnippet;
       
   402 					msgSnippet= NULL;  		
       
   403 			    	
       
   404 					}
       
   405 					tempHeavy->SetSnippetFormatL( tempBuf.Des());	
       
   406 					aSearchResultArray.AppendL( tempHeavy );
       
   407                 }
       
   408 		
       
   409 		
       
   410             }
       
   411         }
       
   412 	
       
   413 	iObserver->ResultsRetrieveCompleteL( aSearchResultArray );
       
   414     aSearchResultArray.Reset();
       
   415 
       
   416 }	
       
   417 
       
   418 // ------------------------------------------------------------------------------------------------
       
   419 // CMessagesSearcher::CancelResultsRetrieve( )
       
   420 // Cancels the request for the result retrieval
       
   421 // ------------------------------------------------------------------------------------------------
       
   422 //	
       
   423 void CMessagesSearcher::CancelResultsRetrieve ( )
       
   424 {
       
   425 
       
   426 }
       
   427 
       
   428 // ------------------------------------------------------------------------------------------------
       
   429 // CMessagesSearcher::SetTargetFolderL()
       
   430 // Cancels the search.
       
   431 // ------------------------------------------------------------------------------------------------
       
   432 //
       
   433 
       
   434 void CMessagesSearcher::SetTargetFolderL()
       
   435 {
       
   436 iToBeSearchedFolders.Reset();
       
   437 
       
   438 // Find all subfolders under the "Root" folder
       
   439 CMsvEntry* rootEntry;
       
   440 rootEntry = CMsvEntry::NewL( *iSession, KMsvRootIndexEntryIdValue,
       
   441 TMsvSelectionOrdering( KMsvGroupByStandardFolders, EMsvSortByDetails, EFalse ) );
       
   442 
       
   443 CleanupStack::PushL( rootEntry );
       
   444 ListSubFoldersL( *rootEntry );
       
   445 
       
   446 CleanupStack::PopAndDestroy( rootEntry );
       
   447 }
       
   448 
       
   449 
       
   450 // ------------------------------------------------------------------------------------------------
       
   451 // CMessagesSearcher::ListSubFoldersL()
       
   452 // Checks all folders that need to be searched.  Folders to be searched are
       
   453 //	set via SetTargetFolderL.
       
   454 //	Calls AddFolderWithSubFoldersL to add the folder to the array of folders to be
       
   455 //	searched.
       
   456 // ------------------------------------------------------------------------------------------------
       
   457 //
       
   458 void CMessagesSearcher::ListSubFoldersL(  const CMsvEntry& aFolderEntry )
       
   459 {
       
   460 // Only list "folder" children
       
   461 CMsvEntrySelection* children = aFolderEntry.ChildrenL();
       
   462 CleanupStack::PushL( children );
       
   463 
       
   464 TInt sizeChildren = children->Count();
       
   465 
       
   466 
       
   467 for ( TInt i=0; i < children->Count(); i++ )
       
   468 	{
       
   469 	TMsvId& childId = ( *children )[i];
       
   470 	const TMsvEntry& childEntry ( aFolderEntry.ChildDataL( childId ) );
       
   471 
       
   472 	if ( ( childEntry.iType == KUidMsvServiceEntry ) ||
       
   473     	 ( childEntry.iType == KUidMsvFolderEntry ) )
       
   474 		{
       
   475         AddFolderWithSubFoldersL( childId );
       
   476 		}
       
   477 	}
       
   478 
       
   479 CleanupStack::PopAndDestroy( children );  
       
   480 }
       
   481 
       
   482 
       
   483 // ------------------------------------------------------------------------------------------------
       
   484 // CMessagesSearcher::AddFolderWithSubFoldersL(  )
       
   485 // Will add the specified folder to the folder array to be searched.
       
   486 // Subfolders of the specified folder are checked by calling ListSubFoldersL.
       
   487 // ------------------------------------------------------------------------------------------------
       
   488 //
       
   489 void CMessagesSearcher::AddFolderWithSubFoldersL( const TMsvId& aFolderId )
       
   490 {
       
   491 User::LeaveIfError( iToBeSearchedFolders.Append( aFolderId ) );
       
   492 
       
   493 CMsvEntry* folderEntry = CMsvEntry::NewL( *iSession, aFolderId,
       
   494 		TMsvSelectionOrdering( KMsvGroupByStandardFolders, EMsvSortByDetails, EFalse ) );
       
   495 CleanupStack::PushL( folderEntry );
       
   496 
       
   497 ListSubFoldersL( *folderEntry );
       
   498 
       
   499 CleanupStack::PopAndDestroy( folderEntry );	// folderEntry
       
   500 }
       
   501 
       
   502 // ------------------------------------------------------------------------------------------------
       
   503 // Prepares the object for the search. MoveOnToNextMessageL is called
       
   504 // to find the 1st message in the to be searched folders.
       
   505 // Returns:  ETrue: When messages were found.
       
   506 //          EFalse: No messages to search for found.	
       
   507 // ------------------------------------------------------------------------------------------------
       
   508 //
       
   509 TBool CMessagesSearcher::PrepareForSearchL()
       
   510 {
       
   511 iToBeSearchedFoldersIdx = 0;		// start searching on 1st folder item
       
   512 iMessageEntriesIdx = 0;				// start searching on 1st message item
       
   513 
       
   514 TInt foldersCount = iToBeSearchedFolders.Count();
       
   515 
       
   516 if ( !foldersCount )
       
   517 {
       
   518 	return EFalse;
       
   519 }
       
   520 
       
   521 delete iFolderEntry;
       
   522 iFolderEntry = NULL;
       
   523 
       
   524 TMsvId& folderId = iToBeSearchedFolders[iToBeSearchedFoldersIdx];
       
   525 TMsvSelectionOrdering order;
       
   526 iFolderEntry = CMsvEntry::NewL( *iSession, folderId, order );
       
   527 if(iMessageEntries)
       
   528     {
       
   529     delete iMessageEntries;
       
   530     iMessageEntries = NULL;
       
   531     iMessageEntries = iFolderEntry->ChildrenWithTypeL( KUidMsvMessageEntry );	
       
   532     }
       
   533     else
       
   534     {
       
   535         iMessageEntries = iFolderEntry->ChildrenWithTypeL( KUidMsvMessageEntry );	
       
   536     }
       
   537 
       
   538 // no messages in this folder, go and find folder with messages
       
   539 if ( !iMessageEntries->Count() )
       
   540 {
       
   541 	return MoveOnToNextMessageL();	// returns ETrue when messages are found,
       
   542 								//  EFalse otherwise
       
   543 }
       
   544 
       
   545 return ETrue;	// Messages were found, ready to start searching
       
   546 }
       
   547 
       
   548 // ------------------------------------------------------------------------------------------------
       
   549 // CMessagesSearcher::DoActualSearchL()
       
   550 // Does the search of one message.  Called from RunL.  In one RunL call
       
   551 // a limited number of messages are searched.
       
   552 // Uses MoveOnToNextMessageL to get the next message to be searched.
       
   553 // Returns:  ETrue: More seaching needed.
       
   554 //          EFalse: No more items to search.
       
   555 // ------------------------------------------------------------------------------------------------
       
   556 //
       
   557 TBool CMessagesSearcher::DoActualSearchL()
       
   558 {
       
   559 	TInt messagesInOneGoCounter( 0 );
       
   560 
       
   561 	TBool messages ( ETrue );
       
   562 
       
   563 	TTime startTime;
       
   564 	startTime.HomeTime();
       
   565 	TTime now;
       
   566 
       
   567 
       
   568 	while( messages && ( messagesInOneGoCounter < KSearchThisManyMessagesInOneGo )  
       
   569 														&& (iSearchNotCancelled) )
       
   570 	{
       
   571 		iHitFound = EFalse;
       
   572 		
       
   573 		TMsvId& messageId = iMessageEntries->At( iMessageEntriesIdx );
       
   574 		
       
   575 		if (iMessageEntry)
       
   576 		{
       
   577 			delete iMessageEntry;
       
   578 			iMessageEntry = NULL;
       
   579 		}
       
   580 		
       
   581 		iMessageEntry = iSession->GetEntryL( messageId );
       
   582 
       
   583 		const TMsvEntry& messageEntry = iMessageEntry->Entry();
       
   584 		const TUid id (messageEntry.iMtm);
       
   585 
       
   586 		// Load message
       
   587 		if ( messageEntry.iMtm == KUidMsgTypeSMS ) 
       
   588 		{
       
   589 			TRAP_IGNORE( SearchSmsL( messageId ));
       
   590 		}
       
   591 
       
   592         else if ( ( messageEntry.iMtm == KUidMsgTypeMultimedia ||
       
   593 	                messageEntry.iMtm == KUidMsvTechnologyGroupMMS ||
       
   594 	                messageEntry.iMtm == KUidMsgMMSNotification ||
       
   595 	                messageEntry.iMtm == KUidMsgTypeBt ||
       
   596 	                messageEntry.iMtm == KSenduiMtmIrUid ||
       
   597 	                messageEntry.iMtm == KSenduiMtmPushMtmUid ||
       
   598 	                messageEntry.iMtm == KSenduiMtmUniMessageUid ) )
       
   599 	              
       
   600         {          	
       
   601          SearchInMmsMessageL(messageId);
       
   602         	
       
   603         }
       
   604         
       
   605 	    else if ( messageEntry.iMtm != KUidMsgTypeBt
       
   606 	               && messageEntry.iMtm != KSenduiMtmBioUid
       
   607 	               && messageEntry.iMtm != KSenduiMtmIrUid
       
   608 	               && messageEntry.iMtm != KSenduiMtmFaxUid
       
   609 	               && messageEntry.iMtm !=  KSenduiMtmAudioMessageUid
       
   610 	               && messageEntry.iMtm !=  KSenduiMtmPostcardUid
       
   611 	               && messageEntry.iMtm !=  KDrmLinkSender  )
       
   612 	           
       
   613         {
       
   614 				
       
   615 			TRAP_IGNORE( SearchGenericEmailL( messageId, messageEntry.iMtm ) );
       
   616         
       
   617         }// if
       
   618         
       
   619 
       
   620 		messagesInOneGoCounter++;
       
   621 		iStatusItemCounter++;
       
   622 		messages = MoveOnToNextMessageL();		// move to next message
       
   623 	
       
   624 		now.HomeTime();
       
   625 	    if ( now.MicroSecondsFrom( startTime ) > KSearchTimeFrame )
       
   626 		{
       
   627 				break;
       
   628 		}
       
   629 	}
       
   630 
       
   631 	if ( !messages )
       
   632 		{
       
   633 
       
   634 		ReportFinishedL( iStatusItemCounter, iTotalNumOfItems );
       
   635 		}
       
   636 
       
   637 	return messages;
       
   638 
       
   639 }
       
   640 // ------------------------------------------------------------------------------------------------
       
   641 // CMessagesSearcher::MoveOnToNextMessageL()
       
   642 // Moves through all messages under those folders to be searched and returns
       
   643 // with ETrue when a message is found.
       
   644 // Returns:  ETrue: When messages were found.
       
   645 //          EFalse: No messages to search for found.
       
   646 // 	On return (with ETrue) iMessageEntries is pointing to the folder where
       
   647 //	 the next message is to be searched.
       
   648 
       
   649 //	On return (with ETrue) iMessageEntriesIdx is having the index of
       
   650 //	 the message (index of iMessageEntries) next to be searched.
       
   651 //
       
   652 // ------------------------------------------------------------------------------------------------
       
   653 //
       
   654 TBool CMessagesSearcher::MoveOnToNextMessageL()
       
   655 {
       
   656 iMessageEntriesIdx++;
       
   657 
       
   658 if ( iMessageEntriesIdx > iMessageEntries->Count()-1 )	// go to next folder
       
   659 	{
       
   660 	iMessageEntriesIdx = 0;
       
   661 	iToBeSearchedFoldersIdx++;
       
   662 
       
   663 	if ( iToBeSearchedFoldersIdx < iToBeSearchedFolders.Count() )
       
   664 		{
       
   665 		delete iFolderEntry;
       
   666 		iFolderEntry = NULL;
       
   667 
       
   668 		TMsvId& folderId = iToBeSearchedFolders[iToBeSearchedFoldersIdx];
       
   669 
       
   670 		TMsvSelectionOrdering order( KMsvNoGrouping, EMsvSortByNone, EFalse );
       
   671 
       
   672     	iFolderEntry = CMsvEntry::NewL( *iSession, folderId, order );
       
   673 
       
   674 		CMsvEntrySelection* msgEntry = iFolderEntry->ChildrenL();
       
   675 		CleanupStack::PushL( msgEntry );
       
   676 
       
   677 		TInt msgEntryCounts = msgEntry->Count();
       
   678 		const TMsvEntry& msgNoEntry ( iFolderEntry->Entry()); //ChildDataL( folderId ) );
       
   679 		
       
   680 		_LIT16(KDocuments,"Documents");
       
   681 		TPtrC ptrDocuments(KDocuments); 
       
   682 
       
   683 		if(msgNoEntry.iDetails != ptrDocuments)
       
   684 			iMsgEntriesInFoldersArray.Append(msgEntryCounts);
       
   685 
       
   686 		if (ETrue) //msgEntryCounts)
       
   687 		    {		             
       
   688     		delete iMessageEntries;
       
   689     		iMessageEntries = NULL;
       
   690 
       
   691     		iMessageEntries = iFolderEntry->ChildrenWithTypeL( KUidMsvMessageEntry );
       
   692     		}
       
   693     	else
       
   694     		{
       
   695     		iMessageEntries->Reset();
       
   696     		return EFalse;
       
   697     		}
       
   698     		
       
   699 		CleanupStack::PopAndDestroy( 1 );
       
   700 							
       
   701 		// no messages in this folder, go and find folder with messages
       
   702 		if ( !iMessageEntries->Count() )
       
   703 			{
       
   704 			return MoveOnToNextMessageL();
       
   705 			}
       
   706 		
       
   707 		}
       
   708 	else
       
   709 		{
       
   710 		return EFalse;	// nothing to be searched anymore
       
   711 		}
       
   712 	}
       
   713 return ETrue;	// iMessageEntriesIdx is pointing to a valid message
       
   714 }
       
   715 
       
   716 
       
   717 // ------------------------------------------------------------------------------------------------
       
   718 // Searches SMS message.
       
   719 // ------------------------------------------------------------------------------------------------
       
   720 //
       
   721 void CMessagesSearcher::SearchSmsL( TMsvId& aMessageId ) // id of the message to search
       
   722 {
       
   723    
       
   724 	iHitFound = EFalse;
       
   725 	
       
   726 	iSmsMtm->SwitchCurrentEntryL( aMessageId );
       
   727 	
       
   728 	TRAPD(err, iSmsMtm->LoadMessageL());
       
   729 	if(err) User::Leave( err );
       
   730 	
       
   731 	//search sender/receiver first
       
   732 	iFieldCurrentlyUnderSearch = ESearchingSender;
       
   733 
       
   734 	iHitFound = EFalse; 
       
   735 	  
       
   736 
       
   737 	delete iCurrentTextBeingSearched;
       
   738 	iCurrentTextBeingSearched = NULL;
       
   739 	iCurrentTextBeingSearched = HBufC::NewL(iSmsMtm->Entry().Entry().iDetails.Length());
       
   740 	TPtr curTextPtr(iCurrentTextBeingSearched->Des());
       
   741     curTextPtr.Append(iSmsMtm->Entry().Entry().iDetails);
       
   742 
       
   743 	iTextSearcher->SearchL( *iCurrentTextBeingSearched );
       
   744 	if(iSenderReciever)	
       
   745 	{
       
   746 		delete iSenderReciever;
       
   747 		iSenderReciever = NULL;
       
   748 	}
       
   749 	iSenderReciever = HBufC::NewL(iCurrentTextBeingSearched->Des().Length());
       
   750 	iSenderReciever = iCurrentTextBeingSearched->Des().AllocL();
       
   751 	// if still no results, then look up for other receivers, if any
       
   752 	if (!iHitFound)
       
   753 	{
       
   754 	    
       
   755 		delete iCurrentTextBeingSearched;
       
   756 	    iCurrentTextBeingSearched = NULL;
       
   757 	    const MDesCArray& addressee = iSmsMtm->AddresseeList().RecipientList();
       
   758         if (addressee.MdcaCount() == 0)
       
   759 		{
       
   760 			const CSmsHeader& header = iSmsMtm->SmsHeader();
       
   761 			const TPtrC fromAddress = header.FromAddress();
       
   762 
       
   763 			if ( fromAddress.Length() > 0 ) 
       
   764 			{
       
   765 			     
       
   766 		        iCurrentTextBeingSearched = HBufC::NewL(fromAddress.Length());
       
   767 	            TPtr curTextPtr(iCurrentTextBeingSearched->Des());
       
   768                 curTextPtr.Append(fromAddress);
       
   769 			    iTextSearcher->SearchL( *iCurrentTextBeingSearched );
       
   770 			}			       
       
   771 		}
       
   772 		else
       
   773 		{   
       
   774 			for (TInt i = 0; i < addressee.MdcaCount(); i++)
       
   775 		    {
       
   776 			    
       
   777 			    iCurrentTextBeingSearched = addressee.MdcaPoint( i ).AllocL();
       
   778 			    
       
   779 			    iTextSearcher->SearchL( *iCurrentTextBeingSearched );
       
   780 			    if(iHitFound)
       
   781 			       {
       
   782 			       break;	
       
   783 			       }
       
   784 			       
       
   785 		    } //for
       
   786 		    
       
   787 		}// else		   	
       
   788 		
       
   789 	} // if
       
   790 	
       
   791 	// for searching the body of the message
       
   792 	if (!iHitFound)
       
   793 	{
       
   794 	    iFieldCurrentlyUnderSearch = ESearchingBody;
       
   795 		delete iCurrentTextBeingSearched;
       
   796 		iCurrentTextBeingSearched = NULL;
       
   797 		iCurrentTextBeingSearched = HBufC::NewL(iSmsMtm->Body().DocumentLength() + 1 );
       
   798 	    TPtr msgText = iCurrentTextBeingSearched->Des();
       
   799 	    iSmsMtm->Body().Extract( msgText, 0 );
       
   800 	    iTextSearcher->SearchL( msgText );
       
   801 	    
       
   802 	}
       
   803 
       
   804    
       
   805 }
       
   806 
       
   807 void CMessagesSearcher::SearchInMmsMessageL(const TMsvId& aMessageId)
       
   808     {
       
   809       _LIT8(KTextMimeType,"text/plain");
       
   810       iHitFound = EFalse;
       
   811       iMmsMtm->SwitchCurrentEntryL( aMessageId );
       
   812       TRAPD(err,iMmsMtm->LoadMessageL());
       
   813 	
       
   814       CMsvEntry* messageEntry = iSession->GetEntryL(aMessageId);
       
   815       CleanupStack::PushL(messageEntry );
       
   816       CMsvAttachment* attachment = NULL;
       
   817       
       
   818       
       
   819       if( !iHitFound )
       
   820         {
       
   821             iFieldCurrentlyUnderSearch = ESearchingMMSSender;
       
   822             if(iCurrentTextBeingSearched)
       
   823             {
       
   824             delete iCurrentTextBeingSearched;
       
   825             iCurrentTextBeingSearched = NULL;
       
   826             }
       
   827             iCurrentTextBeingSearched  =  messageEntry->Entry().iDetails.AllocL(); 
       
   828             if(iSenderReciever)	
       
   829             {
       
   830             delete iSenderReciever;
       
   831             iSenderReciever = NULL;
       
   832             }
       
   833             iSenderReciever = iCurrentTextBeingSearched->Des().AllocL();	  
       
   834             iTextSearcher->SearchL( *iCurrentTextBeingSearched );
       
   835         }
       
   836       
       
   837       if (!iHitFound)
       
   838         {
       
   839             iFieldCurrentlyUnderSearch = ESearchingMMSBody;
       
   840             if(iCurrentTextBeingSearched)
       
   841             {
       
   842             delete iCurrentTextBeingSearched;
       
   843             iCurrentTextBeingSearched = NULL;
       
   844             }
       
   845             if(iSenderReciever)	
       
   846             {
       
   847             delete iSenderReciever;
       
   848             iSenderReciever = NULL;
       
   849             }
       
   850             iSenderReciever = messageEntry->Entry().iDetails.AllocL(); 
       
   851             iCurrentTextBeingSearched = messageEntry->Entry().iDescription.AllocL();
       
   852             	  
       
   853             iTextSearcher->SearchL( *iCurrentTextBeingSearched );
       
   854         } 
       
   855       
       
   856       if(!iHitFound ) 
       
   857     	  {
       
   858           CMsvEntrySelection* messageChildren = messageEntry->ChildrenL(); //Child ->Message
       
   859           CleanupStack::PushL(messageChildren);
       
   860           TBool ifBTorIR = EFalse;
       
   861           if (messageChildren->Count() == 1) // This is case of BT & IR messages with attachments
       
   862         	  {
       
   863               TMsvId childAtt = (*messageChildren)[0];
       
   864               messageEntry->SetEntryL(childAtt); // switch context to CHILD entry
       
   865               ifBTorIR = ETrue;  
       
   866         	  }
       
   867             
       
   868           if (messageEntry->HasStoreL() )
       
   869         	  {
       
   870               CMsvStore* store = messageEntry->ReadStoreL();
       
   871                 CleanupStack::PushL(store);
       
   872                 
       
   873                 MMsvAttachmentManager& attMngr = store->AttachmentManagerL();
       
   874                 TInt attcount = attMngr.AttachmentCount();
       
   875                 for(TInt i = 0 ; i < attcount ; i++ )
       
   876                     {
       
   877                         attachment = attMngr.GetAttachmentInfoL( i );
       
   878                         CleanupStack::PushL( attachment );
       
   879                         
       
   880                         //break it
       
   881                         if(iCurrentTextBeingSearched)
       
   882                         {
       
   883                         delete iCurrentTextBeingSearched;
       
   884                         iCurrentTextBeingSearched = NULL;
       
   885                         }
       
   886                         if(iSenderReciever)	
       
   887                         {
       
   888                         delete iSenderReciever;
       
   889                         iSenderReciever = NULL;
       
   890                         }
       
   891                         
       
   892                         HBufC* buf16 = NULL;
       
   893                         if( KErrNotFound != attachment->MimeType().Find(KTextMimeType))
       
   894                         {
       
   895                         
       
   896 						HBufC8* buf8 = NULL;
       
   897 						RFile fsFile = attMngr.GetAttachmentFileL( i );
       
   898 						TInt fileSize = 0;
       
   899 						fsFile.Size( fileSize );
       
   900 						
       
   901 						if ( fileSize ) 
       
   902 							{
       
   903 							buf8 =  HBufC8::NewL( fileSize );
       
   904 							buf16 =  HBufC::NewL( fileSize );
       
   905 							TPtr8 bufPtr8 = buf8->Des();
       
   906 							TPtr bufPtr16 = buf16->Des();
       
   907 							fsFile.Read( 0, bufPtr8, fileSize );
       
   908 							//TInt err = fs.ReadFileSection( filepath, 0, buf8, 10);
       
   909 							CnvUtfConverter::ConvertToUnicodeFromUtf8( bufPtr16, bufPtr8 );	
       
   910 							}
       
   911 						if ( buf8 ) 
       
   912 							{
       
   913 							delete buf8;	
       
   914 							}
       
   915 						
       
   916 						fsFile.Close();
       
   917 						
       
   918 						}
       
   919                         
       
   920                         iSenderReciever = messageEntry->Entry().iDetails.AllocL();	 
       
   921                         HBufC* fileName = attachment->AttachmentName().AllocL();
       
   922                         iCurrentTextBeingSearched = messageEntry->Entry().iDescription.AllocL();	
       
   923                         
       
   924                         TInt sizeOfAttachement = 0;
       
   925                         if ( ifBTorIR ) 
       
   926                         	{
       
   927                         	if ( iSenderReciever ) 
       
   928 	                        	{
       
   929 	                        	sizeOfAttachement += iSenderReciever->Size();
       
   930 	  							}
       
   931 	                        if ( fileName ) 
       
   932 	                        	{
       
   933 	                        	sizeOfAttachement += fileName->Size();
       
   934 	                        	}
       
   935 	                        sizeOfAttachement += 3;
       
   936                         	}
       
   937                         
       
   938                         if ( buf16 ) 
       
   939                         	{
       
   940                         	sizeOfAttachement += buf16->Size();
       
   941                         	}
       
   942 
       
   943                         if ( sizeOfAttachement ) 
       
   944                         	{
       
   945                         	iCurrentTextBeingSearched = HBufC::NewL( sizeOfAttachement );
       
   946                         	TPtr curPtr = iCurrentTextBeingSearched->Des();
       
   947                         	if ( ifBTorIR ) 
       
   948                         		{
       
   949                         		if ( iSenderReciever ) 
       
   950 	                        		{
       
   951 	                        		curPtr.Append( *iSenderReciever );
       
   952 	                        		curPtr.Append( ' ' );
       
   953 	                        		}
       
   954 	                        	if ( fileName ) 
       
   955 	                        		{
       
   956 	                        		curPtr.Append( *fileName );
       
   957 	                        		curPtr.Append( ' ' );
       
   958 	                        		}
       
   959                         		}	
       
   960                         	
       
   961                         	if ( buf16 ) 
       
   962                         		{
       
   963                         		curPtr.Append( *buf16 );
       
   964                         		}
       
   965                         	}
       
   966                         
       
   967                         
       
   968                         iFieldCurrentlyUnderSearch = ESearchingMMSBody; 
       
   969                         
       
   970                         if (!iHitFound)
       
   971                         {
       
   972                         iTextSearcher->SearchL( *iCurrentTextBeingSearched );
       
   973                         }
       
   974                      CleanupStack::PopAndDestroy(attachment);     
       
   975                     }//for
       
   976               CleanupStack::PopAndDestroy(store); // store 	
       
   977             }//if
       
   978             CleanupStack::PopAndDestroy(messageChildren );   
       
   979          }
       
   980       CleanupStack::PopAndDestroy(messageEntry); // btEntry & btChildren
       
   981    }
       
   982 // -------------------------------------------------------------------------------------------------
       
   983 // void CMessagesSearcher::SearchGenericEmailL( ) //message id to search
       
   984 // Searches Generic Email message.
       
   985 // -------------------------------------------------------------------------------------------------
       
   986 //
       
   987 void CMessagesSearcher::SearchGenericEmailL( TMsvId& aMessageId, TUid aMessageUid ) 
       
   988 {
       
   989 
       
   990     delete iMsvStore;
       
   991     iMsvStore = NULL;
       
   992     
       
   993 	iHitFound = EFalse;
       
   994     
       
   995     iGenericMtm = SearchFromMtmArrayL( aMessageUid );
       
   996 
       
   997 	iGenericMtm->SwitchCurrentEntryL( aMessageId );
       
   998 	
       
   999 	TRAPD(err, iGenericMtm->LoadMessageL());
       
  1000 	if(err) User::Leave( err );
       
  1001 	
       
  1002 	
       
  1003 	TRAPD ( readStoreError, iMsvStore = iGenericMtm->Entry().ReadStoreL() );
       
  1004         
       
  1005     // if error occured during the store reading, message was unfetched and cannot
       
  1006     // therefore be handled in the usual manner. Instead a different kind of approach is needed.
       
  1007     if ( readStoreError != KErrNone ) 
       
  1008        {
       
  1009        // Stop searching the rest of the message. Since the msvStore is null, it will only 
       
  1010        // result in Leaves.
       
  1011        return;    
       
  1012        }
       
  1013        
       
  1014        
       
  1015 	if (iGenericMtm->Body().LdDocumentLength() > 0  )
       
  1016 	{
       
  1017 	    
       
  1018         delete iCurrentTextBeingSearched;
       
  1019         iCurrentTextBeingSearched = NULL;
       
  1020         iCurrentTextBeingSearched = HBufC::NewL( iGenericMtm->Body().LdDocumentLength() + 1 );
       
  1021 	    
       
  1022 	    iFieldCurrentlyUnderSearch = ESearchingGenericEmailBody;
       
  1023 
       
  1024 	    TInt i( 0 );
       
  1025 
       
  1026 	    while ( ETrue )
       
  1027         {
       
  1028 	    	TPtrC msgText = iGenericMtm->Body().Read( Max ( i - 1, 0 ) );
       
  1029 	        iCurrentTextBeingSearched->Des().Append(msgText);
       
  1030 	        i = i + KEmailSegmentLength;
       
  1031 	        if ( i > iGenericMtm->Body().LdDocumentLength() )
       
  1032 	            {
       
  1033 	            break;
       
  1034 	            }
       
  1035 	    }
       
  1036 
       
  1037 	    if (!iHitFound ) 
       
  1038 	        {
       
  1039 	        iTextSearcher->SearchL( *iCurrentTextBeingSearched );	
       
  1040 	        }
       
  1041 	    
       
  1042 	}
       
  1043 
       
  1044 	iFieldCurrentlyUnderSearch = ESearchingGenericEmailSubject;
       
  1045 	if (!iHitFound )
       
  1046 	    {     
       
  1047 	    delete iCurrentTextBeingSearched;
       
  1048 	    iCurrentTextBeingSearched = NULL;
       
  1049 	    iCurrentTextBeingSearched = HBufC::NewL(iGenericMtm->Entry().Entry().iDescription.Length());
       
  1050 	    TPtr curTextPtr(iCurrentTextBeingSearched->Des());
       
  1051         curTextPtr.Append(iGenericMtm->Entry().Entry().iDescription);
       
  1052 		
       
  1053 	
       
  1054 	    iTextSearcher->SearchL( *iCurrentTextBeingSearched );
       
  1055 	}
       
  1056 	iFieldCurrentlyUnderSearch = ESearchingGenericEmailSender;
       
  1057 
       
  1058 	if (!iHitFound) 
       
  1059 	    { 
       
  1060 	    delete iCurrentTextBeingSearched;
       
  1061 	    iCurrentTextBeingSearched = NULL;
       
  1062 	     
       
  1063 	    iCurrentTextBeingSearched = HBufC::NewL(iGenericMtm->Entry().Entry().iDetails.Length());
       
  1064 	    TPtr curTextPtr(iCurrentTextBeingSearched->Des());
       
  1065         curTextPtr.Append(iGenericMtm->Entry().Entry().iDetails);
       
  1066 		 
       
  1067 	
       
  1068 		iTextSearcher->SearchL( *iCurrentTextBeingSearched );
       
  1069 	}
       
  1070 		
       
  1071 
       
  1072 	if (!iHitFound)
       
  1073 	{
       
  1074 	    iFieldCurrentlyUnderSearch = ESearchingGenericEmailSender;
       
  1075 		const CMsvRecipientList& list = iGenericMtm->AddresseeList();
       
  1076         iHitFound = EFalse;
       
  1077 		for (TInt i = 0; i < list.Count(); i++)
       
  1078 			{
       
  1079 				if (!iHitFound) 
       
  1080 				{
       
  1081 				    delete iCurrentTextBeingSearched;
       
  1082 	                iCurrentTextBeingSearched = NULL; 
       
  1083 	             
       
  1084 	                iCurrentTextBeingSearched = HBufC::NewL(list.operator[](i).Length());
       
  1085 	                TPtr curTextPtr(iCurrentTextBeingSearched->Des());
       
  1086                     curTextPtr.Append(list.operator[](i));
       
  1087 				   
       
  1088 				    
       
  1089 					iTextSearcher->SearchL(*iCurrentTextBeingSearched);	
       
  1090 					if(iHitFound)
       
  1091 					 break;
       
  1092 				}
       
  1093 			  
       
  1094 		    }
       
  1095 	}
       
  1096 				
       
  1097 }
       
  1098 
       
  1099 // -------------------------------------------------------------------------------------------------
       
  1100 // Searches for Mtm -class from the array that can be used to open the message specified by aUid.
       
  1101 // If proper class is not found, it's created .
       
  1102 // -------------------------------------------------------------------------------------------------
       
  1103 //
       
  1104 CBaseMtm* CMessagesSearcher::SearchFromMtmArrayL( TUid aUid ) 
       
  1105 {
       
  1106     
       
  1107 	for (TInt i = 0; i < iMtmArray.Count(); i++)
       
  1108 	    {
       
  1109 	    if (iMtmArray[i]->Type() == aUid)
       
  1110 	        {
       
  1111 	        CBaseMtm* baseMtm = iMtmArray[i];
       
  1112 	        return baseMtm;
       
  1113 	        }
       
  1114 	    }
       
  1115 	    
       
  1116     CBaseMtm* newMtm;
       
  1117 	newMtm = iMtmReg->NewMtmL( aUid );
       
  1118 	iMtmArray.AppendL( newMtm );
       
  1119 	return newMtm;
       
  1120 
       
  1121 }
       
  1122 
       
  1123 
       
  1124 
       
  1125 // Implementation from the CActive Class
       
  1126 // ------------------------------------------------------------------------------------------------
       
  1127 // CMessagesSearcher::RunL()
       
  1128 // ------------------------------------------------------------------------------------------------
       
  1129 //
       
  1130 void CMessagesSearcher::RunL()
       
  1131 {
       
  1132 if ( DoActualSearchL() )	// If more searching is needed, the active object is set active
       
  1133 	                        // again
       
  1134 	{
       
  1135 		TRequestStatus* status = &iStatus;
       
  1136 		User::RequestComplete( status, KErrNone );
       
  1137 		SetActive();
       
  1138 	}
       
  1139 }
       
  1140 
       
  1141 
       
  1142 // ------------------------------------------------------------------------------------------------
       
  1143 // Called if error during execution of the RunL() 
       
  1144 // ------------------------------------------------------------------------------------------------
       
  1145 //
       
  1146 TInt CMessagesSearcher::RunError( TInt aError )
       
  1147 	{
       
  1148 	return aError;
       
  1149 	}
       
  1150 
       
  1151 // ------------------------------------------------------------------------------------------------
       
  1152 // CMessagesSearcher::HandleSessionEventL()
       
  1153 // ------------------------------------------------------------------------------------------------
       
  1154 //
       
  1155 void CMessagesSearcher::HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3 )
       
  1156 	{
       
  1157 	if( aEvent== EMsvEntriesDeleted )	
       
  1158     	iEntryDeleted = (static_cast<CMsvEntrySelection*>(aArg1))->CopyL();
       
  1159 	}
       
  1160 
       
  1161 // ------------------------------------------------------------------------------------------------
       
  1162 // CMessagesSearcher::HitL( )
       
  1163 // ------------------------------------------------------------------------------------------------
       
  1164 //
       
  1165 void CMessagesSearcher::HitL( TInt aKeyWordPos )
       
  1166 	{   
       
  1167 	iHitFound = ETrue;
       
  1168    
       
  1169 	if(  aKeyWordPos!= KErrNotFound )
       
  1170 	{		
       
  1171 		 
       
  1172 		iTotalNumOfItems++;
       
  1173 		
       
  1174 		if (iFieldCurrentlyUnderSearch == ESearchingBody ||
       
  1175 		    iFieldCurrentlyUnderSearch == ESearchingSender )
       
  1176 		{
       
  1177 		    ReportHitInSmsL( aKeyWordPos );
       
  1178 		}
       
  1179 		else  
       
  1180 		    if (iFieldCurrentlyUnderSearch == ESearchingMMSBody ||
       
  1181 		    	iFieldCurrentlyUnderSearch == ESearchingMMSSender )
       
  1182 		    {
       
  1183 		        ReportHitInMmsL( aKeyWordPos );	    
       
  1184 		    }
       
  1185 		else 
       
  1186 		    if ( iFieldCurrentlyUnderSearch == ESearchingSMTPBody || 
       
  1187 		         iFieldCurrentlyUnderSearch == ESearchingPOP3Body ||
       
  1188 		         iFieldCurrentlyUnderSearch == ESearchingIMAP4Body || 
       
  1189 		         iFieldCurrentlyUnderSearch == ESearchingSMTPSender || 
       
  1190 		         iFieldCurrentlyUnderSearch == ESearchingSMTPSubject || 
       
  1191 		         iFieldCurrentlyUnderSearch == ESearchingPOP3Sender || 
       
  1192 		         iFieldCurrentlyUnderSearch == ESearchingPOP3Subject || 
       
  1193 		         iFieldCurrentlyUnderSearch == ESearchingIMAP4Sender ||
       
  1194 		         iFieldCurrentlyUnderSearch == ESearchingIMAP4Subject ||
       
  1195 		         iFieldCurrentlyUnderSearch == ESearchingGenericEmailSubject ||
       
  1196 		         iFieldCurrentlyUnderSearch == ESearchingGenericEmailBody ||
       
  1197 		         iFieldCurrentlyUnderSearch == ESearchingGenericEmailSender ||
       
  1198 		         iFieldCurrentlyUnderSearch == ESearchingGenericEmailSubject )
       
  1199 
       
  1200 		      	{
       
  1201 		      	    ReportHitInEmailL( aKeyWordPos );	    
       
  1202 		       	}
       
  1203 	
       
  1204 	}
       
  1205 		       	
       
  1206 }
       
  1207     
       
  1208 // -----------------------------------------------------------------------------
       
  1209 // Returns the launch info corresponding to a particular documentid
       
  1210 // -----------------------------------------------------------------------------
       
  1211 //     
       
  1212 HBufC8* CMessagesSearcher::LaunchInfoL( const CSearchDocumentId& aDocumentID )
       
  1213 {
       
  1214      if(aDocumentID.PluginId() == iPluginId) 
       
  1215          {
       
  1216          
       
  1217          HBufC8 * launchInfo = HBufC8::NewL(256);
       
  1218          TPtr8 docIdPtr = launchInfo->Des();
       
  1219          docIdPtr.AppendNum(aDocumentID.DocumentId());
       
  1220          return launchInfo;
       
  1221          
       
  1222          }
       
  1223      
       
  1224      return NULL;
       
  1225      
       
  1226 }
       
  1227    
       
  1228 // -----------------------------------------------------------------------------
       
  1229 // Tell observer search finished
       
  1230 // -----------------------------------------------------------------------------
       
  1231 //  
       
  1232 void CMessagesSearcher::ReportFinishedL( TInt aSearchResult, TInt aTotalNumOfItems)
       
  1233 	{
       
  1234     iObserver->SearchCompletedL( aSearchResult, aTotalNumOfItems );
       
  1235 
       
  1236 	}
       
  1237 
       
  1238 // ------------------------------------------------------------------------------------------------
       
  1239 // Generates a result from a hit in Sms message.
       
  1240 // ------------------------------------------------------------------------------------------------
       
  1241 //	 
       
  1242 void CMessagesSearcher::ReportHitInSmsL( TInt aKeyWordPos )
       
  1243 {
       
  1244 
       
  1245    	TInt Pos = aKeyWordPos;
       
  1246 	const TMsvEntry& entry = iMessageEntry->Entry();
       
  1247     TBuf8<KEmailMessageItemIdLengthInHex> entryId;
       
  1248 
       
  1249     entryId.AppendNum( entry.Id(), EDecimal );
       
  1250     
       
  1251 	// TMsvId 
       
  1252 	CSearchDocumentId* documentId = CSearchDocumentId::NewL( entry.Id(), iPluginId );
       
  1253 	documentId->SetRepositoryIdL( KSearchCClassMessagesUid.iUid );			
       
  1254 	CSearchLightResult* searchLightResult = CSearchLightResult::NewL( documentId );
       
  1255 	
       
  1256 	searchLightResult->SetContentClassId( KSearchCClassMessagesUid );
       
  1257 	
       
  1258 	if( entry.Parent() == KMsvSentEntryId )
       
  1259 	{
       
  1260 		searchLightResult->SetContentFolderId( KSearchCFolderSentUid );
       
  1261 	}
       
  1262 	
       
  1263 	else if( entry.Parent() == KMsvGlobalOutBoxIndexEntryId )
       
  1264 	{
       
  1265 		searchLightResult->SetContentFolderId( KSearchCFolderOutboxUid );
       
  1266 	}
       
  1267 	
       
  1268 	else if( entry.Parent() == KMsvGlobalInBoxIndexEntryId )
       
  1269 	{
       
  1270 		searchLightResult->SetContentFolderId( KSearchCFolderInboxUid );
       
  1271 	}
       
  1272 
       
  1273 	else if( entry.Parent() == KMsvDraftEntryId )
       
  1274 	{
       
  1275 		searchLightResult->SetContentFolderId( KSearchCFolderDraftsUid );
       
  1276 	}
       
  1277 	
       
  1278     searchLightResult->SetServiceId( KNullUid );	
       
  1279 		
       
  1280 	CMsgDesC* msgdetail = new(ELeave) CMsgDesC();		
       
  1281     CleanupStack::PushL ( msgdetail );
       
  1282 
       
  1283 	msgdetail->SetTitleL(entry.iDetails);
       
  1284 	
       
  1285     if ((iFieldCurrentlyUnderSearch == ESearchingSender)||(iFieldCurrentlyUnderSearch == ESearchingBody)) 
       
  1286 	{	        	                    
       
  1287 	   msgdetail->SetKeywordHitPosL(-1);
       
  1288 	   msgdetail->SetBodyL(iSmsMtm->Entry().Entry().iDescription );
       
  1289     }
       
  1290     
       
  1291 	iMsgDesCArray.Append( msgdetail );	
       
  1292 
       
  1293 
       
  1294     CleanupStack::Pop ( msgdetail );
       
  1295     
       
  1296    	CSearchResult* searchResult = CSearchResult::NewL( searchLightResult);
       
  1297 
       
  1298 	searchResult->SetSnippetL(KNullDesC8);
       
  1299 	searchResult->SetTitleL(iSmsMtm->Entry().Entry().iDetails);
       
  1300 	
       
  1301 	iHeavyResultsArray.Append( searchResult );
       
  1302   
       
  1303 	iObserver->ResultFoundL( searchLightResult, iStatusItemCounter, 
       
  1304 							iTotalNumOfItems );
       
  1305 
       
  1306 }
       
  1307 
       
  1308 // ------------------------------------------------------------------------------------------------
       
  1309 // Generates a result from a hit in Mms message.
       
  1310 // ------------------------------------------------------------------------------------------------
       
  1311 //    
       
  1312 
       
  1313 void CMessagesSearcher::ReportHitInMmsL( TInt aKeyWordPos ) 
       
  1314 {
       
  1315 
       
  1316 	const TMsvEntry& entry = iMessageEntry->Entry();
       
  1317 	
       
  1318     TBuf8<KEmailMessageItemIdLengthInHex> entryId;
       
  1319     entryId.AppendNum( entry.Id(), EDecimal );
       
  1320     		
       
  1321 	CSearchDocumentId* documentId = CSearchDocumentId::NewL( entry.Id(), iPluginId );
       
  1322 		documentId->SetRepositoryIdL( KSearchCClassMessagesUid.iUid );		
       
  1323 	CSearchLightResult* searchLightResult = CSearchLightResult::NewL( documentId );
       
  1324 	
       
  1325 	searchLightResult->SetContentClassId( KSearchCClassMessagesUid );
       
  1326 	
       
  1327 	if( entry.Parent() == KMsvSentEntryId )
       
  1328 	{
       
  1329 		searchLightResult->SetContentFolderId( KSearchCFolderSentUid );
       
  1330 	}
       
  1331 	
       
  1332 	else if( entry.Parent() == KMsvGlobalOutBoxIndexEntryId )
       
  1333 	{
       
  1334 		searchLightResult->SetContentFolderId( KSearchCFolderOutboxUid );
       
  1335 	}
       
  1336 	
       
  1337 	else if( entry.Parent() == KMsvGlobalInBoxIndexEntryId )
       
  1338 	{
       
  1339 		searchLightResult->SetContentFolderId( KSearchCFolderInboxUid );
       
  1340 	}
       
  1341 
       
  1342 	else if( entry.Parent() == KMsvDraftEntryId )
       
  1343 	{
       
  1344 		searchLightResult->SetContentFolderId( KSearchCFolderDraftsUid );
       
  1345 	}
       
  1346 	
       
  1347 
       
  1348     searchLightResult->SetServiceId( KNullUid );	
       
  1349 
       
  1350 	CMsgDesC* msgdetail = new(ELeave) CMsgDesC();		
       
  1351     CleanupStack::PushL ( msgdetail );
       
  1352 
       
  1353 	msgdetail->SetTitleL( *iSenderReciever);  
       
  1354 	
       
  1355   if (iFieldCurrentlyUnderSearch == ESearchingMMSSender) 
       
  1356 	{	      
       
  1357 	     msgdetail->SetKeywordHitPosL(-1);
       
  1358 	     	                    
       
  1359 		msgdetail->SetBodyL(iMmsMtm->Entry().Entry().iDescription );
       
  1360 	}
       
  1361 	else
       
  1362 	{
       
  1363 	     msgdetail->SetKeywordHitPosL(aKeyWordPos);
       
  1364 	     msgdetail->SetBodyL( *iCurrentTextBeingSearched );
       
  1365 	}
       
  1366     
       
  1367 	iMsgDesCArray.Append( msgdetail );
       
  1368 	CleanupStack::Pop ( msgdetail );
       
  1369   
       
  1370    	CSearchResult* searchResult = CSearchResult::NewL( searchLightResult);
       
  1371 
       
  1372 	searchResult->SetSnippetL(KNullDesC8);
       
  1373 	searchResult->SetTitleL(iMmsMtm->Entry().Entry().iDetails);
       
  1374 	
       
  1375 	iHeavyResultsArray.Append( searchResult );
       
  1376  
       
  1377 	iObserver->ResultFoundL( searchLightResult, iStatusItemCounter, 
       
  1378 							iTotalNumOfItems );
       
  1379 }
       
  1380 
       
  1381 // ------------------------------------------------------------------------------------------------
       
  1382 // CMessagesSearcher::ReportHitInEmailL()
       
  1383 // Generates a result from a hit in Email message.
       
  1384 // ------------------------------------------------------------------------------------------------
       
  1385 //
       
  1386 void CMessagesSearcher::ReportHitInEmailL( TInt aKeyWordPos ) 
       
  1387 {        
       
  1388 	const TMsvEntry& entry = iMessageEntry->Entry();
       
  1389 	
       
  1390     TBuf8<KEmailMessageItemIdLengthInHex> entryId;
       
  1391     entryId.AppendNum( entry.Id(), EDecimal );
       
  1392     		
       
  1393 	CSearchDocumentId* documentId = CSearchDocumentId::NewL( entry.Id(), iPluginId );
       
  1394 	documentId->SetRepositoryIdL( KSearchCClassMessagesUid.iUid );		
       
  1395 	CSearchLightResult* searchLightResult = CSearchLightResult::NewL( documentId );
       
  1396 	
       
  1397 	searchLightResult->SetContentClassId( KSearchCClassMessagesUid );
       
  1398 	
       
  1399 	if( entry.Parent() == KMsvSentEntryId )
       
  1400 	{
       
  1401 		searchLightResult->SetContentFolderId( KSearchCFolderSentUid );
       
  1402 	}
       
  1403 	
       
  1404 	else if( entry.Parent() == KMsvGlobalOutBoxIndexEntryId )
       
  1405 	{
       
  1406 		searchLightResult->SetContentFolderId( KSearchCFolderOutboxUid );
       
  1407 	}
       
  1408 	
       
  1409 	else if( entry.Parent() == KMsvGlobalInBoxIndexEntryId )
       
  1410 	{
       
  1411 		searchLightResult->SetContentFolderId( KSearchCFolderInboxUid );
       
  1412 	}
       
  1413 	
       
  1414 	else if( entry.Parent() == KMsvDraftEntryId )
       
  1415 	{
       
  1416 		searchLightResult->SetContentFolderId( KSearchCFolderDraftsUid );
       
  1417 	}
       
  1418 	else
       
  1419 	{
       
  1420 	searchLightResult->SetContentFolderId( KSearchCFolderInboxUid );
       
  1421 	}
       
  1422 	
       
  1423     searchLightResult->SetServiceId( KNullUid );	
       
  1424 	
       
  1425 	CMsgDesC* msgdetail = new(ELeave) CMsgDesC();		
       
  1426     CleanupStack::PushL ( msgdetail );
       
  1427 
       
  1428 	msgdetail->SetTitleL( entry.iDetails);
       
  1429     if (iFieldCurrentlyUnderSearch == ESearchingGenericEmailSender)
       
  1430 	{	        
       
  1431 	    msgdetail->SetKeywordHitPosL(-1);	          
       
  1432 	    msgdetail->SetBodyL(entry.iDescription );          
       
  1433 		
       
  1434 	}
       
  1435 	else 
       
  1436 	{       msgdetail->SetKeywordHitPosL(aKeyWordPos);
       
  1437 		    msgdetail->SetBodyL( *iCurrentTextBeingSearched );
       
  1438 	}
       
  1439 	    
       
  1440 	iMsgDesCArray.Append( msgdetail );		
       
  1441 	
       
  1442     CleanupStack::Pop ( msgdetail );
       
  1443   
       
  1444    	CSearchResult* searchResult = CSearchResult::NewL( searchLightResult);
       
  1445 
       
  1446 	searchResult->SetSnippetL(KNullDesC8);
       
  1447 	searchResult->SetTitleL(KNullDesC);
       
  1448 	iHeavyResultsArray.Append( searchResult );
       
  1449  
       
  1450 	iObserver->ResultFoundL( searchLightResult, iStatusItemCounter, 
       
  1451 							iTotalNumOfItems );
       
  1452 									
       
  1453 }
       
  1454 	
       
  1455 	
       
  1456 void CMessagesSearcher::LaunchApplicationL(const TDesC8& aLaunchInfo)
       
  1457 	{
       
  1458 	TPtrC8 ptr = aLaunchInfo;
       
  1459 	
       
  1460 	TLex8 lex(ptr);
       
  1461 	
       
  1462 	TUid aMsgId;
       
  1463 	lex.Val(aMsgId.iUid);
       
  1464 	
       
  1465 	CMsvSession* session = CMsvSession::OpenSyncL( *this );
       
  1466 	CleanupStack::PushL( session );
       
  1467 	    	   
       
  1468 	CClientMtmRegistry* mtmReg = CClientMtmRegistry::NewL( *session );      
       
  1469 	CleanupStack::PushL( mtmReg );
       
  1470 	
       
  1471 	TMsvId id (aMsgId.iUid);
       
  1472 	
       
  1473 	CMsvEntry* MsvEnt;
       
  1474 	MsvEnt= session->GetEntryL(id);
       
  1475 	CleanupStack::PushL( MsvEnt );
       
  1476 	const TMsvEntry& entry = MsvEnt->Entry();
       
  1477 	
       
  1478 	CBaseMtm* clientMtm = mtmReg->NewMtmL( entry.iMtm);
       
  1479 	CleanupStack::PushL( clientMtm );    
       
  1480 	clientMtm->SwitchCurrentEntryL( MsvEnt->EntryId() );
       
  1481 
       
  1482     if ( MsvEnt->HasStoreL() )
       
  1483         {                                  
       
  1484         TEditorParameters temp;    
       
  1485 
       
  1486         if ( clientMtm->HasContext() )
       
  1487             {
       
  1488             temp.iId = clientMtm->Entry().EntryId();
       
  1489             }
       
  1490 
       
  1491         TPckgC<TEditorParameters> paramPack( temp );    
       
  1492       
       
  1493         if( clientMtm->Entry().Entry().Parent() == KMsvDraftEntryId )
       
  1494             {
       
  1495             temp.iFlags &= ~EMsgReadOnly;
       
  1496             }
       
  1497         else
       
  1498             {
       
  1499             temp.iFlags|=EMsgReadOnly ;
       
  1500             }
       
  1501         
       
  1502         TUid uid = KNullUid;
       
  1503        	uid = DiscoverL( temp, clientMtm->Type() );
       
  1504         if( uid == KNullUid )
       
  1505         	{
       
  1506         	User::Leave( KErrNotSupported );
       
  1507         	}
       
  1508 
       
  1509         TApaAppInfo appInfo;
       
  1510         RApaLsSession lsSession;
       
  1511         User::LeaveIfError( lsSession.Connect() );
       
  1512         CleanupClosePushL( lsSession );
       
  1513         User::LeaveIfError( lsSession.GetAppInfo( appInfo, uid ) );
       
  1514 
       
  1515         CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
       
  1516         cmdLine->SetExecutableNameL( appInfo.iFullName );
       
  1517         cmdLine->SetCommandL( EApaCommandViewActivate );
       
  1518         // EApaCommandRun );
       
  1519 
       
  1520         cmdLine->SetTailEndL( paramPack );
       
  1521 
       
  1522         User::LeaveIfError( lsSession.StartApp( *cmdLine ) );
       
  1523 
       
  1524         CleanupStack::PopAndDestroy( cmdLine );
       
  1525         CleanupStack::PopAndDestroy( &lsSession );
       
  1526      
       
  1527         }
       
  1528 
       
  1529     CleanupStack::PopAndDestroy( clientMtm );
       
  1530     CleanupStack::PopAndDestroy( MsvEnt );
       
  1531     CleanupStack::PopAndDestroy( mtmReg );    
       
  1532     CleanupStack::PopAndDestroy( session );
       
  1533 	}
       
  1534 
       
  1535 // -------------------------------------------------------------------------------------------------
       
  1536 // CIdsMessagesUiImpLauncher::DiscoverL
       
  1537 // -------------------------------------------------------------------------------------------------
       
  1538 //
       
  1539 TUid CMessagesSearcher::DiscoverL( const TEditorParameters aParams, TUid aMtmType )
       
  1540 	{
       
  1541 	// Let's first check if a special editor/viewer is set
       
  1542     if( aParams.iSpecialAppId != KNullUid )
       
  1543 		{ // If set, simply return that appUid
       
  1544 		return aParams.iSpecialAppId;
       
  1545 		}
       
  1546 	
       
  1547 	CApaAppServiceInfoArray* services = NULL;	
       
  1548 	RApaLsSession ls;
       
  1549 	TUid appUid = KNullUid; // Set the uid as NULL
       
  1550 	
       
  1551 	if( ls.Connect() == KErrNone )
       
  1552 		{
       
  1553 	    CleanupClosePushL( ls );
       
  1554 		TInt ret = ls.GetServerApps( KMuiuMsgEditorServiceUid );
       
  1555 
       
  1556 		if( ret != KErrNone )
       
  1557 			{
       
  1558 		    CleanupStack::PopAndDestroy( &ls );
       
  1559 		    return appUid; // return NULL appUid
       
  1560 			}
       
  1561 
       
  1562 		services = ls.GetServiceImplementationsLC( KMuiuMsgEditorServiceUid );			
       
  1563 		
       
  1564 		if( services )
       
  1565 			{
       
  1566 			TArray<TApaAppServiceInfo> s = services->Array( );
       
  1567 			
       
  1568 			TInt count = s.Count( );
       
  1569 		
       
  1570 			if( count != 0)
       
  1571 				{	// 
       
  1572 				for( TInt i = 0; i<count; i++ )
       
  1573 					{
       
  1574 					if( TryMatchL( aParams, aMtmType, s[i], appUid ) )
       
  1575 						{ // If one of the services match, return the uid set by TryMatchL
       
  1576 						break;
       
  1577 						}
       
  1578 					}
       
  1579 				}		
       
  1580 			}
       
  1581 	    CleanupStack::PopAndDestroy( services );
       
  1582 	    CleanupStack::PopAndDestroy( &ls );
       
  1583 		}
       
  1584 	return appUid;
       
  1585 	}
       
  1586 
       
  1587 // -------------------------------------------------------------------------------------------------
       
  1588 // CIdsMessagesUiImpLauncher::TryMatchL
       
  1589 // -------------------------------------------------------------------------------------------------
       
  1590 //
       
  1591 TBool CMessagesSearcher::TryMatchL( const TEditorParameters aParams, 
       
  1592                                            TUid aMtmType, 
       
  1593                                            const TApaAppServiceInfo aInfo, 
       
  1594                                            TUid& aAppUid )
       
  1595 	{
       
  1596 	TBool useViewer = EFalse;
       
  1597 
       
  1598 	if( ( aParams.iFlags & EMsgReadOnly ) || ( aParams.iFlags & EMsgPreviewMessage ) )
       
  1599 		{ // If readonly or preview flag is set -> look for "Viewer" service type
       
  1600 		useViewer = ETrue;
       
  1601 		}
       
  1602 	
       
  1603 	RResourceReader r;
       
  1604 	r.OpenLC( aInfo.OpaqueData() );
       
  1605 	
       
  1606 	TUid mtm = TUid::Uid( r.ReadInt32L( ) ); // read the mtm
       
  1607 	TInt serviceType = r.ReadInt16L( ); // the service type (view, edit)
       
  1608 
       
  1609     CleanupStack::PopAndDestroy( &r );
       
  1610 
       
  1611 	if( aMtmType == mtm && useViewer && serviceType == KMsgServiceView )
       
  1612 		{
       
  1613 		aAppUid.iUid = aInfo.Uid( ).iUid;
       
  1614 		return ETrue;
       
  1615 		}
       
  1616 	else  if( aMtmType == mtm && !useViewer && serviceType == KMsgServiceEdit )
       
  1617 		{
       
  1618 		aAppUid.iUid = aInfo.Uid( ).iUid;
       
  1619 		return ETrue;			
       
  1620 		}
       
  1621 	
       
  1622 	return EFalse;	
       
  1623 	}