|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Comms Database Connection Preferences Table View definitions |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @deprecated since v9.1. Functionality is replaced with commsdat. |
|
21 */ |
|
22 |
|
23 #include <cdbtemp.h> |
|
24 #include <cdbpreftable.h> |
|
25 #include "CDBSTD.H" |
|
26 #include "commdb_impl.H" |
|
27 #include "Commsdat_Log.h" |
|
28 |
|
29 class TCommDbCommonBearerInfo |
|
30 /** |
|
31 @internalComponent |
|
32 */ |
|
33 { |
|
34 public: |
|
35 TUint32 iBearerSet; |
|
36 TBool iBearerSetExists; |
|
37 TUint32 iIapId; |
|
38 TBool iIapIdExists; |
|
39 }; |
|
40 |
|
41 // TCommDbIapBearer and TCommDbIapConnectionPref definitions |
|
42 |
|
43 |
|
44 EXPORT_C CCommsDbConnectionPrefTableView::TCommDbIapBearer::TCommDbIapBearer() : |
|
45 iBearerSet(0), iIapId(0) |
|
46 /** Default constructor. |
|
47 All member data is initialised to zero. */ |
|
48 { |
|
49 } |
|
50 |
|
51 EXPORT_C CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref::TCommDbIapConnectionPref() : |
|
52 iRanking(0), iDirection(ECommDbConnectionDirectionUnknown), |
|
53 iDialogPref(ECommDbDialogPrefUnknown), iBearer() |
|
54 /** Default constructor. |
|
55 The rank is set to 0, and the direction and dialog preference to unknown. */ |
|
56 { |
|
57 } |
|
58 |
|
59 EXPORT_C TBool CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref::operator==(const TCommDbIapConnectionPref& aPref) const |
|
60 /** Overloaded equality operator. |
|
61 Checks for equality between 'this' and another TCommDbIapConnectionPref object passed in. |
|
62 |
|
63 @param aPref Object to compare. |
|
64 @return ETrue if all fields in the objects are equal, otherwise EFalse. */ |
|
65 { |
|
66 return (aPref.iRanking == iRanking && |
|
67 aPref.iDirection == iDirection && |
|
68 aPref.iDialogPref == iDialogPref && |
|
69 aPref.iBearer.iBearerSet == iBearer.iBearerSet && |
|
70 aPref.iBearer.iIapId == iBearer.iIapId); |
|
71 } |
|
72 |
|
73 |
|
74 EXPORT_C CCommsDbConnectionPrefTableView::TCommDbIspBearer::TCommDbIspBearer() |
|
75 /** |
|
76 Framework left in place for 6.1BC purposes. |
|
77 */ |
|
78 { |
|
79 } |
|
80 |
|
81 |
|
82 EXPORT_C CCommsDbConnectionPrefTableView::TCommDbIspConnectionPref::TCommDbIspConnectionPref() : |
|
83 iBearer() |
|
84 /** |
|
85 Framework left in place for 6.1BC purposes. |
|
86 */ |
|
87 { |
|
88 } |
|
89 |
|
90 |
|
91 EXPORT_C TBool CCommsDbConnectionPrefTableView::TCommDbIspConnectionPref::operator==(const TCommDbIspConnectionPref& /*aPref*/) const |
|
92 /** |
|
93 * Check for equality between 'this' and another TCommDbIspConnectionPref object passed in. |
|
94 * Framework letf in place for 6.1BC purposes. Returns KErrNotSupported only. |
|
95 * @param aPref Preferences. |
|
96 * @return KErrNotSupported Function has been deprecated therefore always return with this error. |
|
97 */ |
|
98 { |
|
99 return KErrNotSupported; |
|
100 } |
|
101 |
|
102 /** |
|
103 CCommsDbConnectionPrefTableView definitions |
|
104 */ |
|
105 |
|
106 CCommsDbConnectionPrefTableView* CCommsDbConnectionPrefTableView::NewLC(CCommsDatabase& /*aDb*/, const TDbQuery& /*aQuery*/) |
|
107 /** Create a view. Usually, however, views are created by calling one of the |
|
108 CCommsDatabase::OpenConnectionPrefTable*LC() functions. |
|
109 |
|
110 @deprecated This method is deprecated from 9.1 and always returns/leaves with KErrNotSupported instead of describing past operation/parameters. |
|
111 @param aDb reference to the database to use. |
|
112 @param aQuery Query to preform |
|
113 @return Reference to the new CCommsDbConnectionPrefTableView. */ |
|
114 { |
|
115 User::Leave(KErrNotSupported); |
|
116 return NULL; |
|
117 } |
|
118 CCommsDbConnectionPrefTableView* CCommsDbConnectionPrefTableView::NewLC(CCommsDatabase& aDb, TCommDbConnectionDirection aDirection, TBool aSortRanking) |
|
119 /** Create a view. Usually, however, views are created by calling one of the |
|
120 CCommsDatabase::OpenConnectionPrefTable*LC() functions. |
|
121 |
|
122 @param aDb reference to the database to use. |
|
123 @param aDirection |
|
124 @param aSortRanking -> ETrue Sort by ranking, EFalse not sorted |
|
125 @return Reference to the new CCommsDbConnectionPrefTableView. */ |
|
126 { |
|
127 CCommsDbConnectionPrefTableView* self = new(ELeave) CCommsDbConnectionPrefTableView(aDb); |
|
128 CleanupStack::PushL(self); |
|
129 self->ConstructL(aDirection, aSortRanking); |
|
130 // register view in Database |
|
131 aDb.iImpl->RegisterConnPrefViewL(self); |
|
132 return self; |
|
133 } |
|
134 |
|
135 CCommsDbConnectionPrefTableView* CCommsDbConnectionPrefTableView::NewL(CCommsDatabase& aDb, TCommDbConnectionDirection aDirection, TUint32 aRank) |
|
136 /** Create a view. Usually, however, views are created by calling one of the |
|
137 CCommsDatabase::OpenConnectionPrefTable*LC() functions. |
|
138 |
|
139 @param aDb reference to the database to use. |
|
140 @param aDirection |
|
141 @param aRank |
|
142 @return Reference to the new CCommsDbConnectionPrefTableView. */ |
|
143 { |
|
144 CCommsDbConnectionPrefTableView* self = new(ELeave) CCommsDbConnectionPrefTableView(aDb); |
|
145 CleanupStack::PushL(self); |
|
146 TRAPD(err,self->ConstructL(aDirection, aRank)); |
|
147 if(err == KErrNotFound) |
|
148 { |
|
149 __FLOG_STATIC0(KLogComponent, KCommDbShim, _L("CCommsDbConnectionPrefTableView::NewL is leaving with KErrOverflow")); |
|
150 err = KErrOverflow; |
|
151 } |
|
152 User::LeaveIfError(err); |
|
153 |
|
154 // register view in Database |
|
155 aDb.iImpl->RegisterConnPrefViewL(self); |
|
156 CleanupStack::Pop(self); |
|
157 return self; |
|
158 } |
|
159 |
|
160 CCommsDbConnectionPrefTableView::CCommsDbConnectionPrefTableView(CCommsDatabase& aDb) |
|
161 : iDb(aDb) |
|
162 /** |
|
163 Constructor |
|
164 |
|
165 @param aDb reference to the database to use. |
|
166 */ |
|
167 { |
|
168 } |
|
169 |
|
170 void CCommsDbConnectionPrefTableView::ConstructL(const TDbQuery& /*aQuery*/) |
|
171 /** |
|
172 Prepares and evaluates the table view using the SQL query aQuery |
|
173 |
|
174 @deprecated This method is deprecated from 9.1 and always returns/leaves with KErrNotSupported instead of describing past operation/parameters. |
|
175 |
|
176 @param aQuery Query to perform |
|
177 */ |
|
178 { |
|
179 User::Leave(KErrNotSupported); |
|
180 } |
|
181 |
|
182 void CCommsDbConnectionPrefTableView::ConstructL(TCommDbConnectionDirection aDirection, TBool aSortRanking) |
|
183 /** |
|
184 Creates RecordSet Container and loads date to it. |
|
185 |
|
186 @param aDirection |
|
187 @param aSortRanking |
|
188 */ |
|
189 { |
|
190 CMDBSession* dbSession = iDb.iImpl->iDbs; |
|
191 // create RecordSet object and save a pointer within CTableViewExtension |
|
192 iTableExt = CCommDbTableExtension::NewL(); |
|
193 |
|
194 // object will be deleted by CTableViewExtension object |
|
195 CMDBRecordSet<CCDConnectionPrefsRecord>* connPrefRecordSet = new(ELeave) CMDBRecordSet<CCDConnectionPrefsRecord>(KCDTIdConnectionPrefsRecord); |
|
196 CleanupStack::PushL(connPrefRecordSet); |
|
197 |
|
198 if(aDirection == ECommDbConnectionDirectionUnknown) |
|
199 { |
|
200 // Load all records regardless of direction |
|
201 TRAPD(err,connPrefRecordSet->LoadL(*dbSession)); |
|
202 if((err != KErrNotFound) && (err != KErrNone)) |
|
203 { |
|
204 __FLOG_STATIC2(KLogComponent, KCommDbShim, _L("Connection Preferences Table constructed Direction:%d, Sorted rank: %b, returned Err:%d"), |
|
205 aDirection, aSortRanking); |
|
206 User::Leave(err); |
|
207 } |
|
208 |
|
209 __FLOG_STATIC3(KLogComponent, KCommDbShim, _L("Connection Preferences Table constructed Direction:%d, Sorted rank: %b, returned Err:%d"), |
|
210 aDirection, aSortRanking, err); |
|
211 } |
|
212 else |
|
213 { |
|
214 // Search per direction |
|
215 TBool ret(EFalse); |
|
216 |
|
217 // create 0 record for priming |
|
218 CCDConnectionPrefsRecord* connPrefRecord = static_cast<CCDConnectionPrefsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdConnectionPrefsRecord)); |
|
219 CleanupStack::PushL(connPrefRecord); |
|
220 |
|
221 // prime |
|
222 connPrefRecord->iDirection = aDirection; |
|
223 |
|
224 // add record to record set |
|
225 connPrefRecordSet->iRecords.AppendL(connPrefRecord); |
|
226 |
|
227 CleanupStack::Pop(connPrefRecord); |
|
228 |
|
229 // Load record |
|
230 TRAPD(err, ret = connPrefRecordSet->FindL(*dbSession)); |
|
231 |
|
232 if(err != KErrNone) |
|
233 { |
|
234 __FLOG_STATIC3(KLogComponent, KCommDbShim, _L("Connection Preferences Table constructed Direction:%d, Sorted rank: %b, returned Err:%d"), |
|
235 aDirection, aSortRanking, err); |
|
236 // error is returned back |
|
237 User::Leave(err); |
|
238 } |
|
239 |
|
240 // check if anything is returned back |
|
241 if(!ret) |
|
242 { |
|
243 // remove primed record from the record set |
|
244 connPrefRecordSet->iRecords.ResetAndDestroy(); |
|
245 __FLOG_STATIC2(KLogComponent, KCommDbShim, _L("Table: ConnectionPreference with Direction:%d, SortedByRanking:%b is empty"), aDirection, aSortRanking); |
|
246 } |
|
247 } |
|
248 |
|
249 CleanupStack::Pop(connPrefRecordSet); |
|
250 |
|
251 iTableExt->SetRecordSet(connPrefRecordSet); |
|
252 |
|
253 if (aSortRanking) |
|
254 { |
|
255 iTableExt->SortByRank(); |
|
256 } |
|
257 } |
|
258 |
|
259 void CCommsDbConnectionPrefTableView::ConstructL(TCommDbConnectionDirection aDirection, TUint32 aRank) |
|
260 /** |
|
261 Prepares and evaluates the table view using params |
|
262 |
|
263 @param aDirection |
|
264 @param aRank |
|
265 */ |
|
266 { |
|
267 TBool ret(EFalse); |
|
268 // create RecordSet object and save a pointer within CTableViewExtension |
|
269 iTableExt = CCommDbTableExtension::NewL(); |
|
270 // object will be deleted by CTableViewExtension object |
|
271 CMDBRecordSet<CCDConnectionPrefsRecord>* connPrefRecordSet = new(ELeave) CMDBRecordSet<CCDConnectionPrefsRecord>(KCDTIdConnectionPrefsRecord); |
|
272 CleanupStack::PushL(connPrefRecordSet); |
|
273 |
|
274 // create 0 record for priming |
|
275 CCDConnectionPrefsRecord* connPrefRecord = static_cast<CCDConnectionPrefsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdConnectionPrefsRecord)); |
|
276 CleanupStack::PushL(connPrefRecord); |
|
277 |
|
278 // prime |
|
279 connPrefRecord->iDirection = aDirection; |
|
280 connPrefRecord->iRanking = aRank; |
|
281 |
|
282 // add record to record set |
|
283 connPrefRecordSet->iRecords.AppendL(connPrefRecord); |
|
284 CleanupStack::Pop(connPrefRecord); |
|
285 |
|
286 // Load record |
|
287 TRAPD(err, ret = connPrefRecordSet->FindL(*iDb.iImpl->iDbs)); |
|
288 |
|
289 if(err != KErrNone) |
|
290 { |
|
291 __FLOG_STATIC3(KLogComponent, KCommDbShim, _L("Connection Preferences Table constructed with Ranking: %d and Direction:%d returned Err:%d"), |
|
292 aRank, aDirection, err); |
|
293 // error is returned back |
|
294 User::Leave(err); |
|
295 } |
|
296 |
|
297 // check if anything is returned back |
|
298 if(!ret) |
|
299 { |
|
300 __FLOG_STATIC2(KLogComponent, KCommDbShim, _L("Table: ConnectionPreference with Direction:%d, Rank:%d is empty"), aDirection, aRank); |
|
301 User::Leave(KErrNotFound); |
|
302 } |
|
303 |
|
304 iTableExt->SetRecordSet(connPrefRecordSet); |
|
305 |
|
306 CleanupStack::Pop(connPrefRecordSet); |
|
307 } |
|
308 |
|
309 EXPORT_C CCommsDbConnectionPrefTableView::~CCommsDbConnectionPrefTableView() |
|
310 /** Destructor.*/ |
|
311 { |
|
312 delete iTableExt; |
|
313 iDb.iImpl->UnRegisterConnPrefView(this); |
|
314 } |
|
315 |
|
316 |
|
317 EXPORT_C void CCommsDbConnectionPrefTableView::InsertConnectionPreferenceL(const TCommDbIapConnectionPref& aPref, TBool aReadOnly) |
|
318 /** Inserts a new IAP connection preference into the connetion preference table. |
|
319 The supplied `aPref` is checked to ensure that the rank and direction |
|
320 do not conflict with existing records. The dialog option, bearer set |
|
321 and IAP are checked for consistancy. |
|
322 Deprecated in 7.0 but re-instated to accommodate 6.1 BC |
|
323 |
|
324 @param aPref Settings for the new connection preference. |
|
325 @param aReadOnly If ETrue the record is set to be read-only. If left unspecified the default is EFalse. |
|
326 @capability Dependent on table, see the guide page referenced below. |
|
327 */ |
|
328 { |
|
329 CMDBSession* dbSession = iDb.iImpl->iDbs; |
|
330 CCDConnectionPrefsRecord* connPrefRecord = static_cast<CCDConnectionPrefsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdConnectionPrefsRecord)); |
|
331 |
|
332 connPrefRecord->SetRecordId(KCDNewRecordRequest); |
|
333 connPrefRecord->iDirection = aPref.iDirection; |
|
334 connPrefRecord->iRanking = aPref.iRanking; |
|
335 connPrefRecord->iDialogPref = aPref.iDialogPref; |
|
336 connPrefRecord->iBearerSet = aPref.iBearer.iBearerSet; |
|
337 connPrefRecord->iDefaultIAP = aPref.iBearer.iIapId; |
|
338 |
|
339 CMDBRecordSetBase* recordSet = iTableExt->GetRecordSetL(); |
|
340 |
|
341 if ( recordSet->IsSetAttribute(ECDNoWriteButDelete) || |
|
342 recordSet->IsSetAttribute(ECDProtectedWrite) ) |
|
343 { |
|
344 __FLOG_STATIC5(KLogComponent, KCommDbShim, _L("InsertConnectionPreferenceL -> TableName=ConnectionPreferences, Ranking=%d, Direction=%d, DialogPref=%d, Bearer=%d, ReadOnly=%b") |
|
345 , aPref.iRanking, aPref.iDirection, aPref.iDialogPref, aPref.iBearer.iBearerSet, aReadOnly); |
|
346 User::Leave(KErrAccessDenied); |
|
347 } |
|
348 |
|
349 if(aReadOnly) |
|
350 { |
|
351 connPrefRecord->SetAttributes(ECDNoWriteButDelete); |
|
352 dbSession->SetAttributeMask(ECDNoWriteButDelete); |
|
353 } |
|
354 |
|
355 iTableExt->InsertConnPrefRecordL(connPrefRecord, *dbSession); |
|
356 |
|
357 if (aReadOnly) |
|
358 { |
|
359 dbSession->ClearAttributeMask(ECDNoWriteButDelete); |
|
360 } |
|
361 |
|
362 __FLOG_STATIC5(KLogComponent, KCommDbShim, _L("InsertConnectionPreferenceL -> TableName=ConnectionPreferences, Ranking=%d, Direction=%d, DialogPref=%d, Bearer=%d, ReadOnly=%b") |
|
363 , aPref.iRanking, aPref.iDirection, aPref.iDialogPref, aPref.iBearer.iBearerSet, aReadOnly); |
|
364 |
|
365 } |
|
366 |
|
367 EXPORT_C void CCommsDbConnectionPrefTableView::InsertConnectionPreferenceL(const TCommDbIspConnectionPref& /*aPref*/, TBool /*aReadOnly*/) |
|
368 /** |
|
369 * Override version of InsertConnectionPreferenceL for BC purposes. |
|
370 * @param aPref Preferences. |
|
371 * @param aReadOnly Read only? |
|
372 * @deprecated This method is deprecated from 9.1 and always returns/leaves with KErrNotSupported instead of describing past operation/parameters. |
|
373 * |
|
374 */ |
|
375 { |
|
376 User::Leave(KErrNotSupported); |
|
377 } |
|
378 |
|
379 EXPORT_C void CCommsDbConnectionPrefTableView::UpdateBearerL(const TCommDbIapBearer& aUpdate, TBool aReadOnly) |
|
380 /** Update the bearer set and IAP for the currently selected IAP connection |
|
381 preference record. The dialog option, bearer set and IAP are checked for |
|
382 consistancy. |
|
383 Deprecated in 7.0 but re-instated to accomodate 6.1 BC. |
|
384 Update the bearer set and iap for the currently selected connection preference. |
|
385 The dialog option, bearer set and IAP are checked for consistancy. The function sets the bearer set |
|
386 (CONNECT_PREF_BEARER_SET) and IAP (CONNECT_PREF_IAP) fields. The direction field (CONNECTION_PREF_DIRECTION) |
|
387 cannot be altered after it has been written to the record. |
|
388 @param aUpdate Updated settings for the connection preference. Note that all fields need to be set, |
|
389 including any unchanged fields. |
|
390 @param aReadOnly If true, the record is set to be read-only. If unspecified, EFalse by default. |
|
391 @leave KErrAccessDenied The record cannot be updated as it is read-only; |
|
392 KErrArgument The specified IAP (aPref.iBearer.iIapId) cannot be used, as it does not fall in the bearer set |
|
393 defined by aPref.iBearer.iBearerSet and have the same direction as aPref.iDirection; |
|
394 KErrNotFound There is no current record in the view. |
|
395 @capability Dependent on table, see the guide page referenced below. |
|
396 */ |
|
397 { |
|
398 CMDBSession* dbSession = iDb.iImpl->iDbs; |
|
399 CMDBRecordBase* currentRecord = iTableExt->GetCurrentRecordL(); |
|
400 CCDConnectionPrefsRecord* conPref = static_cast<CCDConnectionPrefsRecord*>(currentRecord); |
|
401 conPref->iBearerSet = aUpdate.iBearerSet; |
|
402 conPref->iDefaultIAP = aUpdate.iIapId; |
|
403 |
|
404 |
|
405 if ( currentRecord->IsSetAttribute(ECDNoWriteButDelete) || |
|
406 currentRecord->IsSetAttribute(ECDProtectedWrite) ) |
|
407 { |
|
408 __FLOG_STATIC0(KLogComponent, KCommDbShim, _L("CCommsDbConnectionPrefTableView::UpdateBearerL is leaving with KErrAccessDenied")); |
|
409 User::Leave(KErrAccessDenied); |
|
410 } |
|
411 |
|
412 if(aReadOnly) |
|
413 { |
|
414 currentRecord->SetAttributes(ECDNoWriteButDelete); |
|
415 dbSession->SetAttributeMask(ECDNoWriteButDelete); |
|
416 } |
|
417 |
|
418 // modify record |
|
419 currentRecord->ModifyL(*dbSession); |
|
420 |
|
421 if (aReadOnly) |
|
422 { |
|
423 dbSession->ClearAttributeMask(ECDNoWriteButDelete); |
|
424 } |
|
425 |
|
426 __FLOG_STATIC3(KLogComponent, KCommDbShim, _L("UpdateBearerL -> TableName=ConnectionPreferences, Bearer=%d, IAP=%d, ReadOnly=%b") |
|
427 , aUpdate.iBearerSet, aUpdate.iIapId, aReadOnly); |
|
428 } |
|
429 |
|
430 EXPORT_C void CCommsDbConnectionPrefTableView::UpdateBearerL(const TCommDbIspBearer& /*aUpdate*/, TBool /*aReadOnly*/) |
|
431 /** |
|
432 * Override version of UpdateBearerL for BC purposes. |
|
433 * @deprecated This method is deprecated from 9.1 and always returns/leaves with KErrNotSupported instead of describing past operation/parameters. |
|
434 |
|
435 * @param aUpdate Update. |
|
436 * @param aReadOnly Read only? |
|
437 * @return KErrNotSupported. |
|
438 */ |
|
439 |
|
440 { |
|
441 User::Leave(KErrNotSupported); |
|
442 } |
|
443 |
|
444 EXPORT_C void CCommsDbConnectionPrefTableView::ReadConnectionPreferenceL(TCommDbIapConnectionPref& aPref) |
|
445 /** Gets the IAP connection preferences record currently selected in the view. |
|
446 |
|
447 @param aPref On return, the connection preferences |
|
448 @leave KErrNotFound There is no current record in the view |
|
449 @leave KErrUnknown A field in the connection preference record is null |
|
450 @capability Dependent on table, see the guide page referenced below. */ |
|
451 { |
|
452 CMDBRecordBase* currentRecord = iTableExt->GetCurrentRecordL(); |
|
453 CCDConnectionPrefsRecord* connPref = (static_cast<CCDConnectionPrefsRecord*>(currentRecord)); |
|
454 |
|
455 if (connPref->iDirection.IsNull() |
|
456 || connPref->iRanking.IsNull() |
|
457 || connPref->iDialogPref.IsNull() |
|
458 || connPref->iBearerSet.IsNull() ) |
|
459 { |
|
460 __FLOG_STATIC0(KLogComponent, KCommDbShim, _L("ReadConnectionPreferenceL is Leaving with KErrUnknown (One of the field has NULL value)")); |
|
461 User::Leave(KErrUnknown); |
|
462 } |
|
463 |
|
464 TInt dialogPref = connPref->iDialogPref; |
|
465 |
|
466 aPref.iDirection = connPref->iDirection; |
|
467 aPref.iRanking = connPref->iRanking; |
|
468 aPref.iDialogPref = static_cast<TCommDbDialogPref>(dialogPref); |
|
469 aPref.iBearer.iBearerSet = connPref->iBearerSet; |
|
470 aPref.iBearer.iIapId = connPref->iDefaultIAP; |
|
471 |
|
472 |
|
473 __FLOG_STATIC4(KLogComponent, KCommDbShim, _L("ReadConnectionPreferenceL -> TableName=ConnectionPreferences, Ranking=%d, Direction=%d, DialogPref=%d, Bearer=%d") |
|
474 , aPref.iRanking, aPref.iDirection, aPref.iDialogPref, aPref.iBearer.iBearerSet); |
|
475 } |
|
476 |
|
477 EXPORT_C void CCommsDbConnectionPrefTableView::ReadConnectionPreferenceL(TCommDbIspConnectionPref& /*aPref*/) |
|
478 /**@deprecated in v7.0 |
|
479 |
|
480 Framework left to support BC with v6.1 |
|
481 @leave KErrNotSupported |
|
482 */ |
|
483 { |
|
484 User::Leave(KErrNotSupported); |
|
485 } |
|
486 |
|
487 EXPORT_C void CCommsDbConnectionPrefTableView::UpdateDialogPrefL(const TCommDbDialogPref& aUpdate) |
|
488 /** Updates the dialog preference field (CONNECT_PREF_DIALOG_PREF) in the currently selected |
|
489 connection preferences IAP record in the view. |
|
490 |
|
491 @param aUpdate New value for the dialog preference field |
|
492 @leave KErrAccessDenied The record cannot be updated as it is read-only |
|
493 @leave KErrNotFound There is no current record in the view |
|
494 @capability Dependent on table, see the guide page referenced below. */ |
|
495 { |
|
496 CMDBRecordBase* currentRecord = iTableExt->GetCurrentRecordL(); |
|
497 |
|
498 (static_cast<CCDConnectionPrefsRecord*>(currentRecord))->iDialogPref = aUpdate; |
|
499 |
|
500 if ( currentRecord->IsSetAttribute(ECDNoWriteButDelete) || |
|
501 currentRecord->IsSetAttribute(ECDProtectedWrite) ) |
|
502 { |
|
503 __FLOG_STATIC1(KLogComponent, KCommDbShim, _L("UpdateDialogPrefL -> TableName=ConnectionPreferences, DialogPref=%d is leaving with KErrAccessDenied"), aUpdate); |
|
504 User::Leave(KErrAccessDenied); |
|
505 } |
|
506 |
|
507 // store change |
|
508 currentRecord->ModifyL(*iDb.iImpl->iDbs); |
|
509 |
|
510 __FLOG_STATIC1(KLogComponent, KCommDbShim, _L("UpdateDialogPrefL -> TableName=ConnectionPreferences, DialogPref=%d"), aUpdate); |
|
511 } |
|
512 |
|
513 EXPORT_C void CCommsDbConnectionPrefTableView::SwapConnectionPreferencesL(TCommDbConnectionDirection aDirection, TUint32 aFirstRank, TUint32 aSecondRank) |
|
514 // Restores the cursor in case of a Leave in `DoSwapConnectionPreferencesL()` though it probably shouldn't. |
|
515 /** Swaps the bearer (CONNECT_PREF_BEARER_SET) and the IAP (CONNECT_PREF_IAP) fields |
|
516 between two connection preferences records. |
|
517 |
|
518 The records to use are specified by their rank (CONNECT_PREF_RANKING) and |
|
519 direction (CONNECTION_PREF_DIRECTION). |
|
520 |
|
521 Note that the dialogue option is not altered. |
|
522 |
|
523 @param aDirection Direction of the connection preferences records |
|
524 @param aFirstRank Rank of the first record to swap |
|
525 @param aSecondRank Rank of the second record to swap |
|
526 @leave KErrAccessDenied The record cannot be updated as it is read-only |
|
527 @leave KErrArgument There is more than one record with the same ranking as |
|
528 one of the rankings |
|
529 @leave KErrNotFound A record with one of the rankings does not exist |
|
530 @leave KErrOverflow One of the rankings is greater than the maximum allowed |
|
531 @capability Dependent on table, see the guide page referenced below. */ |
|
532 { |
|
533 CMDBSession* dbSession = iDb.iImpl->iDbs; |
|
534 if((aFirstRank > 2) || (aSecondRank > 2)) |
|
535 { |
|
536 __FLOG_STATIC2(KLogComponent, KCommDbShim, _L("SwapConnectionPreferencesL -> TableName=ConnectionPreferences, FirstRank=%d, SecondRank=%d is leaveing with Err=KErrOverflow (Rankings are greater then allowed 2)"), aFirstRank, aSecondRank); |
|
537 User::Leave(KErrOverflow); |
|
538 } |
|
539 |
|
540 TInt isInTransaction = dbSession->IsInTransaction(); |
|
541 |
|
542 // start internal transaction if it is not already in transaction |
|
543 if (!isInTransaction) |
|
544 { |
|
545 dbSession->OpenTransactionL(); |
|
546 |
|
547 TRAPD(err, DoSwapConnectionPreferencesL(aDirection, aFirstRank, aSecondRank)); |
|
548 if(err == KErrNone) |
|
549 { |
|
550 dbSession->CommitTransactionL(); |
|
551 } |
|
552 else |
|
553 { |
|
554 __FLOG_STATIC3(KLogComponent, KCommDbShim, _L("SwapConnectionPreferencesL -> TableName=ConnectionPreferences, FirstRank=%d, SecondRank=%d RollBackTransaction Err=%d"), aFirstRank, aSecondRank, err); |
|
555 dbSession->RollbackTransactionL(); |
|
556 User::Leave(err); |
|
557 } |
|
558 } |
|
559 else |
|
560 { |
|
561 DoSwapConnectionPreferencesL(aDirection, aFirstRank, aSecondRank); |
|
562 } |
|
563 |
|
564 __FLOG_STATIC2(KLogComponent, KCommDbShim, _L("SwapConnectionPreferencesL -> TableName=ConnectionPreferences, FirstRank=%d, SecondRank=%d"), aFirstRank, aSecondRank); |
|
565 } |
|
566 |
|
567 void CCommsDbConnectionPrefTableView::DoSwapConnectionPreferencesL(TCommDbConnectionDirection aDirection, TUint32 aFirstRank, TUint32 aSecondRank) |
|
568 // Restores the cursor in case of a Leave in `DoSwapConnectionPreferencesL()` though it probably shouldn't. |
|
569 /** Swaps the bearer (CONNECT_PREF_BEARER_SET) and the IAP (CONNECT_PREF_IAP) fields |
|
570 between two connection preferences records. |
|
571 |
|
572 The records to use are specified by their rank (CONNECT_PREF_RANKING) and |
|
573 direction (CONNECTION_PREF_DIRECTION). |
|
574 |
|
575 Note that the dialogue option is not altered. |
|
576 |
|
577 @param aDirection Direction of the connection preferences records |
|
578 @param aFirstRank Rank of the first record to swap |
|
579 @param aSecondRank Rank of the second record to swap |
|
580 @leave KErrAccessDenied The record cannot be updated as it is read-only |
|
581 @leave KErrArgument There is more than one record with the same ranking as |
|
582 one of the rankings |
|
583 @leave KErrNotFound A record with one of the rankings does not exist |
|
584 @leave KErrOverflow One of the rankings is greater than the maximum allowed |
|
585 @capability Dependent on table, see the guide page referenced below. */ |
|
586 { |
|
587 CMDBSession* dbSession = iDb.iImpl->iDbs; |
|
588 CMDBRecordSetBase* rs = iTableExt->GetRecordSetL(); |
|
589 |
|
590 // Is it writable? |
|
591 if ( rs->IsSetAttribute(ECDNoWriteButDelete) || |
|
592 rs->IsSetAttribute(ECDProtectedWrite) ) |
|
593 { |
|
594 __FLOG_STATIC0(KLogComponent, KCommDbShim, _L("DoSwapConnectionPreferencesL is leaving with KErrAccessDenied (Table query)")); |
|
595 User::Leave(KErrAccessDenied); |
|
596 } |
|
597 |
|
598 TInt indexFirstRank(0); |
|
599 TInt indexSecondRank(0); |
|
600 |
|
601 TBool foundFirstRank(EFalse); |
|
602 TBool foundSecondRank(EFalse); |
|
603 |
|
604 for (TInt i=0;i<rs->iRecords.Count();++i) |
|
605 { |
|
606 CCDConnectionPrefsRecord* prefRecord = static_cast<CCDConnectionPrefsRecord*>(rs->iRecords[i]); |
|
607 if(prefRecord->iDirection == aDirection) |
|
608 { |
|
609 if(prefRecord->iRanking == aFirstRank) |
|
610 { |
|
611 indexFirstRank = i; |
|
612 |
|
613 if (foundFirstRank) |
|
614 { |
|
615 // Found this rank twice! |
|
616 User::Leave(KErrArgument); |
|
617 } |
|
618 |
|
619 foundFirstRank = ETrue; |
|
620 } |
|
621 |
|
622 if(prefRecord->iRanking == aSecondRank) |
|
623 { |
|
624 indexSecondRank = i; |
|
625 |
|
626 if (foundSecondRank) |
|
627 { |
|
628 // Found this rank twice! |
|
629 User::Leave(KErrArgument); |
|
630 } |
|
631 |
|
632 foundSecondRank = ETrue; |
|
633 } |
|
634 } |
|
635 } |
|
636 |
|
637 |
|
638 // if both ranikings are valid, exchange values |
|
639 if(foundFirstRank && foundSecondRank) |
|
640 { |
|
641 if(indexFirstRank != indexSecondRank) |
|
642 { |
|
643 CCDConnectionPrefsRecord* firstRecord = static_cast<CCDConnectionPrefsRecord*>(rs->iRecords[indexFirstRank]); |
|
644 CCDConnectionPrefsRecord* secondRecord = static_cast<CCDConnectionPrefsRecord*>(rs->iRecords[indexSecondRank]); |
|
645 |
|
646 if ( firstRecord->IsSetAttribute(ECDNoWriteButDelete) || |
|
647 firstRecord->IsSetAttribute(ECDProtectedWrite) || |
|
648 secondRecord->IsSetAttribute(ECDNoWriteButDelete) || |
|
649 secondRecord->IsSetAttribute(ECDProtectedWrite) ) |
|
650 { |
|
651 __FLOG_STATIC0(KLogComponent, KCommDbShim, _L("DoSwapConnectionPreferencesL is leaving with KErrAccessDenied (Record query)")); |
|
652 User::Leave(KErrAccessDenied); |
|
653 } |
|
654 |
|
655 |
|
656 // temp. delete record from database |
|
657 CCDConnectionPrefsRecord* firstRec = static_cast<CCDConnectionPrefsRecord*>(rs->iRecords[indexFirstRank]); |
|
658 firstRec->DeleteL(*dbSession); |
|
659 |
|
660 // gather data records |
|
661 TInt firstBearerSet = firstRecord->iBearerSet; |
|
662 TInt firstIapId = firstRecord->iDefaultIAP; |
|
663 |
|
664 TInt secondBearerSet = secondRecord->iBearerSet; |
|
665 TInt secondIapId = secondRecord->iDefaultIAP; |
|
666 |
|
667 // modify the second one |
|
668 secondRecord->iBearerSet = firstBearerSet; |
|
669 secondRecord->iDefaultIAP = firstIapId; |
|
670 secondRecord->ModifyL(*dbSession); |
|
671 |
|
672 // change and restore the changed first record |
|
673 |
|
674 firstRecord->iBearerSet = secondBearerSet; |
|
675 firstRecord->iDefaultIAP = secondIapId; |
|
676 firstRecord->StoreL(*dbSession); |
|
677 } |
|
678 } |
|
679 else |
|
680 { |
|
681 // one or both rankings are not valid |
|
682 __FLOG_STATIC3(KLogComponent, KCommDbShim, _L("SwapConnectionPreferencesL -> TableName=ConnectionPreferences, Direction=%d, FirstRank=%d, SecondRank=%d, Err: Rankings are not valid!!!") |
|
683 ,aDirection, aFirstRank, aSecondRank); |
|
684 User::Leave(KErrNotFound); |
|
685 } |
|
686 |
|
687 __FLOG_STATIC3(KLogComponent, KCommDbShim, _L("SwapConnectionPreferencesL -> TableName=ConnectionPreferences, Direction=%d, FirstRank=%d, SecondRank=%d") |
|
688 ,aDirection, aFirstRank, aSecondRank); |
|
689 } |
|
690 |
|
691 EXPORT_C void CCommsDbConnectionPrefTableView::ChangeConnectionPreferenceRankL(TUint32 aNewRank) |
|
692 /** Sets the rank field (CONNECT_PREF_RANKING) in the currently selected connection preference |
|
693 record in the view. |
|
694 |
|
695 Note that if the new rank is not zero, and there is already a record with |
|
696 this rank and the same direction, then the existing record's rank is set to |
|
697 zero. This means that record is not used when the system finds the preferred |
|
698 connections. |
|
699 |
|
700 @param aNewRank The new rank for the record. |
|
701 @leave KErrAccessDenied The record cannot be updated as it is read-only |
|
702 @leave KErrNotFound There is no current record in the view |
|
703 @leave KErrOverflow aNewRank is greater than the maximum allowed |
|
704 @capability Dependent on table, see the guide page referenced below. */ |
|
705 { |
|
706 |
|
707 CMDBRecordBase* record = iTableExt->GetCurrentRecordL(); |
|
708 // Is it writable? |
|
709 if ( record->IsSetAttribute(ECDNoWriteButDelete) || |
|
710 record->IsSetAttribute(ECDProtectedWrite) ) |
|
711 { |
|
712 __FLOG_STATIC0(KLogComponent, KCommDbShim, _L("ChangeConnectionPreferenceRankL is leaving with KErrAccessDenied")); |
|
713 User::Leave(KErrAccessDenied); |
|
714 } |
|
715 |
|
716 if (aNewRank != 0) |
|
717 { |
|
718 |
|
719 if(aNewRank>2) |
|
720 { |
|
721 __FLOG_STATIC0(KLogComponent, KCommDbShim, _L("ChangeConnectionPreferenceRankL is leaving with KErrOverflow (Rank is greater then 2)")); |
|
722 User::Leave(KErrOverflow); |
|
723 } |
|
724 |
|
725 // get current direction |
|
726 const TCommDbConnectionDirection direction = (static_cast<CCDConnectionPrefsRecord*>(record))->iDirection; |
|
727 |
|
728 CCommsDbConnectionPrefTableView* view = NULL; |
|
729 TRAPD(err, view = iDb.OpenConnectionPrefTableViewOnRankLC(direction, aNewRank);CleanupStack::Pop()); |
|
730 |
|
731 if(err == KErrNone) |
|
732 { |
|
733 CleanupStack::PushL(view); |
|
734 |
|
735 view->SetRankL(0); |
|
736 |
|
737 CleanupStack::PopAndDestroy(view); |
|
738 } |
|
739 |
|
740 SetRankL(aNewRank); |
|
741 // Refresh the data since there was a change of data in another view |
|
742 iTableExt->RefreshDatabaseL(*iDb.iImpl->iDbs); |
|
743 } |
|
744 else |
|
745 { |
|
746 SetRankL(0); |
|
747 } |
|
748 __FLOG_STATIC1(KLogComponent, KCommDbShim, _L("ChangeConnectionPreferenceRankL -> TableName=ConnectionPreferences, NewRank=%d") , aNewRank); |
|
749 } |
|
750 |
|
751 EXPORT_C void CCommsDbConnectionPrefTableView::DeleteConnectionPreferenceL() |
|
752 /** Deletes the currently selected connection preference record in the view. |
|
753 @capability Dependent on table, see the guide page referenced below. */ |
|
754 { |
|
755 // deletes current row from container and from database |
|
756 iTableExt->DeleteCurrentRecordL(*iDb.iImpl->iDbs); |
|
757 |
|
758 __FLOG_STATIC0(KLogComponent, KCommDbShim, _L("DeleteConnectionPreferenceL -> TableName=ConnectionPreferences")); |
|
759 } |
|
760 |
|
761 EXPORT_C TInt CCommsDbConnectionPrefTableView::GotoFirstRecord() |
|
762 //Moves the cursor to first connection preference record in this view |
|
763 /** Sets the first connection preference record in this view as the current record. |
|
764 |
|
765 @return KErrNotFound if the view has no records. Error codes from DBMS can |
|
766 also be returned. |
|
767 @capability Dependent on table, see the guide page referenced below. */ |
|
768 { |
|
769 __FLOG_STATIC0(KLogComponent, KCommDbShim, _L("GotoFirstRecord -> TableName=ConnectionPreferences")); |
|
770 return iTableExt->GotoFirstRecord(*iDb.iImpl->iDbs); |
|
771 } |
|
772 |
|
773 EXPORT_C TInt CCommsDbConnectionPrefTableView::GotoNextRecord() |
|
774 // Moves the cursor to next connection preference record in this view |
|
775 /** Sets the next connection preference record in the view as the current record. |
|
776 |
|
777 @return KErrNotFound if the current record is the last in the view. Error |
|
778 codes from DBMS can also be returned. |
|
779 @capability Dependent on table, see the guide page referenced below. */ |
|
780 { |
|
781 __FLOG_STMT(TInt index;) |
|
782 __FLOG_STMT(TInt err = iTableExt->GetRecordSetIndex(index);) |
|
783 __FLOG_STATIC1(KLogComponent, KCommDbShim, _L("GotoNextRecord -> TableName=ConnectionPreferences, RecordNum=%d"), index); |
|
784 |
|
785 return iTableExt->GotoNextRecord(*iDb.iImpl->iDbs); |
|
786 } |
|
787 |
|
788 EXPORT_C TInt CCommsDbConnectionPrefTableView::GotoPreviousRecord() |
|
789 // Move the cursor to previous connection preference record in this view |
|
790 /** Sets the previous connection preference record in the view as the current record. |
|
791 |
|
792 @return KErrNotFound if the current record is the first in the view. Error |
|
793 codes from DBMS can also be returned. |
|
794 @capability Dependent on table, see the guide page referenced below. */ |
|
795 { |
|
796 __FLOG_STMT(TInt index;) |
|
797 __FLOG_STMT(TInt err = index = iTableExt->GetRecordSetIndex(index);) |
|
798 __FLOG_STATIC0(KLogComponent, KCommDbShim, _L("GotoPreviousRecord -> TableName=ConnectionPreferences")); |
|
799 |
|
800 return iTableExt->GotoPreviousRecord(*iDb.iImpl->iDbs); |
|
801 } |
|
802 |
|
803 RDbRowSet::TAccess CCommsDbConnectionPrefTableView::GetL() |
|
804 /** |
|
805 Gets the operations that can be performed on the current connection preference record |
|
806 If there isn't an access table at all, then treat the table as updatable. |
|
807 @return EUpdatable, if All operations can be performed on the rowset. |
|
808 EReadOnly, Row navigation and reading are permitted. |
|
809 EInsertOnly, Inserting new rows is the only valid operation on the rowset. |
|
810 */ |
|
811 { |
|
812 RDbRowSet::TAccess access; |
|
813 iTableExt->GetTableAccess(access); |
|
814 |
|
815 return access; |
|
816 } |
|
817 |
|
818 void CCommsDbConnectionPrefTableView::Close() |
|
819 /** |
|
820 Closes the rowset and releases any owned resources. |
|
821 */ |
|
822 { |
|
823 } |
|
824 |
|
825 void CCommsDbConnectionPrefTableView::SetRankL(TUint32 aNewRank) |
|
826 { |
|
827 CMDBRecordBase* record = iTableExt->GetCurrentRecordL(); |
|
828 CCDConnectionPrefsRecord* currConnPrefRec = static_cast<CCDConnectionPrefsRecord*>(record); |
|
829 |
|
830 // Is it writable? |
|
831 if ( record->IsSetAttribute(ECDNoWriteButDelete) || |
|
832 record->IsSetAttribute(ECDProtectedWrite) ) |
|
833 { |
|
834 __FLOG_STATIC0(KLogComponent, KCommDbShim, _L("CCommsDbConnectionPrefTableView::SetRankL is leaving with KErrAccessDenied")); |
|
835 User::Leave(KErrAccessDenied); |
|
836 } |
|
837 |
|
838 // change the ranking of a record |
|
839 TUint32 currentrank = currConnPrefRec->iRanking; |
|
840 |
|
841 currConnPrefRec->iRanking = aNewRank; |
|
842 // store change |
|
843 |
|
844 TRAPD(err,currConnPrefRec->ModifyL(*iDb.iImpl->iDbs)); |
|
845 if(err == KErrArgument) |
|
846 { |
|
847 err = KErrOverflow; //commdb specific error code |
|
848 } |
|
849 |
|
850 if(err != KErrNone) |
|
851 { |
|
852 currConnPrefRec->iRanking = currentrank; |
|
853 __FLOG_STATIC2(KLogComponent, KCommDbShim, _L("CCommsDbConnectionPrefTableView::SetRankL -> Rank:%d, is leaving with Err:%d"), currentrank, err); |
|
854 User::Leave(err); |
|
855 } |
|
856 __FLOG_STMT(TInt rank = currConnPrefRec->iRanking;) |
|
857 __FLOG_STATIC1(KLogComponent, KCommDbShim, _L("CCommsDbConnectionPrefTableView::SetRankL -> Rank:%d"), rank); |
|
858 } |