contactextensions/predefinedcontacts/inc/PdcXMLImporter.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 an XML file
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef C_PDCXMLIMPORTER_H
       
    19 #define C_PDCXMLIMPORTER_H
       
    20 
       
    21 // System includes
       
    22 #include <e32base.h> // CActive
       
    23 
       
    24 // User includes
       
    25 #include "CVPbkContactManager.h"
       
    26 
       
    27 // Forward declarations
       
    28 class MVPbkContactStore;
       
    29 class RFs;
       
    30 class CPdcXmlContentHandler;
       
    31 class CVPbkContactLinkArray;
       
    32 
       
    33 namespace Xml
       
    34     {
       
    35     class CParser;
       
    36     class CMatchData;
       
    37     }
       
    38 
       
    39 // Constants 
       
    40 // xml data block size;
       
    41 const TInt KXmlDataBlockSize = 128; // xml data block size; 
       
    42 
       
    43 /**
       
    44  *  This class is responsible for the import of contacts from
       
    45  *  an XML file. It owns a content handler which converts 
       
    46  *  the contents of the XML file into a contacts item.
       
    47  */
       
    48 NONSHARABLE_CLASS( CPdcXmlImporter ): public CActive
       
    49     {
       
    50 public:
       
    51     /**
       
    52     * Symbian 1st phase constructor
       
    53     * @return Self pointer to CPdcXmlImporter pushed to
       
    54     * the cleanup stack.
       
    55     * @param    aFs     file system
       
    56     * @param    aContactDatabase   contacts store
       
    57     * @param    aLinkArray  links to contacts added.
       
    58     * @return a CPdcXmlImporter object.
       
    59     */
       
    60     static CPdcXmlImporter* NewL( RFs& aFs,
       
    61                               MVPbkContactStore& aContactStore,
       
    62                               CVPbkContactLinkArray& aLinkArray );
       
    63     
       
    64     /**
       
    65     * Destructor.
       
    66     */
       
    67     virtual ~CPdcXmlImporter();
       
    68 
       
    69 public:
       
    70     /**
       
    71     * Symbian 1st phase constructor
       
    72     * @return Self pointer to CPdcXmlImporter pushed to
       
    73     * the cleanup stack.
       
    74     * @param    aFileDirectory    directory containing XML script.
       
    75     * @param    aCallerStatus     Caller's iStatus.
       
    76     */
       
    77     void GetXmlContactsL( const TDesC& aFileDirectory,
       
    78                                      TRequestStatus& aCallerStatus  ); 
       
    79     
       
    80      /**
       
    81      * Sets the contactmanager 
       
    82      * @param aContactManager   engine's contactmanager
       
    83      */                                 
       
    84     void SetContactManager(CVPbkContactManager* aContactManager);
       
    85 
       
    86 private: // C++ constructor and the Symbian second-phase constructor
       
    87     CPdcXmlImporter( RFs& aFs, MVPbkContactStore& aContactStore,
       
    88                                 CVPbkContactLinkArray& aLinkArray );
       
    89     void ConstructL();
       
    90 
       
    91 private: // From CActive
       
    92     void DoCancel();
       
    93 	void RunL();
       
    94 	TInt RunError( TInt aError );
       
    95 
       
    96 private: // data
       
    97     /// XML file
       
    98     RFile iFile;
       
    99     /// XML data.
       
   100     TBuf8<KXmlDataBlockSize> iXmlData;
       
   101     
       
   102     /**
       
   103      * XML content handler, receives callbacks as XML is parsed.
       
   104      * Own
       
   105      */
       
   106     CPdcXmlContentHandler* iContentHandler;
       
   107     
       
   108     /**
       
   109      *  XML parser
       
   110      *  Own
       
   111      */
       
   112     Xml::CParser* iXmlParser;
       
   113     
       
   114     /**
       
   115     *  XML used by framework to select the correct xml plugin engine
       
   116     *  to use.
       
   117     *  Own
       
   118     */
       
   119     Xml::CMatchData* iXmlMatchData;
       
   120     /// Ref: Caller's TRequestStatus
       
   121     TRequestStatus* iCallerStatus;
       
   122     /// Ref: Contacts store 
       
   123     MVPbkContactStore& iContactStore;
       
   124     /// Ref: File system. 
       
   125     RFs& iFs;
       
   126     /// Ref: Ids of the contacts that have been added
       
   127     CVPbkContactLinkArray& iLinkArray;
       
   128     CVPbkContactManager* iContactManager;
       
   129     };
       
   130 
       
   131 #endif //  C_PDCXMLIMPORTER_H