messagingfw/msgsrvnstore/server/src/MSVIPC.CPP
changeset 0 8e480a14352b
child 18 b9e74fff3740
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 1998-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 <s32std.h>
       
    17 
       
    18 #include "MSVIPC.H"
       
    19 #include "MSVIDS.H"
       
    20 #include "MSVPANIC.H"
       
    21 
       
    22 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    23 #include "msvsearchsortconstants.h"
       
    24 #include "msvconsts.h"
       
    25 #endif
       
    26 
       
    27 GLDEF_C void DoUnpackEntry(TUint8*& aPtr, TMsvEntry& aEntry)
       
    28 //
       
    29 //
       
    30 //
       
    31 	{
       
    32 	// get the entry from the start of the buffer
       
    33 	const TMsvEntry* pEntry = (TMsvEntry*) aPtr;
       
    34 	aEntry = *pEntry;
       
    35 	aPtr = Align4(aPtr + sizeof(TMsvEntry));
       
    36 
       
    37 	const TText* textPtr = (TText*)aPtr;
       
    38 	TInt length=aEntry.iDescription.Length();
       
    39 	aEntry.iDescription.Set(textPtr, length);
       
    40 	textPtr = Align4(textPtr + length);
       
    41 
       
    42 	length=aEntry.iDetails.Length();
       
    43 	aEntry.iDetails.Set(textPtr, length);
       
    44 	textPtr = Align4(textPtr + length);
       
    45 
       
    46 	aPtr = (TUint8*) textPtr;
       
    47 	}
       
    48 	
       
    49 
       
    50 GLDEF_C TInt DoPackEntry(const TUint8*& aPtrStart, const TUint8* aPtrEnd, const TMsvEntry& aEntry)
       
    51 //
       
    52 // Packs an entry into the memory area defined by the two pointers.
       
    53 // Fails with KErrOverflow if the packed entry is too large
       
    54 // aPtrStart is always returned pointing to the end of the packed entry (even if too large)
       
    55 //
       
    56 	{
       
    57 	// make sure the entry can fit into the memory area defined by the two pointers
       
    58 	TInt sizeEntry = Align4(sizeof(TMsvEntry));
       
    59 	TInt sizeString1 = Align4(aEntry.iDescription.Size());
       
    60 	TInt sizeString2 = Align4(aEntry.iDetails.Size());
       
    61 	TInt size =  sizeEntry + sizeString1 + sizeString2;
       
    62 	if ((aPtrStart + size)>aPtrEnd)
       
    63 		{
       
    64 		aPtrStart += size;
       
    65 		return KErrOverflow;
       
    66 		}
       
    67 		
       
    68 	// copy the entry and descriptors into the memory area
       
    69 	Mem::Copy((void*)aPtrStart, &aEntry, sizeof(TMsvEntry));
       
    70 	aPtrStart += sizeEntry;
       
    71 
       
    72 	Mem::Copy((void*)aPtrStart, aEntry.iDescription.Ptr(), aEntry.iDescription.Size());
       
    73 	aPtrStart += sizeString1;
       
    74 	
       
    75 	Mem::Copy((void*)aPtrStart, aEntry.iDetails.Ptr(), aEntry.iDetails.Size());
       
    76 	aPtrStart += sizeString2;
       
    77 	
       
    78 	return KErrNone;
       
    79 	}
       
    80 	
       
    81 	
       
    82 GLDEF_C void DoUnpackFilter(TUint8*& aPtr, CMsvEntryFilter& aFilter)
       
    83 //
       
    84 //
       
    85 //
       
    86 	{
       
    87 	// get the entry from the start of the buffer
       
    88 	const CMsvEntryFilter* pFilter = (CMsvEntryFilter*) aPtr;
       
    89 	Mem::Copy(&aFilter, pFilter, sizeof(CMsvEntryFilter));
       
    90 	aPtr = Align4(aPtr + sizeof(CMsvEntryFilter));
       
    91 	}
       
    92 
       
    93 
       
    94 GLDEF_C TInt DoPackFilter(const TUint8*& aPtrStart, const TUint8* aPtrEnd, const CMsvEntryFilter& aFilter)
       
    95 //
       
    96 //
       
    97 //
       
    98 	{
       
    99 	// make sure the entry can fit into the memory area defined by the two pointers
       
   100 	TInt size = Align4(sizeof(CMsvEntryFilter));
       
   101 	if ((aPtrStart + size)>aPtrEnd)
       
   102 		{
       
   103 		aPtrStart += size;
       
   104 		return KErrOverflow;
       
   105 		}
       
   106 		
       
   107 	// copy the filter into the memory area
       
   108 	Mem::Copy((void*)aPtrStart, &aFilter, sizeof(CMsvEntryFilter));
       
   109 	aPtrStart += size;
       
   110 	
       
   111 	return KErrNone;
       
   112 	}
       
   113 
       
   114 //**********************************
       
   115 // TMsvPackedEntry
       
   116 //**********************************
       
   117 
       
   118 
       
   119 EXPORT_C TMsvPackedEntry::TMsvPackedEntry(HBufC8*& aBuffer)
       
   120 : iBuffer(aBuffer)
       
   121 	{}
       
   122 
       
   123 EXPORT_C TInt TMsvPackedEntry::PackEntry(const TMsvEntry& aEntry)
       
   124 //
       
   125 //
       
   126 //
       
   127 	{
       
   128 	// find the start and end of the buffer
       
   129 	const TUint8* pS = iBuffer->Ptr();
       
   130 	const TUint8* pE = PtrAdd(pS, iBuffer->Des().MaxSize());
       
   131 
       
   132 	TInt error = DoPackEntry(pS, pE, aEntry);
       
   133 	if (error==KErrNone)
       
   134 		{
       
   135 		// update the length of the buffer
       
   136 		iBuffer->Des().SetLength(pS-iBuffer->Ptr());
       
   137 		}
       
   138 
       
   139 	return error;
       
   140 	}
       
   141 
       
   142 EXPORT_C void TMsvPackedEntry::UnpackEntry(TMsvEntry& aEntry)
       
   143 //
       
   144 //
       
   145 //
       
   146 	{
       
   147 #if defined(_DEBUG)
       
   148 	// check that the buffer contain a valid package
       
   149 	const TMsvEntry* dEntry = (TMsvEntry*) iBuffer->Ptr();
       
   150 	const TUint8* dPos = PtrAdd(iBuffer->Ptr(), Align4(sizeof(TMsvEntry)) + Align4(dEntry->iDescription.Size()) + Align4(dEntry->iDetails.Size()));
       
   151 	__ASSERT_DEBUG(dPos <= PtrAdd(iBuffer->Ptr(), iBuffer->Des().MaxLength()), PanicServer(EMsvEntryOverrunBuffer));
       
   152 #endif
       
   153 	
       
   154 	TUint8* pS = CONST_CAST(TUint8*, iBuffer->Ptr());
       
   155 	DoUnpackEntry(pS, aEntry);
       
   156 	}
       
   157 
       
   158 //**********************************
       
   159 // TMsvPackedEntryArray
       
   160 //**********************************
       
   161 
       
   162 
       
   163 EXPORT_C TMsvPackedEntryArray::TMsvPackedEntryArray(HBufC8*& aBuffer, TInt aCount)
       
   164 : iIndex(0), iCount(aCount), iBuffer(aBuffer) 
       
   165 	{
       
   166 	iPos = iBuffer->Ptr();
       
   167 	}
       
   168 
       
   169 
       
   170 EXPORT_C void TMsvPackedEntryArray::Reset()
       
   171 //
       
   172 //
       
   173 //
       
   174 	{
       
   175 	iBuffer->Des().SetLength(0);
       
   176 	iPos  = iBuffer->Ptr();
       
   177 	iIndex=0;
       
   178 	iCount=0;
       
   179 	}
       
   180 
       
   181 EXPORT_C TInt TMsvPackedEntryArray::PackEntry(const TMsvEntry& aEntry)
       
   182 //
       
   183 //
       
   184 //
       
   185 	{
       
   186 	const TUint8* pS = iPos;
       
   187 	const TUint8* pE = PtrAdd(iBuffer->Ptr(), iBuffer->Des().MaxSize());
       
   188 
       
   189 	TInt error = DoPackEntry(pS, pE, aEntry);
       
   190 	if (error==KErrNone)
       
   191 		{
       
   192 		// update the length of the buffer and the position for the next entry
       
   193 		iBuffer->Des().SetLength(pS-iBuffer->Ptr());
       
   194 		iPos = pS;
       
   195 		iIndex++;
       
   196 		iCount++;
       
   197 		}
       
   198 	
       
   199 	return error;
       
   200 	}
       
   201 
       
   202 EXPORT_C TInt TMsvPackedEntryArray::UnpackEntry(TInt aIndex, TMsvEntry& aEntry)
       
   203 //
       
   204 //
       
   205 //
       
   206 	{
       
   207 	TInt error=KErrNone;
       
   208 
       
   209 	if (iIndex!=aIndex)
       
   210 		error = FindEntryInArray(aIndex);
       
   211 
       
   212 	if (error==KErrNone)
       
   213 		{
       
   214 		TUint8* pS=CONST_CAST(TUint8*, iPos);
       
   215 		DoUnpackEntry(pS, aEntry);
       
   216 		iPos=pS;
       
   217 		iIndex++;
       
   218 		}	
       
   219 
       
   220 	return error;
       
   221 	}
       
   222 
       
   223 
       
   224 TInt TMsvPackedEntryArray::FindEntryInArray(TInt aIndex)
       
   225 //
       
   226 //
       
   227 //
       
   228 	{
       
   229 	if (aIndex>=iCount)
       
   230 		return KErrNotFound;
       
   231 
       
   232 	if (iIndex>aIndex)
       
   233 		{
       
   234 		// have to reset to the start of the buffer
       
   235 		iPos = iBuffer->Ptr();
       
   236 		iIndex=0;
       
   237 		}
       
   238 
       
   239 	while (iIndex!=aIndex)
       
   240 		{
       
   241 		const TMsvEntry* pEntry = (TMsvEntry*) iPos;
       
   242 		iPos += Align4(sizeof(TMsvEntry)) + Align4(pEntry->iDescription.Size()) + Align4(pEntry->iDetails.Size());
       
   243 		iIndex++;
       
   244 		}
       
   245 
       
   246 	__ASSERT_DEBUG(iPos < PtrAdd(iBuffer->Ptr(), iBuffer->Des().MaxLength()), PanicServer(EMsvPointerOverrunBuffer));
       
   247 
       
   248 	return KErrNone;
       
   249 	}
       
   250 
       
   251 
       
   252 
       
   253 //**********************************
       
   254 // TMsvMoveCopyDetails
       
   255 //**********************************
       
   256 
       
   257 EXPORT_C TMsvLocalOperationProgress::TMsvLocalOperationProgress()
       
   258 : iType(ELocalNone), iTotalNumberOfEntries(0), iNumberCompleted(0), iNumberFailed(0), iNumberRemaining(0), iError(KErrNone), iId(KMsvNullIndexEntryId)
       
   259 /** Initialises the new object to suitable zero or null values. */
       
   260 	{
       
   261 	}
       
   262 
       
   263 //**********************************
       
   264 // TMsvServerOperationProgress
       
   265 //**********************************
       
   266 
       
   267 EXPORT_C TMsvServerOperationProgress::TMsvServerOperationProgress()
       
   268 : iOperationType(EMsvNoOperation)
       
   269 /** Default constructor.
       
   270 
       
   271 Sets iOperationType to EMsvNoOperation. */
       
   272 	{
       
   273 	}
       
   274 
       
   275 TMsvServerOperationProgress::TMsvServerOperationProgress(TMsvServerOperationType aType)
       
   276 : iOperationType(aType)
       
   277 	{
       
   278 	}
       
   279 
       
   280 //**********************************
       
   281 // TMsvIndexProgress
       
   282 //**********************************
       
   283 
       
   284 EXPORT_C TMsvIndexProgress::TMsvIndexProgress()
       
   285 : iTotal(0), iCompleted(0), iRemaining(0), iId(KMsvNullIndexEntryId)
       
   286 /** Default constructor.
       
   287 
       
   288 Data members are intialised to 0 or KMsvNullIndexEntryId as appropriate. */
       
   289 	{
       
   290 	}
       
   291 
       
   292 //**********************************
       
   293 // TMsvIndexLoadProgress
       
   294 //**********************************
       
   295 
       
   296 EXPORT_C TMsvIndexLoadProgress::TMsvIndexLoadProgress()
       
   297 : TMsvServerOperationProgress(EMsvChangeDriveOperation), iError(KErrNone), iState(EIndexNotLoaded)
       
   298 /** Default constructor.
       
   299 
       
   300 iOperationType is set to EMsvChangeDriveOperation; iError is set to KErrNone; 
       
   301 iState is set to EIndexNotLoaded. */
       
   302 	{
       
   303 	}
       
   304 	
       
   305 	
       
   306 	
       
   307 //**********************************
       
   308 // TMsvCopyProgress
       
   309 //**********************************
       
   310 
       
   311 /** Default constructor.
       
   312 iOperationType is set to EMsvCopyOperation; iError is set to KErrNone; 
       
   313 iState is set to ENotYetStarted. */  
       
   314 
       
   315 EXPORT_C TMsvCopyProgress::TMsvCopyProgress()
       
   316 : TMsvServerOperationProgress(EMsvCopyOperation), iError(KErrNone), iState(ENotYetStarted)
       
   317 	{
       
   318 	}
       
   319 
       
   320 
       
   321 //**********************************
       
   322 // TMsvDeleteProgress
       
   323 //**********************************
       
   324 
       
   325 /** Default constructor.
       
   326 iOperationType is set to EMsvDeleteOperation; iError is set to KErrNone; 
       
   327 iState is set to ENotYetStarted. */
       
   328 
       
   329 EXPORT_C TMsvDeleteProgress::TMsvDeleteProgress()
       
   330 : TMsvServerOperationProgress(EMsvDeleteOperation), iError(KErrNone), iState(ENotYetStarted)
       
   331 
       
   332 	{
       
   333 	}
       
   334 
       
   335 
       
   336 //**********************************
       
   337 // TMsvChildrenDetails
       
   338 //**********************************
       
   339 
       
   340 EXPORT_C TMsvChildrenDetails::TMsvChildrenDetails()
       
   341 : iParentId(KMsvNullIndexEntryId), iTotalNumberChildren(0), iNumberChildrenInArray(0), iLastEntryInArray(0)
       
   342 	{
       
   343 	}
       
   344 
       
   345 
       
   346 //**********************************
       
   347 // TMsvPackedOperation
       
   348 //**********************************
       
   349 
       
   350 EXPORT_C TMsvPackedOperation::TMsvPackedOperation(HBufC8*& aBuffer)
       
   351 : iBuffer(aBuffer)
       
   352 	{
       
   353 	}
       
   354 
       
   355 
       
   356 EXPORT_C TInt TMsvPackedOperation::Pack(const CMsvEntrySelection& aSelection, TInt aParameter1, TInt aParameter2)
       
   357 	{
       
   358 	// check the buffer is large enough
       
   359 	TInt requiredSize = (aSelection.Count()+3)*4;
       
   360 	if (requiredSize>iBuffer->Des().MaxSize())
       
   361 		return KErrOverflow;
       
   362 	// set the buffer with correct length
       
   363 	iBuffer->Des().SetLength(requiredSize);
       
   364 
       
   365 	TInt* ptr = (TInt*) CONST_CAST(TUint8*, iBuffer->Ptr());
       
   366 	*ptr++ = aSelection.Count();
       
   367 	for (TInt count=0; count<aSelection.Count(); count++)
       
   368 		*ptr++ = aSelection.At(count);
       
   369 	*ptr++ = aParameter1;
       
   370 	*ptr++ = aParameter2;
       
   371 	return KErrNone;
       
   372 	}
       
   373 
       
   374 
       
   375 EXPORT_C void TMsvPackedOperation::UnpackL(CMsvEntrySelection& aSelection, TInt& aParameter1, TInt& aParameter2)
       
   376 	{
       
   377 	__ASSERT_DEBUG(aSelection.Count()==0, PanicServer(EMsvOperationUnpackSelectionNotEmpty));	
       
   378 	TInt* ptr = (TInt*) CONST_CAST(TUint8*, iBuffer->Ptr());
       
   379 
       
   380 	TInt count = *ptr++;
       
   381 	
       
   382 	TInt bufSize = iBuffer->Des().Length();
       
   383 	
       
   384 	// This length is calculated on the basis of length set in TMsvPackedOperation::Pack above.
       
   385 	TInt len = (count+3)*4; 
       
   386 	if(bufSize == len)	
       
   387 		{
       
   388 		while (count--)
       
   389 			{
       
   390 			aSelection.AppendL(*ptr++);
       
   391 			}
       
   392 		aParameter1 = *ptr++;
       
   393 		aParameter2 = *ptr++;
       
   394 		}
       
   395 	else
       
   396 		{
       
   397 		User::Leave(KErrArgument);
       
   398 		}
       
   399 	}
       
   400 
       
   401 
       
   402 EXPORT_C TMsvPackedChangeNotification::TMsvPackedChangeNotification(TMsvNotifBuffer& aBuffer)
       
   403 : iBuffer(aBuffer)
       
   404 	{
       
   405 	}
       
   406 
       
   407 
       
   408 EXPORT_C void TMsvPackedChangeNotification::Pack(TMsvServerChangeNotificationType aChangeType, const CMsvEntrySelection& aSelection, TInt aParameter1, TInt aParameter2, TInt aStartIndex, TInt aFinishIndex)
       
   409 //
       
   410 // Packs the aStartIndex->aFinishIndex (inc) into the buffer
       
   411 //
       
   412 	{
       
   413 	__ASSERT_DEBUG(aFinishIndex-aStartIndex+1<=KMsvPackedChangeLimit, PanicServer(EMsvChangeSelectionTooLarge));
       
   414 
       
   415 	// set the buffer with correct length
       
   416 	TInt requiredSize = (aFinishIndex-aStartIndex+1+KMsvChangeNotificationNumberOfTInts)*4;
       
   417 	iBuffer.SetLength(requiredSize);
       
   418 
       
   419 	TInt* ptr = (TInt*) CONST_CAST(TUint8*, iBuffer.Ptr());
       
   420 	*ptr++ = aChangeType;
       
   421 	*ptr++ = aParameter1;
       
   422 	*ptr++ = aParameter2;
       
   423 	*ptr++ = aFinishIndex - aStartIndex + 1;
       
   424 	for (TInt count=aStartIndex; count<=aFinishIndex; count++)
       
   425 		*ptr++ = aSelection.At(count);
       
   426 	}
       
   427 
       
   428 
       
   429 EXPORT_C void TMsvPackedChangeNotification::Pack(TMsvServerChangeNotificationType aChangeType, TMsvId aId, TInt aParameter1, TInt aParameter2)
       
   430 //
       
   431 // Packs a single id
       
   432 //
       
   433 	{
       
   434 	// set the buffer with correct length
       
   435 	TInt requiredSize = (1+KMsvChangeNotificationNumberOfTInts)*4;
       
   436 	iBuffer.SetLength(requiredSize);
       
   437 
       
   438 	TInt* ptr = (TInt*) CONST_CAST(TUint8*, iBuffer.Ptr());
       
   439 	*ptr++ = aChangeType;
       
   440 	*ptr++ = aParameter1;
       
   441 	*ptr++ = aParameter2;
       
   442 	*ptr++ = 1;
       
   443 	*ptr++ = aId;
       
   444 	}
       
   445 
       
   446 
       
   447 EXPORT_C void TMsvPackedChangeNotification::UnpackL(TMsvServerChangeNotificationType& aChangeType, CMsvEntrySelection& aSelection, TInt& aParameter1, TInt& aParameter2)
       
   448 //
       
   449 //
       
   450 //
       
   451 	{
       
   452 	__ASSERT_DEBUG(aSelection.Count()==0, PanicServer(EMsvChangedUnpackSelectionNotEmpty));	
       
   453 	TInt* ptr = (TInt*) CONST_CAST(TUint8*, iBuffer.Ptr());
       
   454 	switch (*ptr++)
       
   455 		{
       
   456 		case 1:
       
   457 			aChangeType = EMsvEntriesCreated;
       
   458 			break;
       
   459 		case 2:
       
   460 			aChangeType = EMsvEntriesChanged;
       
   461 			break;
       
   462 		case 3:
       
   463 			aChangeType = EMsvEntriesDeleted;
       
   464 			break;
       
   465 		case 4:
       
   466 			aChangeType = EMsvEntriesMoved;
       
   467 			break;
       
   468 		case 5:
       
   469 			aChangeType = EMsvMtmGroupInstalled;
       
   470 			break;
       
   471 		case 6:
       
   472 			aChangeType = EMsvMtmGroupDeInstalled;
       
   473 			break;
       
   474 		case 8:
       
   475 			aChangeType = EMsvCloseSession;
       
   476 			break;
       
   477 		case 9:
       
   478 			aChangeType = EMsvIndexLoaded;
       
   479 			break;
       
   480 		case 10:
       
   481 			aChangeType = EMsvIndexFailedToLoad;
       
   482 			break;
       
   483 		case 12:
       
   484 			aChangeType = EMsvMediaChanged;
       
   485 			break;
       
   486 		case 13:
       
   487 			aChangeType = EMsvMediaUnavailable;
       
   488 			break;
       
   489 		case 14:
       
   490 			aChangeType = EMsvMediaAvailable;
       
   491 			break;
       
   492 		case 15:
       
   493 			aChangeType = EMsvMediaIncorrect;
       
   494 			break;
       
   495 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
   496 		case 16:
       
   497 			aChangeType = EMsvMessageStoreNotSupported;
       
   498 			break;
       
   499 		case 17:
       
   500 			aChangeType = EMsvMessageStoreCorrupt;
       
   501 			break;
       
   502 		case 18:
       
   503 			aChangeType = EMsvRefreshMessageView;
       
   504 			break;
       
   505 		case 19:
       
   506 			aChangeType = EMsvDiskNotAvailable;
       
   507 			break;
       
   508 		case 20:
       
   509 			aChangeType = EMsvUnableToProcessDiskNotification;
       
   510 			break;
       
   511 #endif	
       
   512 		default:
       
   513 			__ASSERT_DEBUG(EFalse, PanicServer(EMsvUnknownChangeType));
       
   514 			aChangeType = EMsvEntriesNoChange;
       
   515 		}
       
   516 	aParameter1 = *ptr++;
       
   517 	aParameter2 = *ptr++;
       
   518 	TInt count = *ptr++;
       
   519 	while (count--)
       
   520 		aSelection.AppendL(*ptr++);
       
   521 	}
       
   522 
       
   523 TMsvPackedEntryFilter::TMsvPackedEntryFilter(HBufC8*& aBuffer)
       
   524 : iBuffer(aBuffer)
       
   525 	{}
       
   526 
       
   527 TInt TMsvPackedEntryFilter::PackFilter(const CMsvEntryFilter& aFilter)
       
   528 	{
       
   529 	// find the start and end of the buffer
       
   530 	const TUint8* pS = iBuffer->Ptr();
       
   531 	const TUint8* pE = PtrAdd(pS, iBuffer->Des().MaxSize());
       
   532 
       
   533 	TInt error = DoPackFilter(pS, pE, aFilter);
       
   534 	if (error==KErrNone)
       
   535 		{
       
   536 		// update the length of the buffer
       
   537 		iBuffer->Des().SetLength(pS-iBuffer->Ptr());
       
   538 		}
       
   539 
       
   540 	return error;
       
   541 	}
       
   542 
       
   543 void TMsvPackedEntryFilter::UnpackFilter(CMsvEntryFilter& aFilter)
       
   544 	{
       
   545 #if defined(_DEBUG)
       
   546 	// check that the buffer contain a valid package
       
   547 	const TUint8* dPos = PtrAdd(iBuffer->Ptr(), Align4(sizeof(CMsvEntryFilter)));
       
   548 	__ASSERT_DEBUG(dPos <= PtrAdd(iBuffer->Ptr(), iBuffer->Des().MaxLength()), PanicServer(EMsvEntryOverrunBuffer));
       
   549 #endif	
       
   550 	TUint8* pS = CONST_CAST(TUint8*, iBuffer->Ptr());
       
   551 	DoUnpackFilter(pS, aFilter);
       
   552 	}
       
   553 
       
   554 /**
       
   555 Constructor for TMsvPackQuery.
       
   556 @internalComponent
       
   557 @released
       
   558 @param aBuffer: buffer for packing
       
   559 */
       
   560 
       
   561 EXPORT_C TMsvPackQuery::TMsvPackQuery(HBufC8*& aBuffer)
       
   562 : iBuffer(aBuffer)
       
   563 	{}
       
   564 
       
   565 
       
   566 TInt TMsvPackQuery::DoPackQuery(const TUint8*& aPtrStart, const TUint8* aPtrEnd, const CMsvSearchSortQuery* aQuery)
       
   567 	{
       
   568 	//size of class - sizeof(iQueryTable pointer)
       
   569 	TInt sizeOfClass = Align4(sizeof(CMsvSearchSortQuery) - sizeof(TInt));
       
   570 	TInt sizeQueryTable = Align4(sizeof(TMsvQueryTable) * KMaxLevelOfSearchAndSort);
       
   571 	TInt size = sizeOfClass + sizeQueryTable;
       
   572 	
       
   573 	if ((aPtrStart + size)>aPtrEnd)
       
   574 		{
       
   575 		aPtrStart += size;
       
   576 		return KErrOverflow;
       
   577 		}
       
   578 		
       
   579 	// copy the entry and descriptors into the memory area
       
   580 	Mem::Copy((void*)aPtrStart, aQuery, sizeOfClass);
       
   581 	aPtrStart += sizeOfClass;
       
   582 
       
   583 	Mem::Copy((void*)aPtrStart, aQuery->iQueryTable, sizeQueryTable);
       
   584 	aPtrStart += sizeQueryTable;
       
   585 
       
   586 	return KErrNone;
       
   587 	}
       
   588 
       
   589 /**
       
   590 Packs TMsvSearchSortQuery object into a buffer for sending across IPC. 
       
   591 @internalComponent
       
   592 @released
       
   593 @param aQuery: TMsvSearchSortQuery object needs to pack.
       
   594 @return: reurn KErrNone if successful else KErrOverflow.
       
   595 */
       
   596 EXPORT_C TInt TMsvPackQuery::PackQuery(const CMsvSearchSortQuery* aQuery)
       
   597 	{
       
   598 	// find the start and end of the buffer
       
   599 	const TUint8* pS = iBuffer->Ptr();
       
   600 	const TUint8* pE = PtrAdd(pS, iBuffer->Des().MaxSize());
       
   601 
       
   602 	TInt error = DoPackQuery(pS, pE, aQuery);
       
   603 	if (error==KErrNone)
       
   604 		{
       
   605 		// update the length of the buffer
       
   606 		iBuffer->Des().SetLength(pS-iBuffer->Ptr());
       
   607 		}
       
   608 	return error;
       
   609 	}
       
   610 	
       
   611 
       
   612 void TMsvPackQuery::DoUnpackQuery(TUint8*& aPtr, CMsvSearchSortQuery* aQuery)
       
   613 	{
       
   614 	//size of class - sizeof(iQueryTable pointer)
       
   615 	TInt sizeOfClass = Align4(sizeof(CMsvSearchSortQuery) - sizeof(TInt));
       
   616 	TInt sizeQueryTable = Align4(sizeof(TMsvQueryTable) * KMaxLevelOfSearchAndSort);
       
   617 	
       
   618 	Mem::Copy((void*)aQuery, aPtr, sizeOfClass);
       
   619 	aPtr += sizeOfClass;
       
   620 	
       
   621 	Mem::Copy((void*)aQuery->iQueryTable, aPtr, sizeQueryTable);
       
   622 	aPtr += sizeQueryTable;
       
   623 	}	
       
   624 
       
   625 /**
       
   626 Unpacks the data to a aQuery.
       
   627 @internalComponent
       
   628 @released
       
   629 @param aQuery: Unpacked TMsvSearchSortQuery object.
       
   630 */
       
   631 EXPORT_C void TMsvPackQuery::UnpackQuery(CMsvSearchSortQuery* aQuery)
       
   632 	{
       
   633 #if defined(_DEBUG)
       
   634 	// check that the buffer contain a valid package
       
   635 	const TUint8* dPos = PtrAdd(iBuffer->Ptr(), Align4(sizeof(CMsvSearchSortQuery)));
       
   636 	__ASSERT_DEBUG(dPos <= PtrAdd(iBuffer->Ptr(), iBuffer->Des().MaxLength()), PanicServer(EMsvEntryOverrunBuffer));
       
   637 #endif
       
   638 	
       
   639 	TUint8* pS = CONST_CAST(TUint8*, iBuffer->Ptr());
       
   640 	DoUnpackQuery(pS, aQuery);
       
   641 	}
       
   642 
       
   643 /**
       
   644 Constructor for TMsvPackedIdOperation.
       
   645 @internalComponent
       
   646 @released
       
   647 @param aBuffer: buffer for packing
       
   648 */
       
   649 EXPORT_C TMsvPackedIdOperation::TMsvPackedIdOperation(HBufC8*& aBuffer)
       
   650 : iBuffer(aBuffer)
       
   651 	{
       
   652 	}
       
   653 
       
   654 /**
       
   655 Packs RArray of TMsvId and count value into a buffer for sending across IPC. 
       
   656 @internalComponent
       
   657 @released
       
   658 @param aId: RArray of TMsvIds needs to pack.
       
   659 @return: reurn KErrNone if successful else KErrOverflow.
       
   660 */
       
   661 EXPORT_C TInt TMsvPackedIdOperation::Pack(const RArray<TMsvId>& aId)
       
   662 	{
       
   663 	//place for TMsvId's and count
       
   664 	TInt requiredSize = (aId.Count() + 1) * 4;
       
   665 	
       
   666 	// check the buffer is large enough
       
   667 	if (requiredSize > iBuffer->Des().MaxSize())
       
   668 		{
       
   669 		return KErrOverflow;
       
   670 		}
       
   671 		
       
   672 	// set the buffer with correct length
       
   673 	iBuffer->Des().SetLength(requiredSize);
       
   674 	
       
   675 	TInt* ptr = (TInt*) CONST_CAST(TUint8*, iBuffer->Ptr());
       
   676 	//number of TMsvId's
       
   677 	*ptr++ = aId.Count();
       
   678 	
       
   679 	//copy TMsvId's to buffer 	
       
   680 	for (TInt count=0; count<aId.Count(); count++)
       
   681 		{
       
   682 		*ptr++ = aId[count];
       
   683 		}
       
   684 		
       
   685 	return KErrNone;
       
   686 	}
       
   687 
       
   688 /**
       
   689 Unpacks the data in buffer to a RArray.
       
   690 @internalComponent
       
   691 @released
       
   692 @param aId: Unpacked RArray of TMsvIds.
       
   693 */
       
   694 EXPORT_C void TMsvPackedIdOperation::UnpackL(RArray<TMsvId>& aId)
       
   695 	{
       
   696 	__ASSERT_DEBUG(aId.Count()==0, PanicServer(EMsvOperationUnpackSelectionNotEmpty));	
       
   697 	TInt* ptr = (TInt*) CONST_CAST(TUint8*, iBuffer->Ptr());
       
   698 
       
   699 	//unpack the count
       
   700 	TInt count = *ptr++;
       
   701 	//unpack TMsvId's to RArray
       
   702 	while (count--)
       
   703 		{
       
   704 		aId.AppendL(*ptr++);
       
   705 		}
       
   706 	}
       
   707 
       
   708 
       
   709 /**
       
   710 Constructor for TMsvPackedIdAndMessagePart.
       
   711 @internalComponent
       
   712 @released
       
   713 */
       
   714 EXPORT_C TMsvPackedIdAndMessagePart::TMsvPackedIdAndMessagePart()
       
   715 	{
       
   716 	}
       
   717 
       
   718 /**
       
   719 Size() will returns size of the data occupied by TMsvIdWithSortField.
       
   720 @internalComponent
       
   721 @released
       
   722 @param aData: RArray of TMsvIdWithSortField.
       
   723 */	
       
   724 EXPORT_C TInt TMsvPackedIdAndMessagePart::Size(const RArray<TMsvIdWithSortField>& aData)
       
   725 	{
       
   726 	// number of TMsvId's in RArray
       
   727 	TInt count = aData.Count();
       
   728 	TInt size = 0;
       
   729 	
       
   730 	// to hold counter value
       
   731 	size += sizeof(TInt);
       
   732 	
       
   733 	// calculate length of RArray<TMsvId + SortFiled>
       
   734 	for(TInt index = 0; index < count; index++)
       
   735 		{
       
   736 		size += sizeof(TMsvId);
       
   737 		size += aData[index].iContentMessagePart.Length();
       
   738 		}
       
   739 	return size;
       
   740 	}
       
   741 
       
   742 /**
       
   743 Packs or Externalize the RArray of TMsvIdWithSortField into a aWriteStream for sending across IPC. 
       
   744 @internalComponent
       
   745 @released
       
   746 @param aWriteStream: aData will be written to aWriteStream.
       
   747 @param aData: RArray of TMsvIdWithSortField
       
   748 */	
       
   749 EXPORT_C void TMsvPackedIdAndMessagePart::ExternalizeL(RWriteStream& aWriteStream, RArray<TMsvIdWithSortField>& aData) const
       
   750 	{
       
   751 	TInt count = aData.Count();
       
   752 	aWriteStream.WriteInt32L(count);
       
   753   	
       
   754   	for(TInt index=0; index < count; ++index)
       
   755  		{
       
   756  		aWriteStream.WriteInt32L(aData[index].iMessageId);
       
   757  		aWriteStream << aData[index].iContentMessagePart;
       
   758  		}
       
   759 	}
       
   760 
       
   761 /**
       
   762 Unpacks or Internalize aReadStream buffer to RArray of TMsvIdWithSortField.
       
   763 @internalComponent
       
   764 @released
       
   765 @param aReadStream: aReadStream data will be unpacked to TMsvIdWithSortField of aData.
       
   766 @param aData: RArray of TMsvIdWithSortField
       
   767 */	
       
   768 EXPORT_C void TMsvPackedIdAndMessagePart::InternalizeL(RReadStream& aReadStream, RArray<TMsvIdWithSortField>& aData)
       
   769 	{
       
   770 	TInt count =  aReadStream.ReadInt32L();
       
   771 	
       
   772 	TMsvIdWithSortField tmsvidAndmessagepart;
       
   773 	
       
   774 	for(TInt index=0; index < count; ++index)
       
   775  		{
       
   776  		tmsvidAndmessagepart.iMessageId = aReadStream.ReadInt32L();
       
   777  		aReadStream >> tmsvidAndmessagepart.iContentMessagePart;
       
   778  		aData.AppendL(tmsvidAndmessagepart);
       
   779  		}
       
   780 	}
       
   781 
       
   782 
       
   783 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
   784 EXPORT_C TMsvPackedDriveIdOperation::TMsvPackedDriveIdOperation(HBufC8*& aBuffer)
       
   785 : iBuffer(aBuffer)
       
   786 	{
       
   787 	}
       
   788 	
       
   789 	
       
   790 EXPORT_C void TMsvPackedDriveIdOperation::UnpackL(RArray<TDriveNumber>& aDriveNumber)
       
   791 	{
       
   792 	TInt* ptr = (TInt*) CONST_CAST(TUint8*, iBuffer->Ptr());
       
   793 
       
   794 	// Unpack the count.
       
   795 	TInt count = *ptr++;
       
   796 	
       
   797 	// Append TDriveNumber
       
   798 	while (count--)
       
   799 		{
       
   800 		aDriveNumber.AppendL((TDriveNumber)*ptr++);
       
   801 		}	
       
   802 	}
       
   803 	
       
   804 	
       
   805 EXPORT_C TInt TMsvPackedDriveIdOperation::Pack(const RArray<TDriveNumber>& aDriveNumber)
       
   806 	{
       
   807 	// place for TMsvId's and count
       
   808 	TInt requiredSize = (aDriveNumber.Count() + 1) * 4;
       
   809 	
       
   810 	// check the buffer is large enough
       
   811 	if (requiredSize > iBuffer->Des().MaxSize())
       
   812 		{
       
   813 		return KErrOverflow;
       
   814 		}
       
   815 		
       
   816 	// set the buffer with correct length
       
   817 	iBuffer->Des().SetLength(requiredSize);
       
   818 	
       
   819 	TInt* ptr = (TInt*) CONST_CAST(TUint8*, iBuffer->Ptr());
       
   820 	//number of TMsvId's
       
   821 	*ptr++ = aDriveNumber.Count();
       
   822 	
       
   823 	//copy TMsvId's to buffer 	
       
   824 	for (TInt count=0; count<aDriveNumber.Count(); count++)
       
   825 		{
       
   826 		*ptr++ = aDriveNumber[count];
       
   827 		}
       
   828 		
       
   829 	return KErrNone;
       
   830 	}
       
   831 
       
   832 #endif		// #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
   833 
       
   834 
       
   835 
       
   836 
       
   837 
       
   838 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
       
   839 
       
   840 /**
       
   841  * TMsvPackedHeaderStructure()
       
   842  * 
       
   843  * TMsvPackedHeaderStructure Constructor.
       
   844  *
       
   845  * @param HBufC8*&
       
   846  * @return None.
       
   847  * @leave None.
       
   848  */	
       
   849 EXPORT_C TMsvPackedHeaderStructure::TMsvPackedHeaderStructure(HBufC8*& aBuffer)
       
   850 : iBuffer(aBuffer)
       
   851 	{
       
   852 	}
       
   853 	
       
   854 
       
   855 /**
       
   856  * UnpackL()
       
   857  * 
       
   858  * Unpacks the buffer to fill header structure.
       
   859  *
       
   860  * @param RPointerArray<CFieldPair>&: Header Structure.
       
   861  * @return None.
       
   862  * @leave KErrNoMemory
       
   863  */	
       
   864 EXPORT_C void TMsvPackedHeaderStructure::UnpackL(RPointerArray<CFieldPair>& aFieldDetails)
       
   865 	{
       
   866 	TInt* ptr = (TInt*) CONST_CAST(TUint8*, iBuffer->Ptr());
       
   867 
       
   868 	// Unpack the count.
       
   869 	TInt count = *ptr++;
       
   870 
       
   871 	TInt size = 0;
       
   872 	TPtrC16 ptrBuf;	
       
   873 
       
   874 	while (count--)
       
   875 		{
       
   876 		CFieldPair* fieldPair = new(ELeave) CFieldPair();
       
   877 		CleanupStack::PushL(fieldPair);
       
   878 		size = *ptr++;
       
   879 		
       
   880 		const TText* textPtr = (TText*)ptr;
       
   881 		ptrBuf.Set(textPtr, (size/2));			// ptrBuf is 16 bits.
       
   882 		ptr += Align4(size)/sizeof(TInt);
       
   883 		
       
   884 		fieldPair->iFieldName = ptrBuf.AllocL();
       
   885 		fieldPair->iFieldType = (EFieldType) *ptr++;
       
   886 		aFieldDetails.AppendL(fieldPair);
       
   887 		CleanupStack::Pop();			// fieldPair
       
   888 		}	
       
   889 	}
       
   890 	
       
   891 
       
   892 
       
   893 /**
       
   894  * Pack()
       
   895  * 
       
   896  * Packs the header structure to a buffer.
       
   897  *
       
   898  * @param RPointerArray<CFieldPair>&: Header Structure.
       
   899  * @return TInt: KErrOverflow, if buffer does not have sufficient memory.
       
   900  */		
       
   901 EXPORT_C TInt TMsvPackedHeaderStructure::Pack(const RPointerArray<CFieldPair>& aFieldDetails)
       
   902 	{
       
   903 	TInt count = aFieldDetails.Count();
       
   904 	TInt requiredSize = 0;
       
   905 	
       
   906 	// Calculate the size of the data to be written.
       
   907 	for(TInt index=0; index<count; index++)
       
   908 		{
       
   909 		CFieldPair* fieldPair = aFieldDetails[index]; 	
       
   910 		requiredSize += Align4(fieldPair->iFieldName->Des().Size());
       
   911 		requiredSize += 8;		// 4 bytes for EFieldType and 4 bytes for size of iFieldName
       
   912 		}
       
   913 	
       
   914 	// 4 bytes are needed to store the array count.
       
   915 	requiredSize += 4;
       
   916 	if(requiredSize > iBuffer->Des().MaxSize())
       
   917 		{
       
   918 		return KErrOverflow;
       
   919 		}
       
   920 
       
   921 	// Set the buffer with correct length
       
   922 	iBuffer->Des().SetLength(requiredSize);
       
   923 		
       
   924 	// Start writing to the buffer.
       
   925 	TInt* ptr = (TInt*) CONST_CAST(TUint8*, iBuffer->Ptr());
       
   926 	*ptr++ = count;
       
   927 	
       
   928 	for(TInt index=0; index<count; index++)
       
   929 		{
       
   930 		CFieldPair* fieldPair = aFieldDetails[index];
       
   931 		TInt size = fieldPair->iFieldName->Des().Size();
       
   932 		
       
   933 		*ptr++ = size;
       
   934 		Mem::Copy((void*)ptr, fieldPair->iFieldName->Des().Ptr(), size);
       
   935 		ptr += (Align4(size))/sizeof(TInt);
       
   936 		*ptr++ = (TInt)(fieldPair->iFieldType);
       
   937 		}
       
   938 
       
   939 	// place for TMsvId's and count
       
   940 	return KErrNone;
       
   941 	}
       
   942 
       
   943 
       
   944 
       
   945 
       
   946 /**
       
   947  * TMsvPackedHeaderData()
       
   948  * 
       
   949  * TMsvPackedHeaderData Constructor.
       
   950  *
       
   951  * @param HBufC8*&
       
   952  * @return None.
       
   953  * @leave None.
       
   954  */	
       
   955 EXPORT_C TMsvPackedHeaderData::TMsvPackedHeaderData(HBufC8*& aBuffer)
       
   956 : iBuffer(aBuffer)
       
   957 	{
       
   958 	}
       
   959 	
       
   960 
       
   961 /**
       
   962  * UnpackL()
       
   963  * 
       
   964  * Unpacks the buffer to fill header data structure.
       
   965  *
       
   966  * @param RPointerArray<CHeaderFields>&: Header Structure.
       
   967  * @return None.
       
   968  * @leave KErrNoMemory
       
   969  */		
       
   970 EXPORT_C void TMsvPackedHeaderData::UnpackL(RPointerArray<CHeaderFields>& aFieldDetails)
       
   971 	{
       
   972 	aFieldDetails.ResetAndDestroy();
       
   973 	TInt* ptr = (TInt*) CONST_CAST(TUint8*, iBuffer->Ptr());
       
   974 
       
   975 	// Unpack the count.
       
   976 	TInt count = *ptr++;
       
   977 
       
   978 	TPtrC16 ptrBuf;
       
   979 	while (count--)
       
   980 		{
       
   981 		CHeaderFields* headerRow = new(ELeave) CHeaderFields();
       
   982 		CleanupStack::PushL(headerRow);
       
   983 		
       
   984 		headerRow->iUid = TUid::Uid(*ptr++);
       
   985 		TInt colCount = *ptr++;
       
   986 		while(colCount--)
       
   987 			{
       
   988 			CFieldPair* fieldObj = new(ELeave) CFieldPair();
       
   989 			CleanupStack::PushL(fieldObj);
       
   990 			
       
   991 			if(EIntegerField == (EFieldType)*ptr++)
       
   992 				{
       
   993 				TUint32 rVal = *ptr++;
       
   994 				fieldObj->iFieldNumValue = rVal;
       
   995 				TUint64 lVal = (*ptr++);
       
   996 				lVal = lVal << 32;
       
   997 				fieldObj->iFieldNumValue |= lVal;
       
   998 				}
       
   999 			else
       
  1000 				{
       
  1001 				TInt size = *ptr++;
       
  1002 				const TText* textPtr = (TText*)ptr;
       
  1003 				ptrBuf.Set(textPtr, (size/2));
       
  1004 				ptr += Align4(size)/sizeof(TInt);
       
  1005 				
       
  1006 				fieldObj->iFieldTextValue = ptrBuf.AllocL();
       
  1007 				}
       
  1008 
       
  1009 			headerRow->iFieldPairList.AppendL(fieldObj);
       
  1010 			CleanupStack::Pop(fieldObj);
       
  1011 			}
       
  1012 		
       
  1013 		aFieldDetails.AppendL(headerRow);
       
  1014 		CleanupStack::Pop(headerRow);
       
  1015 		}	
       
  1016 	}
       
  1017 	
       
  1018 
       
  1019 
       
  1020 
       
  1021 /**
       
  1022  * Pack()
       
  1023  * 
       
  1024  * Packs the header data to a buffer.
       
  1025  *
       
  1026  * @param RPointerArray<CHeaderFields>&: Header Data.
       
  1027  * @return TInt: KErrOverflow, if buffer does not have sufficient memory.
       
  1028  */		
       
  1029 EXPORT_C TInt TMsvPackedHeaderData::Pack(const RPointerArray<CHeaderFields>& aFieldDetails)
       
  1030 	{
       
  1031 	TInt count = aFieldDetails.Count();
       
  1032 	TInt requiredSize = 0;
       
  1033 	
       
  1034 	// Calculate the size of the data to be written.
       
  1035 	for(TInt headerRow=0; headerRow<count; headerRow++)
       
  1036 		{
       
  1037 		RPointerArray<CFieldPair>& fieldPairList = aFieldDetails[headerRow]->iFieldPairList;
       
  1038 		for(TInt fieldIndex=0; fieldIndex<fieldPairList.Count(); fieldIndex++)	
       
  1039 			{
       
  1040 			requiredSize += 4;			// Store the data type.
       
  1041 			// If it is a text field
       
  1042 			if(fieldPairList[fieldIndex]->iFieldTextValue)
       
  1043 				{
       
  1044 				requiredSize += 4; 		// 4 bytes to store size of iFieldTextValue
       
  1045 				requiredSize += Align4(fieldPairList[fieldIndex]->iFieldTextValue->Des().Size());				
       
  1046 				}
       
  1047 			else	// For Int or date field.
       
  1048 				{
       
  1049 				requiredSize += sizeof(TInt64);
       
  1050 				}				
       
  1051 			}
       
  1052 		requiredSize += 8;		// 4 bytes for TUid, 4 bytes for size of iFieldPairList
       
  1053 		}
       
  1054 	requiredSize += 4; 			// 4 bytes are needed to store the array count. (count)
       
  1055 	
       
  1056 	if(requiredSize > iBuffer->Des().MaxSize())
       
  1057 		{
       
  1058 		return KErrOverflow;
       
  1059 		}
       
  1060 
       
  1061 	// Set the buffer with correct length
       
  1062 	iBuffer->Des().SetLength(requiredSize);
       
  1063 	
       
  1064 	// Start writing to the buffer.
       
  1065 	TInt* ptr = (TInt*) CONST_CAST(TUint8*, iBuffer->Ptr());
       
  1066 	*ptr++ = count;
       
  1067 	
       
  1068 	for(TInt headerRow=0; headerRow<count; headerRow++)
       
  1069 		{
       
  1070 		// For each header row...
       
  1071 		
       
  1072 		// Store UID of the row.
       
  1073 		*ptr++ = aFieldDetails[headerRow]->iUid.iUid;
       
  1074 		
       
  1075 		// Store field list.
       
  1076 		RPointerArray<CFieldPair>& fieldPairList = aFieldDetails[headerRow]->iFieldPairList;
       
  1077 		*ptr++ = fieldPairList.Count();
       
  1078 		
       
  1079 		for(TInt fieldIndex=0; fieldIndex<fieldPairList.Count(); fieldIndex++)
       
  1080 			{
       
  1081 			CFieldPair* fieldPair = fieldPairList[fieldIndex];
       
  1082 			if(fieldPair->iFieldTextValue)
       
  1083 				{
       
  1084 				// Data type
       
  1085 				*ptr++ = ETextField;				
       
  1086 				// Data Size
       
  1087 				TInt textSize = fieldPair->iFieldTextValue->Des().Size();
       
  1088 				*ptr++ = textSize;
       
  1089 				// Data
       
  1090 				Mem::Copy((void*)ptr, fieldPair->iFieldTextValue->Des().Ptr(), textSize);
       
  1091 				ptr += Align4(textSize)/sizeof(TInt);
       
  1092 				}
       
  1093 			else
       
  1094 				{
       
  1095 				// Data type
       
  1096 				*ptr++ = EIntegerField;
       
  1097 				// Data (64 bits)
       
  1098 				TUint64 maskVal = KMaxTUint32;
       
  1099 				*ptr++ = (fieldPair->iFieldNumValue) & maskVal;
       
  1100 				maskVal = ~maskVal;
       
  1101 				*ptr++ = (fieldPair->iFieldNumValue & maskVal) >> 32;
       
  1102 				}
       
  1103 			}
       
  1104 		}
       
  1105 		
       
  1106 	return KErrNone;
       
  1107 	}
       
  1108 	
       
  1109 
       
  1110 
       
  1111 #endif		// #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
       
  1112 
       
  1113 
       
  1114 
       
  1115