phonebookui/Phonebook2/inc/CPbk2ContactMerge.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-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:  A class for combining the data of two contacts.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPBK2CONTACTMERGE_H
       
    20 #define CPBK2CONTACTMERGE_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 
       
    25 // FORWARD DECLARATIONS
       
    26 class CVPbkContactManager;
       
    27 class MVPbkBaseContact;
       
    28 class MVPbkStoreContact;
       
    29 class MVPbkBaseContactField;
       
    30 class MVPbkContactFieldData;
       
    31 class MVPbkContactFieldTextData;
       
    32 class MVPbkContactFieldBinaryData;
       
    33 class MVPbkContactFieldDateTimeData;
       
    34 class CVPbkFieldTypeSelector;
       
    35 class MPbk2ContactNameFormatter;
       
    36 class MPbk2FieldPropertyArray;
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41  * A class for combining the data of two contacts.
       
    42  */
       
    43 class CPbk2ContactMerge : public CBase
       
    44     {
       
    45     public: // Construction and destruction
       
    46 
       
    47         /**
       
    48          * Creates a new instance of this class.
       
    49          *
       
    50          * @param aContactManager   Virtual Phonebook contact manager.
       
    51          * @param aNameFormatter    Name formatter.
       
    52          * @param aFieldProperties  Phonebook 2 field properties.
       
    53          * @return  A new instance of this class.
       
    54          */
       
    55         IMPORT_C static CPbk2ContactMerge* NewL(
       
    56                 CVPbkContactManager& aContactManager,
       
    57                 MPbk2ContactNameFormatter& aNameFormatter,
       
    58                 const MPbk2FieldPropertyArray& aFieldProperties );
       
    59 
       
    60         /**
       
    61          * Destructor.
       
    62          */
       
    63         virtual ~CPbk2ContactMerge();
       
    64 
       
    65     public: // Interface
       
    66 
       
    67         /**
       
    68          * Merges the data of two contacts.
       
    69          * Title fields of the target contact are not changed.
       
    70          *
       
    71          * @param aContactFrom  The source contact whose data need to
       
    72          *                      be merged.
       
    73          * @param aContactTo    The target contact into which the data
       
    74          *                      is copied to.
       
    75          * @return  ETrue if all the data fields from the source
       
    76          *          contact were copied to the target contact.
       
    77          *          EFalse if none or part of the fields were copied.
       
    78          */
       
    79         IMPORT_C TBool MergeDataL(
       
    80                 const MVPbkBaseContact& aContactFrom,
       
    81                 MVPbkStoreContact& aContactTo );
       
    82 
       
    83     private: // Implementation
       
    84         CPbk2ContactMerge(
       
    85                 CVPbkContactManager& aContactManager,
       
    86                 MPbk2ContactNameFormatter& aNameFormatter,
       
    87                 const MPbk2FieldPropertyArray& aFieldProperties );
       
    88         void ConstructL();
       
    89         void CopyFieldDataL(
       
    90                 const MVPbkBaseContactField& aField,
       
    91                 MVPbkStoreContact& aContactTo );
       
    92         TBool FindMatch(
       
    93                 const MVPbkBaseContactField& aField,
       
    94                 MVPbkStoreContact& aContactTo );
       
    95         TBool CompareData(
       
    96                 const MVPbkContactFieldData& aData1,
       
    97                 const MVPbkContactFieldData& aData2 );
       
    98         TBool CompareTextData(
       
    99                 const MVPbkContactFieldTextData& aData1,
       
   100                 const MVPbkContactFieldTextData& aData2 );
       
   101         TBool CompareBinaryData(
       
   102                 const MVPbkContactFieldBinaryData& aData1,
       
   103                 const MVPbkContactFieldBinaryData& aData2 );
       
   104         TBool CompareDateTimeData(
       
   105                 const MVPbkContactFieldDateTimeData& aData1,
       
   106                 const MVPbkContactFieldDateTimeData& aData2 );
       
   107 
       
   108     private: // Data
       
   109         /// Ref: Virtual Phonebook contact manager
       
   110         CVPbkContactManager& iContactManager;
       
   111         /// Ref: Name formatter
       
   112         MPbk2ContactNameFormatter& iNameFormatter;
       
   113         /// Ref: Phonebook 2 field properties
       
   114         const MPbk2FieldPropertyArray& iFieldProperties;
       
   115         /// Own: Field type selector for email fields
       
   116         CVPbkFieldTypeSelector* iEMailSelector;
       
   117         /// Own: Field type selector for number fields
       
   118         CVPbkFieldTypeSelector* iNumberSelector;
       
   119     };
       
   120 
       
   121 #endif // CPBK2CONTACTMERGE_H
       
   122 
       
   123 // End of File