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