|
1 // Copyright (c) 2006-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 // CCommDbOverrideSettings class defintions |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @deprecated since v9.1. Functionality is replaced with commsdat. |
|
21 */ |
|
22 |
|
23 #include "cdbover.h" |
|
24 #include "OVERRIDE.H" |
|
25 #include "CDBSTD.H" |
|
26 #include <commsdattypeinfov1_1.h> |
|
27 |
|
28 EXPORT_C CCommDbOverrideSettings* CCommDbOverrideSettings::NewL(TParamList aParamList) |
|
29 /** Allocates and constructs an override settings object. |
|
30 |
|
31 The construction process automatically opens the communications database and |
|
32 connects to the DBMS. The database is closed and the connection to the DBMS |
|
33 is severed when this override object is destroyed. |
|
34 |
|
35 This function was withdrawn in 6.0, but reintroduced in 7.0. |
|
36 |
|
37 @param aParamList Unused except when comparing two sets. |
|
38 @return A pointer to the new override settings object. */ |
|
39 { |
|
40 CCommDbOverrideSettings* r=new(ELeave) CCommDbOverrideSettings(aParamList); |
|
41 CleanupStack::PushL(r); |
|
42 r->ConstructL(); |
|
43 CleanupStack::Pop(r); |
|
44 return r; |
|
45 } |
|
46 |
|
47 EXPORT_C CCommDbOverrideSettings* CCommDbOverrideSettings::NewL(TParamList aParamList, TCommDbDatabaseType /*aDbType*/) |
|
48 /** @deprecated 7.0 |
|
49 |
|
50 Allocates and constructs an override settings object. |
|
51 The construction process automatically opens the communications database and connects to the DBMS. |
|
52 The database is closed and the connection to the DBMS is severed when this override object is destroyed. |
|
53 Re-instated override variant of NewL function in order to maintain BC with 6.1 |
|
54 |
|
55 @param aParamList Parameter list. |
|
56 @param aDbType Whether Database is IAP or ISP version. All Db's are IAP type now. |
|
57 @return CCommDbOverrideSettings* the calling function takes ownership of the returned object. |
|
58 */ |
|
59 { |
|
60 return CCommDbOverrideSettings::NewL(aParamList); |
|
61 } |
|
62 |
|
63 CCommDbOverrideSettings::CCommDbOverrideSettings(TParamList aParamList) |
|
64 : iPartialFull(aParamList) |
|
65 /** |
|
66 Constructor |
|
67 |
|
68 @param aParamList An enumerator which indicates whether the override settings are partial or full. |
|
69 */ |
|
70 {} |
|
71 |
|
72 void CCommDbOverrideSettings::ConstructL() |
|
73 { |
|
74 iDb=CCommsDatabase::NewL(); |
|
75 } |
|
76 |
|
77 EXPORT_C CCommDbOverrideSettings::~CCommDbOverrideSettings() |
|
78 /** Frees all resources owned by this object, prior to its destruction. Specifically, |
|
79 it closes the communications database and severs the connection with the DBMS. */ |
|
80 { |
|
81 iOverrides.ResetAndDestroy(); |
|
82 iIapOverrides.Reset(); |
|
83 |
|
84 delete iDb; |
|
85 } |
|
86 |
|
87 EXPORT_C TInt CCommDbOverrideSettings::SetIntOverride(const TDesC& aTableName, const TDesC& aColumnName, TUint32 aValue) |
|
88 /** Sets an override value for the specified unsigned integer type column in the specified table in the |
|
89 communications database. |
|
90 If the column name is empty, i.e. the length of the descriptor aColumnName is zero, then the override |
|
91 value is assumed to be the overriding ID for the default record for table aTableName. This means that |
|
92 the table must be one which supports default records. |
|
93 |
|
94 For the function to succeed: |
|
95 The column must exist |
|
96 The column type must be an unsigned integer |
|
97 An override for this column (or the overriding default record ID) for this table must not already exist |
|
98 The table must be one which supports override settings |
|
99 |
|
100 @param aTableName A reference to a descriptor containing the name of a table in the |
|
101 communications database. |
|
102 @param aColumnName A reference to a descriptor containing the name of a column in table |
|
103 aTableName. If this descriptor is empty, i.e. its length is zero, then aValue is assumed to be the |
|
104 overriding ID for the default record. |
|
105 @param aValue The override value. |
|
106 |
|
107 @return KErrNone on success; KErrNotSupported if the specified table does not have a default (when overriding the |
|
108 default) or the table does not support overrides; KErrNotFound if the specified table and/or column does not exist; |
|
109 KErrAlreadyExists if the specified column is already overridden. */ |
|
110 { |
|
111 TRAPD(ret,CheckL(aTableName,aColumnName,EIntValue)); |
|
112 if (ret!=KErrNone) |
|
113 return ret; |
|
114 |
|
115 ret = FindOverride(aTableName,aColumnName,EIntValue); |
|
116 if (ret >= 0) |
|
117 { |
|
118 ret = KErrAlreadyExists; |
|
119 } |
|
120 else if (ret == KErrNotFound) |
|
121 { |
|
122 CCommDbOverride* override = new CCommDbIntOverride(aTableName,aColumnName); |
|
123 if (override != 0) |
|
124 { |
|
125 ((CCommDbIntOverride*) override)->iValue = aValue; |
|
126 ret = iOverrides.Append(override); |
|
127 } |
|
128 else |
|
129 ret = KErrNoMemory; |
|
130 } |
|
131 |
|
132 return ret; |
|
133 } |
|
134 |
|
135 EXPORT_C TInt CCommDbOverrideSettings::SetBoolOverride(const TDesC& aTableName, const TDesC& aColumnName, TBool aValue) |
|
136 /** Sets an override value for a boolean type column in the specified table in the communications database. |
|
137 For the function to succeed: |
|
138 The column must exist |
|
139 The column type must be boolean |
|
140 An override for this column for this table must not already exist |
|
141 The table must be one which supports override settings |
|
142 |
|
143 @param aTableName A reference to a descriptor containing the name of a table in the communications |
|
144 database. |
|
145 @param aColumnName A reference to a descriptor containing the name of a column in table aTableName. |
|
146 @param aValue The override value. |
|
147 |
|
148 @return KErrNone on success; KErrNotSupported if the specified table does not have a default (when overriding the |
|
149 default) or the table does not support overrides; KErrNotFound if the specified table and/or column does not exist; |
|
150 KErrAlreadyExists if the specified column is already overridden. */ |
|
151 { |
|
152 TRAPD(ret,CheckL(aTableName,aColumnName,EBoolValue)); |
|
153 if (ret!=KErrNone) |
|
154 return ret; |
|
155 |
|
156 ret = FindOverride(aTableName,aColumnName,EBoolValue); |
|
157 if (ret >= 0) |
|
158 { |
|
159 ret = KErrAlreadyExists; |
|
160 } |
|
161 else if (ret == KErrNotFound) |
|
162 { |
|
163 CCommDbOverride* override = new CCommDbBoolOverride(aTableName,aColumnName); |
|
164 if (override != 0) |
|
165 { |
|
166 ((CCommDbBoolOverride*) override)->iValue = aValue; |
|
167 ret = iOverrides.Append(override); |
|
168 |
|
169 // if Append failed delete override |
|
170 if ( ret != KErrNone ) delete override; |
|
171 |
|
172 } |
|
173 else |
|
174 ret = KErrNoMemory; |
|
175 } |
|
176 return ret; |
|
177 } |
|
178 |
|
179 EXPORT_C TInt CCommDbOverrideSettings::SetDesOverride(const TDesC& aTableName, const TDesC& aColumnName, const TDesC8& aValue) |
|
180 /** Sets an override value for an 8 bit descriptor text type column in the specified table in the communications |
|
181 database. |
|
182 |
|
183 For the function to succeed: |
|
184 The column must exist |
|
185 The column type must be narrow (ASCII) text |
|
186 An override for this column for this table must not already exist. |
|
187 The table must be one which supports override settings |
|
188 |
|
189 In addition, the maximum length of text expected by this function is the value of the constant |
|
190 KCommsDbSvrMaxFieldLength. The length of aValue supplied by the caller cannot be greater than this value. |
|
191 |
|
192 @param aTableName A reference to a descriptor containing the name of a table in the communications |
|
193 database. |
|
194 @param aColumnName A reference to a descriptor containing the name of a column in table aTableName. |
|
195 @param aValue The override value. |
|
196 |
|
197 @return KErrNone on success; KErrNotSupported if the specified table does not have a default (when overriding the |
|
198 default) or the table does not support overrides; KErrNotFound if the specified table and/or column does not exist; |
|
199 KErrAlreadyExists if the specified column is already overridden.*/ |
|
200 { |
|
201 TRAPD(ret,CheckL(aTableName,aColumnName,EDes8Value)); |
|
202 if (ret!=KErrNone) |
|
203 return ret; |
|
204 |
|
205 TInt fieldWidth(0); |
|
206 CCommsDbTableView* tableView = 0; |
|
207 TRAP(ret, tableView = iDb->OpenTableLC(aTableName); CleanupStack::Pop(tableView)); |
|
208 if (ret != KErrNone) |
|
209 { |
|
210 return ret; |
|
211 } |
|
212 |
|
213 TRAP(ret, tableView->ReadColumnMaxLengthL(aColumnName, fieldWidth)); |
|
214 if (ret != KErrNone) |
|
215 { |
|
216 delete tableView; |
|
217 return ret; |
|
218 } |
|
219 |
|
220 if (aValue.Length()< fieldWidth) |
|
221 { |
|
222 ret = FindOverride(aTableName,aColumnName,EDes8Value); |
|
223 if (ret >= 0) |
|
224 { |
|
225 ret = KErrAlreadyExists; |
|
226 } |
|
227 else if (ret == KErrNotFound) |
|
228 { |
|
229 CCommDbOverride* override = new CCommDbDes8Override(aTableName,aColumnName); |
|
230 if (override != 0) |
|
231 { |
|
232 ((CCommDbDes8Override*) override)->iValue.Copy(aValue); |
|
233 ret = iOverrides.Append(override); |
|
234 |
|
235 // if Append failed delete override |
|
236 if ( ret != KErrNone ) delete override; |
|
237 } |
|
238 else |
|
239 { |
|
240 ret = KErrNoMemory; |
|
241 } |
|
242 } |
|
243 } |
|
244 else |
|
245 { |
|
246 ret = KErrOverflow; |
|
247 } |
|
248 |
|
249 delete tableView; |
|
250 return ret; |
|
251 |
|
252 } |
|
253 |
|
254 EXPORT_C TInt CCommDbOverrideSettings::SetDesOverride(const TDesC& aTableName, const TDesC& aColumnName, const TDesC16& aValue) |
|
255 /** Sets an override value for a 16 bit descriptor text type column in the specified table in the communications |
|
256 database. |
|
257 |
|
258 For the function to succeed: |
|
259 The column must exist |
|
260 The column type must be wide (UNICODE) text |
|
261 An override for this column for this table must not already exist |
|
262 The table must be one which supports override settings |
|
263 |
|
264 In addition, the maximum length of text expected by this function is the value of the constant |
|
265 KCommsDbSvrMaxFieldLength. The length of aValue supplied by the caller cannot be greater than this value. |
|
266 |
|
267 @param aTableName A reference to a descriptor containing the name of a table in the communications database. |
|
268 @param aColumnName A reference to a descriptor containing the name of a column in table aTableName. |
|
269 @param aValue The override value. |
|
270 |
|
271 |
|
272 @return KErrNone on success; KErrNotSupported if the specified table does not have a default (when overriding the |
|
273 default) or the table does not support overrides; KErrNotFound if the specified table and/or column does not exist; |
|
274 KErrAlreadyExists if the specified column is already overridden. */ |
|
275 { |
|
276 TRAPD(ret,CheckL(aTableName,aColumnName,EDes16Value)); |
|
277 if (ret!=KErrNone) |
|
278 return ret; |
|
279 |
|
280 TInt fieldWidth(0); |
|
281 CCommsDbTableView* tableView = 0; |
|
282 TRAP(ret, tableView = iDb->OpenTableLC(aTableName); CleanupStack::Pop(tableView)); |
|
283 if (ret != KErrNone) |
|
284 { |
|
285 return ret; |
|
286 } |
|
287 |
|
288 TRAP(ret, tableView->ReadColumnMaxLengthL(aColumnName, fieldWidth)); |
|
289 if (ret != KErrNone) |
|
290 { |
|
291 delete tableView; |
|
292 return ret; |
|
293 } |
|
294 |
|
295 if (aValue.Length()< fieldWidth) |
|
296 { |
|
297 ret = FindOverride(aTableName,aColumnName,EDes16Value); |
|
298 if (ret >= 0) |
|
299 { |
|
300 ret = KErrAlreadyExists; |
|
301 } |
|
302 else if (ret == KErrNotFound) |
|
303 { |
|
304 CCommDbOverride* override = new CCommDbDes16Override(aTableName,aColumnName); |
|
305 if (override != 0) |
|
306 { |
|
307 ((CCommDbDes16Override*) override)->iValue.Copy(aValue); |
|
308 ret = iOverrides.Append(override); |
|
309 |
|
310 // if Append failed delete override |
|
311 if ( ret != KErrNone ) delete override; |
|
312 } |
|
313 else |
|
314 { |
|
315 ret = KErrNoMemory; |
|
316 } |
|
317 } |
|
318 } |
|
319 else |
|
320 { |
|
321 ret = KErrOverflow; |
|
322 } |
|
323 |
|
324 delete tableView; |
|
325 return ret; |
|
326 } |
|
327 |
|
328 EXPORT_C TInt CCommDbOverrideSettings::SetLongDesOverride(const TDesC& aTableName, const TDesC& aColumnName, const TDesC& aValue) |
|
329 /** Sets an override value for a long text type column in a specified table in the communications database. |
|
330 |
|
331 For the function to succeed: |
|
332 The column must exist |
|
333 The column type is assumed to be arbitrarily long text (within the limits defined by descriptors) |
|
334 An override for this column for this table must not already exist |
|
335 The table must be one which supports override settings |
|
336 |
|
337 @param aTableName A reference to a descriptor containing the name of a table in the communications |
|
338 database. |
|
339 @param aColumnName A reference to a descriptor containing the name of a column in table aTableName. |
|
340 @param aValue The override value. |
|
341 |
|
342 @return KErrNone on success; KErrNotSupported if the specified table does not have a default (when overriding the |
|
343 default) or the table does not support overrides; KErrNotFound if the specified table and/or column does not exist; |
|
344 KErrAlreadyExists if the specified column is already overridden. */ |
|
345 { |
|
346 TRAPD(ret,CheckL(aTableName,aColumnName,ELongDesValue)); |
|
347 if (ret!=KErrNone) |
|
348 return ret; |
|
349 |
|
350 ret = FindOverride(aTableName,aColumnName,ELongDesValue); |
|
351 if (ret >= 0) |
|
352 { |
|
353 ret = KErrAlreadyExists; |
|
354 } |
|
355 else if (ret == KErrNotFound) |
|
356 { |
|
357 CCommDbOverride* override = 0; |
|
358 TRAP(ret,(override=CCommDbLongDesOverride::NewL(aTableName,aColumnName,aValue))); |
|
359 if (ret==KErrNone) |
|
360 { |
|
361 ret = iOverrides.Append(override); |
|
362 |
|
363 // if Append failed delete override |
|
364 if ( ret != KErrNone ) delete override; |
|
365 } |
|
366 } |
|
367 return ret; |
|
368 } |
|
369 |
|
370 EXPORT_C TInt CCommDbOverrideSettings::GetIntOverride(const TDesC& aTableName, const TDesC& aColumnName, TUint32& aValue) |
|
371 /** Gets an override value for an unsigned integer type column in the specified table in the communications |
|
372 database. |
|
373 |
|
374 If the column name is empty, i.e. the length of the descriptor aColumnName is zero, then the override |
|
375 value is assumed to be the overriding Id for the default record for table aTableName. |
|
376 |
|
377 For this function to succeed: |
|
378 An override for this column (or the the overriding default record Id) for this table must exist |
|
379 The table must be one which supports override settings |
|
380 |
|
381 @param aTableName A reference to a descriptor containing the name of a table in the communications |
|
382 database. |
|
383 @param aColumnName A reference to a descriptor containing the name of a column in table aTableName. |
|
384 @param aValue An unsigned integer type passed by the caller. On successful return from this function, it |
|
385 contains the override value. |
|
386 |
|
387 @return KErrNone on success; KErrNotFound if the specified table and/or column has not been overridden or does not |
|
388 exist */ |
|
389 { |
|
390 TInt index=FindOverride(aTableName,aColumnName,EIntValue); |
|
391 if (index < 0) |
|
392 return KErrNotFound; |
|
393 |
|
394 aValue=((CCommDbIntOverride*)(iOverrides[index]))->iValue; |
|
395 return KErrNone; |
|
396 } |
|
397 |
|
398 EXPORT_C TInt CCommDbOverrideSettings::GetBoolOverride(const TDesC& aTableName, const TDesC& aColumnName, TBool& aValue) |
|
399 /** Gets an override value for a boolean type column in the specified table in the communications database. |
|
400 |
|
401 For this function to succeed: |
|
402 An override for this column for this table must exist |
|
403 The table must be one which supports override settings |
|
404 |
|
405 @param aTableName A reference to a descriptor containing the name of a table in the communications |
|
406 database. |
|
407 @param aColumnName A reference to a descriptor containing the name of a column in table aTableName. |
|
408 @param aValue A boolean type passed by the caller. On successful return from this function, it contains |
|
409 the override value. |
|
410 |
|
411 @return KErrNone on success; KErrNotFound if the specified table and/or column has not been overridden or does not |
|
412 exist. */ |
|
413 { |
|
414 TInt index=FindOverride(aTableName,aColumnName,EBoolValue); |
|
415 if (index < 0) |
|
416 return KErrNotFound; |
|
417 |
|
418 aValue=((CCommDbBoolOverride*)(iOverrides[index]))->iValue; |
|
419 return KErrNone; |
|
420 } |
|
421 |
|
422 EXPORT_C TInt CCommDbOverrideSettings::GetDesOverride(const TDesC& aTableName, const TDesC& aColumnName, TDes8& aValue) |
|
423 /** Gets an override value for an 8 bit descriptor text type column in the specified table in the communications |
|
424 database. |
|
425 |
|
426 For this function to succeed: |
|
427 An override for this column for this table must exist |
|
428 The table must be one which supports override settings |
|
429 |
|
430 @param aTableName A reference to a descriptor containing the name of a table in the communications |
|
431 database. |
|
432 @param aColumnName A reference to a descriptor containing the name of a column in table aTableName. |
|
433 @param aValue An 8 bit type descriptor passed by the caller. On successful return from this function, it |
|
434 contains the override value. This parameter must be as long as KCommsDbSvrMaxFieldLength or the function will fail. |
|
435 |
|
436 @return KErrNone on success; KErrNotFound if the specified table and/or column has not been overridden or does not |
|
437 exist; KErrOverflow if the aValue parameter was too small.*/ |
|
438 { |
|
439 TInt fieldWidth(0); |
|
440 TInt returnValue = KErrNone; |
|
441 CCommsDbTableView* tableView = 0; |
|
442 TRAP(returnValue, tableView = iDb->OpenTableLC(aTableName); CleanupStack::Pop(tableView)); |
|
443 if (returnValue != KErrNone) |
|
444 { |
|
445 return returnValue; |
|
446 } |
|
447 |
|
448 TRAP(returnValue, tableView->ReadColumnMaxLengthL(aColumnName, fieldWidth)); |
|
449 if (returnValue != KErrNone) |
|
450 { |
|
451 delete tableView; |
|
452 return returnValue; |
|
453 } |
|
454 |
|
455 //TG-hack to restrict OutgoingGPRS/APN to 252 chars to avoid overflow |
|
456 TInt maxLength = aValue.MaxLength(); |
|
457 if((aTableName.CompareF(TPtrC(KCDTypeNameOutgoingWCDMA)) == 0 || aTableName.CompareF(TPtrC(KCDTypeNameIncomingWCDMA)) == 0 ) |
|
458 && aColumnName.CompareF(TPtrC(KCDTypeNameGPRSAPN)) == 0) |
|
459 { |
|
460 fieldWidth = 252; // KGSNNameLength from etelpckt.h |
|
461 } |
|
462 |
|
463 if (aValue.MaxLength() >= fieldWidth) |
|
464 { |
|
465 TInt index=FindOverride(aTableName,aColumnName,EDes8Value); |
|
466 if (index >= 0) |
|
467 { |
|
468 aValue.Copy(((CCommDbDes8Override*)(iOverrides[index]))->iValue); |
|
469 } |
|
470 else |
|
471 { |
|
472 returnValue = KErrNotFound; |
|
473 } |
|
474 } |
|
475 else |
|
476 { |
|
477 returnValue = KErrOverflow; |
|
478 } |
|
479 |
|
480 delete tableView; |
|
481 return returnValue ; |
|
482 } |
|
483 |
|
484 EXPORT_C TInt CCommDbOverrideSettings::GetDesOverride(const TDesC& aTableName, const TDesC& aColumnName, TDes16& aValue) |
|
485 /**Gets an override value for a 16 bit descriptor text type column in the specified table in the communications |
|
486 database. |
|
487 |
|
488 For this function to succeed: |
|
489 An override for this column for this table must exist |
|
490 The table must be one which supports override settings |
|
491 |
|
492 @param aTableName A reference to a descriptor containing the name of a table in the communications |
|
493 database. |
|
494 @param aColumnName A reference to a descriptor containing the name of a column in table aTableName. |
|
495 @param aValue A 16 bit type descriptor passed by the caller. On successful return from this function, it |
|
496 contains the override value. This parameter must be as long as KCommsDbSvrMaxFieldLength or the function will fail. |
|
497 |
|
498 @return KErrNone on success; KErrNotFound if the specified table and/or column has not been overridden or does not |
|
499 exist; KErrOverflow if the aValue parameter was too small.*/ |
|
500 { |
|
501 TInt fieldWidth(0); |
|
502 TInt returnValue = KErrNone; |
|
503 CCommsDbTableView* tableView = 0; |
|
504 TRAP(returnValue, tableView = iDb->OpenTableLC(aTableName); CleanupStack::Pop(tableView)); |
|
505 if (returnValue != KErrNone) |
|
506 { |
|
507 return returnValue; |
|
508 } |
|
509 |
|
510 TRAP(returnValue, tableView->ReadColumnMaxLengthL(aColumnName, fieldWidth)); |
|
511 if (returnValue != KErrNone) |
|
512 { |
|
513 delete tableView; |
|
514 return returnValue; |
|
515 } |
|
516 |
|
517 if (aValue.MaxLength() >= fieldWidth) |
|
518 { |
|
519 TInt index=FindOverride(aTableName,aColumnName,EDes16Value); |
|
520 if (index >= 0) |
|
521 { |
|
522 aValue.Copy(((CCommDbDes16Override*)(iOverrides[index]))->iValue); |
|
523 } |
|
524 else |
|
525 { |
|
526 returnValue = KErrNotFound; |
|
527 } |
|
528 } |
|
529 else |
|
530 { |
|
531 returnValue = KErrOverflow; |
|
532 } |
|
533 |
|
534 delete tableView; |
|
535 return returnValue ; |
|
536 } |
|
537 |
|
538 EXPORT_C TInt CCommDbOverrideSettings::GetLongDesOverride(const TDesC& aTableName, const TDesC& aColumnName, TDes& aValue) |
|
539 /**Gets the override value for a column in the specified table in the communications database. |
|
540 |
|
541 For this function to succeed: |
|
542 An override for this column for this table must exist |
|
543 The table must be one which supports override settings |
|
544 Notes: |
|
545 The maximum length of the descriptor aValue must be large enough to contain the override text. |
|
546 Use the GetLongDesOverrideLength() function to find the length of this text. |
|
547 |
|
548 @param aTableName A reference to a descriptor containing the name of a table in the communications |
|
549 database. |
|
550 @param aColumnName A reference to a descriptor containing the name of a column in table aTableName. |
|
551 @param aValue A descriptor passed by the caller. On successful return from this function, it contains the |
|
552 override value. |
|
553 |
|
554 @return KErrNone on success; KErrNotFound if the specified table and/or column has not been overridden or does not |
|
555 exist. */ |
|
556 { |
|
557 TInt index=FindOverride(aTableName,aColumnName,ELongDesValue); |
|
558 if (index < 0) |
|
559 return KErrNotFound; |
|
560 |
|
561 TPtr ptr(((CCommDbLongDesOverride*)(iOverrides[index]))->iValue->Des()); |
|
562 |
|
563 if (aValue.MaxLength() < ptr.Length()) |
|
564 { |
|
565 return KErrOverflow; |
|
566 } |
|
567 |
|
568 aValue.Copy(ptr); |
|
569 return KErrNone; |
|
570 } |
|
571 |
|
572 EXPORT_C TInt CCommDbOverrideSettings::GetLongDesOverrideLength(const TDesC& aTableName, const TDesC& aColumnName, TInt& aLength) |
|
573 /**Gets the length of the long text override value for a column in the specified table in the communications database. |
|
574 |
|
575 For this function to succeed: |
|
576 An override for this column for this table must exist |
|
577 The table must be one which supports override settings |
|
578 |
|
579 @param aTableName A reference to a descriptor containing the name of a table in |
|
580 the communications database. |
|
581 @param aColumnName A reference to a descriptor containing the name of a column in |
|
582 table aTableName. |
|
583 @param aLength A signed integer type passed by the caller. On successful return from |
|
584 this function, it contains the override value. |
|
585 |
|
586 @return KErrNone on success; KErrNotFound if the specified table and/or column has not been overridden or does not exist; |
|
587 KErrOverflow if the aValue parameter was too small.*/ |
|
588 { |
|
589 TInt index=FindOverride(aTableName,aColumnName,ELongDesValue); |
|
590 if (index < 0) |
|
591 return KErrNotFound; |
|
592 |
|
593 aLength=((CCommDbLongDesOverride*)(iOverrides[index]))->iValue->Des().Length(); |
|
594 return KErrNone; |
|
595 } |
|
596 |
|
597 EXPORT_C TBool CCommDbOverrideSettings::Compare(CCommDbOverrideSettings* aOverrides) const |
|
598 /** Compares aOverrides with this class. |
|
599 |
|
600 @param aOverrides Overrides. |
|
601 @return ETrue if aOverrides has the same as this object; EFalse if not. */ |
|
602 { |
|
603 //Compare *this override values with the passed override values and |
|
604 //return true if all fields match else return false |
|
605 |
|
606 //compare override count |
|
607 TInt overrideCount = iOverrides.Count(); |
|
608 if(overrideCount != aOverrides->iOverrides.Count()) |
|
609 return EFalse; |
|
610 |
|
611 //If everything else checks out then compare override types and values |
|
612 TInt i; |
|
613 for(i = 0; i < overrideCount; ++i) |
|
614 { |
|
615 const CCommDbOverride* myOverride = iOverrides[i]; |
|
616 |
|
617 TInt found = aOverrides->FindOverride(myOverride->iTableName, |
|
618 myOverride->iColumnName, myOverride->iType); |
|
619 if (found < 0) |
|
620 return EFalse; |
|
621 |
|
622 // have found one now check its value |
|
623 const CCommDbOverride* argOverride = aOverrides->iOverrides[found]; |
|
624 |
|
625 switch (myOverride->iType) |
|
626 { |
|
627 case EIntValue: |
|
628 if (((CCommDbIntOverride*) myOverride)->iValue != |
|
629 ((CCommDbIntOverride*) argOverride)->iValue) |
|
630 return EFalse; |
|
631 break; |
|
632 case EBoolValue: |
|
633 if (((CCommDbBoolOverride*) myOverride)->iValue != |
|
634 ((CCommDbBoolOverride*) argOverride)->iValue) |
|
635 return EFalse; |
|
636 break; |
|
637 case EDes8Value: |
|
638 if (((CCommDbDes8Override*) myOverride)->iValue != |
|
639 ((CCommDbDes8Override*) argOverride)->iValue) |
|
640 return EFalse; |
|
641 break; |
|
642 case EDes16Value: |
|
643 if (((CCommDbDes16Override*) myOverride)->iValue != |
|
644 ((CCommDbDes16Override*) argOverride)->iValue) |
|
645 return EFalse; |
|
646 break; |
|
647 case ELongDesValue: |
|
648 if (*((CCommDbLongDesOverride*) myOverride)->iValue != |
|
649 *((CCommDbLongDesOverride*) argOverride)->iValue) |
|
650 return EFalse; |
|
651 break; |
|
652 default: |
|
653 return EFalse; |
|
654 } |
|
655 } |
|
656 |
|
657 // compare connection preference override count |
|
658 overrideCount = iIapOverrides.Count(); |
|
659 if(overrideCount != aOverrides->iIapOverrides.Count()) |
|
660 return EFalse; |
|
661 |
|
662 // compare connection preference override setting |
|
663 for(i = 0; i < overrideCount; ++i) |
|
664 { |
|
665 // Compare value of override parameter with that which was passed in |
|
666 if((aOverrides->iIapOverrides.Find(iIapOverrides[i], MatchIapOverride)) < 0) |
|
667 { |
|
668 return EFalse; |
|
669 } |
|
670 } |
|
671 |
|
672 return ETrue; |
|
673 } |
|
674 |
|
675 TBool CCommDbOverrideSettings::MatchIapOverride(const TCommDbIapConnectionPrefOverride& aFirst, |
|
676 const TCommDbIapConnectionPrefOverride& aSecond) |
|
677 /** |
|
678 Checks if the dialog preference fields in the passed objects of TCommDbIapConnectionPrefOverride are equal. |
|
679 |
|
680 @param aFirst A reference to TCommDbIapConnectionPrefOverride class |
|
681 @param aSecond A reference to TCommDbIapConnectionPrefOverride class |
|
682 @return ETrue if the dialog preferences are equal else EFalse |
|
683 */ |
|
684 { |
|
685 return aFirst.iPref == aSecond.iPref; |
|
686 } |
|
687 |
|
688 EXPORT_C TBool CCommDbOverrideSettings::IsOverridden(const TDesC& aTableName, const TDesC& aColumnName, TValueType aType) |
|
689 /** Tests whether an override value of a specified type exists in the communications |
|
690 database. |
|
691 |
|
692 @param aTableName A reference to a descriptor containing the name of a table |
|
693 in the communications database. |
|
694 @param aColumnName A reference to a descriptor containing the name of a column |
|
695 in table aTableName which is to be overridden. |
|
696 @param aType An enumeration which indicates the type of data in column aType |
|
697 which is to be overridden. |
|
698 @return ETrue if an override has been set for `aColumnName`; EFalse otherwise. */ |
|
699 { |
|
700 // If Find returns an index then it `IsOverridden` |
|
701 return FindOverride(aTableName,aColumnName,aType) >= 0; |
|
702 } |
|
703 |
|
704 EXPORT_C TInt CCommDbOverrideSettings::SetConnectionPreferenceOverride(const CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref& aPref) |
|
705 |
|
706 /** Sets overrides for a record in the Connection preferences table. |
|
707 |
|
708 The rank (CONNECT_PREF_RANKING and the direction (CONNECTION_PREF_DIRECTION |
|
709 part of the aPref parameter must be filled in to indicate which connection |
|
710 preference is to be overridden. It is therefore not possible to override the |
|
711 rank or direction of a connection preference. |
|
712 |
|
713 The other fields should be filled in one of the following ways to override |
|
714 the other settings: |
|
715 |
|
716 Only dialog preference (CONNECT_PREF_DIALOG_PREF) is filled in to override |
|
717 this field (all others should have zero value). |
|
718 |
|
719 Only bearer set and IAP ID (CONNECT_PREF_BEARER_SET) are filled in to override |
|
720 these fields (all other fields should have zero value). |
|
721 |
|
722 The bearer set, IAP ID and the dialog preference are filled in to override |
|
723 these fields. |
|
724 |
|
725 CommDb treats zero values as fields that the client does not wish to override. |
|
726 |
|
727 |
|
728 A note on overriding connection preferences. This is clearly a desirable thing |
|
729 to be able to do, so that the application may choose its own particular first |
|
730 and second preference for a connection. However, at the moment it is only |
|
731 possible to override one row of settings per table, i.e. it would only be |
|
732 possible to override the first ranked connection preferences or the second |
|
733 ranked connection preferences, but not both. To solve this problem, two API |
|
734 functions are added to the CCommDbOverrideSettings class specifically for |
|
735 overriding connection preferences. |
|
736 |
|
737 @param aPref Connection preference settings by which to override. |
|
738 @return An error code from an override setting function, e.g. SetIntOverride(), |
|
739 as documented above. */ |
|
740 { |
|
741 if (aPref.iRanking == 0 || aPref.iDirection == ECommDbConnectionDirectionUnknown) |
|
742 return KErrNotSupported; |
|
743 |
|
744 if (aPref.iBearer.iIapId == 0 && |
|
745 aPref.iDialogPref == ECommDbDialogPrefUnknown && |
|
746 aPref.iBearer.iBearerSet == 0) |
|
747 return KErrArgument; |
|
748 |
|
749 for (TInt count = iIapOverrides.Count() - 1; count >= 0; count--) |
|
750 { |
|
751 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref& currentPref = iIapOverrides[count].iPref; |
|
752 |
|
753 if (aPref.iRanking == currentPref.iRanking && aPref.iDirection == currentPref.iDirection) |
|
754 return KErrAlreadyExists; |
|
755 } |
|
756 |
|
757 TCommDbIapConnectionPrefOverride override; |
|
758 override.iPref = aPref; |
|
759 return iIapOverrides.Append(override); |
|
760 } |
|
761 |
|
762 EXPORT_C TInt CCommDbOverrideSettings::SetConnectionPreferenceOverride(const CCommsDbConnectionPrefTableView::TCommDbIspConnectionPref& /*aPref*/) |
|
763 /** |
|
764 @deprecated 7.0 |
|
765 |
|
766 Framework left in place for 6.1 compatibility purposes. |
|
767 @param aPref Not supported. |
|
768 @return KErrNotSupported*/ |
|
769 { |
|
770 return KErrNotSupported; |
|
771 } |
|
772 |
|
773 EXPORT_C TInt CCommDbOverrideSettings::GetConnectionPreferenceOverride(CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref& aPref) |
|
774 /** Gets the overrides for a record in the Connection preferences table |
|
775 filtered by the contents of `aPref`. Any field in `aPref` may be ignored in the filter by |
|
776 initialising with the following values: |
|
777 aPref.iRanking == 0, |
|
778 aPref.iDirection == ECommDbConnectionDirectionUnknown, |
|
779 aPref.iDialogPref == ECommDbDialogPrefUnknown, |
|
780 aPref.iBearer.iBearerSet == 0, |
|
781 aPref.iBearer.iIapId == 0 |
|
782 The client should set the ranking and the direction of the aPref parameter to the values |
|
783 to be matched when getting the override, e.g. set the iRanking member to 1 |
|
784 and iDirection to ECommDbConnectionDirectionOutgoing to retrieve the overrides |
|
785 for the outgoing connection preference with ranking 1. |
|
786 |
|
787 @param aPref Initially specifies the record for which to get the overrides |
|
788 (the record is matched against the settings in aPref). On return, the override |
|
789 settings for that record. |
|
790 @return KErrArgument if all the members of aPref are zero; KErrNotFound if |
|
791 no matching override is found. */ |
|
792 { |
|
793 if (aPref.iRanking == 0 && |
|
794 aPref.iDirection == ECommDbConnectionDirectionUnknown && |
|
795 aPref.iDialogPref == ECommDbDialogPrefUnknown && |
|
796 aPref.iBearer.iBearerSet == 0) |
|
797 return KErrArgument; |
|
798 |
|
799 for (TInt count = iIapOverrides.Count() - 1; count >= 0; count--) |
|
800 { |
|
801 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref = iIapOverrides[count].iPref; |
|
802 |
|
803 if ((aPref.iRanking == 0 || aPref.iRanking == pref.iRanking) && |
|
804 (aPref.iDirection == ECommDbConnectionDirectionUnknown || aPref.iDirection == pref.iDirection) && |
|
805 (aPref.iDialogPref == ECommDbDialogPrefUnknown || aPref.iDialogPref == pref.iDialogPref) && |
|
806 (aPref.iBearer.iBearerSet == 0 || aPref.iBearer.iBearerSet == pref.iBearer.iBearerSet) && |
|
807 (aPref.iBearer.iIapId == 0 || aPref.iBearer.iIapId == pref.iBearer.iIapId)) |
|
808 { |
|
809 aPref = pref; |
|
810 return KErrNone; |
|
811 } |
|
812 } |
|
813 |
|
814 return KErrNotFound; |
|
815 } |
|
816 |
|
817 EXPORT_C TInt CCommDbOverrideSettings::GetConnectionPreferenceOverride(CCommsDbConnectionPrefTableView::TCommDbIspConnectionPref& /*aPref*/) |
|
818 /** @deprecated v7.0S |
|
819 |
|
820 Left in place for 6.1 BC purposes. |
|
821 |
|
822 @param aPref Connection preference settings. |
|
823 @return KErrNotSupported. */ |
|
824 { |
|
825 return KErrNotSupported; |
|
826 } |
|
827 |
|
828 TInt CCommDbOverrideSettings::FindOverride(const TDesC& aTableName, const TDesC& aColumnName, TValueType aType) const |
|
829 /** |
|
830 Checks whether the given table, column are overridden for the given type. |
|
831 |
|
832 @param aTableName A reference to a descriptor containing the name of a table in the communications database. |
|
833 @param aColumnName A reference to a descriptor containing the name of a column in table aTableName. |
|
834 @param aType The override type. |
|
835 @return The index in the table if the values are matched else KErrNotFound |
|
836 */ |
|
837 { |
|
838 if (IllegalOverride(aTableName,aColumnName)) |
|
839 return KErrNotSupported; |
|
840 |
|
841 TInt index; |
|
842 CCommDbOverride toMatch(aType); |
|
843 toMatch.iColumnName.Copy(aColumnName); |
|
844 toMatch.iTableName.Copy(aTableName); |
|
845 index = iOverrides.Find(&toMatch, toMatch.MatchOverrides); |
|
846 |
|
847 if (index < 0) |
|
848 index = KErrNotFound; |
|
849 |
|
850 return index; |
|
851 } |
|
852 |
|
853 TBool CCommDbOverrideSettings::IllegalOverride(const TDesC& aTableName, const TDesC& aColumnName) const |
|
854 /** |
|
855 Checks whether the overrides are legal or not. |
|
856 |
|
857 @param aTableName A reference to a descriptor containing the name of a table in the communications database. |
|
858 @param aColumnName A reference to a descriptor containing the name of a column in table aTableName. |
|
859 @return ETrue if the override is legal else EFalse |
|
860 */ |
|
861 { |
|
862 if (aTableName.CompareF(TPtrC(MODEM_BEARER)) == 0 && aColumnName.CompareF(TPtrC(MODEM_TSY_NAME)) != 0) |
|
863 return ETrue; |
|
864 |
|
865 // required for BC purposes - check for the old name for the ModemBearer table |
|
866 if (aTableName.CompareF(TPtrC(OLD_MODEM_TABLE)) == 0 && aColumnName.CompareF(TPtrC(MODEM_TSY_NAME)) != 0) |
|
867 return ETrue; |
|
868 |
|
869 if (aTableName.CompareF(TPtrC(PROXIES)) == 0) |
|
870 return ETrue; |
|
871 |
|
872 if (aTableName.CompareF(TPtrC(WAP_ACCESS_POINT)) == 0) |
|
873 return ETrue; |
|
874 |
|
875 if (aTableName.CompareF(TPtrC(WAP_IP_BEARER)) == 0) |
|
876 return ETrue; |
|
877 |
|
878 if (aTableName.CompareF(TPtrC(WAP_SMS_BEARER)) == 0) |
|
879 return ETrue; |
|
880 |
|
881 if (aTableName.CompareF(TPtrC(DEFAULT_GPRS)) == 0) |
|
882 return ETrue; |
|
883 |
|
884 // Globals that may not be overriden |
|
885 if (aColumnName.Length() == 0) |
|
886 { |
|
887 return (aTableName.CompareF(TPtrC(WAP_ACCESS_POINT)) == 0 || |
|
888 aTableName.CompareF(TPtrC(CLIENT_TIMEOUT)) == 0 || |
|
889 aTableName.CompareF(TPtrC(ROUTE_TIMEOUT)) == 0 || |
|
890 aTableName.CompareF(TPtrC(REDIAL_ATTEMPTS)) == 0 || |
|
891 aTableName.CompareF(TPtrC(SMS_BEARER)) == 0 || |
|
892 aTableName.CompareF(TPtrC(SMS_RECEIVE_MODE)) == 0 || |
|
893 aTableName.CompareF(TPtrC(GPRS_ATTACH_MODE)) == 0 || |
|
894 aTableName.CompareF(TPtrC(ACCEPT_INCOMING_GPRS)) == 0 || |
|
895 aTableName.CompareF(TPtrC(GPRS_CLASS_C_BEARER)) == 0 || |
|
896 aTableName.CompareF(TPtrC(MODEM_DATA_FAX)) == 0 || |
|
897 aTableName.CompareF(TPtrC(MODEM_PHONE_SERVICES_SMS)) == 0 || |
|
898 aTableName.CompareF(TPtrC(LOCATION_DATA_FAX)) == 0 || |
|
899 aTableName.CompareF(TPtrC(LOCATION_PHONE_SERVICES_SMS)) == 0 |
|
900 ); |
|
901 } |
|
902 |
|
903 return EFalse; |
|
904 } |
|
905 |
|
906 void CCommDbOverrideSettings::CheckL(const TDesC& aTableName, const TDesC& aColumnName, TValueType aType) const |
|
907 /** |
|
908 Checks whether the column aColumnName of type aType in the table aTableName exists. |
|
909 Panic if the column doesn't exist in the table, otherwise leave with KErrNotFound. |
|
910 |
|
911 @param aTableName A reference to a descriptor containing the name of a table in the communications database. |
|
912 @param aType The override type. |
|
913 */ |
|
914 { |
|
915 if (aColumnName.Length()!=0) |
|
916 { |
|
917 CCommsDbTableView* table=iDb->OpenTableLC(aTableName); |
|
918 TDbColType colType; |
|
919 TUint32 attrib; |
|
920 table->ReadTypeAttribL(aColumnName,colType,attrib); // checks column exists (cannot leave) |
|
921 CleanupStack::PopAndDestroy(table); |
|
922 |
|
923 // check the correct type |
|
924 switch (aType) |
|
925 { |
|
926 case EIntValue: |
|
927 if ((colType!=EDbColUint32) && (colType!=EDbColUint8)) |
|
928 User::Leave(KErrNotFound); |
|
929 break; |
|
930 case EBoolValue: |
|
931 if (colType!=EDbColBit) |
|
932 User::Leave(KErrNotFound); |
|
933 break; |
|
934 case EDes8Value: |
|
935 if (colType!=EDbColText8) |
|
936 User::Leave(KErrNotFound); |
|
937 break; |
|
938 case EDes16Value: |
|
939 if (colType!=EDbColText16) |
|
940 User::Leave(KErrNotFound); |
|
941 break; |
|
942 case ELongDesValue: |
|
943 if (colType!=EDbColLongText) |
|
944 User::Leave(KErrNotFound); |
|
945 break; |
|
946 default: |
|
947 User::Leave(KErrNotFound); |
|
948 break; |
|
949 } |
|
950 } |
|
951 else // global setting |
|
952 { |
|
953 if (aType==EIntValue) |
|
954 { |
|
955 TUint32 val=0; // ignore this |
|
956 TRAPD(ret,iDb->GetGlobalSettingL(aTableName,val)); |
|
957 if (ret==KErrNotSupported) |
|
958 User::Leave(KErrNotFound); |
|
959 } |
|
960 else if (aType==EDes16Value) |
|
961 { |
|
962 HBufC16* bufHeap = HBufC::NewLC(KCommsDbSvrRealMaxFieldLength) ; |
|
963 TPtr buf = bufHeap->Des() ; |
|
964 TRAPD(ret,iDb->GetGlobalSettingL(aTableName,buf)); |
|
965 CleanupStack::PopAndDestroy(bufHeap) ; // bufHeap |
|
966 if (ret==KErrNotSupported) |
|
967 User::Leave(KErrNotFound); |
|
968 } |
|
969 else // all global settings are one of these |
|
970 User::Leave(KErrNotFound); |
|
971 } |
|
972 } |