116 } |
116 } |
117 if( iUiControl ) |
117 if( iUiControl ) |
118 { |
118 { |
119 iUiControl->RegisterCommand( NULL ); |
119 iUiControl->RegisterCommand( NULL ); |
120 } |
120 } |
121 |
121 |
|
122 delete iContact; |
122 delete iRetrieveContactOperation; |
123 delete iRetrieveContactOperation; |
123 delete iRetrieveGroupOperation; |
124 delete iRetrieveGroupOperation; |
124 delete iContactGroup; |
125 delete iContactGroup; |
125 delete iEntriesToAdd; |
126 delete iEntriesToAdd; |
126 delete iEntriesToRelocate; |
127 delete iEntriesToRelocate; |
134 // -------------------------------------------------------------------------- |
135 // -------------------------------------------------------------------------- |
135 // |
136 // |
136 inline void CPguAddMembersCmd::ConstructL() |
137 inline void CPguAddMembersCmd::ConstructL() |
137 { |
138 { |
138 iState = ERetrievingContact; |
139 iState = ERetrievingContact; |
|
140 iContactsCounter = 0; |
139 } |
141 } |
140 // -------------------------------------------------------------------------- |
142 // -------------------------------------------------------------------------- |
141 // CPguAddMembersCmd::NewLC |
143 // CPguAddMembersCmd::NewLC |
142 // -------------------------------------------------------------------------- |
144 // -------------------------------------------------------------------------- |
143 // |
145 // |
248 // -------------------------------------------------------------------------- |
260 // -------------------------------------------------------------------------- |
249 // CPguAddMembersCmd::RunError |
261 // CPguAddMembersCmd::RunError |
250 // -------------------------------------------------------------------------- |
262 // -------------------------------------------------------------------------- |
251 // |
263 // |
252 TInt CPguAddMembersCmd::RunError( TInt aError ) |
264 TInt CPguAddMembersCmd::RunError( TInt aError ) |
253 { |
265 { |
254 if ( iState == EAddingContactsToGroup && aError == KErrInUse && |
266 FinishCommand( aError ); |
255 iEntriesToAdd && iEntriesToAdd->Count() > KOneContact ) |
|
256 { |
|
257 // Incase there was more than just one contact being added, ignore |
|
258 // the KErrInUse error and continue with the remaining contacts |
|
259 iState = EAddingContactsToGroup; |
|
260 IssueRequest(); |
|
261 } |
|
262 else if ( aError != KErrNone ) |
|
263 { |
|
264 FinishCommand( aError ); |
|
265 } |
|
266 |
|
267 return KErrNone; |
267 return KErrNone; |
268 } |
268 } |
269 |
269 |
270 // -------------------------------------------------------------------------- |
270 // -------------------------------------------------------------------------- |
271 // CPguAddMembersCmd::VPbkSingleContactOperationComplete |
271 // CPguAddMembersCmd::VPbkSingleContactOperationComplete |
286 |
286 |
287 __ASSERT_DEBUG( iContactGroup, Panic( EPanicContactNotGroup ) ); |
287 __ASSERT_DEBUG( iContactGroup, Panic( EPanicContactNotGroup ) ); |
288 |
288 |
289 TRAP( error, iContactGroup->LockL( *this ) ); |
289 TRAP( error, iContactGroup->LockL( *this ) ); |
290 } |
290 } |
291 else if ( &aOperation == iRetrieveContactOperation ) |
291 else if ( &aOperation == iRetrieveContactOperation && iState == ERelocateContacts ) |
292 { |
292 { |
293 TRAP( error, RelocateContactL( aContact ) ); |
293 TRAP( error, RelocateContactL( aContact ) ); |
|
294 } |
|
295 else if ( &aOperation == iRetrieveContactOperation && iState == ECheckContacts ) |
|
296 { |
|
297 iContact = aContact; |
|
298 // try to lock to check if contact is being modified by another application |
|
299 TRAP( error, iContact->LockL( *this ) ); |
294 } |
300 } |
295 |
301 |
296 if ( error != KErrNone ) |
302 if ( error != KErrNone ) |
297 { |
303 { |
298 FinishCommand( error ); |
304 FinishCommand( error ); |
313 // CPguAddMembersCmd::ContactOperationCompleted |
319 // CPguAddMembersCmd::ContactOperationCompleted |
314 // -------------------------------------------------------------------------- |
320 // -------------------------------------------------------------------------- |
315 // |
321 // |
316 void CPguAddMembersCmd::ContactOperationCompleted( TContactOpResult aResult ) |
322 void CPguAddMembersCmd::ContactOperationCompleted( TContactOpResult aResult ) |
317 { |
323 { |
318 if ( aResult.iOpCode == MVPbkContactObserver::EContactLock ) |
324 if ( aResult.iOpCode == MVPbkContactObserver::EContactLock && |
|
325 iState == ERetrievingContact ) |
319 { |
326 { |
320 iState = EHandleContactLockedEvent; |
327 iState = EHandleContactLockedEvent; |
321 IssueRequest(); |
328 IssueRequest(); |
322 } |
329 } |
|
330 else if ( aResult.iOpCode == MVPbkContactObserver::EContactLock && |
|
331 iState == ECheckContacts ) |
|
332 { |
|
333 iContactsCounter++; |
|
334 // delete to release the lock of contact |
|
335 delete iContact; |
|
336 iContact = NULL; |
|
337 IssueRequest(); |
|
338 } |
323 else if ( aResult.iOpCode == MVPbkContactObserver::EContactCommit ) |
339 else if ( aResult.iOpCode == MVPbkContactObserver::EContactCommit ) |
324 { |
340 { |
325 FinishCommand( KErrNone ); |
341 FinishCommand( KErrNone ); |
326 } |
342 } |
327 } |
343 } |
328 |
344 |
329 // -------------------------------------------------------------------------- |
345 // -------------------------------------------------------------------------- |
330 // CPguAddMembersCmd::ContactOperationFailed |
346 // CPguAddMembersCmd::ContactOperationFailed |
331 // -------------------------------------------------------------------------- |
347 // -------------------------------------------------------------------------- |
332 // |
348 // |
|
349 |
333 void CPguAddMembersCmd::ContactOperationFailed |
350 void CPguAddMembersCmd::ContactOperationFailed |
334 ( TContactOp /*aOpCode*/, TInt aErrorCode, TBool aErrorNotified ) |
351 ( TContactOp aOpCode, TInt aErrorCode, TBool aErrorNotified ) |
335 { |
352 { |
336 if ( !aErrorNotified ) |
353 if ( aOpCode == MVPbkContactObserver::EContactLock && |
|
354 iState == ECheckContacts ) |
|
355 { |
|
356 delete iContact; |
|
357 iContact = NULL; |
|
358 FinishCommand( aErrorCode ); |
|
359 } |
|
360 else if ( !aErrorNotified ) |
337 { |
361 { |
338 FinishCommand( aErrorCode ); |
362 FinishCommand( aErrorCode ); |
339 } |
363 } |
340 else |
364 else |
341 { |
365 { |
355 |
379 |
356 // -------------------------------------------------------------------------- |
380 // -------------------------------------------------------------------------- |
357 // CPguAddMembersCmd::ContactViewUnavailable |
381 // CPguAddMembersCmd::ContactViewUnavailable |
358 // -------------------------------------------------------------------------- |
382 // -------------------------------------------------------------------------- |
359 // |
383 // |
|
384 |
360 void CPguAddMembersCmd::ContactViewUnavailable |
385 void CPguAddMembersCmd::ContactViewUnavailable |
361 ( MVPbkContactViewBase& /*aView*/ ) |
386 ( MVPbkContactViewBase& /*aView*/ ) |
362 { |
387 { |
363 // Do nothing |
388 // Do nothing |
364 } |
389 } |
679 // We must first relocate the contact |
704 // We must first relocate the contact |
680 iEntriesToRelocate->AppendL( contactLink ); |
705 iEntriesToRelocate->AppendL( contactLink ); |
681 } |
706 } |
682 } |
707 } |
683 |
708 |
684 if ( iEntriesToRelocate->Count() > KOneContact ) |
709 iState = ECheckContacts; |
685 { |
710 IssueRequest(); |
686 RelocateContactsL(); |
|
687 } |
|
688 else if ( iEntriesToRelocate->Count() == KOneContact ) |
|
689 { |
|
690 // We'll have to retrieve the one single contact and |
|
691 // use single contact relocator |
|
692 delete iRetrieveContactOperation; |
|
693 iRetrieveContactOperation = NULL; |
|
694 iRetrieveContactOperation = |
|
695 Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
696 ContactManager().RetrieveContactL( |
|
697 iEntriesToRelocate->At( KFirstElement ), *this ); |
|
698 } |
|
699 else |
|
700 { |
|
701 // Contacts will be added to group. First show |
|
702 // the progress note. |
|
703 iState = EShowingProgressNote; |
|
704 IssueRequest(); |
|
705 } |
|
706 } |
711 } |
707 } |
712 } |
708 |
713 |
709 // -------------------------------------------------------------------------- |
714 // -------------------------------------------------------------------------- |
710 // CPguAddMembersCmd::RelocateContactL |
715 // CPguAddMembersCmd::RelocateContactL |
943 iUiControl->RestoreControlStateL( viewState ); |
948 iUiControl->RestoreControlStateL( viewState ); |
944 CleanupStack::PopAndDestroy(); // viewState |
949 CleanupStack::PopAndDestroy(); // viewState |
945 } |
950 } |
946 } |
951 } |
947 |
952 |
|
953 void CPguAddMembersCmd::BeginRelocationL() |
|
954 { |
|
955 if ( iEntriesToRelocate->Count() > KOneContact ) |
|
956 { |
|
957 RelocateContactsL(); |
|
958 } |
|
959 else if ( iEntriesToRelocate->Count() == KOneContact ) |
|
960 { |
|
961 // We'll have to retrieve the one single contact and |
|
962 // use single contact relocator |
|
963 delete iRetrieveContactOperation; |
|
964 iRetrieveContactOperation = NULL; |
|
965 iRetrieveContactOperation = |
|
966 Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
967 ContactManager().RetrieveContactL( |
|
968 iEntriesToRelocate->At( KFirstElement ), *this ); |
|
969 } |
|
970 else |
|
971 { |
|
972 // Contacts will be added to group. First show |
|
973 // the progress note. |
|
974 iState = EShowingProgressNote; |
|
975 IssueRequest(); |
|
976 } |
|
977 } |
|
978 |
|
979 void CPguAddMembersCmd::CheckContactsL() |
|
980 { |
|
981 if ( iContactsCounter < iEntriesToAdd->Count() ) |
|
982 { |
|
983 delete iRetrieveContactOperation; |
|
984 iRetrieveContactOperation = NULL; |
|
985 iRetrieveContactOperation = Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
986 ContactManager().RetrieveContactL( iEntriesToAdd->At( iContactsCounter ), *this ); |
|
987 } |
|
988 else |
|
989 { |
|
990 iState = ERelocateContacts; |
|
991 IssueRequest(); |
|
992 } |
|
993 } |
948 // End of File |
994 // End of File |