31 // INCLUDES |
31 // INCLUDES |
32 #include "EapSimDbUtils.h" |
32 #include "EapSimDbUtils.h" |
33 #include "EapSimDbDefaults.h" |
33 #include "EapSimDbDefaults.h" |
34 #include "EapSimDbParameterNames.h" |
34 #include "EapSimDbParameterNames.h" |
35 |
35 |
36 #include <EapTraceSymbian.h> |
36 #include "eap_am_trace_symbian.h" |
37 #include "EapPluginTools.h" |
|
38 |
37 |
39 const TInt KMaxSqlQueryLength = 2048; |
38 const TInt KMaxSqlQueryLength = 2048; |
40 const TInt KMicroSecsInAMinute = 60000000; // 60000000 micro seconds is 1 minute. |
39 const TInt KMicroSecsInAMinute = 60000000; // 60000000 micro seconds is 1 minute. |
41 |
40 |
42 // ================= MEMBER FUNCTIONS ======================= |
41 // ================= MEMBER FUNCTIONS ======================= |
43 |
42 |
44 void EapSimDbUtils::OpenDatabaseL( |
43 void EapSimDbUtils::OpenDatabaseL(RDbNamedDatabase& aDatabase, RDbs& aSession, const TIndexType aIndexType, |
45 RDbNamedDatabase& aDatabase, |
44 const TInt aIndex, const eap_type_value_e aTunnelingType) |
46 RFs& aFileServerSession, |
|
47 const TIndexType aIndexType, |
|
48 const TInt aIndex, |
|
49 const eap_type_value_e aTunnelingType) |
|
50 { |
45 { |
51 EAP_TRACE_DEBUG_SYMBIAN( |
46 #ifdef USE_EAP_EXPANDED_TYPES |
52 (_L("EapSimDbUtils::OpenDatabaseL(): Start - aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x\n"), |
47 |
53 aIndexType, |
48 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
54 aIndex, |
49 |
55 aTunnelingType.get_vendor_id(), |
50 #else |
56 aTunnelingType.get_vendor_type())); |
51 |
57 |
52 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
58 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapSimDbUtils::OpenDatabaseL()\n")); |
53 |
|
54 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
55 |
|
56 EAP_TRACE_DEBUG_SYMBIAN((_L("EapSimDbUtils::OpenDatabaseL -Start- aIndexType=%d, aIndex=%d, aTunnelingVendorType=%d \n"), |
|
57 aIndexType,aIndex,aTunnelingVendorType) ); |
59 |
58 |
60 // 1. Open/create a database |
59 // 1. Open/create a database |
61 |
60 |
62 TInt error(KErrNone); |
61 // Connect to the DBMS server. |
63 TFileName aPrivateDatabasePathName; |
62 User::LeaveIfError(aSession.Connect()); |
64 |
63 CleanupClosePushL(aSession); |
65 EapPluginTools::CreateDatabaseLC( |
64 // aSession and aDatabase are pushed to the cleanup stack even though they may be member |
66 aDatabase, |
65 // variables of the calling class and would be closed in the destructor anyway. This ensures |
67 aFileServerSession, |
66 // that if they are not member variables they will be closed. Closing the handle twice |
68 error, |
67 // does no harm. |
69 KEapSimDatabaseName, |
68 |
70 aPrivateDatabasePathName); |
69 #ifdef SYMBIAN_SECURE_DBMS |
71 |
70 |
72 if(error == KErrNone) |
71 // Create the secure shared database with the specified secure policy. |
|
72 // Database will be created in the data caging path for DBMS (C:\private\100012a5). |
|
73 |
|
74 TInt err = aDatabase.Create(aSession, KDatabaseName, KSecureUIDFormat); |
|
75 |
|
76 EAP_TRACE_DEBUG_SYMBIAN((_L("EapSimDbUtils::OpenDatabaseL - Created Secure DB for eapsim.dat. err=%d\n"), err)); |
|
77 |
|
78 |
|
79 if(err == KErrNone) |
73 { |
80 { |
74 aDatabase.Close(); |
81 aDatabase.Close(); |
75 } |
82 |
76 else if (error != KErrAlreadyExists) |
83 } else if (err != KErrAlreadyExists) |
77 { |
84 { |
78 User::LeaveIfError(error); |
85 User::LeaveIfError(err); |
79 } |
86 } |
80 |
87 |
81 EAP_TRACE_DEBUG_SYMBIAN((_L("EapSimDbUtils::OpenDatabaseL(): calls aDatabase.Open()\n"))); |
88 User::LeaveIfError(aDatabase.Open(aSession, KDatabaseName, KSecureUIDFormat)); |
82 |
89 CleanupClosePushL(aDatabase); |
83 error = aDatabase.Open(aFileServerSession, aPrivateDatabasePathName); |
90 |
84 |
91 #else |
85 EAP_TRACE_DEBUG_SYMBIAN((_L("EapSimDbUtils::OpenDatabaseL(): Opened private DB for EAP-SIM. error=%d\n"), error)); |
92 // Non secured database. The database will be created in the old location (c:\system\data). |
86 |
93 |
87 User::LeaveIfError(error); |
94 RFs fsSession; |
|
95 User::LeaveIfError(fsSession.Connect()); |
|
96 CleanupClosePushL(fsSession); |
|
97 TInt err = aDatabase.Create(fsSession, KDatabaseName); |
|
98 |
|
99 EAP_TRACE_DEBUG_SYMBIAN((_L("EapSimDbUtils::OpenDatabaseL - Created Non-Secure DB for eapsim.dat. err=%d\n"), err)); |
|
100 |
|
101 |
|
102 if(err == KErrNone) |
|
103 { |
|
104 aDatabase.Close(); |
|
105 |
|
106 } else if (err != KErrAlreadyExists) |
|
107 { |
|
108 User::LeaveIfError(err); |
|
109 } |
|
110 CleanupStack::PopAndDestroy( &fsSession ); // close fsSession |
|
111 |
|
112 User::LeaveIfError(aDatabase.Open(aSession, KDatabaseName)); |
|
113 CleanupClosePushL(aDatabase); |
|
114 |
|
115 #endif // #ifdef SYMBIAN_SECURE_DBMS |
88 |
116 |
89 // 2. Create the eapsim table to database (ignore error if exists) |
117 // 2. Create the eapsim table to database (ignore error if exists) |
90 |
118 |
91 // Table columns: |
119 // Table columns: |
92 //// NAME ///////////////////////////////////////////////// TYPE ////////////// Constant ///////// |
120 //// NAME ///////////////////////////////////////////////// TYPE ////////////// Constant ///////// |
93 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
121 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
94 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
122 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
95 //| TunnelingTypeVendorId | UNSIGNED INTEGER | KTunnelingTypeVendorId |// |
123 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
96 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
124 //| EAP_GSMSIM_use_manual_realm | UNSIGNED INTEGER | cf_str_EAP_GSMSIM_use_manual_realm_literal |// |
97 //| EAP_GSMSIM_use_manual_realm | UNSIGNED INTEGER | cf_str_EAP_GSMSIM_use_manual_realm_literal |// |
125 //| EAP_GSMSIM_manual_realm | VARCHAR(255) | cf_str_EAP_GSMSIM_manual_realm_literal |// |
98 //| EAP_GSMSIM_manual_realm | VARCHAR(255) | cf_str_EAP_GSMSIM_manual_realm_literal |// |
126 //| EAP_GSMSIM_use_manual_username | UNSIGNED INTEGER | cf_str_EAP_GSMSIM_use_manual_username_literal|// |
99 //| EAP_GSMSIM_use_manual_username | UNSIGNED INTEGER | cf_str_EAP_GSMSIM_use_manual_username_literal|// |
127 //| EAP_GSMSIM_manual_username | VARCHAR(255) | cf_str_EAP_GSMSIM_manual_username_literal |// |
100 //| EAP_GSMSIM_manual_username | VARCHAR(255) | cf_str_EAP_GSMSIM_manual_username_literal |// |
128 //| PseudonymId | LONG VARBINARY | KPseudonymId |// |
101 //| PseudonymId | LONG VARBINARY | KPseudonymId |// |
129 //| XKEY | BINARY(20) | KXKey |// |
102 //| XKEY | BINARY(20) | KXKey |// |
130 //| K_aut | BINARY(16) | KK_aut |// |
103 //| K_aut | BINARY(16) | KK_aut |// |
131 //| K_encr | BINARY(16) | KK_encr |// |
104 //| K_encr | BINARY(16) | KK_encr |// |
132 //| ReauthCounter | UNSIGNED INTEGER | KReauthCounter |// |
105 //| ReauthCounter | UNSIGNED INTEGER | KReauthCounter |// |
133 //| ReauthId | LONG VARBINARY | KReauthId |// |
106 //| ReauthId | LONG VARBINARY | KReauthId |// |
134 //| PreviousIMSI | VARBINARY(15) | KPreviousIMSI |// |
107 //| PreviousIMSI | VARBINARY(15) | KPreviousIMSI |// |
135 //| EAP_GSMSIM_use_pseudonym_identity | UNSIGNED INTEGER | cf_str_EAP_GSMSIM_use_pseudonym_identity_literal |// |
108 //| EAP_GSMSIM_use_pseudonym_identity | UNSIGNED INTEGER | cf_str_EAP_GSMSIM_use_pseudonym_identity_literal |// |
136 //| EAP_GSMSIM_max_session_validity_time | BIGINT | cf_str_EAP_GSMSIM_max_session_validity_time_literal |// |
109 //| EAP_GSMSIM_max_session_validity_time | BIGINT | cf_str_EAP_GSMSIM_max_session_validity_time_literal |// |
137 //| EAP_GSMSIM_last_full_authentication_time | BIGINT | KGSMSIMLastFullAuthTime |// |
110 //| EAP_GSMSIM_last_full_authentication_time | BIGINT | KGSMSIMLastFullAuthTime |// |
138 ////////////////////////////////////////////////////////////////////////////////////////////////// |
111 ////////////////////////////////////////////////////////////////////////////////////////////////// |
|
112 |
139 |
113 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
140 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
114 TPtr sqlStatement = buf->Des(); |
141 TPtr sqlStatement = buf->Des(); |
115 |
142 |
116 _LIT(KSQLCreateTable, "CREATE TABLE %S \ |
143 _LIT(KSQLCreateTable, "CREATE TABLE %S (%S UNSIGNED INTEGER, \ |
117 (%S UNSIGNED INTEGER, \ |
144 %S UNSIGNED INTEGER, \ |
118 %S UNSIGNED INTEGER, \ |
145 %S UNSIGNED INTEGER, \ |
119 %S UNSIGNED INTEGER, \ |
146 %S UNSIGNED INTEGER, \ |
120 %S UNSIGNED INTEGER, \ |
147 %S VARCHAR(%d), \ |
121 %S UNSIGNED INTEGER, \ |
148 %S UNSIGNED INTEGER, \ |
122 %S VARCHAR(%d), \ |
149 %S VARCHAR(%d), \ |
123 %S UNSIGNED INTEGER, \ |
150 %S LONG VARBINARY, \ |
124 %S VARCHAR(%d), \ |
151 %S BINARY(%d), \ |
125 %S LONG VARBINARY, \ |
152 %S BINARY(%d), \ |
126 %S BINARY(%d), \ |
153 %S BINARY(%d), \ |
127 %S BINARY(%d), \ |
154 %S UNSIGNED INTEGER, \ |
128 %S BINARY(%d), \ |
155 %S LONG VARBINARY, \ |
129 %S UNSIGNED INTEGER, \ |
156 %S VARBINARY(%d), \ |
130 %S LONG VARBINARY, \ |
157 %S UNSIGNED INTEGER, \ |
131 %S VARBINARY(%d), \ |
158 %S BIGINT, \ |
132 %S UNSIGNED INTEGER, \ |
159 %S BIGINT)"); |
133 %S BIGINT, \ |
|
134 %S BIGINT)"); |
|
135 |
160 |
136 sqlStatement.Format(KSQLCreateTable, |
161 sqlStatement.Format(KSQLCreateTable, &KSimTableName, &KServiceType, |
137 &KSimTableName, |
162 &KServiceIndex, |
138 &KServiceType, |
163 &KTunnelingType, |
139 &KServiceIndex, |
164 &cf_str_EAP_GSMSIM_use_manual_realm_literal, |
140 &KTunnelingTypeVendorId, |
165 &cf_str_EAP_GSMSIM_manual_realm_literal, KMaxManualRealmLengthInDB, |
141 &KTunnelingType, |
166 &cf_str_EAP_GSMSIM_use_manual_username_literal, |
142 &cf_str_EAP_GSMSIM_use_manual_realm_literal, |
167 &cf_str_EAP_GSMSIM_manual_username_literal, KMaxManualUsernameLengthInDB, |
143 &cf_str_EAP_GSMSIM_manual_realm_literal, KMaxRealmLengthInDB, |
168 &KPseudonymId, |
144 &cf_str_EAP_GSMSIM_use_manual_username_literal, |
169 &KXKey, KMaxXKeyLengthInDB, |
145 &cf_str_EAP_GSMSIM_manual_username_literal, KMaxUsernameLengthInDB, |
170 &KK_aut, KMaxK_autLengthInDB, |
146 &KPseudonymId, |
171 &KK_encr, KMaxK_encrLengthInDB, |
147 &KXKey, KMaxXKeyLengthInDB, |
172 &KReauthCounter, |
148 &KK_aut, KMaxK_autLengthInDB, |
173 &KReauthId, |
149 &KK_encr, KMaxK_encrLengthInDB, |
174 &KPreviousIMSI, KMaxIMSILengthInDB, |
150 &KReauthCounter, |
175 &cf_str_EAP_GSMSIM_use_pseudonym_identity_literal, |
151 &KReauthId, |
176 &cf_str_EAP_GSMSIM_max_session_validity_time_literal, |
152 &KPreviousIMSI, KMaxIMSILengthInDB, |
177 &KGSMSIMLastFullAuthTime); |
153 &cf_str_EAP_GSMSIM_use_pseudonym_identity_literal, |
|
154 &cf_str_EAP_GSMSIM_max_session_validity_time_literal, |
|
155 &KGSMSIMLastFullAuthTime); |
|
156 |
178 |
157 error = aDatabase.Execute(sqlStatement); |
179 err = aDatabase.Execute(sqlStatement); |
158 if (error != KErrNone && error != KErrAlreadyExists) |
180 if (err != KErrNone && err != KErrAlreadyExists) |
159 { |
181 { |
160 User::Leave(error); |
182 User::Leave(err); |
161 } |
183 } |
162 |
184 |
163 // 4. Check if database table contains a row for this service type and id |
185 // 4. Check if database table contains a row for this service type and id |
164 |
186 |
165 _LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
187 _LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
166 |
188 sqlStatement.Format(KSQLQueryRow, &cf_str_EAP_GSMSIM_manual_realm_literal, &KSimTableName, |
167 sqlStatement.Format(KSQLQueryRow, |
189 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
168 &cf_str_EAP_GSMSIM_manual_realm_literal, |
190 |
169 &KSimTableName, |
|
170 &KServiceType, |
|
171 aIndexType, |
|
172 &KServiceIndex, |
|
173 aIndex, |
|
174 &KTunnelingTypeVendorId, |
|
175 aTunnelingType.get_vendor_id(), |
|
176 &KTunnelingType, |
|
177 aTunnelingType.get_vendor_type()); |
|
178 |
|
179 RDbView view; |
191 RDbView view; |
180 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
192 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
181 // View must be closed when no longer needed |
193 // View must be closed when no longer needed |
182 CleanupClosePushL(view); |
194 CleanupClosePushL(view); |
183 |
195 |
200 CleanupStack::PushL(colSet); |
212 CleanupStack::PushL(colSet); |
201 |
213 |
202 view.InsertL(); |
214 view.InsertL(); |
203 view.SetColL(colSet->ColNo(KServiceType), static_cast<TInt>(aIndexType)); |
215 view.SetColL(colSet->ColNo(KServiceType), static_cast<TInt>(aIndexType)); |
204 view.SetColL(colSet->ColNo(KServiceIndex), aIndex); |
216 view.SetColL(colSet->ColNo(KServiceIndex), aIndex); |
205 view.SetColL(colSet->ColNo(KTunnelingTypeVendorId), aTunnelingType.get_vendor_id()); |
217 view.SetColL(colSet->ColNo(KTunnelingType), aTunnelingVendorType); |
206 view.SetColL(colSet->ColNo(KTunnelingType), aTunnelingType.get_vendor_type()); |
|
207 |
218 |
208 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_use_manual_realm_literal), default_EAP_GSMSIM_use_manual_realm); |
219 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_use_manual_realm_literal), default_EAP_GSMSIM_use_manual_realm); |
209 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_manual_realm_literal), default_EAP_realm); |
220 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_manual_realm_literal), default_EAP_GSMSIM_manual_realm); |
210 |
221 |
211 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_use_manual_username_literal), default_EAP_GSMSIM_use_manual_username); |
222 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_use_manual_username_literal), default_EAP_GSMSIM_use_manual_username); |
212 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_manual_username_literal), default_EAP_username); |
223 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_manual_username_literal), default_EAP_GSMSIM_manual_username); |
213 |
224 |
214 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_use_pseudonym_identity_literal), default_EAP_GSMSIM_use_pseudonym_identity); |
225 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_use_pseudonym_identity_literal), default_EAP_GSMSIM_use_pseudonym_identity); |
215 |
226 |
216 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_max_session_validity_time_literal), default_MaxSessionTime); |
227 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_max_session_validity_time_literal), default_MaxSessionTime); |
217 |
228 |
218 view.SetColL(colSet->ColNo(KGSMSIMLastFullAuthTime), default_FullAuthTime); |
229 view.SetColL(colSet->ColNo(KGSMSIMLastFullAuthTime), default_FullAuthTime); |
219 |
230 |
220 view.PutL(); |
231 view.PutL(); |
221 |
232 |
222 CleanupStack::PopAndDestroy( colSet ); |
233 CleanupStack::PopAndDestroy( colSet ); // Delete colSet. |
223 |
234 |
224 CleanupStack::PopAndDestroy( &view ); |
235 CleanupStack::PopAndDestroy( &view ); // Close view. |
225 } |
236 } |
|
237 |
|
238 CleanupStack::PopAndDestroy( buf ); // Delete buf |
|
239 CleanupStack::Pop( &aDatabase ); |
|
240 CleanupStack::Pop( &aSession ); |
226 |
241 |
227 aDatabase.Compact(); |
242 aDatabase.Compact(); |
228 |
|
229 CleanupStack::PopAndDestroy( buf ); |
|
230 CleanupStack::Pop( &aDatabase ); |
|
231 CleanupStack::Pop( &aFileServerSession ); |
|
232 } |
243 } |
233 |
|
234 // ---------------------------------------------------------- |
|
235 |
244 |
236 void EapSimDbUtils::SetIndexL( |
245 void EapSimDbUtils::SetIndexL( |
237 RDbNamedDatabase& aDatabase, |
246 RDbNamedDatabase& aDatabase, |
238 const TIndexType aIndexType, |
247 const TIndexType aIndexType, |
239 const TInt aIndex, |
248 const TInt aIndex, |
240 const eap_type_value_e aTunnelingType, |
249 const eap_type_value_e aTunnelingType, |
241 const TIndexType aNewIndexType, |
250 const TIndexType aNewIndexType, |
242 const TInt aNewIndex, |
251 const TInt aNewIndex, |
243 const eap_type_value_e aNewTunnelingType) |
252 const eap_type_value_e aNewTunnelingType) |
244 { |
253 { |
245 EAP_TRACE_DEBUG_SYMBIAN( |
254 #ifdef USE_EAP_EXPANDED_TYPES |
246 (_L("EapSimDbUtils::SetIndexL(): -Start- aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x\n"), |
255 |
247 aIndexType, |
256 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
248 aIndex, |
257 TUint aNewTunnelingVendorType = aNewTunnelingType.get_vendor_type(); |
249 aTunnelingType.get_vendor_id(), |
258 |
250 aTunnelingType.get_vendor_type())); |
259 #else |
251 |
260 |
252 EAP_TRACE_DEBUG_SYMBIAN( |
261 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
253 (_L("EapSimDbUtils::SetIndexL(): -Start- aNewIndexType=%d, aNewIndex=%d, aNewTunnelingType=0xfe%06x%08x\n"), |
262 TUint aNewTunnelingVendorType = static_cast<TUint>(aNewTunnelingType); |
254 aNewIndexType, |
263 |
255 aNewIndex, |
264 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
256 aNewTunnelingType.get_vendor_id(), |
|
257 aNewTunnelingType.get_vendor_type())); |
|
258 |
|
259 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapSimDbUtils::SetIndexL()\n")); |
|
260 |
265 |
261 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
266 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
262 TPtr sqlStatement = buf->Des(); |
267 TPtr sqlStatement = buf->Des(); |
263 |
268 |
264 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
269 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
265 |
270 |
266 sqlStatement.Format(KSQL, |
271 sqlStatement.Format(KSQL, &KSimTableName, |
267 &KSimTableName, |
272 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
268 &KServiceType, |
|
269 aIndexType, |
|
270 &KServiceIndex, |
|
271 aIndex, |
|
272 &KTunnelingTypeVendorId, |
|
273 aTunnelingType.get_vendor_id(), |
|
274 &KTunnelingType, |
|
275 aTunnelingType.get_vendor_type()); |
|
276 |
273 |
277 RDbView view; |
274 RDbView view; |
278 |
275 |
279 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
276 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
280 |
277 |
299 CleanupStack::PushL(colSet); |
296 CleanupStack::PushL(colSet); |
300 |
297 |
301 view.UpdateL(); |
298 view.UpdateL(); |
302 |
299 |
303 view.SetColL(colSet->ColNo(KServiceType), static_cast<TUint>(aNewIndexType)); |
300 view.SetColL(colSet->ColNo(KServiceType), static_cast<TUint>(aNewIndexType)); |
|
301 |
304 view.SetColL(colSet->ColNo(KServiceIndex), aNewIndex); |
302 view.SetColL(colSet->ColNo(KServiceIndex), aNewIndex); |
305 view.SetColL(colSet->ColNo(KTunnelingTypeVendorId), aNewTunnelingType.get_vendor_id()); |
303 |
306 view.SetColL(colSet->ColNo(KTunnelingType), aNewTunnelingType.get_vendor_type()); |
304 view.SetColL(colSet->ColNo(KTunnelingType), aNewTunnelingVendorType); |
307 |
305 |
308 view.PutL(); |
306 view.PutL(); |
309 |
307 |
310 CleanupStack::PopAndDestroy(colSet); |
308 CleanupStack::PopAndDestroy(3); // view, colset, buf |
311 CleanupStack::PopAndDestroy(&view); |
|
312 CleanupStack::PopAndDestroy(buf); |
|
313 } |
309 } |
314 |
|
315 // ---------------------------------------------------------- |
|
316 |
310 |
317 void EapSimDbUtils::SetConfigurationL( |
311 void EapSimDbUtils::SetConfigurationL( |
318 RDbNamedDatabase& aDatabase, |
312 RDbNamedDatabase& aDatabase, |
319 const EAPSettings& aSettings, |
313 const EAPSettings& aSettings, |
320 const TIndexType aIndexType, |
314 const TIndexType aIndexType, |
321 const TInt aIndex, |
315 const TInt aIndex, |
322 const eap_type_value_e aTunnelingType) |
316 const eap_type_value_e aTunnelingType) |
323 { |
317 { |
324 EAP_TRACE_DEBUG_SYMBIAN( |
318 #ifdef USE_EAP_EXPANDED_TYPES |
325 (_L("EapSimDbUtils::SetConfigurationL(): -Start- aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x\n"), |
319 |
326 aIndexType, |
320 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
327 aIndex, |
321 |
328 aTunnelingType.get_vendor_id(), |
322 #else |
329 aTunnelingType.get_vendor_type())); |
323 |
330 |
324 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
331 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapSimDbUtils::SetConfigurationL()\n")); |
325 |
332 |
326 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
333 EAP_TRACE_DEBUG_SYMBIAN((_L("*************************** SetConfigurationL(): Set the below values: ***************************\n")) ); |
327 |
334 |
328 EAP_TRACE_DEBUG_SYMBIAN((_L("EapSimDbUtils::SetConfigurationL -Start- aIndexType=%d, aIndex=%d, aTunnelingVendorType=%d\n"), |
335 EAP_TRACE_SETTINGS(&aSettings); |
329 aIndexType,aIndex, aTunnelingVendorType)); |
336 |
330 |
337 EAP_TRACE_DEBUG_SYMBIAN((_L("*************************** SetConfigurationL(): Set the above values: ***************************\n")) ); |
331 EAP_TRACE_DEBUG_SYMBIAN((_L("*************************** SetConfigurationL - Set the below values: ***************************\n")) ); |
|
332 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - Set these values for EAPType=%d"),aSettings.iEAPType) ); |
|
333 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, Username=%S"),aSettings.iUsernamePresent, &(aSettings.iUsername)) ); |
|
334 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, Password=%S"),aSettings.iPasswordPresent, &(aSettings.iPassword)) ); |
|
335 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, Realm=%S"),aSettings.iRealmPresent, &(aSettings.iRealm)) ); |
|
336 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, UsePseudonyms=%d"),aSettings.iUsePseudonymsPresent, aSettings.iUsePseudonyms) ); |
|
337 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, VerifyServerRealm=%d"), |
|
338 aSettings.iVerifyServerRealmPresent, aSettings.iVerifyServerRealm) ); |
|
339 |
|
340 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, RequireClientAuthentication=%d"), |
|
341 aSettings.iRequireClientAuthenticationPresent, aSettings.iRequireClientAuthentication) ); |
|
342 |
|
343 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, SessionValidityTime=%d minutes"), |
|
344 aSettings.iSessionValidityTimePresent, aSettings.iSessionValidityTime) ); |
|
345 |
|
346 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, CipherSuites Count=%d"), |
|
347 aSettings.iCipherSuitesPresent, aSettings.iCipherSuites.Count()) ); |
|
348 |
|
349 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, PEAPv0Allowed=%d, PEAPv1Allowed=%d, PEAPv2Allowed=%d"), |
|
350 aSettings.iPEAPVersionsPresent, aSettings.iPEAPv0Allowed,aSettings.iPEAPv1Allowed, aSettings.iPEAPv2Allowed ) ); |
|
351 |
|
352 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, Certificates Count=%d"), |
|
353 aSettings.iCertificatesPresent, aSettings.iCertificates.Count()) ); |
|
354 |
|
355 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - Certificate details below: \n")) ); |
|
356 |
|
357 for( TInt n=0; n < aSettings.iCertificates.Count(); n++ ) |
|
358 { |
|
359 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - Certificate type:%d \n"), aSettings.iCertificates[n].iCertType) ); |
|
360 |
|
361 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - certificates - present=%d, SubjectName=%S"), |
|
362 aSettings.iCertificates[n].iSubjectNamePresent, &(aSettings.iCertificates[n].iSubjectName) ) ); |
|
363 |
|
364 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - certificates - present=%d, IssuerName=%S"), |
|
365 aSettings.iCertificates[n].iIssuerNamePresent, &(aSettings.iCertificates[n].iIssuerName) ) ); |
|
366 |
|
367 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - certificates - present=%d, SerialNumber=%S"), |
|
368 aSettings.iCertificates[n].iSerialNumberPresent, &(aSettings.iCertificates[n].iSerialNumber) ) ); |
|
369 |
|
370 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - certificates - SubjectKeyID present=%d"), |
|
371 aSettings.iCertificates[n].iSubjectKeyIDPresent ) ); |
|
372 |
|
373 EAP_TRACE_DATA_DEBUG_SYMBIAN( ( "SubjectKeyID:", aSettings.iCertificates[n].iSubjectKeyID.Ptr(), |
|
374 aSettings.iCertificates[n].iSubjectKeyID.Size() ) ); |
|
375 |
|
376 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - certificates - present=%d, Thumbprint=%S"), |
|
377 aSettings.iCertificates[n].iThumbprintPresent, &(aSettings.iCertificates[n].iThumbprint) ) ); |
|
378 } |
|
379 |
|
380 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, EncapsulatedEAPTypes Count=%d"), |
|
381 aSettings.iEncapsulatedEAPTypesPresent, aSettings.iEncapsulatedEAPTypes.Count()) ); |
|
382 for( TInt m=0; m < aSettings.iEncapsulatedEAPTypes.Count(); m++ ) |
|
383 { |
|
384 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - EncapsulatedEAPTypes=%d"), |
|
385 aSettings.iEncapsulatedEAPTypes[m]) ); |
|
386 } |
|
387 |
|
388 EAP_TRACE_DEBUG_SYMBIAN((_L("*************************** SetConfigurationL - Set the above values: ***************************\n")) ); |
338 |
389 |
339 // Check if the settings are for the correct type |
390 // Check if the settings are for the correct type |
340 if (aSettings.iEAPExpandedType != (*EapExpandedTypeSim.GetType())) |
391 if (aSettings.iEAPType != EAPSettings::EEapSim) |
341 { |
392 { |
342 User::Leave(KErrNotSupported); |
393 User::Leave(KErrNotSupported); |
343 } |
394 } |
344 |
395 |
345 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
396 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
346 TPtr sqlStatement = buf->Des(); |
397 TPtr sqlStatement = buf->Des(); |
347 |
398 |
348 RDbView view; |
399 RDbView view; |
349 |
400 |
350 _LIT(KSQLQuery, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
401 _LIT(KSQLQuery, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
351 |
402 sqlStatement.Format(KSQLQuery, &KSimTableName, |
352 sqlStatement.Format(KSQLQuery, |
403 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
353 &KSimTableName, |
|
354 &KServiceType, |
|
355 aIndexType, |
|
356 &KServiceIndex, |
|
357 aIndex, |
|
358 &KTunnelingTypeVendorId, |
|
359 aTunnelingType.get_vendor_id(), |
|
360 &KTunnelingType, |
|
361 aTunnelingType.get_vendor_type()); |
|
362 |
404 |
363 // Evaluate view |
405 // Evaluate view |
364 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement))); |
406 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement))); |
365 |
407 |
366 CleanupClosePushL(view); |
408 CleanupClosePushL(view); |
446 User::Leave(KErrArgument); |
464 User::Leave(KErrArgument); |
447 } |
465 } |
448 |
466 |
449 // Length is ok. Set the value in DB. Value could be empty. It doesn't matter. |
467 // Length is ok. Set the value in DB. Value could be empty. It doesn't matter. |
450 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_manual_realm_literal), aSettings.iRealm); |
468 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_manual_realm_literal), aSettings.iRealm); |
|
469 |
|
470 // This is to set the automatic or manual status. |
|
471 TUint useManualRealmStatus; |
|
472 |
|
473 if (aSettings.iRealmPresent) |
|
474 { |
|
475 useManualRealmStatus = EGSMSIMUseManualRealmYes; |
|
476 } |
|
477 else |
|
478 { |
|
479 useManualRealmStatus = EGSMSIMUseManualRealmNo; |
|
480 } |
|
481 |
|
482 // Set the value. |
|
483 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_use_manual_realm_literal), useManualRealmStatus); |
451 } |
484 } |
452 |
485 |
453 // UsePseudonym |
486 // UsePseudonym |
454 if (aSettings.iUsePseudonymsPresent) |
487 if (aSettings.iUsePseudonymsPresent) |
455 { |
488 { |
456 if (aSettings.iUsePseudonyms) |
489 if (aSettings.iUsePseudonyms) |
457 { |
490 { |
458 // Use pseudonym. |
491 // Use pseudonym. |
459 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_use_pseudonym_identity_literal), EEapDbTrue); |
492 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_use_pseudonym_identity_literal), EGSMSIMUsePseudonymIdYes); |
460 } |
493 } |
461 else |
494 else |
462 { |
495 { |
463 // Don't use pseudonym. |
496 // Don't use pseudonym. |
464 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_use_pseudonym_identity_literal), EEapDbFalse); |
497 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_use_pseudonym_identity_literal), EGSMSIMUsePseudonymIdNo); |
465 } |
498 } |
466 } |
499 } |
467 else |
500 else |
468 { |
501 { |
469 // Value is not configured. Value is read from config file if needed. |
502 // Value is not configured. Value is read from config file if needed. |
470 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_use_pseudonym_identity_literal), EEapDbNotValid); |
503 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_use_pseudonym_identity_literal), EGSMSIMUsePseudonymIdNotValid); |
471 } |
504 } |
472 |
505 |
473 // Session validity time |
506 // Session validity time |
474 if (aSettings.iSessionValidityTimePresent) |
507 if (aSettings.iSessionValidityTimePresent) |
475 { |
508 { |
476 // User or device management wants to store the session validity time. |
509 // User or device management wants to store the session validity time. |
477 // Convert the time to micro seconds and save. |
510 // Convert the time to micro seconds and save. |
478 |
511 |
479 TInt64 validityInMicro = (aSettings.iSessionValidityTime) * KMicroSecsInAMinute; |
512 TInt64 validityInMicro = (aSettings.iSessionValidityTime) * KMicroSecsInAMinute; |
480 |
513 |
481 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_max_session_validity_time_literal), validityInMicro); |
514 view.SetColL(colSet->ColNo(cf_str_EAP_GSMSIM_max_session_validity_time_literal), validityInMicro); |
482 } |
515 } |
483 |
516 |
484 if (aIndexType != EVpn) // This allows current VPN IF to use reauthentication. VPN does not zero last full authentication time. |
517 if (aIndexType != EVpn) // This allows current VPN IF to use reauthentication. VPN does not zero last full authentication time. |
485 { |
518 { |
486 // Last full authentication time should be made zero when EAP configurations are modified. |
519 // Last full authentication time should be made zero when EAP configurations are modified. |
487 // This makes sure that the next authentication with this EAP would be full authentication |
520 // This makes sure that the next authentication with this EAP would be full authentication |
488 // instead of reauthentication even if the session is still valid. |
521 // instead of reauthentication even if the session is still valid. |
489 |
522 |
490 view.SetColL(colSet->ColNo(KGSMSIMLastFullAuthTime), default_FullAuthTime); |
523 view.SetColL(colSet->ColNo(KGSMSIMLastFullAuthTime), default_FullAuthTime); |
491 |
524 |
492 EAP_TRACE_DEBUG_SYMBIAN((_L("EapSimDbUtils::SetConfigurationL(): Session Validity: Resetting Full Auth Time since settings are modified\n"))); |
525 EAP_TRACE_DEBUG_SYMBIAN((_L("Session Validity: EAP-Type=%d, Resetting Full Auth Time since settings are modified\n"), |
493 } |
526 aSettings.iEAPType )); |
494 |
527 } |
|
528 |
495 view.PutL(); |
529 view.PutL(); |
496 |
530 CleanupStack::PopAndDestroy(3); // view, colset, buf |
497 CleanupStack::PopAndDestroy(colSet); |
|
498 CleanupStack::PopAndDestroy(&view); |
|
499 CleanupStack::PopAndDestroy(buf); |
|
500 } |
531 } |
501 |
|
502 // ---------------------------------------------------------- |
|
503 |
532 |
504 void EapSimDbUtils::GetConfigurationL( |
533 void EapSimDbUtils::GetConfigurationL( |
505 RDbNamedDatabase& aDatabase, |
534 RDbNamedDatabase& aDatabase, |
506 EAPSettings& aSettings, |
535 EAPSettings& aSettings, |
507 const TIndexType aIndexType, |
536 const TIndexType aIndexType, |
508 const TInt aIndex, |
537 const TInt aIndex, |
509 const eap_type_value_e aTunnelingType) |
538 const eap_type_value_e aTunnelingType) |
510 { |
539 { |
511 EAP_TRACE_DEBUG_SYMBIAN( |
540 #ifdef USE_EAP_EXPANDED_TYPES |
512 (_L("EapSimDbUtils::GetConfigurationL(): -Start- aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x\n"), |
541 |
513 aIndexType, |
542 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
514 aIndex, |
543 |
515 aTunnelingType.get_vendor_id(), |
544 #else |
516 aTunnelingType.get_vendor_type())); |
545 |
517 |
546 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
518 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapSimDbUtils::GetConfigurationL()\n")); |
547 |
|
548 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
519 |
549 |
520 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
550 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
521 TPtr sqlStatement = buf->Des(); |
551 TPtr sqlStatement = buf->Des(); |
522 |
552 |
523 RDbView view; |
553 RDbView view; |
524 |
554 |
525 // Form the query |
555 // Form the query |
526 _LIT(KSQLQuery, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
556 _LIT(KSQLQuery, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
527 |
557 sqlStatement.Format(KSQLQuery, &KSimTableName, |
528 sqlStatement.Format(KSQLQuery, |
558 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
529 &KSimTableName, |
|
530 &KServiceType, |
|
531 aIndexType, |
|
532 &KServiceIndex, |
|
533 aIndex, |
|
534 &KTunnelingTypeVendorId, |
|
535 aTunnelingType.get_vendor_id(), |
|
536 &KTunnelingType, |
|
537 aTunnelingType.get_vendor_type()); |
|
538 |
559 |
539 // Evaluate view |
560 // Evaluate view |
540 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement))); |
561 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement))); |
541 |
562 |
542 CleanupClosePushL(view); |
563 CleanupClosePushL(view); |
549 |
570 |
550 // Get column set so we get the correct column numbers |
571 // Get column set so we get the correct column numbers |
551 CDbColSet* colSet = view.ColSetL(); |
572 CDbColSet* colSet = view.ColSetL(); |
552 CleanupStack::PushL(colSet); |
573 CleanupStack::PushL(colSet); |
553 |
574 |
554 aSettings.iEAPExpandedType = *EapExpandedTypeSim.GetType(); |
575 aSettings.iEAPType = EAPSettings::EEapSim; |
555 |
576 |
556 { |
577 // Username |
557 // For manual or automatic username. |
578 TPtrC username = view.ColDes(colSet->ColNo(cf_str_EAP_GSMSIM_manual_username_literal)); |
558 TUint useUsername = view.ColUint(colSet->ColNo(cf_str_EAP_GSMSIM_use_manual_username_literal)); |
579 aSettings.iUsername.Copy(username); |
559 |
580 |
560 aSettings.iUseAutomaticUsernamePresent = ETrue; |
581 // For manual or automatic status. |
561 |
582 TUint useUsername = view.ColUint(colSet->ColNo(cf_str_EAP_GSMSIM_use_manual_username_literal)); |
562 if(useUsername == EEapDbTrue) |
583 if(useUsername == EGSMSIMUseManualUsernameNo) |
|
584 { |
|
585 aSettings.iUsernamePresent = EFalse; |
|
586 } |
|
587 else |
|
588 { |
|
589 aSettings.iUsernamePresent = ETrue; |
|
590 } |
|
591 |
|
592 // Realm |
|
593 TPtrC realm = view.ColDes(colSet->ColNo(cf_str_EAP_GSMSIM_manual_realm_literal)); |
|
594 aSettings.iRealm.Copy(realm); |
|
595 |
|
596 // For manual or automatic status. |
|
597 TUint useRealm = view.ColUint(colSet->ColNo(cf_str_EAP_GSMSIM_use_manual_realm_literal)); |
|
598 if(useRealm == EGSMSIMUseManualRealmNo) |
|
599 { |
|
600 aSettings.iRealmPresent = EFalse; |
|
601 } |
|
602 else |
|
603 { |
|
604 aSettings.iRealmPresent = ETrue; |
|
605 } |
|
606 |
|
607 TInt usePseudonym = view.ColUint(colSet->ColNo(cf_str_EAP_GSMSIM_use_pseudonym_identity_literal)); |
|
608 |
|
609 if (usePseudonym == EGSMSIMUsePseudonymIdNotValid) |
|
610 { |
|
611 aSettings.iUsePseudonymsPresent = EFalse; |
|
612 } |
|
613 else |
|
614 { |
|
615 if (usePseudonym == EGSMSIMUsePseudonymIdNo) |
563 { |
616 { |
564 aSettings.iUseAutomaticUsername = EFalse; |
617 aSettings.iUsePseudonyms = EFalse; |
565 } |
618 } |
566 else |
619 else |
567 { |
620 { |
568 aSettings.iUseAutomaticUsername = ETrue; |
621 aSettings.iUsePseudonyms = ETrue; |
569 } |
622 } |
570 } |
623 |
571 |
624 aSettings.iUsePseudonymsPresent = ETrue; |
572 { |
625 } |
573 // For manual or automatic realm. |
626 |
574 TUint useRealm = view.ColUint(colSet->ColNo(cf_str_EAP_GSMSIM_use_manual_realm_literal)); |
627 // Session validity time |
575 |
628 TInt64 maxSessionTimeMicro = view.ColInt64(colSet->ColNo(cf_str_EAP_GSMSIM_max_session_validity_time_literal)); |
576 aSettings.iUseAutomaticRealmPresent = ETrue; |
629 |
577 |
630 // Convert the time to minutes. |
578 if(useRealm == EEapDbTrue) |
631 TInt64 maxSessionTimeMin = maxSessionTimeMicro / KMicroSecsInAMinute; |
579 { |
632 |
580 aSettings.iUseAutomaticRealm = EFalse; |
633 aSettings.iSessionValidityTime = static_cast<TUint>(maxSessionTimeMin); |
581 } |
634 aSettings.iSessionValidityTimePresent = ETrue; |
582 else |
635 |
583 { |
636 CleanupStack::PopAndDestroy(3); // view, colset, buf |
584 aSettings.iUseAutomaticRealm = ETrue; |
|
585 } |
|
586 } |
|
587 |
|
588 { |
|
589 // Username |
|
590 TPtrC username = view.ColDes(colSet->ColNo(cf_str_EAP_GSMSIM_manual_username_literal)); |
|
591 |
|
592 aSettings.iUsernamePresent = ETrue; |
|
593 |
|
594 aSettings.iUsername.Copy(username); |
|
595 } |
|
596 |
|
597 { |
|
598 // Realm |
|
599 TPtrC realm = view.ColDes(colSet->ColNo(cf_str_EAP_GSMSIM_manual_realm_literal)); |
|
600 |
|
601 aSettings.iRealmPresent = ETrue; |
|
602 |
|
603 aSettings.iRealm.Copy(realm); |
|
604 } |
|
605 |
|
606 { |
|
607 TInt usePseudonym = view.ColUint(colSet->ColNo(cf_str_EAP_GSMSIM_use_pseudonym_identity_literal)); |
|
608 |
|
609 if (usePseudonym == EEapDbNotValid) |
|
610 { |
|
611 aSettings.iUsePseudonymsPresent = EFalse; |
|
612 } |
|
613 else |
|
614 { |
|
615 if (usePseudonym == EEapDbFalse) |
|
616 { |
|
617 aSettings.iUsePseudonyms = EFalse; |
|
618 } |
|
619 else |
|
620 { |
|
621 aSettings.iUsePseudonyms = ETrue; |
|
622 } |
|
623 |
|
624 aSettings.iUsePseudonymsPresent = ETrue; |
|
625 } |
|
626 } |
|
627 |
|
628 { |
|
629 // Session validity time |
|
630 TInt64 maxSessionTimeMicro = view.ColInt64(colSet->ColNo(cf_str_EAP_GSMSIM_max_session_validity_time_literal)); |
|
631 |
|
632 // Convert the time to minutes. |
|
633 TInt64 maxSessionTimeMin = maxSessionTimeMicro / KMicroSecsInAMinute; |
|
634 |
|
635 aSettings.iSessionValidityTime = static_cast<TUint>(maxSessionTimeMin); |
|
636 aSettings.iSessionValidityTimePresent = ETrue; |
|
637 } |
|
638 |
|
639 CleanupStack::PopAndDestroy(colSet); |
|
640 CleanupStack::PopAndDestroy(&view); |
|
641 CleanupStack::PopAndDestroy(buf); |
|
642 |
|
643 EAP_TRACE_SETTINGS(&aSettings); |
|
644 } |
637 } |
645 |
|
646 // ---------------------------------------------------------- |
|
647 |
638 |
648 void EapSimDbUtils::CopySettingsL( |
639 void EapSimDbUtils::CopySettingsL( |
649 RDbNamedDatabase& aDatabase, |
640 RDbNamedDatabase& aDatabase, |
650 const TIndexType aSrcIndexType, |
641 const TIndexType aSrcIndexType, |
651 const TInt aSrcIndex, |
642 const TInt aSrcIndex, |
652 const eap_type_value_e aSrcTunnelingType, |
643 const eap_type_value_e aSrcTunnelingType, |
653 const TIndexType aDestIndexType, |
644 const TIndexType aDestIndexType, |
654 const TInt aDestIndex, |
645 const TInt aDestIndex, |
655 const eap_type_value_e aDestTunnelingType) |
646 const eap_type_value_e aDestTunnelingType) |
656 { |
647 { |
657 EAP_TRACE_DEBUG_SYMBIAN( |
648 #ifdef USE_EAP_EXPANDED_TYPES |
658 (_L("EapSimDbUtils::CopySettingsL(): -Start- aSrcIndexType=%d, aSrcIndex=%d, aSrcTunnelingType=0xfe%06x%08x\n"), |
649 |
659 aSrcIndexType, |
650 TUint aSrcTunnelingVendorType = aSrcTunnelingType.get_vendor_type(); |
660 aSrcIndex, |
651 TUint aDestTunnelingVendorType = aDestTunnelingType.get_vendor_type(); |
661 aSrcTunnelingType.get_vendor_id(), |
652 |
662 aSrcTunnelingType.get_vendor_type())); |
653 #else |
663 |
654 |
664 EAP_TRACE_DEBUG_SYMBIAN( |
655 TUint aSrcTunnelingVendorType = static_cast<TUint>(aSrcTunnelingType); |
665 (_L("EapSimDbUtils::CopySettingsL(): -Start- aDestIndexType=%d, aDestTunnelingType=0xfe%06x%08x\n"), |
656 TUint aDestTunnelingVendorType = static_cast<TUint>(aDestTunnelingType); |
666 aDestIndexType, |
657 |
667 aDestIndex, |
658 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
668 aDestTunnelingType.get_vendor_id(), |
|
669 aDestTunnelingType.get_vendor_type())); |
|
670 |
|
671 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapSimDbUtils::CopySettingsL()\n")); |
|
672 |
659 |
673 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
660 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
674 TPtr sqlStatement = buf->Des(); |
661 TPtr sqlStatement = buf->Des(); |
675 |
662 |
676 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
663 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
677 |
664 |
678 sqlStatement.Format(KSQL, |
665 sqlStatement.Format(KSQL, &KSimTableName, |
679 &KSimTableName, |
666 &KServiceType, aSrcIndexType, &KServiceIndex, aSrcIndex, &KTunnelingType, aSrcTunnelingVendorType); |
680 &KServiceType, |
|
681 aSrcIndexType, |
|
682 &KServiceIndex, |
|
683 aSrcIndex, |
|
684 &KTunnelingTypeVendorId, |
|
685 aSrcTunnelingType.get_vendor_id(), |
|
686 &KTunnelingType, |
|
687 aSrcTunnelingType.get_vendor_type()); |
|
688 |
667 |
689 RDbView view; |
668 RDbView view; |
690 |
669 |
691 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
670 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
692 |
671 |
713 CDbColSet* colSet = view.ColSetL(); |
692 CDbColSet* colSet = view.ColSetL(); |
714 |
693 |
715 CleanupStack::PushL(colSet); |
694 CleanupStack::PushL(colSet); |
716 |
695 |
717 view.SetColL(colSet->ColNo(KServiceType), static_cast<TUint>(aDestIndexType)); |
696 view.SetColL(colSet->ColNo(KServiceType), static_cast<TUint>(aDestIndexType)); |
|
697 |
718 view.SetColL(colSet->ColNo(KServiceIndex), aDestIndex); |
698 view.SetColL(colSet->ColNo(KServiceIndex), aDestIndex); |
719 view.SetColL(colSet->ColNo(KTunnelingTypeVendorId), aDestTunnelingType.get_vendor_id()); |
699 |
720 view.SetColL(colSet->ColNo(KTunnelingType), aDestTunnelingType.get_vendor_type()); |
700 view.SetColL(colSet->ColNo(KTunnelingType), aDestTunnelingVendorType); |
721 |
701 |
722 view.PutL(); |
702 view.PutL(); |
723 |
703 |
724 CleanupStack::PopAndDestroy(colSet); |
704 CleanupStack::PopAndDestroy(3); // view, colset, buf |
725 CleanupStack::PopAndDestroy(&view); |
|
726 CleanupStack::PopAndDestroy(buf); |
|
727 } |
705 } |
728 |
|
729 // ---------------------------------------------------------- |
|
730 |
706 |
731 void EapSimDbUtils::DeleteConfigurationL( |
707 void EapSimDbUtils::DeleteConfigurationL( |
732 const TIndexType aIndexType, |
708 const TIndexType aIndexType, |
733 const TInt aIndex, |
709 const TInt aIndex, |
734 const eap_type_value_e aTunnelingType) |
710 const eap_type_value_e aTunnelingType) |
735 { |
711 { |
736 EAP_TRACE_DEBUG_SYMBIAN( |
712 #ifdef USE_EAP_EXPANDED_TYPES |
737 (_L("EapSimDbUtils::DeleteConfigurationL(): -Start- aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x\n"), |
713 |
738 aIndexType, |
714 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
739 aIndex, |
715 |
740 aTunnelingType.get_vendor_id(), |
716 #else |
741 aTunnelingType.get_vendor_type())); |
717 |
742 |
718 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
743 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapSimDbUtils::DeleteConfigurationL()\n")); |
719 |
744 |
720 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
745 RDbNamedDatabase aDatabase; |
721 |
746 RFs aFileServerSession; |
722 RDbs session; |
747 |
723 RDbNamedDatabase database; |
748 TInt error(KErrNone); |
724 // Connect to the DBMS server. |
749 TFileName aPrivateDatabasePathName; |
725 User::LeaveIfError(session.Connect()); |
750 |
726 CleanupClosePushL(session); |
751 error = aFileServerSession.Connect(); |
727 |
752 EAP_TRACE_DEBUG_SYMBIAN((_L("EapSimDbUtils::DeleteConfigurationL(): - aFileServerSession.Connect(), error=%d\n"), error)); |
728 #ifdef SYMBIAN_SECURE_DBMS |
753 User::LeaveIfError(error); |
729 |
754 |
730 // Create the secure shared database with the specified secure policy. |
755 EapPluginTools::CreateDatabaseLC( |
731 // Database will be created in the data caging path for DBMS (C:\private\100012a5). |
756 aDatabase, |
732 |
757 aFileServerSession, |
733 TInt err = database.Create(session, KDatabaseName, KSecureUIDFormat); |
758 error, |
734 |
759 KEapSimDatabaseName, |
735 if(err == KErrNone) |
760 aPrivateDatabasePathName); |
|
761 |
|
762 if(error == KErrNone) |
|
763 { |
736 { |
764 // Database was created so it was empty. No need for further actions. |
737 // Database was created so it was empty. No need for further actions. |
765 aDatabase.Destroy(); |
738 database.Destroy(); |
766 CleanupStack::PopAndDestroy(&aDatabase); |
739 CleanupStack::PopAndDestroy(); |
767 CleanupStack::PopAndDestroy(&aFileServerSession); |
|
768 return; |
740 return; |
769 } |
741 |
770 else if (error != KErrAlreadyExists) |
742 } |
771 { |
743 else if (err != KErrAlreadyExists) |
772 User::LeaveIfError(error); |
744 { |
773 } |
745 User::LeaveIfError(err); |
774 |
746 } |
775 error = aDatabase.Open(aFileServerSession, aPrivateDatabasePathName); |
747 |
776 |
748 // Database existed, open it. |
777 User::LeaveIfError(error); |
749 User::LeaveIfError(database.Open(session, KDatabaseName, KSecureUIDFormat)); |
|
750 CleanupClosePushL(database); |
|
751 |
|
752 #else |
|
753 // For non-secured database. The database will be created in the old location (c:\system\data). |
|
754 |
|
755 RFs fsSession; |
|
756 User::LeaveIfError(fsSession.Connect()); |
|
757 CleanupClosePushL(fsSession); |
|
758 TInt err = database.Create(fsSession, KDatabaseName); |
|
759 |
|
760 if(err == KErrNone) |
|
761 { |
|
762 // Database was created so it was empty. No need for further actions. |
|
763 database.Destroy(); |
|
764 CleanupStack::PopAndDestroy(2); // fsSession, database session |
|
765 return; |
|
766 |
|
767 } |
|
768 else if (err != KErrAlreadyExists) |
|
769 { |
|
770 User::LeaveIfError(err); |
|
771 } |
|
772 |
|
773 CleanupStack::PopAndDestroy(); // close fsSession |
|
774 |
|
775 User::LeaveIfError(database.Open(session, KDatabaseName)); |
|
776 CleanupClosePushL(database); |
|
777 |
|
778 #endif // #ifdef SYMBIAN_SECURE_DBMS |
778 |
779 |
779 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
780 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
780 TPtr sqlStatement = buf->Des(); |
781 TPtr sqlStatement = buf->Des(); |
781 |
782 |
782 // Main settings table |
783 // Main settings table |
783 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
784 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
784 |
785 sqlStatement.Format(KSQL, &KSimTableName, |
785 sqlStatement.Format( |
786 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
786 KSQL, |
|
787 &KSimTableName, |
|
788 &KServiceType, |
|
789 aIndexType, |
|
790 &KServiceIndex, |
|
791 aIndex, |
|
792 &KTunnelingTypeVendorId, |
|
793 aTunnelingType.get_vendor_id(), |
|
794 &KTunnelingType, |
|
795 aTunnelingType.get_vendor_type()); |
|
796 |
|
797 // Evaluate view |
787 // Evaluate view |
798 RDbView view; |
788 RDbView view; |
799 |
789 User::LeaveIfError(view.Prepare(database,TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
800 error = view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited); |
|
801 |
|
802 User::LeaveIfError(error); |
|
803 |
|
804 CleanupClosePushL(view); |
790 CleanupClosePushL(view); |
805 |
791 User::LeaveIfError(view.EvaluateAll()); |
806 error = view.EvaluateAll(); |
|
807 |
|
808 User::LeaveIfError(error); |
|
809 |
792 |
810 // Delete rows |
793 // Delete rows |
811 if (view.FirstL()) |
794 if (view.FirstL()) |
812 { |
795 { |
813 do |
796 do { |
814 { |
|
815 EAP_TRACE_DEBUG_SYMBIAN((_L("EapSimDbUtils::DeleteConfigurationL(): calls view.DeleteL()\n"))); |
|
816 |
|
817 view.DeleteL(); |
797 view.DeleteL(); |
818 } |
798 } while (view.NextL() != EFalse); |
819 while (view.NextL() != EFalse); |
799 } |
820 |
800 |
821 EAP_TRACE_DEBUG_SYMBIAN((_L("EapSimDbUtils::DeleteConfigurationL(): All rows deleted.\n"))); |
801 // Close database |
822 } |
802 CleanupStack::PopAndDestroy(4); // view, buf, database, session |
823 else |
|
824 { |
|
825 EAP_TRACE_DEBUG_SYMBIAN((_L("EapSimDbUtils::DeleteConfigurationL(): No rows to delete.\n"))); |
|
826 } |
|
827 |
|
828 CleanupStack::PopAndDestroy(&view); |
|
829 CleanupStack::PopAndDestroy(buf); |
|
830 CleanupStack::PopAndDestroy(&aDatabase); |
|
831 CleanupStack::PopAndDestroy(&aFileServerSession); |
|
832 } |
803 } |
833 |
804 |
834 // ---------------------------------------------------------- |
|
835 |
|
836 // End of file |
805 // End of file |