20
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: Phonebook 2 merge contacts resolver.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef CPBK2MERGERESOLVER_H_
|
|
19 |
#define CPBK2MERGERESOLVER_H_
|
|
20 |
|
|
21 |
// INCLUDES
|
|
22 |
#include <e32base.h>
|
|
23 |
#include <MVPbkStoreContactField.h>
|
|
24 |
#include <TVPbkFieldVersitProperty.h>
|
|
25 |
#include <MVPbkFieldType.h>
|
|
26 |
#include <Pbk2FieldProperty.hrh>
|
|
27 |
#include <MPbk2MergeResolver.h>
|
|
28 |
#include "CPbk2MergeConflict.h"
|
|
29 |
|
|
30 |
// FORWARD DECLARATIONS
|
|
31 |
class CPbk2PresentationContact;
|
|
32 |
|
|
33 |
|
|
34 |
// CLASS DECLARATION
|
|
35 |
/**
|
|
36 |
* Phonebook 2 merge contacts resolver.
|
|
37 |
*/
|
|
38 |
class CPbk2MergeResolver : public CBase,
|
|
39 |
public MPbk2MergeResolver
|
|
40 |
{
|
|
41 |
public: // Construction and destruction
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Creates a new instance of this class.
|
|
45 |
*
|
|
46 |
* @param aFirstContact First contact to merge.
|
|
47 |
* @param aSecondContact Second contact to merge.
|
|
48 |
*
|
|
49 |
* @return A new instance of this class.
|
|
50 |
*/
|
|
51 |
static CPbk2MergeResolver* NewL(
|
|
52 |
CPbk2PresentationContact* aFirstContact,
|
|
53 |
CPbk2PresentationContact* aSecondContact );
|
|
54 |
|
|
55 |
/**
|
|
56 |
* Destructor.
|
|
57 |
*/
|
|
58 |
~CPbk2MergeResolver();
|
|
59 |
|
|
60 |
public: // Implementation
|
|
61 |
/**
|
|
62 |
* Starts merging.
|
|
63 |
*/
|
|
64 |
void MergeL();
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Counts conflicts.
|
|
68 |
*
|
|
69 |
* @return Number of conflicts.
|
|
70 |
*/
|
|
71 |
TInt CountConflicts();
|
|
72 |
|
|
73 |
/**
|
|
74 |
* Gets conflict.
|
|
75 |
*
|
|
76 |
* @param aConflict Index of conflict in array.
|
|
77 |
* @return Base class of conflict.
|
|
78 |
*/
|
|
79 |
MPbk2MergeConflict& GetConflictAt( TInt aConflict );
|
|
80 |
|
|
81 |
/**
|
|
82 |
* Counts merged.
|
|
83 |
*
|
|
84 |
* @return Number of merged.
|
|
85 |
*/
|
|
86 |
TInt CountMerged();
|
|
87 |
|
|
88 |
/**
|
|
89 |
* Gets merged.
|
|
90 |
*
|
|
91 |
* @param aMerged Index of merged in array.
|
|
92 |
* @return Base class of conflict.
|
|
93 |
*/
|
|
94 |
MVPbkStoreContactField& GetMergedAt( TInt aMerged );
|
|
95 |
|
|
96 |
private: // Construction
|
|
97 |
CPbk2MergeResolver(
|
|
98 |
CPbk2PresentationContact* aFirstContact,
|
|
99 |
CPbk2PresentationContact* aSecondContact );
|
|
100 |
|
|
101 |
private: // Declaration
|
|
102 |
enum ECompareAddress
|
|
103 |
{
|
|
104 |
ECAUndefined,
|
|
105 |
ECASame,
|
|
106 |
ECAFirstIncludesSecond,
|
|
107 |
ECASecondIncludesFirst,
|
|
108 |
ECADifferent
|
|
109 |
};
|
|
110 |
|
|
111 |
private: // Implementation
|
|
112 |
TBool EqualsValues(
|
|
113 |
const MVPbkStoreContactField& aFieldFirst,
|
|
114 |
const MVPbkStoreContactField& aFieldSecond );
|
|
115 |
ECompareAddress CompareAddresses( TPbk2FieldGroupId aGroupId );
|
|
116 |
CPbk2MergeResolver::ECompareAddress DoCompareAddresses(
|
|
117 |
TInt aCountEquals,
|
|
118 |
TInt aCountAddressFieldsFirst,
|
|
119 |
TInt aCountAddressFieldsSecond );
|
|
120 |
TBool AreFieldsTypeSame(
|
|
121 |
const MVPbkStoreContactField& aFieldFirst,
|
|
122 |
const MVPbkStoreContactField& aFieldSecond );
|
|
123 |
TBool AreAddressesSubTypeSame(
|
|
124 |
const MVPbkStoreContactField& aFieldFirst,
|
|
125 |
const MVPbkStoreContactField& aFieldSecond );
|
|
126 |
TBool AddressField( const MVPbkStoreContactField& aField );
|
|
127 |
void CopyAddressToMergedL(
|
|
128 |
const CPbk2PresentationContact& aContact,
|
|
129 |
TPbk2FieldGroupId aAddressGroup );
|
|
130 |
TPbk2FieldMultiplicity FieldMultiplicity( const MVPbkStoreContactField& aField );
|
|
131 |
void AddConflictL(
|
|
132 |
const MVPbkStoreContactField& aFieldFirst,
|
|
133 |
const MVPbkStoreContactField& aFieldSecond );
|
|
134 |
HBufC* SyncDisplayFieldLC(
|
|
135 |
const MVPbkStoreContactField& aField );
|
|
136 |
HBufC* LocaliseSyncDisplayFieldLC( const TDesC& aContent );
|
|
137 |
void AddAddressConflictL( TPbk2FieldGroupId aGroupId );
|
|
138 |
TInt FindConflictByFieldL( const MVPbkStoreContactField& aField );
|
|
139 |
void PrintFieldL(const MVPbkStoreContactField & aField);
|
|
140 |
void MergeAddressesL();
|
|
141 |
void CompleteMergeArrL(
|
|
142 |
RArray<TInt>& aDuplicatesInFirst,
|
|
143 |
RArray<TInt>& aDuplicatesInSecond );
|
|
144 |
TBool IsTopContactField(
|
|
145 |
const MVPbkStoreContactField& aField );
|
|
146 |
TInt CompareTopConactFields(
|
|
147 |
const MVPbkStoreContactField& aFieldFirst,
|
|
148 |
const MVPbkStoreContactField& aFieldSecond );
|
|
149 |
|
|
150 |
private: // Data
|
|
151 |
// Own: Array merged contact fields
|
|
152 |
RPointerArray<MVPbkStoreContactField> iMerged;
|
|
153 |
|
|
154 |
// Own: Array conflicted contact fields
|
|
155 |
RPointerArray<MPbk2MergeConflict> iConflicts;
|
|
156 |
|
|
157 |
// Own: First contact
|
|
158 |
CPbk2PresentationContact* iFirstContact;
|
|
159 |
|
|
160 |
// Own: Second contact
|
|
161 |
CPbk2PresentationContact* iSecondContact;
|
|
162 |
};
|
|
163 |
|
|
164 |
#endif /* CPBK2MERGERESOLVER_H_ */
|