commsfwtools/preparedefaultcommsdatabase/Tools/ced/inc/CDBSTD.H
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 1997-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 /**
       
    17  @file
       
    18  @internalComponent
       
    19 */
       
    20 
       
    21 #ifndef __CDBSTD_H__
       
    22 #define __CDBSTD_H__
       
    23 
       
    24 //#include <commdb.h>
       
    25 
       
    26 /**
       
    27 Database location macros
       
    28 @internalComponent
       
    29 */
       
    30 
       
    31 #define KMaxFileNameSize					220
       
    32 _LIT(KDbBaseName, "Cdbv3.dat");
       
    33 _LIT(KCDrive, "c:");
       
    34 
       
    35 _LIT(KDbPolicyUIDString, "secure[10004e1d]");
       
    36 _LIT(KDb, "C:\\private\\100012a5\\DBS_10004e1d_Cdbv3.dat");
       
    37 _LIT(KDefaultDb, "Z:\\private\\100012a5\\DBS_10004e1d_DefaultCdbv3.dat");
       
    38 _LIT(KDbFileName, "C:Cdbv3.dat");
       
    39 
       
    40 
       
    41 #if defined(_UNICODE)
       
    42 #define _I(x) L ## x
       
    43 #else
       
    44 #define _I(x) x
       
    45 #endif
       
    46 
       
    47 /**
       
    48 The _I() strings are passed as parameter s to the CDB_LIT macro
       
    49 @internalComponent
       
    50 */
       
    51 #define CDB_LIT(name,s) const TLitC<sizeof(s)/2> name={sizeof(s)/2-1,s}
       
    52 
       
    53 /**
       
    54 Server name
       
    55 @internalComponent
       
    56 */
       
    57 #define _SERVER_NAME				_I("CommsDbServer")
       
    58 
       
    59 /**
       
    60 Misc table names that don't need to be public
       
    61 @internalComponent
       
    62 */
       
    63 #define _GLOBAL_SETTINGS			_I("GlobalSettings")
       
    64 #define _CONNECTION_PREFERENCES		_I("ConnectionPreferences")
       
    65 #define _ACCESS_TABLE				_I("AccessTypeTable")
       
    66 
       
    67 
       
    68 /**
       
    69 Columns for Access Type table
       
    70 @internalComponent
       
    71 */
       
    72 #define ACCESS_TYPE_TABLE		_S("AccessTypeTable")
       
    73 #define TABLE_ACC_NAME			_S("TableName")
       
    74 #define TABLE_ACC_TYPE			_S("AccessType")
       
    75 
       
    76 
       
    77 /**
       
    78 DEPRECATED : Agent Table has been removed
       
    79 @internalComponent
       
    80 */
       
    81 
       
    82 //#define _AGENT						_I("Agent")
       
    83 
       
    84 /**
       
    85 Specifies whether a record is hidden from the client.
       
    86 Field type: TBool.
       
    87 */
       
    88 #define _COMMDB_HIDDEN				_I("Hidden")
       
    89 
       
    90 /**
       
    91 Specifies whether a record is read-only.
       
    92 Field type: TBool.
       
    93 */
       
    94 #define _COMMDB_READ_ONLY			_I("ReadOnly")	
       
    95 #define _COMMDB_INT_VALUE			_I("IntValue")	//< integer value for global settings
       
    96 #define _COMMDB_TEXT_VALUE			_I("TextValue")	//< text value for global settings
       
    97 
       
    98 //
       
    99 // Columns for Connection Preferences table
       
   100 //
       
   101 /** Ranking of this connection preference.
       
   102 This information is used to specify the order in which attempts at a connection should be
       
   103 carried out. The highest ranking is 1 and is always attempted. If this fails, a preference
       
   104 with rank 2 is then attempted, and so on. Ranking of 0 indicates that a connection
       
   105 preference is only being stored and is not used for connections.
       
   106 
       
   107   For incoming connections, CommDb limits the ranking to 0 or 1. For outgoing connection
       
   108   preferences, the maximum ranking is the value in CONNECTION_ATTEMPTS field in the Global
       
   109   table.
       
   110   
       
   111 	Multiple records with the same ranking (except for 0) and the same direction are not allowed.
       
   112 	
       
   113 	  Field type: TUint32. This field may not be left as NULL.
       
   114 	  @internalComponent
       
   115 */
       
   116 #define _CONNECT_PREF_RANKING		_I("Ranking")
       
   117 
       
   118 /**
       
   119 The direction of the connection. The directions are defined by the enum 
       
   120 TCommDbConnectionDirection.
       
   121 Field type: TUint32. This field may not be left as NULL.
       
   122 */
       
   123 #define _CONNECT_PREF_DIRECTION		_I("Direction")
       
   124 /**
       
   125 The bearers that can be used for this connection. 
       
   126 
       
   127   The bearers are defined by the enum TCommDbBearer. Values can be OR'ed together to indicate 
       
   128   that either of the bearers could be used.
       
   129   Field type: TUint32. This field may not be left as NULL.
       
   130 */
       
   131 #define _CONNECT_PREF_BEARER_SET	_I("BearerSet")
       
   132 
       
   133 /**
       
   134 Determines whether or not the user should be prompted or warned with a dialog 
       
   135 that a connection is going to be made.
       
   136 
       
   137   The options are defined by the enum TCommDbDialogPref.
       
   138   
       
   139 	Field type: TUint32. This field may not be left as NULL.
       
   140 	
       
   141 	  @see TCommDbDialogPref.
       
   142 */
       
   143 #define _CONNECT_PREF_DIALOG_PREF	_I("DialogPref")
       
   144 
       
   145 /**
       
   146 Identifier of a preferred IAP for this connection, if this is an IAP type database.
       
   147 
       
   148   For ISP type databases, see the subsequent fields..
       
   149   
       
   150 	Field type: TUint32. This field may be left as NULL.
       
   151 */
       
   152 #define _CONNECT_PREF_IAP			_I("IAP")
       
   153 
       
   154 
       
   155 /**
       
   156 Columns for Agent table
       
   157 @internalComponent
       
   158 */
       
   159 
       
   160 //#define _AGENT_SERVICE_TYPE			_I("AgentServiceType")
       
   161 //#define _AGENT_NAME					_I("AgentName")
       
   162 //#define _AGENT_EXT_NAME				_I("AgentExtName")
       
   163 //#define _AGENT_LAST_SOCKET_ACTIVITY_TIMEOUT	_I("AgentLastSocketActivityTimeout")
       
   164 //#define _AGENT_LAST_SESSION_CLOSED_TIMEOUT	_I("AgentLastSessionClosedTimeout")
       
   165 //#define _AGENT_LAST_SOCKET_CLOSED_TIMEOUT	_I("AgentLastSocketClosedTimeout")
       
   166 
       
   167 
       
   168 /**
       
   169 SQL query strings
       
   170 @internalComponent
       
   171 */
       
   172 #define _SQL_START_SQL_QUERY		_I("select * from ")
       
   173 #define _SQL_WHERE_KEYWORD			_I("where")
       
   174 #define _SQL_AND_KEYWORD			_I(" and")
       
   175 #define _SQL_ORDER_KEYWORD			_I("order")
       
   176 #define _SQL_ORDER_BY_KEYWORD		_I(" order by ")
       
   177 #define _SQL_WHERE_HIDDEN			_I(" where Hidden=0")
       
   178 #define _SQL_AND_HIDDEN				_I(" and Hidden=0")
       
   179 #define _SQL_INT_MATCH				_I("%S=%d")
       
   180 #define _SQL_WHERE_INT_MATCH		_I(" where %S=%d")
       
   181 #define _SQL_WHERE_TEXT_MATCH		_I(" where %S='%S'")
       
   182 #define _SQL_AND_INT_MATCH			_I(" and %S=%d")
       
   183 #define _SQL_AND_TEXT_MATCH			_I(" and %S='%S'")
       
   184 #define _SQL_OR_TEXT_MATCH			_I(" or %S='%S'")
       
   185 #define _SQL_WHERE_INT_GREATERTHAN	_I(" where %S>%d")
       
   186 
       
   187 /**
       
   188 SQL query lengths
       
   189 @internalComponent
       
   190 */
       
   191 //const TInt KTwiceMaxFieldLength=(2*KCommsDbSvrRealMaxFieldLength);
       
   192 //const TInt KBasicSqlQueryLength=KCommsDbSvrMaxColumnNameLength+29;		// 29 is length of "select * from  where Hidden=0"
       
   193 //const TInt KSqlQueryWithMatch=KBasicSqlQueryLength+KCommsDbSvrMaxColumnNameLength+KTwiceMaxFieldLength+8;  // 8 is length of "='' and "
       
   194 //const TInt KSqlQueryWithDoubleMatch=KSqlQueryWithMatch+KTwiceMaxFieldLength+8;  // 8 is length of "='' and "
       
   195 //const TInt KSqlQueryWithDoubleMatchAndOrderBy=KSqlQueryWithDoubleMatch+KCommsDbSvrMaxColumnNameLength+10;	//10 is the length of " order by "
       
   196 //const TInt KSqlQueryExtraWhereTextMatchesColumn=KTwiceMaxFieldLength+10; // 10 is length of " where %S='%S'"
       
   197 
       
   198 /**
       
   199 These names are maintained for compatibility they are deprecated
       
   200 and should be replaced in code by CDB_LIT declarations
       
   201 @internalComponent
       
   202 */
       
   203 #define SERVER_NAME					(const TText*)_SERVER_NAME
       
   204 #define GLOBAL_SETTINGS				(const TText*)_GLOBAL_SETTINGS
       
   205 #define CONNECTION_PREFERENCES		(const TText*)_CONNECTION_PREFERENCES
       
   206 //#define AGENT						(const TText*)_AGENT
       
   207 /** 
       
   208 Specifies whether a record is hidden.
       
   209 Field type: TBool
       
   210 */
       
   211 #define COMMDB_HIDDEN				(const TText*)_COMMDB_HIDDEN
       
   212 
       
   213 /** 
       
   214 Specifies whether a record is read only.
       
   215 Field type: TBool
       
   216 */
       
   217 #define COMMDB_READ_ONLY			(const TText*)_COMMDB_READ_ONLY
       
   218 
       
   219 #define COMMDB_INT_VALUE			(const TText*)_COMMDB_INT_VALUE
       
   220 #define COMMDB_TEXT_VALUE			(const TText*)_COMMDB_TEXT_VALUE
       
   221 
       
   222 /**
       
   223 Ranking of this connection preference.
       
   224 
       
   225   This information is used to specify the order in which attempts at a connection 
       
   226   should be carried out. The highest ranking is 1 and is always attempted. If 
       
   227   this fails, a preference with rank 2 is then attempted, and so on. A ranking 
       
   228   of 0 indicates that a connection preference is only being stored and is not 
       
   229   used for connections.
       
   230   
       
   231 	For incoming connections, CommDb limits the ranking to 0 or 1. For outgoing 
       
   232 	connection preferences, the maximum ranking is the value in CONNECTION_ATTEMPTS 
       
   233 	field in the Global table.
       
   234 	
       
   235 	  Multiple records with the same ranking (except for 0) and the same direction 
       
   236 	  are not allowed.
       
   237 	  
       
   238 		Type: TUint32. Null: no
       
   239 		
       
   240 		  @see CONNECTION_ATTEMPTS 
       
   241 */
       
   242 #define CONNECT_PREF_RANKING		(const TText*)_CONNECT_PREF_RANKING
       
   243 
       
   244 /** 
       
   245 The direction of the connection. The directions are defined by the enum 
       
   246 TCommDbConnectionDirection.
       
   247 
       
   248   Type: TUint32. Null: no 
       
   249   
       
   250 	@see TCommDbConnectionDirection
       
   251 */
       
   252 #define CONNECT_PREF_DIRECTION		(const TText*)_CONNECT_PREF_DIRECTION
       
   253 
       
   254 /** 
       
   255 The bearers that can be used for this connection.
       
   256 
       
   257   The bearers are defined by the enum TCommDbBearer. Values can be ORed together 
       
   258   to indicate that either of the bearers could be used.
       
   259   
       
   260 	Type: TUint32. Null: no
       
   261 	
       
   262 	  @see TCommDbBearer 
       
   263 */
       
   264 #define CONNECT_PREF_BEARER_SET		(const TText*)_CONNECT_PREF_BEARER_SET
       
   265 
       
   266 /** 
       
   267 Determines whether or not the user should be should be prompted or warned with 
       
   268 a dialog that a connection is going to be made. 
       
   269 
       
   270   The options are defined by the enum TCommDbDialogPref.
       
   271   
       
   272 	Type: TUint32. Null: no
       
   273 	
       
   274 	  @see TCommDbDialogPref 
       
   275 */
       
   276 #define CONNECT_PREF_DIALOG_PREF	(const TText*)_CONNECT_PREF_DIALOG_PREF
       
   277 
       
   278 /** 
       
   279 Identifier of the preferred IAP for this connection, if this is an IAP type database.
       
   280 
       
   281   For ISP type databases, see the subsequent fields.
       
   282   
       
   283 	Type: TUint32. Null: yes 
       
   284 */
       
   285 #define CONNECT_PREF_IAP			(const TText*)_CONNECT_PREF_IAP
       
   286 
       
   287 //#define AGENT_SERVICE_TYPE			(const TText*)_AGENT_SERVICE_TYPE
       
   288 //#define AGENT_NAME					(const TText*)_AGENT_NAME
       
   289 //#define AGENT_EXT_NAME				(const TText*)_AGENT_EXT_NAME
       
   290 //#define AGENT_LAST_SOCKET_ACTIVITY_TIMEOUT	(const TText*)_AGENT_LAST_SOCKET_ACTIVITY_TIMEOUT
       
   291 //#define AGENT_LAST_SESSION_CLOSED_TIMEOUT	(const TText*)_AGENT_LAST_SESSION_CLOSED_TIMEOUT
       
   292 //#define AGENT_LAST_SOCKET_CLOSED_TIMEOUT	(const TText*)_AGENT_LAST_SOCKET_CLOSED_TIMEOUT
       
   293 #define SQL_START_SQL_QUERY			(const TText*)_SQL_START_SQL_QUERY
       
   294 #define SQL_WHERE_KEYWORD			(const TText*)_SQL_WHERE_KEYWORD
       
   295 #define SQL_AND_KEYWORD				(const TText*)_SQL_AND_KEYWORD
       
   296 #define SQL_ORDER_KEYWORD			(const TText*)_SQL_ORDER_KEYWORD
       
   297 #define SQL_WHERE_HIDDEN			(const TText*)_SQL_WHERE_HIDDEN
       
   298 #define SQL_AND_HIDDEN				(const TText*)_SQL_AND_HIDDEN
       
   299 #define SQL_INT_MATCH				(const TText*)_SQL_INT_MATCH
       
   300 #define SQL_WHERE_INT_MATCH			(const TText*)_SQL_WHERE_INT_MATCH
       
   301 #define SQL_WHERE_TEXT_MATCH		(const TText*)_SQL_WHERE_TEXT_MATCH
       
   302 #define SQL_AND_INT_MATCH			(const TText*)_SQL_AND_INT_MATCH
       
   303 #define SQL_AND_TEXT_MATCH			(const TText*)_SQL_AND_TEXT_MATCH
       
   304 #define SQL_OR_TEXT_MATCH			(const TText*)_SQL_OR_TEXT_MATCH
       
   305 #define SQL_WHERE_INT_GREATERTHAN	(const TText*)_SQL_WHERE_INT_GREATERTHAN
       
   306 
       
   307 /**
       
   308 Reasons for server Panic.
       
   309 @internalComponent 
       
   310 */
       
   311 enum TCommsDbSvrPanic
       
   312 	{
       
   313 	ECommsDbIncorrectNumberOfDbTables,
       
   314 	ECommsDbInsertNotOpenIdle,
       
   315 	ECommsDbUpdateNotOpenIdle,
       
   316 	ECommsDbDeleteNotOpenIdle,
       
   317 	ECommsDbSvrPanicCommitNotInsertUpdate,
       
   318 	ECommsDbCancelNotInsertUpdate,
       
   319 	ECommsDbGotoFirstNotOpenIdle,
       
   320 	ECommsDbGotoNextNotOpenIdle,
       
   321 	ECommsDbGotoPreviousNotOpenIdle,
       
   322 	ECommsDbDeprecated9,
       
   323 	ECommsDbReadNotOpenIdle,
       
   324 	ECommsDbDeprecated11,
       
   325 	ECommsDbWriteNotInsertUpdate,
       
   326 	ECommsDbWritingIdColumn,
       
   327 	ECommsDbOverrideValueLengthTooShort,
       
   328 	ECommsDbColDoesNotExist,
       
   329 	ECommsDbDirectionUnknown,
       
   330 	ECommsDbDeprecated17,
       
   331 	ECommsDbDeprecated18,
       
   332 	ECommsDbMissingDefaultDatabase,
       
   333 	ECommsDBOpenNonNullColSet,
       
   334 	ECommsDbNoAccessTableView
       
   335 	,
       
   336 	ECommsDbPublishAndSubscribeError,
       
   337 	/** Unable to perform the copy of the default commdb, or restore commdb
       
   338 	operation.
       
   339 	*/
       
   340 	ECommdbRestoreFailed
       
   341 	};
       
   342 
       
   343 	/** 
       
   344 	Panics the calling thread. 
       
   345 	@internalComponent 
       
   346 */
       
   347 GLREF_C void CommsDbPanic(TCommsDbSvrPanic aPanic);
       
   348 
       
   349 #endif