pimprotocols/phonebooksync/Server/SyncContactICCEntry.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 // Copyright (c) 2002-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 // Implementation of the Phonebook Synchroniser internal ICC Entry
       
    15 // representation class.
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent
       
    22 */
       
    23 
       
    24 #include "Phonebook.h"
       
    25 #include "PhonebookManager.h"
       
    26 #include "SyncContactICCEntry.h"
       
    27 #include "phbksync.h"
       
    28 #include "phbksyncsvr.h"
       
    29 #include "phbksyncsess.h"
       
    30 #include "phbksynclog.h"
       
    31 #include "common.h"
       
    32 
       
    33 
       
    34 /**
       
    35  *  Granularity of the arrays.
       
    36  */
       
    37 const TInt KSyncArrayGranularity = 4;
       
    38 
       
    39 
       
    40 /**
       
    41  *  Utility function to panic the server if needed.
       
    42  *
       
    43  *  @param aPanicCode  Phonebook Synchroniser Fault type 
       
    44  */
       
    45 GLDEF_C void PhBkSyncPanic(TPhBkSyncPanic aPanicCode)
       
    46 	{
       
    47 	LOGCOMMON2(_L8("PhBkSync Fault %d"), aPanicCode);
       
    48 	User::Panic(_L("PhBkSync Fault"), aPanicCode);
       
    49 	} // PhBkSyncPanic
       
    50 
       
    51 
       
    52 /**
       
    53  *  Factory method to create a CSyncContactICCEntry object.
       
    54  *
       
    55  *  @return Pointer to a new CSyncContactICCEntry object.
       
    56  */
       
    57 CSyncContactICCEntry* CSyncContactICCEntry::NewL()
       
    58 	{
       
    59 	CSyncContactICCEntry*  ptr = new (ELeave) CSyncContactICCEntry();
       
    60 	CleanupStack::PushL(ptr);
       
    61 	ptr->ConstructL();
       
    62 	CleanupStack::Pop(ptr);
       
    63 
       
    64 	return ptr;
       
    65 	} // CSyncContactICCEntry::NewL
       
    66 
       
    67 
       
    68 /**
       
    69  *  Standard constructor.
       
    70  */
       
    71 CSyncContactICCEntry::CSyncContactICCEntry()
       
    72   : iSlotNum(0),
       
    73     iTON(RMobilePhone::EUnknownNumber),
       
    74     iContactId(KNullContactId),
       
    75     iPhonebookUid(KUidIccGlobalAdnPhonebook),
       
    76     iIsHidden(EFalse),
       
    77     iTemplateId(KNullContactId)
       
    78 	{
       
    79 	// NOP
       
    80 	} // CSyncContactICCEntry::CSyncContactICCEntry
       
    81 
       
    82 
       
    83 /**
       
    84  *  Second phase constructor.
       
    85  */
       
    86 void CSyncContactICCEntry::ConstructL()
       
    87 	{
       
    88 	iNumberList = new (ELeave) CArrayFixFlat<TSyncAdditionalNumber>(KSyncArrayGranularity);
       
    89 	iGroupList = new (ELeave) CArrayFixFlat<TSyncEntryName>(KSyncArrayGranularity);
       
    90 	iEmailList = new (ELeave) CArrayFixFlat<TSyncEntryName>(KSyncArrayGranularity);
       
    91 	} //CSyncContactICCEntry::ConstructL
       
    92 
       
    93 
       
    94 /**
       
    95  *  Standard destructor.
       
    96  */
       
    97 CSyncContactICCEntry::~CSyncContactICCEntry()
       
    98 	{
       
    99 	delete iNumberList;
       
   100 	delete iGroupList;
       
   101 	delete iEmailList;
       
   102 	} // CSyncContactICCEntry::~CSyncContactICCEntry
       
   103 
       
   104 
       
   105 /**
       
   106  *  This method stores the streamed contents of the object into a CBufBase
       
   107  *  buffer.
       
   108  *
       
   109  *  @return Pointer to the allocated CBufFlat.
       
   110  */
       
   111 CBufBase* CSyncContactICCEntry::StoreL()
       
   112 	{
       
   113 	CBufBase* buf=CBufFlat::NewL(KSyncArrayGranularity);
       
   114 	CleanupStack::PushL(buf);
       
   115 
       
   116 	RBufWriteStream  strm(*buf);
       
   117 	strm << *this;
       
   118 	strm.CommitL();
       
   119 	CleanupStack::Pop(buf);
       
   120 
       
   121 	return buf;
       
   122 	} // CSyncContactICCEntry::StoreL
       
   123 
       
   124 
       
   125 /**
       
   126  *  This method stores the streamed contents of the oject into a
       
   127  *  descriptor.
       
   128  *
       
   129  *  @param aDes  Descriptor in which to store the object.
       
   130  */
       
   131 void CSyncContactICCEntry::StoreL(TDes8& aDes)
       
   132 	{
       
   133 	RDesWriteStream  strm(aDes);
       
   134 	strm << *this;
       
   135 	strm.CommitL();
       
   136 	} // CSyncContactICCEntry::StoreL
       
   137 
       
   138 
       
   139 /**
       
   140  *  This method retrieves the contents of a CSyncContactICCEntry from a
       
   141  *  descriptor.
       
   142  *
       
   143  * @param aBuf  Descriptor from which to read the CSyncContactICCEntry.
       
   144  */
       
   145 void CSyncContactICCEntry::RestoreL(const TDesC8& aBuf)
       
   146 	{
       
   147 	RDesReadStream  strm(aBuf);
       
   148 	strm >> *this;
       
   149 	} // CSyncContactICCEntry::RestoreL
       
   150 
       
   151 
       
   152 /**
       
   153  *  This method internalises the contents of a CSyncContactICCEntry from
       
   154  *  a stream.
       
   155  *
       
   156  *  @param aStream  The read stream containing a CSyncContactICCEntry.
       
   157  */
       
   158 void CSyncContactICCEntry::InternalizeL(RReadStream& aStream)
       
   159 	{
       
   160 	aStream >> iName;
       
   161 	aStream >> iSecondName;
       
   162 	aStream >> iNumber;
       
   163 	TInt count(aStream.ReadInt32L());	// list of additional numbers 
       
   164 	TInt i(0);
       
   165 	for(i=0; i<count; ++i)
       
   166 		{
       
   167 		TSyncAdditionalNumber addNumber;
       
   168 		aStream >> addNumber;
       
   169 		iNumberList->AppendL(addNumber);
       
   170 		}
       
   171 	count = aStream.ReadInt32L();		// group list
       
   172 	for(i=0; i<count; ++i)
       
   173 		{
       
   174 		TSyncEntryName group;
       
   175 		aStream >> group;
       
   176 		iGroupList->AppendL(group);
       
   177 		}
       
   178 	count = aStream.ReadInt32L();		// email list
       
   179 	for(i=0; i<count; ++i)
       
   180 		{
       
   181 		TSyncEntryName email;
       
   182 		aStream >> email;
       
   183 		iEmailList->AppendL(email);
       
   184 		}
       
   185 	iSlotNum = aStream.ReadInt32L();
       
   186 	iTON = static_cast<RMobilePhone::TMobileTON>(aStream.ReadUint32L());
       
   187 	iContactId = aStream.ReadInt32L();
       
   188 	iPhonebookUid = TUid::Uid(aStream.ReadInt32L());
       
   189 	iIsHidden = static_cast<TBool>(aStream.ReadInt32L());
       
   190 	iTemplateId = aStream.ReadInt32L();
       
   191 	} // CSyncContactICCEntry::InternalizeL
       
   192 
       
   193 
       
   194 /**
       
   195  *  This method externalizes the contents of a CSyncContactICCEntry into
       
   196  *  a stream.
       
   197  *
       
   198  *  @param aStream  The write stream that will contain a CSyncContactICCEntry.
       
   199  */
       
   200 void CSyncContactICCEntry::ExternalizeL(RWriteStream& aStream) const
       
   201 	{
       
   202 	aStream << iName;
       
   203 	aStream << iSecondName;
       
   204 	aStream << iNumber;
       
   205 	TInt count(iNumberList->Count());	// list of additional numbers
       
   206 	TInt i(0);
       
   207 	aStream.WriteInt32L(count);
       
   208 	for(i=0; i<count; ++i)
       
   209 		aStream << iNumberList->At(i);
       
   210 	count = iGroupList->Count();		// group list
       
   211 	aStream.WriteInt32L(count);
       
   212 	for(i=0; i<count; ++i)
       
   213 		aStream << iGroupList->At(i);
       
   214 	count = iEmailList->Count();		// email list
       
   215 	aStream.WriteInt32L(count);
       
   216 	for(i=0; i<count; ++i)
       
   217 		aStream << iEmailList->At(i);
       
   218 	aStream.WriteInt32L(iSlotNum); 
       
   219 	aStream.WriteUint32L(iTON);
       
   220 	aStream.WriteInt32L(iContactId);
       
   221 	aStream.WriteInt32L(iPhonebookUid.iUid);
       
   222 	aStream.WriteInt32L(iIsHidden);
       
   223 	aStream.WriteInt32L(iTemplateId);
       
   224 	} // CSyncContactICCEntry::ExternalizeL
       
   225 
       
   226 
       
   227 /**
       
   228  *  Initialise the class members from data taken from a CContactICCEntry.
       
   229  *
       
   230  *  @param aContactItem  Contacts ICC entry 
       
   231  *
       
   232  *  @return TInt KErrNotSupported if a non-supported field supplied in field set, KErrOverflow for an overflow, 
       
   233  *          othewise KErrNone
       
   234  */
       
   235 void CSyncContactICCEntry::InitialiseFromContactICCEntryL(const CContactICCEntry& aContactItem)
       
   236 	{
       
   237 	//
       
   238 	// Clear the fields to start with...
       
   239 	//
       
   240 	Reset();
       
   241 
       
   242 	TInt retrievedFields(0); // Number of fields retrieved from aContactItem field set 
       
   243 	iContactId = aContactItem.Id(); // get Contact UID
       
   244 	CContactItemFieldSet& fieldSet = aContactItem.CardFields();
       
   245 
       
   246 	TInt index(0), firstPhoneNumIndex(0);
       
   247 	// get default phone number field from aContacItem
       
   248 	firstPhoneNumIndex = fieldSet.Find(KUidContactFieldPhoneNumber);
       
   249 	if(firstPhoneNumIndex != KErrNotFound)
       
   250 		{
       
   251 		++retrievedFields;
       
   252 		const CContactItemField& field = fieldSet[firstPhoneNumIndex];
       
   253 		if(field.TextStorage()->Text().Length() > RMobilePhone::KMaxMobileTelNumberSize)
       
   254 			{
       
   255 			User::Leave(KErrOverflow);
       
   256 			}
       
   257 
       
   258 		TPtrC number(field.TextStorage()->Text());
       
   259 		iNumber.Copy(number);
       
   260 
       
   261 		//
       
   262 		// Set the TON/NPI for that number as International if the number contains
       
   263 		// the '+' prefix, otherwise set it to unknown.
       
   264 		//
       
   265 		if (TLex(iNumber).Get() == '+')
       
   266 			{
       
   267 			iTON = RMobilePhone::EInternationalNumber;
       
   268 			}
       
   269 		else
       
   270 			{
       
   271 			iTON = RMobilePhone::EUnknownNumber;
       
   272 			}
       
   273 
       
   274 		// Check whether this entry is hidden 
       
   275 		if(const_cast<CContactICCEntry&>(aContactItem).IsHidden())
       
   276 			iIsHidden = ETrue;
       
   277 
       
   278 		// Retrieve family name
       
   279 		if((index = fieldSet.Find(KUidContactFieldFamilyName)) != KErrNotFound)
       
   280 			{
       
   281 			++retrievedFields;
       
   282 			// get given name field from aContactItem
       
   283 			if(field.TextStorage()->Text().Length() > CSyncContactICCEntry::KMaxPhBkNameSize)
       
   284 				{
       
   285 				User::Leave(KErrOverflow);
       
   286 				}
       
   287 			iName.Copy(fieldSet[index].TextStorage()->Text());
       
   288 			} // name is not a compulsory field, so do not return an error if not found
       
   289 
       
   290 		// retrieve second name
       
   291 		if((index = fieldSet.Find(KUidContactFieldSecondName)) != KErrNotFound)
       
   292 			{
       
   293 			++retrievedFields;
       
   294 			// get given name field from aContactItem
       
   295 			if(field.TextStorage()->Text().Length() > CSyncContactICCEntry::KMaxPhBkNameSize)
       
   296 				{
       
   297 				User::Leave(KErrOverflow);
       
   298 				}
       
   299 			iSecondName.Copy(fieldSet[index].TextStorage()->Text());
       
   300 			} // name is not a compulsory field, so do not return an error if not found
       
   301 
       
   302 		// get slot number field from aContactItem
       
   303 		index = fieldSet.Find(KUidContactFieldICCSlot);
       
   304 		if(index!=KErrNotFound) // index field provided
       
   305 			{
       
   306 			++retrievedFields;
       
   307 			TPtrC tempPtr(NULL,0);
       
   308 			tempPtr.Set(fieldSet[index].TextStorage()->Text());
       
   309 			TLex lex(tempPtr);
       
   310 			TInt slot;
       
   311 			TInt ret(lex.Val(slot));
       
   312 			if (ret == KErrNone) // index field value supplied 
       
   313 				{
       
   314 				iSlotNum = slot;
       
   315 				}
       
   316 			else
       
   317 				iSlotNum = KSyncIndexNotSupplied; // index field provided as template field, so no actual values supplied
       
   318 			}
       
   319 		else
       
   320 			{
       
   321 			// all fields supplied but slot field not found so it must be a new entry
       
   322 			iSlotNum = KSyncIndexNotSupplied; // Set index to KSyncIndexNotSupplied
       
   323 			}
       
   324 
       
   325 		// handle the a phonebook UID field if present (it should always be as it is in the template)...
       
   326 		index = fieldSet.Find(KUidContactFieldICCPhonebook);
       
   327 		if(index!=KErrNotFound) // index field provided
       
   328 			{
       
   329 			++retrievedFields;
       
   330 			TPtrC tempPtr(NULL,0);
       
   331 			tempPtr.Set(fieldSet[index].TextStorage()->Text());
       
   332 			TLex lex(tempPtr);
       
   333 			TInt phonebook;
       
   334 			TInt ret(lex.Val(phonebook));
       
   335 			if (ret == KErrNone) // index field value supplied 
       
   336 				{
       
   337 				iPhonebookUid.iUid = phonebook;
       
   338 				}
       
   339 			else
       
   340 				{
       
   341 				iPhonebookUid = KUidIccGlobalAdnPhonebook;
       
   342 				}
       
   343 			}
       
   344 		else
       
   345 			{
       
   346 			iPhonebookUid = KUidIccGlobalAdnPhonebook;
       
   347 			}
       
   348 
       
   349 		// now get list of additional phone numbers from CContactICCEntry 		
       
   350 		index = firstPhoneNumIndex;  // skip the default phone number which has been read in early
       
   351 		while((index = fieldSet.FindNext(KUidContactFieldPhoneNumber,index+1)) != KErrNotFound)
       
   352 			{
       
   353 			// get additional phone number field from aContacItem
       
   354 			++retrievedFields;
       
   355 			const CContactItemField& field = fieldSet[index];
       
   356 			if(field.TextStorage()->Text().Length() > RMobilePhone::KMaxMobileTelNumberSize)
       
   357 				{
       
   358 				User::Leave(KErrOverflow);
       
   359 				}
       
   360 
       
   361 			TPtrC number(field.TextStorage()->Text());
       
   362 			CSyncContactICCEntry::TSyncAdditionalNumber addNumber;
       
   363 			addNumber.iNumber.Copy(number);
       
   364 
       
   365 			//
       
   366 			// Set the TON/NPI for that number as International if the number contains
       
   367 			// the '+' prefix, otherwise set it to unknown.
       
   368 			//
       
   369 			if (TLex(addNumber.iNumber).Get() == '+')
       
   370 				{
       
   371 				addNumber.iTON = RMobilePhone::EInternationalNumber;
       
   372 				}
       
   373 			else
       
   374 				{
       
   375 				addNumber.iTON = RMobilePhone::EUnknownNumber;
       
   376 				}
       
   377 
       
   378             //-- assign alpha string to the additional number according to additional field types
       
   379 			const CContentType&  cntType = field.ContentType();
       
   380 		    
       
   381 		    //
       
   382 		    // Assume HOME by default. Please note that this will be used as default 
       
   383 		    // value if something other than HOME or WORK is supplied.
       
   384 		    //
       
   385 			if (cntType.ContainsFieldType(KUidContactFieldVCardMapWORK)) 
       
   386 				{
       
   387 				addNumber.iNumberString.Append(KVersitParamWork);
       
   388 				}
       
   389 			else
       
   390 				{
       
   391 				addNumber.iNumberString.Append(KVersitParamHome);
       
   392 				}
       
   393 
       
   394 		    //
       
   395 		    // Try to locate other tags (FAX, CELL, etc)...
       
   396 			//
       
   397 			if (cntType.ContainsFieldType(KUidContactFieldVCardMapMSG))
       
   398 				{
       
   399 				addNumber.iNumberString.Append(KVersitParamMsg);
       
   400 				}
       
   401 			else if (cntType.ContainsFieldType(KUidContactFieldVCardMapVOICE))
       
   402 				{
       
   403 				addNumber.iNumberString.Append(KVersitParamVoice);
       
   404 				}
       
   405 			else if (cntType.ContainsFieldType(KUidContactFieldVCardMapFAX))
       
   406 				{
       
   407 				addNumber.iNumberString.Append(KVersitParamFax);
       
   408 				}
       
   409 			else if (cntType.ContainsFieldType(KUidContactFieldVCardMapPREF))
       
   410 				{
       
   411 				addNumber.iNumberString.Append(KVersitParamPref);
       
   412 				}
       
   413 			else if (cntType.ContainsFieldType(KUidContactFieldVCardMapCELL))
       
   414 				{
       
   415 				addNumber.iNumberString.Append(KVersitParamCell);
       
   416 				}
       
   417 			else if (cntType.ContainsFieldType(KUidContactFieldVCardMapPAGER))
       
   418 				{
       
   419 				addNumber.iNumberString.Append(KVersitParamPager);
       
   420 				}
       
   421 			else if (cntType.ContainsFieldType(KUidContactFieldVCardMapBBS))
       
   422 				{
       
   423 				addNumber.iNumberString.Append(KVersitParamBbs);
       
   424 				}
       
   425 			else if (cntType.ContainsFieldType(KUidContactFieldVCardMapMODEM))
       
   426 				{
       
   427 				addNumber.iNumberString.Append(KVersitParamModem);
       
   428 				}
       
   429 			else if (cntType.ContainsFieldType(KUidContactFieldVCardMapCAR))
       
   430 				{
       
   431 				addNumber.iNumberString.Append(KVersitParamCar);
       
   432 				}
       
   433 			else if (cntType.ContainsFieldType(KUidContactFieldVCardMapISDN))
       
   434 				{
       
   435 				addNumber.iNumberString.Append(KVersitParamIsdn);
       
   436 				}
       
   437 			else if (cntType.ContainsFieldType(KUidContactFieldVCardMapVIDEO))
       
   438 				{
       
   439 				addNumber.iNumberString.Append(KVersitParamVideo);
       
   440 				}
       
   441 
       
   442 			// finally append additional number to additional number list
       
   443 			iNumberList->AppendL(addNumber);
       
   444 			}
       
   445 
       
   446 		// get all e-mail fields 
       
   447 		index = -1;
       
   448 		while((index = fieldSet.FindNext(KUidContactFieldEMail,index+1)) != KErrNotFound)
       
   449 			{
       
   450 			++retrievedFields;
       
   451 			// get e-mail field from aContactItem
       
   452 			if(field.TextStorage()->Text().Length() > CSyncContactICCEntry::KMaxPhBkNameSize)
       
   453 				{
       
   454 				User::Leave(KErrOverflow);
       
   455 				}
       
   456 
       
   457 			CSyncContactICCEntry::TSyncEntryName name;
       
   458 			name.Copy(fieldSet[index].TextStorage()->Text());
       
   459 			iEmailList->AppendL(name);
       
   460 			} // e-mail is not a compulsory field, so do not return an error if not found
       
   461 
       
   462 		// get all groups that this entry belongs to 
       
   463 		index = -1; // following was originally commented out (JJ)	
       
   464 		while((index = fieldSet.FindNext(KUidContactFieldICCGroup, index+1)) != KErrNotFound)
       
   465 			{
       
   466 			++retrievedFields;
       
   467 			// get group field from aContactItem
       
   468 			if(field.TextStorage()->Text().Length() > CSyncContactICCEntry::KMaxPhBkNameSize)
       
   469 				{
       
   470 				User::Leave(KErrOverflow);
       
   471 				}
       
   472 
       
   473 			CSyncContactICCEntry::TSyncEntryName name;
       
   474 			name.Copy(fieldSet[index].TextStorage()->Text());
       
   475 			iGroupList->AppendL(name);
       
   476 			} // group is not a compulsory field, so do not return an error if not foun
       
   477 
       
   478 		// For new entries phonebook type is not supplied, so always extract Template ID
       
   479 		iTemplateId = aContactItem.TemplateRefId();
       
   480 		}			
       
   481 
       
   482 	//
       
   483 	// Check that all expected fields were retrieved...
       
   484 	//
       
   485 	if (fieldSet.Count() != retrievedFields)
       
   486 		{
       
   487 #ifdef _DEBUG
       
   488 		//
       
   489 		// At least one field has was not supported. Log all the field types!
       
   490 		//
       
   491 		LOGCOMMON1(_L8("CSyncContactICCEntry: Unsupported field found!"));
       
   492 		for (TInt field = 0;  field < fieldSet.Count();  field++)
       
   493 			{
       
   494 			LOGCOMMON2(_L8("CSyncContactICCEntry:   Field[%d]:"), field);
       
   495 			for (TInt type = 0;  type < fieldSet[field].ContentType().FieldTypeCount();  type++)
       
   496 				{
       
   497 				LOGCOMMON3(_L8("CSyncContactICCEntry:     Type[%d]=0x%08x"), type,
       
   498 				           fieldSet[field].ContentType().FieldType(type));
       
   499 				}
       
   500 			}
       
   501 #endif
       
   502 
       
   503 		User::Leave(KErrNotSupported);
       
   504 		}
       
   505 	} // CSyncContactICCEntry::InitialiseFromContactICCEntryL
       
   506 
       
   507 
       
   508 
       
   509 
       
   510 /**
       
   511  *  This method resets all attributes.
       
   512  */
       
   513 void CSyncContactICCEntry::Reset()
       
   514 	{
       
   515 	// reset all variables
       
   516 	iSlotNum      = 0; 
       
   517 	iTON          = RMobilePhone::EUnknownNumber;
       
   518 	iContactId    = KNullContactId;
       
   519 	iPhonebookUid = KUidIccGlobalAdnPhonebook; 
       
   520 	iIsHidden     = EFalse; 
       
   521 	iTemplateId   = KNullContactId;
       
   522 	iName.Zero();
       
   523 	iSecondName.Zero();
       
   524 	iNumber.Zero();
       
   525 
       
   526 	// reset all lists
       
   527 	iNumberList->Reset();
       
   528 	iGroupList->Reset();	
       
   529 	iEmailList->Reset();
       
   530 	} // CSyncContactICCEntry::Reset
       
   531 
       
   532 
       
   533 #ifdef _DEBUG
       
   534 /**
       
   535  *  Logs the contact entry for debugging purposes.
       
   536  */
       
   537 void CSyncContactICCEntry::LogSyncContactICCEntry() const
       
   538 	{
       
   539 	//
       
   540 	// Log the basic fields...
       
   541 	//
       
   542 	TBuf8<KMaxPhBkNameSize>  fieldIn8bit;
       
   543 	TBuf8<RMobilePhone::KMaxMobileTelNumberSize>  numberIn8bit;
       
   544 
       
   545 	fieldIn8bit.Copy(iName);
       
   546 	LOGCOMMON2(_L8("ICCEntry: Name=\"%S\""), &fieldIn8bit);
       
   547 
       
   548 	fieldIn8bit.Copy(iSecondName);
       
   549 	LOGCOMMON2(_L8("ICCEntry: Second Name=\"%S\""), &fieldIn8bit);
       
   550 
       
   551 	numberIn8bit.Copy(iNumber);
       
   552 	LOGCOMMON2(_L8("ICCEntry: Number=\"%S\""), &numberIn8bit);
       
   553 
       
   554 	LOGCOMMON2(_L8("ICCEntry: SlotNum=%d"), iSlotNum);
       
   555 
       
   556 	LOGCOMMON2(_L8("ICCEntry: TypeOfNum=%d"), iTON);
       
   557 
       
   558 	LOGCOMMON2(_L8("ICCEntry: ContactID=0x%08x"), iContactId);
       
   559 
       
   560 	LOGCOMMON2(_L8("ICCEntry: PhonebookUID=0x%08x"), iPhonebookUid.iUid);
       
   561 
       
   562 	LOGCOMMON2(_L8("ICCEntry: IsHidden=%d"), iIsHidden);
       
   563 
       
   564 	LOGCOMMON2(_L8("ICCEntry: TemplateId=%d"), iTemplateId);
       
   565 
       
   566 	//
       
   567 	// Log the number list...
       
   568 	//
       
   569 	TInt  listCount(iNumberList->Count());
       
   570 	TInt  index;
       
   571 
       
   572 	for (index = 0;  index < listCount;  index++)
       
   573 		{
       
   574 		numberIn8bit.Copy(iNumberList->At(index).iNumber);
       
   575 		fieldIn8bit.Copy(iNumberList->At(index).iNumberString);
       
   576 		LOGCOMMON4(_L8("ICCEntry: NumberList[%d] \"%S\" \"%S\""),
       
   577 				   index, &numberIn8bit, &fieldIn8bit);
       
   578 		}
       
   579 
       
   580 	//
       
   581 	// Log the group list...
       
   582 	//
       
   583 	listCount = iGroupList->Count();
       
   584 
       
   585 	for (index = 0;  index < listCount;  index++)
       
   586 		{
       
   587 		fieldIn8bit.Copy(iGroupList->At(index));
       
   588 		LOGCOMMON3(_L8("ICCEntry: GroupList[%d]=\"%S\""), index, &fieldIn8bit);
       
   589 		}
       
   590 
       
   591 	//
       
   592 	// Log the email list...
       
   593 	//
       
   594 	listCount = iEmailList->Count();
       
   595 
       
   596 	for (index = 0;  index < listCount;  index++)
       
   597 		{
       
   598 		fieldIn8bit.Copy(iEmailList->At(index));
       
   599 		LOGCOMMON3(_L8("ICCEntry: EmailList[%d]=\"%S\""), index, &fieldIn8bit);
       
   600 		}
       
   601 	} // CSyncContactICCEntry::LogSyncContactICCEntry
       
   602 #endif
       
   603 
       
   604 
       
   605 /**
       
   606  *  This method internalizes the contents of TSyncAdditionalNumber from
       
   607  *  a stream.
       
   608  *
       
   609  *  @param aStream  The read stream containing TSyncAdditionalNumber.
       
   610  */
       
   611 void CSyncContactICCEntry::TSyncAdditionalNumber::InternalizeL(RReadStream& aStream)
       
   612 	{
       
   613 	aStream >> iNumber;
       
   614 	aStream >> iNumberString;
       
   615 	iTON = static_cast<RMobilePhone::TMobileTON>(aStream.ReadUint32L());
       
   616 	} // CSyncContactICCEntry::TSyncAdditionalNumber::InternalizeL
       
   617 
       
   618 
       
   619 /**
       
   620  *  This method externalizes the contents of TSyncAdditionalNumber into
       
   621  *  a stream.
       
   622  *
       
   623  *  @param aStream  The write stream that will contain TSyncAdditionalNumber.
       
   624  */
       
   625 void CSyncContactICCEntry::TSyncAdditionalNumber::ExternalizeL(RWriteStream& aStream) const
       
   626 	{
       
   627 	aStream << iNumber;
       
   628 	aStream << iNumberString;
       
   629 	aStream.WriteUint32L(iTON);
       
   630 	} // CSyncContactICCEntry::TSyncAdditionalNumber::ExternalizeL
       
   631 
       
   632 
       
   633 /**
       
   634  *  Standard constructor.
       
   635  */
       
   636 TContactFieldFormat::TContactFieldFormat(TInt aLength, TInt aCount,
       
   637 										 TBool aDisplayed)
       
   638   : iLength(aLength),
       
   639     iCount(aCount),
       
   640     iDisplayed(aDisplayed)
       
   641 	{
       
   642 	// NOP
       
   643 	} // TContactFieldFormat::TContactFieldFormat
       
   644 
       
   645 
       
   646 /**
       
   647  *  The old PhBkSyncServerThread Server Thread. This thread is no longer
       
   648  *  supported.
       
   649  */
       
   650 EXPORT_C TInt PhBkSyncServerThread(TAny*)
       
   651 	{
       
   652 	return KErrNotSupported;
       
   653 	} // PhBkSyncServerThread
       
   654 
       
   655 
       
   656 /**
       
   657  *  This method returns the Phonebook Synchroniser API extension number
       
   658  *  of the class.
       
   659  *
       
   660  *  @return An integer that will indicate the version of the type.
       
   661  */
       
   662 EXPORT_C TInt RPhoneBookSession::TContactFieldsV1::ExtensionId() const
       
   663 	{
       
   664 	return iExtensionId;
       
   665 	} // RPhoneBookSession::TContactFieldsV1::ExtensionId()
       
   666 
       
   667 
       
   668 /**
       
   669  *  Standard constructor.
       
   670  */
       
   671 EXPORT_C RPhoneBookSession::TContactFieldsV1::TContactFieldsV1()
       
   672   : iNameField(0, 0, EFalse),
       
   673     iNumberField(0,0,EFalse),
       
   674     iIccSlotField(0,0,EFalse), 
       
   675     iExtensionId(KPhBkSyncTContactFieldsV1)
       
   676 	{
       
   677 	// NOP
       
   678 	} // RPhoneBookSession::TContactFieldsV1::TContactFieldsV1
       
   679 
       
   680 
       
   681 /**
       
   682  *  Standard constructor.
       
   683  */
       
   684 EXPORT_C RPhoneBookSession::TContactFieldsV2::TContactFieldsV2()
       
   685   : TContactFieldsV1(),
       
   686     iAdditionalNumString(0, 0, EFalse),
       
   687     iGroupField(0,0,EFalse), 
       
   688     iEmailField(0,0,EFalse),
       
   689     iPhonebook(KUidIccGlobalAdnPhonebook)
       
   690 	{
       
   691 	iExtensionId = KPhBkSyncTContactFieldsV2;
       
   692 	} // RPhoneBookSession::TContactFieldsV2::TContactFieldsV2()
       
   693 
       
   694 
       
   695 /**
       
   696  *  Standard constructor.
       
   697  */
       
   698 EXPORT_C RPhoneBookSession::TContactFieldsV3::TContactFieldsV3()
       
   699   : TContactFieldsV2(),
       
   700     iAdditionalNumAlphaString(0, 0, EFalse),
       
   701     iSecondNameField(0,0,EFalse)
       
   702 	{
       
   703 	iExtensionId = KPhBkSyncTContactFieldsV3;
       
   704 	} // RPhoneBookSession::TContactFieldsV3::TContactFieldsV3()