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