24
|
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 |
#ifndef __DBUNDO_H__
|
|
17 |
#define __DBUNDO_H__
|
|
18 |
|
|
19 |
#include "commsdattypesv1_1.h"
|
|
20 |
#include <metadatabase.h>
|
|
21 |
using namespace CommsDat;
|
|
22 |
#include <e32base.h>
|
|
23 |
#include <e32std.h>
|
|
24 |
#include <e32def.h>
|
|
25 |
|
|
26 |
// For Connection Preferences table
|
|
27 |
#include <cdbpreftable.h>
|
|
28 |
|
|
29 |
// COMMDB Connection Preference settings
|
|
30 |
#include <comms-infras/connectionsettings.h>
|
|
31 |
|
|
32 |
// Indexes of the CDMA, GPRS and Dial Out IAP records
|
|
33 |
// Dependent on the database used
|
|
34 |
|
|
35 |
#define KGprsIAPIndex 2
|
|
36 |
#define KDialOutIAPIndex 1
|
|
37 |
|
|
38 |
_LIT( KDialOutIap, "DialOutIsp" );
|
|
39 |
_LIT( KGprsIap, "NTRas GPRS" );
|
|
40 |
class CBearerUpdate
|
|
41 |
{
|
|
42 |
public:
|
|
43 |
TUint32 iBearerSet;
|
|
44 |
TUint32 iIapId;
|
|
45 |
};
|
|
46 |
|
|
47 |
class CConnectionPrefUpdate
|
|
48 |
{
|
|
49 |
public:
|
|
50 |
TUint32 iRanking;
|
|
51 |
CMDBField<TCommDbConnectionDirection> iDirection;
|
|
52 |
TUint32 iDialogPref;
|
|
53 |
CBearerUpdate iBearer;
|
|
54 |
};
|
|
55 |
|
|
56 |
// Classes to maintain an "undo" linked list to restore database state
|
|
57 |
// between tests
|
|
58 |
class CDbAgtBase;
|
|
59 |
|
|
60 |
// Base class for storing undo data, derived classes store data specific to the
|
|
61 |
// type of column we're dealing with
|
|
62 |
class CDbUndoBase : public CBase
|
|
63 |
{
|
|
64 |
public:
|
|
65 |
virtual void UndoL(CDbAgtBase *aTable)=0;
|
|
66 |
|
|
67 |
public:
|
|
68 |
TDblQueLink iLink;
|
|
69 |
|
|
70 |
protected:
|
|
71 |
TPtrC iColumn;
|
|
72 |
};
|
|
73 |
|
|
74 |
// Derived from CDbUndoBase to store integer values requiring Undo
|
|
75 |
class CDbUndoInt : public CDbUndoBase
|
|
76 |
{
|
|
77 |
public:
|
|
78 |
|
|
79 |
static CDbUndoInt* NewL(const TDesC &aColumn, const TUint32 &aValue);
|
|
80 |
void ConstructL(const TDesC &aColumn, const TUint32 &aValue);
|
|
81 |
|
|
82 |
// Concrete implementation of pure virtual in CDbUndoBase
|
|
83 |
virtual void UndoL(CDbAgtBase *aDb);
|
|
84 |
|
|
85 |
private:
|
|
86 |
// Data specific to the type of column we're are dealing with
|
|
87 |
// In this class we undo integer data.
|
|
88 |
TUint32 iValue;
|
|
89 |
};
|
|
90 |
|
|
91 |
// Derived from CDbUndoBase to store boolean values requiring Undo
|
|
92 |
class CDbUndoBool : public CDbUndoBase
|
|
93 |
{
|
|
94 |
public:
|
|
95 |
|
|
96 |
static CDbUndoBool* NewL(const TDesC &aColumn, const TBool &aValue);
|
|
97 |
void ConstructL(const TDesC &aColumn, const TBool &aValue);
|
|
98 |
|
|
99 |
// Concrete implementation of pure virtual in CDbUndoBase
|
|
100 |
virtual void UndoL(CDbAgtBase *aDb);
|
|
101 |
|
|
102 |
private:
|
|
103 |
// Data specific to the type of column we're are dealing with
|
|
104 |
// In this class we undo boolean data.
|
|
105 |
TBool iValue;
|
|
106 |
};
|
|
107 |
|
|
108 |
// Derived from CDbUndoBase to store text values requiring Undo
|
|
109 |
class CDbUndoText : public CDbUndoBase
|
|
110 |
{
|
|
111 |
public:
|
|
112 |
|
|
113 |
static CDbUndoText* NewL(const TDesC &aColumn, const TDesC16& aValue);
|
|
114 |
void ConstructL(const TDesC &aColumn, const TDesC16& aValue);
|
|
115 |
|
|
116 |
// Concrete implementation of pure virtual in CDbUndoBase
|
|
117 |
virtual void UndoL(CDbAgtBase *aDb);
|
|
118 |
|
|
119 |
private:
|
|
120 |
// Data specific to the type of column we're are dealing with
|
|
121 |
// In this class we undo text data.
|
|
122 |
TBuf16<KCommsDbSvrMaxFieldLength> iText;
|
|
123 |
};
|
|
124 |
|
|
125 |
// Derived from CDbUndoBase to store long text values requiring Undo
|
|
126 |
class CDbUndoLongText : public CDbUndoBase
|
|
127 |
{
|
|
128 |
public:
|
|
129 |
|
|
130 |
static CDbUndoLongText* NewL(const TDesC &aColumn, const HBufC* aValue);
|
|
131 |
void ConstructL(const TDesC &aColumn, const HBufC* aValue);
|
|
132 |
|
|
133 |
// Concrete implementation of pure virtual in CDbUndoBase
|
|
134 |
virtual void UndoL(CDbAgtBase *aDb);
|
|
135 |
|
|
136 |
private:
|
|
137 |
// Data specific to the type of column we're are dealing with
|
|
138 |
// In this class we undo long text data.
|
|
139 |
HBufC* iLongText;
|
|
140 |
};
|
|
141 |
|
|
142 |
// Derived from CDbUndoBase to store agent extension name requiring Undo
|
|
143 |
class CDbUndoAgentExt : public CDbUndoBase
|
|
144 |
{
|
|
145 |
public:
|
|
146 |
|
|
147 |
static CDbUndoAgentExt* NewL(const TDesC &aService, const TDesC& aAgentExt);
|
|
148 |
void ConstructL(const TDesC &aService, const TDesC& aAgentExt);
|
|
149 |
|
|
150 |
// Concrete implementation of pure virtual in CDbUndoBase
|
|
151 |
virtual void UndoL(CDbAgtBase *aDb);
|
|
152 |
|
|
153 |
private:
|
|
154 |
// Data specific to the type of column we're are dealing with
|
|
155 |
// In this class we undo text data.
|
|
156 |
TBuf16<KCommsDbSvrMaxFieldLength> iText;
|
|
157 |
};
|
|
158 |
|
|
159 |
// Base class for all database access
|
|
160 |
class CDbAgtBase : public CBase
|
|
161 |
{
|
|
162 |
friend class CDbUndoInt;
|
|
163 |
friend class CDbUndoBool;
|
|
164 |
friend class CDbUndoText;
|
|
165 |
friend class CDbUndoLongText;
|
|
166 |
friend class CDbUndoAgentExt;
|
|
167 |
public:
|
|
168 |
~CDbAgtBase();
|
|
169 |
void SetColumnIntL(const TDesC& aColumn, const TUint32& aValue);
|
|
170 |
void SetColumnBoolL(const TDesC& aColumn, const TBool& aValue);
|
|
171 |
void SetColumnTextL(const TDesC& aColumn, const TDesC16& aValue);
|
|
172 |
void SetColumnLongTextL(const TDesC& aColumn, const TDesC16& aValue);
|
|
173 |
void SetAgentExtL(const TDesC& aService, const TDesC& aAgentExt);
|
|
174 |
void UndoDatabaseChangesL();
|
|
175 |
|
|
176 |
protected:
|
|
177 |
CDbAgtBase();
|
|
178 |
void ConstructL();
|
|
179 |
|
|
180 |
|
|
181 |
protected:
|
|
182 |
// Used to access the database and retain a view on whichever table is of interest
|
|
183 |
CMDBSession *iDb;
|
|
184 |
CMDBRecordSetBase* iTable;
|
|
185 |
TUint iCurrentRecord;
|
|
186 |
|
|
187 |
private:
|
|
188 |
void ModifyColumnIntL(const TDesC& aColumn, const TUint32& aValue);
|
|
189 |
void ModifyColumnBoolL(const TDesC& aColumn, const TBool& aValue);
|
|
190 |
void ModifyColumnTextL(const TDesC& aColumn, const TDesC16& aValue);
|
|
191 |
void ModifyColumnLongTextL(const TDesC& aColumn, const TDesC16& aValue);
|
|
192 |
void ModifyAgentExtL(const TDesC &aService, const TDesC& aAgentExt);
|
|
193 |
|
|
194 |
private:
|
|
195 |
// Double linked list header for undo functionality
|
|
196 |
TDblQue<CDbUndoBase> iQHeader;
|
|
197 |
|
|
198 |
// Double linked list iterator for undo functionality
|
|
199 |
TDblQueIter<CDbUndoBase> iQIter;
|
|
200 |
|
|
201 |
};
|
|
202 |
|
|
203 |
|
|
204 |
// GPRS OUTGOING specific class
|
|
205 |
class CDbGPRSOutgoingTable : public CDbAgtBase
|
|
206 |
{
|
|
207 |
public:
|
|
208 |
static CDbGPRSOutgoingTable *NewL();
|
|
209 |
~CDbGPRSOutgoingTable();
|
|
210 |
|
|
211 |
private:
|
|
212 |
CDbGPRSOutgoingTable();
|
|
213 |
void ConstructL();
|
|
214 |
};
|
|
215 |
|
|
216 |
// CSD specific class
|
|
217 |
class CDbCsdTable : public CDbAgtBase
|
|
218 |
{
|
|
219 |
public:
|
|
220 |
static CDbCsdTable *NewL();
|
|
221 |
~CDbCsdTable();
|
|
222 |
|
|
223 |
private:
|
|
224 |
CDbCsdTable();
|
|
225 |
void ConstructL();
|
|
226 |
};
|
|
227 |
|
|
228 |
// MODEM specific class
|
|
229 |
class CDbModemTable : public CDbAgtBase
|
|
230 |
{
|
|
231 |
public:
|
|
232 |
static CDbModemTable *NewL();
|
|
233 |
~CDbModemTable();
|
|
234 |
|
|
235 |
private:
|
|
236 |
CDbModemTable();
|
|
237 |
void ConstructL();
|
|
238 |
};
|
|
239 |
|
|
240 |
// Preference table
|
|
241 |
class CDbPrefTable : public CDbAgtBase
|
|
242 |
{
|
|
243 |
public:
|
|
244 |
static CDbPrefTable *NewL( CMDBField<TCommDbConnectionDirection> aDirection, CBearerUpdate aBearerUpdate, TBool aReadOnly, TUint32 aDialogPref );
|
|
245 |
~CDbPrefTable();
|
|
246 |
|
|
247 |
private:
|
|
248 |
CDbPrefTable();
|
|
249 |
void ConstructL();
|
|
250 |
void RevertPreferenceTableL();
|
|
251 |
CMDBRecordSet<CCDConnectionPrefsRecord>* iPrefTable;
|
|
252 |
TUint iCurrentPrefRecord;
|
|
253 |
|
|
254 |
TBuf16<KCommsDbSvrMaxFieldLength> iIapName;
|
|
255 |
CMDBField<TCommDbConnectionDirection> iDirection;
|
|
256 |
CBearerUpdate iBearerUpdate;
|
|
257 |
CConnectionPrefUpdate iOldPrefs;
|
|
258 |
TBool iReadOnly;
|
|
259 |
TUint32 iDialogPref;
|
|
260 |
};
|
|
261 |
|
|
262 |
// IAP table
|
|
263 |
class CDbIapTable : public CDbAgtBase
|
|
264 |
{
|
|
265 |
public:
|
|
266 |
static CDbIapTable *NewL(const TDesC16& aIapName);
|
|
267 |
~CDbIapTable();
|
|
268 |
void GetBearerSetIapIdL(TUint32& aIapId);
|
|
269 |
|
|
270 |
private:
|
|
271 |
CDbIapTable();
|
|
272 |
void ConstructL();
|
|
273 |
TBuf16<KCommsDbSvrMaxFieldLength> iIapName;
|
|
274 |
};
|
|
275 |
|
|
276 |
#endif // DBUNDO
|