26 |
26 |
27 // INCLUDE FILES |
27 // INCLUDE FILES |
28 #include <barsc.h> // resource file |
28 #include <barsc.h> // resource file |
29 #include <bautils.h> |
29 #include <bautils.h> |
30 #include <miutpars.h> // e-mail utilities |
30 #include <miutpars.h> // e-mail utilities |
31 #include "cimconvertcharconv.h" |
31 |
32 #include "cimconvertheader.h" |
|
33 #include <miutconv.h> // CharConv |
32 #include <miutconv.h> // CharConv |
34 #include <flogger.h> |
33 #include <flogger.h> |
35 #include <e32svr.h> |
34 #include <e32svr.h> |
36 #include <e32base.h> |
35 #include <e32base.h> |
|
36 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
37 #include <imcvcodc.h> |
37 #include <imcvcodc.h> |
|
38 #else |
|
39 #include <imcvcodc.h> |
|
40 #include <cimconvertheader.h> |
|
41 #endif |
38 #include <f32file.h> |
42 #include <f32file.h> |
39 #include <UiklafInternalCRKeys.h> |
43 #include <UiklafInternalCRKeys.h> |
40 // #include <telconfigcrkeys.h> |
44 #include <telconfigcrkeys.h> |
41 #include <centralrepository.h> |
45 #include <centralrepository.h> |
42 #include <CoreApplicationUIsSDKCRKeys.h> |
46 #include <CoreApplicationUIsSDKCRKeys.h> |
43 #include <data_caging_path_literals.hrh> |
47 #include <data_caging_path_literals.hrh> |
44 |
48 |
45 |
49 #include <MVPbkContactStore.h> |
46 #include "telconfigcrkeys.h" |
50 #include <MVPbkContactStoreProperties.h> |
|
51 #include <MVPbkContactLink.h> |
|
52 #include <CPbk2StoreConfiguration.h> // Contact store configuration |
|
53 #include <contactmatcher.h> // contact match wrapper |
|
54 #include <CVPbkPhoneNumberMatchStrategy.h> |
|
55 #include <CVPbkContactLinkArray.h> |
|
56 #include <CVPbkFieldTypeRefsList.h> |
|
57 #include <TVPbkFieldVersitProperty.h> |
|
58 #include <VPbkFieldType.hrh> |
|
59 #include <MVPbkStoreContactFieldCollection.h> |
|
60 #include <MVPbkStoreContact.h> |
|
61 #include <CVPbkContactStoreUriArray.h> |
|
62 #include <VPbkContactStoreUris.h> |
|
63 #include <TVPbkContactStoreUriPtr.h> |
47 #include "mmsgenutils.h" |
64 #include "mmsgenutils.h" |
48 #include "MmsEnginePrivateCRKeys.h" |
65 #include "MmsEnginePrivateCRKeys.h" |
49 |
66 |
50 // EXTERNAL DATA STRUCTURES |
67 // EXTERNAL DATA STRUCTURES |
51 |
68 |
52 // EXTERNAL FUNCTION PROTOTYPES |
69 // EXTERNAL FUNCTION PROTOTYPES |
53 |
70 |
54 // CONSTANTS |
71 // CONSTANTS |
55 |
72 const TInt KLogBufferLength = 256; |
56 #ifdef _DEBUG |
73 #ifdef _DEBUG |
57 const TInt KLogBufferLength = 256; |
|
58 _LIT( KLogDir, "mmsc" ); |
74 _LIT( KLogDir, "mmsc" ); |
59 _LIT( KLogFile, "mmsc.txt" ); |
75 _LIT( KLogFile, "mmsc.txt" ); |
60 #endif |
76 #endif |
61 |
77 const TUint KMinAliasMaxLength = 14; |
62 const TUint KExtraSpaceForConversion10 = 10; |
78 const TUint KExtraSpaceForConversion10 = 10; |
63 const TUint KExtraSpaceForConversion30 = 30; |
79 const TUint KExtraSpaceForConversion30 = 30; |
64 |
80 |
65 |
81 const TInt KErrMultipleMatchFound = KErrGeneral; |
66 // MACROS |
82 // MACROS |
67 |
83 |
68 // LOCAL CONSTANTS AND MACROS |
84 // LOCAL CONSTANTS AND MACROS |
69 |
85 |
70 // MODULE DATA STRUCTURES |
86 // MODULE DATA STRUCTURES |
435 // addresses. This significantly reduces processing time |
457 // addresses. This significantly reduces processing time |
436 // when executing "Create Reply to all" with a lot of addresses |
458 // when executing "Create Reply to all" with a lot of addresses |
437 // --------------------------------------------------------- |
459 // --------------------------------------------------------- |
438 // |
460 // |
439 EXPORT_C void TMmsGenUtils::GetAliasForAllL( |
461 EXPORT_C void TMmsGenUtils::GetAliasForAllL( |
440 const CDesCArray& /*aAddress*/, |
462 const CDesCArray& aAddress, |
441 CDesCArray& /*aAlias*/, |
463 CDesCArray& aAlias, |
442 TInt /*aMaxLength*/, |
464 TInt aMaxLength, |
443 RFs& /*aFs*/ ) |
465 RFs& aFs ) |
444 { |
466 { |
445 |
467 |
446 |
468 if ( aMaxLength <= 0 ) |
|
469 { |
|
470 User::Leave( KErrArgument ); |
|
471 } |
|
472 |
|
473 TUint stack = 0; |
|
474 |
|
475 //Let's find the number of digits to match |
|
476 TInt digitsToMatch = DigitsToMatch(); |
|
477 TInt err = KErrNone; |
|
478 |
|
479 // Use contact wrapper to open all databases |
|
480 CContactMatcher* contactMatcher = OpenAllStoresL( aFs ); |
|
481 CleanupStack::PushL( contactMatcher ); |
|
482 stack++; |
|
483 |
|
484 HBufC* helpBuffer = HBufC::NewL( aMaxLength ); |
|
485 CleanupStack::PushL( helpBuffer ); |
|
486 stack++; |
|
487 |
|
488 TPtr pHelpBuffer = helpBuffer->Des(); |
|
489 |
|
490 for ( TInt i = 0; i < aAddress.MdcaCount(); i++ ) |
|
491 { |
|
492 // We trap these one by one in order to be able |
|
493 // to continue to next match in case of error (not found) |
|
494 |
|
495 // make sure the alias is empty if nothing found |
|
496 pHelpBuffer.Zero(); |
|
497 |
|
498 TRAP( err, DoGetAliasL( |
|
499 aAddress.MdcaPoint(i), |
|
500 pHelpBuffer, |
|
501 aMaxLength, |
|
502 *contactMatcher, |
|
503 digitsToMatch ) ); |
|
504 |
|
505 // if alias is not found, we'll have an empty buffer |
|
506 // We have to insert it anyway to keep the indexes correct |
|
507 // as we have two parallel arrays |
|
508 aAlias.InsertL( i, pHelpBuffer ); |
|
509 } |
|
510 |
|
511 // closing is best effort only. |
|
512 TRAP_IGNORE( contactMatcher->CloseStoresL() ); |
|
513 CleanupStack::PopAndDestroy( stack, contactMatcher ); //contactMatcher, helpBuffer |
|
514 |
447 } |
515 } |
448 |
516 |
449 // --------------------------------------------------------- |
517 // --------------------------------------------------------- |
450 // TMmsGenUtils::GenerateAddress |
518 // TMmsGenUtils::GenerateAddress |
451 // --------------------------------------------------------- |
519 // --------------------------------------------------------- |
734 // --------------------------------------------------------- |
802 // --------------------------------------------------------- |
735 // TMmsGenUtils::DoGetAliasL |
803 // TMmsGenUtils::DoGetAliasL |
736 // --------------------------------------------------------- |
804 // --------------------------------------------------------- |
737 // |
805 // |
738 void TMmsGenUtils::DoGetAliasL( |
806 void TMmsGenUtils::DoGetAliasL( |
739 RFs& /*aFs*/, |
807 RFs& aFs, |
740 const TDesC& /*aAddress*/, |
808 const TDesC& aAddress, |
741 TDes& /*aAlias*/, |
809 TDes& aAlias, |
742 TInt /*aMaxLength*/ ) |
810 TInt aMaxLength ) |
743 { |
811 { |
744 |
812 |
|
813 //Let's find the number of digits to match |
|
814 TInt digitsToMatch = DigitsToMatch(); |
|
815 |
|
816 // We have only one address and one alias to put into the array |
|
817 CDesCArray* aliasArray = new ( ELeave )CDesCArrayFlat( 1 ); |
|
818 CleanupStack::PushL( aliasArray ); |
|
819 |
|
820 CDesCArray* realAddressArray = new ( ELeave )CDesCArrayFlat( 1 ); |
|
821 CleanupStack::PushL( realAddressArray ); |
|
822 |
|
823 realAddressArray->InsertL( 0, aAddress ); |
|
824 |
|
825 // GetAliasForAllL opens contact matcher |
|
826 GetAliasForAllL( *realAddressArray, *aliasArray, aMaxLength, aFs ); |
|
827 |
|
828 TInt size = aliasArray->MdcaCount(); |
|
829 |
|
830 if ( size > 0 ) |
|
831 { |
|
832 // only one item in our array |
|
833 aAlias.Copy( aliasArray->MdcaPoint( 0 ).Left( Min( aMaxLength, aAlias.MaxLength() ) ) ); |
|
834 } |
|
835 |
|
836 CleanupStack::PopAndDestroy( realAddressArray ); |
|
837 CleanupStack::PopAndDestroy( aliasArray ); |
|
838 |
|
839 return; |
|
840 |
745 } |
841 } |
746 |
842 |
747 |
843 |
748 // --------------------------------------------------------- |
844 // --------------------------------------------------------- |
749 // TMmsGenUtils::DoGetAliasL |
845 // TMmsGenUtils::DoGetAliasL |
750 // --------------------------------------------------------- |
846 // --------------------------------------------------------- |
751 // |
847 // |
752 void TMmsGenUtils::DoGetAliasL( |
848 void TMmsGenUtils::DoGetAliasL( |
753 const TDesC& /*aAddress*/, |
849 const TDesC& aAddress, |
754 TDes& /*aAlias*/, |
850 TDes& aAlias, |
755 TInt /*aMaxLength*/, |
851 TInt aMaxLength, |
756 CContactMatcher& /*aContactMatcher*/, |
852 CContactMatcher& aContactMatcher, |
757 TInt /*aDigitsToMatch*/ ) |
853 TInt aDigitsToMatch ) |
758 { |
854 { |
|
855 // It appears that with the new phonebook system with multiple phonebooks, |
|
856 // TContactItemId type id cannot be extracted. |
|
857 // The result contains MVPbkContactLink type objects. |
|
858 |
|
859 // The given descriptor has to be at least 14 in length |
|
860 // (otherwise this method would leave later) |
|
861 if( aAlias.MaxLength() < KMinAliasMaxLength ) |
|
862 { |
|
863 User::Leave( KErrBadDescriptor ); |
|
864 } |
|
865 |
|
866 // These should be inline with each other, but if necessary, |
|
867 // size down aMaxLength. |
|
868 // aMaxLength, however, can be smaller than the buffer |
|
869 if ( aMaxLength > aAlias.MaxLength() ) |
|
870 { |
|
871 aMaxLength = aAlias.MaxLength(); |
|
872 } |
|
873 |
|
874 if ( aMaxLength > 0 ) |
|
875 { |
|
876 // set length of alias to 0 |
|
877 // this can be used to determine if alias was found |
|
878 // contact id not needed or used |
|
879 aAlias.Zero(); |
|
880 } |
|
881 |
|
882 // Convert to real address just in case. The address should be pure already, |
|
883 // but we are just being paranoid... |
|
884 |
|
885 TPtrC realAddress; |
|
886 realAddress.Set( PureAddress( aAddress, KSepaOpen, KSepaClose ) ); |
|
887 CVPbkContactLinkArray* linkArray = CVPbkContactLinkArray::NewL(); |
|
888 CleanupStack::PushL( linkArray ); |
|
889 |
|
890 // Check if the address is phone number or EMail address |
|
891 if ( IsValidMMSPhoneAddress( realAddress, ETrue ) ) |
|
892 { |
|
893 // Lookup the telephone number in the contact database |
|
894 // For numbers shorter than 7 digits, only exact matches are returned |
|
895 |
|
896 aContactMatcher.MatchPhoneNumberL( realAddress, aDigitsToMatch, |
|
897 CVPbkPhoneNumberMatchStrategy::EVPbkMatchFlagsNone, *linkArray ); |
|
898 |
|
899 // If more than one matches have been found, |
|
900 // the first one will be used. |
|
901 } |
|
902 else if ( IsValidEmailAddress( realAddress ) ) |
|
903 { |
|
904 // Try to match with EMail address |
|
905 |
|
906 TVPbkFieldVersitProperty prop; |
|
907 CVPbkFieldTypeRefsList* fieldTypes = CVPbkFieldTypeRefsList::NewL(); |
|
908 CleanupStack::PushL( fieldTypes ); |
|
909 |
|
910 const MVPbkFieldTypeList& fieldTypeList = aContactMatcher.FieldTypes(); |
|
911 const MVPbkFieldType* foundType = NULL; |
|
912 |
|
913 prop.SetName( EVPbkVersitNameEMAIL ); |
|
914 /* |
|
915 // Remove code because matching matches properies, too. |
|
916 // We don't care about properties. |
|
917 |
|
918 // The phonebook should provide a function that allows mathcing name only |
|
919 foundType = fieldTypeList.FindMatch( prop, 0 ); |
|
920 |
|
921 if ( foundType ) |
|
922 { |
|
923 fieldTypes->AppendL( *foundType ); |
|
924 } |
|
925 */ |
|
926 |
|
927 // The field type matching does not work because it tries to match |
|
928 // parameters we are not interested in. |
|
929 // We try to generate a list that has all entries with versit type EMAIL |
|
930 |
|
931 TInt i; |
|
932 for ( i = 0; i < fieldTypeList.FieldTypeCount(); i++ ) |
|
933 { |
|
934 foundType = &(fieldTypeList.FieldTypeAt( i )); |
|
935 if ( foundType->VersitProperties().Count() > 0 |
|
936 && foundType->VersitProperties()[0].Name() == prop.Name() ) |
|
937 { |
|
938 fieldTypes->AppendL( *foundType ); |
|
939 } |
|
940 } |
|
941 |
|
942 |
|
943 // Here we stop at first match - email addresses should be unique |
|
944 aContactMatcher.MatchDataL( realAddress, *fieldTypes, *linkArray ); |
|
945 CleanupStack::PopAndDestroy( fieldTypes ); |
|
946 } |
|
947 else |
|
948 { |
|
949 User::Leave( KErrNotFound ); |
|
950 } |
|
951 |
|
952 TInt nameIndex = 0; //correct index if only one match is found |
|
953 if( linkArray->Count() == 0 ) |
|
954 { |
|
955 Log( _L( "No match found" ) ); |
|
956 User::Leave( KErrNotFound ); |
|
957 } |
|
958 else if( linkArray->Count() > 1 ) |
|
959 { |
|
960 //Multiple matches found. Get the current store single match index if any. |
|
961 nameIndex = GetCurrentStoreIndexL( *linkArray ); |
|
962 if( nameIndex == KErrMultipleMatchFound ) |
|
963 { |
|
964 /* No unique match in current store, Hence show the name only if all the matches have |
|
965 * identical names |
|
966 */ |
|
967 if( ShowContactNameL( linkArray, nameIndex, aContactMatcher) == EFalse) |
|
968 { |
|
969 Log( _L( "No (Perfect) match found" ) ); |
|
970 User::Leave( KErrMultipleMatchFound ); |
|
971 } |
|
972 } |
|
973 } |
|
974 |
|
975 // if not interested in alias, skip this |
|
976 if ( aMaxLength > 0 ) |
|
977 { |
|
978 HBufC* alias = GetContactNameL( linkArray->At(nameIndex), aContactMatcher ); |
|
979 if ( alias && alias->Des().Length() > 0 ) |
|
980 { |
|
981 aAlias.Copy( alias->Des().Left( aMaxLength ) ); |
|
982 } |
|
983 else |
|
984 { |
|
985 aAlias.Copy( TPtrC() ); |
|
986 } |
|
987 delete alias; |
|
988 alias = NULL; |
|
989 // end of part skipped if not interested in alias |
|
990 } |
|
991 |
|
992 linkArray->ResetAndDestroy(); |
|
993 CleanupStack::PopAndDestroy( linkArray ); |
759 } |
994 } |
760 |
995 |
761 // --------------------------------------------------------- |
996 // --------------------------------------------------------- |
762 // TMmsGenUtils::ConvertEscapesFromUri |
997 // TMmsGenUtils::ConvertEscapesFromUri |
763 // --------------------------------------------------------- |
998 // --------------------------------------------------------- |
1191 |
1426 |
1192 // --------------------------------------------------------- |
1427 // --------------------------------------------------------- |
1193 // TMmsGenUtils::OpenAllStoresL |
1428 // TMmsGenUtils::OpenAllStoresL |
1194 // |
1429 // |
1195 // --------------------------------------------------------- |
1430 // --------------------------------------------------------- |
1196 CContactMatcher* TMmsGenUtils::OpenAllStoresL( RFs& /*aFs*/ ) |
1431 CContactMatcher* TMmsGenUtils::OpenAllStoresL( RFs& aFs ) |
1197 { |
1432 { |
1198 // Use contact wrapper to open all databases |
1433 // Use contact wrapper to open all databases |
1199 /* CContactMatcher* contactMatcher = CContactMatcher::NewL( &aFs ); |
1434 CContactMatcher* contactMatcher = CContactMatcher::NewL( &aFs ); |
1200 CleanupStack::PushL( contactMatcher ); |
1435 CleanupStack::PushL( contactMatcher ); |
1201 |
1436 |
1202 contactMatcher->OpenDefaultMatchStoresL(); |
1437 contactMatcher->OpenDefaultMatchStoresL(); |
1203 |
1438 |
1204 CleanupStack::Pop( contactMatcher ); |
1439 CleanupStack::Pop( contactMatcher ); |
1205 return contactMatcher;*/ |
1440 return contactMatcher; |
1206 return NULL; |
|
1207 } |
1441 } |
1208 |
1442 |
1209 // ----------------------------------------------------------------------------- |
1443 // ----------------------------------------------------------------------------- |
1210 // TMmsGenUtils::GetContactNameL |
1444 // TMmsGenUtils::GetContactNameL |
1211 // ----------------------------------------------------------------------------- |
1445 // ----------------------------------------------------------------------------- |
1212 // |
1446 // |
1213 HBufC* TMmsGenUtils::GetContactNameL( |
1447 HBufC* TMmsGenUtils::GetContactNameL( |
1214 const MVPbkContactLink& /*aContactLink*/, |
1448 const MVPbkContactLink& aContactLink, |
1215 CContactMatcher& /*aContactMatcher*/) |
1449 CContactMatcher &aContactMatcher) |
1216 { |
1450 { |
1217 |
1451 Log(_L( "- TMmsGenUtils::GetContactNameL -> start" ) ); |
1218 return NULL; |
1452 MVPbkStoreContact* tempContact; |
|
1453 aContactMatcher.GetStoreContactL(aContactLink, &tempContact); |
|
1454 tempContact->PushL(); |
|
1455 |
|
1456 MVPbkStoreContactFieldCollection& coll = tempContact->Fields(); |
|
1457 HBufC* nameBuff = aContactMatcher.GetNameL( coll ); |
|
1458 |
|
1459 CleanupStack::PopAndDestroy(tempContact); // tempContact |
|
1460 |
|
1461 Log( _L( "- TMmsGenUtils::GetContactNameL <- end" ) ); |
|
1462 return nameBuff; |
1219 } |
1463 } |
1220 |
1464 |
1221 // ----------------------------------------------------------------------------- |
1465 // ----------------------------------------------------------------------------- |
1222 // TMmsGenUtils::GetContactNameInLowerCaseL |
1466 // TMmsGenUtils::GetContactNameInLowerCaseL |
1223 // ----------------------------------------------------------------------------- |
1467 // ----------------------------------------------------------------------------- |
1241 // ----------------------------------------------------------------------------- |
1485 // ----------------------------------------------------------------------------- |
1242 // TMmsGenUtils::ShowContactNameL |
1486 // TMmsGenUtils::ShowContactNameL |
1243 // ----------------------------------------------------------------------------- |
1487 // ----------------------------------------------------------------------------- |
1244 // |
1488 // |
1245 TBool TMmsGenUtils::ShowContactNameL( |
1489 TBool TMmsGenUtils::ShowContactNameL( |
1246 CVPbkContactLinkArray* /*aLinkArray*/, |
1490 CVPbkContactLinkArray* aLinkArray, |
1247 TInt& /*aNameIndex*/, |
1491 TInt &aNameIndex, |
1248 CContactMatcher& /*aContactMatcher*/) |
1492 CContactMatcher &aContactMatcher) |
1249 { |
1493 { |
1250 return 0; |
1494 Log( _L("- TMmsGenUtils::ShowContactName -> start") ); |
|
1495 Log( _L("Contact Match statistics to follow..." ) ); |
|
1496 Log( _L("Match count: %d"), aLinkArray->Count() ); |
|
1497 /* TODO:: compare the names upto standard |
|
1498 * 1. if all the names are same - display the name |
|
1499 * eg: "abcdef xyz" && "abcdef xyz" |
|
1500 * 2. find min name legth among all,(if ONLY Part-match is needed ) |
|
1501 * if this length is > standard length and matches upto standard length - display the larger name. |
|
1502 * eg: abcdef xyz123, abcdef xyz12, abcdef xyz and std length is 10, |
|
1503 * since match upto 10 chars is fine, display abcdef xyz123 |
|
1504 * 3. in any other case do not show name |
|
1505 * eg: abcdef xyz , abcde xyz |
|
1506 * abcdef xyz , abcdef xy |
|
1507 * abcdef xyz , abcde |
|
1508 */ |
|
1509 TInt i, minLength = 999, maxLength = 0, length = 0, maxLengthIndex = 0, stdLength = 14; |
|
1510 TBool retVal = ETrue ; |
|
1511 |
|
1512 for( i = 0 ; i < aLinkArray->Count(); i++ ) |
|
1513 { |
|
1514 HBufC* alias = GetContactNameL( aLinkArray->At(i), aContactMatcher ); |
|
1515 Log( _L(":-> %s" ), alias->Des().PtrZ()); |
|
1516 length = alias->Des().Length(); |
|
1517 if(minLength > length) |
|
1518 { |
|
1519 minLength = length; |
|
1520 } |
|
1521 if(maxLength < length) |
|
1522 { |
|
1523 maxLength = length; |
|
1524 maxLengthIndex = i; |
|
1525 } |
|
1526 delete alias; |
|
1527 alias = NULL; |
|
1528 } |
|
1529 |
|
1530 Log( _L( "Contact Lengths: Std Length : %d\n MinLength : %d\n MaxLength : %d\n MaxLen index: %d" ), |
|
1531 stdLength, |
|
1532 minLength, |
|
1533 maxLength, |
|
1534 maxLengthIndex); |
|
1535 |
|
1536 if(minLength != maxLength) |
|
1537 { |
|
1538 //complete length match not possible |
|
1539 retVal = EFalse; |
|
1540 |
|
1541 /* NOTE: |
|
1542 * Uncomment below code if partial length(upto stdLength) match is sufficient, |
|
1543 * ensure stdLength is correct |
|
1544 */ |
|
1545 /* |
|
1546 if(minLength < stdLength) |
|
1547 { |
|
1548 retVal = EFalse; |
|
1549 } |
|
1550 */ |
|
1551 } |
|
1552 |
|
1553 if( retVal ) |
|
1554 { |
|
1555 TInt ret; |
|
1556 HBufC* longestName = GetContactNameInLowerCaseL( aLinkArray->At(maxLengthIndex), aContactMatcher ); |
|
1557 Log( _L( "Longest name:-> %s" ), longestName->Des().PtrZ()); |
|
1558 for ( i = 0; i < aLinkArray->Count() && retVal; i++ ) |
|
1559 { |
|
1560 HBufC* nameI = GetContactNameInLowerCaseL( aLinkArray->At(i), aContactMatcher ); |
|
1561 Log( _L( "compared with -> %s" ), nameI->Des().PtrZ()); |
|
1562 ret = longestName->Find(nameI->Des()); |
|
1563 if(ret == KErrNotFound || ret != 0) |
|
1564 { |
|
1565 Log( _L( "Part/Full Match error/offset: %d" ), ret); |
|
1566 retVal = EFalse; |
|
1567 } |
|
1568 delete nameI; |
|
1569 nameI = NULL; |
|
1570 } |
|
1571 delete longestName; |
|
1572 longestName = NULL; |
|
1573 } |
|
1574 |
|
1575 aNameIndex = maxLengthIndex; |
|
1576 |
|
1577 Log( _L( "Final Match result : %d\n Final Match index : %d" ), retVal, maxLengthIndex); |
|
1578 Log( _L( "- TMmsGenUtils::ShowContactName <- end" ) ); |
|
1579 |
|
1580 return retVal; |
1251 } |
1581 } |
1252 |
1582 |
1253 // ----------------------------------------------------------------------------- |
1583 // ----------------------------------------------------------------------------- |
1254 // TMmsGenUtils::GetCurrentStoreIndexL |
1584 // TMmsGenUtils::GetCurrentStoreIndexL |
1255 // ----------------------------------------------------------------------------- |
1585 // ----------------------------------------------------------------------------- |
1256 // |
1586 // |
1257 TInt TMmsGenUtils::GetCurrentStoreIndexL( CVPbkContactLinkArray& /*aLinkArray*/ ) |
1587 TInt TMmsGenUtils::GetCurrentStoreIndexL( CVPbkContactLinkArray& aLinkArray ) |
1258 { |
1588 { |
1259 |
1589 TInt curStoreIndex( KErrMultipleMatchFound ); |
1260 return 0; |
1590 TInt curStoreMatchCount = 0; |
|
1591 RArray<TInt> otherStoreMatchIndices; |
|
1592 CleanupClosePushL( otherStoreMatchIndices ); |
|
1593 |
|
1594 //Get the current configured contact store array(s) |
|
1595 CPbk2StoreConfiguration* storeConfiguration = CPbk2StoreConfiguration::NewL(); |
|
1596 CleanupStack::PushL( storeConfiguration ); |
|
1597 CVPbkContactStoreUriArray* currStoreArray = storeConfiguration->CurrentConfigurationL(); |
|
1598 CleanupStack::PopAndDestroy(storeConfiguration); |
|
1599 |
|
1600 if ( currStoreArray ) |
|
1601 { |
|
1602 /* Contact's store is compared against user selected stores. |
|
1603 * If contact is from such store, found index is incremented |
|
1604 * else, other store contact indices are populated into array for further use |
|
1605 */ |
|
1606 for ( TInt i = 0; i < aLinkArray.Count(); i++ ) |
|
1607 { |
|
1608 TVPbkContactStoreUriPtr uri = aLinkArray.At(i).ContactStore().StoreProperties().Uri(); |
|
1609 if ( currStoreArray->IsIncluded( uri ) ) |
|
1610 { |
|
1611 // Set index to found contact and increment the count. |
|
1612 curStoreIndex = i; |
|
1613 curStoreMatchCount++; |
|
1614 } |
|
1615 else |
|
1616 { |
|
1617 otherStoreMatchIndices.AppendL(i); |
|
1618 } |
|
1619 } |
|
1620 |
|
1621 delete currStoreArray; |
|
1622 if ( curStoreMatchCount > 1) |
|
1623 { |
|
1624 /* Multiple matches found from current user selected store(s) |
|
1625 * Delete match from other stores in aLinkArray. New aLinkArray should only contain |
|
1626 * current store contact matches, so that next level pruning can be done(e.g, names can be |
|
1627 * compared and displayed if they are identical). |
|
1628 */ |
|
1629 for(TInt i = otherStoreMatchIndices.Count() - 1; i >= 0; i--) |
|
1630 { |
|
1631 aLinkArray.Delete( otherStoreMatchIndices[i] ); |
|
1632 } |
|
1633 curStoreIndex = KErrMultipleMatchFound; |
|
1634 } |
|
1635 } |
|
1636 CleanupStack::PopAndDestroy( &otherStoreMatchIndices ); |
|
1637 return curStoreIndex; |
1261 } |
1638 } |
1262 |
1639 |
1263 // ================= OTHER EXPORTED FUNCTIONS ============== |
1640 // ================= OTHER EXPORTED FUNCTIONS ============== |
1264 |
1641 |
1265 // End of File |
1642 // End of File |