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 command.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef CPBK2MERGECONTACTSCMD_H
|
|
19 |
#define CPBK2MERGECONTACTSCMD_H
|
|
20 |
|
|
21 |
// INCLUDES
|
|
22 |
#include <e32base.h>
|
|
23 |
#include <MPbk2Command.h>
|
|
24 |
#include <MPbk2FetchDlgObserver.h>
|
|
25 |
#include <MVPbkContactViewObserver.h>
|
|
26 |
#include <MVPbkSingleContactOperationObserver.h>
|
|
27 |
#include <MVPbkContactSelector.h>
|
|
28 |
#include <MVPbkBatchOperationObserver.h>
|
|
29 |
#include <MPbk2ExitCallback.h>
|
|
30 |
#include <MPbk2ProcessDecorator.h>
|
|
31 |
#include "CPbk2MergeResolver.h"
|
|
32 |
#include <f32file.h>
|
|
33 |
#include <MVPbkContactObserver.h>
|
|
34 |
|
|
35 |
// FORWARD DECLARATIONS
|
|
36 |
class MPbk2ContactUiControl;
|
|
37 |
class MVPbkContactOperationBase;
|
|
38 |
class CVPbkContactManager;
|
|
39 |
class MPbk2DialogEliminator;
|
|
40 |
class CVPbkContactStoreUriArray;
|
|
41 |
class CPbk2MergeResolver;
|
|
42 |
class CPbk2ApplicationServices;
|
|
43 |
class CAknNavigationDecorator;
|
|
44 |
class CVPbkContactLinkArray;
|
|
45 |
class MVPbkStoreContactField;
|
|
46 |
|
|
47 |
// CLASS DECLARATION
|
|
48 |
/**
|
|
49 |
* Phonebook 2 merge contacts command.
|
|
50 |
*/
|
|
51 |
class CPbk2MergeContactsCmd : public CActive,
|
|
52 |
public MPbk2Command,
|
|
53 |
private MPbk2FetchDlgObserver,
|
|
54 |
private MVPbkContactSelector,
|
|
55 |
private MVPbkContactViewObserver,
|
|
56 |
private MVPbkSingleContactOperationObserver,
|
|
57 |
private MVPbkBatchOperationObserver,
|
|
58 |
private MPbk2ExitCallback,
|
|
59 |
private MPbk2ProcessDecoratorObserver,
|
|
60 |
private MVPbkContactObserver
|
|
61 |
{
|
|
62 |
public:
|
|
63 |
// Construction and destruction
|
|
64 |
|
|
65 |
/**
|
|
66 |
* Creates a new instance of this class.
|
|
67 |
*
|
|
68 |
* @param aUiControl The UI control.
|
|
69 |
*
|
|
70 |
* @return A new instance of this class.
|
|
71 |
*/
|
|
72 |
static CPbk2MergeContactsCmd* NewL(MPbk2ContactUiControl& aUiControl);
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Destructor.
|
|
76 |
*/
|
|
77 |
~CPbk2MergeContactsCmd();
|
|
78 |
|
|
79 |
private: // From MVPbkContactSelector
|
|
80 |
TBool IsContactIncluded(
|
|
81 |
const MVPbkBaseContact& aContact );
|
|
82 |
|
|
83 |
private: // MPbk2ExitCallback
|
|
84 |
TBool OkToExitL(TInt aCommandId);
|
|
85 |
|
|
86 |
private: //From MPbk2Command
|
|
87 |
void ExecuteLD();
|
|
88 |
void ResetUiControl(MPbk2ContactUiControl& aUiControl);
|
|
89 |
void AddObserver(MPbk2CommandObserver& aObserver);
|
|
90 |
|
|
91 |
private: // From MVPbkContactViewObserver
|
|
92 |
void ContactViewReady(MVPbkContactViewBase& aView);
|
|
93 |
void ContactViewUnavailable(MVPbkContactViewBase& aView);
|
|
94 |
void ContactAddedToView(MVPbkContactViewBase& aView, TInt aIndex,
|
|
95 |
const MVPbkContactLink& aContactLink);
|
|
96 |
void ContactRemovedFromView(MVPbkContactViewBase& aView, TInt aIndex,
|
|
97 |
const MVPbkContactLink& aContactLink);
|
|
98 |
void ContactViewError(MVPbkContactViewBase& aView, TInt aError,
|
|
99 |
TBool aErrorNotified);
|
|
100 |
|
|
101 |
private: // From MVPbkSingleContactOperationObserver
|
|
102 |
void VPbkSingleContactOperationComplete(
|
|
103 |
MVPbkContactOperationBase& aOperation,
|
|
104 |
MVPbkStoreContact* aContact );
|
|
105 |
void VPbkSingleContactOperationFailed(
|
|
106 |
MVPbkContactOperationBase& aOperation, TInt aError );
|
|
107 |
|
|
108 |
private: //Construction
|
|
109 |
CPbk2MergeContactsCmd(MPbk2ContactUiControl& aUiControl);
|
|
110 |
void ConstructL();
|
|
111 |
|
|
112 |
private: //From CActive
|
|
113 |
void RunL();
|
|
114 |
TInt RunError(TInt aError);
|
|
115 |
void DoCancel();
|
|
116 |
|
|
117 |
private: // From MPbk2FetchDlgObserver
|
|
118 |
MPbk2FetchDlgObserver::TPbk2FetchAcceptSelection AcceptFetchSelectionL(
|
|
119 |
TInt aNumMarkedEntries, MVPbkContactLink& aLastSelection);
|
|
120 |
void FetchCompletedL(MVPbkContactLinkArray* aMarkedEntries);
|
|
121 |
void FetchCanceled();
|
|
122 |
void FetchAborted();
|
|
123 |
TBool FetchOkToExit();
|
|
124 |
|
|
125 |
private: // From MVPbkBatchOperationObserver
|
|
126 |
void StepComplete(
|
|
127 |
MVPbkContactOperationBase& aOperation,
|
|
128 |
TInt aStepSize );
|
|
129 |
TBool StepFailed(
|
|
130 |
MVPbkContactOperationBase& aOperation,
|
|
131 |
TInt aStepSize,
|
|
132 |
TInt aError );
|
|
133 |
void OperationComplete(
|
|
134 |
MVPbkContactOperationBase& aOperation );
|
|
135 |
|
|
136 |
private: // From MVPbkContactObserver
|
|
137 |
void ContactOperationCompleted( TContactOpResult aResult );
|
|
138 |
void ContactOperationFailed
|
|
139 |
( TContactOp aOpCode, TInt aErrorCode, TBool aErrorNotified );
|
|
140 |
private: // From MPbk2ProcessDecoratorObserver
|
|
141 |
void ProcessDismissed( TInt aCancelCode );
|
|
142 |
|
|
143 |
private: // Implementation
|
|
144 |
enum TPhase
|
|
145 |
{
|
|
146 |
EPhaseNone,
|
|
147 |
EPhaseGetSelection,
|
|
148 |
EPhaseGetStoreContacts,
|
|
149 |
EPhaseMerge,
|
|
150 |
EPhaseResolveConflicts,
|
|
151 |
EPhaseResolvePhotoConflict,
|
|
152 |
EPhaseCreateMergedContact,
|
|
153 |
EPhaseGetGroups,
|
|
154 |
EPhaseAddGroups,
|
|
155 |
EPhaseFinish
|
|
156 |
};
|
|
157 |
|
|
158 |
void GetContactsFromUiFetchL();
|
|
159 |
void Finish(TInt aReason);
|
|
160 |
void StartNext(TPhase aPhase);
|
|
161 |
void StartNext();
|
|
162 |
void CleanAfterFetching();
|
|
163 |
TBool IsFromReadOnlyStore(
|
|
164 |
const MVPbkContactLink& aContactLink ) const;
|
|
165 |
void RetrieveContact( const MVPbkContactLink& aContactLink );
|
|
166 |
void NotifyObservers();
|
|
167 |
void SetTitlePaneL( TBool aCustom );
|
|
168 |
void CheckPhotoConflictL();
|
|
169 |
void ResolvePhotoConflictL();
|
|
170 |
void ResolveAllPhotoConflicts(
|
|
171 |
EPbk2ConflictedNumber aConflictResolutionNumber );
|
|
172 |
void AddFieldToMergedContactL( MVPbkStoreContactField& field );
|
|
173 |
HBufC* ContactAsStringL( MVPbkStoreContact* aStoreContact );
|
|
174 |
void ShowContactsMergedNoteL();
|
|
175 |
void GetStoreContacts();
|
|
176 |
void ResolveConflictsL();
|
|
177 |
void FinalizeMergeL();
|
|
178 |
void DeleteSourceContactsL();
|
|
179 |
void DeleteMergedContact();
|
|
180 |
void DeleteMergedContactL();
|
|
181 |
void GetGroupsL();
|
|
182 |
void AutomaticMergeL();
|
|
183 |
void AddGroupsL();
|
|
184 |
|
|
185 |
private: // Data
|
|
186 |
|
|
187 |
// Own: CPbk2MergeContactsCmd phase
|
|
188 |
TPhase iNextPhase;
|
|
189 |
|
|
190 |
/// Ref
|
|
191 |
MPbk2CommandObserver* iCommandObserver;
|
|
192 |
|
|
193 |
/// Ref
|
|
194 |
MPbk2ContactUiControl *iUiControl;
|
|
195 |
|
|
196 |
/// Not own: contact manager
|
|
197 |
CVPbkContactManager* iContactManager;
|
|
198 |
|
|
199 |
/// Own: all contacts view sans read-only stores
|
|
200 |
// Not constructed if current store configuration doesn't include
|
|
201 |
// read-only stores
|
|
202 |
MVPbkContactViewBase* iAllContactsView;
|
|
203 |
|
|
204 |
/// Not own: Used to getting view notifications
|
|
205 |
MVPbkContactViewBase* iObservedView;
|
|
206 |
|
|
207 |
/// Own: reference to the fetch dlg, to insure is deleted
|
|
208 |
MPbk2DialogEliminator* iFetchDlgEliminator;
|
|
209 |
|
|
210 |
/// Own: Store uris used for the fetch dlg
|
|
211 |
CVPbkContactStoreUriArray* iStoreUris;
|
|
212 |
|
|
213 |
//Own: Fitst contact for merging
|
|
214 |
MVPbkContactLink* iContactFirst;
|
|
215 |
|
|
216 |
//Own: Second contact for merging
|
|
217 |
MVPbkContactLink* iContactSecond;
|
|
218 |
|
|
219 |
//Own: Merged contact
|
|
220 |
MVPbkContactLink* iMergedContactLink;
|
|
221 |
|
|
222 |
/// Own: First store contact
|
|
223 |
MVPbkStoreContact* iStoreContactFirst;
|
|
224 |
|
|
225 |
/// Own: Second store contact
|
|
226 |
MVPbkStoreContact* iStoreContactSecond;
|
|
227 |
|
|
228 |
/// Own: Merged store contact
|
|
229 |
MVPbkStoreContact* iMergedContact;
|
|
230 |
|
|
231 |
// Own: Merge resolver
|
|
232 |
CPbk2MergeResolver* iMergeResolver;
|
|
233 |
|
|
234 |
/// Own: Retrieve operation
|
|
235 |
MVPbkContactOperationBase* iRetrieveOperation;
|
|
236 |
|
|
237 |
/// Own: Delete operation
|
|
238 |
MVPbkContactOperationBase* iDeleteOperation;
|
|
239 |
|
|
240 |
/// Own: Commit operation
|
|
241 |
MVPbkContactOperationBase* iCommitOperation;
|
|
242 |
|
|
243 |
/// Own: Delete merged contact operation
|
|
244 |
MVPbkContactOperationBase* iDeleteMergedOperation;
|
|
245 |
|
|
246 |
/// Own: Results
|
|
247 |
CVPbkContactLinkArray* iContactsToDelete;
|
|
248 |
|
|
249 |
/// Own: Results
|
|
250 |
CArrayPtrFlat<MVPbkStoreContact>* iContactToCommit;
|
|
251 |
|
|
252 |
/// Own: Application Services pointer
|
|
253 |
CPbk2ApplicationServices* iAppServices;
|
|
254 |
|
|
255 |
/// Own: Image field data from first contact
|
|
256 |
TPtrC8 iDataFirst;
|
|
257 |
|
|
258 |
/// Own: Image field data from second contact
|
|
259 |
TPtrC8 iDataSecond;
|
|
260 |
|
|
261 |
/// Own: Index of photo conflict
|
|
262 |
// KErrNotFound if conflit does not exist
|
|
263 |
TInt iPhotoConflictIndex;
|
|
264 |
|
|
265 |
/// Own: Count of image type conflicts
|
|
266 |
TInt iImageTypeConflictsCount;
|
|
267 |
|
|
268 |
/// Own: All groups for merged contact
|
|
269 |
CArrayPtrFlat<MVPbkStoreContact>* iGroupsToAdd;
|
|
270 |
|
|
271 |
/// Own: Groups links array of first contact
|
|
272 |
CVPbkContactLinkArray* iGroupLinksFirst;
|
|
273 |
|
|
274 |
/// Own: Groups links array of second contact
|
|
275 |
CVPbkContactLinkArray* iGroupLinksSecond;
|
|
276 |
|
|
277 |
/// Own: Waiting note
|
|
278 |
MPbk2ProcessDecorator* iWaitDecorator;
|
|
279 |
|
|
280 |
/// Own: string for ending note
|
|
281 |
HBufC* iFirstContactString;
|
|
282 |
|
|
283 |
/// Own: string for ending note
|
|
284 |
HBufC* iSecondContactString;
|
|
285 |
|
|
286 |
/// Own: string for ending note
|
|
287 |
HBufC* iMergedContactString;
|
|
288 |
|
|
289 |
/// Own: Timer used to delay contact's deletion after new contact creation
|
|
290 |
/// it ensures that all filtered views are updated before deleting contacts
|
|
291 |
RTimer iTimer;
|
|
292 |
};
|
|
293 |
|
|
294 |
#endif // CPBK2MERGECONTACTSCMD_H
|
|
295 |
// End of File
|