33 #include "EapGtcDbUtils.h" |
33 #include "EapGtcDbUtils.h" |
34 #include "EapGtcDbDefaults.h" |
34 #include "EapGtcDbDefaults.h" |
35 #include "EapGtcDbParameterNames.h" |
35 #include "EapGtcDbParameterNames.h" |
36 #include "EapSecurIDDbParameterNames.h" |
36 #include "EapSecurIDDbParameterNames.h" |
37 |
37 |
38 #include "eap_am_trace_symbian.h" |
38 #include <EapTraceSymbian.h> |
|
39 #include <EapPluginTools.h> |
39 |
40 |
40 const TUint KMaxSqlQueryLength = 512; |
41 const TUint KMaxSqlQueryLength = 512; |
41 const TInt KMicroSecsInAMinute = 60000000; // 60000000 micro seconds is 1 minute. |
42 const TInt KMicroSecsInAMinute = 60000000; // 60000000 micro seconds is 1 minute. |
42 |
43 |
43 // ================= MEMBER FUNCTIONS ======================= |
44 // ================= MEMBER FUNCTIONS ======================= |
44 |
45 |
45 void EapGtcDbUtils::OpenDatabaseL(RDbNamedDatabase& aDatabase, RDbs& aSession, const TIndexType aIndexType, |
46 void EapGtcDbUtils::OpenDatabaseL( |
46 const TInt aIndex, const eap_type_value_e aTunnelingType) |
47 RDbNamedDatabase& aDatabase, |
|
48 RFs& aFileServerSession, |
|
49 const TIndexType aIndexType, |
|
50 const TInt aIndex, |
|
51 const eap_type_value_e aTunnelingType) |
47 { |
52 { |
48 #ifdef USE_EAP_EXPANDED_TYPES |
53 EAP_TRACE_DEBUG_SYMBIAN( |
49 |
54 (_L("EapGtcDbUtils::OpenDatabaseL(): - Start - aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x\n"), |
50 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
55 aIndexType, |
51 |
56 aIndex, |
52 #else |
57 aTunnelingType.get_vendor_id(), |
53 |
58 aTunnelingType.get_vendor_type())); |
54 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
59 |
55 |
60 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapGtcDbUtils::OpenDatabaseL()\n")); |
56 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
57 |
|
58 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL -Start- aIndexType=%d, aIndex=%d, aTunnelingVendorType=%d \n"), |
|
59 aIndexType,aIndex,aTunnelingVendorType) ); |
|
60 |
61 |
61 // 1. Open/create a database |
62 // 1. Open/create a database |
62 |
63 |
63 // Connect to the DBMS server. |
64 TInt error(KErrNone); |
64 User::LeaveIfError(aSession.Connect()); |
65 TFileName aPrivateDatabasePathName; |
65 CleanupClosePushL(aSession); |
66 |
66 // aSession and aDatabase are pushed to the cleanup stack even though they may be member |
67 EapPluginTools::CreateDatabaseLC( |
67 // variables of the calling class and would be closed in the destructor anyway. This ensures |
68 aDatabase, |
68 // that if they are not member variables they will be closed. Closing the handle twice |
69 aFileServerSession, |
69 // does no harm. |
70 error, |
70 |
71 KEapGtcDatabaseName, |
71 #ifdef SYMBIAN_SECURE_DBMS |
72 aPrivateDatabasePathName); |
72 |
73 |
73 // Create the secure shared database with the specified secure policy. |
74 if(error == KErrNone) |
74 // Database will be created in the data caging path for DBMS (C:\private\100012a5). |
|
75 |
|
76 TInt err = aDatabase.Create(aSession, KGtcDatabaseName, KGtcSecureUIDFormat); |
|
77 |
|
78 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL - Created Secure DB for eapgtc.dat. err=%d\n"), err)); |
|
79 |
|
80 |
|
81 if(err == KErrNone) |
|
82 { |
75 { |
83 aDatabase.Close(); |
76 aDatabase.Close(); |
84 |
77 } |
85 } else if (err != KErrAlreadyExists) |
78 else if (error != KErrAlreadyExists) |
86 { |
79 { |
87 User::LeaveIfError(err); |
80 User::LeaveIfError(error); |
88 } |
81 } |
89 |
82 |
90 User::LeaveIfError(aDatabase.Open(aSession, KGtcDatabaseName, KGtcSecureUIDFormat)); |
83 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL(): - calls aDatabase.Open()\n"))); |
91 CleanupClosePushL(aDatabase); |
84 |
92 |
85 error = aDatabase.Open(aFileServerSession, aPrivateDatabasePathName); |
93 #else |
86 |
94 // For non-secured database. The database will be created in the old location (c:\system\data). |
87 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL(): - Opened private DB for EAP-AKA. error=%d\n"), error)); |
95 |
88 |
96 RFs fsSession; |
89 User::LeaveIfError(error); |
97 User::LeaveIfError(fsSession.Connect()); |
|
98 CleanupClosePushL(fsSession); |
|
99 TInt err = aDatabase.Create(fsSession, KGtcDatabaseName); |
|
100 |
|
101 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL - Created Non-Secure DB for eapgtc.dat. err=%d\n"), err)); |
|
102 |
|
103 |
|
104 if(err == KErrNone) |
|
105 { |
|
106 aDatabase.Close(); |
|
107 |
|
108 } else if (err != KErrAlreadyExists) |
|
109 { |
|
110 User::LeaveIfError(err); |
|
111 } |
|
112 CleanupStack::PopAndDestroy(); // close fsSession |
|
113 |
|
114 User::LeaveIfError(aDatabase.Open(aSession, KGtcDatabaseName)); |
|
115 CleanupClosePushL(aDatabase); |
|
116 |
|
117 #endif // #ifdef SYMBIAN_SECURE_DBMS |
|
118 |
90 |
119 // 2. Create the eap-securid table to database (ignore error if exists) |
91 // 2. Create the eap-securid table to database (ignore error if exists) |
120 |
92 |
121 // Table columns: |
93 // Table columns: |
122 //// NAME ///////////////////////////////////////////////// TYPE ////////////// Constant ///////// |
94 //// NAME ///////////////////////////////////////////////// TYPE ////////////// Constant ///////// |
123 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
95 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
124 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
96 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
125 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
97 //| TunnelingTypeVendorId | UNSIGNED INTEGER | KTunnelingTypeVendorId |// |
126 //| EAP_GTC_identity | VARCHAR(255) | cf_str_EAP_GTC_identity_literal |// |
98 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
127 //| EAP_GTC_max_session_validity_time | BIGINT | cf_str_EAP_GTC_max_session_validity_time_literal |// |
99 //| EAP_GTC_identity | VARCHAR(255) | cf_str_EAP_GTC_identity_literal |// |
128 //| EAP_GTC_last_full_authentication_time | BIGINT | KGTCLastFullAuthTime |// |
100 //| EAP_GTC_max_session_validity_time | BIGINT | cf_str_EAP_GTC_max_session_validity_time_literal |// |
|
101 //| EAP_GTC_last_full_authentication_time | BIGINT | KGTCLastFullAuthTime |// |
|
102 //| EAP_GTC_password_prompt | UNSIGNED INTEGER | cf_str_EAP_GTC_passcode_prompt_literal |// |
|
103 //| EAP_GTC_password | VARCHAR(255) | cf_str_EAP_GTC_passcode_literal |// |
129 ////////////////////////////////////////////////////////////////////////////////////////////////// |
104 ////////////////////////////////////////////////////////////////////////////////////////////////// |
|
105 |
|
106 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL(): calls HBufC::NewLC()\n"))); |
130 |
107 |
131 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
108 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
132 TPtr sqlStatement = buf->Des(); |
109 TPtr sqlStatement = buf->Des(); |
133 |
110 |
134 _LIT(KSQLCreateTable1, "CREATE TABLE %S (%S UNSIGNED INTEGER, \ |
111 _LIT(KSQLCreateTable1, "CREATE TABLE %S \ |
135 %S UNSIGNED INTEGER, \ |
112 (%S UNSIGNED INTEGER, \ |
136 %S UNSIGNED INTEGER, \ |
113 %S UNSIGNED INTEGER, \ |
137 %S VARCHAR(255), \ |
114 %S UNSIGNED INTEGER, \ |
138 %S BIGINT, \ |
115 %S UNSIGNED INTEGER, \ |
139 %S BIGINT)"); |
116 %S VARCHAR(255), \ |
|
117 %S BIGINT, \ |
|
118 %S BIGINT, \ |
|
119 %S UNSIGNED INTEGER, \ |
|
120 %S VARCHAR(255))"); |
140 |
121 |
|
122 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL(): calls sqlStatement.Format()\n"))); |
|
123 |
141 sqlStatement.Format(KSQLCreateTable1, |
124 sqlStatement.Format(KSQLCreateTable1, |
142 &KGtcTableName, |
125 &KGtcTableName, |
143 &KServiceType, |
126 &KServiceType, |
144 &KServiceIndex, |
127 &KServiceIndex, |
|
128 &KTunnelingTypeVendorId, |
145 &KTunnelingType, |
129 &KTunnelingType, |
146 &cf_str_EAP_GTC_identity_literal, |
130 &cf_str_EAP_GTC_identity_literal, |
147 &cf_str_EAP_GTC_max_session_validity_time_literal, |
131 &cf_str_EAP_GTC_max_session_validity_time_literal, |
148 &KGTCLastFullAuthTime); |
132 &KGTCLastFullAuthTime, |
149 |
133 &cf_str_EAP_GTC_passcode_prompt_literal, |
150 err = aDatabase.Execute(sqlStatement); |
134 &cf_str_EAP_GTC_passcode_literal); |
151 if (err != KErrNone && err != KErrAlreadyExists) |
135 |
152 { |
136 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL(): calls aDatabase.Execute()\n"))); |
153 User::Leave(err); |
137 |
|
138 error = aDatabase.Execute(sqlStatement); |
|
139 if (error != KErrNone && error != KErrAlreadyExists) |
|
140 { |
|
141 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapGtcDbUtils::OpenDatabaseL(): aDatabase.Execute() error=%d\n"), |
|
142 error)); |
|
143 |
|
144 User::Leave(error); |
154 } |
145 } |
155 |
146 |
156 // 4. Check if database table contains a row for this service type and id |
147 // 4. Check if database table contains a row for this service type and id |
157 |
148 |
158 _LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
149 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL(): calls sqlStatement.Format()\n"))); |
159 sqlStatement.Format(KSQLQueryRow, &cf_str_EAP_GTC_identity_literal, &KGtcTableName, |
150 |
160 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
151 _LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
|
152 |
|
153 sqlStatement.Format(KSQLQueryRow, |
|
154 &cf_str_EAP_GTC_identity_literal, |
|
155 &KGtcTableName, |
|
156 &KServiceType, |
|
157 aIndexType, |
|
158 &KServiceIndex, |
|
159 aIndex, |
|
160 &KTunnelingTypeVendorId, |
|
161 aTunnelingType.get_vendor_id(), |
|
162 &KTunnelingType, |
|
163 aTunnelingType.get_vendor_type()); |
161 |
164 |
162 RDbView view; |
165 RDbView view; |
163 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
166 |
|
167 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL(): calls view.Prepare()\n"))); |
|
168 |
|
169 error = view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited); |
|
170 |
|
171 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL(): view.Prepare() error=%d\n"), |
|
172 error)); |
|
173 |
|
174 User::LeaveIfError(error); |
164 // View must be closed when no longer needed |
175 // View must be closed when no longer needed |
165 CleanupClosePushL(view); |
176 CleanupClosePushL(view); |
166 User::LeaveIfError(view.EvaluateAll()); |
177 |
|
178 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL(): calls view.EvaluateAll()\n"))); |
|
179 |
|
180 error = view.EvaluateAll(); |
|
181 |
|
182 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL(): view.EvaluateAll() error=%d\n"), |
|
183 error)); |
|
184 |
|
185 User::LeaveIfError(error); |
167 |
186 |
168 // 5. If row is not found then add it |
187 // 5. If row is not found then add it |
169 |
188 |
|
189 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL(): calls view.CountL()\n"))); |
|
190 |
170 TInt rows = view.CountL(); |
191 TInt rows = view.CountL(); |
171 CleanupStack::PopAndDestroy(); // view |
192 |
|
193 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL(): view.CountL() rows=%d\n"), |
|
194 rows)); |
|
195 |
|
196 CleanupStack::PopAndDestroy(&view); |
172 if (rows == 0) |
197 if (rows == 0) |
173 { |
198 { |
174 _LIT(KSQLInsert, "SELECT * FROM %S"); |
199 _LIT(KSQLInsert, "SELECT * FROM %S"); |
175 sqlStatement.Format(KSQLInsert, &KGtcTableName); |
200 sqlStatement.Format(KSQLInsert, &KGtcTableName); |
176 |
201 |
177 view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited, RDbView::EInsertOnly); |
202 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL(): calls view.Prepare()\n"))); |
|
203 |
|
204 error = view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited, RDbView::EInsertOnly); |
|
205 |
|
206 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL(): view.Prepare() error=%d\n"), |
|
207 error)); |
|
208 |
178 CleanupClosePushL(view); |
209 CleanupClosePushL(view); |
179 |
210 |
180 // Get column set so we get the correct column numbers |
211 // Get column set so we get the correct column numbers |
|
212 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL(): calls view.ColSetL()\n"))); |
|
213 |
181 CDbColSet* colSet = view.ColSetL(); |
214 CDbColSet* colSet = view.ColSetL(); |
182 CleanupStack::PushL(colSet); |
215 CleanupStack::PushL(colSet); |
183 |
216 |
|
217 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL(): calls view.InsertL()\n"))); |
|
218 |
184 view.InsertL(); |
219 view.InsertL(); |
185 view.SetColL(colSet->ColNo(KServiceType), static_cast<TInt> (aIndexType)); |
220 view.SetColL(colSet->ColNo(KServiceType), static_cast<TInt> (aIndexType)); |
186 view.SetColL(colSet->ColNo(KServiceIndex), aIndex); |
221 view.SetColL(colSet->ColNo(KServiceIndex), aIndex); |
187 view.SetColL(colSet->ColNo(KTunnelingType), aTunnelingVendorType); |
222 view.SetColL(colSet->ColNo(KTunnelingTypeVendorId), aTunnelingType.get_vendor_id()); |
188 view.SetColL(colSet->ColNo(cf_str_EAP_GTC_identity_literal), default_EAP_GTC_identity); |
223 view.SetColL(colSet->ColNo(KTunnelingType), aTunnelingType.get_vendor_type()); |
|
224 view.SetColL(colSet->ColNo(cf_str_EAP_GTC_identity_literal), default_EAP_identity); |
189 |
225 |
190 view.SetColL(colSet->ColNo(cf_str_EAP_GTC_max_session_validity_time_literal), default_MaxSessionTime); |
226 view.SetColL(colSet->ColNo(cf_str_EAP_GTC_max_session_validity_time_literal), default_MaxSessionTime); |
191 |
227 |
192 view.SetColL(colSet->ColNo(KGTCLastFullAuthTime), default_FullAuthTime); |
228 view.SetColL(colSet->ColNo(KGTCLastFullAuthTime), default_FullAuthTime); |
|
229 view.SetColL(colSet->ColNo(cf_str_EAP_GTC_passcode_prompt_literal), default_EAP_password_prompt); |
|
230 view.SetColL(colSet->ColNo(cf_str_EAP_GTC_passcode_literal), default_EAP_password); |
193 |
231 |
194 view.PutL(); |
232 view.PutL(); |
195 |
233 |
196 CleanupStack::PopAndDestroy( colSet ); // Delete colSet. |
234 CleanupStack::PopAndDestroy( colSet ); |
197 |
235 |
198 CleanupStack::PopAndDestroy( &view ); // Close view. |
236 CleanupStack::PopAndDestroy( &view ); |
199 |
237 |
200 } |
238 } |
201 |
239 |
202 CleanupStack::PopAndDestroy( buf ); // Delete buf |
240 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::OpenDatabaseL(): calls aDatabase.Compact()\n"))); |
|
241 |
|
242 aDatabase.Compact(); |
|
243 |
|
244 CleanupStack::PopAndDestroy( buf ); |
203 CleanupStack::Pop( &aDatabase ); |
245 CleanupStack::Pop( &aDatabase ); |
204 CleanupStack::Pop( &aSession ); |
246 CleanupStack::Pop( &aFileServerSession ); |
205 |
|
206 aDatabase.Compact(); |
|
207 } |
247 } |
208 |
248 |
|
249 // ---------------------------------------------------------- |
209 |
250 |
210 void EapGtcDbUtils::SetIndexL( |
251 void EapGtcDbUtils::SetIndexL( |
211 RDbNamedDatabase& aDatabase, |
252 RDbNamedDatabase& aDatabase, |
212 const TIndexType aIndexType, |
253 const TIndexType aIndexType, |
213 const TInt aIndex, |
254 const TInt aIndex, |
214 const eap_type_value_e aTunnelingType, |
255 const eap_type_value_e aTunnelingType, |
215 const TIndexType aNewIndexType, |
256 const TIndexType aNewIndexType, |
216 const TInt aNewIndex, |
257 const TInt aNewIndex, |
217 const eap_type_value_e aNewTunnelingType) |
258 const eap_type_value_e aNewTunnelingType) |
218 { |
259 { |
219 #ifdef USE_EAP_EXPANDED_TYPES |
260 EAP_TRACE_DEBUG_SYMBIAN( |
220 |
261 (_L("EapGtcDbUtils::SetIndexL(): -Start- aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x\n"), |
221 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
262 aIndexType, |
222 TUint aNewTunnelingVendorType = aNewTunnelingType.get_vendor_type(); |
263 aIndex, |
223 |
264 aTunnelingType.get_vendor_id(), |
224 #else |
265 aTunnelingType.get_vendor_type())); |
225 |
266 |
226 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
267 EAP_TRACE_DEBUG_SYMBIAN( |
227 TUint aNewTunnelingVendorType = static_cast<TUint>(aNewTunnelingType); |
268 (_L("EapGtcDbUtils::SetIndexL(): -Start- aNewIndexType=%d, aNewIndex=%d, aNewTunnelingType=0xfe%06x%08x\n"), |
228 |
269 aNewIndexType, |
229 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
270 aNewIndex, |
|
271 aNewTunnelingType.get_vendor_id(), |
|
272 aNewTunnelingType.get_vendor_type())); |
|
273 |
|
274 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapGtcDbUtils::SetIndexL()\n")); |
230 |
275 |
231 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
276 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
232 TPtr sqlStatement = buf->Des(); |
277 TPtr sqlStatement = buf->Des(); |
233 |
278 |
234 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
279 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
235 |
280 |
236 sqlStatement.Format(KSQL, &KGtcTableName, |
281 sqlStatement.Format(KSQL, |
237 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
282 &KGtcTableName, |
|
283 &KServiceType, |
|
284 aIndexType, |
|
285 &KServiceIndex, |
|
286 aIndex, |
|
287 &KTunnelingTypeVendorId, |
|
288 aTunnelingType.get_vendor_id(), |
|
289 &KTunnelingType, |
|
290 aTunnelingType.get_vendor_type()); |
238 |
291 |
239 RDbView view; |
292 RDbView view; |
240 |
293 |
241 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
294 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
242 |
295 |
262 CleanupStack::PushL(colSet); |
315 CleanupStack::PushL(colSet); |
263 |
316 |
264 |
317 |
265 view.UpdateL(); |
318 view.UpdateL(); |
266 |
319 |
267 view.SetColL(colSet->ColNo(KServiceType), static_cast<TUint>(aNewIndexType)); |
320 view.SetColL(colSet->ColNo(KServiceType), static_cast<TUint>(aNewIndexType)); |
268 |
321 view.SetColL(colSet->ColNo(KServiceIndex), aNewIndex); |
269 view.SetColL(colSet->ColNo(KServiceIndex), aNewIndex); |
322 view.SetColL(colSet->ColNo(KTunnelingTypeVendorId), aNewTunnelingType.get_vendor_id()); |
270 |
323 view.SetColL(colSet->ColNo(KTunnelingType), aNewTunnelingType.get_vendor_type()); |
271 view.SetColL(colSet->ColNo(KTunnelingType), aNewTunnelingVendorType); |
|
272 |
324 |
273 view.PutL(); |
325 view.PutL(); |
274 |
326 |
275 CleanupStack::PopAndDestroy(3); // view, colset, buf |
327 CleanupStack::PopAndDestroy(colSet); |
|
328 CleanupStack::PopAndDestroy(&view); |
|
329 CleanupStack::PopAndDestroy(buf); |
276 } |
330 } |
|
331 |
|
332 // ---------------------------------------------------------- |
277 |
333 |
278 void EapGtcDbUtils::SetConfigurationL( |
334 void EapGtcDbUtils::SetConfigurationL( |
279 RDbNamedDatabase& aDatabase, |
335 RDbNamedDatabase& aDatabase, |
280 const EAPSettings& aSettings, |
336 const EAPSettings& aSettings, |
281 const TIndexType aIndexType, |
337 const TIndexType aIndexType, |
282 const TInt aIndex, |
338 const TInt aIndex, |
283 const eap_type_value_e aTunnelingType) |
339 const eap_type_value_e aTunnelingType) |
284 { |
340 { |
285 #ifdef USE_EAP_EXPANDED_TYPES |
341 EAP_TRACE_DEBUG_SYMBIAN( |
286 |
342 (_L("EapGtcDbUtils::SetConfigurationL(): -Start- aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x\n"), |
287 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
343 aIndexType, |
288 |
344 aIndex, |
289 #else |
345 aTunnelingType.get_vendor_id(), |
290 |
346 aTunnelingType.get_vendor_type())); |
291 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
347 |
292 |
348 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapGtcDbUtils::SetConfigurationL()\n")); |
293 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
349 |
|
350 EAP_TRACE_SETTINGS(&aSettings); |
294 |
351 |
295 // Check if the settings are for the correct type |
352 // Check if the settings are for the correct type |
296 if (aSettings.iEAPType != EAPSettings::EEapGtc) |
353 if (aSettings.iEAPExpandedType != (*EapExpandedTypeGtc.GetType())) |
297 { |
354 { |
298 User::Leave(KErrNotSupported); |
355 User::Leave(KErrNotSupported); |
299 } |
356 } |
300 |
357 |
301 |
358 |
302 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
359 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
303 TPtr sqlStatement = buf->Des(); |
360 TPtr sqlStatement = buf->Des(); |
304 |
361 |
305 RDbView view; |
362 RDbView view; |
306 |
363 |
307 _LIT(KSQLQuery, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
364 _LIT(KSQLQuery, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
308 sqlStatement.Format(KSQLQuery, &KGtcTableName, |
365 |
309 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
366 sqlStatement.Format(KSQLQuery, |
|
367 &KGtcTableName, |
|
368 &KServiceType, |
|
369 aIndexType, |
|
370 &KServiceIndex, |
|
371 aIndex, |
|
372 &KTunnelingTypeVendorId, |
|
373 aTunnelingType.get_vendor_id(), |
|
374 &KTunnelingType, |
|
375 aTunnelingType.get_vendor_type()); |
310 |
376 |
311 // Evaluate view |
377 // Evaluate view |
312 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement))); |
378 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement))); |
313 |
379 |
314 CleanupClosePushL(view); |
380 CleanupClosePushL(view); |
349 |
415 |
350 TInt64 validityInMicro = (aSettings.iSessionValidityTime) * KMicroSecsInAMinute; |
416 TInt64 validityInMicro = (aSettings.iSessionValidityTime) * KMicroSecsInAMinute; |
351 |
417 |
352 view.SetColL(colSet->ColNo(cf_str_EAP_GTC_max_session_validity_time_literal), validityInMicro); |
418 view.SetColL(colSet->ColNo(cf_str_EAP_GTC_max_session_validity_time_literal), validityInMicro); |
353 } |
419 } |
354 |
420 |
355 // Last full authentication time should be made zero when EAP configurations are modified. |
421 // Last full authentication time should be made zero when EAP configurations are modified. |
356 // This makes sure that the next authentication with this EAP would be full authentication |
422 // This makes sure that the next authentication with this EAP would be full authentication |
357 // instead of reauthentication even if the session is still valid. |
423 // instead of reauthentication even if the session is still valid. |
358 |
424 |
359 view.SetColL(colSet->ColNo(KGTCLastFullAuthTime), default_FullAuthTime); |
425 view.SetColL(colSet->ColNo(KGTCLastFullAuthTime), default_FullAuthTime); |
360 |
426 |
361 EAP_TRACE_DEBUG_SYMBIAN((_L("Session Validity: EAP-Type=%d, Resetting Full Auth Time since settings are modified\n"), |
427 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::SetConfigurationL(): Session Validity: Resetting Full Auth Time since settings are modified\n"))); |
362 aSettings.iEAPType )); |
428 |
|
429 // Password existence. |
|
430 if (aSettings.iPasswordExistPresent |
|
431 && !aSettings.iPasswordExist) |
|
432 { |
|
433 // Clear password from database. |
|
434 view.SetColL(colSet->ColNo(cf_str_EAP_GTC_passcode_literal), KNullPasswordData); |
|
435 view.PutL(); |
|
436 view.SetColNullL(colSet->ColNo(cf_str_EAP_GTC_passcode_literal)); |
|
437 } |
|
438 |
|
439 // Password |
|
440 if (aSettings.iPasswordPresent) |
|
441 { |
|
442 // Validate length. |
|
443 if(aSettings.iPassword.Length() > KMaxPasswordLengthInDB) |
|
444 { |
|
445 // Password too long. Can not be stored in DB. |
363 |
446 |
|
447 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapGtcDbUtils::SetConfigurationL(): Too long Password. Length=%d \n"), |
|
448 aSettings.iPassword.Length())); |
|
449 |
|
450 User::Leave(KErrArgument); |
|
451 } |
|
452 |
|
453 // Length is ok. Set the value in DB. |
|
454 view.SetColL(colSet->ColNo(cf_str_EAP_GTC_passcode_literal), aSettings.iPassword); |
|
455 |
|
456 } |
|
457 |
|
458 if (aSettings.iShowPassWordPromptPresent) |
|
459 { |
|
460 // If password was supplied set password prompting off |
|
461 view.SetColL(colSet->ColNo(cf_str_EAP_GTC_passcode_prompt_literal), aSettings.iShowPassWordPrompt); |
|
462 } |
|
463 |
364 view.PutL(); |
464 view.PutL(); |
365 CleanupStack::PopAndDestroy(3); // view, colset, buf |
465 |
366 |
466 CleanupStack::PopAndDestroy(colSet); |
|
467 CleanupStack::PopAndDestroy(&view); |
|
468 CleanupStack::PopAndDestroy(buf); |
367 } |
469 } |
|
470 |
|
471 // ---------------------------------------------------------- |
368 |
472 |
369 void EapGtcDbUtils::GetConfigurationL( |
473 void EapGtcDbUtils::GetConfigurationL( |
370 RDbNamedDatabase& aDatabase, |
474 RDbNamedDatabase& aDatabase, |
371 EAPSettings& aSettings, |
475 EAPSettings& aSettings, |
372 const TIndexType aIndexType, |
476 const TIndexType aIndexType, |
373 const TInt aIndex, |
477 const TInt aIndex, |
374 const eap_type_value_e aTunnelingType) |
478 const eap_type_value_e aTunnelingType) |
375 { |
479 { |
376 #ifdef USE_EAP_EXPANDED_TYPES |
480 EAP_TRACE_DEBUG_SYMBIAN( |
377 |
481 (_L("EapGtcDbUtils::GetConfigurationL(): -Start- aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x\n"), |
378 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
482 aIndexType, |
379 |
483 aIndex, |
380 #else |
484 aTunnelingType.get_vendor_id(), |
381 |
485 aTunnelingType.get_vendor_type())); |
382 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
486 |
383 |
487 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapGtcDbUtils::GetConfigurationL()\n")); |
384 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
385 |
488 |
386 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
489 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
387 TPtr sqlStatement = buf->Des(); |
490 TPtr sqlStatement = buf->Des(); |
388 |
491 |
389 RDbView view; |
492 RDbView view; |
390 |
493 |
391 // Form the query |
494 // Form the query |
392 _LIT(KSQLQuery, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
495 _LIT(KSQLQuery, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
393 sqlStatement.Format(KSQLQuery, &KGtcTableName, |
496 |
394 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
497 sqlStatement.Format(KSQLQuery, |
|
498 &KGtcTableName, |
|
499 &KServiceType, |
|
500 aIndexType, |
|
501 &KServiceIndex, |
|
502 aIndex, |
|
503 &KTunnelingTypeVendorId, |
|
504 aTunnelingType.get_vendor_id(), |
|
505 &KTunnelingType, |
|
506 aTunnelingType.get_vendor_type()); |
395 |
507 |
396 // Evaluate view |
508 // Evaluate view |
397 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement))); |
509 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement))); |
398 |
510 |
399 CleanupClosePushL(view); |
511 CleanupClosePushL(view); |
406 |
518 |
407 // Get column set so we get the correct column numbers |
519 // Get column set so we get the correct column numbers |
408 CDbColSet* colSet = view.ColSetL(); |
520 CDbColSet* colSet = view.ColSetL(); |
409 CleanupStack::PushL(colSet); |
521 CleanupStack::PushL(colSet); |
410 |
522 |
411 aSettings.iEAPType = EAPSettings::EEapGtc; |
523 aSettings.iEAPExpandedType = *EapExpandedTypeGtc.GetType(); |
412 |
524 |
413 // Username |
525 // Username |
414 TPtrC username = view.ColDes(colSet->ColNo(cf_str_EAP_GTC_identity_literal)); |
526 TPtrC username = view.ColDes(colSet->ColNo(cf_str_EAP_GTC_identity_literal)); |
415 aSettings.iUsername.Copy(username); |
527 aSettings.iUsername.Copy(username); |
416 aSettings.iUsernamePresent = ETrue; |
528 aSettings.iUsernamePresent = ETrue; |
417 |
529 |
|
530 // Password existence. |
|
531 aSettings.iPasswordExistPresent = ETrue; |
|
532 aSettings.iPasswordExist = ! view.IsColNull(colSet->ColNo(cf_str_EAP_GTC_passcode_literal)); |
|
533 |
|
534 #if defined(USE_EAP_PASSWORD_READ_FROM_DATABASE) |
|
535 // Password |
|
536 TPtrC password = view.ColDes(colSet->ColNo(cf_str_EAP_GTC_passcode_literal)); |
|
537 aSettings.iPassword.Copy(password); |
|
538 aSettings.iPasswordPresent = ETrue; |
|
539 #else |
|
540 EAP_TRACE_DEBUG_SYMBIAN((_L("WARNING: EapGtcDbUtils::GetConfigurationL(): Password read is disabled\n"))); |
|
541 #endif //#if defined(USE_EAP_PASSWORD_READ_FROM_DATABASE) |
|
542 |
|
543 aSettings.iShowPassWordPromptPresent = ETrue; |
|
544 |
|
545 TUint aShow = view.ColUint(colSet->ColNo(cf_str_EAP_GTC_passcode_prompt_literal)); |
|
546 if(aShow == EEapDbFalse) |
|
547 { |
|
548 aSettings.iShowPassWordPrompt = EFalse; |
|
549 } |
|
550 else |
|
551 { |
|
552 aSettings.iShowPassWordPrompt = ETrue; |
|
553 } |
|
554 |
418 // Session validity time |
555 // Session validity time |
419 TInt64 maxSessionTimeMicro = view.ColInt64(colSet->ColNo(cf_str_EAP_GTC_max_session_validity_time_literal)); |
556 TInt64 maxSessionTimeMicro = view.ColInt64(colSet->ColNo(cf_str_EAP_GTC_max_session_validity_time_literal)); |
420 |
557 |
421 // Convert the time to minutes. |
558 // Convert the time to minutes. |
422 TInt64 maxSessionTimeMin = maxSessionTimeMicro / KMicroSecsInAMinute; |
559 TInt64 maxSessionTimeMin = maxSessionTimeMicro / KMicroSecsInAMinute; |
423 |
560 |
424 aSettings.iSessionValidityTime = static_cast<TUint>(maxSessionTimeMin); |
561 aSettings.iSessionValidityTime = static_cast<TUint>(maxSessionTimeMin); |
425 aSettings.iSessionValidityTimePresent = ETrue; |
562 aSettings.iSessionValidityTimePresent = ETrue; |
426 |
563 |
427 CleanupStack::PopAndDestroy(3); // view, colset, buf |
564 CleanupStack::PopAndDestroy(colSet); |
|
565 CleanupStack::PopAndDestroy(&view); |
|
566 CleanupStack::PopAndDestroy(buf); |
|
567 |
|
568 EAP_TRACE_SETTINGS(&aSettings); |
428 } |
569 } |
|
570 |
|
571 // ---------------------------------------------------------- |
429 |
572 |
430 void EapGtcDbUtils::CopySettingsL( |
573 void EapGtcDbUtils::CopySettingsL( |
431 RDbNamedDatabase& aDatabase, |
574 RDbNamedDatabase& aDatabase, |
432 const TIndexType aSrcIndexType, |
575 const TIndexType aSrcIndexType, |
433 const TInt aSrcIndex, |
576 const TInt aSrcIndex, |
434 const eap_type_value_e aSrcTunnelingType, |
577 const eap_type_value_e aSrcTunnelingType, |
435 const TIndexType aDestIndexType, |
578 const TIndexType aDestIndexType, |
436 const TInt aDestIndex, |
579 const TInt aDestIndex, |
437 const eap_type_value_e aDestTunnelingType) |
580 const eap_type_value_e aDestTunnelingType) |
438 { |
581 { |
439 #ifdef USE_EAP_EXPANDED_TYPES |
582 EAP_TRACE_DEBUG_SYMBIAN( |
440 |
583 (_L("EapGtcDbUtils::CopySettingsL(): -Start- aSrcIndexType=%d, aSrcIndex=%d, aSrcTunnelingType=0xfe%06x%08x\n"), |
441 TUint aSrcTunnelingVendorType = aSrcTunnelingType.get_vendor_type(); |
584 aSrcIndexType, |
442 TUint aDestTunnelingVendorType = aDestTunnelingType.get_vendor_type(); |
585 aSrcIndex, |
443 |
586 aSrcTunnelingType.get_vendor_id(), |
444 #else |
587 aSrcTunnelingType.get_vendor_type())); |
445 |
588 |
446 TUint aSrcTunnelingVendorType = static_cast<TUint>(aSrcTunnelingType); |
589 EAP_TRACE_DEBUG_SYMBIAN( |
447 TUint aDestTunnelingVendorType = static_cast<TUint>(aDestTunnelingType); |
590 (_L("EapGtcDbUtils::CopySettingsL(): -Start- aDestIndexType=%d, aDestTunnelingType=0xfe%06x%08x\n"), |
448 |
591 aDestIndexType, |
449 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
592 aDestIndex, |
|
593 aDestTunnelingType.get_vendor_id(), |
|
594 aDestTunnelingType.get_vendor_type())); |
|
595 |
|
596 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapGtcDbUtils::CopySettingsL()\n")); |
450 |
597 |
451 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
598 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
452 TPtr sqlStatement = buf->Des(); |
599 TPtr sqlStatement = buf->Des(); |
453 |
600 |
454 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
601 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
455 |
602 |
456 sqlStatement.Format(KSQL, &KGtcTableName, |
603 sqlStatement.Format(KSQL, |
457 &KServiceType, aSrcIndexType, &KServiceIndex, aSrcIndex, &KTunnelingType, aSrcTunnelingVendorType); |
604 &KGtcTableName, |
|
605 &KServiceType, |
|
606 aSrcIndexType, |
|
607 &KServiceIndex, |
|
608 aSrcIndex, |
|
609 &KTunnelingTypeVendorId, |
|
610 aSrcTunnelingType.get_vendor_id(), |
|
611 &KTunnelingType, |
|
612 aSrcTunnelingType.get_vendor_type()); |
458 |
613 |
459 RDbView view; |
614 RDbView view; |
460 |
615 |
461 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
616 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
462 |
617 |
483 CDbColSet* colSet = view.ColSetL(); |
638 CDbColSet* colSet = view.ColSetL(); |
484 |
639 |
485 CleanupStack::PushL(colSet); |
640 CleanupStack::PushL(colSet); |
486 |
641 |
487 view.SetColL(colSet->ColNo(KServiceType), static_cast<TUint>(aDestIndexType)); |
642 view.SetColL(colSet->ColNo(KServiceType), static_cast<TUint>(aDestIndexType)); |
488 |
|
489 view.SetColL(colSet->ColNo(KServiceIndex), aDestIndex); |
643 view.SetColL(colSet->ColNo(KServiceIndex), aDestIndex); |
490 |
644 view.SetColL(colSet->ColNo(KTunnelingTypeVendorId), aDestTunnelingType.get_vendor_id()); |
491 view.SetColL(colSet->ColNo(KTunnelingType), aDestTunnelingVendorType); |
645 view.SetColL(colSet->ColNo(KTunnelingType), aDestTunnelingType.get_vendor_type()); |
492 |
646 |
493 view.PutL(); |
647 view.PutL(); |
494 |
648 |
495 CleanupStack::PopAndDestroy(3); // view, colset, buf |
649 CleanupStack::PopAndDestroy(colSet); |
|
650 CleanupStack::PopAndDestroy(&view); |
|
651 CleanupStack::PopAndDestroy(buf); |
496 } |
652 } |
|
653 |
|
654 // ---------------------------------------------------------- |
497 |
655 |
498 void EapGtcDbUtils::DeleteConfigurationL( |
656 void EapGtcDbUtils::DeleteConfigurationL( |
499 const TIndexType aIndexType, |
657 const TIndexType aIndexType, |
500 const TInt aIndex, |
658 const TInt aIndex, |
501 const eap_type_value_e aTunnelingType) |
659 const eap_type_value_e aTunnelingType) |
502 { |
660 { |
503 #ifdef USE_EAP_EXPANDED_TYPES |
661 EAP_TRACE_DEBUG_SYMBIAN( |
504 |
662 (_L("EapGtcDbUtils::DeleteConfigurationL(): -Start- aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x\n"), |
505 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
663 aIndexType, |
506 |
664 aIndex, |
507 #else |
665 aTunnelingType.get_vendor_id(), |
508 |
666 aTunnelingType.get_vendor_type())); |
509 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
667 |
510 |
668 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapGtcDbUtils::DeleteConfigurationL()\n")); |
511 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
669 |
512 |
670 RDbNamedDatabase aDatabase; |
513 RDbs session; |
671 RFs aFileServerSession; |
514 RDbNamedDatabase database; |
672 |
515 // Connect to the DBMS server. |
673 TInt error(KErrNone); |
516 User::LeaveIfError(session.Connect()); |
674 TFileName aPrivateDatabasePathName; |
517 CleanupClosePushL(session); |
675 |
518 |
676 EapPluginTools::CreateDatabaseLC( |
519 #ifdef SYMBIAN_SECURE_DBMS |
677 aDatabase, |
520 |
678 aFileServerSession, |
521 // Create the secure shared database with the specified secure policy. |
679 error, |
522 // Database will be created in the data caging path for DBMS (C:\private\100012a5). |
680 KEapGtcDatabaseName, |
523 |
681 aPrivateDatabasePathName); |
524 TInt err = database.Create(session, KGtcDatabaseName, KGtcSecureUIDFormat); |
682 |
525 |
683 if(error == KErrNone) |
526 if(err == KErrNone) |
|
527 { |
684 { |
528 // Database was created so it was empty. No need for further actions. |
685 // Database was created so it was empty. No need for further actions. |
529 database.Destroy(); |
686 aDatabase.Destroy(); |
530 CleanupStack::PopAndDestroy(); |
687 CleanupStack::PopAndDestroy(&aDatabase); |
|
688 CleanupStack::PopAndDestroy(&aFileServerSession); |
531 return; |
689 return; |
532 |
690 } |
533 } |
691 else if (error != KErrAlreadyExists) |
534 else if (err != KErrAlreadyExists) |
692 { |
535 { |
693 User::LeaveIfError(error); |
536 User::LeaveIfError(err); |
694 } |
537 } |
695 |
538 |
696 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::DeleteConfigurationL(): - calls aDatabase.Open()\n"))); |
539 // Database existed, open it. |
697 |
540 User::LeaveIfError(database.Open(session, KGtcDatabaseName, KGtcSecureUIDFormat)); |
698 error = aDatabase.Open(aFileServerSession, aPrivateDatabasePathName); |
541 CleanupClosePushL(database); |
699 |
542 |
700 EAP_TRACE_DEBUG_SYMBIAN((_L("EapGtcDbUtils::DeleteConfigurationL(): - Opened private DB for EAP-GTC. error=%d\n"), error)); |
543 #else |
701 |
544 // For non-secured database. The database will be created in the old location (c:\system\data). |
702 User::LeaveIfError(error); |
545 |
|
546 RFs fsSession; |
|
547 User::LeaveIfError(fsSession.Connect()); |
|
548 CleanupClosePushL(fsSession); |
|
549 TInt err = database.Create(fsSession, KGtcDatabaseName); |
|
550 |
|
551 if(err == KErrNone) |
|
552 { |
|
553 // Database was created so it was empty. No need for further actions. |
|
554 database.Destroy(); |
|
555 CleanupStack::PopAndDestroy(2); // fsSession, database session |
|
556 return; |
|
557 |
|
558 } |
|
559 else if (err != KErrAlreadyExists) |
|
560 { |
|
561 User::LeaveIfError(err); |
|
562 } |
|
563 |
|
564 CleanupStack::PopAndDestroy(); // close fsSession |
|
565 |
|
566 User::LeaveIfError(database.Open(session, KGtcDatabaseName)); |
|
567 CleanupClosePushL(database); |
|
568 |
|
569 #endif // #ifdef SYMBIAN_SECURE_DBMS |
|
570 |
703 |
571 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
704 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
572 TPtr sqlStatement = buf->Des(); |
705 TPtr sqlStatement = buf->Des(); |
573 |
706 |
574 // Main settings table |
707 // Main settings table |
575 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
708 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
576 sqlStatement.Format(KSQL, &KGtcTableName, |
709 |
577 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
710 sqlStatement.Format(KSQL, |
|
711 &KGtcTableName, |
|
712 &KServiceType, |
|
713 aIndexType, |
|
714 &KServiceIndex, |
|
715 aIndex, |
|
716 &KTunnelingTypeVendorId, |
|
717 aTunnelingType.get_vendor_id(), |
|
718 &KTunnelingType, |
|
719 aTunnelingType.get_vendor_type()); |
|
720 |
578 // Evaluate view |
721 // Evaluate view |
579 RDbView view; |
722 RDbView view; |
580 User::LeaveIfError(view.Prepare(database,TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
723 User::LeaveIfError(view.Prepare(aDatabase,TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
581 CleanupClosePushL(view); |
724 CleanupClosePushL(view); |
582 User::LeaveIfError(view.EvaluateAll()); |
725 User::LeaveIfError(view.EvaluateAll()); |
583 |
726 |
584 // Delete rows |
727 // Delete rows |
585 if (view.FirstL()) |
728 if (view.FirstL()) |