summaryrefslogtreecommitdiffstats
path: root/plugins/contacts/symbian/contactsmodel/tsrc/integration/cntperftest/src/preparedatateststep.cpp
blob: c4cc7510806dc4ffa87916fdf8bbfeb565d87f74 (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
/*
* 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 "preparedatateststep.h"

/**
 * Constructor
 */
CPrepareDataTestStep::CPrepareDataTestStep()
	{
	// Mandatory call to base class method to set up the human readable name for logging.
	SetTestStepName(KPrepareDataTestStep);
	}

/**
 * Destructor
 */
CPrepareDataTestStep::~CPrepareDataTestStep()
	{
	iListOfContactItemsInDatabase.Close();
	}

/**
 * Setup the environment required for test, install schedular in the current thread
 * Opens the relevant contacts database file
 */
TVerdict CPrepareDataTestStep::doTestStepPreambleL()
	{
 	CTestContactViewDatabaseUtilitiesStep::doTestStepPreambleL();
	return TestStepResult();
	}

/**
 * Cleanup function for the test step
 */
TVerdict CPrepareDataTestStep::doTestStepPostambleL()
	{
 	CTestContactViewDatabaseUtilitiesStep::doTestStepPostambleL();
	return TestStepResult();
	}


/**
Base class pure virtual.
* @return EPass or EFail indicating the result of the test step.
*/
TVerdict CPrepareDataTestStep::doTestStepL()
	{
	ImportContactsL();
	AddContactsInDatabaseL();
	IterateThroAllSortOrderSectionsAndUpdateContactsInDatabaseL();
	IterateThroAllFilterViewsSectionsAndUpdateL();
	IterateThroAllMatchingStringSectionsAndUpdateL();
	AddGroupsInDatabaseL();
	IterateThroAllGroupSectionsAndUpdateL();
	UpdateContactToSpecificStringL();
	CloseDatabaseL();
	CopyDatabaseL();
	return TestStepResult();
	}

/**
* Import Contact entries
*/
void CPrepareDataTestStep::ImportContactsL()
	{
	ViewUtilityReference().ImportContactsL();
	}

/**
 * Here we are trying add blank contact items in the database
 * Say some 2000 thousand contacts are added to the database
 */
void CPrepareDataTestStep::AddContactsInDatabaseL()
	{
	_LIT(KNumOfContacts, "numofcontacts");
	TInt numOfContacts = 0;
	GetIntFromConfig(ConfigSection(), KNumOfContacts, numOfContacts);

	for(TInt i = 0; i < numOfContacts; ++i)
		{
		CContactCard* contactCard = CContactCard::NewL();
		CleanupStack::PushL(contactCard);
		TContactItemId contactId = DatabaseReference().AddNewContactL(*contactCard);
		CleanupStack::PopAndDestroy(contactCard);
		iListOfContactItemsInDatabase.AppendL(contactId);
		DatabaseReference().CloseContactL(contactId);
		}

	TInt count = DatabaseReference().CountL();
	_LIT(KDatabaseCount, "Total number of contact entries is %d :");
	INFO_PRINTF2(KDatabaseCount, count);
	}


/* As mentioned earlier there will be some 1000 blank contacts in the database
 * Now any view will have it's own criteria like
 * -- view sort order i.e. the order in which the contact items in the view must be sorted
 * -- view preferences i.e. whether only contact cards or contact groups or both must be included in the view
 *    whether the unsorted contacts must be included in the view or not, if included, whether they must be included in the
 *    start of view or end  of view
 * It becomes necessary to supply the necessary envirnoment that meets the view criteia
 * Each view can supply its desired criteria. Based on this, the contacts in the database will be updated to meet the view specificattions
 */
void CPrepareDataTestStep::IterateThroAllSortOrderSectionsAndUpdateContactsInDatabaseL()
	{
	_LIT(KListOfSortOrderSections, "listofsortorder");
	TPtrC listOfSortOrderSectionsString;
	GetStringFromConfig(ConfigSection(), KListOfSortOrderSections, listOfSortOrderSectionsString);

	RArray<TPtrC>	listOfSortOrderSections;
	CleanupClosePushL(listOfSortOrderSections);

	ViewUtilityReference().TokenizeStringL(listOfSortOrderSectionsString, listOfSortOrderSections);

	for ( TInt i = 0; i < listOfSortOrderSections.Count(); ++i )
		{
		UpdateContactFieldsSpecificToSortOrderL(listOfSortOrderSections[i]);
		}

	CleanupStack::PopAndDestroy(&listOfSortOrderSections);
	}

/**
 * Here we are trying add contacts fields in the existing contacts such that they meet the contact views
 * Sort Order. Intentionally some of the contacts are updated with the contact fields of Null data to meet
 * the unsorted contacts criteria
 */
void CPrepareDataTestStep::UpdateContactFieldsSpecificToSortOrderL(const TPtrC& aSortOrderSection)
	{
	// Based on the sort order, the desired number of contacts will be updated i.e contact fields will be
	// added to the contacts in the database. The new fields added will be as per the sort order
	// at the end of this operation, if we constuct a contact view with this sort order
	// then the desired number of contacts will be included in the view

	_LIT(KViewSortOrder, "sortorder");
	TPtrC viewSortOrderString;
	GetStringFromConfig(aSortOrderSection, KViewSortOrder, viewSortOrderString);

	RContactViewSortOrder sortOrder = ViewUtilityReference().ConvertStringToSortOrderL(viewSortOrderString) ;
	CleanupClosePushL(sortOrder);

	_LIT(KNumOfSortableContacts, "numofsortablecontacts");
	TInt numOfSortableContacts;
	GetIntFromConfig(aSortOrderSection, KNumOfSortableContacts, numOfSortableContacts);

	// Here we are trying to update the desired number of contacts in the database
	// with Null contact fields in order to meet the unsortable contacts requirement

	_LIT(KNumUnSortableContacts, "numunsortedcontacts");
	TInt numUnSortableContacts;
	GetIntFromConfig(aSortOrderSection, KNumUnSortableContacts, numUnSortableContacts);

	const TInt KTotalNumOfContactsSpecificToThisSortOrder =  numOfSortableContacts + numUnSortableContacts;

	TInt numberOfReadySortableContacts = 0;
	TInt numberOfReadyUnSortableContacts = 0;

	// There may be contact items in the database that meet the sort order
	// We need be sure about the contact items that we should update

	RArray <TContactItemId> ListOfContactItemsThatCanUpdatedToMeetSortOrder;
	CleanupClosePushL(ListOfContactItemsThatCanUpdatedToMeetSortOrder);


	for(TInt i = 0; i < iListOfContactItemsInDatabase.Count(); ++i)
		{
		TContactItemId desiredContactItemId = iListOfContactItemsInDatabase[i];
		CContactItem* contact = DatabaseReference().OpenContactL(desiredContactItemId);
		CleanupStack::PushL(contact);
		CContactItemFieldSet& fieldSet = contact->CardFields();

		TInt firstContactFieldPosition = fieldSet.Find(sortOrder[0]);
		TInt secondContactFieldPosition = fieldSet.Find(sortOrder[1]);
		TInt thirdContactFieldPosition = fieldSet.Find(sortOrder[2]);

		if ((firstContactFieldPosition != KErrNotFound) &&  (secondContactFieldPosition != KErrNotFound) && (thirdContactFieldPosition!= KErrNotFound))
			{
			CContactItemField& firstContactItemField = fieldSet[firstContactFieldPosition];
			CContactItemField& secondContactItemField = fieldSet[secondContactFieldPosition];
			CContactItemField& thirdContactItemField  = fieldSet[thirdContactFieldPosition];

			if((firstContactItemField.Storage() == NULL) && (secondContactItemField.Storage() == NULL) && (thirdContactItemField.Storage() == NULL))
				{
		  		++numberOfReadyUnSortableContacts;
				}
			else
				{
				++numberOfReadySortableContacts;
				}
			}
		else
			{
			ListOfContactItemsThatCanUpdatedToMeetSortOrder.AppendL(desiredContactItemId);
			}

		CleanupStack::PopAndDestroy(contact);
		DatabaseReference().CloseContactL(desiredContactItemId);
		}

	if((numberOfReadyUnSortableContacts + numberOfReadySortableContacts) < KTotalNumOfContactsSpecificToThisSortOrder)
		{
		TInt j = 0;
		for(; j < (numOfSortableContacts-numberOfReadySortableContacts); ++j)
			{
			TContactItemId contactItemIdToBeUpdated = ListOfContactItemsThatCanUpdatedToMeetSortOrder[j];
			CContactItem* contact = DatabaseReference().OpenContactL(contactItemIdToBeUpdated);
			CleanupStack::PushL(contact);
			AddContactFieldL(*contact, sortOrder, ETrue);
			DatabaseReference().CommitContactL(*contact);
			DatabaseReference().CloseContactL(contactItemIdToBeUpdated);
			CleanupStack::PopAndDestroy(contact);
			}

		for(TInt k = j; k < (j + (numUnSortableContacts-numberOfReadyUnSortableContacts)); ++k)
			{
			TContactItemId contactItemIdToBeUpdated = ListOfContactItemsThatCanUpdatedToMeetSortOrder[k];
			CContactItem* contact = DatabaseReference().OpenContactL(contactItemIdToBeUpdated);
			CleanupStack::PushL(contact);
			AddContactFieldL(*contact, sortOrder);
			DatabaseReference().CommitContactL(*contact);
			DatabaseReference().CloseContactL(contactItemIdToBeUpdated);
			CleanupStack::PopAndDestroy(contact);
			}
		}

	CleanupStack::PopAndDestroy(2,&sortOrder);
	}

/** Adds contact fields specific to sort order,
 * Sort Order. Intentionally some of the contacts are updated with the contact fields of Null data to meet
 * the unsorted contacts criteria
 */
void CPrepareDataTestStep::AddContactFieldL(CContactItem& aContact, const RContactViewSortOrder& aSortOrder,
																								TBool aDataRequired)
	{
	const TInt KMaxSortOrderCount = 3;
	for(TInt i = 0; i < KMaxSortOrderCount; ++i)
		{
		TFieldType fieldType = aSortOrder[i];
		TStorageType storageType = GetStorageType(fieldType);
		CContentType* contentType = CContentType::NewL();
		CleanupStack::PushL(contentType);
		contentType->AddFieldTypeL(fieldType);
		CContactItemField* field = 	CContactItemField::NewL(storageType, *contentType);
		CleanupStack::PushL(field);

		if(aDataRequired)
			{
			SetDataL(fieldType, *field);
			}

		aContact.AddFieldL(*field);
		CleanupStack::Pop(field);
		CleanupStack::PopAndDestroy(contentType);
		}
	}

/**
 * Reads all the sections in the ini file relevant for updating the contacts database
 * in order to meet filter view requirements
 */
void CPrepareDataTestStep::IterateThroAllFilterViewsSectionsAndUpdateL()
	{
	_LIT(KListOfFilterViewSectionsString, "listoffilterviewsections");
	TPtrC listOfFilterViewSectionsString;
	GetStringFromConfig(ConfigSection(), KListOfFilterViewSectionsString, listOfFilterViewSectionsString);

	RArray<TPtrC>	listOfFilterViewSections;
	CleanupClosePushL(listOfFilterViewSections);
	ViewUtilityReference().TokenizeStringL(listOfFilterViewSectionsString, listOfFilterViewSections);

	for(TInt i = 0; i < listOfFilterViewSections.Count(); ++i)
		{
		UpdateContactsInDatabaseAsPerFilteredViewRequirementsL(listOfFilterViewSections[i]);
		}

	CleanupStack::PopAndDestroy(&listOfFilterViewSections);
	}

/**
 * Updates contacts in database as per filter view requirements specified in the ini section
 */
void CPrepareDataTestStep::UpdateContactsInDatabaseAsPerFilteredViewRequirementsL(const TPtrC& aFilteredViewSection)
	{
	_LIT(KViewSortOrder, "sortorder");
	TPtrC viewSortOrderString;
	GetStringFromConfig(aFilteredViewSection, KViewSortOrder, viewSortOrderString);

	RContactViewSortOrder sortOrder = 	ViewUtilityReference().ConvertStringToSortOrderL(viewSortOrderString);
	CleanupClosePushL(sortOrder);

	_LIT(KNumOfContactsWithFilter, "numofcontactswiththisfilter");
	TInt numOfContactsWithFilter;
	GetIntFromConfig(aFilteredViewSection, KNumOfContactsWithFilter, numOfContactsWithFilter);

	_LIT(KDesiredFilterString, "desiredFilter");
	TPtrC desiredFilterString;
	GetStringFromConfig(aFilteredViewSection, KDesiredFilterString, desiredFilterString);

	CContactDatabase::TContactViewFilter	viewFilter = ViewUtilityReference().GetContactViewFilterL(desiredFilterString);

	RArray<TContactItemId> contactSpecificToSortOrder;
	CleanupClosePushL(contactSpecificToSortOrder);

	RetrieveContactsSpecificToSortOrderL(sortOrder, contactSpecificToSortOrder);

	for(TInt i = 0; i < numOfContactsWithFilter; ++i)
		{
		TContactItemId id = contactSpecificToSortOrder[i];
		CContactItem* contactItem = DatabaseReference().OpenContactL(id);
		CleanupStack::PushL(contactItem);
		AddFilterBasedFieldsL(*contactItem, viewFilter);
		DatabaseReference().CommitContactL(*contactItem);
		DatabaseReference().CloseContactL(id);
		CleanupStack::PopAndDestroy(contactItem);
		}

	CleanupStack::PopAndDestroy(2, &sortOrder);
	}


/**
 * Retrieves contacts specific to desired sort order from the database
 */
void CPrepareDataTestStep::RetrieveContactsSpecificToSortOrderL(const RContactViewSortOrder& aSortOrder, RArray<TContactItemId>& aContactSpecificToSorder)
	{
	for(TInt i = 0; i < iListOfContactItemsInDatabase.Count(); ++i)
		{
		TContactItemId contactId = iListOfContactItemsInDatabase[i];
		CContactItem* contactItem = DatabaseReference().OpenContactL(contactId);
		CleanupStack::PushL(contactItem);
		TBool exists = CheckAllTheFieldsExists(*contactItem, aSortOrder);
		if(exists)
			{
			aContactSpecificToSorder.AppendL(contactId);
			}
		DatabaseReference().CloseContactL(contactId);
		CleanupStack::PopAndDestroy(contactItem);
		}

	}

/**
 * Checks whether all the three desired contact fields are present in the contact or not
 */
TBool CPrepareDataTestStep::CheckAllTheFieldsExists(const CContactItem& aContact, const RContactViewSortOrder& aSortOrder)
	{
	CContactItemFieldSet& fieldSet = aContact.CardFields();

	TInt firstContactFieldPosition = fieldSet.Find(aSortOrder[0]);
	TInt secondContactFieldPosition = fieldSet.Find(aSortOrder[1]);
	TInt thirdContactFieldPosition = fieldSet.Find(aSortOrder[2]);

	TInt error = KErrNotFound;

	if ((firstContactFieldPosition != error) &&  (secondContactFieldPosition != error) && (thirdContactFieldPosition!= error))
		{
		return ETrue;
		}
	else
		{
		return EFalse;
		}
	}


/**
 * Data is read from the ini file about the matching strings expected to be present in some of the
 * contact fields and desired number of contacts in the database are updated with this matching string info
 */
void CPrepareDataTestStep::IterateThroAllMatchingStringSectionsAndUpdateL()
	{
	_LIT(KListOfMatchingStringSectionsString, "listofMatchingString");
	TPtrC listOfMatchingStringSectionsString;
	GetStringFromConfig(ConfigSection(), KListOfMatchingStringSectionsString, listOfMatchingStringSectionsString);

	RArray<TPtrC>	listOfMatchingStringSections;
	CleanupClosePushL(listOfMatchingStringSections);
	ViewUtilityReference().TokenizeStringL(listOfMatchingStringSectionsString, listOfMatchingStringSections);

	for(TInt i = 0; i < listOfMatchingStringSections.Count(); ++i)
		{
		UpdateContactsInDatabaseAsPerMatchingStringsL(listOfMatchingStringSections[i]);
		}

	CleanupStack::PopAndDestroy(&listOfMatchingStringSections);
	}

/**
 * Updates the contacts in the database based on the data available in the ini section
 * @param aMatchingStringSection - Relevant section in the ini file
 */
void CPrepareDataTestStep::UpdateContactsInDatabaseAsPerMatchingStringsL(const TPtrC& aMatchingStringSection)
	{
	_LIT(KViewSortOrder, "sortorder");
	TPtrC viewSortOrderString;
	GetStringFromConfig(aMatchingStringSection, KViewSortOrder, viewSortOrderString);

	RContactViewSortOrder sortOrder = ViewUtilityReference().ConvertStringToSortOrderL(viewSortOrderString);
	CleanupClosePushL(sortOrder);


	_LIT(KNumOfContactsWithFilter, "numofcontactswiththisstring");
	TInt numOfContactsWithThisString;
	GetIntFromConfig(aMatchingStringSection, KNumOfContactsWithFilter, numOfContactsWithThisString);

	_LIT(KDesiredMatchingString, "matchingstring");
	TPtrC desiredMatchingString;
	GetStringFromConfig(aMatchingStringSection, KDesiredMatchingString, desiredMatchingString);

	_LIT(KDesiredContactField, "contactfield");
	TPtrC desiredContactField;
	GetStringFromConfig(aMatchingStringSection, KDesiredContactField, desiredContactField);

	TUid uidInfo = GetContactFieldType(desiredContactField);

	RArray<TContactItemId> contactSpecificToSortOrder;
	CleanupClosePushL(contactSpecificToSortOrder);

	RetrieveContactsSpecificToSortOrderL(sortOrder, contactSpecificToSortOrder);

	for(TInt i = 0; (i < (contactSpecificToSortOrder.Count()) && (i < numOfContactsWithThisString)); ++i)
		{
		TContactItemId id = contactSpecificToSortOrder[i];
		CContactItem* contactItem = DatabaseReference().OpenContactL(id);
		CleanupStack::PushL(contactItem);	// contactItem
		AddMatchingStringToContactL(*contactItem, uidInfo, desiredMatchingString);
		DatabaseReference().CommitContactL(*contactItem);
		DatabaseReference().CloseContactL(id);
		CleanupStack::PopAndDestroy(contactItem);
		}

	CleanupStack::PopAndDestroy(2, &sortOrder);

	}

/**
 * Update contacts in database with desired string
 * This feature is useful while constructing Find Views, Sub Views etc..
 * @param aContact - Contact to be updated
 * @param aUid - uid of field in the contact item to be updated
 * @param aDesiredMatchingString - Matching string
 */
void CPrepareDataTestStep::AddMatchingStringToContactL(CContactItem& aContact, TUid aUid, const TPtrC& aDesiredMatchingString)
	{
	CContactItemFieldSet& fieldSet = aContact.CardFields();
	TInt pos = fieldSet.Find(aUid);
	if(pos == KErrNotFound)
		{
		TFieldType fieldType = aUid;
		TStorageType storageType = GetStorageType(fieldType);
		CContentType* contentType = CContentType::NewL();
		contentType->AddFieldTypeL(fieldType);
		CContactItemField* field = 	CContactItemField::NewL(storageType, *contentType);
		CleanupStack::PushL(field);
		field->TextStorage()->SetTextL(aDesiredMatchingString);
		aContact.AddFieldL(*field);
		CleanupStack::Pop();	// field
		}
	else
		{
		CContactItemField& field = fieldSet[pos];
		field.TextStorage()->SetTextL(aDesiredMatchingString);
		}
	}

void CPrepareDataTestStep::UpdateContactToSpecificStringL()
	{
		_LIT(KListOfSetDesiredStringSections, "listofcontacttoupdate");
		TPtrC listOfSections;
		GetStringFromConfig(ConfigSection(), KListOfSetDesiredStringSections, listOfSections);

		RArray<TPtrC>	listOfUpdateContact;
		CleanupClosePushL(listOfUpdateContact);

		ViewUtilityReference().TokenizeStringL(listOfSections, listOfUpdateContact);

		for ( TInt i = 0; i < listOfUpdateContact.Count(); ++i )
			{
			UpdateContactFieldsToDesireStingL(listOfUpdateContact[i]);
			}

		CleanupStack::PopAndDestroy(&listOfUpdateContact);

	}

void CPrepareDataTestStep::UpdateContactFieldsToDesireStingL(const TPtrC& aMatchingStringSection)
	{
	_LIT(KViewSortOrder, "sortorder");
	_LIT(KContactId, "contactid");
	_LIT(KDesiredString, "desiredstring");

	TPtrC viewSortOrderString;
	GetStringFromConfig(aMatchingStringSection, KViewSortOrder, viewSortOrderString);

	RContactViewSortOrder sortOrder = ViewUtilityReference().ConvertStringToSortOrderL(viewSortOrderString) ;
	CleanupClosePushL(sortOrder);

	TInt contactId;
	GetIntFromConfig(aMatchingStringSection, KContactId, contactId);

	TPtrC desiredSting;
	GetStringFromConfig(aMatchingStringSection, KDesiredString, desiredSting);

	RArray<TContactItemId> contactSpecificToSortOrder;
	CleanupClosePushL(contactSpecificToSortOrder);

	RetrieveContactsSpecificToSortOrderL(sortOrder, contactSpecificToSortOrder);
	CContactItem* contactItem = DatabaseReference().OpenContactL(contactId);
	CleanupStack::PushL(contactItem);

	CContactItemFieldSet& fieldSet = contactItem->CardFields();

	TInt firstContactFieldPosition = fieldSet.Find(sortOrder[0]);
	TInt secondContactFieldPosition = fieldSet.Find(sortOrder[1]);
	TInt thirdContactFieldPosition = fieldSet.Find(sortOrder[2]);

	// Check whether they have content.
	CContactItemField& field1 = fieldSet[firstContactFieldPosition];
	CContactFieldStorage* firstStorage = field1.Storage();

	CContactItemField& field2 = fieldSet[secondContactFieldPosition];
	CContactFieldStorage* secondStorage = field2.Storage();

	CContactItemField& field3 = fieldSet[thirdContactFieldPosition];
	CContactFieldStorage* thirdStorage = field3.Storage();

	field1.TextStorage()->SetTextL(desiredSting);
	field2.TextStorage()->SetTextL(desiredSting);
	field3.TextStorage()->SetTextL(desiredSting);

	DatabaseReference().CommitContactL(*contactItem);
	DatabaseReference().CloseContactL(contactId);

	CleanupStack::PopAndDestroy(contactItem);
	CleanupStack::PopAndDestroy(&contactSpecificToSortOrder);
	CleanupStack::PopAndDestroy(&sortOrder);
	}