harvesterplugins/messaging/smsmms/src/cmessagedatahandler.cpp
changeset 26 367228f82b66
parent 18 1edf350003c5
child 27 7a8855317cbd
equal deleted inserted replaced
24:1abfa342db42 26:367228f82b66
    40 #include "cmessagedatahandlerTraces.h"
    40 #include "cmessagedatahandlerTraces.h"
    41 #endif
    41 #endif
    42 
    42 
    43 
    43 
    44 /** Number of symbols from MsgBody taken to excerpt */
    44 /** Number of symbols from MsgBody taken to excerpt */
    45 const TInt KMsgBodyExcerptSymbols = 160;
    45 //const TInt KMsgBodyExcerptSymbols = 160;
    46 
    46 
    47 // For Ucs2 detection
    47 // For Ucs2 detection
    48 const TInt KUtf8BomLength = 3;
    48 const TInt KUtf8BomLength = 3;
    49 const TUint8 KUtf8Bom[KUtf8BomLength] = {0xEF, 0xBB, 0xBF};
    49 const TUint8 KUtf8Bom[KUtf8BomLength] = {0xEF, 0xBB, 0xBF};
    50 
    50 
    51 // CSearchDocument ID max length
    51 // CSearchDocument ID max length
    52 const TUint KMaxDocId = 20;
    52 const TUint KMaxDocId = 20;
    53 // Hardcoded limit for the body size to index (and store)
    53 // Hardcoded limit for the body size to index (and store)
    54 const TInt KMaxDocumentSize = 1024;
    54 //const TInt KMaxDocumentSize = 1024;
    55 
    55 
    56 _LIT8(KMimeTypeText, "text/plain" );
    56 _LIT8(KMimeTypeText, "text/plain" );
    57 
    57 
    58 _LIT(KMimeTypeField, CPIX_MIMETYPE_FIELD);
    58 _LIT(KMimeTypeField, CPIX_MIMETYPE_FIELD);
    59 _LIT(KMimeTypeMessaging, MESSAGING_MIMETYPE);
    59 _LIT(KMimeTypeMessaging, MESSAGING_MIMETYPE);
    60 
    60 
    61 /** Field names */
    61 /** Field names */
    62 _LIT(KToField, TO_FIELD);
    62 _LIT(KToField, TO_FIELD);
    63 _LIT(KCcField, CC_FIELD);
    63 //_LIT(KCcField, CC_FIELD);
    64 _LIT(KBccField, BCC_FIELD);
    64 //_LIT(KBccField, BCC_FIELD);
    65 _LIT(KFromField, FROM_FIELD);
    65 _LIT(KFromField, FROM_FIELD);
    66 _LIT(KFolderField, FOLDER_FIELD);
    66 _LIT(KFolderField, FOLDER_FIELD);
    67 _LIT(KBodyField, BODY_FIELD);
    67 _LIT(KBodyField, BODY_FIELD);
    68 _LIT(KSubjectField, SUBJECT_FIELD);
    68 _LIT(KSubjectField, SUBJECT_FIELD);
    69 _LIT(KAttachmentField, ATTACHMENT_FIELD);
    69 _LIT(KAttachmentField, ATTACHMENT_FIELD);
    70 _LIT(KValueAttachment, "Attachment");
    70 _LIT(KValueAttachment, "Attachment");
    71 #ifdef USE_HIGHLIGHTER
    71 //#ifdef USE_HIGHLIGHTER
    72 _LIT(KExcerptDelimiter, " ");
    72 _LIT(KExcerptDelimiter, " ");
    73 #endif
    73 //#endif
    74 // ============================ MEMBER FUNCTIONS ===============================
    74 // ============================ MEMBER FUNCTIONS ===============================
    75 
    75 
    76 // ---------------------------------------------------------------------------
    76 // ---------------------------------------------------------------------------
    77 // CMessageDataHandler::NewL
    77 // CMessageDataHandler::NewL
    78 // ---------------------------------------------------------------------------
    78 // ---------------------------------------------------------------------------
   190 void CMessageDataHandler::CreateMessageIndexItemL(const TMsvId& aMsvId,
   190 void CMessageDataHandler::CreateMessageIndexItemL(const TMsvId& aMsvId,
   191 		TCPixActionType aActionType, const TMsvId& aFolderId)
   191 		TCPixActionType aActionType, const TMsvId& aFolderId)
   192 	{
   192 	{
   193 	OstTrace1( TRACE_NORMAL, CMESSAGEDATAHANDLER_CREATEMESSAGEINDEXITEML, "CMessageDataHandler::CreateMessageIndexItemL;aMsvId=%d", aMsvId );
   193 	OstTrace1( TRACE_NORMAL, CMESSAGEDATAHANDLER_CREATEMESSAGEINDEXITEML, "CMessageDataHandler::CreateMessageIndexItemL;aMsvId=%d", aMsvId );
   194 	CPIXLOGSTRING2("CMessageDataHandler::CreateMessageIndexItemL(): aMsvId = %d ", aMsvId );
   194 	CPIXLOGSTRING2("CMessageDataHandler::CreateMessageIndexItemL(): aMsvId = %d ", aMsvId );
       
   195 	OstTrace0( TRACE_NORMAL, DUP5_CMESSAGEDATAHANDLER_CREATEMESSAGEINDEXITEML, "CMessageDataHandler::Indexing Message" );
   195 
   196 
   196 	// Index an empty item if removal action
   197 	// Index an empty item if removal action
   197 	if (aActionType == ECPixRemoveAction)
   198 	if (aActionType == ECPixRemoveAction)
   198 		{
   199 		{
   199 		TBuf<20> docid_str;
   200 		TBuf<20> docid_str;
   300 	TMsvId service = 0;
   301 	TMsvId service = 0;
   301 	iMsvSession.GetEntry(aMsvId, service, entry);
   302 	iMsvSession.GetEntry(aMsvId, service, entry);
   302 	HBufC *fromNameOrNumberBuf = entry.iDetails.AllocLC();
   303 	HBufC *fromNameOrNumberBuf = entry.iDetails.AllocLC();
   303 	index_item->AddFieldL(KFromField, *fromNameOrNumberBuf,
   304 	index_item->AddFieldL(KFromField, *fromNameOrNumberBuf,
   304 	        CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText);
   305 	        CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText);
   305 #ifdef USE_HIGHLIGHTER 
   306 //#ifdef USE_HIGHLIGHTER 
   306 	if( aFolderId == KMsvGlobalInBoxIndexEntryIdValue)
   307 	if( aFolderId == KMsvGlobalInBoxIndexEntryIdValue)
   307         {
   308         {
   308         index_item->AddHLDisplayFieldL(*fromNameOrNumberBuf);
   309         index_item->AddHLDisplayFieldL(*fromNameOrNumberBuf);
   309         }
   310         }
   310 #endif	
   311 //#endif	
   311 
   312 
   312 	// Add the recipients as content items
   313 	// Add the recipients as content items
   313 	TBuf<64> to_field;
   314 	TBuf<64> to_field;
   314 	
   315 	
   315 #ifdef USE_HIGHLIGHTER	
   316 //#ifdef USE_HIGHLIGHTER	
   316 	HBufC* toList = HBufC::NewL(5);
   317 	HBufC* toList = HBufC::NewL(5);
   317 #endif	
   318 //#endif	
   318 	const CDesCArray
   319 	const CDesCArray
   319 			& recipientArray =
   320 			& recipientArray =
   320 					static_cast<const CDesCArray&> (iSmsMtm->AddresseeList().RecipientList());
   321 					static_cast<const CDesCArray&> (iSmsMtm->AddresseeList().RecipientList());
   321 	for (TInt i = 0; i < recipientArray.MdcaCount(); i++)
   322 	for (TInt i = 0; i < recipientArray.MdcaCount(); i++)
   322 		{
   323 		{
   324 		if (i>0)
   325 		if (i>0)
   325 			to_field.AppendNum(i);
   326 			to_field.AppendNum(i);
   326 		index_item->AddFieldL(to_field, recipientArray.MdcaPoint(i),
   327 		index_item->AddFieldL(to_field, recipientArray.MdcaPoint(i),
   327 		        CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText);
   328 		        CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText);
   328 		
   329 		
   329 #ifdef USE_HIGHLIGHTER
   330 //#ifdef USE_HIGHLIGHTER
   330         // Folder field		
   331         // Folder field		
   331 		// Iterate through the list of recipients and add them under To field 
   332 		// Iterate through the list of recipients and add them under To field 
   332 		if( aFolderId != KMsvGlobalInBoxIndexEntryIdValue)
   333 		if( aFolderId != KMsvGlobalInBoxIndexEntryIdValue)
   333 		    {		    
   334 		    {		    
   334 		    TInt currentSize = toList->Size();
   335 		    TInt currentSize = toList->Size();
   339                 }
   340                 }
   340             TPtr ptr = toList->Des();
   341             TPtr ptr = toList->Des();
   341             ptr.Append(recipientArray.MdcaPoint(i));
   342             ptr.Append(recipientArray.MdcaPoint(i));
   342             ptr.Append(KExcerptDelimiter);            
   343             ptr.Append(KExcerptDelimiter);            
   343             }        
   344             }        
   344 #endif
   345 //#endif
   345 		}
   346 		}
   346 #ifdef USE_HIGHLIGHTER
   347 //#ifdef USE_HIGHLIGHTER
   347 	if( aFolderId != KMsvGlobalInBoxIndexEntryIdValue)
   348 	if( aFolderId != KMsvGlobalInBoxIndexEntryIdValue)
   348 	    {
   349 	    {
   349 	    index_item->AddHLDisplayFieldL( *toList);
   350 	    index_item->AddHLDisplayFieldL( *toList);
   350 	    }
   351 	    }
   351 	delete toList;
   352 	delete toList;
   352 	toList = NULL;
   353 	toList = NULL;
   353 #endif
   354 //#endif
   354 	// Add the body text as a content item
   355 	// Add the body text as a content item
   355 	TInt msgLength = iSmsMtm->Body().DocumentLength();
   356 	TInt msgLength = iSmsMtm->Body().DocumentLength();
   356 	HBufC* bodyText = HBufC::NewLC(msgLength);
   357 	HBufC* bodyText = HBufC::NewLC(msgLength);
   357 	TPtr body_ptr = bodyText->Des();
   358 	TPtr body_ptr = bodyText->Des();
   358 	iSmsMtm->Body().Extract(body_ptr);
   359 	iSmsMtm->Body().Extract(body_ptr);
   387 	docid_str.AppendNum(aMsvId);
   388 	docid_str.AppendNum(aMsvId);
   388 	CSearchDocument* index_item = CSearchDocument::NewLC(docid_str, _L(MMSAPPCLASS));
   389 	CSearchDocument* index_item = CSearchDocument::NewLC(docid_str, _L(MMSAPPCLASS));
   389 	
   390 	
   390 	// Add from field
   391 	// Add from field
   391 	index_item->AddFieldL(KFromField, iMmsMtm->Sender());
   392 	index_item->AddFieldL(KFromField, iMmsMtm->Sender());
   392 #ifdef USE_HIGHLIGHTER 
   393 //#ifdef USE_HIGHLIGHTER 
   393     if( aFolderId == KMsvGlobalInBoxIndexEntryIdValue)
   394     if( aFolderId == KMsvGlobalInBoxIndexEntryIdValue)
   394         {
   395         {
   395         index_item->AddHLDisplayFieldL(iMmsMtm->Sender());
   396         index_item->AddHLDisplayFieldL(iMmsMtm->Sender());
   396         }
   397         }
   397 #endif
   398 //#endif
   398 
   399 
   399 	// Add the recipients as content items
   400 	// Add the recipients as content items
   400 	TBuf<64> to_field;
   401 	TBuf<64> to_field;
   401 #ifdef USE_HIGHLIGHTER 
   402 //#ifdef USE_HIGHLIGHTER 
   402     HBufC* toList = HBufC::NewL(5);
   403     HBufC* toList = HBufC::NewL(5);
   403 #endif
   404 //#endif
   404 	const CDesCArray
   405 	const CDesCArray
   405 			& recipientArray =
   406 			& recipientArray =
   406 					static_cast<const CDesCArray&> (iMmsMtm->AddresseeList().RecipientList());
   407 					static_cast<const CDesCArray&> (iMmsMtm->AddresseeList().RecipientList());
   407 	for (TInt i = 0; i < recipientArray.MdcaCount(); i++)
   408 	for (TInt i = 0; i < recipientArray.MdcaCount(); i++)
   408 		{
   409 		{
   409 		to_field = KToField;
   410 		to_field = KToField;
   410 		if (i>0)
   411 		if (i>0)
   411 			to_field.AppendNum(i);
   412 			to_field.AppendNum(i);
   412 		index_item->AddFieldL(to_field, recipientArray.MdcaPoint(i));
   413 		index_item->AddFieldL(to_field, recipientArray.MdcaPoint(i));
   413 		
   414 		
   414 #ifdef USE_HIGHLIGHTER
   415 //#ifdef USE_HIGHLIGHTER
   415         // Folder field     
   416         // Folder field     
   416         // Iterate through the list of recipients and add them under To field 
   417         // Iterate through the list of recipients and add them under To field 
   417         if( aFolderId != KMsvGlobalInBoxIndexEntryIdValue)
   418         if( aFolderId != KMsvGlobalInBoxIndexEntryIdValue)
   418             {           
   419             {           
   419             TInt currentSize = toList->Size();
   420             TInt currentSize = toList->Size();
   424                 }
   425                 }
   425             TPtr ptr = toList->Des();
   426             TPtr ptr = toList->Des();
   426             ptr.Append(recipientArray.MdcaPoint(i));
   427             ptr.Append(recipientArray.MdcaPoint(i));
   427             ptr.Append(KExcerptDelimiter);            
   428             ptr.Append(KExcerptDelimiter);            
   428             }        
   429             }        
   429 #endif
   430 //#endif
   430 		}
   431 		}
   431 
   432 
   432 #ifdef USE_HIGHLIGHTER
   433 //#ifdef USE_HIGHLIGHTER
   433     if( aFolderId != KMsvGlobalInBoxIndexEntryIdValue)
   434     if( aFolderId != KMsvGlobalInBoxIndexEntryIdValue)
   434         {
   435         {
   435         index_item->AddHLDisplayFieldL( *toList);
   436         index_item->AddHLDisplayFieldL( *toList);
   436         }
   437         }
   437     delete toList;
   438     delete toList;
   438     toList = NULL;
   439     toList = NULL;
   439 #endif
   440 //#endif
   440 	// Add subject
   441 	// Add subject
   441 	TPtrC subject(iMmsMtm->SubjectL());
   442 	TPtrC subject(iMmsMtm->SubjectL());
   442 	index_item->AddFieldL(KSubjectField, subject);
   443 	index_item->AddFieldL(KSubjectField, subject);
   443 
   444 
   444 	// Add the body parts as a content items
   445 	// Add the body parts as a content items
   563     //See appclass-hierarchy.txt for details.  
   564     //See appclass-hierarchy.txt for details.  
   564     
   565     
   565 	_LIT(KEllipsis, "...");
   566 	_LIT(KEllipsis, "...");
   566 	_LIT(KSpace, " ");
   567 	_LIT(KSpace, " ");
   567 	//
   568 	//
   568 #ifdef USE_HIGHLIGHTER	
   569 //#ifdef USE_HIGHLIGHTER	
   569 	TInt excerptLength = aBodyText.Length() + KEllipsis().Length();
   570 	TInt excerptLength = aBodyText.Length() + KEllipsis().Length();
   570 #else	
   571 //#else	
   571 	TInt excerptLength = KMsgBodyExcerptSymbols + KEllipsis().Length();
   572 //	TInt excerptLength = KMsgBodyExcerptSymbols + KEllipsis().Length();
   572 #endif	
   573 //#endif	
   573 	//Not removing commented out code as this may come back into use in near future.
   574 	//Not removing commented out code as this may come back into use in near future.
   574 //	TMsvEntry entry;
   575 //	TMsvEntry entry;
   575 //	TMsvId service = 0;
   576 //	TMsvId service = 0;
   576 //	iMsvSession.GetEntry(aFolderId, service, entry);
   577 //	iMsvSession.GetEntry(aFolderId, service, entry);
   577 //	HBufC *folder_str = entry.iDetails.AllocLC();
   578 //	HBufC *folder_str = entry.iDetails.AllocLC();
   621 //	if (aSubject.Length() > 0)
   622 //	if (aSubject.Length() > 0)
   622 //		{
   623 //		{
   623 //		excerptPtr.Append(aSubject);
   624 //		excerptPtr.Append(aSubject);
   624 //		excerptPtr.Append(KSpace);
   625 //		excerptPtr.Append(KSpace);
   625 //		}
   626 //		}
   626 #ifdef USE_HIGHLIGHTER
   627 //#ifdef USE_HIGHLIGHTER
   627     excerptPtr.Append(aBodyText);
   628     excerptPtr.Append(aBodyText);
   628 #else    
   629 //#else    
   629 	excerptPtr.Append(aBodyText.Left(KMsgBodyExcerptSymbols));	
   630 //	excerptPtr.Append(aBodyText.Left(KMsgBodyExcerptSymbols));	
   630 	if (aBodyText.Length() > KMsgBodyExcerptSymbols)
   631 //	if (aBodyText.Length() > KMsgBodyExcerptSymbols)
   631 		excerptPtr.Append(KEllipsis);
   632 //		excerptPtr.Append(KEllipsis);
   632 #endif
   633 //#endif
   633 //	CleanupStack::PopAndDestroy(folder_str);
   634 //	CleanupStack::PopAndDestroy(folder_str);
   634 	CleanupStack::PushL(excerpt);
   635 	CleanupStack::PushL(excerpt);
   635 	return excerpt;
   636 	return excerpt;
   636 	}
   637 	}
   637 
   638 
   854 // HandleNextRequest
   855 // HandleNextRequest
   855 // ---------------------------------------------------------------------------
   856 // ---------------------------------------------------------------------------
   856 //
   857 //
   857 void CMessageDataHandler::HandleNextRequest()
   858 void CMessageDataHandler::HandleNextRequest()
   858 	{
   859 	{
   859 	if (!IsActive())
   860 	OstTraceFunctionEntry0( CMESSAGEDATAHANDLER_HANDLENEXTREQUEST_ENTRY );
       
   861 	if (!IsActive() && iMessagePlugin.GetHarvesterState())
   860 		{
   862 		{
   861 		SetActive();
   863 		SetActive();
   862 		TRequestStatus* status = &iStatus;
   864 		TRequestStatus* status = &iStatus;
   863 		User::RequestComplete(status, KErrNone);
   865 		User::RequestComplete(status, KErrNone);
   864 		}
   866 		}
   865 	}
   867 	OstTraceFunctionExit0( CMESSAGEDATAHANDLER_HANDLENEXTREQUEST_EXIT );
       
   868 	}
       
   869 
       
   870 void CMessageDataHandler::ResumeL()
       
   871     {
       
   872     OstTraceFunctionEntry0( CMESSAGEDATAHANDLER_RESUMEL_ENTRY );
       
   873     if (iMessageArray.Count() > 0 && iMessagePlugin.GetHarvesterState())
       
   874         {
       
   875         // Take first id from array
       
   876         CreateMessageIndexItemL(iMessageArray[0].iMessageId,
       
   877                 iMessageArray[0].iActionType, iMessageArray[0].iFolderId);
       
   878         
       
   879         // Remove item that is handled
       
   880         iMessageArray.Remove(0);
       
   881         }
       
   882     OstTraceFunctionExit0( CMESSAGEDATAHANDLER_RESUMEL_EXIT );
       
   883     }
   866 
   884 
   867 // End of File
   885 // End of File
   868 
   886