|
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: Phonebook 2 server app contact data assign phase. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CPbk2MultiAssignDataPhase.h" |
|
20 |
|
21 // Phonebook 2 |
|
22 #include "MPbk2ServicePhaseObserver.h" |
|
23 #include "CPbk2ServerAppAppUi.h" |
|
24 #include "Pbk2ServerApp.hrh" |
|
25 #include "MPbk2ContactAssigner.h" |
|
26 #include "Pbk2ContactAssignerFactory.h" |
|
27 #include "MPbk2SelectFieldProperty.h" |
|
28 #include "TPbk2AssignNoteService.h" |
|
29 #include "Pbk2AssignValidateField.h" |
|
30 #include "CPbk2KeyEventDealer.h" |
|
31 #include <CPbk2StoreConfiguration.h> |
|
32 #include <TPbk2DestructionIndicator.h> |
|
33 #include <CPbk2FieldPropertyArray.h> |
|
34 #include <CPbk2PresentationContact.h> |
|
35 #include <MPbk2ApplicationServices.h> |
|
36 #include <Pbk2ServerApp.rsg> |
|
37 |
|
38 // Virtual Phonebook |
|
39 #include <MVPbkContactLink.h> |
|
40 #include <MVPbkStoreContact.h> |
|
41 #include <CVPbkContactLinkArray.h> |
|
42 #include <MVPbkContactOperationBase.h> |
|
43 #include <CVPbkContactManager.h> |
|
44 #include <MVPbkContactStoreProperties.h> |
|
45 #include <VPbkContactStoreUris.h> |
|
46 #include <CVPbkContactStoreUriArray.h> |
|
47 |
|
48 // System includes |
|
49 #include <AiwContactAssignDataTypes.h> |
|
50 |
|
51 using namespace AiwContactAssign; |
|
52 |
|
53 /// Unnamed namespace for local definitions |
|
54 namespace { |
|
55 |
|
56 const TInt KFirstElement = 0; |
|
57 const TInt KGranularity = 4; |
|
58 |
|
59 /** |
|
60 * Copies a link array to another. |
|
61 * |
|
62 * @param aSourceLinkArray Link array which is copied |
|
63 * @param aTargetLinkArray Links are copied to this |
|
64 */ |
|
65 void CopyContactLinksL( const MVPbkContactLinkArray& aSourceLinkArray, |
|
66 CVPbkContactLinkArray& aTargetLinkArray ) |
|
67 { |
|
68 const TInt count = aSourceLinkArray.Count(); |
|
69 for ( TInt i(0); i < count; ++i ) |
|
70 { |
|
71 const MVPbkContactLink& contactLink = aSourceLinkArray.At(i); |
|
72 aTargetLinkArray.AppendL( contactLink.CloneLC() ); |
|
73 CleanupStack::Pop(); // link |
|
74 } |
|
75 } |
|
76 |
|
77 } /// namespace |
|
78 |
|
79 // -------------------------------------------------------------------------- |
|
80 // CPbk2MultiAssignDataPhase::CPbk2MultiAssignDataPhase |
|
81 // -------------------------------------------------------------------------- |
|
82 // |
|
83 CPbk2MultiAssignDataPhase::CPbk2MultiAssignDataPhase |
|
84 ( MPbk2ServicePhaseObserver& aObserver, |
|
85 MPbk2SelectFieldProperty* aSelectedFieldProperty, |
|
86 HBufC* aDataBuffer, TInt aMimeType, TUint aNoteFlags ) : |
|
87 iObserver( aObserver ), |
|
88 iSelectedFieldProperty( aSelectedFieldProperty ), |
|
89 iDataBuffer( aDataBuffer ), |
|
90 iMimeType( aMimeType ), |
|
91 iNoteFlags( aNoteFlags ) |
|
92 { |
|
93 } |
|
94 |
|
95 // -------------------------------------------------------------------------- |
|
96 // CPbk2MultiAssignDataPhase::~CPbk2MultiAssignDataPhase |
|
97 // -------------------------------------------------------------------------- |
|
98 // |
|
99 CPbk2MultiAssignDataPhase::~CPbk2MultiAssignDataPhase() |
|
100 { |
|
101 delete iResults; |
|
102 delete iContactDataAssigner; |
|
103 delete iContactLinks; |
|
104 delete iRetrieveOperation; |
|
105 delete iCommitOperation; |
|
106 delete iStoreContact; |
|
107 delete iDealer; |
|
108 if ( iStoreContacts ) |
|
109 { |
|
110 iStoreContacts->ResetAndDestroy(); |
|
111 } |
|
112 delete iStoreContacts; |
|
113 |
|
114 if ( iDestroyedPtr ) |
|
115 { |
|
116 *iDestroyedPtr = ETrue; |
|
117 } |
|
118 } |
|
119 |
|
120 // -------------------------------------------------------------------------- |
|
121 // CPbk2MultiAssignDataPhase::ConstructL |
|
122 // -------------------------------------------------------------------------- |
|
123 // |
|
124 inline void CPbk2MultiAssignDataPhase::ConstructL |
|
125 ( MVPbkContactLinkArray* aContactLinks ) |
|
126 { |
|
127 iEikenv = CEikonEnv::Static(); |
|
128 |
|
129 iContactLinks = CVPbkContactLinkArray::NewL(); |
|
130 // Take a own copy of supplied contact links |
|
131 CopyContactLinksL( *aContactLinks, *iContactLinks ); |
|
132 |
|
133 iDealer = CPbk2KeyEventDealer::NewL( *this ); |
|
134 } |
|
135 |
|
136 // -------------------------------------------------------------------------- |
|
137 // CPbk2MultiAssignDataPhase::NewL |
|
138 // -------------------------------------------------------------------------- |
|
139 // |
|
140 CPbk2MultiAssignDataPhase* CPbk2MultiAssignDataPhase::NewL |
|
141 ( MPbk2ServicePhaseObserver& aObserver, |
|
142 MVPbkContactLinkArray* aContactLinks, |
|
143 MPbk2SelectFieldProperty* aSelectedFieldProperty, |
|
144 HBufC* aDataBuffer, TInt aMimeType, TUint aNoteFlags ) |
|
145 { |
|
146 CPbk2MultiAssignDataPhase* self = |
|
147 new ( ELeave ) CPbk2MultiAssignDataPhase |
|
148 ( aObserver, aSelectedFieldProperty, |
|
149 aDataBuffer, aMimeType, aNoteFlags ); |
|
150 CleanupStack::PushL( self ); |
|
151 self->ConstructL( aContactLinks ); |
|
152 CleanupStack::Pop( self ); |
|
153 return self; |
|
154 } |
|
155 |
|
156 // -------------------------------------------------------------------------- |
|
157 // CPbk2MultiAssignDataPhase::LaunchServicePhaseL |
|
158 // -------------------------------------------------------------------------- |
|
159 // |
|
160 void CPbk2MultiAssignDataPhase::LaunchServicePhaseL() |
|
161 { |
|
162 ContinueL(); |
|
163 } |
|
164 |
|
165 // -------------------------------------------------------------------------- |
|
166 // CPbk2MultiAssignDataPhase::CancelServicePhase |
|
167 // -------------------------------------------------------------------------- |
|
168 // |
|
169 void CPbk2MultiAssignDataPhase::CancelServicePhase() |
|
170 { |
|
171 iOperationCancelled = ETrue; |
|
172 iObserver.PhaseCanceled( *this ); |
|
173 } |
|
174 |
|
175 // -------------------------------------------------------------------------- |
|
176 // CPbk2MultiAssignDataPhase::RequestCancelL |
|
177 // -------------------------------------------------------------------------- |
|
178 // |
|
179 void CPbk2MultiAssignDataPhase::RequestCancelL( TInt aExitCommandId ) |
|
180 { |
|
181 // Withdraw our key event agent so that it does not react to |
|
182 // app shutter's escape key event simulation |
|
183 delete iDealer; |
|
184 iDealer = NULL; |
|
185 |
|
186 iOperationCancelled = ETrue; |
|
187 |
|
188 if ( aExitCommandId == EEikBidCancel ) |
|
189 { |
|
190 iObserver.PhaseAborted( *this ); |
|
191 } |
|
192 else |
|
193 { |
|
194 iObserver.PhaseCanceled( *this ); |
|
195 } |
|
196 } |
|
197 |
|
198 // -------------------------------------------------------------------------- |
|
199 // CPbk2MultiAssignDataPhase::AcceptDelayed |
|
200 // -------------------------------------------------------------------------- |
|
201 // |
|
202 void CPbk2MultiAssignDataPhase::AcceptDelayedL |
|
203 ( const TDesC8& /*aContactLinkBuffer*/ ) |
|
204 { |
|
205 // Nothing to do |
|
206 } |
|
207 |
|
208 // -------------------------------------------------------------------------- |
|
209 // CPbk2MultiAssignDataPhase::DenyDelayed |
|
210 // -------------------------------------------------------------------------- |
|
211 // |
|
212 void CPbk2MultiAssignDataPhase::DenyDelayedL |
|
213 ( const TDesC8& /*aContactLinkBuffer*/ ) |
|
214 { |
|
215 // Nothing to do |
|
216 } |
|
217 |
|
218 // -------------------------------------------------------------------------- |
|
219 // CPbk2MultiAssignDataPhase::Results |
|
220 // -------------------------------------------------------------------------- |
|
221 // |
|
222 MVPbkContactLinkArray* CPbk2MultiAssignDataPhase::Results() const |
|
223 { |
|
224 return iResults; |
|
225 } |
|
226 |
|
227 // -------------------------------------------------------------------------- |
|
228 // CPbk2MultiAssignDataPhase::ExtraResultData |
|
229 // -------------------------------------------------------------------------- |
|
230 // |
|
231 TInt CPbk2MultiAssignDataPhase::ExtraResultData() const |
|
232 { |
|
233 return KErrNotSupported; |
|
234 } |
|
235 |
|
236 // -------------------------------------------------------------------------- |
|
237 // CPbk2MultiAssignDataPhase::TakeStoreContact |
|
238 // -------------------------------------------------------------------------- |
|
239 // |
|
240 MVPbkStoreContact* CPbk2MultiAssignDataPhase::TakeStoreContact() |
|
241 { |
|
242 // Not supported |
|
243 return NULL; |
|
244 } |
|
245 |
|
246 // -------------------------------------------------------------------------- |
|
247 // CPbk2MultiAssignDataPhase::FieldContent |
|
248 // -------------------------------------------------------------------------- |
|
249 // |
|
250 HBufC* CPbk2MultiAssignDataPhase::FieldContent() const |
|
251 { |
|
252 return NULL; |
|
253 } |
|
254 |
|
255 // -------------------------------------------------------------------------- |
|
256 // CPbk2MultiAssignDataPhase::AssignComplete |
|
257 // -------------------------------------------------------------------------- |
|
258 // |
|
259 void CPbk2MultiAssignDataPhase::AssignComplete |
|
260 ( MPbk2ContactAssigner& /*aAssigner*/, TInt /*aIndex*/ ) |
|
261 { |
|
262 MVPbkStoreContact* storeContact = iStoreContact; |
|
263 iStoreContact = NULL; |
|
264 TRAPD( err, AppendResultAndContinueL( storeContact ) ); |
|
265 if ( err != KErrNone ) |
|
266 { |
|
267 iObserver.PhaseError( *this, err ); |
|
268 } |
|
269 } |
|
270 |
|
271 // -------------------------------------------------------------------------- |
|
272 // CPbk2MultiAssignDataPhase::AssignFailed |
|
273 // -------------------------------------------------------------------------- |
|
274 // |
|
275 void CPbk2MultiAssignDataPhase::AssignFailed |
|
276 ( MPbk2ContactAssigner& /*aAssigner*/, TInt aErrorCode ) |
|
277 { |
|
278 iObserver.PhaseError( *this, aErrorCode ); |
|
279 } |
|
280 |
|
281 // -------------------------------------------------------------------------- |
|
282 // CPbk2MultiAssignDataPhase::ContactOperationCompleted |
|
283 // -------------------------------------------------------------------------- |
|
284 // |
|
285 void CPbk2MultiAssignDataPhase::ContactOperationCompleted |
|
286 ( TContactOpResult aResult ) |
|
287 { |
|
288 if ( aResult.iOpCode == EContactLock ) |
|
289 { |
|
290 TRAPD( err, AssignDataL() ); |
|
291 |
|
292 if ( err != KErrNone && err != KErrDied ) |
|
293 { |
|
294 iObserver.PhaseError( *this, err ); |
|
295 } |
|
296 } |
|
297 } |
|
298 |
|
299 // -------------------------------------------------------------------------- |
|
300 // CPbk2MultiAssignDataPhase::ContactOperationFailed |
|
301 // -------------------------------------------------------------------------- |
|
302 // |
|
303 void CPbk2MultiAssignDataPhase::ContactOperationFailed |
|
304 ( TContactOp /*aOpCode*/, TInt aErrorCode, TBool /*aErrorNotified*/ ) |
|
305 { |
|
306 // If the contact operation failed, the iStoreContact is expected to be deleted, |
|
307 // otherwise it will lead to memory leak. |
|
308 if ( iStoreContact ) |
|
309 { |
|
310 delete iStoreContact; |
|
311 iStoreContact = NULL; |
|
312 } |
|
313 |
|
314 // if iContactsProcessed > 0, the note (how many contacts had been processed) needs to be shown. |
|
315 if ( (iContactLinks->Count() > 0) || (iContactsProcessed > 0) ) |
|
316 { |
|
317 ContinueL(); |
|
318 } |
|
319 else |
|
320 { |
|
321 iObserver.PhaseError( *this, aErrorCode ); |
|
322 } |
|
323 |
|
324 } |
|
325 |
|
326 // -------------------------------------------------------------------------- |
|
327 // CPbk2MultiAssignDataPhase::VPbkSingleContactOperationComplete |
|
328 // -------------------------------------------------------------------------- |
|
329 // |
|
330 void CPbk2MultiAssignDataPhase::VPbkSingleContactOperationComplete |
|
331 ( MVPbkContactOperationBase& /*aOperation*/, |
|
332 MVPbkStoreContact* aContact ) |
|
333 { |
|
334 iStoreContact = aContact; |
|
335 TRAPD( err, iStoreContact->LockL( *this ) ); |
|
336 if ( err != KErrNone ) |
|
337 { |
|
338 iObserver.PhaseError( *this, err ); |
|
339 } |
|
340 } |
|
341 |
|
342 // -------------------------------------------------------------------------- |
|
343 // CPbk2MultiAssignDataPhase::VPbkSingleContactOperationFailed |
|
344 // -------------------------------------------------------------------------- |
|
345 // |
|
346 void CPbk2MultiAssignDataPhase::VPbkSingleContactOperationFailed |
|
347 ( MVPbkContactOperationBase& /*aOperation*/, TInt aError ) |
|
348 { |
|
349 iObserver.PhaseError( *this, aError ); |
|
350 } |
|
351 |
|
352 // -------------------------------------------------------------------------- |
|
353 // CPbk2MultiAssignDataPhase::StepComplete |
|
354 // -------------------------------------------------------------------------- |
|
355 // |
|
356 void CPbk2MultiAssignDataPhase::StepComplete |
|
357 ( MVPbkContactOperationBase& /*aOperation*/, TInt /*aStepSize*/ ) |
|
358 { |
|
359 // Do nothing |
|
360 } |
|
361 |
|
362 // -------------------------------------------------------------------------- |
|
363 // CPbk2MultiAssignDataPhase::StepFailed |
|
364 // -------------------------------------------------------------------------- |
|
365 // |
|
366 TBool CPbk2MultiAssignDataPhase::StepFailed |
|
367 ( MVPbkContactOperationBase& /*aOperation*/, TInt /*aStepSize*/, |
|
368 TInt aError ) |
|
369 { |
|
370 iObserver.PhaseError( *this, aError ); |
|
371 |
|
372 // Do not continue |
|
373 return EFalse; |
|
374 } |
|
375 |
|
376 // -------------------------------------------------------------------------- |
|
377 // CPbk2MultiAssignDataPhase::OperationComplete |
|
378 // -------------------------------------------------------------------------- |
|
379 // |
|
380 void CPbk2MultiAssignDataPhase::OperationComplete |
|
381 ( MVPbkContactOperationBase& /*aOperation*/ ) |
|
382 { |
|
383 // Commit done, we can finish now |
|
384 Finalize(); |
|
385 } |
|
386 |
|
387 // -------------------------------------------------------------------------- |
|
388 // CPbk2MultiAssignDataPhase::Pbk2ProcessKeyEventL |
|
389 // -------------------------------------------------------------------------- |
|
390 // |
|
391 TBool CPbk2MultiAssignDataPhase::Pbk2ProcessKeyEventL |
|
392 ( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
393 { |
|
394 TBool ret = EFalse; |
|
395 |
|
396 if ( aType == EEventKey && aKeyEvent.iCode == EKeyEscape ) |
|
397 { |
|
398 iObserver.PhaseOkToExit( *this, EEikBidCancel ); |
|
399 ret = ETrue; |
|
400 } |
|
401 |
|
402 return ret; |
|
403 } |
|
404 |
|
405 // -------------------------------------------------------------------------- |
|
406 // CPbk2MultiAssignDataPhase::AssignDataL |
|
407 // -------------------------------------------------------------------------- |
|
408 // |
|
409 void CPbk2MultiAssignDataPhase::AssignDataL() |
|
410 { |
|
411 const MVPbkFieldType* fieldType = NULL; |
|
412 if ( iSelectedFieldProperty ) |
|
413 { |
|
414 fieldType = iSelectedFieldProperty->SelectedFieldType(); |
|
415 } |
|
416 |
|
417 if ( fieldType ) |
|
418 { |
|
419 MVPbkStoreContactField* contactField = NULL; |
|
420 if ( SelectContactFieldL( contactField ) ) |
|
421 { |
|
422 CPbk2ServerAppAppUi& appUi = static_cast<CPbk2ServerAppAppUi&> |
|
423 ( *iEikenv->EikAppUi() ); |
|
424 |
|
425 delete iContactDataAssigner; |
|
426 iContactDataAssigner = NULL; |
|
427 iContactDataAssigner = |
|
428 Pbk2ContactAssignerFactory::CreateContactDataAssignerL |
|
429 ( *this, iMimeType, fieldType, |
|
430 appUi.ApplicationServices().ContactManager(), |
|
431 appUi.ApplicationServices().FieldProperties() ); |
|
432 |
|
433 iContactDataAssigner->AssignDataL |
|
434 ( *iStoreContact, contactField, fieldType, iDataBuffer ); |
|
435 } |
|
436 else |
|
437 { |
|
438 ContinueL(); |
|
439 } |
|
440 } |
|
441 } |
|
442 |
|
443 // -------------------------------------------------------------------------- |
|
444 // CPbk2MultiAssignDataPhase::SelectContactFieldL |
|
445 // -------------------------------------------------------------------------- |
|
446 // |
|
447 TBool CPbk2MultiAssignDataPhase::SelectContactFieldL |
|
448 ( MVPbkStoreContactField*& aField ) |
|
449 { |
|
450 TBool ret = ETrue; |
|
451 |
|
452 TBool thisDestroyed = EFalse; |
|
453 iDestroyedPtr = &thisDestroyed; |
|
454 TPbk2DestructionIndicator indicator( &thisDestroyed, iDestroyedPtr ); |
|
455 |
|
456 CPbk2ServerAppAppUi& appUi = static_cast<CPbk2ServerAppAppUi&> |
|
457 ( *iEikenv->EikAppUi() ); |
|
458 |
|
459 CPbk2PresentationContact* contact = |
|
460 CPbk2PresentationContact::NewL( *iStoreContact, |
|
461 appUi.ApplicationServices().FieldProperties() ); |
|
462 CleanupStack::PushL( contact ); |
|
463 |
|
464 // Check is the field type already used up in the contact |
|
465 TInt fieldIndex = KErrNotSupported; |
|
466 TInt result = |
|
467 Pbk2AssignValidateField::ValidateFieldTypeUsageInContactL |
|
468 ( *contact, *iSelectedFieldProperty->SelectedFieldType(), |
|
469 appUi.ApplicationServices().ContactManager().FsSession(), |
|
470 fieldIndex ); |
|
471 |
|
472 switch( result ) |
|
473 { |
|
474 case KErrAlreadyExists: |
|
475 { |
|
476 // Contact already has the one and only suitable contact |
|
477 // field filled up, show replace detail query |
|
478 TPbk2AssignNoteService noteService; |
|
479 TInt queryResult = noteService.ShowReplaceDetailQueryL |
|
480 ( appUi.ApplicationServices().NameFormatter(), |
|
481 *iStoreContact ); |
|
482 if ( !queryResult ) |
|
483 { |
|
484 ret = EFalse; |
|
485 } |
|
486 else if ( !thisDestroyed ) |
|
487 { |
|
488 // Set contact field to existing field so it gets replaced |
|
489 aField = &iStoreContact->Fields().FieldAt( fieldIndex ); |
|
490 } |
|
491 break; |
|
492 } |
|
493 case KErrPathNotFound: |
|
494 { |
|
495 // Set contact field to existing field so it gets replaced |
|
496 aField = &iStoreContact->Fields().FieldAt( fieldIndex ); |
|
497 break; |
|
498 } |
|
499 case KErrNotFound: // FALLTHROUGH |
|
500 case KErrNone: |
|
501 { |
|
502 // Contact does not have the field type used, or does have |
|
503 // it used but supports more fields of that type. |
|
504 // Return value stays at ETrue. |
|
505 break; |
|
506 } |
|
507 default: |
|
508 { |
|
509 // If result was any other error code |
|
510 if ( result < KErrNone ) |
|
511 { |
|
512 TPbk2AssignNoteService noteService; |
|
513 noteService.ShowCanNotAddDetailNoteL |
|
514 ( appUi.ApplicationServices().NameFormatter(), |
|
515 *iStoreContact ); |
|
516 ret = EFalse; |
|
517 } |
|
518 break; |
|
519 } |
|
520 }; |
|
521 |
|
522 CleanupStack::PopAndDestroy( contact ); |
|
523 |
|
524 if ( thisDestroyed || iOperationCancelled ) |
|
525 { |
|
526 // The calling code excepts us to leave with KErrDied if |
|
527 // this was destroyed |
|
528 User::Leave( KErrDied ); |
|
529 } |
|
530 |
|
531 return ret; |
|
532 } |
|
533 |
|
534 // -------------------------------------------------------------------------- |
|
535 // CPbk2MultiAssignDataPhase::AppendResultL |
|
536 // -------------------------------------------------------------------------- |
|
537 // |
|
538 void CPbk2MultiAssignDataPhase::AppendResultL |
|
539 ( MVPbkStoreContact* aStoreContact ) |
|
540 { |
|
541 if ( aStoreContact ) |
|
542 { |
|
543 CleanupDeletePushL( aStoreContact ); |
|
544 |
|
545 // Add the contact link to the result array |
|
546 MVPbkContactLink* link = aStoreContact->CreateLinkLC(); |
|
547 if ( link ) |
|
548 { |
|
549 if ( !iResults ) |
|
550 { |
|
551 iResults = CVPbkContactLinkArray::NewL(); |
|
552 } |
|
553 |
|
554 CleanupStack::Pop(); // aStoreContact->CreateLinkLC() |
|
555 |
|
556 iResults->AppendL( link ); |
|
557 } |
|
558 |
|
559 if ( !iStoreContacts ) |
|
560 { |
|
561 iStoreContacts = new ( ELeave ) |
|
562 CArrayPtrFlat<MVPbkStoreContact>( KGranularity ); |
|
563 } |
|
564 |
|
565 // Add contact to the array of store contacts |
|
566 // to be commited later |
|
567 CleanupStack::Pop(); // aStoreContact |
|
568 iStoreContacts->AppendL( aStoreContact ); // takes ownership |
|
569 ++iContactsProcessed; |
|
570 } |
|
571 } |
|
572 |
|
573 // -------------------------------------------------------------------------- |
|
574 // CPbk2MultiAssignDataPhase::DisplayNotesL |
|
575 // -------------------------------------------------------------------------- |
|
576 // |
|
577 void CPbk2MultiAssignDataPhase::DisplayNotesL() |
|
578 { |
|
579 CPbk2ServerAppAppUi& appUi = static_cast<CPbk2ServerAppAppUi&> |
|
580 ( *iEikenv->EikAppUi() ); |
|
581 CPbk2StorePropertyArray& array = |
|
582 appUi.ApplicationServices().StoreProperties(); |
|
583 |
|
584 TPbk2AssignNoteService noteService; |
|
585 noteService.ShowDetailAddedNoteL( iContactsProcessed ); |
|
586 |
|
587 TVPbkContactStoreUriPtr store |
|
588 ( VPbkContactStoreUris::DefaultCntDbUri() ); |
|
589 if ( iNoteFlags & KPbk2NoteFlagOneContactRelocated ) |
|
590 { |
|
591 noteService.ShowInformationNoteL |
|
592 ( R_QTN_PHOB_NOTE_CONTACT_HIDDEN, store, array ); |
|
593 } |
|
594 else if ( iNoteFlags & KPbk2NoteFlagSeveralContactsRelocated ) |
|
595 { |
|
596 noteService.ShowInformationNoteL |
|
597 ( R_QTN_PHOB_NOTE_CONTACTS_HIDDEN, store, array ); |
|
598 } |
|
599 } |
|
600 |
|
601 // -------------------------------------------------------------------------- |
|
602 // CPbk2MultiAssignDataPhase::AppendResultAndContinueL |
|
603 // -------------------------------------------------------------------------- |
|
604 // |
|
605 void CPbk2MultiAssignDataPhase::AppendResultAndContinueL |
|
606 ( MVPbkStoreContact* aContact ) |
|
607 { |
|
608 AppendResultL( aContact ); |
|
609 ContinueL(); |
|
610 } |
|
611 |
|
612 // -------------------------------------------------------------------------- |
|
613 // CPbk2MultiAssignDataPhase::RetrieveContactL |
|
614 // -------------------------------------------------------------------------- |
|
615 // |
|
616 void CPbk2MultiAssignDataPhase::RetrieveContactL() |
|
617 { |
|
618 CPbk2ServerAppAppUi& appUi = static_cast<CPbk2ServerAppAppUi&> |
|
619 ( *iEikenv->EikAppUi() ); |
|
620 |
|
621 // Retrieve one contact at a time |
|
622 delete iRetrieveOperation; |
|
623 iRetrieveOperation = NULL; |
|
624 iRetrieveOperation = appUi.ApplicationServices().ContactManager(). |
|
625 RetrieveContactL( iContactLinks->At( KFirstElement ), *this ); |
|
626 iContactLinks->Delete( KFirstElement ); |
|
627 } |
|
628 // -------------------------------------------------------------------------- |
|
629 // CPbk2MultiAssignDataPhase::CommitContactsL |
|
630 // -------------------------------------------------------------------------- |
|
631 // |
|
632 void CPbk2MultiAssignDataPhase::CommitContactsL() |
|
633 { |
|
634 CPbk2ServerAppAppUi& appUi = static_cast<CPbk2ServerAppAppUi&> |
|
635 ( *iEikenv->EikAppUi() ); |
|
636 |
|
637 // All contacts have been processed, commit changes |
|
638 delete iCommitOperation; |
|
639 iCommitOperation = NULL; |
|
640 iCommitOperation = appUi.ApplicationServices().ContactManager(). |
|
641 CommitContactsL( iStoreContacts->Array(), *this ); |
|
642 } |
|
643 |
|
644 // -------------------------------------------------------------------------- |
|
645 // CPbk2MultiAssignDataPhase::ContinueL |
|
646 // -------------------------------------------------------------------------- |
|
647 // |
|
648 void CPbk2MultiAssignDataPhase::ContinueL() |
|
649 { |
|
650 if ( iContactLinks->Count() > 0 ) |
|
651 { |
|
652 RetrieveContactL(); |
|
653 } |
|
654 else if ( iStoreContacts && iStoreContacts->Count() > 0 ) |
|
655 { |
|
656 CommitContactsL(); |
|
657 } |
|
658 else |
|
659 { |
|
660 Finalize(); |
|
661 } |
|
662 } |
|
663 |
|
664 // -------------------------------------------------------------------------- |
|
665 // CPbk2MultiAssignDataPhase::Finalize |
|
666 // -------------------------------------------------------------------------- |
|
667 // |
|
668 void CPbk2MultiAssignDataPhase::Finalize() |
|
669 { |
|
670 // Safe to ignore the error, it concerns only showing notes |
|
671 TRAP_IGNORE( DisplayNotesL(); ); |
|
672 |
|
673 iObserver.NextPhase( *this ); |
|
674 } |
|
675 |
|
676 // End of File |