48 #include <CPbk2StoreSpecificFieldPropertyArray.h> |
48 #include <CPbk2StoreSpecificFieldPropertyArray.h> |
49 #include <CPbk2FieldPropertyArray.h> |
49 #include <CPbk2FieldPropertyArray.h> |
50 #include <CPbk2SortOrderManager.h> |
50 #include <CPbk2SortOrderManager.h> |
51 #include <Pbk2ContactNameFormatterFactory.h> |
51 #include <Pbk2ContactNameFormatterFactory.h> |
52 #include <MPbk2ContactNameFormatter.h> |
52 #include <MPbk2ContactNameFormatter.h> |
53 #include <cpbk2applicationservices.h> |
53 #include <CPbk2ApplicationServices.h> |
54 #include <cpbk2storemanager.h> |
54 #include <CPbk2StoreManager.h> |
55 #include <CPbk2StoreConfiguration.h> |
55 #include <CPbk2StoreConfiguration.h> |
56 #include <CPbk2ContactEditorDlg.h> |
56 #include <CPbk2ContactEditorDlg.h> |
57 #include <MVPbkBaseContactField.h> |
57 #include <MVPbkBaseContactField.h> |
58 // internal |
58 // internal |
59 #include "ccappmycardplugin.h" |
59 #include "ccappmycardplugin.h" |
103 } |
103 } |
104 Release(iAppServices); |
104 Release(iAppServices); |
105 |
105 |
106 delete iCloseCallBack; |
106 delete iCloseCallBack; |
107 delete iCreateCallBack; |
107 delete iCreateCallBack; |
|
108 delete iDlgCloseCallBack; |
108 |
109 |
109 CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCard::~CCCAppMyCard()")); |
110 CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCard::~CCCAppMyCard()")); |
110 } |
111 } |
111 |
112 |
112 // --------------------------------------------------------------------------- |
113 // --------------------------------------------------------------------------- |
136 |
137 |
137 iCloseCallBack = new(ELeave) CAsyncCallBack( |
138 iCloseCallBack = new(ELeave) CAsyncCallBack( |
138 TCallBack( CloseCcaL, this ), CActive::EPriorityIdle ); |
139 TCallBack( CloseCcaL, this ), CActive::EPriorityIdle ); |
139 iCreateCallBack = new(ELeave) CAsyncCallBack( |
140 iCreateCallBack = new(ELeave) CAsyncCallBack( |
140 TCallBack( CreateMyCardContact, this ), CActive::EPriorityHigh ); |
141 TCallBack( CreateMyCardContact, this ), CActive::EPriorityHigh ); |
|
142 iDlgCloseCallBack = new(ELeave) CAsyncCallBack( |
|
143 TCallBack( ExitDlgL, this ), CActive::EPriorityHigh ); |
141 } |
144 } |
142 |
145 |
143 // --------------------------------------------------------------------------- |
146 // --------------------------------------------------------------------------- |
144 // CCCAppMyCard::PresentationContactL |
147 // CCCAppMyCard::PresentationContactL |
145 // --------------------------------------------------------------------------- |
148 // --------------------------------------------------------------------------- |
283 // |
286 // |
284 void CCCAppMyCard::LoadContact() |
287 void CCCAppMyCard::LoadContact() |
285 { |
288 { |
286 CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCard::LoadContact()")); |
289 CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCard::LoadContact()")); |
287 |
290 |
288 delete iFetchOperation; |
291 if( !iFetchOperation && iMyCard ) |
289 iFetchOperation = NULL; |
292 { |
290 TRAPD( err, iFetchOperation = |
293 TRAPD( err, iFetchOperation = |
291 iVPbkContactManager->RetrieveContactL( *iMyCard, *this ) ); |
294 iVPbkContactManager->RetrieveContactL( *iMyCard, *this ) ); |
292 if( err ) |
295 if( err ) |
293 { |
296 { |
294 // Cannot load own contact from VPbk |
297 // Cannot load own contact from VPbk |
295 CCA_DP(KMyCardLogFile, |
298 CCA_DP(KMyCardLogFile, |
296 CCA_L(" CCCAppMyCard::LoadContact load error = %d"), err ); |
299 CCA_L(" CCCAppMyCard::LoadContact load error = %d"), err ); |
297 |
300 |
298 // TODO: How is this handled. show error on UI? |
301 // TODO: How is this handled. show error on UI? |
|
302 } |
299 } |
303 } |
300 |
304 |
301 CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCard::LoadContact()")); |
305 CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCard::LoadContact()")); |
302 } |
306 } |
303 |
307 |
457 // pass current store contact, ownership is taken |
461 // pass current store contact, ownership is taken |
458 contact = iMyCardContact; |
462 contact = iMyCardContact; |
459 iMyCardContact = NULL; |
463 iMyCardContact = NULL; |
460 } |
464 } |
461 // params for the editor |
465 // params for the editor |
462 TPbk2ContactEditorParams params( aFlags, field, NULL, NULL ); |
466 TPbk2ContactEditorParams params( aFlags, field, NULL, this ); |
463 |
467 |
464 // pass custom title text |
468 // pass custom title text |
465 HBufC* title = CCoeEnv::Static()->AllocReadResourceLC( R_QTN_MYCARD_TITLE ); |
469 if ( contact ) |
466 // ownership of the title is passed |
470 { |
467 CPbk2ContactEditorDlg* dlg = |
471 HBufC* title = CCoeEnv::Static()->AllocReadResourceLC( |
468 CPbk2ContactEditorDlg::NewL( params, contact, *this, iAppServices, title, |
472 R_QTN_CCA_MC_TITLE_EDIT_MY_CARD ); |
469 R_SOCIAL_PHONEBOOK_FIELD_PROPERTIES ); |
473 // ownership of the title is passed |
470 CleanupStack::Pop( title ); |
474 CPbk2ContactEditorDlg* dlg = CPbk2ContactEditorDlg::NewL( params, contact, |
471 dlg->ExecuteLD(); |
475 *this, iAppServices, title, R_SOCIAL_PHONEBOOK_FIELD_PROPERTIES ); |
|
476 CleanupStack::Pop( title ); |
|
477 iEditorEliminator = dlg; |
|
478 dlg->ResetWhenDestroyed( &iEditorEliminator ); |
|
479 dlg->ExecuteLD(); |
|
480 } |
472 |
481 |
473 // if field was created, destroy it |
482 // if field was created, destroy it |
474 if( field ) |
483 if( field ) |
475 { |
484 { |
476 CleanupStack::PopAndDestroy( field ); |
485 CleanupStack::PopAndDestroy( field ); |
496 // CCCAppMyCard::ContactEditingComplete |
505 // CCCAppMyCard::ContactEditingComplete |
497 // --------------------------------------------------------------------------- |
506 // --------------------------------------------------------------------------- |
498 // |
507 // |
499 void CCCAppMyCard::ContactEditingComplete( MVPbkStoreContact* aEditedContact ) |
508 void CCCAppMyCard::ContactEditingComplete( MVPbkStoreContact* aEditedContact ) |
500 { |
509 { |
501 // My Card modifications are handled in HandleStoreEventL. Editor complete |
510 // create link of mycard |
502 // event is only interesting if we don't yet have mycard at all. Meaning |
511 MVPbkContactLink* link = NULL; |
503 // it was just created. |
512 TRAPD( err, |
504 |
513 link = aEditedContact->CreateLinkLC(); |
505 if( !iMyCard ) |
514 CleanupStack::Pop(); ); //link |
506 { |
515 |
507 TRAPD( err, iMyCard = aEditedContact->CreateLinkLC(); |
516 if( !err ) |
508 CleanupStack::Pop(); ); //link |
517 { |
509 if( err ) |
518 delete iMyCard; |
510 { |
519 iMyCard = link; |
511 // TODO handle error |
520 |
512 } |
521 // reload mycard to get rid of the empty template fields |
513 else |
522 LoadContact(); |
514 { |
523 } |
515 // reload contact to get rid of the template(empty) fields. |
524 |
516 LoadContact(); |
|
517 } |
|
518 } |
|
519 delete aEditedContact; // ignore given contact |
525 delete aEditedContact; // ignore given contact |
520 } |
526 } |
521 |
527 |
522 // --------------------------------------------------------------------------- |
528 // --------------------------------------------------------------------------- |
523 // CCCAppMyCard::ContactEditingDeletedContact |
529 // CCCAppMyCard::ContactEditingDeletedContact |
537 // |
543 // |
538 void CCCAppMyCard::ContactEditingAborted() |
544 void CCCAppMyCard::ContactEditingAborted() |
539 { |
545 { |
540 // Editing was aborted -> move to pb2 |
546 // Editing was aborted -> move to pb2 |
541 } |
547 } |
|
548 |
|
549 // --------------------------------------------------------------------------- |
|
550 // CCCAppMyCard::OkToExitL |
|
551 // --------------------------------------------------------------------------- |
|
552 // |
|
553 TBool CCCAppMyCard::OkToExitL( TInt /*aCommandId*/ ) |
|
554 { |
|
555 // Handle exit via callback. Calls CCCAppMyCard::ExitDlg. |
|
556 // Dialog's exit is handled this way to make the address selector's |
|
557 // exit work as it should. |
|
558 iDlgCloseCallBack->Call(); |
|
559 return EFalse; |
|
560 } |
542 |
561 |
543 // --------------------------------------------------------------------------- |
562 // --------------------------------------------------------------------------- |
544 // CCCAppMyCard::CloseCcaL |
563 // CCCAppMyCard::CloseCcaL |
545 // --------------------------------------------------------------------------- |
564 // --------------------------------------------------------------------------- |
546 // |
565 // |
550 // if fields are empty, and user pushes "Done" or "Exit" this function is |
569 // if fields are empty, and user pushes "Done" or "Exit" this function is |
551 // called. Card is not created -> goto pbk2 |
570 // called. Card is not created -> goto pbk2 |
552 self->DoCloseCCaL(); |
571 self->DoCloseCCaL(); |
553 return KErrNone; |
572 return KErrNone; |
554 } |
573 } |
|
574 |
|
575 // --------------------------------------------------------------------------- |
|
576 // CCCAppMyCard::CloseCcaL |
|
577 // --------------------------------------------------------------------------- |
|
578 // |
|
579 TInt CCCAppMyCard::ExitDlgL( TAny* aPtr ) |
|
580 { |
|
581 CCCAppMyCard* self = static_cast<CCCAppMyCard*>( aPtr ); |
|
582 if( self->iEditorEliminator ) |
|
583 { |
|
584 self->iEditorEliminator->RequestExitL( EAknCmdExit ); |
|
585 } |
|
586 return KErrNone; |
|
587 } |
555 |
588 |
556 // --------------------------------------------------------------------------- |
589 // --------------------------------------------------------------------------- |
557 // CCCAppMyCard::DoCloseCCaL |
590 // CCCAppMyCard::DoCloseCCaL |
558 // --------------------------------------------------------------------------- |
591 // --------------------------------------------------------------------------- |
559 // |
592 // |
640 { |
673 { |
641 CCA_DP(KMyCardLogFile, |
674 CCA_DP(KMyCardLogFile, |
642 CCA_L("->CCCAppMyCard::VPbkSingleContactOperationFailed error = %d"), |
675 CCA_L("->CCCAppMyCard::VPbkSingleContactOperationFailed error = %d"), |
643 aError ); |
676 aError ); |
644 |
677 |
|
678 delete iFetchOperation; |
|
679 iFetchOperation = NULL; |
|
680 |
645 delete iOperation; |
681 delete iOperation; |
646 iOperation = NULL; |
682 iOperation = NULL; |
647 |
683 |
648 // TODO: How to handle loading error? |
684 // TODO: How to handle loading error? |
649 |
685 |