summaryrefslogtreecommitdiffstats
path: root/plugins/contacts/symbian/contactsmodel/tsrc/integration/cntperftest/src/addmodifydeletecontactfields.cpp
blob: 4ff4a195249b118b5aa8449f066a903a651ac8ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
/*
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/


#include "addmodifydeletecontactfields.h"

/* The following set of functions are available for creating and updating desired contact items fields
*  A contact item field has 3 important parts to it
*  1) Field Type
*  2) Storage Type
*  3) Content
*  Functions are available which construct the contact items fields with meet the above criteria
*  In General, the contact item fields are set with random string as their content
*  In specific case, the contact item field will be supplied withh desired content
*  useful in case of find views and Sub Views
*  In case of filtered views, it is required that the contact item possess fields that meet the
*  contact item view filter. Functions are available to added contact item fields in order to meet
*  the contact item view filter criteria
*/

/**
* Retrieve the relevant contact field storage type for the specified contact field
* @param aFieldType - Contact field information
* @return TStorageType - The contact field storage type
*/
TStorageType TAddModifyDeleteContactFields::GetStorageType(const TFieldType& aFieldType)
	{
	if((aFieldType == KUidContactFieldAnniversary) || (aFieldType == KUidContactFieldBirthday))
		{
		return KStorageTypeDateTime ;
		}
	return KStorageTypeText;
	}

/**
* Adds content to the specified field based on the available contact field type information
* @param aFieldType - Contact field type information
* @param aField - The contact field to be updated
*/
void TAddModifyDeleteContactFields::SetDataL(const TFieldType& aFieldType, CContactItemField& aField)
	{
	HBufC* buf = HBufC::NewLC(SharedConstants::KMaxBufferLength);
	TPtr bufPtr = buf->Des();

	if ((aFieldType == KUidContactFieldJobTitle) || (aFieldType == KUidContactFieldNote) ||

	    (aFieldType == KUidContactFieldAssistant) || (aFieldType == KUidContactFieldSpouse) ||

	    (aFieldType == KUidContactFieldChildren) || (aFieldType == KUidContactFieldRegion)  ||

	    (aFieldType == KUidContactFieldCountry) || (aFieldType == KUidContactFieldCompanyName) ||

	    (aFieldType == KUidContactFieldCompanyNamePronunciation) || (aFieldType == KUidContactFieldGivenName) ||

	    (aFieldType == KUidContactFieldFamilyName) || (aFieldType == KUidContactFieldGivenNamePronunciation)  ||

	    (aFieldType == KUidContactFieldFamilyNamePronunciation) || (aFieldType == KUidContactFieldAdditionalName) ||

	    (aFieldType == KUidContactFieldSuffixName) || (aFieldType == KUidContactFieldPrefixName)  ||

	    (aFieldType == KUidContactFieldDepartmentName) || (aFieldType == KUidContactFieldClass) || 
	    
	    (aFieldType == KUidContactFieldClass))
	    	{
			SetRandomAlphaString(bufPtr, SharedConstants::KMaxBufferLength);
			aField.TextStorage()->SetTextL(bufPtr);
	    	}

	else if ((aFieldType == KUidContactFieldPostcode ) || (aFieldType == KUidContactFieldPhoneNumber) ||

		 (aFieldType == KUidContactFieldAnniversary ) || (aFieldType == KUidContactFieldSms) ||

		 (aFieldType == KUidContactFieldFax ) || (aFieldType == KUidContactFieldBirthday) ||

		 (aFieldType == KUidContactFieldICCPhonebook ) || (aFieldType == KUidContactFieldDTMF) ||

		 (aFieldType == KUidContactFieldICCSlot) ||  (aFieldType == KUidContactsVoiceDialField))
		 	{
		   	SetRandomNumericString(bufPtr, SharedConstants::KMaxBufferLength);
			aField.TextStorage()->SetTextL(bufPtr);
		 	}

	else if ((aFieldType == KUidContactFieldAddress ) || (aFieldType == KUidContactFieldPostOffice) ||

		(aFieldType == KUidContactFieldExtendedAddress ) ||  (aFieldType == KUidContactFieldLocality) ||

		(aFieldType == KUidContactFieldEMail ) || (aFieldType == KUidContactFieldMsg) ||

		(aFieldType == KUidContactFieldUrl ) || (aFieldType == KUidContactFieldPicture) ||

		(aFieldType == KUidContactFieldRingTone) ||  (aFieldType == KUidContactFieldICCGroup) ||

		(aFieldType == KUidContactFieldIMAddress ) || (aFieldType == KUidContactFieldSecondName) ||

		(aFieldType == KUidContactFieldSIPID))
			{
			SetRandomAlphaNumericString(bufPtr, SharedConstants::KMaxBufferLength);
			aField.TextStorage()->SetTextL(bufPtr);
			}
	CleanupStack::PopAndDestroy(); // buf
	}

