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 TRAPD(err, GetMatchDigitCountL()) |
|
73 if (err != KErrNone) |
|
74 { |
|
75 iMatchDigitCount = KDefaultGsmNumberMatchLength; |
|
76 } |
|
77 |
|
78 } |
62 } |
79 |
63 |
80 CPbapVCardExporterUtil::~CPbapVCardExporterUtil() |
64 CPbapVCardExporterUtil::~CPbapVCardExporterUtil() |
81 { |
65 { |
82 LOG_FUNC |
66 LOG_FUNC |
83 iTzClient.Close(); |
67 iTzClient.Close(); |
84 CVersitTlsData::CloseVersitTlsData(); |
68 CVersitTlsData::CloseVersitTlsData(); |
85 } |
69 } |
86 |
70 |
87 void CPbapVCardExporterUtil::GetMatchDigitCountL() |
|
88 { |
|
89 // Read the amount of digits to be used in contact matching |
|
90 // The key is properly owned by PhoneApp, however we cannot include |
|
91 // that header file from here, so a temporary fix has been done to |
|
92 // use locally defined versions. If there is a problem here it is |
|
93 // likely because these values have gone out of sync. |
|
94 CRepository* repository = CRepository::NewLC(KCRUidTelConfiguration); |
|
95 User::LeaveIfError(repository->Get(KTelMatchDigits, iMatchDigitCount)); |
|
96 // The rest of the system has a miniumum of 7 for the number matching, so we do the same here |
|
97 iMatchDigitCount = Max(iMatchDigitCount, KDefaultGsmNumberMatchLength); |
|
98 CleanupStack::PopAndDestroy(repository); |
|
99 } |
|
100 |
|
101 /** |
71 /** |
102 Export a contact as vCard. |
72 Export a contact as vCard. |
103 |
73 |
104 @param aContactId Contact item ID to export. If this value is set to KNullContactId an empty vCard |
74 @param aContactId Contact item ID to export. If this value is set to KNullContactId an empty vCard |
105 containing only the mandatory properties defined in the PBAP specification will be exported |
75 containing only the mandatory properties defined in the PBAP specification will be exported |
189 } |
159 } |
190 |
160 |
191 TContactItemId CPbapVCardExporterUtil::FindContactIdFromNumberL(const TDesC& aNumber) |
161 TContactItemId CPbapVCardExporterUtil::FindContactIdFromNumberL(const TDesC& aNumber) |
192 { |
162 { |
193 TContactItemId ret = KNullContactId; |
163 TContactItemId ret = KNullContactId; |
194 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); |
195 if (contactIdArray->Count() > 0) |
169 if (contactIdArray->Count() > 0) |
196 { |
170 { |
197 ret = (*contactIdArray)[0]; |
171 ret = (*contactIdArray)[0]; |
198 } |
172 } |
199 delete contactIdArray; |
173 CleanupStack::PopAndDestroy(2); // contactIdArray, fieldDef |
200 return ret; |
174 return ret; |
201 } |
175 } |
202 |
176 |
203 /** |
177 /** |
204 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 |