syncmlfw/ds/syncagent/inc/nsmldscontent.h
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     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:  Database (content) specific data and functionality
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __NSMLDSCONTENT_H__
       
    20 #define __NSMLDSCONTENT_H__
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32hashtab.h>
       
    24 #include <e32base.h>
       
    25 #include <SyncMLDef.h>
       
    26 #include <SmlDataSyncDefs.h>
       
    27 #include <SyncMLDataFilter.h>
       
    28 #include "NSmlDSAgent.h"
       
    29 
       
    30 // CONSTANTS
       
    31 const TUint KNSmlTwoWayFlag = 1 << 0;
       
    32 const TUint KNSmlSlowTwoWayFlag = 1 << 1;
       
    33 const TUint KNSmlOneWayFromClientFlag = 1 << 2;
       
    34 const TUint KNSmlRefreshFromClientFlag = 1 << 3;
       
    35 const TUint KNSmlOneWayFromServerFlag = 1 << 4;
       
    36 const TUint KNSmlRefreshFromServerFlag = 1 << 5;
       
    37 const TUint KNSmlServerAlertedFlag = 1 << 6;
       
    38 
       
    39 // <MAPINFO_RESEND_MOD_BEGIN>
       
    40 const TInt KNSmlDefaultMapStreamUID = 0x101F6DF4;
       
    41 // <MAPINFO_RESEND_MOD_END>
       
    42 
       
    43 // FORWARD DECLARATIONS
       
    44 class CNSmlDbCaps;
       
    45 class CNSmlURI;
       
    46 class CNSmlFilter;
       
    47 class CNSmlDSHostClient;
       
    48 class CNSmlDSContentItem;
       
    49 
       
    50 /**
       
    51 * Class that handles content (datastore) specific data processing.
       
    52 *
       
    53 * @lib nsmldsagent.lib
       
    54 */
       
    55 class CNSmlDSContent : public CBase 
       
    56 	{
       
    57 	public: // constructors and destructor
       
    58 		/**
       
    59 		* Symbian two-phased constructor.
       
    60 		*/
       
    61 		static CNSmlDSContent* NewL();
       
    62 		
       
    63 		/**
       
    64 		* Destructor.
       
    65 		*/
       
    66 		~CNSmlDSContent();
       
    67 	
       
    68 	public: // new functions
       
    69 	
       
    70 		/**
       
    71 		* Creates DSHostClient
       
    72 		* @return -
       
    73 		*/
       
    74 		void InitContentDataL();
       
    75 		
       
    76 		/**
       
    77 		* Returns the index of the current content.
       
    78 		* @return The index of the current content.
       
    79 		*/
       
    80 		TInt CurrentIndex() const;
       
    81 		
       
    82 		/**
       
    83 		* Checks if the content index is set.
       
    84 		* @return ETrue if the content index is set.
       
    85 		*/
       
    86 		TBool ContentIndexIsSet() const;
       
    87 		
       
    88 		/**
       
    89 		* Returns the number of contents.
       
    90 		* @return The number of contents.
       
    91 		*/
       
    92 		TInt Count() const;
       
    93 		
       
    94 		/**
       
    95 		* Returns the implementation UID at the current content index.
       
    96 		* @return UID of the current data provider.
       
    97 		*/
       
    98 		TInt ImplementationUID() const;
       
    99 		
       
   100 		/**
       
   101 		* Returns the local database URI at the current content index.
       
   102 		* @return URI of the current local database.
       
   103 		*/
       
   104 		CNSmlURI* LocalDatabase() const;
       
   105 		
       
   106 		/**
       
   107 		* Returns the remote database URI at the current content index.
       
   108 		* @return URI of the current remote database.
       
   109 		*/
       
   110 		CNSmlURI* RemoteDatabase() const;
       
   111 		
       
   112 		/**
       
   113 		* Returns the synchronization type at the current content index.
       
   114 		* @return Synchronization type.
       
   115 		*/
       
   116 		TPtrC8 SyncType() const;
       
   117 		
       
   118 		//RD_SUSPEND_RESUME
       
   119 		/**
       
   120 		* Returns the Synchronization Type proposed by the client in the Current Sync session
       
   121 		*@return Synchronization type.
       
   122 		*/
       
   123 	    TPtrC8 	PrevClientSyncType();
       
   124 	    
       
   125 	    /**
       
   126 		* Returns the Synchronization Type proposed by the client in the Current Sync session
       
   127 		*@return Synchronization type.
       
   128 		*/
       
   129 	    TPtrC8  ClientSyncType();
       
   130 	    
       
   131 	    //RD_SUSPEND_RESUME
       
   132 	    /**
       
   133 		* Gets the UID of the current data item at the current content index.
       
   134 		* @param aLocalUID On returns contains the current local UID.
       
   135 		*/
       
   136 		void CurrentUID( TSmlDbItemUid& aLocalUID ) const;
       
   137 		
       
   138 		/**
       
   139 		* Gets the DevInfo structure at the current content index.
       
   140 		* @param aDbCaps On return contains the current DevInfo structure.
       
   141 		* @return KErrNone if successful, otherwise one of the system wide error codes.
       
   142 		*/
       
   143 		TInt DbCapabilitiesL(CNSmlDbCaps*& aDbCaps) const;
       
   144 		
       
   145 		/**
       
   146 		* Checks if the given Rx element type is supported by the current data 
       
   147 		* store.
       
   148 		* @param aType The Rx type to be checked against.
       
   149 		* @return ETrue if the given Rx type is supported.
       
   150 		*/
       
   151 		TBool IsSupportedRxL( const TDesC8& aType ) const;
       
   152 		
       
   153 		/**
       
   154 		* Checks if the given Tx element type is supported by the current data 
       
   155 		* store.
       
   156 		* @param aType The Tx type to be checked against.
       
   157 		* @return ETrue if the given Tx type is supported.
       
   158 		*/
       
   159 		TBool IsSupportedTxL( const TDesC8& aType ) const;
       
   160 		
       
   161 		/**
       
   162 		* Checks if the given synchronization type is supported by the current
       
   163 		* data store.
       
   164 		* @param aSyncType The synchronization type to be checked.
       
   165 		* @return ETrue if the given sync type is supported.
       
   166 		*/
       
   167 		TBool IsSupportedSyncTypeL( CNSmlDbCaps::ENSmlSyncTypes aSyncType ) const;
       
   168 		
       
   169 		/**
       
   170 		* Checks if the given synchronization type is supported by the current
       
   171 		* data store.
       
   172 		* @param aSyncType The synchronization type to be checked.
       
   173 		* @return ETrue if the given sync type is supported.
       
   174 		*/
       
   175 		TBool IsSupportedSyncTypeL( const TDesC8& aSyncType ) const;
       
   176 		
       
   177 		/**
       
   178 		* Checks if the current data store supports hierarchical sync with the
       
   179 		* given media type.
       
   180 		* @param aMediaType Media type used during check.
       
   181 		* @return ETrue if hierarchical sync is supported.
       
   182 		*/
       
   183 		TBool IsHierarchicalSyncSupportedL( const TPtr8 aMediaType ) ;
       
   184 		
       
   185 		/**
       
   186 		* Checks if server supports the synchronization type used in the sync
       
   187 		* session at the current content index.
       
   188 		@ return ETrue if the sync type is supported.
       
   189 		*/
       
   190 		TBool IsSupportedSyncTypeByServerL() const;
       
   191 		
       
   192 		/**
       
   193 		* Checks if synchronization session with the current data store has 
       
   194 		* been interrupted.
       
   195 		* @return ETrue if the sync session has been interrupted.
       
   196 		*/
       
   197 		TBool Interrupted() const;
       
   198 		
       
   199 		/**
       
   200 		* Checks if an error due to a Status code received from the server has
       
   201 		* been written to the history log at the current content index.
       
   202 		* @return ETrue if an error has been written.
       
   203 		*/
       
   204 		TBool ServerStatusError() const;
       
   205 		
       
   206 		/**
       
   207 		* Checks if the initialization Alert command is not yet received for
       
   208 		* the current data store.
       
   209 		* @return ETrue if initialization Alert is not received.
       
   210 		*/
       
   211 		TBool WaitingInitAlert() const;
       
   212 		
       
   213 		/**
       
   214 		* Checks if slow sync request has been stored for the current data store.
       
   215 		* @return ETrue if slow sync request has been stored.
       
   216 		*/
       
   217 		TBool SlowSyncRequestL() const;
       
   218 		
       
   219 		/**
       
   220 		* Checks if synchronization of any content has been interrupted.
       
   221 		* @return ETrue if some content is interrupted.
       
   222 		*/
       
   223 		TBool AnyDatabaseIsInterrupted() const;
       
   224 		
       
   225 		/**
       
   226 		* Checks if synchronization of all data stores has been interrupted.
       
   227 		* @ETrue if all contents are interrupted.
       
   228 		*/
       
   229 		TBool AllDatabasesAreInterrupted() const;
       
   230 		
       
   231 		/**
       
   232 		* Checks if synchronization of all data stores has been interrupted
       
   233 		* immediately. In that case no Status commands are sent.
       
   234 		* @return ETrue if interrupted immediately.
       
   235 		*/
       
   236 		TBool AllDatabasesAreInterruptedImmediately() const;
       
   237 		
       
   238 		/**
       
   239 		* Checks if synchronization type is one-way sync from client for all
       
   240 		* data stores.
       
   241 		* @ETrue if one-way sync from client is used for all data stores.
       
   242 		*/
       
   243 		TBool AllDatabasesOneWayFromClient() const;
       
   244 		
       
   245 		/**
       
   246 		* Checks if there are map items to be sent at the current content index.
       
   247 		* @ETrue if map items exist.
       
   248 		*/
       
   249 		TBool MapExists() const;
       
   250 		
       
   251 		/**
       
   252 		* Checks if the number of synchronized items at the current content index
       
   253 		* was asked previously.
       
   254 		* @return ETrue if the count was asked already.
       
   255 		*/
       
   256 		TBool ClientItemCountAsked() const;
       
   257 
       
   258 		/**
       
   259 		* Checks if the number of synchronized items on the server at the current
       
   260 		* content index was asked already.
       
   261 		* @return ETrue if the count was asked.
       
   262 		*/		
       
   263 		TBool ServerItemCountAsked() const;
       
   264 		
       
   265 		/**
       
   266 		* Returns the number of synchronized items in the client for the current
       
   267 		* data store.
       
   268 		* @return The number of synchronized items.
       
   269 		*/
       
   270 		TInt ClientItemCount() const;
       
   271 		
       
   272 		/**
       
   273 		* Returns the number of synchronized items in the server for the current
       
   274 		* data store.
       
   275 		* @return The number of synchronized items.
       
   276 		*/
       
   277 		TInt ServerItemCount() const;
       
   278 		
       
   279 		/**
       
   280 		* Returns the map item list at the current content index.
       
   281 		* @return Map item list.
       
   282 		*/
       
   283 		SmlMapItemList_t* MapItemListL() const;
       
   284 		
       
   285 		/**
       
   286 		* Returns the maximum object size in the server at the current content
       
   287 		* index. The size is returned in bytes.
       
   288 		* @return The maximum object size.
       
   289 		*/
       
   290 		TInt MaxObjSizeInServer() const;
       
   291 		
       
   292 		/**
       
   293 		* Returns the maximum object size in content.
       
   294 		* @return The maximum object size in content.
       
   295 		*/
       
   296 		TInt MaxObjSizeL() const;
       
   297 		
       
   298 		/**
       
   299 		* Returns the sync anchor the client has sent to the server during the
       
   300 		* previous synchronization session.
       
   301 		* @return Sync anchor of the previous session.
       
   302 		*/
       
   303 		TTime LastSyncAnchorL() const;
       
   304 		
       
   305 		/**
       
   306 		* Initializes interruption flags for all contents.
       
   307 		*/
       
   308 		void InitInterruptionFlags() const;
       
   309 		
       
   310 		/**
       
   311 		* Creates a new map item to the current content's map item container.
       
   312 		* @param aLUID Local UID.
       
   313 		* @param aGUID Global UID.
       
   314 		* @param aAtomicId Atomic command id associated with the item (0 = none).
       
   315 		*/
       
   316 		void CreateNewMapItemL( const TSmlDbItemUid aLUID, const TDesC8& aGUID, const TInt aAtomicId ) const;
       
   317 		
       
   318 // <MAPINFO_RESEND_MOD_BEGIN>
       
   319 		
       
   320 		/**
       
   321 		* Sets the stream uid to be used for the map information streaming.
       
   322 		* @param aMapStreamUid Uid of the stream.
       
   323 		*/
       
   324 		void SetMapStreamUID(TInt aMapStreamUid = KNSmlDefaultMapStreamUID);
       
   325 	
       
   326 		/**
       
   327 		* Calls map loader function.
       
   328 		* @param aStatus Request status.
       
   329 		* @return If error occurs, system wide error code is returned. 
       
   330 		*/
       
   331 		TInt ScanMapContentL( TRequestStatus &aStatus );
       
   332 	
       
   333 		/**
       
   334 		* Loads the map information form the physical storage to the cache.
       
   335 		*/	
       
   336 		void LoadMapInfoL();
       
   337 
       
   338 		/**
       
   339 		* Saves the map information to the physical storage and update the sync flags required for next sync to continue properly but not the last sync anchor
       
   340 		* @param aAnchor Time anchor.
       
   341 		*/
       
   342 		void SaveMapInfoL( const TTime& aAnchor );
       
   343 
       
   344 		/**
       
   345 		*  Cleans up the map information from the cache as well as from physical storage for current database
       
   346 		*/
       
   347 		void CleanMapInfo();
       
   348 
       
   349 		/**
       
   350 		* Cleans up the map information in the cash and physical storage for all the databases.
       
   351 		*/	
       
   352 		void CleanAllMapInfo();	
       
   353 
       
   354 		/**
       
   355 		* Saves the map information to the physical storage.
       
   356 		* @param aAnchor Time anchor.
       
   357 		*/
       
   358 		void PackupRequestL( const TTime& aAnchor );
       
   359 
       
   360 		/**
       
   361 		* Checks if a given index is a valid index of a database in a sync
       
   362 		* @param TInt Index of a database.
       
   363 		* @return Boolean value indicating if given index is valid.
       
   364 		*/
       
   365 		TBool CheckDbIndex(TInt aIndex);
       
   366 	
       
   367 		/**
       
   368 		* To Delay the removal of map information from the cache to be removed at a later stage
       
   369 		* @aRemoveMap Boolean value indicating if map is removable.
       
   370 		*/
       
   371 		void SetRemoveMap(TBool aRemoveMap = ETrue);
       
   372 	
       
   373 		/**
       
   374 		* Checks if map information can be removed. 
       
   375 		* @return Boolean value indicating if map information can be removed..
       
   376 		*/
       
   377 		TBool isMapRemovable();
       
   378 	
       
   379 		/**
       
   380 		* Removes the map information form the cache for only set removable map for all the databases.
       
   381 		*/
       
   382 		void RemoveAllRemovableMap() const;
       
   383 	
       
   384 		/**
       
   385 		* Removes the map information form the cache for only set removable map and corresponding to the current database under consideration.
       
   386 		*/
       
   387 		void RemoveRemovableMap() const;
       
   388 	
       
   389 		/**
       
   390 		* Sets resend to be used. 
       
   391 		* @param aResendUsed Boolean value indicating if mapinfo resend is used.
       
   392 		*/
       
   393 		void SetResendUsed( TBool aResendUsed = EFalse );
       
   394 
       
   395 		/**
       
   396 		* Checks if resend is used. 
       
   397 		* @return Boolean value indicating if resend is used.
       
   398 		*/
       
   399 		TBool ResendUsed() const;
       
   400 // <MAPINFO_RESEND_MOD_END>
       
   401 		
       
   402 		/**
       
   403 		* Sets a list of map items to the current content.
       
   404 		* @param aMapItemList List of map items. Ownership is changed for this class.
       
   405 		*/
       
   406 		void SetMapItemList( SmlMapItemList_t* aMapItemList ) const;
       
   407 		
       
   408 		/**
       
   409 		* Resets the current content's map item container.
       
   410 		*/
       
   411 		void RemoveMap() const;
       
   412 		
       
   413 		//RD_SUSPEND_RESUME
       
   414 		/**
       
   415 		* Sets the synchronization type of the current data store.
       
   416 		* @param aSyncType Synchronization type.
       
   417 		*/		
       
   418 		void SetSyncTypeL( const TDesC8& aSyncType ) const;
       
   419 		/**
       
   420 		* Sets the synchronization type of the current data store.
       
   421 		* This Sync Type is proposed by the Client for each content and will be stored into the Agent Log db.
       
   422 		* Helps in the Resumed session to check if the Sync Type proposed by client is different than the Suspened session.
       
   423 		* @param aSyncType Synchronization type.
       
   424 		*/	
       
   425 		void SetClientSyncTypeL( const TDesC8& aSyncType ) const;
       
   426 		
       
   427 		//RD_SUSPEND_RESUME
       
   428 		/**
       
   429 		* Sets the synchronization type of the current data store.
       
   430 		* @param aSyncType Synchronization type.
       
   431 		*/		
       
   432     	void SetSyncTypeL( CNSmlDbCaps::ENSmlSyncTypes aSyncCap ) const;
       
   433     	
       
   434 		/**
       
   435     	* Changes the initializations of the current data store during the sync
       
   436     	* session. If data store's sync type is slow sync or refresh sync from 
       
   437     	* client then ResetChangeInfoL is called. If the given sync type is
       
   438     	* refresh from server then also DeleteAllItemsL is called in addition 
       
   439     	* to ResetChangeInfoL.
       
   440     	* @param aEndOfInits EFalse on return if all data stores are processed.
       
   441     	* @param aResultCode On return contains the result code of the operation.
       
   442     	* @param aStartOfInits Should be set to ETrue if this is the first time 
       
   443     	* this function is called.
       
   444     	*/
       
   445 		void SetDbAndTimeInitsL( TBool& aEndOfInits, TInt& aResultCode, TBool aStartOfInits);
       
   446 		
       
   447 		/**
       
   448 		* Initializes History Log event of the current content.
       
   449 		* @param aSyncLog Reference to the History Log.
       
   450 		*/
       
   451 		void InitSyncLogEventL( CSyncMLHistoryJob& aSyncLog );
       
   452 		
       
   453 		/**
       
   454 		* Initializes History log events of all contents.
       
   455 		* @param aSyncLog Reference to the History Log.
       
   456 		*/
       
   457 		void InitAllSyncLogEventsL( CSyncMLHistoryJob& aSyncLog );
       
   458 		
       
   459 		/**
       
   460 		* Both the number of synchronized items and synchronization statuses of
       
   461 		* all contents are written to the History Log.
       
   462 		*/
       
   463 		void FinalizeSyncLogEvents() const;
       
   464 		
       
   465 		/**
       
   466 		* Adds a new content (data store) instance.
       
   467 		*/
       
   468 		void AddNewContentL();
       
   469 		
       
   470 		/**
       
   471 		* Sets the implementation UID of the current content.
       
   472 		* @param aImplUID Current content's implementation UID.
       
   473 		*/
       
   474 		void SetImplementationUID( TInt aImplUID ) const;
       
   475 		
       
   476 		/**
       
   477 		* Sets the local database URI of the current content.
       
   478 		* @param aLocalDatabase Local database URI.
       
   479 		*/		
       
   480 		void SetLocalDatabaseL( CNSmlURI& aLocalDatabase ) const;
       
   481 		
       
   482 		/**
       
   483 		* Sets the remote database URI of the current content.
       
   484 		* @param aRemoteDatabase Remote database URI.
       
   485 		*/
       
   486 		void SetRemoteDatabaseL( const CNSmlURI& aRemoteDatabase ) const;
       
   487 		
       
   488 		/**
       
   489 		* Initializes the current content (data store).
       
   490 		* @param aServerId ServerId of the current content.
       
   491 		* @return ETrue if the operation succeeded.
       
   492 		*/
       
   493 		TBool InitContentInstanceL( TDesC& aServerId );
       
   494 		
       
   495 		/**
       
   496 		* Opens the current data store.
       
   497 		* @param aResultCode On return contains the return code of the operation.
       
   498 		*/
       
   499 		void OpenContentInstanceL( TInt& aResultCode ) const;
       
   500 		
       
   501 		/**
       
   502 		* Creates local UID buffer for the current content.
       
   503 		* @param aResultCode On return contains the return code of the operation.
       
   504 		*/
       
   505 		void CreateLUIDBufferL( TInt& aResultCode ) const;
       
   506 		
       
   507 		/**
       
   508 		* Cancels an ongoing asynchronous operation.
       
   509 		*/
       
   510 		void CancelRequestL() const;
       
   511 		
       
   512 		/**
       
   513 		* The current content is marked as waiting for the initialization Alert
       
   514 		* command from the server.
       
   515 		*/
       
   516 		void SetInitAlertWaiting() const;
       
   517 		
       
   518 		/**
       
   519 		* The current content is marked as not waiting for the initialization
       
   520 		* Alert command from the server.
       
   521 		*/
       
   522 		void SetInitAlertReceived() const;
       
   523 		
       
   524 		/**
       
   525 		* A slow synchronization request for the current content is passed 
       
   526 		* on/off for the current content. This value is used in the next
       
   527 		* synchronization session.
       
   528 		* @param aRequest ETrue if slow sync flag should be turned on.
       
   529 		*/
       
   530 		void SetSlowSyncReqForNextSyncL( TBool aRequest ) const;
       
   531 		/**
       
   532 		* Sets the Value to ETrue if the Resume session is rejected by the Server
       
   533 		* @param aRefreshRequired variable used to store the Status code returned by Server for Resume command
       
   534 		*/
       
   535 		void SetRefreshRequiredL(TBool aRefreshRequired);
       
   536 		/**
       
   537 		* Gets value stored for the variable aRefreshRequired.
       
   538 		* aRefreshRequired is Set to ETrue if the Resume command rejected by server.
       
   539 		*/
       
   540 		TBool GetRefreshRequired();
       
   541 		
       
   542 		//RD_SUSPEND_RESUME
       
   543 		/**
       
   544 		* Sets the Value to ETrue if the Resume command is sent by the client for a content
       
   545 		* @param iSessionResumed variable is set to ETrue if Resume command is sent by the client
       
   546 		*/
       
   547 		
       
   548 		void SetSessionResumedL(TBool aSessionResumed);
       
   549 				
       
   550 		/**
       
   551 		* Gets value stored for the variable iSessionResumed.
       
   552 		* iSessionResumed is Set to ETrue if the Resume command sent by the client
       
   553 		*/
       
   554 		
       
   555 		TBool GetSessionResumed();
       
   556 		
       
   557 		//RD_SUSPEND_RESUME
       
   558 		/**
       
   559 		* Sets the content index using the given local database URI.
       
   560 		* @param aDatabase Local database URI.
       
   561 		* @return ETrue if a matching content was found.
       
   562 		*/
       
   563 		TBool SetIndexByLocalDatabaseL( CNSmlURI& aDatabase );
       
   564 		
       
   565 		/**
       
   566 		* Sets the content index using the given remote database URI.
       
   567 		* @param aDatabase Remote database URI.
       
   568 		* @param aRespURIExists ETrue if respURI is present.
       
   569 		* @return ETrue if a matching content was found.
       
   570 		*/
       
   571 		TBool SetIndexByRemoteDatabaseL( CNSmlURI& aDatabase, TBool aRespURIExists );
       
   572 		
       
   573 		/**
       
   574 		* Sets the content index using the given remote database URI, local
       
   575 		* database URI and content type.
       
   576 		* @param aRemoteDatabase Remote database URI.
       
   577 		* @param aLocalDatabase Local database URI.
       
   578 		* @param aType Content type.
       
   579 		* @return ETrue if a matching content was found.
       
   580 		*/
       
   581 		TBool SetIndexByDatabasesAndTypeL( CNSmlURI& aRemoteDatabase, CNSmlURI& aLocalDatabase, const TDesC8& aType );
       
   582 		
       
   583 		/**
       
   584 		* Marks the current content alerted by the server.
       
   585 		*/
       
   586 		void SetAsServerAlerted() const;
       
   587 		
       
   588 		/**
       
   589 		* Sets the content index to the first content.
       
   590 		* @return EFalse if there are no contents.
       
   591 		*/
       
   592 		TBool SetToFirst();
       
   593 		
       
   594 		/**
       
   595 		* Advances the content index by one.
       
   596 		* @return EFalse if there's no next content.
       
   597 		*/
       
   598 		TBool SetToNext();
       
   599 		
       
   600 		/**
       
   601 		* Sets the content index to the given content.
       
   602 		* @param aInd The new index.
       
   603 		* @return EFalse if the given content does not exist.
       
   604 		*/
       
   605 		TBool SetIndex( TInt aInd );
       
   606 		
       
   607 		/**
       
   608 		* Saves the current content index value.
       
   609 		*/
       
   610 		void SaveCurrentIndex();
       
   611 		
       
   612 		/**
       
   613 		* Sets the content index to the saved value.
       
   614 		*/
       
   615 		void SetIndexToSaved();
       
   616 		
       
   617 		/**
       
   618 		* Marks the current item of the current content as written to the 
       
   619 		* outgoing SyncML package.
       
   620 		*/
       
   621 		void SetCurrentItemWritten() const;
       
   622 		
       
   623 		/**
       
   624 		* Sets the current content as interrupted. This means that status codes
       
   625 		* will be sent to the server but the synchronization does not proceed
       
   626 		* further.
       
   627 		*/
       
   628 		void SetInterrupted();
       
   629 		
       
   630 		/**
       
   631 		* Sets the current content as immediately interrupted. This means that
       
   632 		* no further data about this content will be sent to the server.
       
   633 		*/
       
   634 		void SetImmediatelyInterrupted();
       
   635 		
       
   636 		/**
       
   637 		* Marks that the error status received from the server which caused sync
       
   638 		* interruption has been received by the current content.
       
   639 		*/
       
   640 		void SetServerStatusError();
       
   641 		
       
   642 		/**
       
   643 		* Sets the current content to the interrupted state before the sync
       
   644 		* session has been started.
       
   645 		*/
       
   646 		void SetInterruptedBeforeSync() const;
       
   647 		
       
   648 		/**
       
   649 		* Sets all interruption flags off for all contents.
       
   650 		*/
       
   651 		void UpdateInterruptedFlags();
       
   652 		
       
   653 		/**
       
   654 		* Sets the synchronization status of the current content.
       
   655 		* @param aSyncStatus Synchronization status.
       
   656 		*/
       
   657 		void SetSyncStatus( CNSmlDSAgent::TNSmlAgentSyncStatus aSyncStatus ) const; 
       
   658 		
       
   659 		/**
       
   660 		* Sets the synchronization status of all contents.
       
   661 		* @param aSyncStatus Synchronization status.
       
   662 		*/
       
   663 		void SetSyncStatusToAll( CNSmlDSAgent::TNSmlAgentSyncStatus aSyncStatus ) const;
       
   664 		
       
   665 		/**
       
   666 		* Sets device capabilities (CtCap elements) for all contents. Data
       
   667 		* stores use them when building the items that will be sent to the
       
   668 		* server.
       
   669 		* @return KErrNone if there were no errors.
       
   670 		*/
       
   671 		TInt SetTypeAndDevCapsL() const;
       
   672 		
       
   673 		/**
       
   674 		* Sets device capabilities (CtCap elements) for the current content. 
       
   675 		* Data stores use them when building the items that will be sent to the
       
   676 		* server.
       
   677 		* @return KErrNone if there were no errors.
       
   678 		*/
       
   679 		TInt SetSavedPartnerDevCapsL();
       
   680 		
       
   681 		/**
       
   682 		* Marks that client item count of the current content has been asked.
       
   683 		*/
       
   684 		void SetClientItemCountAsked() const;
       
   685 		
       
   686 		/**
       
   687 		* Marks that server item count for the current content has been asked.
       
   688 		* @param aCount Server item count.
       
   689 		*/
       
   690 		void SetServerItemCount( TInt aCount ) const;
       
   691 		
       
   692 		/**
       
   693 		* Sets the maximum size of the object that the server can accept from 
       
   694 		* the current content.
       
   695 		* @param aSize Maximum object size (in bytes).
       
   696 		*/
       
   697 		void SetMaxObjSizeInServer( TInt aSize ) const;
       
   698 
       
   699 		/**
       
   700 		* Removes those mappings that were created under a failed atomic command.
       
   701 		* @param aAtomicId Id of the failed atomic command.
       
   702 		*/
       
   703 		void RemoveFailedMappingsL( const TInt aAtomicId );
       
   704 		
       
   705 		/**
       
   706 		* Sets the current data store to the batch mode.
       
   707 		*/
       
   708 		void BeginBatchL();
       
   709 		
       
   710 		/**
       
   711 		* Cancels the ongoing batch mode.
       
   712 		*/
       
   713 		void CancelBatchL();
       
   714 		
       
   715 		/**
       
   716 		* Orders the current data store to commit batched operations. Batch mode is
       
   717 		* ended within this function.
       
   718 		* @param aResultArray Array of results in the order operations were requested.
       
   719 		* @param aResult On return contains the result code.
       
   720 		*/
       
   721 		void CommitBatchL( RArray<TInt>& aResultArray, TInt& aResultCode );
       
   722 		
       
   723 		/**
       
   724 		* Checks if the current data store is in the batch mode.
       
   725 		* @return ETrue is the batch mode is on, otherwise EFalse.
       
   726 		*/
       
   727 		TBool BatchModeOn() const;
       
   728 
       
   729 		/**
       
   730 		* Checks if the current data store is in the transaction mode.
       
   731 		* @return ETrue is the transaction mode is on, otherwise EFalse.
       
   732 		*/
       
   733 		TBool AtomicModeOn() const;
       
   734 
       
   735 		/**
       
   736 		* Opens the item that is first in the current content's LUID buffer.
       
   737 		* @param aLocalUid On return contains the opened item's local UID.
       
   738 		* @param aCmdName On return contains the opened item's command type.
       
   739 		* @param aSize On return contains the opened item's data size.
       
   740 		* @param aMeta On return contains the opened item's meta information.
       
   741 		* @return KErrNone if the item was opened, otherwise a system wide error code.
       
   742 		*/
       
   743 		TInt OpenNextItemL( TSmlDbItemUid& aLocalUid, TSmlDbItemUid& aParentUid, TDes8& aCmdName, TInt& aSize, CNSmlDbMeta& aMeta ) const;
       
   744 		
       
   745 		/**
       
   746 		* Creates new item to the current datastore. The created item is left open.
       
   747 		* @param aUid On return contains the new item's uid.
       
   748 		* @param aSize New item's size.		
       
   749 		* @param aMimeType New item's mime type.
       
   750 		* @param aMimeVersion New item's mime version.
       
   751 		* @param aParent New item's parent item.
       
   752 		* @return KErrNone if successful.
       
   753 		*/
       
   754 	    TInt CreateItemL( TSmlDbItemUid& aUid, TInt aSize, const TPtrC8 aMimeType, const TPtrC8 aMimeVersion, TSmlDbItemUid aParent ) const;
       
   755 		
       
   756 		/**
       
   757 		* Replaces a item in the current datastore with a new one. The item is left open.
       
   758 		* @param aUid Uid of the item to be replaced.
       
   759 		* @param aSize Item's size.
       
   760 		* @param aParent Item's parent item.
       
   761 		* @param aPartialUpdate ETrue if partial update should be used.
       
   762 		* @return KErrNone if successful.
       
   763 		*/
       
   764 		TInt ReplaceItemL( const TSmlDbItemUid aUid, TInt aSize, TSmlDbItemUid aParent, TBool aPartialUpdate ) const;
       
   765 
       
   766 		/**
       
   767 		* Deletes the given item.
       
   768 		* @param aUid Item's UID.
       
   769 		* @param aSoftDelete If set then the item is only soft deleted.
       
   770 		* @return KErrNone if successfull, otherwise a system wide error code.
       
   771 		*/
       
   772 		TInt DeleteItemL( const TSmlDbItemUid aUid, TBool aSoftDelete ) const;
       
   773 	
       
   774 		/**
       
   775 		* Moves the given item under a different parent.
       
   776 		* @param aUid Item to be moved.
       
   777 		* @param aParent Item's new parent.
       
   778 		* @return KErrNone if successfull, otherwise a system wide error code.
       
   779 		*/
       
   780 		TInt MoveItemL( const TSmlDbItemUid aUid, const TSmlDbItemUid aParent ) const;
       
   781 
       
   782 		/**
       
   783 		* Reads data from the currently open item. The number of bytes read is the same
       
   784 		* as the given buffer's maximum size.
       
   785 		* @param aBuffer Buffer where the read data is placed.
       
   786 		*/
       
   787 		void ReadItemL( TDes8& aBuffer );
       
   788 		
       
   789 		/**
       
   790 		* Writes data to the currently opened item.
       
   791 		* @param aData Buffer containing the data that should be written.
       
   792 		*/
       
   793 		void WriteItemL( const TDesC8& aData );
       
   794 
       
   795 		/**
       
   796 		* Closes the item that was previously opened with OpenNextItemL.
       
   797 		*/
       
   798 		void CloseItemL();
       
   799 		
       
   800 		/**
       
   801 		* Commits the currently opened item.
       
   802 		* @return KErrNone if successfull.
       
   803 		*/
       
   804 		TInt CommitItemL();
       
   805 
       
   806 		/**
       
   807 		* Checks if the current data store has been synced previously or not. Also the
       
   808 		* situation where the actual underlying database has been changed is checked.
       
   809 		* @return ETrue if the current datastore has been synced previously.
       
   810 		*/ 
       
   811 		TBool HasSyncHistoryL() const;
       
   812 		
       
   813 		/**
       
   814 		* Maps the given SourceParent value to an existing LUID.
       
   815 		* @param aSourceParent SourceParent that should be mapped.
       
   816 		* @param aUid On return contains the matching LUID.
       
   817 		* @return ETrue if a matching LUID was found.
       
   818 		*/
       
   819 		TBool MapSourceParent( const TDesC8& aSourceParent, TSmlDbItemUid& aUid );
       
   820 		
       
   821 		/**
       
   822 		* Sets the item with the given local UID as received. The current data
       
   823 		* store is called.
       
   824 		* @param aLUID Local UID of the received item.
       
   825 		*/
       
   826 		void SetAsReceivedL( TSmlDbItemUid aLUID ) const;
       
   827 		
       
   828 		/**
       
   829 		* Increases the number of warnings associated with the current content.
       
   830 		*/
       
   831 		void IncreaseWarnings() const; 
       
   832 		
       
   833 		/**
       
   834 		* Stores the server supported synchronization types for the current
       
   835 		* content.
       
   836 		* @param aSyncTypeArray Array of supported sync types.
       
   837 		*/
       
   838 		void UpdateSyncTypeL( const CArrayFix<HBufC8*>& aSyncTypeArray ) const;
       
   839 		
       
   840 		/**
       
   841 		* Stores the server supported CtCaps to the Agent Log.
       
   842 		* @param aDbCaps DevInfo from where CtCaps are read.
       
   843 		*/
       
   844 		void UpdateCtCapsL( const RPointerArray<CNSmlDbCaps>& aDbCaps ) const;
       
   845 		
       
   846 		/**
       
   847 		* Removes CtCaps of the current content from the Agent Log.
       
   848 		*/
       
   849 		void RemoveCtCapsL() const;
       
   850 		
       
   851 		/**
       
   852 		* Stores whether the used server supports hierarchical sync or not.
       
   853 		* @param aSupport ETrue if hierarchical sync is supported.
       
   854 		*/
       
   855 		void UpdateSupportHierarchicalSyncL( TInt aSupport ) const;
       
   856 		
       
   857 		/**
       
   858 		* Finalizes all contents.
       
   859 		*/
       
   860 		void FinalizeDatabasesL() const;
       
   861 		
       
   862 		/**
       
   863 		* Updates sync anchors of all contents with the given date.
       
   864 		* @param aAnchor The new sync anchor value.
       
   865 		*/
       
   866 		void UpdateSyncAnchorsL( const TTime& aAnchor ) const;
       
   867 		
       
   868 		/**
       
   869 		* Removes the current content from the content array.
       
   870 		*/
       
   871 		void RemoveContent();
       
   872 		
       
   873 		/**
       
   874 		* Removes non-server alerted contents from the content array.
       
   875 		*/
       
   876     	void RemoveNotServerAlertedContents();
       
   877     
       
   878 		/**
       
   879 		* Checks if an operation is supported by the data provider.
       
   880 		* @param aOperation UID of the operation.
       
   881 		* @return ETrue if the operation is supported.
       
   882 		*/
       
   883 		TBool SupportsOperationL( TUid aOperation );
       
   884 		
       
   885 		/**
       
   886 		* Orders the current data store to start the transaction mode.
       
   887 		*/
       
   888 		void BeginTransActionL();
       
   889 		
       
   890 		/**
       
   891 		* Orders the current data store to apply pending atomic operations.
       
   892 		* @param aStatus Asynchronous request status.
       
   893 		*/
       
   894 		void CommitTransactionL( TInt& aResultCode );
       
   895 		
       
   896 		/**
       
   897 		* Aborts the ongoing transaction.
       
   898 		* @param aStatus Asynchronous request status.
       
   899 		*/
       
   900 		void RevertTransactionL( TInt& aResultCode );
       
   901 
       
   902 		/**
       
   903 		* Updates current synchronization profile's server ID.
       
   904 		* @param aServerId New Server Id.
       
   905 		*/ 
       
   906 		TInt UpdateServerIdL( TDesC& aServerId ) const;
       
   907 
       
   908 		/**
       
   909 		* Returns current content's task id.
       
   910 		* @return Task Id of the current content or 0 if no content set.
       
   911 		*/
       
   912 		TSmlTaskId TaskId() const;
       
   913 	
       
   914 		/**
       
   915 		* Sets current content's task id.
       
   916 		* @param aId Content's task id.
       
   917 		*/
       
   918 		void TaskId( const TSmlTaskId aId );
       
   919 		
       
   920 		/**
       
   921 		* Increases the counter of added items.
       
   922 		*/
       
   923 		void IncreaseItemsAdded() const;
       
   924 
       
   925 		/**
       
   926 		* Increases the counter of changed items.
       
   927 		*/
       
   928 		void IncreaseItemsChanged() const;
       
   929 	
       
   930 		/**
       
   931 		* Increases the counter of deleted items.
       
   932 		*/
       
   933 		void IncreaseItemsDeleted() const;
       
   934 	
       
   935 		/**
       
   936 		* Increases the counter of moved items.
       
   937 		*/
       
   938 		void IncreaseItemsMoved() const;
       
   939 	
       
   940 		/**
       
   941 		* Increases the counter of failed items.
       
   942 		*/
       
   943 		void IncreaseItemsFailed() const;
       
   944 	
       
   945 		/**
       
   946 		* Increases the counter of items added on the server.
       
   947 		*/
       
   948 		void IncreaseServerItemsAdded() const;
       
   949 	
       
   950 		/**
       
   951 		* Increases the counter of items changed on the server.
       
   952 		*/
       
   953 		void IncreaseServerItemsChanged() const;
       
   954 	
       
   955 		/**
       
   956 		* Increases the counter of items deleted on the server.
       
   957 		*/
       
   958 		void IncreaseServerItemsDeleted() const;
       
   959 	
       
   960 		/**
       
   961 		* Increases the counter of items moved on the server.
       
   962 		*/
       
   963 		void IncreaseServerItemsMoved() const;
       
   964 	
       
   965 		/**
       
   966 		* Increases the counter of items failed on the server.
       
   967 		*/
       
   968 		void IncreaseServerItemsFailed() const;
       
   969 		
       
   970 		/**
       
   971 		* Checks if some or all of the updates sent by the server are applied to
       
   972 		* local databases.
       
   973 		* @return ETrue if at least some updates are applied.
       
   974 		*/
       
   975 		TBool PartiallyUpdated() const;
       
   976 		
       
   977 		/**
       
   978 		* Gets a list of current content's store names. Ownership is changed to the
       
   979 		* caller.
       
   980 		* @return List of store names.
       
   981 		*/
       
   982 		CDesCArray* StoreNamesL() const;
       
   983 		
       
   984 		/**
       
   985 		* Checks if filters are used.
       
   986 		* @return ETrue if filtering is used with the current content.
       
   987 		*/
       
   988 		TBool HasFilters() const;
       
   989 		
       
   990 		/**
       
   991 		* Stores the set of filters used with the current content. 
       
   992 		* @param aFilters Array of used filters.
       
   993 		* @param aMatchType Filter match type.
       
   994 		*/
       
   995 		void SetUsedFiltersL( RPointerArray<CSyncMLFilter>& aFilters, TSyncMLFilterMatchType aFilterMatchType );
       
   996 
       
   997         /**
       
   998         * Gets used filters from data store adapter.
       
   999         * @param aFilter On return contains the constructed filter strcuture.
       
  1000         * @return KErrNone if performed without errors.
       
  1001         */
       
  1002         TInt GetFilterL( CNSmlFilter*& aFilter );
       
  1003         
       
  1004         /**
       
  1005         * Gets filter caps from the agent log.
       
  1006         * @param aFilterCaps On return contains the stored filter cap elements.
       
  1007         */
       
  1008         void GetSavedFilterCapsL( CArrayFix<TNSmlFilterCapData>* aFilterCaps ) const;	
       
  1009 	    
       
  1010 	    /**
       
  1011 	    * Updates filter caps in the agent log.
       
  1012 	    * @param aFilterCaps New filter caps.
       
  1013 	    */	    
       
  1014         void UpdateFilterCapsL( const CArrayFix<TNSmlFilterCapData>* aFilterCaps ) const;
       
  1015         
       
  1016         /**
       
  1017         * Removes filter caps from the agent log.
       
  1018         */
       
  1019         void RemoveFilterCapsL() const;
       
  1020         /**
       
  1021         * Checks if the remote database is same as source ref
       
  1022         */
       
  1023 		TBool CheckValidRemoteDbL(RPointerArray<CNSmlURI>& aSourceRefArr, TBool aResp) const;
       
  1024 	
       
  1025 		//RD_SUSPEND_RESUME	
       
  1026 		/**
       
  1027         * Get suspended state from agentlog database
       
  1028         */
       
  1029 		TNSmlSyncSuspendedState SuspendedStateL();
       
  1030 		
       
  1031 		/**
       
  1032         * Save suspended state to agentlog database
       
  1033         */
       
  1034 		void SetSuspendedStateL(TNSmlSyncSuspendedState aState);
       
  1035 		/**
       
  1036         * Save Sync Type of Synchronization session in the AgentLog database.
       
  1037         */		
       
  1038 		void SetPreviousSyncTypeL(TNSmlPreviousSyncType aPrevSyncType);
       
  1039 		
       
  1040 		/**
       
  1041         * Gets Sync Type of the previous Suspened session from Agent Log database
       
  1042         */
       
  1043    		TNSmlPreviousSyncType PreviousSyncTypeL();
       
  1044    		
       
  1045    		
       
  1046    		/** 
       
  1047    		* Save Sync Type proposed by Client in a Synchronization session in the AgentLog database.
       
  1048         */
       
  1049 		void SetPreviousClientSyncTypeL(TNSmlPreviousSyncType aPrevSyncType);
       
  1050    		
       
  1051    		/**
       
  1052         * Gets Sync Type proposed by Client in the previous Suspened session from Agent Log database
       
  1053         */
       
  1054    		TNSmlPreviousSyncType PreviousClientSyncTypeL();
       
  1055 		
       
  1056 		//RD_SUSPEND_RESUME
       
  1057 		/**
       
  1058         * Set mapremovable flag enabled
       
  1059         */
       
  1060 		void SetMapRemovable();
       
  1061 		
       
  1062 		/**
       
  1063         * Read a cenrep key
       
  1064         */
       
  1065 		void ReadRepositoryL(TInt aKey, TInt& aValue);
       
  1066 		
       
  1067 	private: // constructors & operators
       
  1068 		/**
       
  1069 		* Standard C++ constructor,
       
  1070 		*/
       
  1071 		CNSmlDSContent();
       
  1072 		
       
  1073 		/**
       
  1074 		* Symbian 2nd phase constructor.
       
  1075 		*/	
       
  1076 		void ConstructL();
       
  1077 		
       
  1078 		/**
       
  1079 		* Prohibit copy constructor.
       
  1080 		*/
       
  1081 		CNSmlDSContent( const CNSmlDSContent& aOther );
       
  1082 		
       
  1083 		/**
       
  1084 		* Prohibit assignment operator.
       
  1085 		*/
       
  1086 		CNSmlDSContent& operator=( const CNSmlDSContent& aOther );
       
  1087 	
       
  1088 	private: // new functions
       
  1089 		/**
       
  1090 		* Reads given content's remote server DevInfo from the Agent Log.
       
  1091 		* @param aInd Index to a content.
       
  1092 		* @param aDbCaps On return contains remote server's DevInfo.
       
  1093 		*/
       
  1094 		void GetDevCapsFromAgentLogL( TInt aInd, CNSmlDbCaps*& aDbCaps ) const;
       
  1095 		
       
  1096 		/**
       
  1097 		* Convers literal sync type code to a DbCaps sync enumeration.
       
  1098 		* @aSyncType Synctype in literal form.
       
  1099 		* @aDbCapsSyncType On return contains the converted sync type.
       
  1100 		* @return ETrue if the conversion succeeded.
       
  1101 		*/
       
  1102 		TBool SyncTypeConv( const TDesC8& aSyncType, CNSmlDbCaps::ENSmlSyncTypes& aDbCapsSyncType ) const;
       
  1103 		
       
  1104 		/**
       
  1105 		* Checks if a bit in the given integer is set.
       
  1106 		* @param aValue UInt to check against.
       
  1107 		* @param aBit Bit mask to be checked.
       
  1108 		* @return ETrue if the bit is set.
       
  1109 		*/
       
  1110 		TBool IsFlagSet( const TUint& aValue, const TUint& aBit ) const;
       
  1111 		
       
  1112 		/**
       
  1113 		* Resets the given content's TaskInfo structure.
       
  1114 		* @param aSyncLog History Log where the TaskInfo is stored.
       
  1115 		* @param aInd Index to a content.
       
  1116 		*/
       
  1117 		void InitEventL( CSyncMLHistoryJob& aSyncLog, TInt aInd );
       
  1118 
       
  1119 	
       
  1120 	private: // data
       
  1121 		// index to current content
       
  1122 		TInt iIndex;
       
  1123 		// saved index  (for multimessage Sync)
       
  1124 		TInt iSavedIndex;
       
  1125 		// array for contents 
       
  1126 		RPointerArray<CNSmlDSContentItem> iStores;
       
  1127 		// used to communicate with host server(s)
       
  1128 		CNSmlDSHostClient* iHostClient;
       
  1129 		// server used in the previous session
       
  1130 		HBufC* iOldServerId;
       
  1131 		
       
  1132 // <MAPINFO_RESEND_MOD_BEGIN>
       
  1133 	TUid iMapStreamUid;
       
  1134 	TBool iOldMapExists;
       
  1135 	TRequestStatus* iCallerStatus;
       
  1136 	TBool iResendUsed;
       
  1137 // <MAPINFO_RESEND_MOD_END>
       
  1138 	RPtrHashMap<TDesC8, TBool> iHierarchicalSupportTable;
       
  1139 		
       
  1140 	};
       
  1141 
       
  1142 #endif // __NSMLDSCONTENT_H__
       
  1143 
       
  1144 // End of File
       
  1145