/**
 * Update the specified buffer with random alpha content as per specified length
 * @param aBuf - Buffer to be updated
 * @param aLength - Length information
 */
void TAddModifyDeleteContactFields::SetRandomAlphaString(TDes& aBuf,TInt aLength)
	{
	aBuf.SetLength(aLength);

	for (TInt ii = 0; ii < aLength; ++ii)
		{
		aBuf[ii] = RandomAlphaCharCode();
		}
	}

/**
 * Update the specified buffer with random numeric content as per specified length
 * @param aBuf - Buffer to be updated
 * @param aLength - Length information
 */
void TAddModifyDeleteContactFields::SetRandomNumericString(TDes& aBuf,TInt aLength)
	{
	aBuf.SetLength(aLength);

	for (TInt ii = 0; ii < aLength; ++ii)
		{
		aBuf[ii] = RandomNumericCharCode();
		}
	}

/**
 * Update the specified buffer with random alpha and numeric content as per specified length
 * @param aBuf - Buffer to be updated
 * @param aLength - Length information
 */
void TAddModifyDeleteContactFields::SetRandomAlphaNumericString(TDes& aBuf,TInt aLength)
	{
	aBuf.SetLength(aLength);
	for (TInt ii = 0; ii < (aLength-1); ii = ii+2)
		{
		aBuf[ii] = RandomAlphaCharCode();
		aBuf[ii+1] = RandomNumericCharCode();
		}
	}

/**
 * Returns any random character between A to Z
 * @return TText - Random Character
 */
TText TAddModifyDeleteContactFields::RandomAlphaCharCode()
	{
	return RandomCharCode('A','Z',' ');
	}

/**
 * Returns any random ascii character equivalent of number between 0 to 9
 * @return TText - Random Number 
 */
TText TAddModifyDeleteContactFields::RandomNumericCharCode()
	{
	return RandomCharCode('0','9',' ');
	}


TText TAddModifyDeleteContactFields::RandomCharCode(TText aLowerBound,TText aUpperBound,TText aException)
	{
	TText charCode = 0;

	do
		{
		charCode=RandomCharCode(aLowerBound,aUpperBound);
		}
		while (charCode == aException);

	return charCode;
	}

TText TAddModifyDeleteContactFields::RandomCharCode(TText aLowerBound,TText aUpperBound)
	{
	TText charCode = STATIC_CAST(TText,(Math::Rand(iRandSeed) % (aUpperBound - aLowerBound)) + aLowerBound);
	ASSERT(charCode >= aLowerBound && charCode <= aUpperBound);
	return charCode;
	}


/**
* Retrieve the contact field uid information based on the contact field information specified in string format
* @param aContactFieldString - Contact field information in String format
* @return TUid - The contact field information in uid format
*/

