phonebookengines/VirtualPhonebook/VPbkCntModel/inc/CDeleteContactsOperation.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2004-2007 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:  An operation object to delete contacts from contacts database
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CDELETECONTACTSOPERATION_H
       
    20 #define CDELETECONTACTSOPERATION_H
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include <e32base.h>
       
    24 #include <MVPbkContactOperation.h>
       
    25 #include <shareddataclient.h>
       
    26 
       
    27 // FORWARD DECLARAIONS
       
    28 class MVPbkBatchOperationObserver;
       
    29 class CContactIdArray;
       
    30 class MVPbkContactLinkArray;
       
    31 
       
    32 namespace VPbkEngUtils { 
       
    33 class CVPbkDiskSpaceCheck;
       
    34 } /// namespace
       
    35 
       
    36 namespace VPbkCntModel {
       
    37 
       
    38 // FORWARD DECLARAIONS
       
    39 class CContactStore;
       
    40 class CContactLink;
       
    41 class CCompressDbOperation;
       
    42 
       
    43 NONSHARABLE_CLASS( CDeleteContactsOperation ): 
       
    44         public CActive,
       
    45         public MVPbkContactOperation
       
    46     {
       
    47     public:
       
    48         /**
       
    49          * Creates a new instance of this class.
       
    50          *
       
    51          * @param aContactStore     Contact store.
       
    52          * @param aLinks            Contacts to delete.
       
    53          * @param aObserver         Observer for the operation.
       
    54          * @param aSharedDataClient SharedDataClient for freeing disk space
       
    55          * @param aDiskSpaceChecker Disk space checker 
       
    56          * @return A new instance of this class.
       
    57          */
       
    58         static CDeleteContactsOperation* NewL(
       
    59                 CContactStore& aContactStore, 
       
    60                 const MVPbkContactLinkArray& aLinks, 
       
    61                 MVPbkBatchOperationObserver& aObserver,
       
    62                 RSharedDataClient* aSharedDataClient,
       
    63                 VPbkEngUtils::CVPbkDiskSpaceCheck& aDiskSpaceChecker );
       
    64 
       
    65         /**
       
    66          * Destructor.
       
    67          */
       
    68         ~CDeleteContactsOperation();
       
    69 
       
    70     private: // From CActive
       
    71         void DoCancel();
       
    72         void RunL();
       
    73         TInt RunError(TInt aError);
       
    74 
       
    75     private: // From MVPbkContactOperation
       
    76         void StartL();
       
    77         void Cancel();
       
    78 
       
    79     private: // Implementation
       
    80         CDeleteContactsOperation(
       
    81                 CContactStore& aContactStore, 
       
    82                 MVPbkBatchOperationObserver& aObserver,
       
    83                 RSharedDataClient* aSharedDataClient,
       
    84                 VPbkEngUtils::CVPbkDiskSpaceCheck& aDiskSpaceChecker );
       
    85         void ConstructL(
       
    86                 const MVPbkContactLinkArray& aLinks);
       
    87         void IssueRequest();
       
    88         void RunDeleteL();
       
    89         void RunCompressL(TBool aForce);
       
    90         void StartTransactionLC();
       
    91         void CommitTransactionLP();
       
    92         void DoRequestFreeDiskSpace();
       
    93         void DoRequestFreeDiskSpaceLC();
       
    94         void DoCancelFreeDiskSpaceRequest();
       
    95         void PrepareNextDelete();        
       
    96         void UpdateTimeStampOfAllContactsInGroupL();
       
    97         TBool CurrentItemIsGroupL();
       
    98         
       
    99     private: // Data structures
       
   100         /// Operation state
       
   101         enum TState
       
   102             {
       
   103             EDelete,
       
   104             EComplete
       
   105             };
       
   106 
       
   107     private: // Data
       
   108         /// Ref: Contact store
       
   109         CContactStore& iContactStore;
       
   110         /// Ref: Observer
       
   111         MVPbkBatchOperationObserver& iObserver;
       
   112         /// Own: Array of remaining contact IDs that are being deleted
       
   113         CContactIdArray* iRemainingContactIds;        
       
   114         /// Own: Array of contact IDs that are currently being deleted
       
   115         CContactIdArray* iCurrentContactIds;
       
   116         /// Own: Operation state
       
   117         TState iState;
       
   118         /// Ref: Shared data client for freeing disk space
       
   119         RSharedDataClient* iSharedDataClient;
       
   120         /// Ref: Reference to diskspace checker
       
   121         VPbkEngUtils::CVPbkDiskSpaceCheck& iDiskSpaceChecker;
       
   122         /// Own: Amount of free disk space required
       
   123         TBool iFreeDiskSpaceRequired;
       
   124         /// Own: Index of item to delete from iCurrentContactIds
       
   125         TInt iCurrentContactIndex;
       
   126         /// Own: number of groups in contact store
       
   127         TInt iGroupCount;
       
   128     };
       
   129 
       
   130 } // namespace VPbkCntModel
       
   131 
       
   132 #endif // CDELETECONTACTSOPERATION_H
       
   133 
       
   134 // End of File