|
1 /* |
|
2 * Copyright (c) 2007 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <sipprofile.h> |
|
22 #include "mcesecureoutsession.h" |
|
23 #include "mcemanager.h" |
|
24 #include "mceevent.h" |
|
25 #include "mcecomsession.h" |
|
26 #include "mceitcsender.h" |
|
27 #include "mceserial.h" |
|
28 #include "mceclilogs.h" |
|
29 |
|
30 |
|
31 #define _FLAT_DATA static_cast<CMceComSession*>( iFlatData ) |
|
32 #define FLAT_DATA( data ) _FLAT_DATA->data |
|
33 |
|
34 // ============================ MEMBER FUNCTIONS =============================== |
|
35 |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CMceSecureOutSession::NewL |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 EXPORT_C CMceSecureOutSession* CMceSecureOutSession::NewL( |
|
42 CMceManager& aManager, |
|
43 CSIPProfile& aProfile, |
|
44 const TDesC8& aRecipient, |
|
45 HBufC8* aOriginator ) |
|
46 { |
|
47 TUint32 profileId(0); |
|
48 if ( aProfile.GetParameter( KSIPProfileId, profileId ) != KErrNone ) |
|
49 { |
|
50 User::Leave(KErrNotFound); |
|
51 } |
|
52 |
|
53 CMceSecureOutSession* self = |
|
54 new ( ELeave ) CMceSecureOutSession( &aManager, profileId ); |
|
55 CleanupStack::PushL( self ); |
|
56 self->ConstructL( aRecipient, aOriginator ); |
|
57 CleanupStack::Pop( self ); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CMceSecureOutSession::NewL |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 EXPORT_C CMceSecureOutSession* CMceSecureOutSession::NewL( CMceEvent& aEvent ) |
|
66 { |
|
67 CMceSecureOutSession* self = |
|
68 new ( ELeave ) CMceSecureOutSession( &aEvent.Manager(), |
|
69 aEvent.ProfileId() ); |
|
70 CleanupStack::PushL( self ); |
|
71 self->ConstructL( aEvent.Recipient(), |
|
72 aEvent.Originator(), |
|
73 aEvent.DialogId() ); |
|
74 CleanupStack::Pop( self ); |
|
75 return self; |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CMceSecureOutSession::NewL |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 EXPORT_C CMceSecureOutSession* CMceSecureOutSession::NewL( CMceRefer& aRefer ) |
|
83 { |
|
84 CMceSecureOutSession* self = |
|
85 new ( ELeave ) CMceSecureOutSession( &aRefer.Manager(), |
|
86 aRefer.ProfileId() ); |
|
87 CleanupStack::PushL( self ); |
|
88 self->ConstructL( aRefer.Recipient(), |
|
89 aRefer.Originator(), |
|
90 aRefer.DialogId() ); |
|
91 CleanupStack::Pop( self ); |
|
92 return self; |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CMceSecureOutSession::~CMceSecureOutSession |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 EXPORT_C CMceSecureOutSession::~CMceSecureOutSession() |
|
100 { |
|
101 iTemp.Close(); |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CMceSecureOutSession::Type |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 TMceSessionType CMceSecureOutSession::Type() const |
|
109 { |
|
110 return KMceSessionSecure; |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CMceSecureOutSession::SupportedCryptoContextsL |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 const RArray<TMceCryptoContext>& |
|
118 CMceSecureOutSession::SupportedCryptoContextsL() const |
|
119 { |
|
120 return iTemp; |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CMceSecureOutSession::CryptoContexts |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 const RArray<TMceCryptoContext>& CMceSecureOutSession::CryptoContexts() const |
|
128 { |
|
129 return FLAT_DATA( iClientCryptoSuites ); |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CMceSecureOutSession::SetCryptoContextsL |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void CMceSecureOutSession::SetCryptoContextsL( |
|
137 const RArray<TMceCryptoContext>& aArray ) |
|
138 { |
|
139 MCECLI_DEBUG( "CMceSecureOutSession::SetCryptoContextsL, Entry" ) |
|
140 TBool equal( ETrue ); |
|
141 TInt index = 0; |
|
142 TInt count = aArray.Count(); |
|
143 if ( count != FLAT_DATA( iClientCryptoSuites ).Count()) |
|
144 { |
|
145 equal = !equal; |
|
146 } |
|
147 else |
|
148 { |
|
149 for ( index = 0; index < count; index ++) |
|
150 { |
|
151 if (aArray[ index ] != FLAT_DATA( iClientCryptoSuites )[ index ]) |
|
152 { |
|
153 equal = !equal; |
|
154 } |
|
155 } |
|
156 } |
|
157 if ( !equal ) |
|
158 { |
|
159 MCECLI_DEBUG( "CMceSecureOutSession::SetCryptoContextsL, setting" ) |
|
160 |
|
161 FLAT_DATA( iClientCryptoSuites ).Reset(); |
|
162 for ( index = 0; index < count; index++) |
|
163 { |
|
164 FLAT_DATA( iClientCryptoSuites ).InsertL(aArray[index], index ); |
|
165 } |
|
166 } |
|
167 |
|
168 MCECLI_DEBUG( "CMceSecureOutSession::SetCryptoContextsL, Exit" ) |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // CMceSecureOutSession::NewL |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 CMceSecureOutSession* CMceSecureOutSession::NewL() |
|
176 { |
|
177 CMceSecureOutSession* self = |
|
178 new ( ELeave ) CMceSecureOutSession( NULL, NULL ); |
|
179 CleanupStack::PushL( self ); |
|
180 self->ConstructL( KNullDesC8, NULL ); |
|
181 CleanupStack::Pop( self ); |
|
182 return self; |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CMceSecureOutSession::CMceSecureOutSession |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 CMceSecureOutSession::CMceSecureOutSession( CMceManager* aManager, |
|
190 TUint32 aProfileId ) : |
|
191 CMceOutSession( aManager, aProfileId ) |
|
192 { |
|
193 //NOP |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CMceSecureOutSession::ConstructL |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 void CMceSecureOutSession::ConstructL( const TDesC8& aRecipient, |
|
201 HBufC8* aOriginator ) |
|
202 { |
|
203 // CMceOutSession::ConstructL takes ownership of aOriginator. But as leave |
|
204 // may occur after that, create a copy of aOriginator. |
|
205 HBufC8* originator( NULL ); |
|
206 if ( aOriginator ) |
|
207 { |
|
208 originator = aOriginator->AllocL(); |
|
209 } |
|
210 CleanupStack::PushL( originator ); |
|
211 CMceOutSession::ConstructL( aRecipient, originator ); |
|
212 CleanupStack::Pop( originator ); |
|
213 |
|
214 FLAT_DATA( iClientCryptoSuites ).InsertL( EAES_CM_128_HMAC_SHA1_80, 0 ); |
|
215 FLAT_DATA( iClientCryptoSuites ).InsertL( EAES_CM_128_HMAC_SHA1_32, 1 ); |
|
216 |
|
217 iTemp.Reset(); |
|
218 User::LeaveIfError( iTemp.Append( EAES_CM_128_HMAC_SHA1_80 ) ); |
|
219 User::LeaveIfError( iTemp.Append( EAES_CM_128_HMAC_SHA1_32 ) ); |
|
220 |
|
221 // Take ownership when leave can't happen |
|
222 delete aOriginator; |
|
223 } |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // CMceSecureOutSession::ConstructL |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 void CMceSecureOutSession::ConstructL( const TDesC8& aRecipient, |
|
230 const TDesC8& aOriginator, |
|
231 TUint32 aDialogId ) |
|
232 { |
|
233 CMceOutSession::ConstructL( aRecipient, aOriginator, aDialogId ); |
|
234 FLAT_DATA( iClientCryptoSuites ).InsertL( EAES_CM_128_HMAC_SHA1_80, 0 ); |
|
235 FLAT_DATA( iClientCryptoSuites ).InsertL( EAES_CM_128_HMAC_SHA1_32, 1 ); |
|
236 |
|
237 iTemp.Reset(); |
|
238 User::LeaveIfError( iTemp.Append( EAES_CM_128_HMAC_SHA1_80 ) ); |
|
239 User::LeaveIfError( iTemp.Append( EAES_CM_128_HMAC_SHA1_32 ) ); |
|
240 } |