TUid TAddModifyDeleteContactFields::GetContactFieldType(const TPtrC& aContactFieldString)
	{

	_LIT(KAddress, 						"Address");
	_LIT(KPostOffice,					"PostOffice");
	_LIT(KExtendedAddress, 				"ExtendedAddress");
	_LIT(KLocality,	 					"Locality");
	_LIT(KRegion,	 					"Region");
	_LIT(KPostCode,	 					"PostCode");
	_LIT(KCountry,	 					"Country");
	_LIT(KCompanyName, 					"CompanyName");
	_LIT(KCompanyNamePronunciation, 	"CompanyNamePronunciation");
	_LIT(KPhoneNumber,     				"PhoneNumber");
	_LIT(KGivenName,       		        "GivenName");
	_LIT(KFamilyName,                	"FamilyName");
	_LIT(KGivenNamePronunciation,     	"GivenNamePronunciation");
	_LIT(KFamilyNamePronunciation,    	"FamilyNamePronunciation");
	_LIT(KAdditionalName,             	"AdditionalName");
	_LIT(KSuffixName,                	"SuffixName");
	_LIT(KPrefixName,                	"PrefixName");
	_LIT(KHidden,                		"Hidden");
	_LIT(KEMail,                		"EMail");
	_LIT(KMsg,                			"Msg");
	_LIT(KSms,                			"Sms");
	_LIT(KFax,                			"Fax");
	_LIT(KNote,			  				"Note");
	_LIT(KBirthday,		          		"Birthday");
	_LIT(KUrl,			  				"Url");
	_LIT(KPicture,		          		"Picture");
	_LIT(KRingTone,		          		"RingTone");
	_LIT(KDTMF,			  				"DTMF");
	_LIT(KVoiceDialField,		  		"VoiceDialField");
	_LIT(KJobTitle,		          		"JobTitle");
	_LIT(KICCSlot,		          		"ICCSlot");
	_LIT(KICCPhonebook,	          		"ICCPhonebook");
	_LIT(KICCGroup,		          		"ICCGroup");
	_LIT(KIMAddress,		  			"IMAddress");
	_LIT(KSecondName,		  			"SecondName");
	_LIT(KSIPID,		          		"SIPID");
	_LIT(KAssistant,		  			"Assistant");
	_LIT(KAnniversary,	          		"Anniversary");
	_LIT(KSpouse,		          		"Spouse");
	_LIT(KChildren,		          		"Children");
	_LIT(KClass,		          		"Class");
	_LIT(KDepartmentName,	          	"DepartmentName");

	TUid	uid;

	if ( aContactFieldString.Compare(KAddress) == 0)
		{
		uid = KUidContactFieldAddress;
		}
	else if ( aContactFieldString.Compare(KPostOffice) == 0)
		{
		uid = KUidContactFieldPostOffice;
		}
	else if ( aContactFieldString.Compare(KExtendedAddress) == 0)
		{
		uid = KUidContactFieldExtendedAddress;
		}
	else if ( aContactFieldString.Compare(KLocality) == 0)
		{
		uid = KUidContactFieldLocality;
		}
	else if ( aContactFieldString.Compare(KRegion) == 0)
		{
		uid = KUidContactFieldRegion;
		}
	else if ( aContactFieldString.Compare(KPostCode) == 0)
		{
		uid = KUidContactFieldPostcode;
		}
	else if ( aContactFieldString.Compare(KCountry) == 0)
		{
		uid = KUidContactFieldCountry;
		}
	else if ( aContactFieldString.Compare(KCompanyName) == 0)
		{
		uid = KUidContactFieldCompanyName;
		}
	else if ( aContactFieldString.Compare(KCompanyNamePronunciation) == 0)
		{
		uid = KUidContactFieldCompanyNamePronunciation;
		}
	else if ( aContactFieldString.Compare(KPhoneNumber) == 0)
		{
		uid = KUidContactFieldPhoneNumber;
		}
	else if ( aContactFieldString.Compare(KGivenName) == 0)
		{
		uid = KUidContactFieldGivenName;
		}
	else if ( aContactFieldString.Compare(KFamilyName) == 0)
		{
		uid = KUidContactFieldFamilyName;
		}
	else if ( aContactFieldString.Compare(KGivenNamePronunciation) == 0)
		{
		uid = KUidContactFieldGivenNamePronunciation;
		}
	else if ( aContactFieldString.Compare(KFamilyNamePronunciation) == 0)
		{
		uid = KUidContactFieldFamilyNamePronunciation;
		}
	else if ( aContactFieldString.Compare(KAdditionalName) == 0)
		{
		uid = KUidContactFieldAdditionalName;
		}
	else if ( aContactFieldString.Compare(KSuffixName) == 0)
		{
		uid = KUidContactFieldSuffixName;
		}
	else if ( aContactFieldString.Compare(KPrefixName) == 0)
		{
		uid = KUidContactFieldPrefixName;
		}
	else if ( aContactFieldString.Compare(KHidden) == 0)
		{
		uid = KUidContactFieldHidden;
		}
	else if ( aContactFieldString.Compare(KEMail) == 0)
		{
		uid = KUidContactFieldEMail;
		}
	else if ( aContactFieldString.Compare(KMsg) == 0)
		{
		uid = KUidContactFieldMsg;
		}
	else if ( aContactFieldString.Compare(KSms) == 0)
		{
		uid = KUidContactFieldSms;
		}
	else if ( aContactFieldString.Compare(KFax) == 0)
		{
		uid = KUidContactFieldFax;
		}
	else if ( aContactFieldString.Compare(KNote) == 0)
		{
		uid = KUidContactFieldNote;
		}
	else if ( aContactFieldString.Compare(KBirthday) == 0)
		{
		uid = KUidContactFieldBirthday;
		}
	else if ( aContactFieldString.Compare(KUrl) == 0)
		{
		uid = KUidContactFieldUrl;
		}
	else if ( aContactFieldString.Compare(KPicture) == 0)
		{
		uid = KUidContactFieldPicture;
		}
	else if ( aContactFieldString.Compare(KRingTone) == 0)
		{
		uid = KUidContactFieldRingTone;
		}
	else if ( aContactFieldString.Compare(KDTMF) == 0)
		{
		uid = KUidContactFieldDTMF;
		}
	else if ( aContactFieldString.Compare(KVoiceDialField) == 0)
		{
		uid = KUidContactsVoiceDialField;
		}
	else if ( aContactFieldString.Compare(KJobTitle) == 0)
		{
		uid = KUidContactFieldJobTitle;
		}
	else if ( aContactFieldString.Compare(KICCSlot) == 0)
		{
		uid = KUidContactFieldICCSlot;
		}
	else if ( aContactFieldString.Compare(KICCPhonebook) == 0)
		{
		uid = KUidContactFieldICCPhonebook;
		}
	else if ( aContactFieldString.Compare(KICCGroup) == 0)
		{
		uid = KUidContactFieldICCGroup;
		}
	else if ( aContactFieldString.Compare(KIMAddress) == 0)
		{
		uid = KUidContactFieldIMAddress;
		}
	else if ( aContactFieldString.Compare(KSecondName) == 0)
		{
		uid = KUidContactFieldSecondName;
		}
	else if ( aContactFieldString.Compare(KSIPID) == 0)
		{
		uid = KUidContactFieldSIPID;
		}
	else if ( aContactFieldString.Compare(KAssistant) == 0)
		{
		uid = KUidContactFieldAssistant;
		}
	else if ( aContactFieldString.Compare(KAnniversary) == 0)
		{
		uid = KUidContactFieldAnniversary;
		}
	else if ( aContactFieldString.Compare(KSpouse) == 0)
		{
		uid = KUidContactFieldSpouse;
		}
	else if ( aContactFieldString.Compare(KChildren) == 0)
		{
		uid = KUidContactFieldChildren;
		}
	else if ( aContactFieldString.Compare(KClass) == 0)
		{
		uid = KUidContactFieldClass;
		}
	else if ( aContactFieldString.Compare(KDepartmentName) == 0)
		{
		uid = KUidContactFieldDepartmentName;
		}
	else
		{
		uid = KUidContactFieldNone;
		}

	return uid;
	}

