contactextensions/predefinedcontacts/inc/PdcVCardImporter.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 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:    Responsible for the import of contacts from vCards.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef C_PDCVCARDIMPORTER_H
       
    19 #define C_PDCVCARDIMPORTER_H
       
    20 
       
    21 // System includes
       
    22 #include <e32base.h>                  // CActive
       
    23 #include <MVPbkContactCopyObserver.h> // MVPbkContactCopyObserver
       
    24 
       
    25 // Forward declarations
       
    26 class RFs;
       
    27 class MVPbkContactStore;
       
    28 class CVPbkVCardEng;
       
    29 class CVPbkContactLinkArray;
       
    30 class MVPbkContactLinkArray;
       
    31 
       
    32 /**
       
    33  *  This class is responsible for the import of contacts from
       
    34  *  vCards. 
       
    35  */
       
    36 NONSHARABLE_CLASS( CPdcVCardImporter ): public CActive,
       
    37     public MVPbkContactCopyObserver
       
    38     {
       
    39 public:    
       
    40     /**
       
    41     * Symbian 1st phase constructor
       
    42     * @return Self pointer to CPdcXmlContentHandler
       
    43     * @param    aFs             file server
       
    44     * @param    aContactManager   contacts manager
       
    45     * @param    aContactStore   contacts store
       
    46     * @param    aLinkArray      Links to the  contacts added.
       
    47     * @return  a CPdcVCardImporter object
       
    48     */
       
    49     static CPdcVCardImporter* NewL( RFs& aFs,
       
    50                                       CVPbkContactManager& aContactManager,
       
    51                                       MVPbkContactStore& aContactStore,
       
    52                                       CVPbkContactLinkArray& aLinkArray );
       
    53 
       
    54     /**
       
    55     * Destructor.
       
    56     */
       
    57     virtual ~CPdcVCardImporter();
       
    58 
       
    59 public:
       
    60     /**
       
    61     * Asyncronously imports all the vCards in the given directory.
       
    62     * @param    aFileDirectory    directory containg vCards.
       
    63     * @param    aCallerStatus   caller's TRequestStatus
       
    64     */
       
    65     void GetVCardsL( const TDesC& aFileDirectory,
       
    66                                      TRequestStatus& aCallerStatus  );
       
    67 
       
    68 private: // C++ constructor and the Symbian second-phase constructor
       
    69 
       
    70     CPdcVCardImporter( RFs& aFs, MVPbkContactStore& aContactStore,
       
    71                                 CVPbkContactLinkArray& aLinkArray );
       
    72     void ConstructL( CVPbkContactManager& aContactManager );
       
    73 
       
    74 private:
       
    75     void SelfComplete();
       
    76     void ImportContactsL(const TDesC& aFileName);
       
    77     void AddToLinkArrayL( const MVPbkContactLinkArray& aResults);
       
    78 
       
    79 private: // From CActive
       
    80     void DoCancel();
       
    81 	void RunL();
       
    82 	TInt RunError( TInt aError );
       
    83 	
       
    84 private: // From MVPbkContactCopyObserver
       
    85     void ContactsSaved( MVPbkContactOperationBase& aOperation,
       
    86             MVPbkContactLinkArray* aResults );
       
    87             
       
    88    void ContactsSavingFailed( 
       
    89                 MVPbkContactOperationBase& aOperation, TInt aError );
       
    90 
       
    91 private: // data
       
    92     /// Ref: Contacts store
       
    93     MVPbkContactStore& iContactStore;
       
    94     /// Own: VCard import engine
       
    95     CVPbkVCardEng* iVCardEngine;
       
    96     /// Ref: File server
       
    97     RFs& iFs;
       
    98     /// Own: List of vCards in directory
       
    99     CDir* iVCardList;
       
   100     /// Index of current vCard
       
   101     TInt iVCardIndex;
       
   102     /// Ref: Caller's TRequestStatus
       
   103     TRequestStatus* iCallerStatus;
       
   104     /// Own: Directory containing vCards
       
   105     HBufC* iFileDirectory;
       
   106     /// Ref: Ids of the contacts that have been added
       
   107     CVPbkContactLinkArray& iLinkArray;
       
   108     /// Own: Import operation
       
   109     MVPbkContactOperationBase* iImportOperation;
       
   110     };
       
   111 
       
   112 #endif // C_PDCVCARDIMPORTER_H