pimprotocols/pbap/server/pbapvcardexporterutil.cpp
branchRCL_3
changeset 63 f4a778e096c2
parent 62 5b6f26637ad3
child 68 9da50d567e3c
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
    19 
    19 
    20 #include <cntitem.h>
    20 #include <cntitem.h>
    21 #include <s32strm.h>
    21 #include <s32strm.h>
    22 #include <vprop.h>
    22 #include <vprop.h>
    23 #include <vcard.h>
    23 #include <vcard.h>
    24 #include <centralrepository.h>
       
    25 
       
    26 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    24 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    27 #include "vcard3.h"
    25 #include "vcard3.h"
    28 #include "cntdb_internal.h"
    26 #include "cntdb_internal.h"
    29 #endif
    27 #endif
    30 #include <vtoken.h>
    28 #include <vtoken.h>
    31 #include "pbaplogeng.h"
    29 #include "pbaplogeng.h"
    32 #include "btaccesshostlog.h"
    30 #include "btaccesshostlog.h"
    33 
    31 
    34 /* These constants are properly defined in telconfigcrkeys.h, however we 
       
    35 are not allowed to include that from here.  As a temporary fix the constants 
       
    36 from that file are re-defined here. */
       
    37 const TUid KCRUidTelConfiguration = {0x102828B8};
       
    38 const TUint32 KTelMatchDigits = 0x00000001;
       
    39 /* And similarly this constant is defined in ccsdefs.h */
       
    40 const TInt KDefaultGsmNumberMatchLength = 7;
       
    41 
    32 
    42 //constants
    33 //constants
    43 _LIT8(KVersitTokenCALLDATETIME,"X-IRMC-CALL-DATETIME");
    34 _LIT8(KVersitTokenCALLDATETIME,"X-IRMC-CALL-DATETIME");
    44 _LIT8(KVersitParamMISSED,"MISSED");
    35 _LIT8(KVersitParamMISSED,"MISSED");
    45 _LIT8(KVersitParamRECEIVED,"RECEIVED");
    36 _LIT8(KVersitParamRECEIVED,"RECEIVED");
    66 void CPbapVCardExporterUtil::ConstructL()
    57 void CPbapVCardExporterUtil::ConstructL()
    67 	{
    58 	{
    68 	LOG_FUNC
    59 	LOG_FUNC
    69 	CVersitTlsData::VersitTlsDataL();		
    60 	CVersitTlsData::VersitTlsDataL();		
    70 	User::LeaveIfError(iTzClient.Connect());
    61 	User::LeaveIfError(iTzClient.Connect());
    71 	
       
    72 	// Read the amount of digits to be used in contact matching
       
    73 	// The key is properly owned by PhoneApp, however we cannot include
       
    74 	// that header file from here, so a temporary fix has been done to 
       
    75 	// use locally defined versions.  If there is a problem here it is 
       
    76 	// likely because these values have gone out of sync.
       
    77 	CRepository* repository = CRepository::NewLC(KCRUidTelConfiguration);
       
    78     if ( repository->Get(KTelMatchDigits, iMatchDigitCount) == KErrNone )
       
    79         {
       
    80         // Min is 7
       
    81         iMatchDigitCount = Max(iMatchDigitCount, KDefaultGsmNumberMatchLength);
       
    82         }
       
    83     else
       
    84         {
       
    85         iMatchDigitCount = KDefaultGsmNumberMatchLength;
       
    86         }
       
    87 	CleanupStack::PopAndDestroy(repository);
       
    88 	}
    62 	}
    89 
    63 
    90 CPbapVCardExporterUtil::~CPbapVCardExporterUtil()
    64 CPbapVCardExporterUtil::~CPbapVCardExporterUtil()
    91 	{
    65 	{
    92 	LOG_FUNC
    66 	LOG_FUNC
   185 	}
   159 	}
   186 
   160 
   187 TContactItemId CPbapVCardExporterUtil::FindContactIdFromNumberL(const TDesC& aNumber)
   161 TContactItemId CPbapVCardExporterUtil::FindContactIdFromNumberL(const TDesC& aNumber)
   188 	{
   162 	{
   189 	TContactItemId ret = KNullContactId;
   163 	TContactItemId ret = KNullContactId;
   190 	CContactIdArray* contactIdArray = iDatabase.MatchPhoneNumberL(aNumber, iMatchDigitCount);
   164 	CContactItemFieldDef* fieldDef;
       
   165 	fieldDef = new(ELeave) CContactItemFieldDef;
       
   166 	CleanupStack::PushL(fieldDef);
       
   167 	fieldDef->AppendL(KUidContactFieldPhoneNumber);
       
   168 	CContactIdArray* contactIdArray = iDatabase.FindLC(aNumber, fieldDef);
   191 	if (contactIdArray->Count() > 0)
   169 	if (contactIdArray->Count() > 0)
   192 		{
   170 		{
   193 		ret = (*contactIdArray)[0];
   171 		ret = (*contactIdArray)[0];
   194 		}
   172 		}
   195 	delete contactIdArray;
   173 	CleanupStack::PopAndDestroy(2); // contactIdArray, fieldDef
   196 	return ret;
   174 	return ret;
   197 	}
   175 	}
   198 
   176 
   199 /**
   177 /**
   200 Writes a vCard to the stream containing only the mandatory properties defined in the PBAP specification
   178 Writes a vCard to the stream containing only the mandatory properties defined in the PBAP specification