/**
 * Adds contact field to meet the specified contact based to meet the filter requirements
 * @param aContact contact to be updated
 * @param aBitWiseFilter desired view filter
 */
void TAddModifyDeleteContactFields::AddFilterBasedFieldsL(CContactItem& aContact, TInt aBitWiseFilter)
	{
	HBufC* buf = HBufC::NewLC(SharedConstants::KMaxBufferLength);
	TPtr bufPtr = buf->Des();

	if(aBitWiseFilter & CContactDatabase::ELandLine)
		{
		SetRandomNumericString(bufPtr,SharedConstants::KMaxBufferLength);
		SetWorkPhoneL(aContact, bufPtr);
		}

	if(aBitWiseFilter & CContactDatabase::ESmsable)
		{
		SetRandomNumericString(bufPtr, SharedConstants::KMaxBufferLength);
		SetWorkMobileL(aContact, bufPtr);
		}

	if(aBitWiseFilter & CContactDatabase::EMailable)
		{
		SetRandomAlphaNumericString(bufPtr, SharedConstants::KMaxBufferLength);
		if (aBitWiseFilter&CContactDatabase::EHome)
			SetHomeEmailAddressL(aContact, bufPtr);
		else
			SetWorkEmailAddressL(aContact, bufPtr);
		}

	if(aBitWiseFilter & CContactDatabase::EFaxable)
		{
		SetRandomNumericString(bufPtr, SharedConstants::KMaxBufferLength);
		SetFaxL(aContact, bufPtr);
		}

	if(aBitWiseFilter & CContactDatabase::ERingTone)
		{
		SetRandomNumericString(bufPtr, SharedConstants::KMaxBufferLength);
		SetRingToneL(aContact, bufPtr);
		}

	if(aBitWiseFilter & CContactDatabase::EVoiceDial)
		{
		SetRandomNumericString(bufPtr, SharedConstants::KMaxBufferLength);
		SetVoiceDialL(aContact, bufPtr);
		}

	if(aBitWiseFilter & CContactDatabase::EWirelessVillage)
		{
		SetRandomNumericString(bufPtr, SharedConstants::KMaxBufferLength);
		SetIMAddressL(aContact, bufPtr);
		}
	if(aBitWiseFilter & CContactDatabase::EIMAddress)
		{
		SetRandomAlphaNumericString(bufPtr, SharedConstants::KMaxBufferLength);
		SetIMAddressL(aContact, bufPtr);
		}

	CleanupStack::PopAndDestroy(buf);
	}

