harvesterplugins/contacts/src/ccontactsplugin.cpp
changeset 26 367228f82b66
parent 21 708468d5143e
child 27 7a8855317cbd
equal deleted inserted replaced
24:1abfa342db42 26:367228f82b66
    85 	delete iDatabase;
    85 	delete iDatabase;
    86 	delete iIndexer;
    86 	delete iIndexer;
    87 	//delete NULL is safe - so no need to test nullity of iExceprt (which routinely
    87 	//delete NULL is safe - so no need to test nullity of iExceprt (which routinely
    88 	//keeps getting deleted in the plugin).
    88 	//keeps getting deleted in the plugin).
    89 	delete iExcerpt;
    89 	delete iExcerpt;
    90 #ifdef USE_HIGHLIGHTER    
    90 	iJobQueue.Reset();
       
    91 	iJobQueue.Close();
       
    92 //#ifdef USE_HIGHLIGHTER    
    91             if(iHLDisplayExcerpt)
    93             if(iHLDisplayExcerpt)
    92                 {
    94                 {
    93                 delete iHLDisplayExcerpt;
    95                 delete iHLDisplayExcerpt;
    94                 iHLDisplayExcerpt = NULL;
    96                 iHLDisplayExcerpt = NULL;
    95                 }
    97                 }
    96 #endif            
    98 //#endif            
    97 	}
    99 	}
    98 	
   100 	
    99 // -----------------------------------------------------------------------------
   101 // -----------------------------------------------------------------------------
   100 // CContactsPlugin::ConstructL()
   102 // CContactsPlugin::ConstructL()
   101 // -----------------------------------------------------------------------------
   103 // -----------------------------------------------------------------------------
   102 //
   104 //
   103 void CContactsPlugin::ConstructL()
   105 void CContactsPlugin::ConstructL()
   104 	{
   106 	{
   105 	iDatabase = CContactDatabase::OpenL();
   107 	iDatabase = CContactDatabase::OpenL();
   106 
   108     iIndexState = ETrue;
   107 	// This pointer is valid until a change is made to the database or until 
   109 	// This pointer is valid until a change is made to the database or until 
   108 	// the database's active object is allowed to run. If the array is 
   110 	// the database's active object is allowed to run. If the array is 
   109 	// required after one of the above two events has occurred, a copy of the 
   111 	// required after one of the above two events has occurred, a copy of the 
   110 	// array must first be made.
   112 	// array must first be made.
   111 	iContacts = iDatabase->SortedItemsL();
   113 	iContacts = iDatabase->SortedItemsL();
   116 // -----------------------------------------------------------------------------
   118 // -----------------------------------------------------------------------------
   117 // CContactsPlugin::StartPluginL()
   119 // CContactsPlugin::StartPluginL()
   118 // -----------------------------------------------------------------------------
   120 // -----------------------------------------------------------------------------
   119 //
   121 //
   120 void CContactsPlugin::StartPluginL()
   122 void CContactsPlugin::StartPluginL()
   121 	{
   123 	{    
   122 	// Define this base application class, use default location
   124 	// Define this base application class, use default location
   123 	User::LeaveIfError(iSearchSession.DefineVolume( _L(CONTACT_QBASEAPPCLASS), KNullDesC ));
   125 	User::LeaveIfError(iSearchSession.DefineVolume( _L(CONTACT_QBASEAPPCLASS), KNullDesC ));
   124 
   126 
   125 	// Open database
   127 	// Open database
   126 	iIndexer = CCPixIndexer::NewL(iSearchSession);
   128 	iIndexer = CCPixIndexer::NewL(iSearchSession);
   138 // -----------------------------------------------------------------------------
   140 // -----------------------------------------------------------------------------
   139 //
   141 //
   140 void CContactsPlugin::StartHarvestingL(const TDesC& /*aQualifiedBaseAppClass*/)
   142 void CContactsPlugin::StartHarvestingL(const TDesC& /*aQualifiedBaseAppClass*/)
   141     {
   143     {
   142 	iIndexer->ResetL();
   144 	iIndexer->ResetL();
   143 	iCurrentIndex = 0;
   145 	iCurrentIndex = 0;	
       
   146 	iHarvestState = EHarvesterStartHarvest;
   144 #ifdef __PERFORMANCE_DATA
   147 #ifdef __PERFORMANCE_DATA
   145     iStartTime.UniversalTime();
   148     iStartTime.UniversalTime();
   146 #endif  
   149 #endif  
   147     iAsynchronizer->Start( 0, this, KHarvestingDelay );
   150     iAsynchronizer->Start( 0, this, KHarvestingDelay );
   148     }
   151     }
   151 // CContactsPlugin::HandleDatabaseEventL
   154 // CContactsPlugin::HandleDatabaseEventL
   152 // -----------------------------------------------------------------------------
   155 // -----------------------------------------------------------------------------
   153 // 
   156 // 
   154 void CContactsPlugin::HandleDatabaseEventL(TContactDbObserverEvent aEvent)
   157 void CContactsPlugin::HandleDatabaseEventL(TContactDbObserverEvent aEvent)
   155 	{
   158 	{
       
   159     TRecord entry;
       
   160     entry.iContactId = aEvent.iContactId;
   156 	switch( aEvent.iType )
   161 	switch( aEvent.iType )
   157 		{
   162 		{
   158 		case EContactDbObserverEventContactChanged:
   163 		case EContactDbObserverEventContactChanged:
   159 		case EContactDbObserverEventGroupChanged:
   164 		case EContactDbObserverEventGroupChanged:
   160 		case EContactDbObserverEventOwnCardChanged:
   165 		case EContactDbObserverEventOwnCardChanged:
   163 #ifdef __PERFORMANCE_DATA
   168 #ifdef __PERFORMANCE_DATA
   164             iStartTime.UniversalTime();
   169             iStartTime.UniversalTime();
   165             CreateContactIndexItemL(aEvent.iContactId, ECPixUpdateAction);
   170             CreateContactIndexItemL(aEvent.iContactId, ECPixUpdateAction);
   166             UpdatePerformaceDataL(ECPixUpdateAction);
   171             UpdatePerformaceDataL(ECPixUpdateAction);
   167 #else			
   172 #else			
   168 			CreateContactIndexItemL(aEvent.iContactId, ECPixUpdateAction);
   173 			entry.iActionType = ECPixUpdateAction;
       
   174 			//CreateContactIndexItemL(aEvent.iContactId, ECPixUpdateAction);
   169 #endif			
   175 #endif			
   170 			break;
   176 			break;
   171 
   177 
   172 		case EContactDbObserverEventContactDeleted:
   178 		case EContactDbObserverEventContactDeleted:
   173 		case EContactDbObserverEventGroupDeleted:
   179 		case EContactDbObserverEventGroupDeleted:
   177 #ifdef __PERFORMANCE_DATA
   183 #ifdef __PERFORMANCE_DATA
   178             iStartTime.UniversalTime();			
   184             iStartTime.UniversalTime();			
   179 			CreateContactIndexItemL(aEvent.iContactId, ECPixRemoveAction);
   185 			CreateContactIndexItemL(aEvent.iContactId, ECPixRemoveAction);
   180 			UpdatePerformaceDataL(ECPixRemoveAction);
   186 			UpdatePerformaceDataL(ECPixRemoveAction);
   181 #else
   187 #else
   182 			CreateContactIndexItemL(aEvent.iContactId, ECPixRemoveAction);
   188 			entry.iActionType = ECPixRemoveAction;
       
   189 			//CreateContactIndexItemL(aEvent.iContactId, ECPixRemoveAction);
   183 #endif
   190 #endif
   184 			break;
   191 			break;
   185 
   192 
   186 		case EContactDbObserverEventContactAdded:
   193 		case EContactDbObserverEventContactAdded:
   187 		case EContactDbObserverEventGroupAdded:
   194 		case EContactDbObserverEventGroupAdded:
   190 #ifdef __PERFORMANCE_DATA
   197 #ifdef __PERFORMANCE_DATA
   191             iStartTime.UniversalTime();			
   198             iStartTime.UniversalTime();			
   192 			CreateContactIndexItemL(aEvent.iContactId, ECPixUpdateAction);
   199 			CreateContactIndexItemL(aEvent.iContactId, ECPixUpdateAction);
   193 			UpdatePerformaceDataL(ECPixUpdateAction);
   200 			UpdatePerformaceDataL(ECPixUpdateAction);
   194 #else
   201 #else
   195 			CreateContactIndexItemL(aEvent.iContactId, ECPixAddAction);
   202 			entry.iActionType = ECPixAddAction;
       
   203 			//CreateContactIndexItemL(aEvent.iContactId, ECPixAddAction);
   196 #endif
   204 #endif
   197 			break;
   205 			break;
   198 
   206 
   199 		default:
   207 		default:
   200 			// Ignore other events
   208 			// Ignore other events
   201 			break;
   209 			break;
   202 		}
   210 		}
       
   211         if( iIndexState )
       
   212             CreateContactIndexItemL(aEvent.iContactId, entry.iActionType);
       
   213         else
       
   214             OverWriteOrAddToQueueL(entry);
   203 	}
   215 	}
   204 
   216 
   205 // -----------------------------------------------------------------------------
   217 // -----------------------------------------------------------------------------
   206 // CContactsPlugin::DelayedCallbackL
   218 // CContactsPlugin::DelayedCallbackL
   207 // -----------------------------------------------------------------------------
   219 // -----------------------------------------------------------------------------
   208 //
   220 //
   209 void CContactsPlugin::DelayedCallbackL( TInt /*aCode*/ )
   221 void CContactsPlugin::DelayedCallbackL( TInt /*aCode*/ )
   210     {
   222     {
   211 	if (!iContacts || !iObserver)
   223 	if (!iContacts || !iObserver)
   212 		return;
   224 		return;
   213 
   225 	
   214 	// may have changed - refresh the pointer
   226 	if(!iIndexState)
   215 	iContacts = iDatabase->SortedItemsL();
   227 	    return;
   216 
   228 	    
   217 	// Read the next set of contacts.
   229     // may have changed - refresh the pointer
   218 	for( TInt i = 0; i < KContactsPerRunL; i++ )
   230     iContacts = iDatabase->SortedItemsL();
   219 		{
   231 
   220 		// Exit the loop if no more contacts
   232     // Read the next set of contacts.
   221 		if (iCurrentIndex >= iContacts->Count())
   233     for( TInt i = 0; i < KContactsPerRunL; i++ )
   222 			break;
   234         {
   223 		
   235         // Exit the loop if no more contacts
   224 		// Create index item
   236         if (iCurrentIndex >= iContacts->Count())
   225 		OstTrace1( TRACE_NORMAL, CCONTACTSPLUGIN_DELAYEDCALLBACKL, "CContactsPlugin::DelayedCallbackL();Harvesting id=%d", (*iContacts)[iCurrentIndex] );
   237             break;
   226 		CPIXLOGSTRING2("CContactsPlugin::DelayedCallbackL(): Harvesting id=%d.", (*iContacts)[iCurrentIndex]);
   238     
   227 		CreateContactIndexItemL((*iContacts)[iCurrentIndex], ECPixAddAction);
   239         // Create index item
   228 		iCurrentIndex++;
   240         OstTrace1( TRACE_NORMAL, CCONTACTSPLUGIN_DELAYEDCALLBACKL, "CContactsPlugin::DelayedCallbackL();Harvesting id=%d", (*iContacts)[iCurrentIndex] );
   229 		}
   241         CPIXLOGSTRING2("CContactsPlugin::DelayedCallbackL(): Harvesting id=%d.", (*iContacts)[iCurrentIndex]);
   230 
   242         CreateContactIndexItemL((*iContacts)[iCurrentIndex], ECPixAddAction);
   231 	if( iAsynchronizer && (iCurrentIndex < iContacts->Count()) )
   243         iCurrentIndex++;
   232 	    {
   244         }
   233 	    // Launch the next RunL
   245 
       
   246     if( iAsynchronizer && (iCurrentIndex < iContacts->Count()) )
       
   247         {
       
   248         // Launch the next RunL
   234         iAsynchronizer->Start(0, this, KHarvestingDelay);
   249         iAsynchronizer->Start(0, this, KHarvestingDelay);
   235         }
   250         }
   236 	else
   251     else
   237 		{
   252         {
   238 		// Harvesting was successfully completed
   253         // Harvesting was successfully completed
   239 		Flush(*iIndexer);
   254         Flush(*iIndexer);
   240 #ifdef __PERFORMANCE_DATA
   255 #ifdef __PERFORMANCE_DATA
   241     UpdatePerformaceDataL();
   256     UpdatePerformaceDataL();
   242 #endif 
   257 #endif 
   243 		iObserver->HarvestingCompleted(this, iIndexer->GetBaseAppClass(), KErrNone);
   258         //On Harvesting completion mark status as Idle
   244 		}
   259         iHarvestState = EHarvesterIdleState;
       
   260         iObserver->HarvestingCompleted(this, iIndexer->GetBaseAppClass(), KErrNone);
       
   261         }
   245 	}
   262 	}
   246 
   263 
   247 void CContactsPlugin::DelayedError(TInt aError)
   264 void CContactsPlugin::DelayedError(TInt aError)
   248 	{
   265 	{
   249 	// Harvesting was successfully completed
   266 	// Harvesting was successfully completed
   250 	Flush(*iIndexer);
   267 	Flush(*iIndexer);
       
   268 	iHarvestState = EHarvesterIdleState;
   251 	iObserver->HarvestingCompleted(this, iIndexer->GetBaseAppClass(), aError);
   269 	iObserver->HarvestingCompleted(this, iIndexer->GetBaseAppClass(), aError);
   252 	}
   270 	}
   253 
   271 
   254 // ---------------------------------------------------------------------------
   272 // ---------------------------------------------------------------------------
   255 // CContactsPlugin::AddFieldL
   273 // CContactsPlugin::AddFieldL
   314 	{
   332 	{
   315 	// Find field
   333 	// Find field
   316 	TInt findpos = aFieldSet.Find( aFieldId );
   334 	TInt findpos = aFieldSet.Find( aFieldId );
   317 	if (! (findpos < 0) || (findpos >= aFieldSet.Count() ) )
   335 	if (! (findpos < 0) || (findpos >= aFieldSet.Count() ) )
   318 		{
   336 		{
   319 		CContactItemField& additionalField = aFieldSet[ findpos ];
   337 		CContactItemField& additionalField = aFieldSet[ findpos ];		
   320 		TInt newfieldsize = 0;
       
   321 		if( additionalField.StorageType() == KStorageTypeDateTime)
   338 		if( additionalField.StorageType() == KStorageTypeDateTime)
   322 		            {
   339 		            {
   323 		            CContactDateField* fieldDate = additionalField.DateTimeStorage();
   340 		            CContactDateField* fieldDate = additionalField.DateTimeStorage();
   324 		            if (fieldDate)
   341 		            if (fieldDate)
   325 		                {
   342 		                {
   375 	if (!iIndexer)
   392 	if (!iIndexer)
   376     	return;
   393     	return;
   377     
   394     
   378 	OstTrace1( TRACE_NORMAL, CCONTACTSPLUGIN_CREATECONTACTINDEXITEML, "CContactsPlugin::CreateContactIndexItemL();aContentId=%d", aContentId );
   395 	OstTrace1( TRACE_NORMAL, CCONTACTSPLUGIN_CREATECONTACTINDEXITEML, "CContactsPlugin::CreateContactIndexItemL();aContentId=%d", aContentId );
   379 	CPIXLOGSTRING2("CContactsPlugin::CreateContactIndexItemL(): aContentId = %d ", aContentId );
   396 	CPIXLOGSTRING2("CContactsPlugin::CreateContactIndexItemL(): aContentId = %d ", aContentId );
       
   397     OstTrace0( TRACE_NORMAL, DUP8_CCONTACTSPLUGIN_CREATECONTACTINDEXITEML, "CContactsPlugin::Indexing Contact" );
   380     
   398     
   381 	// creating CSearchDocument object with unique ID for this application
   399 	// creating CSearchDocument object with unique ID for this application
   382 	TBuf<20> docid_str;
   400 	TBuf<20> docid_str;
   383 	TBuf<2> isGroup;
   401 	TBuf<2> isGroup;
   384 	docid_str.AppendNum(aContentId);
   402 	docid_str.AppendNum(aContentId);
   396             isGroup.AppendNum(ETrue);
   414             isGroup.AppendNum(ETrue);
   397             index_item->AddFieldL( KContactIsGroup, isGroup, CDocumentField::EStoreYes | CDocumentField::EIndexNo );
   415             index_item->AddFieldL( KContactIsGroup, isGroup, CDocumentField::EStoreYes | CDocumentField::EIndexNo );
   398             index_item->AddFieldL( KContactsGivenNameField, static_cast<CContactGroup*>( contact )->GetGroupLabelL(), CDocumentField::EStoreYes | CDocumentField::EIndexTokenized );
   416             index_item->AddFieldL( KContactsGivenNameField, static_cast<CContactGroup*>( contact )->GetGroupLabelL(), CDocumentField::EStoreYes | CDocumentField::EIndexTokenized );
   399             OstTraceExt1( TRACE_NORMAL, DUP1_CCONTACTSPLUGIN_CREATECONTACTINDEXITEML, ";Adding Contact Group=%S", ( static_cast<CContactGroup*>( contact )->GetGroupLabelL() ) );
   417             OstTraceExt1( TRACE_NORMAL, DUP1_CCONTACTSPLUGIN_CREATECONTACTINDEXITEML, ";Adding Contact Group=%S", ( static_cast<CContactGroup*>( contact )->GetGroupLabelL() ) );
   400             CPIXLOGSTRING2("Adding Contact Group %S", &( static_cast<CContactGroup*>( contact )->GetGroupLabelL() ) );
   418             CPIXLOGSTRING2("Adding Contact Group %S", &( static_cast<CContactGroup*>( contact )->GetGroupLabelL() ) );
   401 #ifdef USE_HIGHLIGHTER
   419 //#ifdef USE_HIGHLIGHTER
   402             index_item->AddHLDisplayFieldL(static_cast<CContactGroup*>( contact )->GetGroupLabelL());
   420             index_item->AddHLDisplayFieldL(static_cast<CContactGroup*>( contact )->GetGroupLabelL());
   403 #else
   421 //#else
   404             index_item->AddExcerptL( static_cast<CContactGroup*>( contact )->GetGroupLabelL() );
   422 //            index_item->AddExcerptL( static_cast<CContactGroup*>( contact )->GetGroupLabelL() );
   405 #endif            
   423 //#endif            
   406 		    }
   424 		    }
   407 		else//If the contact item is a regular contact.
   425 		else//If the contact item is a regular contact.
   408 		    {
   426 		    {
   409             if (iExcerpt)
   427             if (iExcerpt)
   410                 {
   428                 {
   423              * is the order of fields shown when you 'Edit' the contact.
   441              * is the order of fields shown when you 'Edit' the contact.
   424              */
   442              */
   425 
   443 
   426             AddFieldL( *index_item, fieldSet, KUidContactFieldGivenName, KContactsGivenNameField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText );
   444             AddFieldL( *index_item, fieldSet, KUidContactFieldGivenName, KContactsGivenNameField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText );
   427             AddFieldL( *index_item, fieldSet, KUidContactFieldFamilyName, KContactsFamilyNameField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField:: EIndexFreeText );        
   445             AddFieldL( *index_item, fieldSet, KUidContactFieldFamilyName, KContactsFamilyNameField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField:: EIndexFreeText );        
   428 #ifdef USE_HIGHLIGHTER    
   446 //#ifdef USE_HIGHLIGHTER    
   429             if(iHLDisplayExcerpt)
   447             if(iHLDisplayExcerpt)
   430                 {
   448                 {
   431                 delete iHLDisplayExcerpt;
   449                 delete iHLDisplayExcerpt;
   432                 iHLDisplayExcerpt = NULL;
   450                 iHLDisplayExcerpt = NULL;
   433                 }
   451                 }
   434             AddFieldToHLExcerptL( fieldSet, KUidContactFieldGivenName);
   452             AddFieldToHLExcerptL( fieldSet, KUidContactFieldGivenName);
   435             AddFieldToHLExcerptL( fieldSet, KUidContactFieldFamilyName);
   453             AddFieldToHLExcerptL( fieldSet, KUidContactFieldFamilyName);
   436             if(iHLDisplayExcerpt)
   454             if(iHLDisplayExcerpt)
   437             index_item->AddHLDisplayFieldL(*iHLDisplayExcerpt);
   455             index_item->AddHLDisplayFieldL(*iHLDisplayExcerpt);
   438 #endif 
   456 //#endif 
   439             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldPhoneNumber, KContactsPhoneNumberField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexPhoneNumber );
   457             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldPhoneNumber, KContactsPhoneNumberField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexPhoneNumber );
   440             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldEMail, KContactsEMailField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText );
   458             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldEMail, KContactsEMailField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText );
   441             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldSIPID, KContactsSIPIDField );
   459             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldSIPID, KContactsSIPIDField );
   442             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldCompanyName, KContactsCompanyNameField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText );
   460             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldCompanyName, KContactsCompanyNameField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText );
   443             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldJobTitle, KContactsJobTitleField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText );
   461             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldJobTitle, KContactsJobTitleField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText );
   468             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldAssistant, KContactAssistant, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText);
   486             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldAssistant, KContactAssistant, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText);
   469             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldDepartmentName, KContactsDepartmentName, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText);
   487             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldDepartmentName, KContactsDepartmentName, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText);
   470             
   488             
   471             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldIMAddress, KContactIMAddress);
   489             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldIMAddress, KContactIMAddress);
   472             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldServiceProvider, KContactServiceProvider);
   490             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldServiceProvider, KContactServiceProvider);
   473 #ifdef USE_HIGHLIGHTER
   491 //#ifdef USE_HIGHLIGHTER
   474             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldBirthday, KContactBirthday);
   492             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldBirthday, KContactBirthday);
   475             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldAnniversary, KContactAnniversary);
   493             AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldAnniversary, KContactAnniversary);
   476 #else
   494 //#else
   477             AddFieldL( *index_item, fieldSet, KUidContactFieldBirthday, KContactBirthday);
   495 //            AddFieldL( *index_item, fieldSet, KUidContactFieldBirthday, KContactBirthday);
   478             AddFieldL( *index_item, fieldSet, KUidContactFieldAnniversary, KContactAnniversary);      
   496 //            AddFieldL( *index_item, fieldSet, KUidContactFieldAnniversary, KContactAnniversary);      
   479 #endif            
   497 //#endif            
   480             index_item->AddExcerptL(*iExcerpt);
   498             index_item->AddExcerptL(*iExcerpt);
   481             }
   499             }
   482         
   500         
   483     	index_item->AddFieldL(KMimeTypeField, KMimeTypeContact, CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
   501     	index_item->AddFieldL(KMimeTypeField, KMimeTypeContact, CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
   484         
   502         
   530 			CPIXLOGSTRING2("CContactsPlugin::CreateContactIndexItemL(): Error %d in deleting.", err);
   548 			CPIXLOGSTRING2("CContactsPlugin::CreateContactIndexItemL(): Error %d in deleting.", err);
   531 			}			
   549 			}			
   532 		}
   550 		}
   533     }
   551     }
   534 
   552 
   535 #ifdef USE_HIGHLIGHTER
   553 //#ifdef USE_HIGHLIGHTER
   536 void CContactsPlugin::AddFieldToHLExcerptL( CContactItemFieldSet& aFieldSet, TUid aFieldId)
   554 void CContactsPlugin::AddFieldToHLExcerptL( CContactItemFieldSet& aFieldSet, TUid aFieldId)
   537     {
   555     {
   538     if(!iHLDisplayExcerpt)
   556     if(!iHLDisplayExcerpt)
   539         {
   557         {
   540     iHLDisplayExcerpt = HBufC::NewL(2);
   558     iHLDisplayExcerpt = HBufC::NewL(2);
   543     TInt findpos = aFieldSet.Find(aFieldId);
   561     TInt findpos = aFieldSet.Find(aFieldId);
   544   
   562   
   545     if (! (findpos < 0) || (findpos >= aFieldSet.Count() ) )
   563     if (! (findpos < 0) || (findpos >= aFieldSet.Count() ) )
   546          {
   564          {
   547             CContactItemField& additionalField = aFieldSet[findpos];
   565             CContactItemField& additionalField = aFieldSet[findpos];
   548             CContactTextField* fieldText = additionalField.TextStorage();
   566             CContactTextField* fieldText = additionalField.TextStorage();            
   549             
       
   550             
   567             
   551             if (fieldText && fieldText->Text() != KNullDesC)//value is not Null
   568             if (fieldText && fieldText->Text() != KNullDesC)//value is not Null
   552                 {
   569                 {
   553                 TInt currentSize = iHLDisplayExcerpt->Size();
   570                 TInt currentSize = iHLDisplayExcerpt->Size();
   554                 TInt newSize = currentSize + fieldText->Text().Length() + 1;
   571                 TInt newSize = currentSize + fieldText->Text().Length() + 1;
   561         ptr.Append(KExcerptDelimiter);
   578         ptr.Append(KExcerptDelimiter);
   562                 }
   579                 }
   563         }    
   580         }    
   564     }
   581     }
   565 
   582 
   566 #endif
   583 //#endif
   567 
   584 
   568 // ---------------------------------------------------------------------------
   585 // ---------------------------------------------------------------------------
   569 // CContactsPlugin::GetDateL
   586 // CContactsPlugin::GetDateL
   570 // ---------------------------------------------------------------------------
   587 // ---------------------------------------------------------------------------
   571 //
   588 //
   588             time.FormatL(aDateString, KTimeFormat);
   605             time.FormatL(aDateString, KTimeFormat);
   589             }
   606             }
   590         }
   607         }
   591     }
   608     }
   592 
   609 
       
   610 void CContactsPlugin::PausePluginL()
       
   611     {
       
   612     OstTraceFunctionEntry0( CCONTACTSPLUGIN_PAUSEPLUGINL_ENTRY );
       
   613     iIndexState = EFalse;
       
   614     OstTraceFunctionExit0( CCONTACTSPLUGIN_PAUSEPLUGINL_EXIT );
       
   615     }
       
   616 
       
   617 void CContactsPlugin::ResumePluginL()
       
   618     {
       
   619     OstTraceFunctionEntry0( CCONTACTSPLUGIN_RESUMEPLUGINL_ENTRY );
       
   620     iIndexState = ETrue;
       
   621     
       
   622     if(iHarvestState == EHarvesterStartHarvest)
       
   623         {
       
   624         if(iAsynchronizer->CallbackPending())
       
   625             iAsynchronizer->CancelCallback();
       
   626         iAsynchronizer->Start( 0, this, KHarvestingDelay );
       
   627         }
       
   628     else
       
   629         {
       
   630         IndexQueuedItems();
       
   631         }
       
   632     OstTraceFunctionExit0( CCONTACTSPLUGIN_RESUMEPLUGINL_EXIT );
       
   633     }
       
   634 
       
   635 void CContactsPlugin::OverWriteOrAddToQueueL(TRecord& aEntry)
       
   636     {
       
   637     OstTraceFunctionEntry0( CCONTACTSPLUGIN_OVERWRITEORADDTOQUEUEL_ENTRY );
       
   638     for (TInt i=0; i<iJobQueue.Count(); i++)
       
   639         {
       
   640             if (iJobQueue[i].iContactId == aEntry.iContactId)
       
   641             {
       
   642                 // Older version found
       
   643                 iJobQueue[i] = aEntry;
       
   644                 OstTraceFunctionExit0( CCONTACTSPLUGIN_OVERWRITEORADDTOQUEUEL_EXIT );
       
   645                 return;
       
   646             }
       
   647         }        
       
   648     // older not found, append
       
   649     iJobQueue.AppendL(aEntry);
       
   650     OstTraceFunctionExit0( DUP1_CCONTACTSPLUGIN_OVERWRITEORADDTOQUEUEL_EXIT );
       
   651     }
       
   652 
       
   653 void CContactsPlugin::IndexQueuedItems()
       
   654     {
       
   655     OstTraceFunctionEntry0( CCONTACTSPLUGIN_INDEXQUEUEDITEMS_ENTRY );
       
   656     while (iJobQueue.Count()>0)
       
   657         {
       
   658         TRecord entry = iJobQueue[0];        
       
   659         //Let the indexer handle this object TRAP it as it can leave
       
   660         TRAPD(err,CreateContactIndexItemL( entry.iContactId, entry.iActionType ));        
       
   661         if(KErrNone == err)
       
   662             {
       
   663             iJobQueue.Remove(0);
       
   664             }
       
   665         }
       
   666     OstTraceFunctionExit0( CCONTACTSPLUGIN_INDEXQUEUEDITEMS_EXIT );
       
   667     }
   593 // ---------------------------------------------------------------------------
   668 // ---------------------------------------------------------------------------
   594 // CContactsPlugin::UpdatePerformaceDataL
   669 // CContactsPlugin::UpdatePerformaceDataL
   595 // ---------------------------------------------------------------------------
   670 // ---------------------------------------------------------------------------
   596 //	
   671 //	
   597 #ifdef __PERFORMANCE_DATA
   672 #ifdef __PERFORMANCE_DATA