Update contrib.
1 // Copyright (c) 2007-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 the License "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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include <caf/streaming/keystreamsink.h>
18 #include "ipsec/ipseckeystreamsink.h"
21 const TInt KExpandSize = 128;
23 using namespace StreamAccess;
25 EXPORT_C TPtr8 CKeyStreamSink::ExternalizeLC() const
27 CBufFlat* buf = CBufFlat::NewL(KExpandSize);
28 CleanupStack::PushL(buf);
30 RBufWriteStream stream(*buf);
31 CleanupClosePushL(stream);
32 this->DoExternalizeL(stream);
33 CleanupStack::PopAndDestroy(&stream);
35 HBufC8 *allocatedBuf = HBufC8::NewL(buf->Size());
36 TPtr8 ptr(allocatedBuf->Des());
37 buf->Read(0, ptr, buf->Size());
38 CleanupStack::PopAndDestroy(buf);
39 CleanupStack::PushL(allocatedBuf);
43 EXPORT_C CKeyStreamSink* CKeyStreamSink::InternalizeLC(const TDesC8 &aBuf)
45 CKeyStreamSink* ret(NULL);
46 RDesReadStream readStream(aBuf);
47 CleanupClosePushL(readStream);
48 TUint16 keyStreamSinkType = readStream.ReadUint16L();
49 switch (keyStreamSinkType)
51 case EIpSecSinkId: ret = CIpSecKeyStreamSink::NewLC(readStream); break;
52 default: User::Leave(KErrNotSupported);
54 CleanupStack::Pop(ret);
55 CleanupStack::PopAndDestroy(&readStream);
56 CleanupStack::PushL(ret);