PECengine/ListLibrary2/AttrListSrc/CPEngAttributeListTransactionManager.h
branchRCL_3
changeset 17 a941bc465d9f
parent 0 094583676ce7
equal deleted inserted replaced
16:6ca72c0fe49a 17:a941bc465d9f
       
     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:  Attribute list transaction manager
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CPENGATTRIBUTELISTTRANSACTIONMANAGER_H__
       
    19 #define __CPENGATTRIBUTELISTTRANSACTIONMANAGER_H__
       
    20 
       
    21 
       
    22 //  INCLUDES
       
    23 
       
    24 #include "CPEngAttributeListManager.h"
       
    25 #include "MPEngTransactionFactory.h"
       
    26 #include "MPEngAttributeListTransactionManager.h"
       
    27 #include "PEngWVCspVersion.h"
       
    28 #include <e32base.h>
       
    29 
       
    30 // DATA TYPES
       
    31 typedef void ( CPEngAttributeListItem::*CommitCall )( const TDesC& );
       
    32 typedef TBool ( CPEngAttributeListItem::*ItemDefaultSet )( void ) const;
       
    33 
       
    34 
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class CPEngContactListTransactionManager;
       
    38 class MPEngListLibFactory;
       
    39 
       
    40 
       
    41 // CLASS DECLARATION
       
    42 /**
       
    43  * Attribute list transaction manager
       
    44  *
       
    45  * @lib PEngListLib2
       
    46  * @since 3.0
       
    47  */
       
    48 NONSHARABLE_CLASS( CPEngAttributeListTransactionManager ):
       
    49         public CPEngAttributeListManager,
       
    50         public MPEngTransactionFactory,
       
    51         public MPEngAttributeListTransactionManager
       
    52     {
       
    53 public:
       
    54     /**
       
    55      * Two-phased constructor.
       
    56      */
       
    57     static CPEngAttributeListTransactionManager* NewL(
       
    58         MPEngListLibFactory& aFactory,
       
    59         const CPEngSessionSlotId& aSessionSlot,
       
    60         TPEngWVCspVersion& aCSPVersion );
       
    61 
       
    62     /**
       
    63      * Two-phased constructor.
       
    64      */
       
    65     static CPEngAttributeListTransactionManager* NewLC(
       
    66         MPEngListLibFactory& aFactory,
       
    67         const CPEngSessionSlotId& aSessionSlot,
       
    68         TPEngWVCspVersion& aCSPVersion );
       
    69 
       
    70     /**
       
    71      * Destructor.
       
    72      */
       
    73     ~CPEngAttributeListTransactionManager();
       
    74 
       
    75 
       
    76 
       
    77 public: // Functions from MPEngTransactionFactory
       
    78 
       
    79     /**
       
    80      * Clean up stack support for the factory
       
    81      * @see <MPEngTransactionFactory.h>
       
    82      */
       
    83     void Close();
       
    84 
       
    85 
       
    86     /**
       
    87      * Factory method to create handler for incoming data
       
    88      * @see <MPEngTransactionFactory.h>
       
    89      */
       
    90     MPEngIncomingTransactionHandler* IncomingTransactionHandlerL(
       
    91         const TDesC8& aIncomingRequest );
       
    92 
       
    93     /**
       
    94      * Factory method to create outgoing handler(s)
       
    95      * @see <MPEngTransactionFactory.h>
       
    96      */
       
    97     void OutgoingTransactionHandlerL(
       
    98         TInt aOperation,
       
    99         const TDesC& aData,
       
   100         RPointerArray<MPEngOutgoingTransactionHandler>& aHandlers );
       
   101 
       
   102 
       
   103 
       
   104 public: // From MPEngAttributeListTransactionManager
       
   105 
       
   106     /**
       
   107      * Commit Attribute list creation
       
   108      * @see <MPEngAttributeListTransactionManager.h>
       
   109      */
       
   110     void AttributeListCreated( const RArray<TUint32>& aAttrList );
       
   111 
       
   112 
       
   113     /**
       
   114      * Attribute list synchronized with the server
       
   115      * @see <MPEngAttributeListTransactionManager.h>
       
   116      */
       
   117     void AttributeEngineSynchronizedL();
       
   118 
       
   119 
       
   120     /**
       
   121      * Commit successful creation of the attribute list for contact list
       
   122      * @see <MPEngAttributeListTransactionManager.h>
       
   123      */
       
   124     void CommitContactListL( const TDesC& aContactList );
       
   125 
       
   126 
       
   127     /**
       
   128      * Commit successful creation of the attribute list for contact ID
       
   129      * @see <MPEngAttributeListTransactionManager.h>
       
   130      */
       
   131     void CommitContactIdL( const TDesC& aContactId );
       
   132 
       
   133 
       
   134     /**
       
   135      * Rollback unsuccessful creation of the attribute list
       
   136      * @see <MPEngAttributeListTransactionManager.h>
       
   137      */
       
   138     void RollBackContactListL( const TDesC& aContactList );
       
   139 
       
   140 
       
   141     /**
       
   142      * Rollback unsuccessful creation of the attribute list
       
   143      * @see <MPEngAttributeListTransactionManager.h>
       
   144      */
       
   145     void RollBackContactIdL( const TDesC& aContactId );
       
   146 
       
   147 
       
   148     /**
       
   149      * Commit creation of the attribute list
       
   150      * @see <MPEngAttributeListTransactionManager.h>
       
   151      */
       
   152     void CommitDefaultL();
       
   153 
       
   154 
       
   155     /**
       
   156      * Roll back creating of the default attribute list
       
   157      * @see <MPEngAttributeListTransactionManager.h>
       
   158      */
       
   159     void RollBackDefaultL();
       
   160 
       
   161 
       
   162     /**
       
   163      * Commit contacts, creating of the attribute list was successful
       
   164      * @see <MPEngAttributeListTransactionManager.h>
       
   165      */
       
   166     void CommitDefinedContactsL( const CDesCArray* aContactLists,
       
   167                                  const CDesCArray* aContactIds );
       
   168 
       
   169     /**
       
   170      * RollBack contacts
       
   171      * @see <MPEngAttributeListTransactionManager.h>
       
   172      */
       
   173     void RollBackDefinedContactsL( const CDesCArray* aContactLists,
       
   174                                    const CDesCArray* aContactIds );
       
   175 
       
   176 
       
   177     /**
       
   178      * Store changes of the attribute list to the store
       
   179      * @see <MPEngAttributeListTransactionManager.h>
       
   180      */
       
   181     void StoreChangesToStoreL();
       
   182 
       
   183 
       
   184 
       
   185 
       
   186 
       
   187 private:    // new function of the base class
       
   188 
       
   189     /**
       
   190      * Create synchronization Handlers
       
   191      *
       
   192      * @since 3.0
       
   193      * @param aTransactionHandlers array to append handlers
       
   194      */
       
   195     void GetSyncHandlersL(
       
   196         RPointerArray<MPEngOutgoingTransactionHandler>& TransactionHandlers,
       
   197         TInt aOperationId );
       
   198 
       
   199     /**
       
   200      * Get attribute lists update handler
       
   201      *
       
   202      * @since 3.0
       
   203      * @param aTransactionHandlers array to append handlers
       
   204      * @param aOperationId operation Id
       
   205      */
       
   206     void GetAttributeListsUpdateHandlersL(
       
   207         RPointerArray<MPEngOutgoingTransactionHandler>& TransactionHandlers,
       
   208         TInt aOperationId );
       
   209 
       
   210     /**
       
   211      * Get attribute lists update handlers for defined contact lists.
       
   212      *
       
   213      * @since 3.0
       
   214      * @param aData packed Storage Ids of the contact lists
       
   215      * @param aTransactionHandlers array to append handlers
       
   216      * @param aOperationId operation Id
       
   217      */
       
   218     void GetLazyContLstInitializeAttrLstHandlersL(
       
   219         const TDesC& aData,
       
   220         RPointerArray<MPEngOutgoingTransactionHandler>& TransactionHandlers,
       
   221         TInt aOperationId );
       
   222 
       
   223     /**
       
   224      * Get attribute lists update handlers for to be deleted attr lists
       
   225      *
       
   226      * @since 3.0
       
   227      * @param aTransactionHandlers array to append handlers
       
   228      * @param aOperationId operation Id
       
   229      */
       
   230     void GetDeleteAttributeListsHandlersL(
       
   231         RPointerArray<MPEngOutgoingTransactionHandler>& aTransactionHandlers,
       
   232         TInt aOperationId );
       
   233 
       
   234 
       
   235     /**
       
   236      * Compress array of attribute lists
       
   237      *
       
   238      * @since 3.0
       
   239      */
       
   240     void CompressArrListArray();
       
   241 
       
   242     /**
       
   243      * Append descriptors from the original array to the new array
       
   244      *
       
   245      * @since 3.0
       
   246      * @param aOriginalDesArray original descriptor array
       
   247      * @param aNewArray new descriptor array
       
   248      */
       
   249     void AppendDesArrayContentL(
       
   250         const CDesC16Array& aOriginalDesArray,
       
   251         CDesC16Array& aNewDesArray );
       
   252 
       
   253 
       
   254     /**
       
   255      * Check if attribute list is valid on the server
       
   256      *
       
   257      * @since 3.0
       
   258      * @param aAttributeList attribute list
       
   259      * @return ETrue if attribute list is valid
       
   260      */
       
   261     TBool CheckAttributeListServerValidityCurrent(
       
   262         const CPEngAttributeListItem& aAttributeList );
       
   263 
       
   264     /**
       
   265      * Check if attribute list needs to be created on the network server.
       
   266      *
       
   267      * @since 3.0
       
   268      * @param aAttributeList attribute list
       
   269      * @return ETrue if attribute list is valid
       
   270      */
       
   271     TBool CheckAttributeListCreateNewValidity(
       
   272         const CPEngAttributeListItem& aAttributeList );
       
   273 
       
   274     /**
       
   275      * Check if attribute list needs to be deleted from the server
       
   276      *
       
   277      * @since 3.0
       
   278      * @param
       
   279      * @return ETrue if attribute list is valid
       
   280      */
       
   281     TBool CheckAttributeListDeleteValidity();
       
   282 
       
   283     /**
       
   284      * Commit whole content of the attribute list
       
   285      *
       
   286      * @since 3.0
       
   287      * @param aAttributeList attribute list
       
   288      */
       
   289     void CommitAttributeListL(
       
   290         const CPEngAttributeListItem& aAttributeList );
       
   291 
       
   292     /**
       
   293      * Commit all attribute lists
       
   294      *
       
   295      * @since 3.0
       
   296      */
       
   297     void CommitAllAttributeListL();
       
   298 
       
   299     /**
       
   300      * Commit attribute lists for deletion
       
   301      *
       
   302      * @since 3.0
       
   303      */
       
   304     void CommitDeleteAttributeListL();
       
   305 
       
   306     /**
       
   307      * Commit successful creation of the attribute list for contact
       
   308      *
       
   309      * @since 3.0
       
   310      * @param aContact Contact to commit
       
   311      * @param aCommitCall call back function to use for commit
       
   312      * @param aDeleteArray delete array to be used for commiting
       
   313      */
       
   314     void CommitContactL( const TDesC& aContact,
       
   315                          CommitCall aCommitCall,
       
   316                          CDesCArray& aDeleteArray );
       
   317 
       
   318     /**
       
   319       * Rollback not successful creation of the attribute list for contact
       
   320       *
       
   321       * @since 3.0
       
   322       * @param aContact Contact to rollback
       
   323       * @param aNewCommitArray array of the attr list item to use to rollback
       
   324       * @param aDeleteArray delete array to use to rollback
       
   325       */
       
   326     void RollBackOneContactL( const TDesC& aContact,
       
   327                               CPEngAttributeListItem::TPEngAttrListItemArrays aNewCommitArray,
       
   328                               CDesCArray& aDeleteArray );
       
   329     /**
       
   330      * Check if attribute list is validity
       
   331      *
       
   332      * @since 3.0
       
   333      * @param aAttributeList attribute list
       
   334      * @param aIDsArray id array to use
       
   335      * @param aCntListArray cnt list array to use
       
   336      * @param aDefaultSetCall call function pointer
       
   337      * @param aSynchronizeFlagIncluded synchronization flag included
       
   338      * @return ETrue if attribute list is valid
       
   339      */
       
   340     TBool CheckAttributeListValidity(
       
   341         const CPEngAttributeListItem& aAttributeList,
       
   342         CPEngAttributeListItem::TPEngAttrListItemArrays aIDsArray,
       
   343         CPEngAttributeListItem::TPEngAttrListItemArrays aCntListArray,
       
   344         ItemDefaultSet aDefaultSetCall,
       
   345         TBool aSynchronizeFlagIncluded );
       
   346 
       
   347 private: // constructors
       
   348 
       
   349     /**
       
   350      * By default Symbian constructor is private.
       
   351      */
       
   352     void ConstructL( const CPEngSessionSlotId& aSessionSlot );
       
   353 
       
   354     /**
       
   355      * C++ default constructor.
       
   356      */
       
   357     CPEngAttributeListTransactionManager( MPEngListLibFactory& aFactory,
       
   358                                           TPEngWVCspVersion& aCSPVersion );
       
   359 
       
   360 private:    // Data
       
   361 
       
   362     // REF: Contact list transaction manager
       
   363     CPEngContactListTransactionManager*     iContactListTransManager;
       
   364 
       
   365     /// REF: CSP Version
       
   366     TPEngWVCspVersion&                      iCSPVersion;
       
   367 
       
   368     /// OWN: Count of created sync handlers
       
   369     TInt									iSyncHandlerCount;
       
   370 
       
   371     };
       
   372 
       
   373 #endif  //   __CPENGATTRIBUTELISTTRANSACTIONMANAGER_H__
       
   374 
       
   375 // End of File
       
   376