diff -r d4f567ce2e7c -r 5b6f26637ad3 pimprotocols/pbap/server/pbapvcardexporterutil.cpp --- a/pimprotocols/pbap/server/pbapvcardexporterutil.cpp Thu Aug 19 09:41:07 2010 +0300 +++ b/pimprotocols/pbap/server/pbapvcardexporterutil.cpp Tue Aug 31 15:05:21 2010 +0300 @@ -21,6 +21,8 @@ #include #include #include +#include + #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS #include "vcard3.h" #include "cntdb_internal.h" @@ -29,6 +31,13 @@ #include "pbaplogeng.h" #include "btaccesshostlog.h" +/* These constants are properly defined in telconfigcrkeys.h, however we +are not allowed to include that from here. As a temporary fix the constants +from that file are re-defined here. */ +const TUid KCRUidTelConfiguration = {0x102828B8}; +const TUint32 KTelMatchDigits = 0x00000001; +/* And similarly this constant is defined in ccsdefs.h */ +const TInt KDefaultGsmNumberMatchLength = 7; //constants _LIT8(KVersitTokenCALLDATETIME,"X-IRMC-CALL-DATETIME"); @@ -59,6 +68,23 @@ LOG_FUNC CVersitTlsData::VersitTlsDataL(); User::LeaveIfError(iTzClient.Connect()); + + // Read the amount of digits to be used in contact matching + // The key is properly owned by PhoneApp, however we cannot include + // that header file from here, so a temporary fix has been done to + // use locally defined versions. If there is a problem here it is + // likely because these values have gone out of sync. + CRepository* repository = CRepository::NewLC(KCRUidTelConfiguration); + if ( repository->Get(KTelMatchDigits, iMatchDigitCount) == KErrNone ) + { + // Min is 7 + iMatchDigitCount = Max(iMatchDigitCount, KDefaultGsmNumberMatchLength); + } + else + { + iMatchDigitCount = KDefaultGsmNumberMatchLength; + } + CleanupStack::PopAndDestroy(repository); } CPbapVCardExporterUtil::~CPbapVCardExporterUtil() @@ -161,16 +187,12 @@ TContactItemId CPbapVCardExporterUtil::FindContactIdFromNumberL(const TDesC& aNumber) { TContactItemId ret = KNullContactId; - CContactItemFieldDef* fieldDef; - fieldDef = new(ELeave) CContactItemFieldDef; - CleanupStack::PushL(fieldDef); - fieldDef->AppendL(KUidContactFieldPhoneNumber); - CContactIdArray* contactIdArray = iDatabase.FindLC(aNumber, fieldDef); + CContactIdArray* contactIdArray = iDatabase.MatchPhoneNumberL(aNumber, iMatchDigitCount); if (contactIdArray->Count() > 0) { ret = (*contactIdArray)[0]; } - CleanupStack::PopAndDestroy(2); // contactIdArray, fieldDef + delete contactIdArray; return ret; }