diff -r 000000000000 -r 8e480a14352b messagingfw/msgsrvnstore/server/src/TMsvPackedNotifierRequest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingfw/msgsrvnstore/server/src/TMsvPackedNotifierRequest.cpp Mon Jan 18 20:36:02 2010 +0200 @@ -0,0 +1,82 @@ +// Copyright (c) 2005-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 +#include "MSVPANIC.H" + +const TInt KTSecInfoNumTInts = sizeof(TSecurityInfo)/sizeof(TInt); + + +EXPORT_C TMsvPackedNotifierRequest::TMsvPackedNotifierRequest(HBufC8*& aBuffer) +: iBuffer(aBuffer) + { + } + +EXPORT_C TInt TMsvPackedNotifierRequest::Pack(const CMsvEntrySelection& aSelection, const TSecurityInfo& aSecurityInfo) + { + // check the buffer is large enough for the CMsvSelection array and the TSecurityInfo object + // note the extra +1 is to package the CMsvSelection array count + TInt requiredSize = ((aSelection.Count()+KTSecInfoNumTInts+1)*sizeof(TInt)); + if (requiredSize>iBuffer->Des().MaxSize()) + { + return KErrOverflow; + } + + // set the buffer (contents) length + iBuffer->Des().SetLength(requiredSize); + + // get pointer to start of iBuffer data + TInt* ptr = (TInt*) const_cast (iBuffer->Ptr()); + + // pack MSvSelection array size and contents + *ptr++ = aSelection.Count(); + for (TInt count=0; count (&aSecurityInfo); + + // pack TSecurityInfo size and copy into buffer + for (TInt count=0; count (aBuffer.Ptr()); + + // extract the CMsvEntrySelection object + TInt count = *ptr++; + while (count--) + { + aSelection.AppendL(*ptr++); + } + + // extract the TSecurityInfo object + TInt* secPtr = (TInt*) const_cast (&aSecurityInfo); + count = KTSecInfoNumTInts; + while (count--) + { + *secPtr++ = *ptr++; + } + }