harvesterplugins/calendar/src/ccalendarplugin.cpp
changeset 2 208a4ba3894c
parent 0 ccd0fd43f247
child 3 6832643895f7
equal deleted inserted replaced
0:ccd0fd43f247 2:208a4ba3894c
    24 #include <e32base.h> 
    24 #include <e32base.h> 
    25 #include <calsession.h>
    25 #include <calsession.h>
    26 #include <calentry.h>
    26 #include <calentry.h>
    27 #include <caliterator.h>
    27 #include <caliterator.h>
    28 #include <calentryview.h>
    28 #include <calentryview.h>
    29 #include <mmfcontrollerpluginresolver.h> // CleanupResetAndDestroyPushL
    29 #include <mmfcontrollerpluginresolver.h>
       
    30 #include "OstTraceDefinitions.h"
       
    31 #ifdef OST_TRACE_COMPILER_IN_USE
       
    32 #include "ccalendarpluginTraces.h"
       
    33 #endif
       
    34  // CleanupResetAndDestroyPushL
    30 
    35 
    31 _LIT(KMimeTypeField, CPIX_MIMETYPE_FIELD);
    36 _LIT(KMimeTypeField, CPIX_MIMETYPE_FIELD);
    32 _LIT(KMimeTypeCalendar, CALENDAR_MIMETYPE);
    37 _LIT(KMimeTypeCalendar, CALENDAR_MIMETYPE);
    33 
    38 
    34 _LIT(KExcerptDelimiter, " ");
    39 _LIT(KExcerptDelimiter, " ");
   211 		iEntryView->FetchL( uid, entryArray );
   216 		iEntryView->FetchL( uid, entryArray );
   212 		// Handle only the first (i.e. parent entry)
   217 		// Handle only the first (i.e. parent entry)
   213 		if( entryArray.Count() > 0 )
   218 		if( entryArray.Count() > 0 )
   214 			{
   219 			{
   215 			CCalEntry* entry = (CCalEntry*)entryArray[ 0 ];
   220 			CCalEntry* entry = (CCalEntry*)entryArray[ 0 ];
       
   221 			OstTrace1( TRACE_NORMAL, CCALENDARPLUGIN_DELAYEDCALLBACKL, "CCalendarPlugin::DelayedCallbackL();Harvesting id=%d", entry->LocalUidL() );
   216 			CPIXLOGSTRING2("CCalendarPlugin::DelayedCallbackL(): Harvesting id=%d.", entry->LocalUidL());
   222 			CPIXLOGSTRING2("CCalendarPlugin::DelayedCallbackL(): Harvesting id=%d.", entry->LocalUidL());
   217 			CreateEntryL( entry->LocalUidL(), ECPixAddAction );
   223 			CreateEntryL( entry->LocalUidL(), ECPixAddAction );
   218 			}
   224 			}
   219 		CleanupStack::PopAndDestroy(&entryArray);
   225 		CleanupStack::PopAndDestroy(&entryArray);
   220 
   226 
   250 // ---------------------------------------------------------------------------
   256 // ---------------------------------------------------------------------------
   251 //  
   257 //  
   252 void CCalendarPlugin::CalChangeNotification( RArray< TCalChangeEntry >& aChangeItems )
   258 void CCalendarPlugin::CalChangeNotification( RArray< TCalChangeEntry >& aChangeItems )
   253 	{
   259 	{
   254 	const TInt count(aChangeItems.Count());
   260 	const TInt count(aChangeItems.Count());
       
   261 	OstTrace1( TRACE_NORMAL, CCALENDARPLUGIN_CALCHANGENOTIFICATION, "CCalendarPlugin::CalChangeNotification();changed item count=%d", count );
   255 	CPIXLOGSTRING2("CCalendarPlugin::CalChangeNotification(): changed item count =%d.", count);
   262 	CPIXLOGSTRING2("CCalendarPlugin::CalChangeNotification(): changed item count =%d.", count);
   256 	for( TInt i = 0; i < count; ++i )
   263 	for( TInt i = 0; i < count; ++i )
   257 		{
   264 		{
   258 		TCalChangeEntry changedEntry = aChangeItems[ i ];
   265 		TCalChangeEntry changedEntry = aChangeItems[ i ];
   259 		TRAP_IGNORE(HandleChangedEntryL(changedEntry));
   266 		TRAP_IGNORE(HandleChangedEntryL(changedEntry));
   268 	{
   275 	{
   269 	switch( changedEntry.iChangeType )
   276 	switch( changedEntry.iChangeType )
   270 		{		
   277 		{		
   271 		case EChangeAdd:
   278 		case EChangeAdd:
   272 			{
   279 			{
       
   280 			OstTrace1( TRACE_NORMAL, CCALENDARPLUGIN_HANDLECHANGEDENTRYL, "CCalendarPlugin::HandleChangedEntryL();Monitored add id=%d", changedEntry.iEntryId );
   273 			CPIXLOGSTRING2("CCalendarPlugin::HandleChangedEntryL(): Monitored add id=%d.", changedEntry.iEntryId);
   281 			CPIXLOGSTRING2("CCalendarPlugin::HandleChangedEntryL(): Monitored add id=%d.", changedEntry.iEntryId);
   274 #ifdef __PERFORMANCE_DATA
   282 #ifdef __PERFORMANCE_DATA
   275             iStartTime.UniversalTime();
   283             iStartTime.UniversalTime();
   276 			CreateEntryL( changedEntry.iEntryId, ECPixAddAction );
   284 			CreateEntryL( changedEntry.iEntryId, ECPixAddAction );
   277 			UpdatePerformaceDataL(ECPixAddAction);
   285 			UpdatePerformaceDataL(ECPixAddAction);
   281 			break;
   289 			break;
   282 			}
   290 			}
   283 
   291 
   284 		case EChangeDelete:
   292 		case EChangeDelete:
   285 			{	
   293 			{	
       
   294 			OstTrace1( TRACE_NORMAL, DUP1_CCALENDARPLUGIN_HANDLECHANGEDENTRYL, "CCalendarPlugin::HandleChangedEntryL();Monitored delete id=%d", changedEntry.iEntryId );
   286 			CPIXLOGSTRING2("CCalendarPlugin::HandleChangedEntryL(): Monitored delete id=%d.", changedEntry.iEntryId);
   295 			CPIXLOGSTRING2("CCalendarPlugin::HandleChangedEntryL(): Monitored delete id=%d.", changedEntry.iEntryId);
   287 #ifdef __PERFORMANCE_DATA
   296 #ifdef __PERFORMANCE_DATA
   288             iStartTime.UniversalTime();
   297             iStartTime.UniversalTime();
   289 			CreateEntryL( changedEntry.iEntryId, ECPixAddAction );
   298 			CreateEntryL( changedEntry.iEntryId, ECPixAddAction );
   290 			UpdatePerformaceDataL(ECPixAddAction);
   299 			UpdatePerformaceDataL(ECPixAddAction);
   294 			break;
   303 			break;
   295 			}
   304 			}
   296 
   305 
   297 		case EChangeModify:
   306 		case EChangeModify:
   298 			{
   307 			{
       
   308 			OstTrace1( TRACE_NORMAL, DUP2_CCALENDARPLUGIN_HANDLECHANGEDENTRYL, "CCalendarPlugin::HandleChangedEntryL();Monitored update id=%d", changedEntry.iEntryId );
   299 			CPIXLOGSTRING2("CCalendarPlugin::HandleChangedEntryL(): Monitored update id=%d.", changedEntry.iEntryId);
   309 			CPIXLOGSTRING2("CCalendarPlugin::HandleChangedEntryL(): Monitored update id=%d.", changedEntry.iEntryId);
   300 #ifdef __PERFORMANCE_DATA
   310 #ifdef __PERFORMANCE_DATA
   301             iStartTime.UniversalTime(); 
   311             iStartTime.UniversalTime(); 
   302 			CreateEntryL( changedEntry.iEntryId, ECPixUpdateAction );
   312 			CreateEntryL( changedEntry.iEntryId, ECPixUpdateAction );
   303 			UpdatePerformaceDataL(ECPixUpdateAction);
   313 			UpdatePerformaceDataL(ECPixUpdateAction);
   311 			If iChangeType is EChangeUndefined or EChangeOverflowError, iEntryId and
   321 			If iChangeType is EChangeUndefined or EChangeOverflowError, iEntryId and
   312 			iEntryType are undefined and should not be used by clients.
   322 			iEntryType are undefined and should not be used by clients.
   313 		 */
   323 		 */
   314 		case EChangeUndefined:
   324 		case EChangeUndefined:
   315 			{
   325 			{
       
   326 			OstTrace0( TRACE_NORMAL, DUP3_CCALENDARPLUGIN_HANDLECHANGEDENTRYL, "CCalendarPlugin::HandleChangedEntryL(): EChangeUndefined." );
   316 			CPIXLOGSTRING("CCalendarPlugin::HandleChangedEntryL(): EChangeUndefined.");
   327 			CPIXLOGSTRING("CCalendarPlugin::HandleChangedEntryL(): EChangeUndefined.");
   317 			// This event could be related to synchronization.
   328 			// This event could be related to synchronization.
   318 			// Mark harvesting as cancelled.
   329 			// Mark harvesting as cancelled.
   319 			// Remove it from the harvesting queue to cause it to enter 
   330 			// Remove it from the harvesting queue to cause it to enter 
   320 			// EHarvesterStatusHibernate state.
   331 			// EHarvesterStatusHibernate state.
   340 void CCalendarPlugin::CreateEntryL( const TCalLocalUid& aLocalUid, TCPixActionType aActionType )
   351 void CCalendarPlugin::CreateEntryL( const TCalLocalUid& aLocalUid, TCPixActionType aActionType )
   341 	{
   352 	{
   342 	if (!iIndexer)
   353 	if (!iIndexer)
   343     	return;
   354     	return;
   344 
   355 
       
   356 	OstTrace1( TRACE_NORMAL, CCALENDARPLUGIN_CREATEENTRYL, "CCalendarPlugin::CreateEntryL();Uid=%d", aLocalUid );
   345 	CPIXLOGSTRING2("CCalendarPlugin::CreateEntryL():  Uid = %d.", aLocalUid);
   357 	CPIXLOGSTRING2("CCalendarPlugin::CreateEntryL():  Uid = %d.", aLocalUid);
   346 	
   358 	
   347 	// creating CSearchDocument object with unique ID for this application
   359 	// creating CSearchDocument object with unique ID for this application
   348 	TBuf<20> docid_str;
   360 	TBuf<20> docid_str;
   349 	docid_str.AppendNum(aLocalUid);
   361 	docid_str.AppendNum(aLocalUid);
   360 		// TODO Uncomment below portion of code when the latest Organiser code in MCL
   372 		// TODO Uncomment below portion of code when the latest Organiser code in MCL
   361 		if( CCalEntry::ENote == entry->EntryTypeL() )
   373 		if( CCalEntry::ENote == entry->EntryTypeL() )
   362 		    {
   374 		    {
   363             CleanupStack::PopAndDestroy(entry);
   375             CleanupStack::PopAndDestroy(entry);
   364             CleanupStack::PopAndDestroy(index_item);
   376             CleanupStack::PopAndDestroy(index_item);
       
   377             OstTrace0( TRACE_NORMAL, DUP1_CCALENDARPLUGIN_CREATEENTRYL, "CCalendarPlugin::CreateEntryL(): Donot harvest Note item." );
   365             CPIXLOGSTRING("CCalendarPlugin::CreateEntryL(): Donot harvest Note item.");
   378             CPIXLOGSTRING("CCalendarPlugin::CreateEntryL(): Donot harvest Note item.");
   366             return;
   379             return;
   367 		    }
   380 		    }
   368 
   381 
   369 		// Add fields
   382 		// Add fields
   411 		if (aActionType == ECPixAddAction)
   424 		if (aActionType == ECPixAddAction)
   412 			{
   425 			{
   413 			TRAPD(err, iIndexer->AddL(*index_item));
   426 			TRAPD(err, iIndexer->AddL(*index_item));
   414 			if (err == KErrNone)
   427 			if (err == KErrNone)
   415 				{
   428 				{
       
   429 				OstTrace0( TRACE_NORMAL, DUP2_CCALENDARPLUGIN_CREATEENTRYL, "CCalendarPlugin::CreateEntryL(): Added." );
   416 				CPIXLOGSTRING("CCalendarPlugin::CreateEntryL(): Added.");
   430 				CPIXLOGSTRING("CCalendarPlugin::CreateEntryL(): Added.");
   417 				}
   431 				}
   418 			else
   432 			else
   419 				{
   433 				{
       
   434 				OstTrace1( TRACE_NORMAL, DUP3_CCALENDARPLUGIN_CREATEENTRYL, "CCalendarPlugin::CreateEntryL();Error %d in adding", err );
   420 				CPIXLOGSTRING2("CCalendarPlugin::CreateEntryL(): Error %d in adding.", err);
   435 				CPIXLOGSTRING2("CCalendarPlugin::CreateEntryL(): Error %d in adding.", err);
   421 				}			
   436 				}			
   422 			}
   437 			}
   423 		else if (aActionType == ECPixUpdateAction)
   438 		else if (aActionType == ECPixUpdateAction)
   424 			{
   439 			{
   425 			TRAPD(err, iIndexer->UpdateL(*index_item));
   440 			TRAPD(err, iIndexer->UpdateL(*index_item));
   426 			if (err == KErrNone)
   441 			if (err == KErrNone)
   427 				{
   442 				{
       
   443 				OstTrace0( TRACE_NORMAL, DUP4_CCALENDARPLUGIN_CREATEENTRYL, "CCalendarPlugin::CreateEntryL(): Updated." );
   428 				CPIXLOGSTRING("CCalendarPlugin::CreateEntryL(): Updated.");
   444 				CPIXLOGSTRING("CCalendarPlugin::CreateEntryL(): Updated.");
   429 				}
   445 				}
   430 			else
   446 			else
   431 				{
   447 				{
       
   448 				OstTrace1( TRACE_NORMAL, DUP5_CCALENDARPLUGIN_CREATEENTRYL, "CCalendarPlugin::CreateEntryL();Error %d in updating", err );
   432 				CPIXLOGSTRING2("CCalendarPlugin::CreateEntryL(): Error %d in updating.", err);
   449 				CPIXLOGSTRING2("CCalendarPlugin::CreateEntryL(): Error %d in updating.", err);
   433 				}			
   450 				}			
   434 			}
   451 			}
   435 		CleanupStack::PopAndDestroy(index_item);
   452 		CleanupStack::PopAndDestroy(index_item);
   436 		}
   453 		}
   437 	else if (aActionType == ECPixRemoveAction)
   454 	else if (aActionType == ECPixRemoveAction)
   438 		{
   455 		{
   439 		TRAPD(err, iIndexer->DeleteL(docid_str));
   456 		TRAPD(err, iIndexer->DeleteL(docid_str));
   440 		if (err == KErrNone)
   457 		if (err == KErrNone)
   441 			{
   458 			{
       
   459 			OstTrace0( TRACE_NORMAL, DUP6_CCALENDARPLUGIN_CREATEENTRYL, "CCalendarPlugin::CreateEntryL(): Deleted." );
   442 			CPIXLOGSTRING("CCalendarPlugin::CreateEntryL(): Deleted.");
   460 			CPIXLOGSTRING("CCalendarPlugin::CreateEntryL(): Deleted.");
   443 			}
   461 			}
   444 		else
   462 		else
   445 			{
   463 			{
       
   464 			OstTrace1( TRACE_NORMAL, DUP7_CCALENDARPLUGIN_CREATEENTRYL, "CCalendarPlugin::CreateEntryL();Error %d in deleting", err );
   446 			CPIXLOGSTRING2("CCalendarPlugin::CreateEntryL(): Error %d in deleting.", err);				
   465 			CPIXLOGSTRING2("CCalendarPlugin::CreateEntryL(): Error %d in deleting.", err);				
   447 			}
   466 			}
   448 		}
   467 		}
   449 
   468 
   450 	}
   469 	}