phonebookui/Phonebook2/UIControls/src/CPbk2ContactEditorDlgImpl.cpp
branchRCL_3
changeset 74 6b5524b4f673
parent 68 9da50d567e3c
child 85 38bb213f60ba
equal deleted inserted replaced
68:9da50d567e3c 74:6b5524b4f673
    68 #include "Pbk2FieldProperty.hrh"
    68 #include "Pbk2FieldProperty.hrh"
    69 #include "Pbk2IconId.hrh"
    69 #include "Pbk2IconId.hrh"
    70 #include <Pbk2UID.h>
    70 #include <Pbk2UID.h>
    71 #include <pbk2mapcommands.hrh>
    71 #include <pbk2mapcommands.hrh>
    72 #include <MPbk2StartupMonitor.h>
    72 #include <MPbk2StartupMonitor.h>
       
    73 #include <featmgr.h>
    73 
    74 
    74 // Virtual Phonebook
    75 // Virtual Phonebook
    75 #include <CVPbkContactManager.h>
    76 #include <CVPbkContactManager.h>
    76 #include <MVPbkStoreContact.h>
    77 #include <MVPbkStoreContact.h>
    77 #include <MVPbkContactStore.h>
    78 #include <MVPbkContactStore.h>
    94 #include <aknnotewrappers.h>
    95 #include <aknnotewrappers.h>
    95 #include <hlplch.h>
    96 #include <hlplch.h>
    96 #include <aknnavide.h>
    97 #include <aknnavide.h>
    97 #include <akninputblock.h>
    98 #include <akninputblock.h>
    98 #include <charconv.h>
    99 #include <charconv.h>
       
   100 #include <aknpriv.hrh>
    99 
   101 
   100 /// Unnamed namespace for local definitions
   102 /// Unnamed namespace for local definitions
   101 namespace {
   103 namespace {
   102 
   104 
   103 const TInt KEditorNameFormatFlags = MPbk2ContactNameFormatter::EUseSeparator;
   105 const TInt KEditorNameFormatFlags = MPbk2ContactNameFormatter::EUseSeparator;
   173         iContactObserver( aContactObserver ),
   175         iContactObserver( aContactObserver ),
   174         iRelocator( aRelocator ),
   176         iRelocator( aRelocator ),
   175         iEndKeyWasPressed( EFalse ),
   177         iEndKeyWasPressed( EFalse ),
   176         iAddressViewStandalone( EFalse ),
   178         iAddressViewStandalone( EFalse ),
   177         iAppServices( aAppServices ),
   179         iAppServices( aAppServices ),
   178         iTitleText( aTitleText )
   180         iTitleText( aTitleText ),
       
   181         iExitApp( EFalse ),
       
   182         iIsInputPaneOpen( EFalse )
   179     {
   183     {
   180     // Exit is approved by default
   184     // Exit is approved by default
   181     iExitRecord.Set( EExitApproved );
   185     iExitRecord.Set( EExitApproved );
   182     }
   186     }
   183 
   187 
   199     if ( iSelfPtr )
   203     if ( iSelfPtr )
   200         {
   204         {
   201         *iSelfPtr = NULL;
   205         *iSelfPtr = NULL;
   202         }
   206         }
   203     // Make the variable in CloseDialog() to ETrue.
   207     // Make the variable in CloseDialog() to ETrue.
   204     if ( iDestroyedPtr )
   208     if ( iDestroyedPtrForCloseDlg )
   205         {
   209         {
   206         *iDestroyedPtr = ETrue;
   210         *iDestroyedPtrForCloseDlg = ETrue;
       
   211         }
       
   212     
       
   213     // Make the variable in AddItemToContactL() to ETrue.
       
   214     if ( iDestroyedPtrForAddItem )
       
   215         {
       
   216         *iDestroyedPtrForAddItem = ETrue;
   207         }
   217         }
   208     
   218     
   209     if( iAppServices )
   219     if( iAppServices )
   210         {
   220         {
   211         iAppServices->StoreObservationRegister().DeregisterStoreEvents( *this );
   221         iAppServices->StoreObservationRegister().DeregisterStoreEvents( *this );
   226 
   236 
   227     // Remove empty status pane
   237     // Remove empty status pane
   228     if (iNaviContainer)
   238     if (iNaviContainer)
   229         {
   239         {
   230         iNaviContainer->Pop();
   240         iNaviContainer->Pop();
   231         TRAP_IGNORE(RestorePrevNaviDecoratorL());        
   241         TRAP_IGNORE(RestorePrevNaviDecoratorL());
   232         }
   242         }
   233 
   243 
   234     delete iStoreContact;
   244     delete iStoreContact;
   235     delete iFieldFactory;
   245     delete iFieldFactory;
   236     delete iPbk2BaseCommand;
   246     delete iPbk2BaseCommand;
   242     delete iStoredTitlePaneText;
   252     delete iStoredTitlePaneText;
   243     iStoredTitlePaneText = NULL;
   253     iStoredTitlePaneText = NULL;
   244 
   254 
   245     delete iConverter;
   255     delete iConverter;
   246     delete iDelayDelete;
   256     delete iDelayDelete;
       
   257     
       
   258     // The if-expression is used here to Exit Phonebook2 for the case 
       
   259     // that Exit phonebook2 with the EditorDlg opened.
       
   260     if ( iExitApp )
       
   261         {
       
   262         TRAP_IGNORE( ((CAknViewAppUi*)CEikonEnv::Static()->EikAppUi())->ProcessCommandL( EAknCmdExit ) );
       
   263         }
   247     }
   264     }
   248 
   265 
   249 // --------------------------------------------------------------------------
   266 // --------------------------------------------------------------------------
   250 // CPbk2ContactEditorDlgImpl::NewL
   267 // CPbk2ContactEditorDlgImpl::NewL
   251 // --------------------------------------------------------------------------
   268 // --------------------------------------------------------------------------
   493 // CPbk2ContactEditorDlgImpl::HandleResourceChange
   510 // CPbk2ContactEditorDlgImpl::HandleResourceChange
   494 // --------------------------------------------------------------------------
   511 // --------------------------------------------------------------------------
   495 //
   512 //
   496 void CPbk2ContactEditorDlgImpl::HandleResourceChange( TInt aType )
   513 void CPbk2ContactEditorDlgImpl::HandleResourceChange( TInt aType )
   497     {
   514     {
   498     // Handle change in layout orientation
   515     switch ( aType )
   499     if ( aType == KEikDynamicLayoutVariantSwitch )
   516         {
   500         {
   517         case KEikDynamicLayoutVariantSwitch: // Handle change in layout orientation
   501         // Set status pane layout to the Phonebook 2 one
   518             {
   502         CEikStatusPane* statusPane = iAvkonAppUi->StatusPane();
   519             // Set status pane layout to the Phonebook 2 one
   503         if ( statusPane )
   520             CEikStatusPane* statusPane = iAvkonAppUi->StatusPane();
   504             {
   521             if ( statusPane )
   505             iCurrentstatuspane = statusPane->CurrentLayoutResId();
   522                 {
   506             if( iCurrentstatuspane != R_AVKON_STATUS_PANE_LAYOUT_USUAL )
   523                 iCurrentstatuspane = statusPane->CurrentLayoutResId();
   507                 {
   524                 if( iCurrentstatuspane != R_AVKON_STATUS_PANE_LAYOUT_USUAL )
   508                 TRAP_IGNORE( statusPane->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL) );
   525                     {
   509                 }
   526                     TRAP_IGNORE( 
   510             }
   527                         statusPane->SwitchLayoutL(
       
   528                             R_AVKON_STATUS_PANE_LAYOUT_USUAL )
       
   529                         );
       
   530                     }
       
   531                 }
       
   532             }
       
   533             break;
       
   534         case KAknSplitInputEnabled:     // Handle split input keyboard
       
   535             {
       
   536             // Sometimes this function will be called continuously
       
   537             // with the same parameter.
       
   538             // Add a flag iIsInputPaneOpen to ensure the dialog
       
   539             // only draw one time.
       
   540             if( !iIsInputPaneOpen )
       
   541                 {
       
   542                 Layout();
       
   543                 DrawNow();
       
   544                 iIsInputPaneOpen = ETrue;
       
   545                 }
       
   546             }
       
   547             break;
       
   548         case KAknSplitInputDisabled:
       
   549             {
       
   550             // Sometimes this function will be called continuously
       
   551             // with the same parameter.
       
   552             // Add a flag iIsInputPaneOpen to ensure the dialog
       
   553             // only draw one time.
       
   554             if( iIsInputPaneOpen )
       
   555                 {
       
   556                 // Set status pane layout to the Phonebook 2 one
       
   557                 Layout();
       
   558                 DrawNow();
       
   559                 CEikStatusPane* statusPane = iAvkonAppUi->StatusPane();
       
   560                 if ( statusPane )
       
   561                     {
       
   562                     TRAP_IGNORE(
       
   563                             statusPane->SwitchLayoutL(
       
   564                                     R_AVKON_STATUS_PANE_LAYOUT_USUAL )
       
   565                         );
       
   566                     }
       
   567                 iIsInputPaneOpen = EFalse;
       
   568                 }
       
   569             }
       
   570             break;
       
   571         default:
       
   572             break;
   511         }
   573         }
   512     
   574     
   513     CAknForm::HandleResourceChange( aType );
   575     CAknForm::HandleResourceChange( aType );
   514     }
   576     }
   515 
   577 
   520 void CPbk2ContactEditorDlgImpl::AddItemToContactL
   582 void CPbk2ContactEditorDlgImpl::AddItemToContactL
   521       ( TInt aFieldTypeResourceId,
   583       ( TInt aFieldTypeResourceId,
   522         const TDesC& aFieldTypeXspName, 
   584         const TDesC& aFieldTypeXspName, 
   523         TBool aSetFocus )
   585         TBool aSetFocus )
   524     {
   586     {
       
   587     // For knowing whether the destructor has been called
       
   588     TBool destroyed = EFalse;
       
   589     iDestroyedPtrForAddItem = &destroyed;
   525     // Store the original parameter value, since it is
   590     // Store the original parameter value, since it is
   526     // changed by AddFieldsL
   591     // changed by AddFieldsL
   527     TInt origParam = aFieldTypeResourceId;
   592     TInt origParam = aFieldTypeResourceId;
   528     TPtrC xSpName = aFieldTypeXspName;
   593     TPtrC xSpName = aFieldTypeXspName;
   529 
   594 
   530     CPbk2AddItemManager* addItemManager = CPbk2AddItemManager::NewL
   595     CPbk2AddItemManager* addItemManager = CPbk2AddItemManager::NewL
   531             (iContact, *iUiFieldArray, iParams, iAppServices );
   596             (iContact, *iUiFieldArray, iParams, iAppServices );
   532     CleanupStack::PushL(addItemManager);
   597     CleanupStack::PushL(addItemManager);
   533     CPbk2AddItemManager::TReturnValue ret = addItemManager->AddFieldsL(
   598     CPbk2AddItemManager::TReturnValue ret = addItemManager->AddFieldsL(
   534             aFieldTypeResourceId, xSpName);
   599             aFieldTypeResourceId, xSpName);
   535 
   600     
   536     if (ret.iControlId == KErrAlreadyExists)
   601     // In case that pop list for adding item is closed by FSW, this object 
   537         {
   602     // will be destructed by CPbk2ContactEditorOperator::ForceExit().
   538         // cannot add more than one of this field type
   603     // If this object is destructed, don't execute the following anymore.
   539         // find and focus that
   604     if ( !destroyed )
   540         TInt fieldArrayCount( iUiFieldArray->Count() );
   605         {
   541         for (TInt i(0); i < fieldArrayCount && ret.iControlId
   606         if (ret.iControlId == KErrAlreadyExists)
   542                 == KErrAlreadyExists; ++i)
   607             {
   543             {
   608             // cannot add more than one of this field type
   544             if (!iUiFieldArray->At(i).ContactEditorField())
   609             // find and focus that
   545                 {
   610             TInt fieldArrayCount( iUiFieldArray->Count() );
   546                 continue;
   611             for (TInt i(0); i < fieldArrayCount && ret.iControlId
   547                 }
   612                     == KErrAlreadyExists; ++i)
   548             const MVPbkFieldType* fieldType =
   613                 {
   549                 iUiFieldArray->At(i).ContactEditorField()->ContactField().
   614                 if (!iUiFieldArray->At(i).ContactEditorField())
   550                     BestMatchingFieldType();
       
   551             if(fieldType && fieldType->FieldTypeResId() == aFieldTypeResourceId)
       
   552                 {
       
   553                 ret.iControlId = iUiFieldArray->At(i).ControlId();
       
   554                 }
       
   555             }
       
   556         }
       
   557 
       
   558     if (ret.iControlId > 0)
       
   559         {
       
   560         if (aSetFocus)
       
   561             {
       
   562             TryChangeFocusL(ret.iControlId);
       
   563             MPbk2ContactEditorField* editorField = iUiFieldArray->Find( ret.iControlId )->ContactEditorField();
       
   564             MVPbkStoreContactField& storeContactField = editorField->ContactField();
       
   565             iParams.iFocusedContactField = &storeContactField;
       
   566             // Call this after adding or deleting lines
       
   567             UpdatePageL( ETrue );
       
   568             // Must be DrawNow and not DrawDeferred otherwise field label
       
   569             // and content of the following field will be incorrect
       
   570             DrawNow();
       
   571             }
       
   572         }
       
   573     else if (ret.iControlId == KErrNotSupported && origParam == KErrNotFound)
       
   574         {
       
   575         iUiFieldArray->SaveFieldsL();
       
   576         iRelocator.RelocateContactL(aFieldTypeResourceId, xSpName,
       
   577             Pbk2ContactRelocator::EPbk2DisplayStoreDoesNotSupportQuery);
       
   578         }
       
   579     else if ( iParams.iActiveView == TPbk2ContactEditorParams::EEditorView )
       
   580         {
       
   581         switch( ret.iGruopId )
       
   582             {
       
   583             case EPbk2FieldGroupIdPostalAddress:
       
   584                 if(iUiFieldArray->Count())
       
   585                     {
   615                     {
       
   616                     continue;
       
   617                     }
       
   618                 const MVPbkFieldType* fieldType =
       
   619                     iUiFieldArray->At(i).ContactEditorField()->ContactField().
       
   620                         BestMatchingFieldType();
       
   621                 if(fieldType && fieldType->FieldTypeResId() == aFieldTypeResourceId)
       
   622                     {
       
   623                     ret.iControlId = iUiFieldArray->At(i).ControlId();
       
   624                     }
       
   625                 }
       
   626             }
       
   627     
       
   628         if (ret.iControlId > 0)
       
   629             {
       
   630             if (aSetFocus)
       
   631                 {
       
   632                 TryChangeFocusL(ret.iControlId);
       
   633                 MPbk2ContactEditorField* editorField = iUiFieldArray->Find( ret.iControlId )->ContactEditorField();
       
   634                 MVPbkStoreContactField& storeContactField = editorField->ContactField();
       
   635                 iParams.iFocusedContactField = &storeContactField;
       
   636                 // Call this after adding or deleting lines
       
   637                 UpdatePageL( ETrue );
       
   638                 // Must be DrawNow and not DrawDeferred otherwise field label
       
   639                 // and content of the following field will be incorrect
       
   640                 DrawNow();
       
   641                 }
       
   642             }
       
   643         else if (ret.iControlId == KErrNotSupported && origParam == KErrNotFound)
       
   644             {
       
   645             iUiFieldArray->SaveFieldsL();
       
   646             iRelocator.RelocateContactL(aFieldTypeResourceId, xSpName,
       
   647                 Pbk2ContactRelocator::EPbk2DisplayStoreDoesNotSupportQuery);
       
   648             }
       
   649         else if ( iParams.iActiveView == TPbk2ContactEditorParams::EEditorView )
       
   650             {
       
   651             switch( ret.iGruopId )
       
   652                 {
       
   653                 case EPbk2FieldGroupIdPostalAddress:
       
   654                     if(iUiFieldArray->Count())
       
   655                         {
       
   656                         iUiFieldArray->AddNewFieldL( ret.iGruopId );
       
   657                         ExecuteAddressDlgL( TPbk2ContactEditorParams::EEditorAddressView );
       
   658                         }
       
   659                     break;
       
   660                 case EPbk2FieldGroupIdHomeAddress:
   586                     iUiFieldArray->AddNewFieldL( ret.iGruopId );
   661                     iUiFieldArray->AddNewFieldL( ret.iGruopId );
   587                     ExecuteAddressDlgL( TPbk2ContactEditorParams::EEditorAddressView );
   662                     ExecuteAddressDlgL( TPbk2ContactEditorParams::EEditorAddressHomeView );
   588                     }
   663                     break;
   589                 break;
   664                 case EPbk2FieldGroupIdCompanyAddress:
   590             case EPbk2FieldGroupIdHomeAddress:
   665                     iUiFieldArray->AddNewFieldL( ret.iGruopId );
   591                 iUiFieldArray->AddNewFieldL( ret.iGruopId );
   666                     ExecuteAddressDlgL( TPbk2ContactEditorParams::EEditorAddressOfficeView );
   592                 ExecuteAddressDlgL( TPbk2ContactEditorParams::EEditorAddressHomeView );
   667                     break;
   593                 break;
   668                 }
   594             case EPbk2FieldGroupIdCompanyAddress:
   669             }
   595                 iUiFieldArray->AddNewFieldL( ret.iGruopId );
   670         iDestroyedPtrForAddItem = NULL;
   596                 ExecuteAddressDlgL( TPbk2ContactEditorParams::EEditorAddressOfficeView );
       
   597                 break;
       
   598             }
       
   599         }
   671         }
   600     CleanupStack::PopAndDestroy(addItemManager);
   672     CleanupStack::PopAndDestroy(addItemManager);
   601     }
   673     }
   602 
   674 
   603 // --------------------------------------------------------------------------
   675 // --------------------------------------------------------------------------
   685          {
   757          {
   686          HandleCustomFieldCommandL(EPbk2ExtensionShowOnMap);
   758          HandleCustomFieldCommandL(EPbk2ExtensionShowOnMap);
   687          return EKeyWasConsumed;
   759          return EKeyWasConsumed;
   688          }*/
   760          }*/
   689 
   761 
       
   762      // When the end key is pressed and OfferKeyEventL() is called for the first time,
       
   763      // set the edit dialog to be not editable to close the partial input
       
   764      // screen if it is open.
       
   765      if( aKeyEvent.iCode == EKeyEscape && !iEndKeyWasPressed )
       
   766          {
       
   767          SetEditableL( EFalse );
       
   768          }
       
   769 
   690     // Display menu bar if the focused control doesnt consume selection keys
   770     // Display menu bar if the focused control doesnt consume selection keys
   691     CPbk2ContactEditorArrayItem* currentField = iUiFieldArray->Find(
   771     CPbk2ContactEditorArrayItem* currentField = iUiFieldArray->Find(
   692             IdOfFocusControl());
   772             IdOfFocusControl());
   693 
   773 
   694     if (currentField)
   774     if (currentField)
   714         {
   794         {
   715         iContextMenuBar->TryDisplayMenuBarL();
   795         iContextMenuBar->TryDisplayMenuBarL();
   716         ret = EKeyWasConsumed;
   796         ret = EKeyWasConsumed;
   717         }
   797         }
   718 
   798 
   719     if ( ret != EKeyWasConsumed && !iEndKeyWasPressed )
   799     if ( ret != EKeyWasConsumed )
   720         {
   800         {
   721         if ( aKeyEvent.iCode == EKeyEscape )
   801         // If the iEndKeyWasPressed equels to true, which illustrates
   722             {
   802         // the EditorDlgImpl get the Escape key event one more time 
   723             iEditorStrategy.StopQuery();
   803         // for the case that Exit phonebook2 with the EditorDlg opened,
   724             iEndKeyWasPressed = ETrue;
   804         // sush as save VOIP settings,there will be two event,
   725             }
   805         // one is to close dialog and the other is to exit phonebook2. 
   726         ret = CAknForm::OfferKeyEventL( aKeyEvent, aType );
   806         if ( iEndKeyWasPressed )
   727         if ( ret == EKeyWasConsumed && 
   807             {
   728             aKeyEvent.iCode != EKeyPhoneEnd && aKeyEvent.iCode != EKeyEscape )
   808             if ( aKeyEvent.iCode == EKeyEscape && iAvkonAppUi->IsAppShutterRunning() )
   729             {
   809                 {
   730             UpdateCbasL();
   810                 // Use the iExitApp to record whether the AppShutter is running.
   731             }        
   811                 // According to the value of iExitApp to Exit Phonebook2 app ui 
       
   812                 // after the EditorDlg close completely. 
       
   813                 iExitApp = ETrue;
       
   814                 }
       
   815             }
       
   816         else
       
   817             {
       
   818             if ( aKeyEvent.iCode == EKeyEscape )
       
   819                 {
       
   820                 iEditorStrategy.StopQuery();
       
   821                 iEndKeyWasPressed = ETrue;
       
   822                 }
       
   823             ret = CAknForm::OfferKeyEventL( aKeyEvent, aType );
       
   824             if ( ret == EKeyWasConsumed && aKeyEvent.iCode != EKeyPhoneEnd
       
   825                 && aKeyEvent.iCode != EKeyEscape )
       
   826                 {
       
   827                 UpdateCbasL();
       
   828                 }
       
   829             }
   732         }
   830         }
   733 
   831 
   734     return ret;
   832     return ret;
   735     }
   833     }
   736 
   834 
  1215 
  1313 
  1216 // --------------------------------------------------------------------------
  1314 // --------------------------------------------------------------------------
  1217 // CPbk2ContactEditorDlgImpl::AreAllFieldsEmpty
  1315 // CPbk2ContactEditorDlgImpl::AreAllFieldsEmpty
  1218 // --------------------------------------------------------------------------
  1316 // --------------------------------------------------------------------------
  1219 //
  1317 //
  1220 TBool CPbk2ContactEditorDlgImpl::AreAllFieldsEmpty()
  1318 TBool CPbk2ContactEditorDlgImpl::AreAllFieldsEmptyL()
  1221     {
  1319     {
  1222     TBool result(ETrue);
  1320     TBool result(ETrue);
  1223     TInt countAll = iContact.PresentationFields().FieldCount();
  1321     TInt countAll = iContact.PresentationFields().FieldCount();
  1224     for (TInt idx = 0; idx < countAll; idx++)
  1322     for (TInt idx = 0; idx < countAll; idx++)
  1225         {
  1323         {
  1645                 {
  1743                 {
  1646                  iNaviContainer->Pop();
  1744                  iNaviContainer->Pop();
  1647                  RestorePrevNaviDecoratorL();
  1745                  RestorePrevNaviDecoratorL();
  1648                  iNaviContainer = NULL;
  1746                  iNaviContainer = NULL;
  1649                  }
  1747                  }
  1650             MakeVisible( EFalse );
  1748             
       
  1749             if ( !iAvkonAppUi->IsAppShutterRunning() )
       
  1750                 {
       
  1751                 MakeVisible( EFalse );
       
  1752                 }
       
  1753            
  1651             MPbk2ContactEditorEventObserver::TParams params;
  1754             MPbk2ContactEditorEventObserver::TParams params;
  1652             params.iFlags = EPbk2EditorKeyCode;
  1755             params.iFlags = EPbk2EditorKeyCode;
  1653             params.iKeyCode = aKeycode;
  1756             params.iKeyCode = aKeycode;
  1654 
  1757 
  1655             // If the application is not allowed to hide itself in the
  1758             // If the application is not allowed to hide itself in the
  1963 // --------------------------------------------------------------------------
  2066 // --------------------------------------------------------------------------
  1964 // CPbk2ContactEditorDlgImpl::CloseDialog
  2067 // CPbk2ContactEditorDlgImpl::CloseDialog
  1965 // --------------------------------------------------------------------------
  2068 // --------------------------------------------------------------------------
  1966 //
  2069 //
  1967 void CPbk2ContactEditorDlgImpl::CloseDialog()
  2070 void CPbk2ContactEditorDlgImpl::CloseDialog()
  1968 	{
  2071     {
  1969     // Ignore error and close editor without further user interaction
  2072     // Ignore error and close editor without further user interaction
  1970     MVPbkContactObserver::TContactOpResult exitResult;
  2073     MVPbkContactObserver::TContactOpResult exitResult;
  1971     exitResult.iExtension = NULL;
  2074     exitResult.iExtension = NULL;
  1972     exitResult.iStoreContact = NULL;
  2075     exitResult.iStoreContact = NULL;
  1973     exitResult.iOpCode = MVPbkContactObserver::EContactDelete;
  2076     exitResult.iOpCode = MVPbkContactObserver::EContactDelete;
  2663 void CPbk2ContactEditorDlgImpl::CloseDialog(
  2766 void CPbk2ContactEditorDlgImpl::CloseDialog(
  2664         MVPbkContactObserver::TContactOp aOpCode, TBool aInformObserver)
  2767         MVPbkContactObserver::TContactOp aOpCode, TBool aInformObserver)
  2665     {
  2768     {
  2666     // For knowing if the destructor has been called
  2769     // For knowing if the destructor has been called
  2667     TBool destroyed = EFalse;
  2770     TBool destroyed = EFalse;
  2668     iDestroyedPtr = &destroyed;
  2771     iDestroyedPtrForCloseDlg = &destroyed;
  2669 
  2772 
  2670     if (aInformObserver && iParams.iActiveView
  2773     if (aInformObserver && iParams.iActiveView
  2671             == TPbk2ContactEditorParams::EEditorView || iAddressViewStandalone)
  2774             == TPbk2ContactEditorParams::EEditorView || iAddressViewStandalone)
  2672         {
  2775         {
  2673         switch (aOpCode)
  2776         switch (aOpCode)
  2696         }
  2799         }
  2697 
  2800 
  2698     // In VOIP/new contacts/exit case, this object will be destructed by
  2801     // In VOIP/new contacts/exit case, this object will be destructed by
  2699     // iContactObserver.ContactEditingComplete() above.
  2802     // iContactObserver.ContactEditingComplete() above.
  2700     // If this object is destructed, don't excute the following anymore
  2803     // If this object is destructed, don't excute the following anymore
  2701     if ( destroyed )
  2804     if ( !destroyed )
  2702         {
  2805         {
  2703         return;
  2806         // Don't save any contact data (already saved)
  2704         }
  2807         iExitRecord.Set(EOkToExitWithoutHandlingIt);
  2705 
  2808         iExitRecord.Clear(EExitOrdered);
  2706     // Don't save any contact data (already saved)
  2809     
  2707     iExitRecord.Set(EOkToExitWithoutHandlingIt);
  2810         // Close dialog using TryExitL and returning ETrue from OkToExit
  2708     iExitRecord.Clear(EExitOrdered);
  2811         TInt err = KErrNone;
  2709 
  2812             TRAP( err, TryExitL( EAknSoftkeyBack ) );
  2710     // Close dialog using TryExitL and returning ETrue from OkToExit
  2813         if (err != KErrNone)
  2711     TInt err = KErrNone;
  2814             {
  2712         TRAP( err, TryExitL( EAknSoftkeyBack ) );
  2815             // If not nicely then use the force.
  2713     if (err != KErrNone)
  2816             delete this;
  2714         {
  2817             }
  2715         // If not nicely then use the force.
  2818         iDestroyedPtrForCloseDlg = NULL;
  2716         delete this;
       
  2717         }
  2819         }
  2718     }
  2820     }
  2719 
  2821 
  2720 // --------------------------------------------------------------------------
  2822 // --------------------------------------------------------------------------
  2721 // CPbk2ContactEditorDlgImpl::ExitApplication
  2823 // CPbk2ContactEditorDlgImpl::ExitApplication
  2861             switch(uiField->UIField()->CtrlType())
  2963             switch(uiField->UIField()->CtrlType())
  2862                 {
  2964                 {
  2863                 case EPbk2FieldCtrlTypeExtAddressEditor:
  2965                 case EPbk2FieldCtrlTypeExtAddressEditor:
  2864                 case EPbk2FieldCtrlTypeExtAddressHomeEditor:
  2966                 case EPbk2FieldCtrlTypeExtAddressHomeEditor:
  2865                 case EPbk2FieldCtrlTypeExtAddressOfficeEditor:
  2967                 case EPbk2FieldCtrlTypeExtAddressOfficeEditor:
  2866                     if(IsAddressValidated(Pbk2AddressTools::MapCtrlTypeToAddress(
  2968                     {
  2867                             uiField->UIField()->CtrlType())))
  2969                 	TInt iconId = 0;
       
  2970                     // UnSync feature indicator flag and chinese flag
       
  2971                     TBool supportUnSyncFeature = 
       
  2972                           FeatureManager::FeatureSupported( 
       
  2973                           KFeatureIdFfTdUnSyncabPbfieldsInd );
       
  2974                     TBool supportChinese = 
       
  2975                         FeatureManager::FeatureSupported( KFeatureIdChinese ); 
       
  2976                     // Valid address
       
  2977                     TBool addressValidated = 
       
  2978                          IsAddressValidated( 
       
  2979                             Pbk2AddressTools::MapCtrlTypeToAddress(
       
  2980                             uiField->UIField()->CtrlType()));
       
  2981                     if(supportChinese && supportUnSyncFeature)
  2868                         {
  2982                         {
  2869                         TPbk2IconId iconID(TUid::Uid(KPbk2UID3), EPbk2qgn_prop_locev_map);
  2983                         // Unsync icon
  2870                         uiField->LoadBitmapToFieldL(iconID);
  2984                         iconId = EPbk2qgn_prop_phonebook2_unsync;
  2871                         }
  2985                         }
  2872                     else
  2986                     else
  2873                         {
  2987                         {
  2874                         TPbk2IconId iconID(TUid::Uid(KPbk2UID3), EPbk2qgn_prop_pb_no_valid_lm);
  2988                         iconId = addressValidated ?
  2875                         uiField->LoadBitmapToFieldL(iconID);
  2989                             EPbk2qgn_prop_locev_map : EPbk2qgn_prop_pb_no_valid_lm;
  2876                         }
  2990                         }
       
  2991                     TPbk2IconId pbkIconId(TUid::Uid(KPbk2UID3),iconId);
       
  2992                     uiField->LoadBitmapToFieldL(pbkIconId); 
       
  2993                     }
  2877                     break;
  2994                     break;
  2878                 case EPbk2FieldCtrlTypeExtAssignFromMapsEditor:
  2995                 case EPbk2FieldCtrlTypeExtAssignFromMapsEditor:
  2879                     if(IsAddressValidated( Pbk2AddressTools::MapViewTypeToAddress(iParams.iActiveView)))
  2996                     {
       
  2997                     // UnSync feature indicator flag and chinese flag
       
  2998                     TBool supportUnSyncFeature = 
       
  2999                            FeatureManager::FeatureSupported(
       
  3000                            KFeatureIdFfTdUnSyncabPbfieldsInd );
       
  3001                     TBool supportChinese = 
       
  3002                            FeatureManager::FeatureSupported( KFeatureIdChinese ); 
       
  3003 
       
  3004                     TBool addressValidated = 
       
  3005                            IsAddressValidated( 
       
  3006                            Pbk2AddressTools::MapViewTypeToAddress( iParams.iActiveView ));
       
  3007                     TInt iconId = 0;
       
  3008                     if( supportChinese && supportUnSyncFeature )
  2880                         {
  3009                         {
  2881                           TPbk2IconId iconID(TUid::Uid(KPbk2UID3), EPbk2qgn_prop_locev_map);
  3010                         iconId = EPbk2qgn_prop_phonebook2_unsync;
  2882                           uiField->LoadBitmapToFieldL(iconID);
  3011                         }
  2883                           }
  3012                     else
  2884                       else
  3013                         {
  2885                           {
  3014                         iconId = addressValidated ?
  2886                           TPbk2IconId iconID(TUid::Uid(KPbk2UID3), EPbk2qgn_prop_pb_no_valid_lm);
  3015                             EPbk2qgn_prop_locev_map : EPbk2qgn_prop_pb_no_valid_lm;
  2887                           uiField->LoadBitmapToFieldL(iconID);
  3016                         }
  2888                           }
  3017                     TPbk2IconId pbkIconId(TUid::Uid(KPbk2UID3),iconId);
  2889                     break;  
  3018                     uiField->LoadBitmapToFieldL(pbkIconId); 
       
  3019                     }
       
  3020                     break;
  2890                 default:
  3021                 default:
  2891                     return;
  3022                     return;
  2892                 }
  3023                 }
  2893             }
  3024             }
  2894         }
  3025         }
  2980         if (iParams.iActiveView == TPbk2ContactEditorParams::EEditorView || 
  3111         if (iParams.iActiveView == TPbk2ContactEditorParams::EEditorView || 
  2981             iAddressViewStandalone)
  3112             iAddressViewStandalone)
  2982             {
  3113             {
  2983             // Estimate all field are empty by UI field.
  3114             // Estimate all field are empty by UI field.
  2984         if (( AreAllControlsEmpty() && !iAddressViewStandalone )||
  3115         if (( AreAllControlsEmpty() && !iAddressViewStandalone )||
  2985             (iAddressViewStandalone && AreAllFieldsEmpty()))
  3116             (iAddressViewStandalone && AreAllFieldsEmptyL()))
  2986                 {
  3117                 {
  2987                 if (iEditorExtension->OkToDeleteContactL(aParams))
  3118                 if (iEditorExtension->OkToDeleteContactL(aParams))
  2988                     {
  3119                     {
  2989                     // iUseState must be set before DeleteContactL() because 
  3120                     // iUseState must be set before DeleteContactL() because 
  2990                     // during deletion ForceExit() might be entered and needs to 
  3121                     // during deletion ForceExit() might be entered and needs to 
  3152 TBool CPbk2ContactEditorDlgImpl::OkToExitApplicationL
  3283 TBool CPbk2ContactEditorDlgImpl::OkToExitApplicationL
  3153         ( TInt aCommandId )
  3284         ( TInt aCommandId )
  3154     {
  3285     {
  3155     TBool okToExit = ETrue;
  3286     TBool okToExit = ETrue;
  3156 
  3287 
       
  3288     // The exit callback must be invoked only once when editor dlg is exiting.
       
  3289     if ( (iParams.iActiveView == TPbk2ContactEditorParams::EEditorView || 
       
  3290             iAddressViewStandalone) && iParams.iExitCallback )
       
  3291         {
       
  3292         okToExit = iParams.iExitCallback->OkToExitL( aCommandId );
       
  3293         }
       
  3294     
  3157     // If exit callback returned EFalse, the exit is cancelled
  3295     // If exit callback returned EFalse, the exit is cancelled
  3158     if ( iParams.iExitCallback &&
       
  3159          !iParams.iExitCallback->OkToExitL( aCommandId ) )
       
  3160         {
       
  3161         okToExit = EFalse;
       
  3162         }
       
  3163 
       
  3164     if ( !okToExit )
  3296     if ( !okToExit )
  3165         {
  3297         {
  3166         iExitRecord.Clear( EExitApproved );
  3298         iExitRecord.Clear( EExitApproved );
  3167         }
  3299         }
  3168 
  3300