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