/**
 * Adds contact field to meet the work phone filter requirement
 * @param aContact contact to be updated
 * @param aWorkPhone content for work phone contact field
 */
void TAddModifyDeleteContactFields::SetWorkPhoneL(CContactItem& aContact, const TDesC& aWorkPhone)
	{
	CContentType* contentType = CContentType::NewL();
	CleanupStack::PushL(contentType);
	contentType->AddFieldTypeL(KUidContactFieldPhoneNumber);
	contentType->AddFieldTypeL(KUidContactFieldVCardMapWORK);
	contentType->AddFieldTypeL(KUidContactFieldVCardMapVOICE);
	SetTextFieldL(aContact, *contentType,aWorkPhone);
	CleanupStack::PopAndDestroy(contentType); 
	}

/**
 * Adds contact field to meet the work mobile filter requirement
 * @param aContact contact to be updated
 * @param aWorkMobile content for work mobile contact field
 */
void TAddModifyDeleteContactFields::SetWorkMobileL(CContactItem& aContact, const TDesC& aWorkMobile)
	{
	CContentType* contentType = CContentType::NewL();
	CleanupStack::PushL(contentType);
	contentType->AddFieldTypeL(KUidContactFieldPhoneNumber);
	contentType->AddFieldTypeL(KUidContactFieldVCardMapWORK);
	contentType->AddFieldTypeL(KUidContactFieldVCardMapVOICE);
	contentType->AddFieldTypeL(KUidContactFieldVCardMapCELL);
	SetTextFieldL(aContact, *contentType,aWorkMobile);
	CleanupStack::PopAndDestroy(contentType); 
	}

/**
 * Adds contact field to meet the home phone filter requirement
 * @param aContact contact to be updated
 * @param aHomePhone content for home phone contact field
 */
void TAddModifyDeleteContactFields::SetHomePhoneL(CContactItem& aContact, const TDesC& aHomePhone)
	{
	CContentType* contentType = CContentType::NewL();
	CleanupStack::PushL(contentType);
	contentType->AddFieldTypeL(KUidContactFieldPhoneNumber);
	contentType->AddFieldTypeL(KUidContactFieldVCardMapHOME);
	contentType->AddFieldTypeL(KUidContactFieldVCardMapVOICE);
	SetTextFieldL(aContact, *contentType,aHomePhone);
	CleanupStack::PopAndDestroy(contentType); 
	}

/**
 * Adds contact field to meet the home mobile filter requirement
 * @param aContact contact to be updated
 * @param aHomeMobile content for home mobile contact field
 */
void TAddModifyDeleteContactFields::SetHomeMobileL(CContactItem& aContact, const TDesC& aHomeMobile)
	{
	CContentType* contentType = CContentType::NewL();
	CleanupStack::PushL(contentType);
	contentType->AddFieldTypeL(KUidContactFieldPhoneNumber);
	contentType->AddFieldTypeL(KUidContactFieldVCardMapHOME);
	contentType->AddFieldTypeL(KUidContactFieldVCardMapVOICE);
	contentType->AddFieldTypeL(KUidContactFieldVCardMapCELL);
	SetTextFieldL(aContact, *contentType,aHomeMobile);
	CleanupStack::PopAndDestroy(contentType); 
	}
	
/**
 * Adds contact field to meet the home email filter requirement
 * @param aContact contact to be updated
 * @param aEmailAddress content for home email contact field
 */
void TAddModifyDeleteContactFields::SetHomeEmailAddressL(CContactItem& aContact, const TDesC& aEmailAddress)
	{
	CContentType* contentType = CContentType::NewL();
	CleanupStack::PushL(contentType);
	contentType->AddFieldTypeL(KUidContactFieldEMail);
	contentType->AddFieldTypeL(KUidContactFieldVCardMapHOME);
	SetTextFieldL(aContact, *contentType,aEmailAddress);
	CleanupStack::PopAndDestroy(contentType);
	}

