sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
|
sl@0
|
17 |
#include <caf/streaming/keystreamsink.h>
|
sl@0
|
18 |
#include "ipsec/ipseckeystreamsink.h"
|
sl@0
|
19 |
#include <s32mem.h>
|
sl@0
|
20 |
|
sl@0
|
21 |
const TInt KExpandSize = 128;
|
sl@0
|
22 |
|
sl@0
|
23 |
using namespace StreamAccess;
|
sl@0
|
24 |
|
sl@0
|
25 |
EXPORT_C TPtr8 CKeyStreamSink::ExternalizeLC() const
|
sl@0
|
26 |
{
|
sl@0
|
27 |
CBufFlat* buf = CBufFlat::NewL(KExpandSize);
|
sl@0
|
28 |
CleanupStack::PushL(buf);
|
sl@0
|
29 |
|
sl@0
|
30 |
RBufWriteStream stream(*buf);
|
sl@0
|
31 |
CleanupClosePushL(stream);
|
sl@0
|
32 |
this->DoExternalizeL(stream);
|
sl@0
|
33 |
CleanupStack::PopAndDestroy(&stream);
|
sl@0
|
34 |
|
sl@0
|
35 |
HBufC8 *allocatedBuf = HBufC8::NewL(buf->Size());
|
sl@0
|
36 |
TPtr8 ptr(allocatedBuf->Des());
|
sl@0
|
37 |
buf->Read(0, ptr, buf->Size());
|
sl@0
|
38 |
CleanupStack::PopAndDestroy(buf);
|
sl@0
|
39 |
CleanupStack::PushL(allocatedBuf);
|
sl@0
|
40 |
return ptr;
|
sl@0
|
41 |
}
|
sl@0
|
42 |
|
sl@0
|
43 |
EXPORT_C CKeyStreamSink* CKeyStreamSink::InternalizeLC(const TDesC8 &aBuf)
|
sl@0
|
44 |
{
|
sl@0
|
45 |
CKeyStreamSink* ret(NULL);
|
sl@0
|
46 |
RDesReadStream readStream(aBuf);
|
sl@0
|
47 |
CleanupClosePushL(readStream);
|
sl@0
|
48 |
TUint16 keyStreamSinkType = readStream.ReadUint16L();
|
sl@0
|
49 |
switch (keyStreamSinkType)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
case EIpSecSinkId: ret = CIpSecKeyStreamSink::NewLC(readStream); break;
|
sl@0
|
52 |
default: User::Leave(KErrNotSupported);
|
sl@0
|
53 |
}
|
sl@0
|
54 |
CleanupStack::Pop(ret);
|
sl@0
|
55 |
CleanupStack::PopAndDestroy(&readStream);
|
sl@0
|
56 |
CleanupStack::PushL(ret);
|
sl@0
|
57 |
return ret;
|
sl@0
|
58 |
}
|