371 OstTrace1( TRACE_NORMAL, CCONTACTSPLUGIN_CREATECONTACTINDEXITEML, "CContactsPlugin::CreateContactIndexItemL();aContentId=%d", aContentId ); |
378 OstTrace1( TRACE_NORMAL, CCONTACTSPLUGIN_CREATECONTACTINDEXITEML, "CContactsPlugin::CreateContactIndexItemL();aContentId=%d", aContentId ); |
372 CPIXLOGSTRING2("CContactsPlugin::CreateContactIndexItemL(): aContentId = %d ", aContentId ); |
379 CPIXLOGSTRING2("CContactsPlugin::CreateContactIndexItemL(): aContentId = %d ", aContentId ); |
373 |
380 |
374 // creating CSearchDocument object with unique ID for this application |
381 // creating CSearchDocument object with unique ID for this application |
375 TBuf<20> docid_str; |
382 TBuf<20> docid_str; |
|
383 TBuf<2> isGroup; |
376 docid_str.AppendNum(aContentId); |
384 docid_str.AppendNum(aContentId); |
377 |
385 |
378 if (aActionType == ECPixAddAction || aActionType == ECPixUpdateAction ) |
386 if (aActionType == ECPixAddAction || aActionType == ECPixUpdateAction ) |
379 { |
387 { |
380 CSearchDocument* index_item = CSearchDocument::NewLC(docid_str, _L(CONTACTAPPCLASS)); |
388 CSearchDocument* index_item = CSearchDocument::NewLC(docid_str, _L(CONTACTAPPCLASS)); |
382 // Add fields |
390 // Add fields |
383 CContactItem* contact = iDatabase->ReadMinimalContactL(aContentId); |
391 CContactItem* contact = iDatabase->ReadMinimalContactL(aContentId); |
384 CleanupStack::PushL( contact ); |
392 CleanupStack::PushL( contact ); |
385 if( contact->Type() == KUidContactGroup ) |
393 if( contact->Type() == KUidContactGroup ) |
386 { |
394 { |
387 index_item->AddFieldL(KContactsGivenNameField, static_cast<CContactGroup*>( contact )->GetGroupLabelL(), CDocumentField::EStoreYes | CDocumentField::EIndexTokenized); |
395 // Added IsGroup field to differenciate Group with contacts, its value made true in case of groups |
|
396 isGroup.AppendNum(ETrue); |
|
397 index_item->AddFieldL( KContactIsGroup, isGroup, CDocumentField::EStoreYes | CDocumentField::EIndexNo ); |
|
398 index_item->AddFieldL( KContactsGivenNameField, static_cast<CContactGroup*>( contact )->GetGroupLabelL(), CDocumentField::EStoreYes | CDocumentField::EIndexTokenized ); |
388 OstTraceExt1( TRACE_NORMAL, DUP1_CCONTACTSPLUGIN_CREATECONTACTINDEXITEML, ";Adding Contact Group=%S", ( static_cast<CContactGroup*>( contact )->GetGroupLabelL() ) ); |
399 OstTraceExt1( TRACE_NORMAL, DUP1_CCONTACTSPLUGIN_CREATECONTACTINDEXITEML, ";Adding Contact Group=%S", ( static_cast<CContactGroup*>( contact )->GetGroupLabelL() ) ); |
389 CPIXLOGSTRING2("Adding Contact Group %S", &( static_cast<CContactGroup*>( contact )->GetGroupLabelL() ) ); |
400 CPIXLOGSTRING2("Adding Contact Group %S", &( static_cast<CContactGroup*>( contact )->GetGroupLabelL() ) ); |
|
401 #ifdef USE_HIGHLIGHTER |
|
402 index_item->AddHLDisplayFieldL(static_cast<CContactGroup*>( contact )->GetGroupLabelL()); |
|
403 #else |
390 index_item->AddExcerptL( static_cast<CContactGroup*>( contact )->GetGroupLabelL() ); |
404 index_item->AddExcerptL( static_cast<CContactGroup*>( contact )->GetGroupLabelL() ); |
|
405 #endif |
391 } |
406 } |
392 else//If the contact item is a regular contact. |
407 else//If the contact item is a regular contact. |
393 { |
408 { |
394 if (iExcerpt) |
409 if (iExcerpt) |
395 { |
410 { |
397 iExcerpt = NULL; |
412 iExcerpt = NULL; |
398 } |
413 } |
399 iExcerpt = HBufC::NewL(2); |
414 iExcerpt = HBufC::NewL(2); |
400 |
415 |
401 CContactItemFieldSet& fieldSet = contact->CardFields(); |
416 CContactItemFieldSet& fieldSet = contact->CardFields(); |
402 |
417 //IsGroup value made false in case of contact |
|
418 isGroup.AppendNum(EFalse); |
|
419 index_item->AddFieldL( KContactIsGroup, isGroup,CDocumentField::EStoreYes | CDocumentField::EIndexNo); |
403 //For contacts, all fields __except__ GivenName and FamilyName should be added to excerpt. |
420 //For contacts, all fields __except__ GivenName and FamilyName should be added to excerpt. |
404 //See appclass-hierarchy.txt for details. |
421 //See appclass-hierarchy.txt for details. |
405 /* The order of fields in excerpt is as below. The order in this case |
422 /* The order of fields in excerpt is as below. The order in this case |
406 * is the order of fields shown when you 'Edit' the contact. |
423 * is the order of fields shown when you 'Edit' the contact. |
407 */ |
424 */ |
408 #ifdef USE_HIGHLIGHTER |
425 |
409 AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldGivenName, KContactsGivenNameField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText ); |
|
410 AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldFamilyName, KContactsFamilyNameField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField:: EIndexFreeText ); |
|
411 #else |
|
412 AddFieldL( *index_item, fieldSet, KUidContactFieldGivenName, KContactsGivenNameField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText ); |
426 AddFieldL( *index_item, fieldSet, KUidContactFieldGivenName, KContactsGivenNameField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText ); |
413 AddFieldL( *index_item, fieldSet, KUidContactFieldFamilyName, KContactsFamilyNameField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField:: EIndexFreeText ); |
427 AddFieldL( *index_item, fieldSet, KUidContactFieldFamilyName, KContactsFamilyNameField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField:: EIndexFreeText ); |
414 #endif |
428 #ifdef USE_HIGHLIGHTER |
|
429 if(iHLDisplayExcerpt) |
|
430 { |
|
431 delete iHLDisplayExcerpt; |
|
432 iHLDisplayExcerpt = NULL; |
|
433 } |
|
434 AddFieldToHLExcerptL( fieldSet, KUidContactFieldGivenName); |
|
435 AddFieldToHLExcerptL( fieldSet, KUidContactFieldFamilyName); |
|
436 if(iHLDisplayExcerpt) |
|
437 index_item->AddHLDisplayFieldL(*iHLDisplayExcerpt); |
|
438 #endif |
415 AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldPhoneNumber, KContactsPhoneNumberField ); |
439 AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldPhoneNumber, KContactsPhoneNumberField ); |
416 AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldEMail, KContactsEMailField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText ); |
440 AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldEMail, KContactsEMailField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText ); |
417 AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldSIPID, KContactsSIPIDField ); |
441 AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldSIPID, KContactsSIPIDField ); |
418 AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldCompanyName, KContactsCompanyNameField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText ); |
442 AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldCompanyName, KContactsCompanyNameField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText ); |
419 AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldJobTitle, KContactsJobTitleField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText ); |
443 AddFieldToDocumentAndExcerptL( *index_item, fieldSet, KUidContactFieldJobTitle, KContactsJobTitleField, CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText ); |
506 CPIXLOGSTRING2("CContactsPlugin::CreateContactIndexItemL(): Error %d in deleting.", err); |
530 CPIXLOGSTRING2("CContactsPlugin::CreateContactIndexItemL(): Error %d in deleting.", err); |
507 } |
531 } |
508 } |
532 } |
509 } |
533 } |
510 |
534 |
|
535 #ifdef USE_HIGHLIGHTER |
|
536 void CContactsPlugin::AddFieldToHLExcerptL( CContactItemFieldSet& aFieldSet, TUid aFieldId) |
|
537 { |
|
538 if(!iHLDisplayExcerpt) |
|
539 { |
|
540 iHLDisplayExcerpt = HBufC::NewL(2); |
|
541 } |
|
542 // Find field |
|
543 TInt findpos = aFieldSet.Find(aFieldId); |
|
544 |
|
545 if (! (findpos < 0) || (findpos >= aFieldSet.Count() ) ) |
|
546 { |
|
547 CContactItemField& additionalField = aFieldSet[findpos]; |
|
548 CContactTextField* fieldText = additionalField.TextStorage(); |
|
549 |
|
550 |
|
551 if (fieldText && fieldText->Text() != KNullDesC)//value is not Null |
|
552 { |
|
553 TInt currentSize = iHLDisplayExcerpt->Size(); |
|
554 TInt newSize = currentSize + fieldText->Text().Length() + 1; |
|
555 if(newSize > currentSize) //New size is bigger so we have to reallocate |
|
556 { |
|
557 iHLDisplayExcerpt = iHLDisplayExcerpt->ReAllocL(newSize); |
|
558 } |
|
559 TPtr ptr = iHLDisplayExcerpt->Des(); |
|
560 ptr.Append(fieldText->Text()); |
|
561 ptr.Append(KExcerptDelimiter); |
|
562 } |
|
563 } |
|
564 } |
|
565 |
|
566 #endif |
|
567 |
511 // --------------------------------------------------------------------------- |
568 // --------------------------------------------------------------------------- |
512 // CContactsPlugin::GetDateL |
569 // CContactsPlugin::GetDateL |
513 // --------------------------------------------------------------------------- |
570 // --------------------------------------------------------------------------- |
514 // |
571 // |
515 void CContactsPlugin::GetDateL(const TDesC& aTime, TDes& aDateString) |
572 void CContactsPlugin::GetDateL(const TDesC& aTime, TDes& aDateString) |