28 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
28 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
29 |
29 |
30 |
30 |
31 // INCLUDE FILES |
31 // INCLUDE FILES |
32 #include <e32base.h> |
32 #include <e32base.h> |
33 //#include "EapTlsPeapUtils.h" |
33 #include "EapTlsPeapUtils.h" |
34 #include <EapTlsPeapUiConnection.h> |
34 #include <EapTlsPeapUiConnection.h> |
35 #include <EapTlsPeapUiEapTypes.h> |
35 #include <EapTlsPeapUiEapTypes.h> |
36 #include <EapTlsPeapUiEapType.h> |
36 #include <EapTlsPeapUiEapType.h> |
37 #include <EapTraceSymbian.h> |
37 #include "eap_am_trace_symbian.h" |
38 #include "EapConversion.h" |
|
39 #include <EapType.h> |
|
40 |
38 |
41 const TUint KNumberOfSupportedEAPTypes = 10; //Now 10, including EAP-FAST & TTLS-PAP |
39 const TUint KNumberOfSupportedEAPTypes = 10; //Now 10, including EAP-FAST & TTLS-PAP |
42 |
40 |
43 CEapTlsPeapUiEapTypes::CEapTlsPeapUiEapTypes(CEapTlsPeapUiConnection * const aUiConn) |
41 CEapTlsPeapUiEapTypes::CEapTlsPeapUiEapTypes(CEapTlsPeapUiConnection * const aUiConn) |
44 : iIsOpened(EFalse) |
42 : iIsOpened(EFalse) |
45 , iUiConn(aUiConn) |
43 , iUiConn(aUiConn) |
46 , iDataPtr(NULL) |
44 , iDataPtr(NULL) |
47 , iEapTypeConnection(NULL) |
|
48 { |
45 { |
49 } |
46 } |
50 |
47 |
51 |
48 |
52 CEapTlsPeapUiEapTypes::~CEapTlsPeapUiEapTypes() |
49 CEapTlsPeapUiEapTypes::~CEapTlsPeapUiEapTypes() |
53 { |
50 { |
54 Close(); |
51 if (iUiConn) |
|
52 { |
|
53 Close(); |
|
54 iUiConn = NULL; |
|
55 } |
55 } |
56 } |
56 |
57 |
57 |
58 |
58 TInt CEapTlsPeapUiEapTypes::Open() |
59 TInt CEapTlsPeapUiEapTypes::Open() |
59 { |
60 { |
60 if (iIsOpened) |
61 if (iIsOpened) |
61 { |
62 { |
62 return KErrAlreadyExists; |
63 return KErrAlreadyExists; |
63 } |
64 } |
64 |
65 |
65 TEapExpandedType aEapType(iUiConn->GetEapType()); |
66 TInt err = iUiConn->GetDatabase(iDatabase); |
66 |
67 if (err != KErrNone) |
67 TRAPD(error, iEapTypeConnection = CEapType::NewL(iUiConn->GetIndexType(), iUiConn->GetIndex(), aEapType)); |
68 { |
68 if (error != KErrNone) |
69 return err; |
69 { |
70 } |
70 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: CEapTlsPeapUiEapTypes::Open() CEapType::NewL() error=%d\n"),error)); |
71 |
71 return error; |
|
72 } |
|
73 |
|
74 iEapTypeConnection->SetTunnelingType(iUiConn->GetTunnelingType()); |
|
75 |
|
76 iIsOpened = ETrue; |
72 iIsOpened = ETrue; |
77 |
73 |
78 return KErrNone; |
74 return KErrNone; |
79 } |
75 } |
80 |
76 |
81 |
77 |
82 TInt CEapTlsPeapUiEapTypes::GetEapTypes(RPointerArray<TEapTlsPeapUiEapType> ** aDataPtr) |
78 TInt CEapTlsPeapUiEapTypes::GetEapTypes(CArrayFixFlat<TEapTlsPeapUiEapType> ** aDataPtr) |
83 { |
79 { |
84 if (aDataPtr == NULL) |
80 if (aDataPtr == NULL) |
85 { |
81 { |
86 return KErrArgument; |
82 return KErrArgument; |
87 } |
83 } |
88 |
84 if (iIsOpened == EFalse) |
89 if (iIsOpened == EFalse) |
|
90 { |
85 { |
91 return KErrSessionClosed; |
86 return KErrSessionClosed; |
92 } |
87 } |
93 |
|
94 if (iDataPtr != 0) |
88 if (iDataPtr != 0) |
95 { |
89 { |
96 *aDataPtr = iDataPtr; |
90 *aDataPtr = iDataPtr; |
97 return KErrNone; |
91 return KErrNone; |
98 } |
92 } |
99 |
93 iDataPtr = new CArrayFixFlat<TEapTlsPeapUiEapType>(KNumberOfSupportedEAPTypes); |
100 iDataPtr = new RPointerArray<TEapTlsPeapUiEapType>(KNumberOfSupportedEAPTypes); |
|
101 if (!iDataPtr) |
94 if (!iDataPtr) |
102 { |
95 { |
103 return KErrNoMemory; |
96 return KErrNoMemory; |
104 } |
97 } |
105 |
98 |
|
99 #ifdef USE_EAP_EXPANDED_TYPES |
|
100 |
106 TRAPD(err, FetchExpandedDataL()); |
101 TRAPD(err, FetchExpandedDataL()); |
|
102 |
|
103 #else |
|
104 |
|
105 TRAPD(err, FetchDataL()); |
|
106 |
|
107 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
108 |
107 if (err != KErrNone) |
109 if (err != KErrNone) |
108 { |
110 { |
109 delete iDataPtr; |
111 delete iDataPtr; |
110 return err; |
112 return err; |
111 } |
113 } |
133 |
180 |
134 delete iDataPtr; |
181 delete iDataPtr; |
135 iDataPtr = 0; |
182 iDataPtr = 0; |
136 |
183 |
137 iUiConn = NULL; |
184 iUiConn = NULL; |
138 |
|
139 if (iEapTypeConnection) |
|
140 { |
|
141 delete iEapTypeConnection; |
|
142 iEapTypeConnection = 0; |
|
143 } |
|
144 |
|
145 iIsOpened = EFalse; |
|
146 |
|
147 return KErrNone; |
185 return KErrNone; |
148 } |
186 } |
149 |
187 |
|
188 #ifndef USE_EAP_EXPANDED_TYPES |
|
189 |
|
190 void CEapTlsPeapUiEapTypes::FetchDataL() |
|
191 { |
|
192 TEapArray eapTypes; |
|
193 |
|
194 TRAPD(err, EapTlsPeapUtils::GetEapDataL( |
|
195 iDatabase, |
|
196 0, |
|
197 eapTypes, |
|
198 iUiConn->GetIndexType(), |
|
199 iUiConn->GetIndex(), |
|
200 static_cast<eap_type_value_e>(iUiConn->GetTunnelingType()), |
|
201 static_cast<eap_type_value_e>(iUiConn->GetEapType()))); |
|
202 |
|
203 if (err != KErrNone) |
|
204 { |
|
205 eapTypes.ResetAndDestroy(); |
|
206 User::Leave(err); |
|
207 } |
|
208 |
|
209 TInt i(0); |
|
210 for (i = 0; i < eapTypes.Count(); i++) |
|
211 { |
|
212 TEapTlsPeapUiEapType tmp; |
|
213 |
|
214 tmp.iIsEnabled = eapTypes[i]->Enabled; |
|
215 |
|
216 tmp.iEapType.Copy(eapTypes[i]->UID); |
|
217 |
|
218 TRAPD(err, iDataPtr->AppendL(tmp)); |
|
219 if (err != KErrNone) |
|
220 { |
|
221 eapTypes.ResetAndDestroy(); |
|
222 User::Leave(err); |
|
223 } |
|
224 } |
|
225 eapTypes.ResetAndDestroy(); |
|
226 } |
|
227 #endif // #ifndef USE_EAP_EXPANDED_TYPES |
|
228 |
|
229 #ifdef USE_EAP_EXPANDED_TYPES |
|
230 |
150 void CEapTlsPeapUiEapTypes::FetchExpandedDataL() |
231 void CEapTlsPeapUiEapTypes::FetchExpandedDataL() |
151 { |
232 { |
152 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::FetchExpandedDataL: Start\n"))); |
233 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::FetchExpandedDataL: Start\n"))); |
153 |
234 |
154 EAPSettings aSettings; |
235 RExpandedEapTypePtrArray enabledEAPTypes; |
|
236 RExpandedEapTypePtrArray disabledEAPTypes; |
|
237 |
|
238 eap_type_value_e tunnelingType(static_cast<eap_type_ietf_values_e>(iUiConn->GetTunnelingType())); |
|
239 eap_type_value_e eapType(static_cast<eap_type_ietf_values_e>(iUiConn->GetEapType())); |
|
240 |
|
241 TRAPD(err, EapTlsPeapUtils::GetTunnelingExpandedEapDataL( |
|
242 iDatabase, |
|
243 0, |
|
244 enabledEAPTypes, |
|
245 disabledEAPTypes, |
|
246 iUiConn->GetIndexType(), |
|
247 iUiConn->GetIndex(), |
|
248 tunnelingType, |
|
249 eapType)); |
|
250 |
|
251 if (err != KErrNone) |
|
252 { |
|
253 enabledEAPTypes.ResetAndDestroy(); |
|
254 disabledEAPTypes.ResetAndDestroy(); |
|
255 |
|
256 EAP_TRACE_DEBUG_SYMBIAN( |
|
257 (_L("CEapTlsPeapUiEapTypes::FetchExpandedDataL: Error from GetTunnelingExpandedEapDataL:%d\n"), |
|
258 err)); |
|
259 |
|
260 User::Leave(err); |
|
261 } |
|
262 |
|
263 EAP_TRACE_DEBUG_SYMBIAN( |
|
264 (_L("CEapTlsPeapUiEapTypes::FetchExpandedDataL: Got tunneling EAPs from DB: enabled=%d,disabled=%d\n"), |
|
265 enabledEAPTypes.Count(), disabledEAPTypes.Count())); |
|
266 |
|
267 TInt i(0); |
|
268 |
|
269 // First fill the enabled EAP types. |
|
270 for (i = 0; i < enabledEAPTypes.Count(); i++) |
|
271 { |
|
272 TEapTlsPeapUiEapType tmpEAP; |
|
273 |
|
274 tmpEAP.iIsEnabled = ETrue; // All EAP types here are enabled. |
|
275 |
|
276 tmpEAP.iEapType.Copy(enabledEAPTypes[i]->iExpandedEAPType); |
|
277 |
|
278 TRAPD(err, iDataPtr->AppendL(tmpEAP)); |
|
279 if (err != KErrNone) |
|
280 { |
|
281 enabledEAPTypes.ResetAndDestroy(); |
|
282 User::Leave(err); |
|
283 } |
|
284 |
|
285 EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::FetchExpandedDataL:Appended ENABLED EAP type:", |
|
286 tmpEAP.iEapType.Ptr(), |
|
287 tmpEAP.iEapType.Size() ) ); |
|
288 } |
|
289 |
|
290 // Now fill the disabled EAP types. |
|
291 for (i = 0; i < disabledEAPTypes.Count(); i++) |
|
292 { |
|
293 TEapTlsPeapUiEapType tmpEAP; |
|
294 |
|
295 tmpEAP.iIsEnabled = EFalse; // All EAP types here are disabled. |
|
296 |
|
297 tmpEAP.iEapType.Copy(disabledEAPTypes[i]->iExpandedEAPType); |
|
298 |
|
299 TRAPD(err, iDataPtr->AppendL(tmpEAP)); |
|
300 if (err != KErrNone) |
|
301 { |
|
302 disabledEAPTypes.ResetAndDestroy(); |
|
303 User::Leave(err); |
|
304 } |
|
305 |
|
306 EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::FetchExpandedDataL:Appended DISABLED EAP type:", |
|
307 tmpEAP.iEapType.Ptr(), |
|
308 tmpEAP.iEapType.Size() ) ); |
|
309 } |
|
310 |
|
311 enabledEAPTypes.ResetAndDestroy(); |
|
312 disabledEAPTypes.ResetAndDestroy(); |
|
313 |
|
314 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::FetchExpandedDataL: End\n"))); |
|
315 } |
|
316 |
|
317 void CEapTlsPeapUiEapTypes::UpdateExpandedDataL() |
|
318 { |
|
319 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::UpdateExpandedDataL: Start\n"))); |
|
320 |
|
321 RExpandedEapTypePtrArray enabledEAPTypes; |
|
322 RExpandedEapTypePtrArray disabledEAPTypes; |
|
323 SExpandedEAPType* expandedEAPTmp; |
|
324 |
|
325 for(TInt i=0 ; i < iDataPtr->Count(); i++) |
|
326 { |
|
327 expandedEAPTmp = new (ELeave) SExpandedEAPType; |
|
328 CleanupStack::PushL(expandedEAPTmp); |
|
329 |
|
330 expandedEAPTmp->iExpandedEAPType.Copy(iDataPtr->At(i).iEapType); |
|
331 |
|
332 if(iDataPtr->At(i).iIsEnabled) |
|
333 { |
|
334 // Enabled |
|
335 TInt error = enabledEAPTypes.Append(expandedEAPTmp); |
|
336 |
|
337 if (error != KErrNone) |
|
338 { |
|
339 enabledEAPTypes.ResetAndDestroy(); |
|
340 disabledEAPTypes.ResetAndDestroy(); |
|
341 User::LeaveIfError(error); |
|
342 } |
|
343 |
|
344 EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::UpdateExpandedDataL:Appended ENABLED EAP type:", |
|
345 expandedEAPTmp->iExpandedEAPType.Ptr(), |
|
346 expandedEAPTmp->iExpandedEAPType.Size() ) ); |
|
347 } |
|
348 else |
|
349 { |
|
350 // Disabled |
|
351 TInt error = disabledEAPTypes.Append(expandedEAPTmp); |
|
352 |
|
353 if (error != KErrNone) |
|
354 { |
|
355 enabledEAPTypes.ResetAndDestroy(); |
|
356 disabledEAPTypes.ResetAndDestroy(); |
|
357 User::LeaveIfError(error); |
|
358 } |
|
359 |
|
360 EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::UpdateExpandedDataL:Appended DISABLED EAP type:", |
|
361 expandedEAPTmp->iExpandedEAPType.Ptr(), |
|
362 expandedEAPTmp->iExpandedEAPType.Size() ) ); |
|
363 } |
|
364 |
|
365 CleanupStack::Pop(expandedEAPTmp); |
|
366 } |
|
367 |
|
368 eap_type_value_e tunnelingType(static_cast<eap_type_ietf_values_e>(iUiConn->GetTunnelingType())); |
|
369 eap_type_value_e eapType(static_cast<eap_type_ietf_values_e>(iUiConn->GetEapType())); |
|
370 |
|
371 TRAPD(err, EapTlsPeapUtils::SetTunnelingExpandedEapDataL( |
|
372 iDatabase, |
|
373 0, |
|
374 enabledEAPTypes, |
|
375 disabledEAPTypes, |
|
376 iUiConn->GetIndexType(), |
|
377 iUiConn->GetIndex(), |
|
378 tunnelingType, |
|
379 eapType)); |
|
380 |
|
381 enabledEAPTypes.ResetAndDestroy(); |
|
382 disabledEAPTypes.ResetAndDestroy(); |
|
383 |
|
384 if (err != KErrNone) |
|
385 { |
|
386 EAP_TRACE_DEBUG_SYMBIAN( |
|
387 (_L("CEapTlsPeapUiEapTypes::UpdateExpandedDataL: Error from SetTunnelingExpandedEapDataL:%d\n"), |
|
388 err)); |
|
389 |
|
390 User::Leave(err); |
|
391 } |
|
392 |
|
393 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::UpdateExpandedDataL: End\n"))); |
|
394 } |
155 |
395 |
156 TRAPD(error,iEapTypeConnection->GetConfigurationL(aSettings)); |
396 #endif // #ifdef USE_EAP_EXPANDED_TYPES |
157 if (error) |
|
158 { |
|
159 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: CEapTlsPeapUiEapTypes::FetchExpandedDataL(): GetConfigurationL() failed %d\n"), error)); |
|
160 User::Leave(error); |
|
161 } |
|
162 |
|
163 TInt i(0); |
|
164 |
|
165 { |
|
166 TEapExpandedType enabledEAPType(*EapExpandedTypeNone.GetType()); |
|
167 |
|
168 if (aSettings.iEnabledEncapsulatedEAPExpandedTypesPresent) |
|
169 { |
|
170 // First fill the enabled EAP types. |
|
171 for (i = 0; i < aSettings.iEnabledEncapsulatedEAPExpandedTypes.Count(); i++) |
|
172 { |
|
173 TEapTlsPeapUiEapType * tmpEAP = new (ELeave) TEapTlsPeapUiEapType; |
|
174 if (tmpEAP == 0) |
|
175 { |
|
176 User::Leave(KErrNoMemory); |
|
177 } |
|
178 |
|
179 tmpEAP->SetIsEnabled(ETrue); // All EAP types here are enabled. |
|
180 |
|
181 tmpEAP->SetEapType(aSettings.iEnabledEncapsulatedEAPExpandedTypes[i]); |
|
182 |
|
183 TRAPD(err, iDataPtr->AppendL(tmpEAP)); |
|
184 if (err != KErrNone) |
|
185 { |
|
186 User::Leave(err); |
|
187 } |
|
188 |
|
189 EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::FetchExpandedDataL(): Appended ENABLED EAP type:", |
|
190 tmpEAP->GetEapType().GetValue().Ptr(), |
|
191 tmpEAP->GetEapType().GetValue().Length() ) ); |
|
192 } |
|
193 } |
|
194 } |
|
195 |
|
196 { |
|
197 TEapExpandedType disabledEAPType(*EapExpandedTypeNone.GetType()); |
|
198 |
|
199 if (aSettings.iDisabledEncapsulatedEAPExpandedTypesPresent) |
|
200 { |
|
201 // Now fill the disabled EAP types. |
|
202 for (i = 0; i < aSettings.iDisabledEncapsulatedEAPExpandedTypes.Count(); i++) |
|
203 { |
|
204 TEapTlsPeapUiEapType * tmpEAP = new (ELeave) TEapTlsPeapUiEapType; |
|
205 if (tmpEAP == 0) |
|
206 { |
|
207 User::Leave(KErrNoMemory); |
|
208 } |
|
209 |
|
210 tmpEAP->SetIsEnabled(EFalse); // All EAP types here are disabled. |
|
211 |
|
212 tmpEAP->SetEapType(aSettings.iDisabledEncapsulatedEAPExpandedTypes[i]); |
|
213 |
|
214 TRAPD(err, iDataPtr->AppendL(tmpEAP)); |
|
215 if (err != KErrNone) |
|
216 { |
|
217 User::Leave(err); |
|
218 } |
|
219 |
|
220 EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::FetchExpandedDataL(): Appended DISABLED EAP type:", |
|
221 tmpEAP->GetEapType().GetValue().Ptr(), |
|
222 tmpEAP->GetEapType().GetValue().Length() ) ); |
|
223 } |
|
224 } |
|
225 } |
|
226 |
|
227 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::FetchExpandedDataL(): End\n"))); |
|
228 } |
|
229 |
|
230 void CEapTlsPeapUiEapTypes::UpdateExpandedDataL() |
|
231 { |
|
232 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::UpdateExpandedDataL(): Start\n"))); |
|
233 |
|
234 if (iDataPtr == 0) |
|
235 { |
|
236 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::UpdateExpandedDataL(): iDataPtr == 0\n"))); |
|
237 User::Leave(KErrArgument); |
|
238 } |
|
239 |
|
240 EAPSettings aSettings; |
|
241 |
|
242 for(TInt i=0 ; i < iDataPtr->Count(); i++) |
|
243 { |
|
244 if ((*iDataPtr)[i] != 0) |
|
245 { |
|
246 TEapExpandedType expandedEAPTmp = (*iDataPtr)[i]->GetEapType(); |
|
247 |
|
248 if((*iDataPtr)[i]->GetIsEnabled()) |
|
249 { |
|
250 // Enabled |
|
251 TInt error = aSettings.iEnabledEncapsulatedEAPExpandedTypes.Append(expandedEAPTmp); |
|
252 |
|
253 if (error != KErrNone) |
|
254 { |
|
255 User::LeaveIfError(error); |
|
256 } |
|
257 |
|
258 aSettings.iEnabledEncapsulatedEAPExpandedTypesPresent = ETrue; |
|
259 |
|
260 EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::UpdateExpandedDataL(): Appended ENABLED EAP type:", |
|
261 expandedEAPTmp.GetValue().Ptr(), |
|
262 expandedEAPTmp.GetValue().Size() ) ); |
|
263 } |
|
264 else |
|
265 { |
|
266 // Disabled |
|
267 TInt error = aSettings.iDisabledEncapsulatedEAPExpandedTypes.Append(expandedEAPTmp); |
|
268 |
|
269 if (error != KErrNone) |
|
270 { |
|
271 User::LeaveIfError(error); |
|
272 } |
|
273 |
|
274 aSettings.iDisabledEncapsulatedEAPExpandedTypesPresent = ETrue; |
|
275 |
|
276 EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::UpdateExpandedDataL(): Appended DISABLED EAP type:", |
|
277 expandedEAPTmp.GetValue().Ptr(), |
|
278 expandedEAPTmp.GetValue().Size() ) ); |
|
279 } |
|
280 } |
|
281 } // for() |
|
282 |
|
283 TRAPD(error,iEapTypeConnection->SetConfigurationL(aSettings)); |
|
284 |
|
285 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::UpdateExpandedDataL(): error = %d\n"),error)); |
|
286 |
|
287 User::LeaveIfError(error); |
|
288 |
|
289 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::UpdateExpandedDataL(): End\n"))); |
|
290 } |
|
291 |
397 |
292 // End of file |
398 // End of file |