phonebookengines/VirtualPhonebook/VPbkVCardEng/inc/CVPbkImportToStoreOperation.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2006-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 for importing and saving a contact to the store
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CVPBKIMPORTTOSTOREOPERATION_H
       
    21 #define CVPBKIMPORTTOSTOREOPERATION_H
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <MVPbkContactOperation.h>
       
    25 #include <MVPbkContactCopyObserver.h>
       
    26 #include <MVPbkContactFindObserver.h>
       
    27 #include "CVPbkOwnCardHandler.h"
       
    28 #include "CVPbkGroupCardHandler.h"
       
    29 #include "MVPbkImportOperationImpl.h"
       
    30 
       
    31 class MVPbkImportOperationImpl;
       
    32 class MVPbkStoreContact;
       
    33 class MVPbkContactStore;
       
    34 class CVPbkVCardData;
       
    35 class MVPbkContactCopyObserver;
       
    36 class CVPbkContactLinkArray;
       
    37 class MVPbkContactOperationBase;
       
    38 class MVPbkContactCopyPolicy;
       
    39 class MVPbkContactDuplicatePolicy;
       
    40 
       
    41 /**
       
    42  *  An operation for importing and saving a contact to the store
       
    43  */
       
    44 NONSHARABLE_CLASS(CVPbkImportToStoreOperation) 
       
    45     :   public CBase,
       
    46         public MVPbkContactOperation,
       
    47         private MVPbkImportOperationObserver,
       
    48         private MVPbkContactCopyObserver,
       
    49         private MVPbkContactFindObserver
       
    50     {
       
    51 public:
       
    52         
       
    53     static CVPbkImportToStoreOperation* NewL( 
       
    54         TVPbkImportCardType aType,
       
    55         MVPbkContactStore& aTargetStore, 
       
    56         RReadStream &aSourceStream,
       
    57         CVPbkVCardData& aData,
       
    58         MVPbkContactCopyObserver& aObserver,
       
    59         TBool aSync );
       
    60 
       
    61     virtual ~CVPbkImportToStoreOperation();
       
    62 
       
    63     
       
    64 // from base class MVPbkContactOperation
       
    65     void StartL();
       
    66     void Cancel();
       
    67 
       
    68 // from base class MVPbkImportOperationObserver
       
    69     void ContactsImported();
       
    70     void ContactImportingFailed( TInt aError );
       
    71     void ContactsImportingCompleted();
       
    72 
       
    73 // from base class MVPbkContactCopyObserver
       
    74     void ContactsSaved(MVPbkContactOperationBase& aOperation,
       
    75             MVPbkContactLinkArray* aResults);
       
    76     void ContactsSavingFailed(MVPbkContactOperationBase& aOperation,
       
    77             TInt aError);
       
    78             
       
    79 // from base class MVPbkContactFindObserver
       
    80     void FindCompleteL( MVPbkContactLinkArray* aResults );
       
    81     void FindFailed( TInt aError );
       
    82 
       
    83 private:
       
    84 
       
    85     CVPbkImportToStoreOperation( MVPbkContactCopyObserver& aObserver,
       
    86         MVPbkContactStore& aTargetStore );
       
    87     void ConstructL( 
       
    88         TVPbkImportCardType aType, 
       
    89         RReadStream &aSourceStream,
       
    90         CVPbkVCardData& aData,
       
    91         TBool aSync  );
       
    92     
       
    93     void CommitNextContactL();
       
    94     void HandleContactSavedL( MVPbkContactLinkArray* aResults );
       
    95     void ResetOperation();
       
    96     
       
    97 private: // data
       
    98         /// Own: the imported contacts
       
    99         RPointerArray<MVPbkStoreContact> iImportedContacts;
       
   100         /// Ref: the target store of the operation
       
   101         MVPbkContactStore& iTargetStore;
       
   102         /// Ref: client that waits importing
       
   103         MVPbkContactCopyObserver& iObserver;
       
   104         /// Own: the implementation of the import operation
       
   105         MVPbkImportOperationImpl* iOperationImpl;
       
   106         /// Own; the operation that commits the contact
       
   107         MVPbkContactOperationBase* iVPbkOperation;
       
   108         /// Own: an array of links of saved contacts
       
   109         CVPbkContactLinkArray* iSavedContacts;
       
   110         /// Ref: a copy policy for target store
       
   111         MVPbkContactCopyPolicy* iCopyPolicy;
       
   112         /// Ref: a duplicate policy for finding duplicate before copy
       
   113         MVPbkContactDuplicatePolicy* iDuplicatePolicy;
       
   114         /// Own: owns the contacts
       
   115         RPointerArray<MVPbkStoreContact> iDuplicates;
       
   116          CVPbkOwnCardHandler* iOwncardHandler;
       
   117         //Own: GroupCrad Handler
       
   118         CVPbkGroupCardHandler* iGroupcardHandler;
       
   119     };
       
   120 
       
   121 #endif // CVPBKIMPORTTOSTOREOPERATION_H