40 class MVPbkSingleContactOperationObserver; |
42 class MVPbkSingleContactOperationObserver; |
41 class MVPbkContactCopyObserver; |
43 class MVPbkContactCopyObserver; |
42 class CVPbkVCardEng; |
44 class CVPbkVCardEng; |
43 class CVPbkVCardImporter; |
45 class CVPbkVCardImporter; |
44 class CVPbkContactManager; |
46 class CVPbkContactManager; |
45 |
47 class MVPbkSetAttributeObserver; |
46 /** |
48 /** |
47 * An operation for Updating a contact in the store |
49 * An operation for Updating a contact in the store |
48 */ |
50 */ |
49 NONSHARABLE_CLASS(CVPbkImportToContactsMergeOperation) |
51 NONSHARABLE_CLASS(CVPbkImportToContactsMergeOperation) |
50 : public CActive, |
52 : public CActive, |
51 public MVPbkContactOperation, |
53 public MVPbkContactOperation, |
52 public MVPbkImportOperationObserver, |
54 public MVPbkImportOperationObserver, |
53 public MVPbkSingleContactOperationObserver, |
55 public MVPbkSingleContactOperationObserver, |
54 public MVPbkContactObserver |
56 public MVPbkContactObserver, |
|
57 public MVPbkSetAttributeObserver |
55 { |
58 { |
56 public: |
59 public: |
57 static CVPbkImportToContactsMergeOperation *NewL( |
60 static CVPbkImportToContactsMergeOperation *NewL( |
58 TVPbkImportCardType aType, |
61 TVPbkImportCardType aType, |
59 CVPbkVCardData& aData, |
62 CVPbkVCardData& aData, |
60 const MVPbkContactLink& aReplaceContact, |
63 const MVPbkContactLink& aReplaceContact, |
61 MVPbkContactStore& aTargetStore, |
64 MVPbkContactStore& aTargetStore, |
62 RReadStream& aSourceStream, |
65 RReadStream& aSourceStream, |
63 MVPbkSingleContactOperationObserver& aObserver ); |
66 MVPbkSingleContactOperationObserver& aObserver ); |
64 |
67 |
65 /** |
68 /** |
66 * Destructor. |
69 * Destructor. |
67 */ |
70 */ |
68 ~CVPbkImportToContactsMergeOperation(); |
71 ~CVPbkImportToContactsMergeOperation(); |
69 |
72 |
70 protected: // CActive |
73 protected: // CActive |
71 /** |
74 /** |
72 * From CActive. Called when asynchronous operation completes. |
75 * From CActive. Called when asynchronous operation completes. |
73 */ |
76 */ |
74 void RunL(); |
77 void RunL(); |
75 /** |
78 /** |
76 * From CActive. Called when RunL leaves. |
79 * From CActive. Called when RunL leaves. |
77 */ |
80 */ |
78 |
81 |
79 TInt RunError( TInt aError ); |
82 TInt RunError( TInt aError ); |
80 /** |
83 /** |
81 * From CActive. Cancels operation. |
84 * From CActive. Cancels operation. |
82 */ |
85 */ |
83 |
86 |
84 void DoCancel(); |
87 void DoCancel(); |
85 |
88 |
86 private: |
89 private: |
87 |
90 |
89 const MVPbkContactLink& aReplaceContact, |
92 const MVPbkContactLink& aReplaceContact, |
90 MVPbkSingleContactOperationObserver& aObserver, |
93 MVPbkSingleContactOperationObserver& aObserver, |
91 MVPbkContactStore& aTargetStore, |
94 MVPbkContactStore& aTargetStore, |
92 CVPbkVCardData & aData |
95 CVPbkVCardData & aData |
93 ); |
96 ); |
94 /** |
97 /** |
95 * Second phase constructor. |
98 * Second phase constructor. |
96 */ |
99 */ |
97 void ConstructL( TVPbkImportCardType aType, RReadStream& aSourceStream); |
100 void ConstructL( TVPbkImportCardType aType, RReadStream& aSourceStream); |
98 |
101 |
99 public: |
102 public: |
100 // from base class MVPbkImportOperationObserver |
103 // from base class MVPbkImportOperationObserver |
101 /** |
104 /** |
102 * From MVPbkImportOperationObserver |
105 * From MVPbkImportOperationObserver |
103 * Called when a contact import operation has Completed. |
106 * Called when a contact import operation has Completed. |
104 */ |
107 */ |
105 void ContactsImported(); |
108 void ContactsImported(); |
106 /** |
109 /** |
107 * From MVPbkImportOperationObserver |
110 * From MVPbkImportOperationObserver |
108 * Called when a contact import operation has failed. |
111 * Called when a contact import operation has failed. |
109 */ |
112 */ |
110 void ContactImportingFailed( TInt aError ); |
113 void ContactImportingFailed( TInt aError ); |
111 /** |
114 /** |
112 * From MVPbkImportOperationObserver |
115 * From MVPbkImportOperationObserver |
113 * Called when a contact import operation has Completed Fully. |
116 * Called when a contact import operation has Completed Fully. |
114 */ |
117 */ |
115 void ContactsImportingCompleted(); |
118 void ContactsImportingCompleted(); |
116 |
119 |
117 public: |
120 public: |
118 // from base class MVPbkContactOperation |
121 // from base class MVPbkContactOperation |
119 /** |
122 /** |
120 * From MVPbkContactOperation |
123 * From MVPbkContactOperation |
121 * Called when a contact operation has to be started |
124 * Called when a contact operation has to be started |
122 */ |
125 */ |
123 void StartL(); |
126 void StartL(); |
124 /** |
127 /** |
125 * From MVPbkContactOperation |
128 * From MVPbkContactOperation |
126 * Called when a contact operation has to be cancled |
129 * Called when a contact operation has to be cancled |
127 */ |
130 */ |
128 void Cancel(); |
131 void Cancel(); |
129 |
132 |
130 public: // from MVPbkSingleContactOperationObserver |
133 public: // from MVPbkSingleContactOperationObserver |
131 |
134 |
132 /** |
135 /** |
133 * From MVPbkSingleContactOperationObserver |
136 * From MVPbkSingleContactOperationObserver |
134 * Called when the contact operation is complete |
137 * Called when the contact operation is complete |
135 * Client takes Ownership in deleting returned aContact. |
138 * Client takes Ownership in deleting returned aContact. |
136 */ |
139 */ |
137 void VPbkSingleContactOperationComplete( |
140 void VPbkSingleContactOperationComplete( |
138 MVPbkContactOperationBase& aOperation, |
141 MVPbkContactOperationBase& aOperation, |
139 MVPbkStoreContact* aContact ); |
142 MVPbkStoreContact* aContact ); |
140 /** |
143 /** |
141 * From MVPbkSingleContactOperationObserver |
144 * From MVPbkSingleContactOperationObserver |
142 * Called when the contact operation fails |
145 * Called when the contact operation fails |
143 */ |
146 */ |
144 void VPbkSingleContactOperationFailed( |
147 void VPbkSingleContactOperationFailed( |
145 MVPbkContactOperationBase& aOperation, |
148 MVPbkContactOperationBase& aOperation, |
146 TInt aError ); |
149 TInt aError ); |
147 public: |
150 public: |
148 |
151 |
149 // from MVPbkContactObserver |
152 // from MVPbkContactObserver |
150 /** |
153 /** |
151 * From MVPbkContactObserver |
154 * From MVPbkContactObserver |
152 * Called when a contact operation has succesfully completed. |
155 * Called when a contact operation has succesfully completed. |
153 * Client takes Ownership in deleting returned aResult. |
156 * Client takes Ownership in deleting returned aResult. |
154 */ |
157 */ |
155 void ContactOperationCompleted(TContactOpResult aResult); |
158 void ContactOperationCompleted(TContactOpResult aResult); |
156 /** |
159 /** |
157 * From MVPbkContactObserver |
160 * From MVPbkContactObserver |
158 * Called when a contact operation has failed. |
161 * Called when a contact operation has failed. |
159 */ |
162 */ |
160 void ContactOperationFailed |
163 void ContactOperationFailed |
161 (TContactOp aOpCode, TInt aErrorCode, TBool aErrorNotified); |
164 (TContactOp aOpCode, TInt aErrorCode, TBool aErrorNotified); |
162 |
165 |
|
166 |
|
167 private: |
|
168 |
|
169 // from MVPbkSetAttributeObserver |
|
170 /** |
|
171 * From MVPbkSetAttributeObserver |
|
172 * Called when a set attribute operation has succesfully completed. |
|
173 * Client takes Ownership in deleting returned aResult. |
|
174 */ |
|
175 void AttributeOperationComplete( MVPbkContactOperationBase& aOperation ); |
|
176 /** |
|
177 * From MVPbkSetAttributeObserver |
|
178 * Called when a set attribute operation has failed. |
|
179 */ |
|
180 void AttributeOperationFailed( |
|
181 MVPbkContactOperationBase& aOperation, |
|
182 TInt aError ); |
|
183 |
163 private: // types |
184 private: // types |
164 enum TState |
185 enum TState |
165 { |
186 { |
166 EImport, |
187 EImport, |
167 ERetrieve, |
188 ERetrieve, |
168 ELock, |
189 ELock, |
|
190 EUpdateContact, |
169 EReplaceFields, |
191 EReplaceFields, |
|
192 ESetAttributes, |
170 ECommit, |
193 ECommit, |
171 EReRetrieve, //Reload contact to have valid lastmodified datetime |
194 EReRetrieve, //Reload contact to have valid lastmodified datetime |
172 EComplete |
195 EComplete |
173 }; |
196 }; |
174 |
197 |
175 private: |
198 private: |
176 void NextState( TState aNextState ); |
199 void NextState( TState aNextState ); |
177 /** |
200 /** |
178 * Retrive the contact to be updated |
201 * Retrive the contact to be updated |
179 */ |
202 */ |
180 void RetrieveContactL(); |
203 void RetrieveContactL(); |
181 /** |
204 /** |
182 * Lock the contact for editing |
205 * Lock the contact for editing |
183 */ |
206 */ |
184 void LockContactL(); |
207 void LockContactL(); |
185 /** |
208 /** |
186 * Commit the updated contact |
209 * Commit the updated contact |
187 */ |
210 */ |
188 void CommitContactL(); |
211 void CommitContactL(); |
189 /** |
212 /** |
190 * Update imported contacts |
213 * Update imported contacts |
191 */ |
214 */ |
192 void UpdateContactL(); |
215 void UpdateContactL(); |
193 /** |
216 /** |
194 * Retrieve the contact after updation |
217 * Retrieve the contact after updation |
195 */ |
218 */ |
196 void ReRetrieveContactL(); |
219 void ReRetrieveContactL(); |
197 |
220 |
198 void HandleError(TInt aError); |
221 void HandleError(TInt aError); |
199 void HandleContactReplacing(MVPbkStoreContact* aContact); |
222 void HandleContactReplacing(MVPbkStoreContact* aContact); |
200 /** |
223 /** |
201 * Replace the fields of target contact |
224 * Replace the fields of target contact |
202 */ |
225 */ |
203 void ReplaceContactL( const MVPbkStoreContact& aSrc, MVPbkStoreContact& aTarget ); |
226 void ReplaceFieldL( const MVPbkStoreContact& aSrc, MVPbkStoreContact& aTarget ); |
204 /** |
227 /** |
205 * Copy the fields of source contact to target contact |
228 * Copy the fields of source contact to target contact |
206 */ |
229 */ |
207 void CopyFieldL( const MVPbkStoreContactField& aSourceField, |
230 void CopyFieldL( const MVPbkStoreContactField& aSourceField, |
208 const MVPbkFieldType& aType, |
231 const MVPbkFieldType& aType, |
209 MVPbkStoreContact& aTargetContact ); |
232 MVPbkStoreContact& aTargetContact ); |
210 |
233 /** |
|
234 * Gets the attributes from aField |
|
235 */ |
|
236 void GetDefaultAttributsL( const MVPbkStoreContactField& aField ); |
|
237 /** |
|
238 * Return the attribute which is to be set |
|
239 */ |
|
240 TVPbkDefaultType NextAttribute(); |
|
241 /** |
|
242 * Set the attribute to the target contect field |
|
243 */ |
|
244 void SetNextL(); |
|
245 |
211 private: // data |
246 private: // data |
212 /// Own: state |
247 /// Own: state |
213 TState iState; |
248 TState iState; |
214 /// Own: the imported contacts |
249 /// Own: the imported contacts |
215 RPointerArray<MVPbkStoreContact> iImportedContacts; |
250 RPointerArray<MVPbkStoreContact> iImportedContacts; |
216 /// Own: the implementation of the import operation |
251 /// Own: the implementation of the import operation |
217 MVPbkImportOperationImpl* iOperationImpl; |
252 MVPbkImportOperationImpl* iOperationImpl; |
218 /// Ref: the target store of the operation |
253 /// Ref: the target store of the operation |
219 MVPbkContactStore& iTargetStore; |
254 MVPbkContactStore& iTargetStore; |
220 //Ref: Vcard Data |
255 /// Ref: Vcard Data |
221 CVPbkVCardData& iData; |
256 CVPbkVCardData& iData; |
222 /// Ref: contact to replace |
257 /// Ref: contact to replace |
223 const MVPbkContactLink& iReplaceContact; |
258 const MVPbkContactLink& iReplaceContact; |
224 /// Own: current contact |
259 /// Own: current contact |
225 MVPbkStoreContact* iContact; |
260 MVPbkStoreContact* iContact; |
226 /// Ref: client that waits importing |
261 /// Ref: client that waits importing |
227 MVPbkSingleContactOperationObserver& iObserver; |
262 MVPbkSingleContactOperationObserver& iObserver; |
228 /// Own: the operation for import and retrieve |
263 /// Own: the operation for import and retrieve |
229 MVPbkContactOperationBase* iVPbkOperation; |
264 MVPbkContactOperationBase* iVPbkOperation; |
230 //Own: Group Card Handler |
265 /// Own: Group Card Handler |
231 CVPbkGroupCardHandler* iGroupcardHandler; |
266 CVPbkGroupCardHandler* iGroupcardHandler; |
|
267 /// Own: the operation for set attribute |
|
268 MVPbkContactOperationBase* iSetAttributeOperation; |
|
269 /// Own: the array of one field's attributes |
|
270 CArrayFixFlat<TVPbkDefaultType>* iDefaultAttributes; |
|
271 /// The index of the current operated field |
|
272 TInt iCurrentFieldIndex; |
|
273 /// The field count of the source contact |
|
274 TInt iFieldCount; |
232 }; |
275 }; |
233 |
276 |
234 #endif |
277 #endif |