|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 #include <caf/streaming/keystreamsink.h> |
|
18 #include "ipsec/ipseckeystreamsink.h" |
|
19 #include <s32mem.h> |
|
20 |
|
21 const TInt KExpandSize = 128; |
|
22 |
|
23 using namespace StreamAccess; |
|
24 |
|
25 EXPORT_C TPtr8 CKeyStreamSink::ExternalizeLC() const |
|
26 { |
|
27 CBufFlat* buf = CBufFlat::NewL(KExpandSize); |
|
28 CleanupStack::PushL(buf); |
|
29 |
|
30 RBufWriteStream stream(*buf); |
|
31 CleanupClosePushL(stream); |
|
32 this->DoExternalizeL(stream); |
|
33 CleanupStack::PopAndDestroy(&stream); |
|
34 |
|
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); |
|
40 return ptr; |
|
41 } |
|
42 |
|
43 EXPORT_C CKeyStreamSink* CKeyStreamSink::InternalizeLC(const TDesC8 &aBuf) |
|
44 { |
|
45 CKeyStreamSink* ret(NULL); |
|
46 RDesReadStream readStream(aBuf); |
|
47 CleanupClosePushL(readStream); |
|
48 TUint16 keyStreamSinkType = readStream.ReadUint16L(); |
|
49 switch (keyStreamSinkType) |
|
50 { |
|
51 case EIpSecSinkId: ret = CIpSecKeyStreamSink::NewLC(readStream); break; |
|
52 default: User::Leave(KErrNotSupported); |
|
53 } |
|
54 CleanupStack::Pop(ret); |
|
55 CleanupStack::PopAndDestroy(&readStream); |
|
56 CleanupStack::PushL(ret); |
|
57 return ret; |
|
58 } |