omads/omadsextensions/adapters/agenda/inc/nsmlagendadatastore.h
changeset 19 2691f6aa1921
parent 4 e6e896426eac
child 20 e1de7d03f843
equal deleted inserted replaced
4:e6e896426eac 19:2691f6aa1921
     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:  DS agenda data store
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __NSMLAGENDADATASTORE_H__
       
    20 #define __NSMLAGENDADATASTORE_H__
       
    21 
       
    22 
       
    23 //  INCLUDES
       
    24 #include <calentry.h>
       
    25 #include <calsession.h> 
       
    26 #include <caldataexchange.h> 
       
    27 #include <calentryview.h>
       
    28 #include <f32file.h>
       
    29 #include <SmlDataProvider.h>
       
    30 #include <SmlDataFormat.h>
       
    31 #include <calprogresscallback.h>
       
    32 #include <msvapi.h>
       
    33 #include <CalenImporter.h>
       
    34 #include <CalenExporter.h>
       
    35 #include <CalenInterimUtils2.h>
       
    36 #include <versittls.h>
       
    37 #include <nsmlagendaadapterhandler.h>
       
    38 #include "nsmlconstants.h"
       
    39 #include "nsmlchangefinder.h"
       
    40 #include "NSmlDataModBase.h"
       
    41 #include "nsmlagendadefines.hrh"
       
    42 
       
    43 // CONSTANTS
       
    44 const TInt KNSmlAgendaCompressLimit        = 20;
       
    45 const TInt KNSmlAgendaLittleArraySize      = 4;
       
    46 const TInt KNSmlAgendaSmallArraySize       = 8;
       
    47 const TInt KNSmlAgendaLargeArraySize       = 128;
       
    48 const TInt KNSmlAgendaOwnMaxObjectSize     = 1048576;
       
    49 const TInt KNSmlCompactAfterChanges        = 30;
       
    50 const TInt KNSmlDefaultStoreNameMaxSize    = 256;
       
    51 const TInt KNSmlItemDataExpandSize         = 1024;
       
    52 const TUint KNSmlAgendaAdapterUid    	   = 0x101F6DDD;
       
    53 const TUint KNSmlAgendaAdapterStreamUid    = 0x101F6DDD+0x10009d8d;
       
    54 _LIT( KNSmlDriveC, "C" );
       
    55 _LIT( KNSmlAgendaStoreNameForDefaultDB, "Calendar" );
       
    56 _LIT( KNSmlAgendaFileNameForDefaultDB, "c:calendar" );
       
    57 _LIT8( KNSmlVersitTokenRecurrenceID, 	"RECURRENCE-ID");
       
    58 _LIT8( KNSmlVersitTokenXRecurrenceID, 	"X-RECURRENCE-ID");
       
    59 _LIT8(KNSmlVersitTokenGeoID,"GEO");
       
    60 
       
    61 //RD_MULTICAL
       
    62 // MIME content type for folder item
       
    63 _LIT8( KNSmlContentTypeFolder, "application/vnd.omads-folder+xml" );
       
    64 // Email folder item type version
       
    65 _LIT8( KNSmlContentTypeFolderVersion, "1.2" );
       
    66 _LIT8( KNSmlDefaultOpaqueData, "Default" );
       
    67 
       
    68 const TInt KArrayGranularity    = 30;
       
    69 const TInt KBuffLength = 128;
       
    70 
       
    71 // DATA TYPES
       
    72 enum TNSmlDataMimeType
       
    73     {
       
    74     ENSmlNone = 0,
       
    75     ENSmlCalendar,
       
    76     ENSmlFolder
       
    77     };
       
    78 //RD_MULTICAL
       
    79 enum TNSmlDataStoreStatus
       
    80 	{
       
    81 	ENSmlClosed = 0,
       
    82 	ENSmlOpenAndWaiting,
       
    83 	ENSmlItemOpen,
       
    84 	ENSmlItemCreating,
       
    85 	ENSmlItemUpdating
       
    86 	};
       
    87 	
       
    88 enum TNSmlDataEntryType
       
    89 	{
       
    90 	ENSmlVCal = 1,
       
    91 	ENSmlICal,
       
    92 	ENSmlNotSet
       
    93 	};
       
    94 // FORWARD CLASS DECLARATIONS
       
    95 class CNSmlAgendaAdapterLog;
       
    96 
       
    97 // CLASS DECLARATIONS
       
    98 // ----------------------------------------------------------------------------
       
    99 // CNSmlAgendaProgressview provides progress observations for some calendar
       
   100 // classes.
       
   101 // @lib nsmlagendadataprovider.dll
       
   102 // ----------------------------------------------------------------------------
       
   103 class CNSmlAgendaProgressview : public CBase , public MCalProgressCallBack
       
   104     {
       
   105     public:
       
   106         /**
       
   107         * Two-phased constructor.
       
   108         */
       
   109     	static CNSmlAgendaProgressview* NewL();
       
   110 
       
   111         /**
       
   112         * Destructor.
       
   113         */
       
   114     	~CNSmlAgendaProgressview();
       
   115 
       
   116     	/**
       
   117         * This calls the observing class with the percentage complete
       
   118         * of the current operation.
       
   119         * @param  aPercentageCompleted    The percentage complete
       
   120         */
       
   121     	void Progress( TInt aPercentageCompleted );
       
   122     	
       
   123     	/**
       
   124         * This calls the observing class when the current operation is
       
   125         * finished.
       
   126         * @param    aError  The error if the operation failed,
       
   127         *                   or KErrNone if successful.
       
   128         */
       
   129     	void Completed( TInt aError );
       
   130 
       
   131     	/**
       
   132         * This method returns status of Completed method (see above).
       
   133         * @return   Value based on status of Completed method.
       
   134         *           KErrNotReady is returned if Completed method is not
       
   135         *           called or same value is Completed status.
       
   136         */
       
   137     	TInt GetCompletedStatus();
       
   138     	
       
   139     	/**
       
   140         * Asks the observing class whether progress callbacks are required.
       
   141         * @return   If the observing class returns EFalse, then the Progress()
       
   142         *           function will not be called.
       
   143         */
       
   144     	TBool NotifyProgress();
       
   145 
       
   146     private:
       
   147         /**
       
   148         * C++ default constructor.
       
   149         */
       
   150     	CNSmlAgendaProgressview();
       
   151 
       
   152         /**
       
   153         * Second phase constructor.
       
   154         */
       
   155     	void ConstructL();
       
   156         
       
   157     private:
       
   158     	TInt    iCompletedStatus;
       
   159 	};
       
   160 
       
   161 // ----------------------------------------------------------------------------
       
   162 // CNSmlAgendaDataStore provides services to cope with calendar database access
       
   163 // for calendar events manipulation.
       
   164 // @lib nsmlagendadataprovider.dll
       
   165 // ----------------------------------------------------------------------------
       
   166 class CNSmlAgendaDataStore : public CSmlDataStore
       
   167 	{
       
   168     public:
       
   169         
       
   170         /**
       
   171         * Two-phased constructor.
       
   172         */
       
   173 	    static CNSmlAgendaDataStore* NewL();
       
   174         
       
   175         /**
       
   176         * Destructor.
       
   177         */
       
   178 	    virtual ~CNSmlAgendaDataStore();
       
   179 
       
   180     public: // New functions
       
   181         
       
   182         /**
       
   183         * Returns a pointer to array of all possible Calendar database names
       
   184         * which are provited by Symbian OS Calendar API.
       
   185         * @param none
       
   186         * @return Pointer to array of all possible Calendar database names 
       
   187         */
       
   188 	    CDesCArray *DoListAgendaFilesLC() const;
       
   189  
       
   190         /**
       
   191         * Returns a reference to default calendar file name which is provited
       
   192         * by Symbian OS Calendar API.
       
   193         * @param none
       
   194         * @return Reference to default calendar file name
       
   195         */
       
   196 	    const TDesC& DoGetDefaultFileNameL() const;
       
   197 	    
       
   198 	    /**
       
   199 	    * Providing DataStore access to CNSmlDataProvider Class
       
   200 	    */
       
   201 	    CSmlDataStoreFormat* StoreFormatL();
       
   202 	    
       
   203 	    /**
       
   204         * Check existance of CalFile with the given ProfileID associativity
       
   205         */
       
   206 	    TBool IsCalFileAvailableL( TInt aProfileId, CDesCArray* aCalFileArr );
       
   207 	    
       
   208 	    /**
       
   209         * Create CalFile with the attributes provided
       
   210         */
       
   211 	    HBufC* CreateCalFileL( HBufC* aProfileName, TInt aProfileId );	    
       
   212     private:
       
   213 
       
   214         /**
       
   215         * C++ default constructor.
       
   216         */
       
   217  	    CNSmlAgendaDataStore();
       
   218 
       
   219         /**
       
   220         * Returns the used store format.
       
   221         */
       
   222 	    CSmlDataStoreFormat* DoOwnStoreFormatL();
       
   223 
       
   224 	    /**
       
   225 	    * Opens the data store specified by aStoreName asynchronously.
       
   226 	    * @param	aStoreName		The name of the data store to open.
       
   227 	    * @param	aContext		Identifies the specific synchronisation
       
   228 	    *                           relationship to use for the
       
   229 	    *                           synchronisation.
       
   230 	    * @param	aStatus			On completion of the open,
       
   231 	    *                           contains the result code.
       
   232 	    */
       
   233 	    void DoOpenL( const TDesC& aStoreName, MSmlSyncRelationship& aContext,
       
   234 	                    TRequestStatus& aStatus );
       
   235 
       
   236 	    /**
       
   237 	    * Cancel the current asynchronous request, including open. 
       
   238 	    * Only one asynchronous request may be outstanding at any one time.
       
   239 	    */
       
   240 	    void DoCancelRequest();
       
   241 
       
   242 	    /**
       
   243 	    * Returns the name of the open data store.
       
   244 	    */
       
   245 	    const TDesC& DoStoreName() const;
       
   246 
       
   247 	    /**
       
   248 	    * BeginTransactionL() starts the transaction mode. During this mode
       
   249 	    * calls to CreateItemL, ReplaceItemL, WriteItemL, CommitItemL,
       
   250 	    * MoveItemL, DeleteItemL and SoftDeleteItemL will be part of this
       
   251 	    * transaction.
       
   252 	    * Their RequestStatus must be completed, even if the change is not
       
   253 	    * yet really executed in the Data Store.
       
   254 	    * If a RequestStatus is completed with an error code, the transaction
       
   255 	    * has failed and a rollback must be done. In this case
       
   256 	    * RevertTransaction will be called.
       
   257 	    */
       
   258 	    void DoBeginTransactionL();
       
   259 
       
   260 	    /**
       
   261 	    * CommitTransactionL() will be called at the end of a successful
       
   262 	    * transaction. At this point in time the operations within the
       
   263 	    * transaction are applied to the Data Store in an atomic way.
       
   264 	    * If all operations succeed, the RequestStatus must be completed
       
   265 	    * with KErrNone. If an operation fails, a rollback must be done and
       
   266 	    * the RequestStatus must be completed with an appropriate error code.
       
   267 	    */
       
   268 	    void DoCommitTransactionL( TRequestStatus& aStatus );
       
   269 
       
   270 	    /**
       
   271 	    * RevertTransaction() will be called to abort an ongoing transaction.
       
   272 	    * None of the operations already submitted may be applied to the Data
       
   273 	    * Store. The RequestStatus must be completed with KErrNone as a revert
       
   274 	    * cannot fail.
       
   275 	    */
       
   276 	    void DoRevertTransaction( TRequestStatus& aStatus );
       
   277 
       
   278 	    /**
       
   279 	    * BeginBatchL() starts the batch mode. During this mode calls to
       
   280 	    * CreateItemL, ReplaceItemL, WriteItemL, CommitItemL, MoveItemL,
       
   281 	    * DeleteItemL and SoftDeleteItemL will be part of this batch.
       
   282 	    * Their RequestStatus must be completed with KErrNone, which only
       
   283 	    * signals acceptance of the operation for batch processing.
       
   284 	    */
       
   285 	    void DoBeginBatchL();
       
   286 
       
   287 	    /**
       
   288 	    * CommitBatchL() will be called at the end of the batch mode. This
       
   289 	    * tells the Data Store to process the batched operations (in the
       
   290 	    * order they were submitted), and to append the error code for each
       
   291 	    * operation to aResultArray.
       
   292 	    * The error codes in aResultArray are only valid if the RequestStatus
       
   293 	    * is completed with KErrNone.
       
   294 	    * If the RequestStatus is completed with an error code none of the
       
   295 	    * operations in the batch mode were applied to the Data Store.
       
   296 	    */
       
   297 	    void DoCommitBatchL( RArray<TInt>& aResultArray,
       
   298                         TRequestStatus& aStatus );
       
   299 
       
   300 	    /**
       
   301 	    * CancelBatch() will be called to abort an ongoing batch mode.
       
   302 	    * None of the operations already submitted may be applied to
       
   303 	    * the Data Store.
       
   304 	    */
       
   305 	    void DoCancelBatch();
       
   306 
       
   307 	    /**
       
   308 	    * Sets the SyncML server Data Format - this may optionally be used
       
   309 	    * by the Data Provider to filter out properties that the server does
       
   310 	    * not support, and should be used to avoid deleting these properties
       
   311 	    * in case the server sends a changed item to the Data Provider
       
   312 	    */
       
   313 	    void DoSetRemoteStoreFormatL(
       
   314 	                    const CSmlDataStoreFormat& aServerDataStoreFormat );
       
   315 
       
   316 	    /**
       
   317 	    * Sets the SyncML server maximum object size - this may optionally
       
   318 	    * be used by the Data Provider to not send items to the server
       
   319 	    * exceeding its maximum size. 0 means there is no limit.
       
   320 	    */
       
   321 	    void DoSetRemoteMaxObjectSize( TInt aServerMaxObjectSize );
       
   322 
       
   323 	    /**
       
   324 	    * Gets the Data Store maximum object size which is reported to
       
   325 	    * the SyncML server. 0 means there is no limit.
       
   326 	    */
       
   327 	    TInt DoMaxObjectSize() const;
       
   328 
       
   329 		/**
       
   330 		* Opens the data item specified by aUid asynchronously for reading.
       
   331 		* @param		aUid				Item UID which going to be read.
       
   332 		* @param		aFieldChange		Accept field changes.
       
   333 		* @param		aParent				Parent of the item.
       
   334 		* @param		aSize				Size of the item data.
       
   335 		* @param		aMimeType			MIME type of the item.
       
   336 		* @param		aMimeVer			MIME version used on item.
       
   337 		* @param		aStatus				On completion of the opening of
       
   338 		*                                   item, contains the result code.
       
   339 		*/
       
   340 	    void DoOpenItemL( TSmlDbItemUid aUid, TBool& aFieldChange, TInt& aSize,
       
   341 	                        TSmlDbItemUid& aParent, TDes8& aMimeType,
       
   342 	                        TDes8& aMimeVer, TRequestStatus& aStatus );
       
   343 
       
   344 		/**
       
   345 		* Sets the item properties and reference to aUid which will be created.
       
   346 		* @param		aUid				Reference to item UID which going
       
   347 		*                                   to be created.
       
   348 		* @param		aSize				Size of the item to be created.
       
   349 		* @param		aParent				Parent of the item.
       
   350 		* @param		aMimeType			MIME type of the item.
       
   351 		* @param		aMimeVer			MIME version used on item.
       
   352 		* @param		aStatus				On completion of the creating an
       
   353 		*                                   item, contains the result code.
       
   354 		*/
       
   355 	    void DoCreateItemL( TSmlDbItemUid& aUid, TInt aSize,
       
   356 	                    TSmlDbItemUid aParent, const TDesC8& aMimeType,
       
   357                         const TDesC8& aMimeVer, TRequestStatus& aStatus );
       
   358 
       
   359 		/**
       
   360 		* Opens the data item specified by aUid asynchronously to be updated.
       
   361 		* @param		aUid				Item UID which going to be updated.
       
   362 		* @param		aSize				Size of the item data.
       
   363 		* @param		aParent				Parent of the item.
       
   364 		* @param		aFieldChange		Accept field changes.
       
   365 		* @param		aStatus				On completion of the updating of
       
   366 		*                                   item, contains the result code.
       
   367 		*/
       
   368 	    void DoReplaceItemL( TSmlDbItemUid aUid, TInt aSize,
       
   369                         TSmlDbItemUid aParent, TBool aFieldChange,
       
   370                         TRequestStatus& aStatus );
       
   371 
       
   372 		/**
       
   373 		* Reads data(or size of aBuffer) of an item opened in DoOpenItemL()
       
   374 		* to given aBuffer.
       
   375 		* @param		aBuffer				Buffer to item data.
       
   376 		*/
       
   377 	    void DoReadItemL( TDes8& aBuffer );
       
   378 
       
   379 		/**
       
   380 		* Writes aData of an item opened in DoCreateItemL() or DoReplaceItemL()
       
   381 		*  to be saved on database.
       
   382 		* @param		aData				Item data (or part of data).
       
   383 		*/
       
   384 	    void DoWriteItemL( const TDesC8& aData );
       
   385 
       
   386 		/**
       
   387 		* Completes an item operation started in DoCreateItemL() or
       
   388 		* DoReplaceItemL().
       
   389 		* @param		aStatus				On completion of the operation,
       
   390 		*                                   contains the result code.
       
   391 		*/
       
   392 	    void DoCommitItemL( TRequestStatus& aStatus );
       
   393 
       
   394 		/**
       
   395 		* Completes an item operation started in DoOpenItemL().
       
   396 		*/
       
   397 	    void DoCloseItem();
       
   398 
       
   399 		/**
       
   400 		* Moves item specified by aUid asynchronously.
       
   401 		* @param		aUid				Item UID which going to be moved.
       
   402 		* @param		aNewParent			A new parent of the item.
       
   403 		* @param		aStatus				On completion of the moving an
       
   404 		*                                   item, contains the result code.
       
   405 		*/
       
   406 	    void DoMoveItemL( TSmlDbItemUid aUid, TSmlDbItemUid aNewParent, TRequestStatus& aStatus );
       
   407 
       
   408 		/**
       
   409 		* Deletes item specified by aUid asynchronously.
       
   410 		* @param		aUid				Item UID which going to be deleted.
       
   411 		* @param		aStatus				On completion of the deleting an
       
   412 		*                                   item, contains the result code.
       
   413 		*/
       
   414 	    void DoDeleteItemL( TSmlDbItemUid aUid, TRequestStatus& aStatus );
       
   415 
       
   416 		/**
       
   417 		* Softdeletes item specified by aUid asynchronously.
       
   418 		* @param		aUid				Item UID which going to be
       
   419 		*                                   softdeleted.
       
   420 		* @param		aStatus				On completion of the softdeleting
       
   421 		*                                   an item, contains the result code.
       
   422 		*/
       
   423 	    void DoSoftDeleteItemL( TSmlDbItemUid aUid, TRequestStatus& aStatus );
       
   424 
       
   425 		/**
       
   426 		* Deletes all items from opened database asynchronously.
       
   427 		* @param		aStatus				On completion of delete, contains
       
   428 		*                                   the result code.
       
   429 		*/
       
   430 	    void DoDeleteAllItemsL( TRequestStatus& aStatus );
       
   431 
       
   432 		/**
       
   433 		* Check if previous sync with opened server and context.
       
   434 		*/
       
   435 	    TBool DoHasSyncHistory() const;
       
   436 
       
   437 		/**
       
   438 		* Get all added items on client since previous synchronization.
       
   439 		*/
       
   440 	    const MSmlDataItemUidSet& DoAddedItems() const;
       
   441 
       
   442 		/**
       
   443 		* Get all deleted items on client since previous synchronization.
       
   444 		*/
       
   445 	    const MSmlDataItemUidSet& DoDeletedItems() const;
       
   446 
       
   447 		/**
       
   448 		* Get all softdeleted items on client since previous synchronization.
       
   449 		*/
       
   450 	    const MSmlDataItemUidSet& DoSoftDeletedItems() const;
       
   451 
       
   452 		/**
       
   453 		* Get all modified items on client since previous synchronization.
       
   454 		*/
       
   455 	    const MSmlDataItemUidSet& DoModifiedItems() const;
       
   456 
       
   457 		/**
       
   458 		* Get all moved items on client since previous synchronization.
       
   459 		*/
       
   460 	    const MSmlDataItemUidSet& DoMovedItems() const;
       
   461 
       
   462 		/**
       
   463 		* Resets client synchronization data => next time will be slow sync.
       
   464 		* @param		aStatus				On completion of reset, contains
       
   465 		*                                   the result code.
       
   466 		*/
       
   467 	    void DoResetChangeInfoL( TRequestStatus& aStatus );
       
   468 
       
   469 		/**
       
   470 		* Commits client synchronization changes for given aItems list.
       
   471 		* @param		aStatus				On completion of given items,
       
   472 		*                                   contains the result code.
       
   473 		* @param		aItems				Item ids to be commited.
       
   474 		*/
       
   475 	    void DoCommitChangeInfoL( TRequestStatus& aStatus,
       
   476 	                    const MSmlDataItemUidSet& aItems );
       
   477 
       
   478 		/**
       
   479 		* Commits all client synchronization changes.
       
   480 		* @param		aStatus				On completion of all items,
       
   481 		*                                   contains the result code.
       
   482 		*/
       
   483 	    void DoCommitChangeInfoL( TRequestStatus& aStatus );
       
   484 
       
   485         /**
       
   486         * Registers current snapshot.
       
   487         */
       
   488 	    void RegisterSnapshotL();
       
   489 	    
       
   490 	    /**
       
   491         * Creates new snapshot. Method gets data from database.
       
   492         * @param	aUid    UID of item.
       
   493         * @return   New snapshot based on item with given UID
       
   494         */
       
   495 	    TNSmlSnapshotItem CreateSnapshotItemL( const TCalLocalUid& aUid );
       
   496 
       
   497         /**
       
   498         * Second phase constructor.
       
   499         */
       
   500 	    void ConstructL();
       
   501 
       
   502         /**
       
   503         * Returns ETrue if indicated entry can be syncronized.
       
   504         */
       
   505 		TBool CanBeSynchronized(
       
   506 		       const CCalEntry::TReplicationStatus& aReplicationStatus ) const;
       
   507 
       
   508 	    /**
       
   509 		* Completes an item operation started in DoCreateItemL().
       
   510 		*/
       
   511 	    void DoCommitCreateCalItemL();
       
   512 	    
       
   513 	    /**
       
   514 		* Completes an item operation started in DoReplaceItemL().
       
   515 		*/
       
   516 	    void DoCommitReplaceCalItemL();
       
   517 	    /**
       
   518        * Completes an Folder item operation started in DoCreateItemL().
       
   519        */
       
   520        void DoCommitCreateFolderItemL();
       
   521        
       
   522        /**
       
   523        * Completes an Folder item operation started in DoReplaceItemL().
       
   524        */
       
   525        void DoCommitReplaceFolderItemL();
       
   526 	    
       
   527 	    /**
       
   528 		* Gets property from old item.
       
   529 		* @param	aOldItem        Data of old item.
       
   530 		* @param	aValue          Value of searched property.
       
   531 		* @param	aProperty       Property that is searched.
       
   532 		*/
       
   533 	    void GetPropertiesFromDataL( CBufFlat* aOldItem,
       
   534 	                                 HBufC8*& aValue,
       
   535 	                                 const TDesC8& aProperty );
       
   536 	                                         
       
   537         /**
       
   538 		* Adds property and it's value to new item.
       
   539 		* This method also removes original property and it's value.
       
   540 		* @param	aValue          Value of added property.
       
   541 		* @param	aProperty       Property that is added.
       
   542 		*/
       
   543 	    void SetPropertiesToDataL( HBufC8*& aValue,
       
   544 	                               const TDesC8& aProperty );
       
   545 	    
       
   546 		/**
       
   547         * Method to determine the MIME type, provided the UID
       
   548         */
       
   549 		void DataMimeType( TSmlDbItemUid aUid );
       
   550 		
       
   551 		/**
       
   552         * Get All the AdapterHandler instance
       
   553         */
       
   554 	    void ListAllAgendaPluginAdaptersL();
       
   555 	    
       
   556 	    /**
       
   557         * Get the AdapterHandler instance
       
   558         */
       
   559 	    void AgendaAdapterHandlerL();
       
   560 	    
       
   561 	    /**
       
   562         * Retrieve the CalendarFile and associated entries ID
       
   563         */
       
   564 	    void SynchronizableCalEntryIdsL( RArray<TCalLocalUid>& aUidArray );	    
       
   565 
       
   566         /**
       
   567         * Method to retrieve the Id of the Calendar Entry
       
   568         */
       
   569         void GetCalendarEntryIdL( TCalLocalUid& aParentId, TCalLocalUid& aCalId ) const;
       
   570         
       
   571         /**
       
   572         * Open the Store if present else create one to work upon
       
   573         */
       
   574         void OpenStoreL();
       
   575         
       
   576         /**
       
   577         * Filters out the non-active items from the given array
       
   578         */
       
   579         CNSmlDataItemUidSet* ActiveItemsL( CNSmlDataItemUidSet& aUids ) const;
       
   580         
       
   581         /**
       
   582         * Populate iCommittedUidArr from the Stream
       
   583         */
       
   584         void ExternalizeCommittedUidL() const;
       
   585         
       
   586         /**
       
   587         * Write the contents of iCommittedUidArr to the Stream
       
   588         */
       
   589         void InternalizeCommittedUidL() const;
       
   590 
       
   591     private: // Data
       
   592         // Key
       
   593 	    TKeyArrayFix iKey;
       
   594         // Position of buffer
       
   595 	    TInt iPos;
       
   596         // Flag if Synchronization history is available or not
       
   597 	    TBool iHasHistory;
       
   598         // Modification count
       
   599 	    TInt iModificationCount;
       
   600         // Internal state of this class
       
   601 	    TNSmlDataStoreStatus iState;
       
   602         // Flag if SnapshotRegistered is registered or not
       
   603 	    TBool iSnapshotRegistered;
       
   604         // Drive letter
       
   605 	    TInt iDrive;
       
   606         // Item's ID that is to be replaced
       
   607 	    TInt iReplaceItemId;
       
   608         // Internal entry type for received item
       
   609 	    TNSmlDataEntryType iRXEntryType;
       
   610 	    // Internal entry type for transmitted item
       
   611 	    TNSmlDataEntryType iTXEntryType;
       
   612         // ChangeFinder
       
   613 	    CNSmlChangeFinder* iChangeFinder;
       
   614         // DataModel
       
   615 	    CNSmlDataModBase* iDataMod;
       
   616         // Status code from functions
       
   617 	    TRequestStatus* iCallerStatus;
       
   618         // A handle to a file server session
       
   619 	    RFs iRfs;
       
   620         // ServerMaxObjectSize
       
   621 	    TInt iServerMaxObjectSize;
       
   622         // Name of the opened database
       
   623 	    HBufC* iOpenedStoreName;
       
   624 	    // Name of the received storename
       
   625 	    HBufC* iReceivedStoreName;
       
   626         // Default name of the database
       
   627 	    HBufC* iDefaultStoreFileName;
       
   628         // Opened database ID
       
   629 	    TInt64 iOpenedStoreId;
       
   630         // Item's ID that is to be added
       
   631 	    TInt* iAddItemId;
       
   632         // Item's data that is to be written
       
   633 	    CBufBase* iItemData;
       
   634         // Own store format
       
   635 	    CSmlDataStoreFormat* iOwnFormat;
       
   636         // StringPool
       
   637 	    RStringPool iStringPool;
       
   638         // Uids of new items
       
   639 	    CNSmlDataItemUidSet* iNewUids;
       
   640         // Uids of deleted items
       
   641 	    CNSmlDataItemUidSet* iDeletedUids;
       
   642         // Uids of softdeleted items
       
   643 	    CNSmlDataItemUidSet* iSoftDeletedUids;
       
   644         // Uids of replaced items
       
   645 	    CNSmlDataItemUidSet* iReplacedUids;
       
   646         // Uids of moved items
       
   647 	    CNSmlDataItemUidSet* iMovedUids;
       
   648         /*// Session to calendar server
       
   649 	    CCalSession* iVCalSession;
       
   650         // Internal progress notifier
       
   651 	    CNSmlAgendaProgressview* iAgendaProgressview;*/
       
   652 	    // Interim Utility
       
   653 	    CCalenInterimUtils2* iInterimUtils;
       
   654 	    
       
   655         /*// Importer
       
   656 	    CCalenImporter* iImporter;
       
   657 	    // Exporter
       
   658 	    CCalenExporter* iExporter;
       
   659 	    
       
   660 	    // Entry view
       
   661         CCalEntryView* iEntryView;
       
   662         CVersitTlsData *iVersitTlsData; // for better performance*/
       
   663         // Flag is Hierarchical Sync is supported
       
   664 		TBool iIsHierarchicalSyncSupported;
       
   665 		// Mime Type of Calendar Item
       
   666 		TNSmlDataMimeType iDataMimeType;
       
   667 		// Parent Id of the Calendar Item
       
   668 		TInt iParentItemId;
       
   669 		// Offset value
       
   670 		TUint iCalOffsetVal;
       
   671 		// Offset memory values of the Calendar DB
       
   672 		CArrayFixFlat<TUint>* iCalOffsetArr;
       
   673 		// List of committed UIDs
       
   674 		CNSmlDataItemUidSet* iCommittedUidArr;
       
   675 		// Agenda Adapter Handler Instance
       
   676 		RPointerArray<CNSmlAgendaAdapterHandler>  iAgendaPluginAdapters;  
       
   677 		// Agenda Adapter Handler Instance
       
   678         CNSmlAgendaAdapterHandler* iAgendaAdapterHandler;
       
   679         // SyncRelationship instance
       
   680         CNSmlAgendaAdapterLog* iAgendaAdapterLog;
       
   681 	};
       
   682 
       
   683 // ----------------------------------------------------------------------------
       
   684 // CNSmlAgendaDataStoreUtil provides services to cope with maintaining calendar 
       
   685 // API's used for database access
       
   686 // @lib nsmlagendadataprovider.dll
       
   687 // ----------------------------------------------------------------------------
       
   688 NONSHARABLE_CLASS(CNSmlAgendaDataStoreUtil) : public CBase
       
   689     {
       
   690     public:
       
   691         /**
       
   692         * Two-phased constructor.
       
   693         */
       
   694         static CNSmlAgendaDataStoreUtil* NewL();
       
   695         
       
   696         /**
       
   697         * Destructor.
       
   698         */
       
   699         virtual ~CNSmlAgendaDataStoreUtil();
       
   700       
       
   701     private:
       
   702         /**
       
   703         * C++ default constructor.
       
   704         */
       
   705         CNSmlAgendaDataStoreUtil();
       
   706         
       
   707     public: // New Functions
       
   708         /**
       
   709         * Initialize Calendar APIs for database access using the provided name and id
       
   710         */
       
   711         void InitializeCalAPIsL( HBufC* aFileName, TSmlDbItemUid aUid = NULL );
       
   712        
       
   713     
       
   714     public: // Data
       
   715         CCalSession* iCalSession;
       
   716         CCalenExporter* iExporter;
       
   717         CCalenImporter* iImporter;
       
   718         CNSmlAgendaProgressview* iProgressView;
       
   719         CCalEntryView* iEntryView;
       
   720         CCalEntry* iEntry;
       
   721         HBufC8* iFileName;
       
   722         TSmlDbItemUid iUid;
       
   723     };
       
   724 
       
   725 // ----------------------------------------------------------------------------
       
   726 // CNSmlAgendaAdapterLog provides services know active Sync 
       
   727 // API's used for database access
       
   728 // @lib nsmlagendadataprovider.dll
       
   729 // ----------------------------------------------------------------------------
       
   730 NONSHARABLE_CLASS(CNSmlAgendaAdapterLog) : public CBase
       
   731     {
       
   732     public:
       
   733         /**
       
   734         * Two-phased constructor.
       
   735         */
       
   736         static CNSmlAgendaAdapterLog* NewL( MSmlSyncRelationship& aSyncRelationship );
       
   737         
       
   738         /**
       
   739         * Destructor.
       
   740         */
       
   741         virtual ~CNSmlAgendaAdapterLog();
       
   742       
       
   743     private:
       
   744         /**
       
   745         * C++ default constructor.
       
   746         */
       
   747         CNSmlAgendaAdapterLog( MSmlSyncRelationship& aSyncRelationship );
       
   748     
       
   749     public: // Data
       
   750         MSmlSyncRelationship& iSyncRelationship;
       
   751         
       
   752     };
       
   753 #endif // __NSMLAGENDADATASTORE_H__
       
   754             
       
   755 // End of File