phonebookengines/VirtualPhonebook/VPbkVCardEng/inc/CVPbkVCardCompactBCardImporter.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:  Virtual Phonebook VCard compact BCard importer
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CVPBKVCARDCOMPACTBCARDIMPORTER_H
       
    21 #define CVPBKVCARDCOMPACTBCARDIMPORTER_H
       
    22 
       
    23 // INCLUDES
       
    24 #include "MVPbkImportOperationImpl.h"
       
    25 #include <e32base.h>
       
    26 #include <MVPbkContactFieldCopyObserver.h>
       
    27 #include <badesca.h>
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class MVPbkStoreContact;
       
    31 class MVPbkFieldType;
       
    32 class MVPbkContactStore;
       
    33 class CVPbkVCardData;
       
    34 class MVPbkContactCopyPolicy;
       
    35 
       
    36 // CLASS DECLARATIONS
       
    37 NONSHARABLE_CLASS(CVPbkVCardCompactBCardImporter)
       
    38     :	public CActive,
       
    39         public MVPbkImportOperationImpl,
       
    40         private MVPbkContactFieldCopyObserver,
       
    41         private MVPbkContactFieldsCopyObserver
       
    42     {
       
    43     public: // Static constructors and destructor
       
    44         static CVPbkVCardCompactBCardImporter* NewL(
       
    45             RPointerArray<MVPbkStoreContact>& aImportedContacts,
       
    46             MVPbkContactStore& aTargetStore, 
       
    47             RReadStream &aSourceStream,
       
    48             CVPbkVCardData& aData );
       
    49 
       
    50         ~CVPbkVCardCompactBCardImporter();
       
    51     
       
    52     public: // From MVPbkImportOperationImpl
       
    53 
       
    54         void StartL();
       
    55         void SetObserver( MVPbkImportOperationObserver& aObserver );
       
    56         TBool IsOwncard();
       
    57     
       
    58     private: // From CActive
       
    59         void RunL();
       
    60         void DoCancel();
       
    61         TInt RunError(TInt aError);
       
    62     
       
    63     private: // From MVPbkContactFieldCopyObserver 
       
    64         void FieldAddedToContact( MVPbkContactOperationBase& aOperation );
       
    65         void FieldAddingFailed( MVPbkContactOperationBase& aOperation,
       
    66             TInt aError);
       
    67     
       
    68     private: // From MVPbkContactFieldsCopyObserver
       
    69         void FieldsCopiedToContact(
       
    70                 MVPbkContactOperationBase& aOperation );
       
    71         void FieldsCopyFailed(
       
    72                 MVPbkContactOperationBase& aOperation, 
       
    73                 TInt aError);
       
    74                 
       
    75     private: 
       
    76         void IssueRequest();
       
    77         TBool GetLineL();
       
    78         void ParseLineL();
       
    79         void ValueToBufL( const TDesC& aBuffer, TInt aResId );
       
    80         void ValueToArrayL( const TDesC& aBuffer );
       
    81         void ValueAndLabelToBufL( const TDesC& aBuffer, TInt aResId );
       
    82         void AddAddressL();
       
    83         const MVPbkFieldType* FindFieldTypeL( TInt aFieldIndex );
       
    84         void AddFieldWithValueL( 
       
    85             const MVPbkFieldType& aFieldType, const TDesC& aValue, HBufC* aLabel );
       
    86         void StartTitleCopyL();
       
    87         TInt GetLineFromStreamL( TDes& aBuf, RReadStream& aSourceStream );
       
    88         TInt GetByteFromStream( TInt8& aByte, RReadStream& aSourceStream );
       
    89         void HandleContactSwitchL();
       
    90         void CopyTitleL();
       
    91         void MoveCurrentContactToImportsL();
       
    92         void HandleError( TInt aError );
       
    93         TInt ResolveFieldTypeResIdL( const TDesC& aBuffer );
       
    94 
       
    95     private: // Construction
       
    96 
       
    97         CVPbkVCardCompactBCardImporter(
       
    98             RPointerArray<MVPbkStoreContact>& aImportedContacts,
       
    99             MVPbkContactStore& aTargetStore,
       
   100             RReadStream &aSourceStream,
       
   101             CVPbkVCardData& aData );
       
   102 
       
   103         void ConstructL();
       
   104 
       
   105     private: // Data
       
   106         /// Ref: to the clients result array
       
   107         RPointerArray<MVPbkStoreContact>& iImportedContacts;
       
   108         /// Ref: the store to use as a target for importing
       
   109         MVPbkContactStore& iTargetStore;
       
   110         /// Ref:
       
   111         CVPbkVCardData& iData;
       
   112         /// Ref: the copy policy for the target store
       
   113         MVPbkContactCopyPolicy* iCopyPolicy;
       
   114         /// Own:
       
   115         CDesCArray*         iAddressArray;
       
   116         /// Own:
       
   117         HBufC*              iLabel;
       
   118         /// Own:
       
   119         HBufC*              iValue;
       
   120         /// Own:
       
   121         HBufC*              iLine;
       
   122         /// Ref:
       
   123         RReadStream&        iSource;
       
   124         /// Own: the current destination contact
       
   125         MVPbkStoreContact*  iCurContact;
       
   126         /// Own:
       
   127         TInt                iLineCount;
       
   128         /// Own:
       
   129         TInt                iValueLength;
       
   130         /// Own:
       
   131         TBool               iEMailFetchedFlag;
       
   132         /// Own: an operation that adds an field to the contact
       
   133         MVPbkContactOperationBase* iAddToFieldOperation;
       
   134         /// Internal state of the import operation
       
   135         TInt                iState;
       
   136         /// Ref: the observer of the import
       
   137         MVPbkImportOperationObserver* iObserver;
       
   138         /// An index of target contact when title fields are copied
       
   139         /// to split contacts
       
   140         TInt iTargetContactIndex;
       
   141     };
       
   142 
       
   143 #endif // CVPBKVCARDCOMPACTBCARDIMPORTER_H
       
   144 //End of file
       
   145