/**
 * Adds contact field to meet the work email filter requirement
 * @param aContact contact to be updated
 * @param aEmailAddress content for work email contact field
 */
void TAddModifyDeleteContactFields::SetWorkEmailAddressL(CContactItem& aContact, const TDesC& aEmailAddress)
	{
	CContentType* contentType = CContentType::NewL();
	CleanupStack::PushL(contentType);
	contentType->AddFieldTypeL(KUidContactFieldEMail);
	contentType->AddFieldTypeL(KUidContactFieldVCardMapWORK);
	SetTextFieldL(aContact, *contentType,aEmailAddress);
	CleanupStack::PopAndDestroy(contentType);
	}

/**
 * Adds a new contact field to meet the fax filter requirement
 * @param aContact contact to be updated
 * @param aFax content for fax contact field
 */
void TAddModifyDeleteContactFields::SetFaxL(CContactItem& aContact, const TDesC& aFax)
	{
	CContentType* contentType = CContentType::NewL();
	CleanupStack::PushL(contentType);
	contentType->AddFieldTypeL(KUidContactFieldFax);
	SetTextFieldL(aContact, *contentType, aFax);
	CleanupStack::PopAndDestroy(contentType); 
	}
	
/**
 * Adds a new contact field to meet the IMAddress filter requirement
 * @param aContact contact to be updated
 * @param aIMAddress content for fax contact field
 */
void TAddModifyDeleteContactFields::SetIMAddressL(CContactItem& aContact, const TDesC& aIMAddress)
	{
	CContentType* contentType = CContentType::NewL();
	CleanupStack::PushL(contentType);
	contentType->AddFieldTypeL(KUidContactFieldIMAddress);
	SetTextFieldL(aContact, *contentType, aIMAddress);
	CleanupStack::PopAndDestroy(contentType); 
	}

/**
 * Adds a new contact field to meet the voice dial filter requirement
 * @param aContact contact to be updated
 * @param aVoiceDial content for voice dial contact field
 */
void TAddModifyDeleteContactFields::SetVoiceDialL(CContactItem& aContact, const TDesC& aVoiceDial)
	{
	CContentType* contentType = CContentType::NewL();
	CleanupStack::PushL(contentType);
	contentType->AddFieldTypeL(KUidContactsVoiceDialField);
	SetTextFieldL(aContact,  *contentType, aVoiceDial );
	CleanupStack::PopAndDestroy(contentType); 
	}

/**
 * Adds a new contact field to meet the ring tone filter requirement
 * @param aContact contact to be updated
 * @param aRingTone content for ring tone contact field
 */
void TAddModifyDeleteContactFields::SetRingToneL(CContactItem& aContact, const TDesC& aRingTone)
	{
	CContentType* contentType = CContentType::NewL();
	CleanupStack::PushL(contentType);
	contentType->AddFieldTypeL(KUidContactFieldRingTone);
	SetTextFieldL(aContact, *contentType, aRingTone );
	CleanupStack::PopAndDestroy(contentType); 
	}
	
/**
 * Adds desired contact field content to the contact specified
 * @param aContact contact to be updated
 * @param aTypesToMatch Storage type for Contact Field
 * @param aText content for the desired field
 */
void TAddModifyDeleteContactFields::SetTextFieldL(CContactItem& aContact, const CContentType& aTypesToMatch, const TDesC& aText)
	{
	TStorageType storageType = KStorageTypeText;
	CContactItemField* field = 	CContactItemField::NewL(storageType, aTypesToMatch);
	CleanupStack::PushL(field);
	field->TextStorage()->SetTextL(aText);
	aContact.AddFieldL(*field);
	CleanupStack::Pop(field);	
	}

/**
 * Update the contact item fields with new content
 * @param aContact contact to be updated
 */
void TAddModifyDeleteContactFields::UpdateFieldsL(CContactItem& aContact)
	{
	CContactItemFieldSet& fieldSet = aContact.CardFields();
	for(TInt i = 0; i < fieldSet.Count();i++)
		{
		TFieldType fieldType(KUidContactFieldNone);
		CContactItemField& field = fieldSet[i];
		SetDataL(fieldType, field);
		}
	}