1 /* |
|
2 * Copyright (c) 2001-2006 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 the License "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: EAP and WLAN authentication protocols. |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 14.1.3.1.2 % |
|
20 */ |
|
21 |
|
22 // This is enumeration of EAPOL source code. |
|
23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
24 #undef EAP_FILE_NUMBER_ENUM |
|
25 #define EAP_FILE_NUMBER_ENUM 215 |
|
26 #undef EAP_FILE_NUMBER_DATE |
|
27 #define EAP_FILE_NUMBER_DATE 1127594498 |
|
28 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
29 |
|
30 #include <e32base.h> |
|
31 #include "EapSimDbUtils.h" |
|
32 #include "EapSimDbParameterNames.h" |
|
33 #include "EapSimDbDefaults.h" |
|
34 #include <EapSimUiConnection.h> |
|
35 #include <EapSimUiDataConnection.h> |
|
36 #include <EapSimUiSimData.h> |
|
37 #include "eap_am_trace_symbian.h" |
|
38 |
|
39 const TUint KMaxSqlQueryLength = 256; |
|
40 |
|
41 CEapSimUiDataConnection::CEapSimUiDataConnection(CEapSimUiConnection * aUiConn) |
|
42 : iIsOpened(EFalse) |
|
43 , iUiConn(aUiConn) |
|
44 , iColSet(NULL) |
|
45 , iDataPtr(NULL) |
|
46 { |
|
47 } |
|
48 |
|
49 |
|
50 CEapSimUiDataConnection::~CEapSimUiDataConnection() |
|
51 { |
|
52 if (iUiConn) |
|
53 { |
|
54 Close(); |
|
55 iUiConn = NULL; |
|
56 } |
|
57 } |
|
58 |
|
59 |
|
60 TInt CEapSimUiDataConnection::Open() |
|
61 { |
|
62 if (iIsOpened) |
|
63 { |
|
64 return KErrAlreadyExists; |
|
65 } |
|
66 |
|
67 TInt err = iUiConn->GetDatabase(iDatabase); |
|
68 if (err != KErrNone) |
|
69 { |
|
70 return err; |
|
71 } |
|
72 |
|
73 iIsOpened = ETrue; |
|
74 return KErrNone; |
|
75 } |
|
76 |
|
77 |
|
78 TInt CEapSimUiDataConnection::GetData(CEapSimUiSimData ** aDataPtr) |
|
79 { |
|
80 if (aDataPtr == NULL) |
|
81 { |
|
82 return KErrArgument; |
|
83 } |
|
84 if (iIsOpened == EFalse) |
|
85 { |
|
86 return KErrSessionClosed; |
|
87 } |
|
88 iDataPtr = new CEapSimUiSimData(); |
|
89 if (!iDataPtr) |
|
90 { |
|
91 return KErrNoMemory; |
|
92 } |
|
93 |
|
94 TRAPD(err, FetchDataL()); |
|
95 if (err != KErrNone) |
|
96 { |
|
97 delete iDataPtr; |
|
98 iDataPtr = NULL; |
|
99 |
|
100 delete iColSet; |
|
101 iColSet = NULL; |
|
102 |
|
103 iView.Close(); |
|
104 |
|
105 return err; |
|
106 } |
|
107 |
|
108 *aDataPtr = iDataPtr; |
|
109 |
|
110 return KErrNone; |
|
111 } |
|
112 |
|
113 |
|
114 TInt CEapSimUiDataConnection::Update() |
|
115 { |
|
116 TRAPD(err, iView.UpdateL()); |
|
117 if (err != KErrNone) |
|
118 { |
|
119 return err; |
|
120 } |
|
121 |
|
122 // Check if length of username and realm are less than the max length possible in DB. |
|
123 if(iDataPtr->GetManualUsername().Length() > KMaxManualUsernameLengthInDB |
|
124 || iDataPtr->GetManualRealm().Length() > KMaxManualRealmLengthInDB) |
|
125 { |
|
126 // Username or realm too long. Can not be stored in DB. |
|
127 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapSimUiDataConnection::Update: Too long username or realm. Length: UN=%d, Realm=%d\n"), |
|
128 iDataPtr->GetManualUsername().Length(), |
|
129 iDataPtr->GetManualRealm().Length())); |
|
130 |
|
131 return KErrArgument; |
|
132 } |
|
133 |
|
134 TRAP(err, iView.SetColL(iColSet->ColNo(cf_str_EAP_GSMSIM_manual_username_literal), iDataPtr->GetManualUsername())); |
|
135 if (err != KErrNone) |
|
136 { |
|
137 return err; |
|
138 } |
|
139 |
|
140 TRAP(err, iView.SetColL(iColSet->ColNo(cf_str_EAP_GSMSIM_manual_realm_literal), iDataPtr->GetManualRealm())); |
|
141 if (err != KErrNone) |
|
142 { |
|
143 return err; |
|
144 } |
|
145 |
|
146 if (*(iDataPtr->GetUseManualUsername())) |
|
147 { |
|
148 TRAP(err, iView.SetColL(iColSet->ColNo(cf_str_EAP_GSMSIM_use_manual_username_literal), EGSMSIMUseManualUsernameYes)); |
|
149 if (err != KErrNone) |
|
150 { |
|
151 return err; |
|
152 } |
|
153 } |
|
154 else |
|
155 { |
|
156 TRAP(err, iView.SetColL(iColSet->ColNo(cf_str_EAP_GSMSIM_use_manual_username_literal), EGSMSIMUseManualUsernameNo)); |
|
157 if (err != KErrNone) |
|
158 { |
|
159 return err; |
|
160 } |
|
161 } |
|
162 |
|
163 if (*(iDataPtr->GetUseManualRealm())) |
|
164 { |
|
165 TRAP(err, iView.SetColL(iColSet->ColNo(cf_str_EAP_GSMSIM_use_manual_realm_literal), EGSMSIMUseManualRealmYes)); |
|
166 if (err != KErrNone) |
|
167 { |
|
168 return err; |
|
169 } |
|
170 } |
|
171 else |
|
172 { |
|
173 TRAP(err, iView.SetColL(iColSet->ColNo(cf_str_EAP_GSMSIM_use_manual_realm_literal), EGSMSIMUseManualRealmNo)); |
|
174 if (err != KErrNone) |
|
175 { |
|
176 return err; |
|
177 } |
|
178 } |
|
179 |
|
180 // Last full authentication time should be made zero when EAP configurations are modified. |
|
181 // This makes sure that the next authentication with this EAP would be full authentication |
|
182 // instead of reauthentication even if the session is still valid. |
|
183 |
|
184 TRAP(err, iView.SetColL(iColSet->ColNo(KGSMSIMLastFullAuthTime), default_FullAuthTime)); |
|
185 if (err != KErrNone) |
|
186 { |
|
187 return err; |
|
188 } |
|
189 |
|
190 EAP_TRACE_DEBUG_SYMBIAN((_L("Session Validity: Resetting Full Auth Time since EAP-SIM settings are modified\n"))); |
|
191 |
|
192 TRAP(err, iView.PutL()); |
|
193 |
|
194 return err; |
|
195 } |
|
196 |
|
197 |
|
198 TInt CEapSimUiDataConnection::Close() |
|
199 { |
|
200 if (iIsOpened == EFalse) |
|
201 { |
|
202 return KErrNone; |
|
203 } |
|
204 |
|
205 delete iDataPtr; |
|
206 iDataPtr = NULL; |
|
207 |
|
208 delete iColSet; |
|
209 iColSet = NULL; |
|
210 |
|
211 iView.Close(); |
|
212 |
|
213 iUiConn = NULL; |
|
214 return KErrNone; |
|
215 } |
|
216 |
|
217 |
|
218 void CEapSimUiDataConnection::FetchDataL() |
|
219 { |
|
220 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
|
221 TPtr sqlStatement = buf->Des(); |
|
222 |
|
223 // Form the query. Query everything. |
|
224 _LIT(KSQLQuery, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
|
225 sqlStatement.Format(KSQLQuery, |
|
226 &KSimTableName, |
|
227 &KServiceType, |
|
228 iUiConn->GetIndexType(), |
|
229 &KServiceIndex, |
|
230 iUiConn->GetIndex(), |
|
231 &KTunnelingType, |
|
232 iUiConn->GetTunnelingType()); |
|
233 // Evaluate view |
|
234 User::LeaveIfError(iView.Prepare(iDatabase, TDbQuery(sqlStatement))); |
|
235 User::LeaveIfError(iView.EvaluateAll()); |
|
236 // Get the first (and only) row |
|
237 iView.FirstL(); |
|
238 iView.GetL(); |
|
239 // Get column set so we get the correct column numbers |
|
240 delete iColSet; |
|
241 iColSet = NULL; |
|
242 iColSet = iView.ColSetL(); |
|
243 |
|
244 // Start fetching the values |
|
245 |
|
246 // use manual username |
|
247 TUint intValue = iView.ColUint(iColSet->ColNo(cf_str_EAP_GSMSIM_use_manual_username_literal)); |
|
248 if (intValue == 0) |
|
249 { |
|
250 *(iDataPtr->GetUseManualUsername()) = EFalse; |
|
251 } |
|
252 else |
|
253 { |
|
254 *(iDataPtr->GetUseManualUsername()) = ETrue; |
|
255 } |
|
256 |
|
257 // use manual realm |
|
258 intValue = iView.ColUint(iColSet->ColNo(cf_str_EAP_GSMSIM_use_manual_realm_literal)); |
|
259 if (intValue == 0) |
|
260 { |
|
261 *(iDataPtr->GetUseManualRealm()) = EFalse; |
|
262 } |
|
263 else |
|
264 { |
|
265 *(iDataPtr->GetUseManualRealm()) = ETrue; |
|
266 } |
|
267 |
|
268 // manual username |
|
269 iDataPtr->GetManualUsername().Copy(iView.ColDes16(iColSet->ColNo(cf_str_EAP_GSMSIM_manual_username_literal))); |
|
270 |
|
271 // manual realm |
|
272 iDataPtr->GetManualRealm().Copy(iView.ColDes16(iColSet->ColNo(cf_str_EAP_GSMSIM_manual_realm_literal))); |
|
273 |
|
274 CleanupStack::PopAndDestroy(buf); |
|
275 } |
|
276 |
|
277 // End of file |
|