|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "AddModifyDeleteContactFields.h" |
|
17 |
|
18 /* The following set of functions are available for creating and updating desired contact items fields |
|
19 * A contact item field has 3 important parts to it |
|
20 * 1) Field Type |
|
21 * 2) Storage Type |
|
22 * 3) Content |
|
23 * Functions are available which construct the contact items fields with meet the above criteria |
|
24 * In General, the contact item fields are set with random string as their content |
|
25 * In specific case, the contact item field will be supplied withh desired content |
|
26 * useful in case of find views and Sub Views |
|
27 * In case of filtered views, it is required that the contact item possess fields that meet the |
|
28 * contact item view filter. Functions are available to added contact item fields in order to meet |
|
29 * the contact item view filter criteria |
|
30 */ |
|
31 |
|
32 /** |
|
33 * Retrieve the relevant contact field storage type for the specified contact field |
|
34 * @param aFieldType - Contact field information |
|
35 * @return TStorageType - The contact field storage type |
|
36 */ |
|
37 TStorageType TAddModifyDeleteContactFields::GetStorageType(const TFieldType& aFieldType) |
|
38 { |
|
39 if((aFieldType == KUidContactFieldAnniversary) || (aFieldType == KUidContactFieldBirthday)) |
|
40 { |
|
41 return KStorageTypeDateTime ; |
|
42 } |
|
43 return KStorageTypeText; |
|
44 } |
|
45 |
|
46 /** |
|
47 * Adds content to the specified field based on the available contact field type information |
|
48 * @param aFieldType - Contact field type information |
|
49 * @param aField - The contact field to be updated |
|
50 */ |
|
51 void TAddModifyDeleteContactFields::SetDataL(const TFieldType& aFieldType, CContactItemField& aField) |
|
52 { |
|
53 HBufC* buf = HBufC::NewLC(SharedConstants::KMaxBufferLength); |
|
54 TPtr bufPtr = buf->Des(); |
|
55 |
|
56 if ((aFieldType == KUidContactFieldJobTitle) || (aFieldType == KUidContactFieldNote) || |
|
57 |
|
58 (aFieldType == KUidContactFieldAssistant) || (aFieldType == KUidContactFieldSpouse) || |
|
59 |
|
60 (aFieldType == KUidContactFieldChildren) || (aFieldType == KUidContactFieldRegion) || |
|
61 |
|
62 (aFieldType == KUidContactFieldCountry) || (aFieldType == KUidContactFieldCompanyName) || |
|
63 |
|
64 (aFieldType == KUidContactFieldCompanyNamePronunciation) || (aFieldType == KUidContactFieldGivenName) || |
|
65 |
|
66 (aFieldType == KUidContactFieldFamilyName) || (aFieldType == KUidContactFieldGivenNamePronunciation) || |
|
67 |
|
68 (aFieldType == KUidContactFieldFamilyNamePronunciation) || (aFieldType == KUidContactFieldAdditionalName) || |
|
69 |
|
70 (aFieldType == KUidContactFieldSuffixName) || (aFieldType == KUidContactFieldPrefixName) || |
|
71 |
|
72 (aFieldType == KUidContactFieldDepartmentName) || (aFieldType == KUidContactFieldClass) || |
|
73 |
|
74 (aFieldType == KUidContactFieldClass)) |
|
75 { |
|
76 SetRandomAlphaString(bufPtr, SharedConstants::KMaxBufferLength); |
|
77 aField.TextStorage()->SetTextL(bufPtr); |
|
78 } |
|
79 |
|
80 else if ((aFieldType == KUidContactFieldPostcode ) || (aFieldType == KUidContactFieldPhoneNumber) || |
|
81 |
|
82 (aFieldType == KUidContactFieldAnniversary ) || (aFieldType == KUidContactFieldSms) || |
|
83 |
|
84 (aFieldType == KUidContactFieldFax ) || (aFieldType == KUidContactFieldBirthday) || |
|
85 |
|
86 (aFieldType == KUidContactFieldICCPhonebook ) || (aFieldType == KUidContactFieldDTMF) || |
|
87 |
|
88 (aFieldType == KUidContactFieldICCSlot) || (aFieldType == KUidContactsVoiceDialField)) |
|
89 { |
|
90 SetRandomNumericString(bufPtr, SharedConstants::KMaxBufferLength); |
|
91 aField.TextStorage()->SetTextL(bufPtr); |
|
92 } |
|
93 |
|
94 else if ((aFieldType == KUidContactFieldAddress ) || (aFieldType == KUidContactFieldPostOffice) || |
|
95 |
|
96 (aFieldType == KUidContactFieldExtendedAddress ) || (aFieldType == KUidContactFieldLocality) || |
|
97 |
|
98 (aFieldType == KUidContactFieldEMail ) || (aFieldType == KUidContactFieldMsg) || |
|
99 |
|
100 (aFieldType == KUidContactFieldUrl ) || (aFieldType == KUidContactFieldPicture) || |
|
101 |
|
102 (aFieldType == KUidContactFieldRingTone) || (aFieldType == KUidContactFieldICCGroup) || |
|
103 |
|
104 (aFieldType == KUidContactFieldIMAddress ) || (aFieldType == KUidContactFieldSecondName) || |
|
105 |
|
106 (aFieldType == KUidContactFieldSIPID)) |
|
107 { |
|
108 SetRandomAlphaNumericString(bufPtr, SharedConstants::KMaxBufferLength); |
|
109 aField.TextStorage()->SetTextL(bufPtr); |
|
110 } |
|
111 CleanupStack::PopAndDestroy(); // buf |
|
112 } |
|
113 |
|
114 /** |
|
115 * Update the specified buffer with random alpha content as per specified length |
|
116 * @param aBuf - Buffer to be updated |
|
117 * @param aLength - Length information |
|
118 */ |
|
119 void TAddModifyDeleteContactFields::SetRandomAlphaString(TDes& aBuf,TInt aLength) |
|
120 { |
|
121 aBuf.SetLength(aLength); |
|
122 |
|
123 for (TInt ii = 0; ii < aLength; ++ii) |
|
124 { |
|
125 aBuf[ii] = RandomAlphaCharCode(); |
|
126 } |
|
127 } |
|
128 |
|
129 /** |
|
130 * Update the specified buffer with random numeric content as per specified length |
|
131 * @param aBuf - Buffer to be updated |
|
132 * @param aLength - Length information |
|
133 */ |
|
134 void TAddModifyDeleteContactFields::SetRandomNumericString(TDes& aBuf,TInt aLength) |
|
135 { |
|
136 aBuf.SetLength(aLength); |
|
137 |
|
138 for (TInt ii = 0; ii < aLength; ++ii) |
|
139 { |
|
140 aBuf[ii] = RandomNumericCharCode(); |
|
141 } |
|
142 } |
|
143 |
|
144 /** |
|
145 * Update the specified buffer with random alpha and numeric content as per specified length |
|
146 * @param aBuf - Buffer to be updated |
|
147 * @param aLength - Length information |
|
148 */ |
|
149 void TAddModifyDeleteContactFields::SetRandomAlphaNumericString(TDes& aBuf,TInt aLength) |
|
150 { |
|
151 aBuf.SetLength(aLength); |
|
152 for (TInt ii = 0; ii < (aLength-1); ii = ii+2) |
|
153 { |
|
154 aBuf[ii] = RandomAlphaCharCode(); |
|
155 aBuf[ii+1] = RandomNumericCharCode(); |
|
156 } |
|
157 } |
|
158 |
|
159 /** |
|
160 * Returns any random character between A to Z |
|
161 * @return TText - Random Character |
|
162 */ |
|
163 TText TAddModifyDeleteContactFields::RandomAlphaCharCode() |
|
164 { |
|
165 return RandomCharCode('A','Z',' '); |
|
166 } |
|
167 |
|
168 /** |
|
169 * Returns any random ascii character equivalent of number between 0 to 9 |
|
170 * @return TText - Random Number |
|
171 */ |
|
172 TText TAddModifyDeleteContactFields::RandomNumericCharCode() |
|
173 { |
|
174 return RandomCharCode('0','9',' '); |
|
175 } |
|
176 |
|
177 |
|
178 TText TAddModifyDeleteContactFields::RandomCharCode(TText aLowerBound,TText aUpperBound,TText aException) |
|
179 { |
|
180 TText charCode = 0; |
|
181 |
|
182 do |
|
183 { |
|
184 charCode=RandomCharCode(aLowerBound,aUpperBound); |
|
185 } |
|
186 while (charCode == aException); |
|
187 |
|
188 return charCode; |
|
189 } |
|
190 |
|
191 TText TAddModifyDeleteContactFields::RandomCharCode(TText aLowerBound,TText aUpperBound) |
|
192 { |
|
193 TText charCode = STATIC_CAST(TText,(Math::Rand(iRandSeed) % (aUpperBound - aLowerBound)) + aLowerBound); |
|
194 ASSERT(charCode >= aLowerBound && charCode <= aUpperBound); |
|
195 return charCode; |
|
196 } |
|
197 |
|
198 |
|
199 /** |
|
200 * Retrieve the contact field uid information based on the contact field information specified in string format |
|
201 * @param aContactFieldString - Contact field information in String format |
|
202 * @return TUid - The contact field information in uid format |
|
203 */ |
|
204 |
|
205 TUid TAddModifyDeleteContactFields::GetContactFieldType(const TPtrC& aContactFieldString) |
|
206 { |
|
207 |
|
208 _LIT(KAddress, "Address"); |
|
209 _LIT(KPostOffice, "PostOffice"); |
|
210 _LIT(KExtendedAddress, "ExtendedAddress"); |
|
211 _LIT(KLocality, "Locality"); |
|
212 _LIT(KRegion, "Region"); |
|
213 _LIT(KPostCode, "PostCode"); |
|
214 _LIT(KCountry, "Country"); |
|
215 _LIT(KCompanyName, "CompanyName"); |
|
216 _LIT(KCompanyNamePronunciation, "CompanyNamePronunciation"); |
|
217 _LIT(KPhoneNumber, "PhoneNumber"); |
|
218 _LIT(KGivenName, "GivenName"); |
|
219 _LIT(KFamilyName, "FamilyName"); |
|
220 _LIT(KGivenNamePronunciation, "GivenNamePronunciation"); |
|
221 _LIT(KFamilyNamePronunciation, "FamilyNamePronunciation"); |
|
222 _LIT(KAdditionalName, "AdditionalName"); |
|
223 _LIT(KSuffixName, "SuffixName"); |
|
224 _LIT(KPrefixName, "PrefixName"); |
|
225 _LIT(KHidden, "Hidden"); |
|
226 _LIT(KEMail, "EMail"); |
|
227 _LIT(KMsg, "Msg"); |
|
228 _LIT(KSms, "Sms"); |
|
229 _LIT(KFax, "Fax"); |
|
230 _LIT(KNote, "Note"); |
|
231 _LIT(KBirthday, "Birthday"); |
|
232 _LIT(KUrl, "Url"); |
|
233 _LIT(KPicture, "Picture"); |
|
234 _LIT(KRingTone, "RingTone"); |
|
235 _LIT(KDTMF, "DTMF"); |
|
236 _LIT(KVoiceDialField, "VoiceDialField"); |
|
237 _LIT(KJobTitle, "JobTitle"); |
|
238 _LIT(KICCSlot, "ICCSlot"); |
|
239 _LIT(KICCPhonebook, "ICCPhonebook"); |
|
240 _LIT(KICCGroup, "ICCGroup"); |
|
241 _LIT(KIMAddress, "IMAddress"); |
|
242 _LIT(KSecondName, "SecondName"); |
|
243 _LIT(KSIPID, "SIPID"); |
|
244 _LIT(KAssistant, "Assistant"); |
|
245 _LIT(KAnniversary, "Anniversary"); |
|
246 _LIT(KSpouse, "Spouse"); |
|
247 _LIT(KChildren, "Children"); |
|
248 _LIT(KClass, "Class"); |
|
249 _LIT(KDepartmentName, "DepartmentName"); |
|
250 |
|
251 TUid uid; |
|
252 |
|
253 if ( aContactFieldString.Compare(KAddress) == 0) |
|
254 { |
|
255 uid = KUidContactFieldAddress; |
|
256 } |
|
257 else if ( aContactFieldString.Compare(KPostOffice) == 0) |
|
258 { |
|
259 uid = KUidContactFieldPostOffice; |
|
260 } |
|
261 else if ( aContactFieldString.Compare(KExtendedAddress) == 0) |
|
262 { |
|
263 uid = KUidContactFieldExtendedAddress; |
|
264 } |
|
265 else if ( aContactFieldString.Compare(KLocality) == 0) |
|
266 { |
|
267 uid = KUidContactFieldLocality; |
|
268 } |
|
269 else if ( aContactFieldString.Compare(KRegion) == 0) |
|
270 { |
|
271 uid = KUidContactFieldRegion; |
|
272 } |
|
273 else if ( aContactFieldString.Compare(KPostCode) == 0) |
|
274 { |
|
275 uid = KUidContactFieldPostcode; |
|
276 } |
|
277 else if ( aContactFieldString.Compare(KCountry) == 0) |
|
278 { |
|
279 uid = KUidContactFieldCountry; |
|
280 } |
|
281 else if ( aContactFieldString.Compare(KCompanyName) == 0) |
|
282 { |
|
283 uid = KUidContactFieldCompanyName; |
|
284 } |
|
285 else if ( aContactFieldString.Compare(KCompanyNamePronunciation) == 0) |
|
286 { |
|
287 uid = KUidContactFieldCompanyNamePronunciation; |
|
288 } |
|
289 else if ( aContactFieldString.Compare(KPhoneNumber) == 0) |
|
290 { |
|
291 uid = KUidContactFieldPhoneNumber; |
|
292 } |
|
293 else if ( aContactFieldString.Compare(KGivenName) == 0) |
|
294 { |
|
295 uid = KUidContactFieldGivenName; |
|
296 } |
|
297 else if ( aContactFieldString.Compare(KFamilyName) == 0) |
|
298 { |
|
299 uid = KUidContactFieldFamilyName; |
|
300 } |
|
301 else if ( aContactFieldString.Compare(KGivenNamePronunciation) == 0) |
|
302 { |
|
303 uid = KUidContactFieldGivenNamePronunciation; |
|
304 } |
|
305 else if ( aContactFieldString.Compare(KFamilyNamePronunciation) == 0) |
|
306 { |
|
307 uid = KUidContactFieldFamilyNamePronunciation; |
|
308 } |
|
309 else if ( aContactFieldString.Compare(KAdditionalName) == 0) |
|
310 { |
|
311 uid = KUidContactFieldAdditionalName; |
|
312 } |
|
313 else if ( aContactFieldString.Compare(KSuffixName) == 0) |
|
314 { |
|
315 uid = KUidContactFieldSuffixName; |
|
316 } |
|
317 else if ( aContactFieldString.Compare(KPrefixName) == 0) |
|
318 { |
|
319 uid = KUidContactFieldPrefixName; |
|
320 } |
|
321 else if ( aContactFieldString.Compare(KHidden) == 0) |
|
322 { |
|
323 uid = KUidContactFieldHidden; |
|
324 } |
|
325 else if ( aContactFieldString.Compare(KEMail) == 0) |
|
326 { |
|
327 uid = KUidContactFieldEMail; |
|
328 } |
|
329 else if ( aContactFieldString.Compare(KMsg) == 0) |
|
330 { |
|
331 uid = KUidContactFieldMsg; |
|
332 } |
|
333 else if ( aContactFieldString.Compare(KSms) == 0) |
|
334 { |
|
335 uid = KUidContactFieldSms; |
|
336 } |
|
337 else if ( aContactFieldString.Compare(KFax) == 0) |
|
338 { |
|
339 uid = KUidContactFieldFax; |
|
340 } |
|
341 else if ( aContactFieldString.Compare(KNote) == 0) |
|
342 { |
|
343 uid = KUidContactFieldNote; |
|
344 } |
|
345 else if ( aContactFieldString.Compare(KBirthday) == 0) |
|
346 { |
|
347 uid = KUidContactFieldBirthday; |
|
348 } |
|
349 else if ( aContactFieldString.Compare(KUrl) == 0) |
|
350 { |
|
351 uid = KUidContactFieldUrl; |
|
352 } |
|
353 else if ( aContactFieldString.Compare(KPicture) == 0) |
|
354 { |
|
355 uid = KUidContactFieldPicture; |
|
356 } |
|
357 else if ( aContactFieldString.Compare(KRingTone) == 0) |
|
358 { |
|
359 uid = KUidContactFieldRingTone; |
|
360 } |
|
361 else if ( aContactFieldString.Compare(KDTMF) == 0) |
|
362 { |
|
363 uid = KUidContactFieldDTMF; |
|
364 } |
|
365 else if ( aContactFieldString.Compare(KVoiceDialField) == 0) |
|
366 { |
|
367 uid = KUidContactsVoiceDialField; |
|
368 } |
|
369 else if ( aContactFieldString.Compare(KJobTitle) == 0) |
|
370 { |
|
371 uid = KUidContactFieldJobTitle; |
|
372 } |
|
373 else if ( aContactFieldString.Compare(KICCSlot) == 0) |
|
374 { |
|
375 uid = KUidContactFieldICCSlot; |
|
376 } |
|
377 else if ( aContactFieldString.Compare(KICCPhonebook) == 0) |
|
378 { |
|
379 uid = KUidContactFieldICCPhonebook; |
|
380 } |
|
381 else if ( aContactFieldString.Compare(KICCGroup) == 0) |
|
382 { |
|
383 uid = KUidContactFieldICCGroup; |
|
384 } |
|
385 else if ( aContactFieldString.Compare(KIMAddress) == 0) |
|
386 { |
|
387 uid = KUidContactFieldIMAddress; |
|
388 } |
|
389 else if ( aContactFieldString.Compare(KSecondName) == 0) |
|
390 { |
|
391 uid = KUidContactFieldSecondName; |
|
392 } |
|
393 else if ( aContactFieldString.Compare(KSIPID) == 0) |
|
394 { |
|
395 uid = KUidContactFieldSIPID; |
|
396 } |
|
397 else if ( aContactFieldString.Compare(KAssistant) == 0) |
|
398 { |
|
399 uid = KUidContactFieldAssistant; |
|
400 } |
|
401 else if ( aContactFieldString.Compare(KAnniversary) == 0) |
|
402 { |
|
403 uid = KUidContactFieldAnniversary; |
|
404 } |
|
405 else if ( aContactFieldString.Compare(KSpouse) == 0) |
|
406 { |
|
407 uid = KUidContactFieldSpouse; |
|
408 } |
|
409 else if ( aContactFieldString.Compare(KChildren) == 0) |
|
410 { |
|
411 uid = KUidContactFieldChildren; |
|
412 } |
|
413 else if ( aContactFieldString.Compare(KClass) == 0) |
|
414 { |
|
415 uid = KUidContactFieldClass; |
|
416 } |
|
417 else if ( aContactFieldString.Compare(KDepartmentName) == 0) |
|
418 { |
|
419 uid = KUidContactFieldDepartmentName; |
|
420 } |
|
421 else |
|
422 { |
|
423 uid = KUidContactFieldNone; |
|
424 } |
|
425 |
|
426 return uid; |
|
427 } |
|
428 |
|
429 /** |
|
430 * Adds contact field to meet the specified contact based to meet the filter requirements |
|
431 * @param aContact contact to be updated |
|
432 * @param aBitWiseFilter desired view filter |
|
433 */ |
|
434 void TAddModifyDeleteContactFields::AddFilterBasedFieldsL(CContactItem& aContact, TInt aBitWiseFilter) |
|
435 { |
|
436 HBufC* buf = HBufC::NewLC(SharedConstants::KMaxBufferLength); |
|
437 TPtr bufPtr = buf->Des(); |
|
438 |
|
439 if(aBitWiseFilter & CContactDatabase::ELandLine) |
|
440 { |
|
441 SetRandomNumericString(bufPtr,SharedConstants::KMaxBufferLength); |
|
442 SetWorkPhoneL(aContact, bufPtr); |
|
443 } |
|
444 |
|
445 if(aBitWiseFilter & CContactDatabase::ESmsable) |
|
446 { |
|
447 SetRandomNumericString(bufPtr, SharedConstants::KMaxBufferLength); |
|
448 SetWorkMobileL(aContact, bufPtr); |
|
449 } |
|
450 |
|
451 if(aBitWiseFilter & CContactDatabase::EMailable) |
|
452 { |
|
453 SetRandomAlphaNumericString(bufPtr, SharedConstants::KMaxBufferLength); |
|
454 if (aBitWiseFilter&CContactDatabase::EHome) |
|
455 SetHomeEmailAddressL(aContact, bufPtr); |
|
456 else |
|
457 SetWorkEmailAddressL(aContact, bufPtr); |
|
458 } |
|
459 |
|
460 if(aBitWiseFilter & CContactDatabase::EFaxable) |
|
461 { |
|
462 SetRandomNumericString(bufPtr, SharedConstants::KMaxBufferLength); |
|
463 SetFaxL(aContact, bufPtr); |
|
464 } |
|
465 |
|
466 if(aBitWiseFilter & CContactDatabase::ERingTone) |
|
467 { |
|
468 SetRandomNumericString(bufPtr, SharedConstants::KMaxBufferLength); |
|
469 SetRingToneL(aContact, bufPtr); |
|
470 } |
|
471 |
|
472 if(aBitWiseFilter & CContactDatabase::EVoiceDial) |
|
473 { |
|
474 SetRandomNumericString(bufPtr, SharedConstants::KMaxBufferLength); |
|
475 SetVoiceDialL(aContact, bufPtr); |
|
476 } |
|
477 |
|
478 if(aBitWiseFilter & CContactDatabase::EWirelessVillage) |
|
479 { |
|
480 SetRandomNumericString(bufPtr, SharedConstants::KMaxBufferLength); |
|
481 SetIMAddressL(aContact, bufPtr); |
|
482 } |
|
483 if(aBitWiseFilter & CContactDatabase::EIMAddress) |
|
484 { |
|
485 SetRandomAlphaNumericString(bufPtr, SharedConstants::KMaxBufferLength); |
|
486 SetIMAddressL(aContact, bufPtr); |
|
487 } |
|
488 |
|
489 CleanupStack::PopAndDestroy(buf); |
|
490 } |
|
491 |
|
492 /** |
|
493 * Adds contact field to meet the work phone filter requirement |
|
494 * @param aContact contact to be updated |
|
495 * @param aWorkPhone content for work phone contact field |
|
496 */ |
|
497 void TAddModifyDeleteContactFields::SetWorkPhoneL(CContactItem& aContact, const TDesC& aWorkPhone) |
|
498 { |
|
499 CContentType* contentType = CContentType::NewL(); |
|
500 CleanupStack::PushL(contentType); |
|
501 contentType->AddFieldTypeL(KUidContactFieldPhoneNumber); |
|
502 contentType->AddFieldTypeL(KUidContactFieldVCardMapWORK); |
|
503 contentType->AddFieldTypeL(KUidContactFieldVCardMapVOICE); |
|
504 SetTextFieldL(aContact, *contentType,aWorkPhone); |
|
505 CleanupStack::PopAndDestroy(contentType); |
|
506 } |
|
507 |
|
508 /** |
|
509 * Adds contact field to meet the work mobile filter requirement |
|
510 * @param aContact contact to be updated |
|
511 * @param aWorkMobile content for work mobile contact field |
|
512 */ |
|
513 void TAddModifyDeleteContactFields::SetWorkMobileL(CContactItem& aContact, const TDesC& aWorkMobile) |
|
514 { |
|
515 CContentType* contentType = CContentType::NewL(); |
|
516 CleanupStack::PushL(contentType); |
|
517 contentType->AddFieldTypeL(KUidContactFieldPhoneNumber); |
|
518 contentType->AddFieldTypeL(KUidContactFieldVCardMapWORK); |
|
519 contentType->AddFieldTypeL(KUidContactFieldVCardMapVOICE); |
|
520 contentType->AddFieldTypeL(KUidContactFieldVCardMapCELL); |
|
521 SetTextFieldL(aContact, *contentType,aWorkMobile); |
|
522 CleanupStack::PopAndDestroy(contentType); |
|
523 } |
|
524 |
|
525 /** |
|
526 * Adds contact field to meet the home phone filter requirement |
|
527 * @param aContact contact to be updated |
|
528 * @param aHomePhone content for home phone contact field |
|
529 */ |
|
530 void TAddModifyDeleteContactFields::SetHomePhoneL(CContactItem& aContact, const TDesC& aHomePhone) |
|
531 { |
|
532 CContentType* contentType = CContentType::NewL(); |
|
533 CleanupStack::PushL(contentType); |
|
534 contentType->AddFieldTypeL(KUidContactFieldPhoneNumber); |
|
535 contentType->AddFieldTypeL(KUidContactFieldVCardMapHOME); |
|
536 contentType->AddFieldTypeL(KUidContactFieldVCardMapVOICE); |
|
537 SetTextFieldL(aContact, *contentType,aHomePhone); |
|
538 CleanupStack::PopAndDestroy(contentType); |
|
539 } |
|
540 |
|
541 /** |
|
542 * Adds contact field to meet the home mobile filter requirement |
|
543 * @param aContact contact to be updated |
|
544 * @param aHomeMobile content for home mobile contact field |
|
545 */ |
|
546 void TAddModifyDeleteContactFields::SetHomeMobileL(CContactItem& aContact, const TDesC& aHomeMobile) |
|
547 { |
|
548 CContentType* contentType = CContentType::NewL(); |
|
549 CleanupStack::PushL(contentType); |
|
550 contentType->AddFieldTypeL(KUidContactFieldPhoneNumber); |
|
551 contentType->AddFieldTypeL(KUidContactFieldVCardMapHOME); |
|
552 contentType->AddFieldTypeL(KUidContactFieldVCardMapVOICE); |
|
553 contentType->AddFieldTypeL(KUidContactFieldVCardMapCELL); |
|
554 SetTextFieldL(aContact, *contentType,aHomeMobile); |
|
555 CleanupStack::PopAndDestroy(contentType); |
|
556 } |
|
557 |
|
558 /** |
|
559 * Adds contact field to meet the home email filter requirement |
|
560 * @param aContact contact to be updated |
|
561 * @param aEmailAddress content for home email contact field |
|
562 */ |
|
563 void TAddModifyDeleteContactFields::SetHomeEmailAddressL(CContactItem& aContact, const TDesC& aEmailAddress) |
|
564 { |
|
565 CContentType* contentType = CContentType::NewL(); |
|
566 CleanupStack::PushL(contentType); |
|
567 contentType->AddFieldTypeL(KUidContactFieldEMail); |
|
568 contentType->AddFieldTypeL(KUidContactFieldVCardMapHOME); |
|
569 SetTextFieldL(aContact, *contentType,aEmailAddress); |
|
570 CleanupStack::PopAndDestroy(contentType); |
|
571 } |
|
572 |
|
573 /** |
|
574 * Adds contact field to meet the work email filter requirement |
|
575 * @param aContact contact to be updated |
|
576 * @param aEmailAddress content for work email contact field |
|
577 */ |
|
578 void TAddModifyDeleteContactFields::SetWorkEmailAddressL(CContactItem& aContact, const TDesC& aEmailAddress) |
|
579 { |
|
580 CContentType* contentType = CContentType::NewL(); |
|
581 CleanupStack::PushL(contentType); |
|
582 contentType->AddFieldTypeL(KUidContactFieldEMail); |
|
583 contentType->AddFieldTypeL(KUidContactFieldVCardMapWORK); |
|
584 SetTextFieldL(aContact, *contentType,aEmailAddress); |
|
585 CleanupStack::PopAndDestroy(contentType); |
|
586 } |
|
587 |
|
588 /** |
|
589 * Adds a new contact field to meet the fax filter requirement |
|
590 * @param aContact contact to be updated |
|
591 * @param aFax content for fax contact field |
|
592 */ |
|
593 void TAddModifyDeleteContactFields::SetFaxL(CContactItem& aContact, const TDesC& aFax) |
|
594 { |
|
595 CContentType* contentType = CContentType::NewL(); |
|
596 CleanupStack::PushL(contentType); |
|
597 contentType->AddFieldTypeL(KUidContactFieldFax); |
|
598 SetTextFieldL(aContact, *contentType, aFax); |
|
599 CleanupStack::PopAndDestroy(contentType); |
|
600 } |
|
601 |
|
602 /** |
|
603 * Adds a new contact field to meet the IMAddress filter requirement |
|
604 * @param aContact contact to be updated |
|
605 * @param aIMAddress content for fax contact field |
|
606 */ |
|
607 void TAddModifyDeleteContactFields::SetIMAddressL(CContactItem& aContact, const TDesC& aIMAddress) |
|
608 { |
|
609 CContentType* contentType = CContentType::NewL(); |
|
610 CleanupStack::PushL(contentType); |
|
611 contentType->AddFieldTypeL(KUidContactFieldIMAddress); |
|
612 SetTextFieldL(aContact, *contentType, aIMAddress); |
|
613 CleanupStack::PopAndDestroy(contentType); |
|
614 } |
|
615 |
|
616 /** |
|
617 * Adds a new contact field to meet the voice dial filter requirement |
|
618 * @param aContact contact to be updated |
|
619 * @param aVoiceDial content for voice dial contact field |
|
620 */ |
|
621 void TAddModifyDeleteContactFields::SetVoiceDialL(CContactItem& aContact, const TDesC& aVoiceDial) |
|
622 { |
|
623 CContentType* contentType = CContentType::NewL(); |
|
624 CleanupStack::PushL(contentType); |
|
625 contentType->AddFieldTypeL(KUidContactsVoiceDialField); |
|
626 SetTextFieldL(aContact, *contentType, aVoiceDial ); |
|
627 CleanupStack::PopAndDestroy(contentType); |
|
628 } |
|
629 |
|
630 /** |
|
631 * Adds a new contact field to meet the ring tone filter requirement |
|
632 * @param aContact contact to be updated |
|
633 * @param aRingTone content for ring tone contact field |
|
634 */ |
|
635 void TAddModifyDeleteContactFields::SetRingToneL(CContactItem& aContact, const TDesC& aRingTone) |
|
636 { |
|
637 CContentType* contentType = CContentType::NewL(); |
|
638 CleanupStack::PushL(contentType); |
|
639 contentType->AddFieldTypeL(KUidContactFieldRingTone); |
|
640 SetTextFieldL(aContact, *contentType, aRingTone ); |
|
641 CleanupStack::PopAndDestroy(contentType); |
|
642 } |
|
643 |
|
644 /** |
|
645 * Adds desired contact field content to the contact specified |
|
646 * @param aContact contact to be updated |
|
647 * @param aTypesToMatch Storage type for Contact Field |
|
648 * @param aText content for the desired field |
|
649 */ |
|
650 void TAddModifyDeleteContactFields::SetTextFieldL(CContactItem& aContact, const CContentType& aTypesToMatch, const TDesC& aText) |
|
651 { |
|
652 TStorageType storageType = KStorageTypeText; |
|
653 CContactItemField* field = CContactItemField::NewL(storageType, aTypesToMatch); |
|
654 CleanupStack::PushL(field); |
|
655 field->TextStorage()->SetTextL(aText); |
|
656 aContact.AddFieldL(*field); |
|
657 CleanupStack::Pop(field); |
|
658 } |
|
659 |
|
660 /** |
|
661 * Update the contact item fields with new content |
|
662 * @param aContact contact to be updated |
|
663 */ |
|
664 void TAddModifyDeleteContactFields::UpdateFieldsL(CContactItem& aContact) |
|
665 { |
|
666 CContactItemFieldSet& fieldSet = aContact.CardFields(); |
|
667 for(TInt i = 0; i < fieldSet.Count();i++) |
|
668 { |
|
669 TFieldType fieldType(KUidContactFieldNone); |
|
670 CContactItemField& field = fieldSet[i]; |
|
671 SetDataL(fieldType, field); |
|
672 } |
|
673 } |