|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: AgentLog header |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __AGENTLOG_H |
|
21 #define __AGENTLOG_H |
|
22 |
|
23 |
|
24 // INCLUDE FILES |
|
25 #include <e32std.h> |
|
26 #include <e32base.h> |
|
27 #include <d32dbms.h> |
|
28 #include <f32file.h> |
|
29 #include <s32file.h> |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 //Database name & drive |
|
34 const TInt KNSmlAgentLogDbDrive = EDriveC; |
|
35 _LIT( KNSmlAgentLogDbName, "c:nsmlagentlog.db" ); |
|
36 |
|
37 const TInt KNSmlAgentLogFatMinSize = 1000; |
|
38 const TInt KNSmlAgentLogFatMaxSize = 10000; |
|
39 |
|
40 //Database tables |
|
41 _LIT( KNSmlTableAgentLog, "AgentLog" ); |
|
42 _LIT( KNSmlTableAuthentication, "Authentication" ); |
|
43 |
|
44 // <MAPINFO_RESEND_BEGIN> |
|
45 _LIT( KNSmlTableDatastore, "Datastore" ); |
|
46 // <MAPINFO_RESEND_END> |
|
47 |
|
48 //table AgentLog columns |
|
49 _LIT( KNSmlAgentLogId, "Id" ); |
|
50 _LIT( KNSmlAgentLogImplementationUID, "ImplementationUID" ); |
|
51 _LIT( KNSmlAgentLogLocalDatabase, "LocalDatabase" ); |
|
52 _LIT( KNSmlAgentLogServerId, "ServerId" ); |
|
53 _LIT( KNSmlAgentLogRemoteDatabase, "RemoteDatabase" ); |
|
54 _LIT( KNSmlAgentLogLastSyncronised, "LastSyncronised" ); |
|
55 _LIT( KNSmlAgentLogSlowSyncRequest, "SlowSyncRequest" ); |
|
56 _LIT( KNSmlAgentLogLastSyncAnchor, "SyncAnchor" ); |
|
57 _LIT( KNSmlAgentLogServerDeviceInfo, "ServerDeviceInfo" ); |
|
58 _LIT( KNSmlAgentLogServerFilterInfo, "ServerFilterInfo" ); |
|
59 _LIT( KNSmlAgentLogServerSupportsHierarchicalSync, "ServerSupportsHierarchicalSync" ); |
|
60 _LIT( KNSmlAgentLogServerSupportsNOC, "ServerSupportsNOC" ); |
|
61 _LIT( KNSmlAgentLogServerSyncTypes, "ServerSyncTypes" ); |
|
62 //RD_SUSPEND_RESUME |
|
63 _LIT( KNSmlAgentLogSuspendedState ,"SyncSuspendedState"); |
|
64 _LIT( KNSmlAgentLogPreviousSyncType, "PreviousSyncType"); |
|
65 _LIT( KNSmlAgentLogPreviousClientSyncType,"PreviousClientSyncType"); |
|
66 //RD_SUSPEND_RESUME |
|
67 //table Authentication columns |
|
68 _LIT( KNSmlAuthenticationServerId, "ServerId" ); |
|
69 _LIT( KNSmlAuthenticationNonce, "Nonce" ); |
|
70 _LIT( KNSmlAuthenticationType, "Type" ); |
|
71 _LIT( KNSmlAuthenticationSessionId, "SessionId" ); |
|
72 |
|
73 // SQL statements |
|
74 _LIT( KSQLGetAgentLogRow, "SELECT * FROM AgentLog WHERE ImplementationUID = %d \ |
|
75 AND LocalDatabase = '%S' AND ServerId = '%S'" ); |
|
76 _LIT( KSQLGetAgentLogRowWithId, "SELECT * FROM AgentLog WHERE Id = %d" ); |
|
77 _LIT( KSQLGetAgentLogRowWithServerId, "SELECT * FROM AgentLog WHERE ServerId = '%S'" ); |
|
78 _LIT( KSQLGetAgentLogAll, "SELECT * FROM AgentLog" ); |
|
79 _LIT( KSQLGetAuthenticationRow, "SELECT * FROM Authentication WHERE ServerId = '%S'" ); |
|
80 _LIT( KSQLGetAuthenticationAll, "SELECT * FROM Authentication" ); |
|
81 _LIT( KColumn, "%S"); |
|
82 |
|
83 // DATA TYPES |
|
84 |
|
85 enum TNSmlAgentLogData |
|
86 { |
|
87 EAgentLogImplementationUID, |
|
88 EAgentLogLocalDatabase, |
|
89 EAgentLogServerId, |
|
90 EAgentLogRemoteDatabase, |
|
91 EAgentLogLastSyncronised, |
|
92 EAgentLogSlowSyncRequest, |
|
93 EAgentLogLastSyncAnchor, |
|
94 EAgentLogServerDeviceInfo, |
|
95 EAgentLogServerSupportsNOC, |
|
96 EAgentLogServerSyncTypes, |
|
97 EAgentLogServerFilterInfo, |
|
98 EAgentLogServerSupportsHierarchicalSync, |
|
99 EAgentLogSyncSuspendedState, |
|
100 EAgentLogPreviousSyncType, |
|
101 EAgentLogPreviousClientSyncType |
|
102 }; |
|
103 |
|
104 enum TNSmlAgentLogAuthenticationType |
|
105 { |
|
106 EAgentLogNoAuth, |
|
107 EAgentLogBasic, |
|
108 EAgentLogMD5 |
|
109 }; |
|
110 |
|
111 //RD_SUSPEND_RESUME |
|
112 //Suspend state column values |
|
113 enum TNSmlSyncSuspendedState |
|
114 { |
|
115 EStateNotStarted = 0, |
|
116 EStateClientModification, |
|
117 EStateServerModification, |
|
118 EStateDataUpdateStatus, |
|
119 EStateMapAcknowledge |
|
120 |
|
121 }; |
|
122 |
|
123 //Sync type column values |
|
124 enum TNSmlPreviousSyncType |
|
125 { |
|
126 ETypeNotSet=0, |
|
127 ESyncDSTwoWay=200, |
|
128 ESyncDSSlowSync, |
|
129 ESyncDSOneWayFromClient, |
|
130 ESyncDSRefreshFromClient, |
|
131 ESyncDSOneWayFromServer, |
|
132 ESyncDSRefreshFromServer, |
|
133 ESyncDSTwoWayByServer, |
|
134 ESyncDSOneWayFromClientByServer, |
|
135 ESyncDSRefreshFromClientByServer, |
|
136 ESyncDSOneWayFromServerByServer, |
|
137 ESyncDSRefreshFromServerByServer |
|
138 }; |
|
139 //RD_SUSPEND_RESUME |
|
140 |
|
141 // FORWARD DECLARATIONS |
|
142 struct TNSmlCtCapData; |
|
143 class CNSmlDbCaps; |
|
144 struct TNSmlFilterCapData; |
|
145 |
|
146 // <MAPINFO_RESEND_BEGIN> |
|
147 // Table Modification columns |
|
148 _LIT( KNSmlDatastoreRowID, "DatastoreRowID" ); |
|
149 _LIT( KNSmlDatastoreAgentlogID, "DatastoreAID" ); |
|
150 _LIT( KNSmlDatastoreStreamID, "DatastoreSID" ); |
|
151 _LIT( KNSmlDatastoreStreamData, "DatastoreData" ); |
|
152 _LIT( KSQLGetDatastoreAll, "SELECT * FROM Datastore" ); |
|
153 // <MAPINFO_RESEND_END> |
|
154 |
|
155 // CLASS DECLARATION |
|
156 |
|
157 /** |
|
158 * CNSmlDSAgentLog provides an interface for accessing AgentLog database. |
|
159 * |
|
160 * @lib nsmlagentlog.lib |
|
161 */ |
|
162 class CNSmlDSAgentLog : public CBase |
|
163 { |
|
164 public: |
|
165 enum TNSmlAgentDataStoreElement |
|
166 { |
|
167 EDataStore = 0x20, |
|
168 ESourceRef, |
|
169 EDisplayName, |
|
170 EMaxGUIDSize, |
|
171 ERxPref, |
|
172 ERx, |
|
173 ETxPref, |
|
174 ETx, |
|
175 EDSMem, |
|
176 ESupportHierarchicalSync, |
|
177 ESyncCap |
|
178 }; |
|
179 |
|
180 public: // Constructors and destructor |
|
181 |
|
182 /** |
|
183 * Two-phased constructor. |
|
184 */ |
|
185 IMPORT_C static CNSmlDSAgentLog* NewL(); |
|
186 |
|
187 /** |
|
188 * Two-phased constructor. |
|
189 */ |
|
190 IMPORT_C static CNSmlDSAgentLog* NewLC(); |
|
191 |
|
192 /** |
|
193 * Destructor. |
|
194 */ |
|
195 ~CNSmlDSAgentLog(); |
|
196 |
|
197 public: // New functions |
|
198 |
|
199 /** |
|
200 * Sets AgentLog key with given string values. |
|
201 * @param aImplUid Implementation UID. |
|
202 * @param aLocalDB Local database name. |
|
203 * @param aServerId Remote server ID. |
|
204 * @param aRemoteDB Remote database name. |
|
205 */ |
|
206 IMPORT_C void SetAgentLogKeyL( const TInt aImplUid, const TDesC& aLocalDB, const TDesC& aServerId, const TDesC& aRemoteDB ); |
|
207 |
|
208 /** |
|
209 * Sets the given integer value for the given AgentLog datatype. |
|
210 * @param aType Type of AgentLog data. |
|
211 * @param aNewValue Integer value to be set. |
|
212 */ |
|
213 IMPORT_C void SetIntValueL( TNSmlAgentLogData aType, const TInt aNewValue ); |
|
214 |
|
215 /** |
|
216 * Gets an integer value for the given AgentLog datatype. |
|
217 * @param aType Type of AgentLog data. |
|
218 * @return Integer value. |
|
219 */ |
|
220 IMPORT_C TInt IntValueL( TNSmlAgentLogData aType ); |
|
221 |
|
222 /** |
|
223 * Sets the given time value for the given AgentLog datatype. |
|
224 * @param aType Type of AgentLog data. |
|
225 * @param aNewValue Time value to be set. |
|
226 */ |
|
227 IMPORT_C void SetTimeValueL( TNSmlAgentLogData aType, const TTime& aNewValue ); |
|
228 |
|
229 /** |
|
230 * Gets the time value for the given AgentLog datatype. If the returned |
|
231 * value is TTime(0), given value was not found. |
|
232 * @param aType Type of AgentLog data. |
|
233 * @return Time value. |
|
234 */ |
|
235 IMPORT_C TTime TimeValueL( TNSmlAgentLogData aType ); |
|
236 |
|
237 /** |
|
238 * Sets the nonce data for given server ID. |
|
239 * @param aServerId Remote server ID. |
|
240 * @param aNewValue The nonce value to be set. |
|
241 */ |
|
242 IMPORT_C void SetNonceL( const TDesC& aServerId, const TDesC& aNewValue ); |
|
243 |
|
244 /** |
|
245 * Gets the nonce data for given server ID. If length of the returned |
|
246 * string is 0, nonce was not found. |
|
247 * @param aServerId Remote server ID. |
|
248 * @return Nonce data. |
|
249 */ |
|
250 IMPORT_C HBufC* NonceL( const TDesC& aServerId ); |
|
251 |
|
252 /** |
|
253 * Sets the given session ID for the given server ID. |
|
254 * @param aServerId Remote server ID. |
|
255 * @param aSessionID Session ID. |
|
256 */ |
|
257 IMPORT_C void SetSessionIDL( const TDesC& aServerId, TInt aSessionID ); |
|
258 |
|
259 /** |
|
260 * Gets the session ID for the given server ID. |
|
261 * @param aServerId Remote server ID. |
|
262 * @return Session ID. |
|
263 */ |
|
264 IMPORT_C TInt SessionIDL( const TDesC& aServerId ); |
|
265 |
|
266 /** |
|
267 * Sets the authentication type for the given server ID. |
|
268 * @param aServerId Remote server ID. |
|
269 * @param aNewValue Authentication type. |
|
270 */ |
|
271 IMPORT_C void SetAuthTypeL( const TDesC& aServerId, const TNSmlAgentLogAuthenticationType aNewValue ); |
|
272 |
|
273 /** |
|
274 * Gets the authentication type for the given server ID. |
|
275 * @param aServerId Remote server ID. |
|
276 * @return Authentication type. |
|
277 */ |
|
278 IMPORT_C TInt AuthTypeL( const TDesC& aServerId ); |
|
279 |
|
280 /** |
|
281 * Replaces the give old server ID with new one. |
|
282 * @param aOldServerId Old remote server ID. |
|
283 * @param aNewValue New remote server ID. |
|
284 */ |
|
285 IMPORT_C void SetServerIdL( TDesC& aOldServerId, TDesC& aNewValue ); |
|
286 |
|
287 /** |
|
288 * Sets the server device info for AgentLog. |
|
289 * @param aDbCaps Server's database capabilities. |
|
290 */ |
|
291 IMPORT_C void SetServerDeviceInfoL( const RPointerArray<CNSmlDbCaps>& aDbCaps ); |
|
292 |
|
293 /** |
|
294 * Gets the server device info for AgentLog. |
|
295 * @param aDbCaps Server's database capabilities. |
|
296 */ |
|
297 IMPORT_C void GetServerDeviceInfoL( RPointerArray<CNSmlDbCaps>& aDbCaps ); |
|
298 |
|
299 /** |
|
300 * Sets the server filter info for AgentLog. |
|
301 * @param aFilterInfoArr Server's filter capabilities. |
|
302 */ |
|
303 IMPORT_C void SetServerFilterInfoL( const CArrayFix<TNSmlFilterCapData>* aFilterInfoArr ); |
|
304 |
|
305 /** |
|
306 * Gets the server filter info for AgentLog. |
|
307 * @param aFilterInfoArr Server's filter capabilities. |
|
308 */ |
|
309 IMPORT_C void GetServerFilterInfoL( CArrayFix<TNSmlFilterCapData>* aFilterInfoArr ); |
|
310 |
|
311 // <MAPINFO_RESEND_MOD_BEGIN> |
|
312 /** |
|
313 * Opens the read stream. |
|
314 * @param aUid UID of the stream. |
|
315 * @return Pointer to the opened stream buffer. |
|
316 */ |
|
317 IMPORT_C MStreamBuf* OpenReadStreamL( TUid aUid ); |
|
318 /** |
|
319 * Opens the write stream |
|
320 * @param aUid UID of the stream. |
|
321 * @return Pointer to the opened stream buffer. |
|
322 */ |
|
323 IMPORT_C MStreamBuf* OpenWriteStreamL( TUid aUid ); |
|
324 /** |
|
325 * Checks if stream uid is already in use. |
|
326 * @param aUid UID of the stream. |
|
327 * @return ETrue if in use. Otherwise EFalse. |
|
328 */ |
|
329 IMPORT_C TBool IsPresentL( TUid aUid ); |
|
330 /** |
|
331 * Delete stream for Uid. |
|
332 * @param aUid UID of the stream. |
|
333 */ |
|
334 IMPORT_C void DeleteStreamL( TUid aUid ); |
|
335 /** |
|
336 * Delete stream for datastore. |
|
337 */ |
|
338 IMPORT_C void DeleteStoreL(); |
|
339 /** |
|
340 * Closes write stream. |
|
341 * @param aCommit Boolean value, which indicates if stream need to be committed before closing. |
|
342 */ |
|
343 IMPORT_C void CloseWriteStreamL( TBool aCommit = ETrue ); |
|
344 /** |
|
345 * Closes read stream. |
|
346 */ |
|
347 IMPORT_C void CloseReadStreamL(); |
|
348 // <MAPINFO_RESEND_MOD_END> |
|
349 |
|
350 private: |
|
351 |
|
352 /** |
|
353 * Creates Agent Log database. |
|
354 * @param aFullName Name and path of database. |
|
355 */ |
|
356 void CreateDatabaseL( const TDesC& aFullName ); |
|
357 |
|
358 /** |
|
359 * Generates a unique Id to a given table. |
|
360 */ |
|
361 TInt GenerateIdL(); |
|
362 |
|
363 /** |
|
364 * Initialises new row in AgentLog table with set key values. |
|
365 */ |
|
366 void InitNewRowL(); |
|
367 |
|
368 /** |
|
369 * Makes an SQL query string for getting a row with currently set |
|
370 * AgentLog key from AgentLog table. |
|
371 */ |
|
372 HBufC* AgentLogRowSqlLC() const; |
|
373 |
|
374 /** |
|
375 * Makes an SQL query string for getting a row with given server ID |
|
376 * from Authentication table |
|
377 * @param aServerId Remote server ID. |
|
378 */ |
|
379 HBufC* AuthenticationSqlLC( const TDesC& aServerId ) const; |
|
380 |
|
381 /** |
|
382 * Closes the view and then prepares it with the given values. |
|
383 * @param aSql SQL statement defining the view. |
|
384 * @param aAccess Permitted operations for the view. |
|
385 */ |
|
386 void PrepareViewL( const TDesC& aSql, RDbRowSet::TAccess aAccess ); |
|
387 |
|
388 /** |
|
389 * Commits update and compacts the database. |
|
390 */ |
|
391 void CommitAndCompact(); |
|
392 |
|
393 /** |
|
394 * Symbian 2nd phase constructor. |
|
395 */ |
|
396 void ConstructL(); |
|
397 |
|
398 private: // Data |
|
399 TInt iID; |
|
400 |
|
401 TInt iImplUid; |
|
402 HBufC* iLocalDB; |
|
403 HBufC* iServerId; |
|
404 HBufC* iRemoteDB; |
|
405 |
|
406 RDbNamedDatabase iDatabase; |
|
407 RFs iFsSession; |
|
408 RDbs iRdbSession; |
|
409 |
|
410 RDbTable iTableAgentLog; |
|
411 CDbColSet* iColSet; |
|
412 RDbView iView; |
|
413 |
|
414 RDbTable iTableAuthentication; |
|
415 CDbColSet* iColSetTableAuth; |
|
416 |
|
417 // <MAPINFO_RESEND_BEGIN> |
|
418 RDbTable iTableDatastore; |
|
419 CDbColSet* iColSetTableDS; |
|
420 RDbView iWSView; |
|
421 RDbView iRSView; |
|
422 TBool iWriteStreamOpen; |
|
423 TBool iReadStreamOpen; |
|
424 RDbColWriteStream iWs; |
|
425 RDbColReadStream iRs; |
|
426 // <MAPINFO_RESEND_END> |
|
427 }; |
|
428 |
|
429 |
|
430 #endif // __AGENTLOG_H |
|
431 |
|
432 // End of File |