|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <e32base.h> |
|
22 |
|
23 _LIT8( KPassword,"salasana"); |
|
24 |
|
25 #include "cunsafmessageencoder.h" |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CUnsafMessageEncoder::CUnsafMessageEncoder() |
|
32 { |
|
33 } |
|
34 |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 void CUnsafMessageEncoder::ConstructL() |
|
41 { |
|
42 } |
|
43 |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CUnsafMessageEncoder* CUnsafMessageEncoder::NewL() |
|
50 { |
|
51 CUnsafMessageEncoder* self = CUnsafMessageEncoder::NewLC(); |
|
52 CleanupStack::Pop( self ); |
|
53 return self; |
|
54 } |
|
55 |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 CUnsafMessageEncoder* CUnsafMessageEncoder::NewLC() |
|
62 { |
|
63 CUnsafMessageEncoder* self = new( ELeave ) CUnsafMessageEncoder; |
|
64 CleanupStack::PushL( self ); |
|
65 self->ConstructL(); |
|
66 return self; |
|
67 } |
|
68 |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 CUnsafMessageEncoder::~CUnsafMessageEncoder() |
|
75 { |
|
76 } |
|
77 |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 HBufC8* CUnsafMessageEncoder::EncodeMessageL( |
|
84 const CNATFWUNSAFMessage& aRequest, const TBool aUseSharedSecret, |
|
85 const TBool aAddFingerPrint ) |
|
86 { |
|
87 CBufBase* message = NULL; |
|
88 |
|
89 if ( !aUseSharedSecret ) |
|
90 { |
|
91 message = aRequest.EncodeL(); |
|
92 } |
|
93 else if ( !aAddFingerPrint ) |
|
94 { |
|
95 message = aRequest.EncodeL( KPassword ); |
|
96 } |
|
97 else |
|
98 { |
|
99 // ETrue indicates that fingerprint attribute will be added |
|
100 message = aRequest.EncodeL( KPassword, ETrue ); |
|
101 } |
|
102 |
|
103 CleanupStack::PushL( message ); |
|
104 TInt length = message->Size(); |
|
105 HBufC8* readBuf = HBufC8::NewLC( length ); |
|
106 TPtr8 writable( readBuf->Des() ); |
|
107 message->Read( 0, writable, length ); |
|
108 |
|
109 CleanupStack::Pop( readBuf ); |
|
110 CleanupStack::PopAndDestroy( message ); |
|
111 |
|
112 return readBuf; |
|
113 } |
|
114 |
|
115 |
|
116 |