|
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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 #ifndef DBACCESS_H |
|
24 #define DBACCESS_H |
|
25 |
|
26 #include "dbdef.h" |
|
27 |
|
28 namespace |
|
29 { |
|
30 // Used to process Hidden and ReadOnly records. |
|
31 |
|
32 // We can't simply set ReadOnly / Hidden columns to their values. |
|
33 // We must intercept these columns, examine their values, and set |
|
34 // the record state. |
|
35 const TPtrC KHidden(COMMDB_HIDDEN); // field |
|
36 const TPtrC KReadOnly(COMMDB_READ_ONLY); // field |
|
37 const TPtrC KTrueVal(TRUE_VAL); // TRUE |
|
38 } |
|
39 |
|
40 class LinkByTagResolver; |
|
41 class DBAccess : public CBase |
|
42 /** |
|
43 @internalComponent |
|
44 */ |
|
45 { |
|
46 public: |
|
47 //not allowing implicit conversions... |
|
48 explicit DBAccess(const TBool aXML); |
|
49 ~DBAccess(); |
|
50 |
|
51 // access |
|
52 GLDEF_C void InitCommsdatL(); |
|
53 GLDEF_C void Close(); |
|
54 GLDEF_C void MaybeBeginTransactionL(); |
|
55 GLDEF_C TInt CommitTransaction(); |
|
56 GLDEF_C void CloseTable(); |
|
57 |
|
58 GLDEF_C TInt CommitChanges(); |
|
59 |
|
60 // miscellaneous |
|
61 GLDEF_C void SetFieldCount(TInt fields) { FieldCountExpected = fields; } |
|
62 GLDEF_C TInt GetFieldCount() { return FieldCountExpected; } |
|
63 GLDEF_C TVersion Version() { return dbVersion; } |
|
64 GLDEF_C TInt ErrorCode() { return iLastError; } |
|
65 GLDEF_C TPtrC ErrorText() { return LastErrorMessage; } |
|
66 GLDEF_C TInt GetActualFieldCount() { return iColCount; } |
|
67 GLDEF_C void CheckElementValidity(TBool aToggle) { iValidityChecking = aToggle; } |
|
68 |
|
69 GLDEF_C TBool IsNameSet() { return iNameSet; } |
|
70 GLDEF_C TInt GetRecordCount() { return iRecordCount; } |
|
71 GLDEF_C void RecordIsTemplate(TBool aIsTemplate); |
|
72 |
|
73 GLDEF_C void SetCommitIndividualRecords(TBool aValue) |
|
74 { |
|
75 iCommitIndividualRecords = aValue; |
|
76 } |
|
77 GLDEF_C TBool CommitIndividualRecords() const |
|
78 { |
|
79 return iCommitIndividualRecords; |
|
80 } |
|
81 |
|
82 //new |
|
83 enum TCreateType |
|
84 { |
|
85 ECreateNew, |
|
86 ECreateInsert, |
|
87 EInsert |
|
88 }; |
|
89 GLDEF_C void CreateOrInsertRecordL(TCreateType aType,TMDBElementId aRecordElementId, TInt aRecordId); |
|
90 GLDEF_C void RemoveRecord(TInt aPos); |
|
91 GLDEF_C TInt SetColAndAttribL(TPtrC& aColumn,TPtrC& aSetting); |
|
92 GLDEF_C TBool ConvertEnumsL(CMDBElement* aPtrField, TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
93 GLDEF_C TBool ConvertMiscEnums(CMDBElement* aPtrField, TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
94 GLDEF_C TBool ConvertModemEnums(CMDBElement* aPtrField,TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
95 GLDEF_C TBool ConvertGPRSEnums(CMDBElement* aPtrField,TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
96 GLDEF_C TBool ConvertCDMAEnums(CMDBElement* aPtrField,TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
97 GLDEF_C TBool ConvertConnectionPrefEnums(CMDBElement* aPtrField,TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
98 GLDEF_C TBool ConvertISPEnums(CMDBElement* aPtrField,TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
99 GLDEF_C TBool ConvertPANEnums(CMDBElement* aPtrField,TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
100 GLDEF_C TBool ConvertLinkRecords(CMDBElement* aPtrField, TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
101 GLDEF_C TBool CheckLegacyLinkRecords(TPtrC& aColumn,TPtrC& aSetting); |
|
102 GLDEF_C TBool SetLinkedRecord(TUint32 aIndex, CMDBElement* aPtrField,TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
103 GLDEF_C TBool ConvertAccessPointEnums(CMDBElement* aPtrField,TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
104 GLDEF_C TBool ConvertIapPrioritySelectionPolicyEnums(CMDBElement* aPtrField,TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
105 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
106 GLDEF_C TBool ConvertApPrioritySelectionPolicyEnums(CMDBElement* aPtrField,TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
107 #endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
108 GLDEF_C void DoInitAndAddL(CCDRecordBase* aNewRecord,TInt aRecordId); |
|
109 GLDEF_C void InitAndAddL(CCDRecordBase* aNewRecord,TInt aRecordId); |
|
110 GLDEF_C void SaveTableProtection(CMDBRecordSetBase* aRecordSet); |
|
111 GLDEF_C TBool AssignFieldValuesL(TPtrC& aColumn,TInt aTempType,CMDBElement* aPtrField,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
112 GLDEF_C TInt ConvertSpecialCharsL(TInt aTempType,CMDBElement* aPtrField,TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
113 GLDEF_C TBool ConvertWAPEnums(CMDBElement* aPtrField,TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
114 GLDEF_C void RemoveCurrentRecord(); |
|
115 GLDEF_C CMDBRecordBase* GetCurrentRecord(); |
|
116 GLDEF_C TBool IsConnectionPrefValid(CCDConnectionPrefsRecord& aConnectionPrefRecord); |
|
117 GLDEF_C TUint32 FindTableIdL(TDesC& aTableName); |
|
118 GLDEF_C TBool CheckBearer(CMDBElement* aPtrField,TPtrC aSetting); |
|
119 GLDEF_C TBool ConvertWLANEnums(CMDBElement* aPtrField,TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
120 GLDEF_C TBool ConvertEAPSecEnums(CMDBElement* aPtrField,TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
121 GLDEF_C TBool ConvertTUNEAPSecEnums(CMDBElement* aPtrField,TPtrC& aColumn,TPtrC& aSetting,TMDBAttributeFlags aAttribute); |
|
122 GLDEF_C void SetInAppendMode(TBool aInAppendMode) { iInAppendMode = aInAppendMode; } |
|
123 GLDEF_C TBool TemplateFieldPresentL(TMDBElementId aElementId); |
|
124 GLDEF_C void SetLinkByTagResolver(LinkByTagResolver* aResolver) { iLnkByTagRes = aResolver; } |
|
125 GLDEF_C void RemoveLinkByTagResolver() { iLnkByTagRes = NULL; } |
|
126 //This function is a getter/setter |
|
127 GLDEF_C TBool& CfgXmlSetting() { return iIsXML; } |
|
128 GLDEF_C void SetMeshProcessing(TBool aIsMeshProcessing) { iIsMeshFileProcessing = aIsMeshProcessing; } |
|
129 |
|
130 private: |
|
131 // intermediate data structures |
|
132 TInt ColCount; // amount of columns to update |
|
133 COLATTRIBUTES TargetCols[MAX_DB_COLUMNS]; // data for columns to update |
|
134 |
|
135 TBool iSecure; |
|
136 TBool iIsTemplate; |
|
137 TBool iConfusingTemplateBehaviour; |
|
138 TBool iNameSet; |
|
139 TBool iCommitIndividualRecords; // for special tables have to commit each record individually, else one duplicate will rollback all edits |
|
140 TBool iIsMeshFileProcessing; |
|
141 |
|
142 // miscellaneous |
|
143 TUint32 access; // access bitmask on a table |
|
144 TVersion dbVersion; // version of the database |
|
145 TInt iLastError; // ret value of last call |
|
146 TPtrC LastErrorMessage; // associated message if any |
|
147 TInt FieldCountExpected; // amount of field updates expected |
|
148 |
|
149 TMDBElementId iTableId; |
|
150 CMDBRecordSetBase* iTable; |
|
151 CMDBSession* iDbSession; |
|
152 TInt iRecordCount; |
|
153 TUint32 iRecordId; |
|
154 TInt iColCount; |
|
155 TBool iValidityChecking; |
|
156 |
|
157 TInt i2000PacketServiceTable; |
|
158 RPointerArray<CMDBRecordSetBase> iRecordSetHolder; |
|
159 |
|
160 GLDEF_C TInt Evaluate(TInt err); // determines if there's been an error |
|
161 TBool iInAppendMode; |
|
162 TBool iIsXML; |
|
163 //the class USES this pointer and doesn't own it!!! |
|
164 LinkByTagResolver* iLnkByTagRes; |
|
165 }; |
|
166 |
|
167 #endif |