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