harvesterplugins/calendar/src/ccalendarplugin.cpp
changeset 11 773be20e0a25
parent 7 51d10d255e92
child 13 0a2ec6860a93
child 17 7d8c8d8f5eab
equal deleted inserted replaced
7:51d10d255e92 11:773be20e0a25
    38 
    38 
    39 _LIT(KExcerptDelimiter, " ");
    39 _LIT(KExcerptDelimiter, " ");
    40 
    40 
    41 /** The delay between harvesting chunks. */
    41 /** The delay between harvesting chunks. */
    42 const TInt KHarvestingDelay = 2000;
    42 const TInt KHarvestingDelay = 2000;
    43 
    43 _LIT(KCalendarTimeFormat,"%04d %02d %02d %02d %02d");
    44 _LIT(KCalendarTimeFormat,"%F%/0%Y %M %D %H%T"); // Locale independent YYYYMMDDHHSS
       
    45 
       
    46 // ---------------------------------------------------------------------------
    44 // ---------------------------------------------------------------------------
    47 // CMessagePlugin::NewL
    45 // CMessagePlugin::NewL
    48 // ---------------------------------------------------------------------------
    46 // ---------------------------------------------------------------------------
    49 //  
    47 //  
    50 CCalendarPlugin* CCalendarPlugin::NewL()
    48 CCalendarPlugin* CCalendarPlugin::NewL()
   350 //  
   348 //  
   351 void CCalendarPlugin::CreateEntryL( const TCalLocalUid& aLocalUid, TCPixActionType aActionType )
   349 void CCalendarPlugin::CreateEntryL( const TCalLocalUid& aLocalUid, TCPixActionType aActionType )
   352 	{
   350 	{
   353 	if (!iIndexer)
   351 	if (!iIndexer)
   354     	return;
   352     	return;
       
   353 	
   355 
   354 
   356 	OstTrace1( TRACE_NORMAL, CCALENDARPLUGIN_CREATEENTRYL, "CCalendarPlugin::CreateEntryL();Uid=%d", aLocalUid );
   355 	OstTrace1( TRACE_NORMAL, CCALENDARPLUGIN_CREATEENTRYL, "CCalendarPlugin::CreateEntryL();Uid=%d", aLocalUid );
   357 	CPIXLOGSTRING2("CCalendarPlugin::CreateEntryL():  Uid = %d.", aLocalUid);
   356 	CPIXLOGSTRING2("CCalendarPlugin::CreateEntryL():  Uid = %d.", aLocalUid);
   358 	
   357 	
   359 	// creating CSearchDocument object with unique ID for this application
   358 	// creating CSearchDocument object with unique ID for this application
   385 
   384 
   386 		// Add fields
   385 		// Add fields
   387 		index_item->AddFieldL(KCalendarSummaryField, entry->SummaryL());
   386 		index_item->AddFieldL(KCalendarSummaryField, entry->SummaryL());
   388 		index_item->AddFieldL(KCalendarDescriptionField, entry->DescriptionL());
   387 		index_item->AddFieldL(KCalendarDescriptionField, entry->DescriptionL());
   389 		index_item->AddFieldL(KCalendarLocationField, entry->LocationL());
   388 		index_item->AddFieldL(KCalendarLocationField, entry->LocationL());
       
   389 		
       
   390 		TUint priority = entry->PriorityL();
       
   391 		
       
   392 		switch(priority)
       
   393 		    {
       
   394 		    case 1:
       
   395 		        index_item->AddFieldL(KCalendarPriorityField, KCalendarPriorityHigh);
       
   396 		        break;
       
   397 		    case 2:
       
   398 		        index_item->AddFieldL(KCalendarPriorityField, KCalendarPriorityMedium);
       
   399                 break;
       
   400 		    case 3:
       
   401 		        index_item->AddFieldL(KCalendarPriorityField, KCalendarPriorityLow);
       
   402                 break;
       
   403 		    default:
       
   404 	            index_item->AddFieldL(KCalendarPriorityField, KNullDesC);
       
   405 	            break;
       
   406 		    }
   390 
   407 
   391 		TBuf<30> dateString;
   408 		TBuf<30> dateString;
   392 
   409 		TDateTime datetime = entry->StartTimeL().TimeUtcL().DateTime();       
   393 		TTime startTime = entry->StartTimeL().TimeUtcL();
   410 		dateString.Format( KCalendarTimeFormat, datetime.Year(),
   394 		startTime.FormatL(dateString, KCalendarTimeFormat);
   411 		                                     TInt(datetime.Month()+ 1),
       
   412 		                                     datetime.Day() + 1,
       
   413 		                                     datetime.Hour()+ 1,
       
   414 		                                     datetime.Minute());
   395 		index_item->AddFieldL(KCalendarStartTimeField, dateString, CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
   415 		index_item->AddFieldL(KCalendarStartTimeField, dateString, CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
   396 
   416 
   397 		TTime endTime = entry->EndTimeL().TimeUtcL();
   417 		TDateTime endTime = entry->EndTimeL().TimeUtcL().DateTime();		
   398 		endTime.FormatL(dateString, KCalendarTimeFormat);
   418 		dateString.Format( KCalendarTimeFormat, endTime.Year(),
       
   419                                                 TInt(endTime.Month()+ 1),
       
   420                                                 endTime.Day() + 1,
       
   421                                                 endTime.Hour()+ 1,
       
   422                                                 endTime.Minute());
   399 		index_item->AddFieldL(KCalendarEndTimeField, dateString, CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
   423 		index_item->AddFieldL(KCalendarEndTimeField, dateString, CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
   400 
   424 		
       
   425 		TTime completedTime = entry->CompletedTimeL().TimeUtcL();
       
   426 		if( completedTime != Time::NullTTime() && CCalEntry::ETodo == entry->EntryTypeL())
       
   427 		    {
       
   428             TDateTime compTime = completedTime.DateTime();
       
   429             dateString.Format( KCalendarTimeFormat, compTime.Year(),
       
   430                                                 TInt(compTime.Month()+ 1),
       
   431                                                 compTime.Day() + 1,
       
   432                                                 compTime.Hour()+ 1,
       
   433                                                 compTime.Minute());
       
   434             index_item->AddFieldL(KCalenderCompletedField, dateString, CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
       
   435 		    }
   401 		index_item->AddFieldL(KMimeTypeField, KMimeTypeCalendar, CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
   436 		index_item->AddFieldL(KMimeTypeField, KMimeTypeCalendar, CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
   402 
   437 
   403     	TInt excerptLength = 1 /*single 1-character delimiters*/ + entry->DescriptionL().Length() + entry->LocationL().Length();
   438     	TInt excerptLength = 1 /*single 1-character delimiters*/ + entry->DescriptionL().Length() + entry->LocationL().Length();
   404 		HBufC* excerpt = HBufC::NewLC(excerptLength);
   439 		HBufC* excerpt = HBufC::NewLC(excerptLength);
   405 		TPtr excerptDes = excerpt->Des();
   440 		TPtr excerptDes = excerpt->Des();