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