commsconfig/commsdatabaseshim/commdbshim/INC/COMMDB.H
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     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 // Comms Database public interface
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @deprecated since v9.1. Functionality is replaced with commsdat.
       
    21 */
       
    22 
       
    23 #ifndef COMMDB_H
       
    24 #define	COMMDB_H
       
    25 
       
    26 #include <d32dbms.h>
       
    27 #include <metadatabase.h>
       
    28 
       
    29 using namespace CommsDat;
       
    30 
       
    31 #include <dial.h>
       
    32 #include <cdbcols.h>
       
    33 #include <cdblen.h>
       
    34 
       
    35 /**
       
    36 Protection of settings: when the entire table is protected, write operations
       
    37 fail with KErrWrite. However KErrAccessDenied should be returned to client
       
    38 @internalComponent
       
    39 */
       
    40 #define TRAPD_CONVERT(_r,_s)	TRAPD(_r,_s); if(ret == KErrWrite) ret = KErrAccessDenied;
       
    41 /**
       
    42 @internalComponent
       
    43 */
       
    44 #define  TRAP_CONVERT(_r,_s)	TRAP(_r,_s);  if(ret == KErrWrite) ret = KErrAccessDenied;
       
    45 
       
    46 class CCommsDbTableView;
       
    47 class CCommsDbConnectionPrefTableView;
       
    48 class CCommDbTableExtension;
       
    49 class CCommsDatabaseImpl;
       
    50 
       
    51 class CCommsDatabaseBase : public CBase
       
    52 /** Base class for CCommsDatabase.
       
    53 
       
    54 This class is never instantiated, but its member functions are used through
       
    55 the derived class.
       
    56 
       
    57 Responsible for Transactions, Notifications, Write protection, Hidden
       
    58 records, Phone number resolution and Creating views. Stores the database, the
       
    59 session, transaction and notifier information.
       
    60 
       
    61 CCommsDatabaseBase is an abstract base class as the CreateDatabaseL() and
       
    62 Open() methods are pure virtual.
       
    63 @publishedAll
       
    64 @released */
       
    65 	{
       
    66 public:
       
    67     // These classes added as friends for commdb shim
       
    68 	friend class CCommsDbTableView;
       
    69 	friend class CCommsDbConnectionPrefTableView;
       
    70 	friend class CCommsDbProtectTableView;
       
    71 	friend class CCommsDbProtectConnectPrefTableView;
       
    72     friend class CCommsDbTemplateRecord;
       
    73 public:
       
    74 	IMPORT_C virtual ~CCommsDatabaseBase();
       
    75 
       
    76 	// Returns the version of the database server.
       
    77 	IMPORT_C TVersion Version() const;
       
    78 	// Begin a transaction. Call before `InsertRecord()` or `UpdateRecord()`.
       
    79 	IMPORT_C TInt BeginTransaction();
       
    80 	// End a transaction. Call after `InsertRecord()` or `UpdateRecord()`.
       
    81 	IMPORT_C TInt CommitTransaction();
       
    82 	// Cancel a transaction.
       
    83 	IMPORT_C void RollbackTransaction();
       
    84 	// True if BeginTransaction() has been called but not
       
    85 	//	`CommitTransaction()` or `RollbackTransaction()`.
       
    86 	IMPORT_C TBool InTransaction();
       
    87 	// True if the database has been locked.
       
    88 	IMPORT_C TBool IsDatabaseWriteLockedL();
       
    89 
       
    90 	// Enable a notification event on any change to the database.
       
    91 	IMPORT_C TInt RequestNotification(TRequestStatus& aStatus);
       
    92 	// Cancels notifications.
       
    93 	IMPORT_C void CancelRequestNotification();
       
    94 
       
    95 	// Obtain a view of all records in a table.
       
    96 	IMPORT_C CCommsDbTableView* OpenTableLC(const TDesC& aTableName);
       
    97 	// Obtain a view of the records in a table that match the query.
       
    98 	IMPORT_C CCommsDbTableView* OpenViewLC(const TDesC& aTableName, const TDesC& aSqlQuery);
       
    99 	// Obtain a view of all the records in a table for which the field
       
   100 	//	`aColumnToMatch` matches `aValueToMatch`.
       
   101 	IMPORT_C CCommsDbTableView* OpenViewMatchingUintLC(const TDesC& aTableName, const TDesC& aColumnToMatch, TUint32 aValueToMatch);
       
   102 	IMPORT_C CCommsDbTableView* OpenViewMatchingBoolLC(const TDesC& aTableName, const TDesC& aColumnToMatch, TBool aValueToMatch);
       
   103 	IMPORT_C CCommsDbTableView* OpenViewMatchingTextLC(const TDesC& aTableName, const TDesC& aColumnToMatch, const TDesC8& aValueToMatch);
       
   104 	IMPORT_C CCommsDbTableView* OpenViewMatchingTextLC(const TDesC& aTableName, const TDesC& aColumnToMatch, const TDesC16& aValueToMatch);
       
   105 
       
   106 	// Make hidden records visible
       
   107 	IMPORT_C void ShowHiddenRecords();
       
   108 
       
   109 	//  Set `aDialString` to be the appropriate string based on the directory
       
   110 	//	number, where the dial is being performed and the chargecard to use.
       
   111 	//	`ResolvePhoneNumberL()` opens a comms database to perform the
       
   112 	//	resolution
       
   113 	IMPORT_C static void ResolvePhoneNumberL(TDesC& aNumber, TDes& aDialString, TParseMode aDialParseMode, TUint32 aLocationId, TUint32 aChargecardId);
       
   114 	// Set `aDialString` to be the appropriate string based on the directory
       
   115 	//	number, where the dial is being performed and the chargecard to use.
       
   116 	IMPORT_C void ResolvePhoneNumberFromDatabaseL(TDesC& aNumber, TDes& aDialString, TParseMode aDialParseMode, TUint32 aLocationId, TUint32 aChargecardId);
       
   117 	IMPORT_C static TInt InitializeFilestore();
       
   118 
       
   119 	// Check access to database fields
       
   120 	IMPORT_C TInt CheckReadCapability( const TDesC& aField, const RMessagePtr2* aMessage );
       
   121 	IMPORT_C TInt CheckWriteCapability( const TDesC& aField, const RMessagePtr2* aMessage );
       
   122 
       
   123 protected:
       
   124 	// internal
       
   125 	// Please note that as of v9.0 TCommDbSystemAgentNotification now actually contains
       
   126 	// the notification information for the Publish and Subscribe notifications, not
       
   127 	// for System Agent notifications.
       
   128 	class TCommDbSystemAgentNotification
       
   129 	/**
       
   130 	@publishedAll
       
   131 	@deprecated
       
   132 	*/
       
   133 		{
       
   134 	public:
       
   135 		TCommDbSystemAgentNotification();
       
   136 		void Set(TUid aUid, TInt aVal);
       
   137 	public:
       
   138 		TUid iUid;
       
   139 		TInt iValue;
       
   140 		};
       
   141 
       
   142 	class TCommDbPublishSubscribeNotification
       
   143 	/**
       
   144 	@internalComponent
       
   145 	@released
       
   146 	*/
       
   147 		{
       
   148 	public:
       
   149 		TCommDbPublishSubscribeNotification();
       
   150 		void Set(TUid aUid, TInt aVal);
       
   151 	public:
       
   152 		TUid iUid;
       
   153 		TInt iValue;
       
   154 		};
       
   155 
       
   156 protected:
       
   157 	// internal
       
   158 	IMPORT_C CCommsDatabaseBase();
       
   159 	// internal
       
   160 	virtual void CreateDatabaseL() =0;
       
   161 	//
       
   162 	void DoClose();
       
   163 	CCommsDbTableView* DoOpenViewMatchingUintL(const TDesC& aTableName, const TDesC& aColumnToMatch, TUint32 aValueToMatch, TBool aIncludeHiddenRecords);
       
   164 	CCommsDbTableView* DoOpenViewMatchingTextL(const TDesC& aTableName, const TDesC& aColumnToMatch, const TDesC8& aValueToMatch, TBool aIncludeHiddenRecords);
       
   165 	CCommsDbTableView* DoOpenViewMatchingTextL(const TDesC& aTableName, const TDesC& aColumnToMatch, const TDesC16& aValueToMatch, TBool aIncludeHiddenRecords);
       
   166 	CCommsDbTableView* DoOpenTableViewL(const TDesC& aTableName, const TDesC& aSqlQuery);
       
   167 	CCommsDbTableView* DoOpenIAPTableViewL(const TDesC& aTableName,const TDesC& aSqlQuery);
       
   168 	//
       
   169 	void PopulateDialLocationL(TUint32 aId, TDialLocation& aLocation);
       
   170 	void PopulateChargeCardL(TUint32 aId, TChargeCard& aChargeCard);
       
   171 	void BeginInternalTransactionL();
       
   172 	TInt CommitInternalTransaction();
       
   173 	void RollbackInternalTransaction();
       
   174 	void DatabaseUpdateHasOccurred();
       
   175 	void NotifyChangeL(const TDesC& aSetting, TUint32 aVal);
       
   176 	TInt NotifyAllChanges();
       
   177 
       
   178 	TUint32 GetNewNumber(TUid aUid);
       
   179 	TInt CheckDBCapability( RDbs::TPolicyType aType, const TDesC& aField, const RMessagePtr2* aMessage );
       
   180 	void ConvertToUid(const TDesC& aSetting, TUint32 aVal, TCommDbPublishSubscribeNotification& aNotification);
       
   181 
       
   182 	inline RDbNamedDatabase* Database();
       
   183 protected:
       
   184 	//internal
       
   185 	CCommsDatabaseImpl* iImpl;
       
   186 	RDbNamedDatabase iDatabase;
       
   187 	RDbNotifier iNotifier;
       
   188 	// store container data for deletion after session is finished
       
   189 	//RPointerArray<CMDBElement> iTransactionCache;
       
   190 
       
   191 	TInt iNotifierOpenError;
       
   192 	TBool iShowHiddenRecords;
       
   193 	TBool iImplNotCreated;
       
   194 	TBool iInInternalTransaction;
       
   195 
       
   196 	RArray<TCommDbPublishSubscribeNotification> iNotifications;
       
   197 private:
       
   198 	// Check access to database fields
       
   199 	TInt DoCheckReadCapabilityL( const TDesC& aField, const RMessagePtr2* aMessage );
       
   200 	TInt DoCheckWriteCapabilityL( const TDesC& aField, const RMessagePtr2* aMessage );
       
   201 
       
   202 	TBool ConvertTableName(const TDesC& aTableName, TDes& aResult);
       
   203 	};
       
   204 
       
   205 class CCommsDatabase : public CCommsDatabaseBase
       
   206 /**
       
   207 Accesses the communications database through the DBMS.
       
   208 
       
   209 An object of this type must be constructed and opened by a client before any
       
   210 of the tables in the database can be accessed, e.g. to create views and access
       
   211 template records.
       
   212 
       
   213 Implements the pure virtual functions CreateDatabaseL() and DoOpen().
       
   214 Responsible for Global settings and Connection Preferences. Has utility
       
   215 functions for accessing Global and Agent tables. No additional state (to
       
   216 CCommsDatabaseBase) is stored.
       
   217 @publishedAll
       
   218 @released */
       
   219 	{
       
   220 public:
       
   221 	IMPORT_C static CCommsDatabase* NewL();
       
   222 	IMPORT_C static CCommsDatabase* NewL(TBool aUseDefaultDb);
       
   223 	IMPORT_C static CCommsDatabase* NewL(TCommDbOpeningMethod &aOpeningMethod);
       
   224 	IMPORT_C virtual ~CCommsDatabase();
       
   225 	IMPORT_C void GetGlobalSettingL(const TDesC& aSetting, TUint32& aValue);
       
   226 	IMPORT_C void GetGlobalSettingL(const TDesC& aSetting, TDes& aValue);
       
   227 	IMPORT_C void SetGlobalSettingL(const TDesC& aSetting, TUint32 aValue);
       
   228 	IMPORT_C void SetGlobalSettingL(const TDesC& aSetting, const TDesC& aValue);
       
   229 	IMPORT_C void ClearGlobalSettingL(const TDesC& aSetting);
       
   230 	IMPORT_C void GetDefaultTsyL(TDes& aValue);
       
   231 
       
   232 	// Deprecated. Past use: Gets settings (Modem, Chargecard, and Service) for the dial out IAP.
       
   233 	IMPORT_C void GetCurrentDialOutSettingL(const TDesC& aSetting, TUint32& aValue);
       
   234 	// Deprecated. Past use: Retrieve settings for the dial in IAP.
       
   235 	IMPORT_C void GetCurrentDialInSettingL(const TDesC& aSetting, TUint32& aValue);
       
   236 	// Open a connection preference view.
       
   237 	IMPORT_C CCommsDbConnectionPrefTableView* OpenConnectionPrefTableLC();
       
   238 	// Open a connection preference view containing connections of the
       
   239 	//	specified direction.
       
   240 	IMPORT_C CCommsDbConnectionPrefTableView* OpenConnectionPrefTableLC(TCommDbConnectionDirection aDirection);
       
   241 	// Open a connection preference view containing connections of the
       
   242 	// specified direction excluding connections of rank zero.
       
   243 	IMPORT_C CCommsDbConnectionPrefTableView* OpenConnectionPrefTableInRankOrderLC(TCommDbConnectionDirection aDirection);
       
   244 	// Open a connection preference view containing connections of the
       
   245 	//	specified direction and rank.
       
   246 	IMPORT_C CCommsDbConnectionPrefTableView* OpenConnectionPrefTableViewOnRankLC(TCommDbConnectionDirection aDirection, TUint32 aRank);
       
   247 
       
   248 	//DEPRECATED : Agent table has been removed. These functions have been
       
   249 	//				stubbed to return KErrNotSupported or leave with the same error.
       
   250 	// Access agent settings. `aService` is one of: (`DIAL_OUT_ISP`,
       
   251 	//	`DIAL_IN_ISP`, `OUTGOING_WCDMA'). */
       
   252 	IMPORT_C void SetAgentL(const TDesC& aService, const TDesC& aAgent);
       
   253 
       
   254 	IMPORT_C void SetAgentExtL(const TDesC& aService, const TDesC& aAgentExt);
       
   255 	IMPORT_C void GetAgentL(const TDesC& aService, TDes& aAgent);
       
   256 	IMPORT_C void GetAgentExtL(const TDesC& aService, TDes& aAgentExt);
       
   257 	IMPORT_C void ClearAgentAndExtL(const TDesC& aService);
       
   258 	IMPORT_C void SetAgentClientTimeoutL(const TDesC& aService, TInt aClientTimeout);
       
   259 	IMPORT_C void SetAgentRouteTimeoutL(const TDesC& aService, TInt aRouteTimeout);
       
   260 	IMPORT_C TInt GetAgentClientTimeoutL(const TDesC& aService);
       
   261 	IMPORT_C TInt GetAgentRouteTimeoutL(const TDesC& aService);
       
   262 
       
   263 	/** Open a view on the IAP table containing records that match the
       
   264 		bearers and direction specified. `aBearerSet` is a bit mask of type
       
   265 		`TCommDbBearer`. */
       
   266 	IMPORT_C CCommsDbTableView* OpenIAPTableViewMatchingBearerSetLC(TUint32 aBearerSet, TCommDbConnectionDirection aDirection);
       
   267 
       
   268 	/** Open a viewon the IAP table containing records which match the specified network */
       
   269 	IMPORT_C CCommsDbTableView* OpenIAPTableViewMatchingNetworkLC(TUint32 aNetwork);
       
   270 
       
   271 	// Open a view on the proxy table containing records that match the
       
   272 	//	service id and type specified.
       
   273 	IMPORT_C CCommsDbTableView* OpenViewOnProxyRecordLC(TUint32 aServiceId, const TDesC& aServiceType);
       
   274 
       
   275 	// Functionality re-implemented to facilitate BC with 6.1
       
   276 	IMPORT_C static CCommsDatabase* NewL(TCommDbDatabaseType aDbType);
       
   277 	// Creates a `CCommsDatabase` as with `NewL()`. The method of opening:
       
   278 	//	(Created, CopiedDefault or Opened) is returned in `aOpeningMethod`.
       
   279 	IMPORT_C static CCommsDatabase* NewL(TCommDbDatabaseType aDbType, TCommDbOpeningMethod &aOpeningMethod);
       
   280 
       
   281 private:
       
   282 	enum TGlobalSettingType
       
   283 		{
       
   284 		ENotASetting,
       
   285 		EGlobalSetting,
       
   286 		ECompatibilitySetting
       
   287 		};
       
   288 protected:
       
   289 	CCommsDatabase();
       
   290 	void DoOpenL(TCommDbOpeningMethod& aOpeningMethod,TBool aUseDefaultDb);
       
   291 private:
       
   292 	/** CCommsDatabaseBase pure virtuals */
       
   293 
       
   294 	virtual void CreateDatabaseL();
       
   295 	CCommsDbTableView* OpenGlobalSettingsTableLC(const TDesC& aSetting, TBool& aExists);
       
   296 	TGlobalSettingType GlobalSettingTypeL(const TDesC& aSetting) const;
       
   297 
       
   298 	};
       
   299 
       
   300 class CCommsDbTemplateRecord;
       
   301 
       
   302 class CCommsDbTableView : public CBase
       
   303 /**
       
   304 
       
   305 The view on a specific table in the database.
       
   306 
       
   307 Includes the necessary behaviour for navigating through the records in
       
   308 the view and reading and writing to columns within a record.
       
   309 
       
   310 Uses a CCommsDatabase and has an RDbView to read from and write to database. Created via
       
   311 CCommsDatabase::OpenTableLC() (which opens a view of all the records in the table) or one
       
   312 of the OpenViewLC...() functions (which open a specific view of the table):
       
   313 
       
   314 CCommsDatabase::OpenTableLC()
       
   315 
       
   316 CCommsDatabase::OpenViewMatchingUintLC()
       
   317 
       
   318 CCommsDatabase::OpenViewMatchingBoolLC()
       
   319 
       
   320 CCommsDatabase::OpenViewMatchingTextLC()
       
   321 
       
   322 CCommsDatabase::OpenViewLC()
       
   323 
       
   324 Note that the above five functions have been withdrawn in CCommsDatabase and
       
   325 are now implemented in CCommsDatabaseBase.
       
   326 @publishedAll
       
   327 @released */
       
   328 	{
       
   329 public:
       
   330 	friend class CCommsDatabaseBase;
       
   331 	friend class CCommsDbTemplateRecord;
       
   332 public:
       
   333 	// Low level view creation. Use if `CCommsDatabase::OpenTableLC()` or
       
   334 	//`CCommsDatabase::OpenViewLC...()` are not sufficient.
       
   335 	static CCommsDbTableView* NewL(CCommsDatabaseBase& aDb, const TDesC& aTableName, const TDbQuery& aQuery, TBool aUseTemplate = ETrue);
       
   336 	static CCommsDbTableView* NewLC(const TDesC& aTableName, CCommsDatabaseBase& aDb);
       
   337 	// additional constructors, commdb shim specific
       
   338 	static CCommsDbTableView* NewLC(CCommsDatabaseBase& aDb, const TDesC& aTableName, TBool aUseTamplate = ETrue); 	// ETrue if template is instantiating
       
   339 	static CCommsDbTableView* NewL(CCommsDatabaseBase& aDb, const TDesC& aTableName, const TDesC& aColumnToMatch, const TDesC8& aValueToMatch);
       
   340 	static CCommsDbTableView* NewL(CCommsDatabaseBase& aDb, const TDesC& aTableName, const TDesC& aColumnToMatch, const TDesC16& aValueToMatch);
       
   341 	static CCommsDbTableView* NewL(CCommsDatabaseBase& aDb, const TDesC& aTableName, const TDesC& aColumnToMatch, TUint32 aValueToMatch);
       
   342 	static CCommsDbTableView* NewLC(CCommsDatabaseBase& aDb, const TDesC& aTableName, const TDesC& aColumnToMatch, TBool aValueToMatch);
       
   343 	// this two are for IAP table only so table name is not needed
       
   344 	static CCommsDbTableView* NewLC(CCommsDatabaseBase& aDb, TUint32 aBearerSet,	TCommDbConnectionDirection aDirection);
       
   345 	static CCommsDbTableView* NewLC(CCommsDatabaseBase& aDb, TUint32 aNetworkId);
       
   346 	//  this one is for Proxie table only
       
   347 	static CCommsDbTableView* NewLC(CCommsDatabaseBase& aDb, TUint32 aServiceId, const TDesC& aServiceType);
       
   348 
       
   349 	CCommsDbTableView(CCommsDatabaseBase& aDb, const TDesC& aTableName);
       
   350 
       
   351 	IMPORT_C virtual ~CCommsDbTableView();
       
   352 
       
   353 	// Add a new record to this table. The record number is returned.
       
   354 	//	`PutRecordChanges()` is called to complete the transaction
       
   355 	IMPORT_C TInt InsertRecord(TUint32& aId);
       
   356 	/** Add a new record to this table. Filling all empty fields with values copied
       
   357 		from record currently pointed at. The record number is returned.
       
   358 		`PutRecordChanges()` is called to complete the transaction */
       
   359 	IMPORT_C TInt InsertCopyRecord(TUint32& aId);
       
   360 	/** Modify the current record of this view. `PutRecordChanges()` is called
       
   361 		to complete the transaction */
       
   362 	IMPORT_C TInt UpdateRecord();
       
   363 	// Remove the current record from the table.
       
   364 	IMPORT_C TInt DeleteRecord();
       
   365 	// Store an inserted or updated record back to the database.
       
   366 	IMPORT_C TInt PutRecordChanges(TBool aHidden = EFalse, TBool aReadOnly = EFalse);
       
   367 	// Cancel pending changes since an insert or update.
       
   368 	IMPORT_C void CancelRecordChanges();
       
   369 	//
       
   370 	// Navigate throught the records in the view
       
   371 	//
       
   372 	IMPORT_C TInt GotoFirstRecord();
       
   373 	IMPORT_C TInt GotoNextRecord();
       
   374 	IMPORT_C TInt GotoPreviousRecord();
       
   375 	//
       
   376 	// Access data from the current record
       
   377 	//
       
   378 	IMPORT_C void ReadTextL(const TDesC& aColumn, TDes8& aValue);
       
   379 	IMPORT_C void ReadTextL(const TDesC& aColumn, TDes16& aValue);
       
   380 	IMPORT_C HBufC* ReadLongTextLC(const TDesC& aColumn);
       
   381 	IMPORT_C void ReadUintL(const TDesC& aColumn, TUint32& aValue);
       
   382 	IMPORT_C void ReadBoolL(const TDesC& aColumn, TBool& aValue);
       
   383 	// Determine the type and attributes of a column. The type is one of:
       
   384 	//	(EDbColBit, EDbColUint32, EDbColText8, EDbColText16, EDbColLongText16).
       
   385 	//	The attribute is a bit mask of: (ENotNull and EAutoIncrement).
       
   386 	IMPORT_C void ReadTypeAttribL(const TDesC& aColumn, TDbColType& aColType, TUint32& aAttrib);
       
   387 	// Null columns return 0, integers and bools 1, strings return their length in characters.
       
   388 	IMPORT_C void ReadColumnLengthL(const TDesC& aColumn, TInt& aLength);
       
   389 
       
   390 	//
       
   391 	// Modify an inserted or modified record. Must call `PutRecordChanges()`
       
   392 	//	to store the changes.
       
   393 	//
       
   394 	IMPORT_C void WriteTextL(const TDesC& aColumn, const TDesC8& aValue);
       
   395 	IMPORT_C void WriteTextL(const TDesC& aColumn, const TDesC16& aValue);
       
   396 	IMPORT_C void WriteLongTextL(const TDesC& aColumn, const TDesC& aValue);
       
   397 	IMPORT_C void WriteUintL(const TDesC& aColumn, const TUint32& aValue);
       
   398 	IMPORT_C void WriteBoolL(const TDesC& aColumn, const TBool& aValue);
       
   399 	IMPORT_C void SetNullL(const TDesC& aColumn);
       
   400 
       
   401 	IMPORT_C void ReadColumnMaxLengthL(const TDesC& aColumn, TInt& aLength);
       
   402 	inline CCommsDatabaseBase* Database() const { return &iDb; }
       
   403 
       
   404 	void  OpenL(const TDbQuery& aQuery);
       
   405 
       
   406 	inline void GetTableName(TDes& aTableName) const;
       
   407 protected:
       
   408 	TDbColNo ColNumL(const TDesC& aColumn) const;
       
   409 	void Close();
       
   410 	void ConstructL(const TDesC& aTableName, TBool aShowHidden, TBool aUseTemplate);
       
   411 	void ConstructL(const TDbQuery& aQuery, TBool aUseTemplate);
       
   412 	RDbRowSet::TAccess GetL();
       
   413 
       
   414 	// All other ConstructructL methods are added for commdb shimm
       
   415 	void ConstructL(const TDesC& aTableName, const TDesC& aColumnToMatch, const TDesC8& aValueToMatch);
       
   416 	void ConstructL(const TDesC& aTableName, const TDesC& aColumnToMatch, const TDesC16& aValueToMatch);
       
   417 	void ConstructL(const TDesC& aTableName, const TDesC& aColumnToMatch, TUint32 aValueToMatch);
       
   418 	void ConstructL(const TDesC& aTableName, const TDesC& aColumnToMatch, TBool aValueToMatch);
       
   419 	void ConstructL(TUint32 aBearerSet,	TCommDbConnectionDirection aDirection);
       
   420 	void ConstructL(TUint32 aNetworkId);
       
   421 	void ConstructL(TUint32 aServiceId, const TDesC& aServiceType);
       
   422 	// used for template creation only
       
   423 	void ConstructL(const TDesC& aTableName);
       
   424 	
       
   425 private:
       
   426 	enum TTableState {
       
   427 		EClosed,
       
   428 		EOpenIdle,
       
   429 		EInsert,
       
   430 		EUpdate
       
   431 		};
       
   432 private:
       
   433 	TBool TableWithTemplateRecord() const;
       
   434 	TInt InsertTemplateRecord();
       
   435 	TInt DoInsertRecord(TBool aType, TUint32& aId, TBool aIsTemplate);
       
   436 	TInt DoPutRecordChanges(TBool aHidden = EFalse, TBool aReadOnly = EFalse, TBool aIsTemplateCall = EFalse);
       
   437 
       
   438 private:
       
   439 	TTableState iState;
       
   440 	CCommsDbTemplateRecord* iTemplate;
       
   441 	TBool iTsyNameChanged;
       
   442 	TUint32 iInsertedRecordIndex;
       
   443 	TUint32 iCurrentId;
       
   444 
       
   445 protected:
       
   446 	CCommsDatabaseBase& iDb;
       
   447 	TBuf<KCommsDbSvrMaxColumnNameLength> iTableName;
       
   448 	RDbView iTableView;
       
   449 	CCommDbTableExtension* iTableExt;
       
   450 	};
       
   451 
       
   452 
       
   453 
       
   454 
       
   455 
       
   456 /**
       
   457 Convert a legacy field name to a CommsDat element Id
       
   458 
       
   459 @internalTechnology
       
   460 @param aFieldName A legacy commdb field name in the format "tableName\fieldName"
       
   461 @return A Commsdat element Id
       
   462 */
       
   463 class CommDbShimUtil
       
   464 	{
       
   465 public:
       
   466 	IMPORT_C static TMDBElementId GetElementIdFromFieldNameL(const TDesC& aFieldName);
       
   467 	};
       
   468 
       
   469 // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   470 
       
   471 
       
   472 #include <commdb.inl>
       
   473 
       
   474 #endif
       
   475 // COMMDB_H