cmmanager/cmmgr/Plugins/cmpluginvpn/src/cmpvpnsettingsdlg.cpp
changeset 0 5a93021fdf25
child 3 f7816ffc66ed
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Dialog for editing VPN settings for a VPN
       
    15 *                connection method
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <cmpluginbaseeng.h>
       
    21 #include <cmpluginvpn.mbg>
       
    22 #include <cmpluginvpnui.rsg>
       
    23 #include <AknDialog.h>
       
    24 #include <StringLoader.h>
       
    25 #include <cmmanager.rsg>
       
    26 #include <akntextsettingpage.h>
       
    27 #include <akntitle.h>
       
    28 #include <cmcommonui.h>
       
    29 #include <csxhelp/cp.hlp.hrh>
       
    30 
       
    31 #include "cmlogger.h"
       
    32 #include "cmmanagerimpl.h"
       
    33 #include "cmpluginvpn.h"
       
    34 #include "cmpvpnsettingsdlg.h"
       
    35 #include "cmvpncommonconstants.h"
       
    36 #include <cmpluginvpndef.h>
       
    37 #include "cmpvpnpolicyselectiondlg.h"
       
    38 #include <cmcommonconstants.h>
       
    39 #include <cmpsettingsconsts.h>
       
    40 #include "cmconnsettingsuiimpl.h"
       
    41 #include "cmdestinationimpl.h"
       
    42 #include "cmmanagerimpl.h"
       
    43 
       
    44 using namespace CMManager;
       
    45 
       
    46 
       
    47 // ================= MEMBER FUNCTIONS =======================================
       
    48 
       
    49 // --------------------------------------------------------------------------
       
    50 // CmPluginVpnSettingsDlg::NewL()
       
    51 // Two-phase dconstructor, second phase is ConstructAndRunLD
       
    52 // --------------------------------------------------------------------------
       
    53 //
       
    54 CmPluginVpnSettingsDlg* CmPluginVpnSettingsDlg::NewL( 
       
    55                                             CCmPluginBaseEng& aCmPluginBase )
       
    56 	{
       
    57 	CmPluginVpnSettingsDlg* self = 
       
    58 	                new ( ELeave ) CmPluginVpnSettingsDlg( aCmPluginBase );
       
    59 	return self;
       
    60 	}
       
    61 	
       
    62 // --------------------------------------------------------------------------
       
    63 // CmPluginVpnSettingsDlg::CmPluginVpnSettingsDlg()
       
    64 // --------------------------------------------------------------------------
       
    65 //
       
    66 CmPluginVpnSettingsDlg::CmPluginVpnSettingsDlg( 
       
    67                                             CCmPluginBaseEng& aCmPluginBase )
       
    68     : CmPluginBaseSettingsDlg( aCmPluginBase )
       
    69     {
       
    70     
       
    71     }
       
    72     
       
    73 //---------------------------------------------------------------------------
       
    74 // CmPluginVpnSettingsDlg::ConstructAndRunLD
       
    75 // --------------------------------------------------------------------------
       
    76 //
       
    77 TInt CmPluginVpnSettingsDlg::ConstructAndRunLD( )
       
    78     {
       
    79     LOGGER_ENTERFN( "CmPluginVpnSettingsDlg::ConstructAndRunLD" );
       
    80     CleanupStack::PushL( this );
       
    81     LoadResourceL( KPluginVPNResDirAndFileName );
       
    82     
       
    83     // check if VPN is available, as if not, we can not show the details...
       
    84     RVpnServ ps;
       
    85     CleanupClosePushL<RVpnServ>( ps );
       
    86     TInt err = ps.Connect();
       
    87     if ( err )
       
    88         {
       
    89         // show note
       
    90         HBufC* text = StringLoader::LoadLC( 
       
    91                                     R_QTN_VPN_INFO_MGMT_UI_NOT_ACCESSIBLE );
       
    92         TCmCommonUi::ShowNoteL( *text, TCmCommonUi::ECmInfoNote );
       
    93         CleanupStack::PopAndDestroy( text );        
       
    94         User::Leave( KLeaveWithoutAlert );
       
    95         }
       
    96     CleanupStack::PopAndDestroy(); // ps.close
       
    97     
       
    98     // check for compulsory fields missing & display note about it
       
    99     // information note VPN access point is incomplete. Try reconfiguring 
       
   100     // the access point. §qtn.vpn.info.vpn.iap.incomplete§ is displayed and 
       
   101     // Must be defined qtn_selec_setting_compulsory is displayed 
       
   102     // for the invalid settings.               
       
   103     if ( !CompulsoryFilledL() )
       
   104         {
       
   105         // show note
       
   106         HBufC* text = StringLoader::LoadLC( 
       
   107                                     R_QTN_VPN_INFO_VPN_IAP_INCOMPLETE );
       
   108         TCmCommonUi::ShowNoteL( *text, TCmCommonUi::ECmInfoNote );
       
   109         CleanupStack::PopAndDestroy( text );
       
   110         }
       
   111     
       
   112     CleanupStack::Pop( this );
       
   113     
       
   114     CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
       
   115     cmMgr.WatcherRegisterL( this );
       
   116     
       
   117     return CmPluginBaseSettingsDlg::ConstructAndRunLD( );
       
   118     }
       
   119 
       
   120 // --------------------------------------------------------------------------
       
   121 // CmPluginVpnSettingsDlg::~CmPluginVpnSettingsDlg
       
   122 // Destructor
       
   123 // --------------------------------------------------------------------------
       
   124 //
       
   125 CmPluginVpnSettingsDlg::~CmPluginVpnSettingsDlg()
       
   126     {
       
   127     iResourceReader.Close();
       
   128     }
       
   129     
       
   130 // --------------------------------------------------------------------------
       
   131 // CmPluginVpnSettingsDlg::UpdateListBoxContentBearerSpecificL
       
   132 // --------------------------------------------------------------------------
       
   133 //
       
   134 void CmPluginVpnSettingsDlg::UpdateListBoxContentBearerSpecificL( 
       
   135                                                     CDesCArray& aItemArray )
       
   136     {
       
   137     LOGGER_ENTERFN( "CmPluginVpnSettingsDlg::UpdateListBoxContentBearerSpecificL" );
       
   138     HBufC* value = NULL;
       
   139         
       
   140     // VPN policy - Compulsory field
       
   141     AppendSettingTextsL( aItemArray, EVpnServicePolicyName );
       
   142     
       
   143     TUint32 iapId = iCmPluginBaseEng.GetIntAttributeL( EVpnIapId );
       
   144     TUint32 destId = iCmPluginBaseEng.GetIntAttributeL( ECmNextLayerSNAPId );
       
   145     
       
   146     CCmDestinationImpl* dest = NULL;
       
   147     
       
   148     // The underlying CM is a Destination
       
   149     if ( destId )
       
   150         {
       
   151         dest = iCmPluginBaseEng.CmMgr().DestinationL( destId );
       
   152         CleanupStack::PushL( dest );
       
   153 //        CleanupReleasePushL( dest );
       
   154         value = dest->NameLC();
       
   155         }
       
   156     // The underlying CM is a CM
       
   157     else if ( iapId )
       
   158         {
       
   159         value = iCmPluginBaseEng.CmMgr().GetConnectionMethodInfoStringL( 
       
   160                                                            iapId, ECmName );
       
   161         CleanupStack::PushL( value );
       
   162         }
       
   163     else
       
   164         {
       
   165         // Must be defined
       
   166         value = StringLoader::LoadLC( R_QTN_VPN_SETT_VPN_IAP_REAL_NETW_REF_COMPULSORY );
       
   167         }
       
   168     
       
   169     AppendSettingTextsL( aItemArray,
       
   170                          ECmNextLayerIapId,
       
   171                          R_QTN_VPN_SETT_VPN_IAP_REAL_NETW_REFERENCE,
       
   172                          *value,
       
   173                          ETrue );
       
   174     CleanupStack::PopAndDestroy( value );
       
   175 
       
   176     if ( destId )
       
   177         {
       
   178         CleanupStack::PopAndDestroy( dest );
       
   179         }
       
   180                          
       
   181     // Proxy server address
       
   182     AppendSettingTextsL( aItemArray, ECmProxyServerName );
       
   183     // Proxy port number
       
   184     AppendSettingTextsL( aItemArray, ECmProxyPortNumber );
       
   185     
       
   186     }
       
   187 
       
   188 
       
   189 // --------------------------------------------------------------------------
       
   190 // CmPluginVpnSettingsDlg::RunAdvancedSettingsL
       
   191 // --------------------------------------------------------------------------
       
   192 //
       
   193 void CmPluginVpnSettingsDlg::RunAdvancedSettingsL()
       
   194     {
       
   195     /* empty functionality */
       
   196     }
       
   197 
       
   198 // --------------------------------------------------------------------------
       
   199 // CmPluginVpnSettingsDlg::DynInitMenuPaneL
       
   200 // --------------------------------------------------------------------------
       
   201 //
       
   202 void CmPluginVpnSettingsDlg::DynInitMenuPaneL( TInt aResourceId,
       
   203                                                CEikMenuPane* aMenuPane )
       
   204    {
       
   205    if ( aResourceId == R_PLUGIN_BASE_MENU )
       
   206         {
       
   207         aMenuPane->SetItemDimmed( EPluginBaseCmdAdvanced, ETrue  );           
       
   208         }
       
   209     }
       
   210         
       
   211 // --------------------------------------------------------------------------
       
   212 // CmPluginVpnSettingsDlg::ShowPopupSettingPageL
       
   213 // --------------------------------------------------------------------------
       
   214 //
       
   215 TBool CmPluginVpnSettingsDlg::ShowPopupSettingPageL( TUint32 aAttribute, 
       
   216                                                      TInt aCommandId )
       
   217     {
       
   218     LOGGER_ENTERFN( "CmPluginVpnSettingsDlg::ShowPopupSettingPageL" );
       
   219     TBool retVal = EFalse;
       
   220     switch ( aAttribute )
       
   221         {
       
   222         case EVpnServicePolicyName:        
       
   223             {
       
   224             CmPluginVpnPolicySelectionDlg* dlg = 
       
   225                     CmPluginVpnPolicySelectionDlg::NewL( iCmPluginBaseEng );
       
   226             CleanupStack::PushL( dlg );
       
   227             retVal = dlg->ShowPolicySelectionDlgL();
       
   228             UpdateListBoxContentL();
       
   229             CleanupStack::PopAndDestroy();
       
   230             break;
       
   231             }
       
   232         case ECmProxyServerName:
       
   233             {
       
   234             retVal = ShowPopupTextSettingPageL( aAttribute );
       
   235             break;
       
   236             }
       
   237         case EVpnIapId:
       
   238         case ECmNextLayerIapId:
       
   239             {
       
   240             ShowIapSelectionSettingPageL();
       
   241             break;
       
   242             }
       
   243         case ECmProxyPortNumber:
       
   244             {
       
   245             retVal = ShowPopupPortNumSettingPageL( aAttribute );
       
   246             break;
       
   247             }
       
   248         default:
       
   249             {
       
   250             CmPluginBaseSettingsDlg::ShowPopupSettingPageL( aAttribute, 
       
   251                                                             aCommandId );
       
   252             break;
       
   253             }
       
   254         }
       
   255     return retVal;
       
   256     }
       
   257 
       
   258 // --------------------------------------------------------------------------
       
   259 // CmPluginVpnSettingsDlg::ShowIapSelectionSettingPageL
       
   260 // --------------------------------------------------------------------------
       
   261 //
       
   262 TBool CmPluginVpnSettingsDlg::ShowIapSelectionSettingPageL()
       
   263     {  
       
   264     LOGGER_ENTERFN( "CmPluginVpnSettingsDlg::ShowIapSelectionSettingPageL" ); 
       
   265     TBool retVal( EFalse );
       
   266     
       
   267     CCmConnSettingsUiImpl* settings = 
       
   268                                 CCmConnSettingsUiImpl::NewL();
       
   269     CleanupStack::PushL( settings );
       
   270     settings->EnableEasyWlan( ETrue );
       
   271     settings->EnableEmptyDestinations( EFalse );
       
   272     settings->EnableVirtualCMs( EFalse );
       
   273     
       
   274     CCmDestinationImpl* d = iCmPluginBaseEng.ParentDestination();
       
   275     if ( d )
       
   276         {
       
   277         settings->SetDestinationToOmit( d->Id() );
       
   278 //        settings->EnableUncat( ETrue );
       
   279         }
       
   280     else
       
   281         {
       
   282 //        settings->EnableUncat( EFalse );
       
   283         }
       
   284     delete d;
       
   285     settings->EnableUncat( ETrue );
       
   286     
       
   287     CCmPluginVpn* plugin = static_cast<CCmPluginVpn *>
       
   288                     ( &iCmPluginBaseEng );
       
   289     
       
   290     RArray<TUint32> cmArray ( KCmArrayMediumGranularity );
       
   291     CleanupClosePushL( cmArray );
       
   292     
       
   293     plugin->BindableDestinationsL( cmArray );
       
   294     
       
   295     settings->SetDestinationArrayToUseL( cmArray );
       
   296     
       
   297     TCmSettingSelection selection;
       
   298     
       
   299     // Get the underlying CM
       
   300     selection.iId = iCmPluginBaseEng.GetIntAttributeL( ECmNextLayerIapId );
       
   301     
       
   302     if ( selection.iId )
       
   303         {
       
   304         selection.iResult = EConnectionMethod;
       
   305         }
       
   306     // The underlying CM is a destination
       
   307     else
       
   308         {        
       
   309         selection.iResult = EDestination;
       
   310         selection.iId = iCmPluginBaseEng.GetIntAttributeL( ECmNextLayerSNAPId );
       
   311         }
       
   312     
       
   313     TBearerFilterArray aFilterArray;
       
   314     if ( settings->RunApplicationSettingsL( selection,
       
   315                                             EShowDestinations |
       
   316                                             EShowConnectionMethods , 
       
   317                                             aFilterArray ) )
       
   318         {
       
   319         switch ( selection.iResult )
       
   320             {
       
   321             case EDestination:
       
   322                 {
       
   323                 iCmPluginBaseEng.SetIntAttributeL( ECmNextLayerSNAPId, selection.iId );
       
   324                 break;
       
   325                 }
       
   326             case EConnectionMethod:
       
   327                 {
       
   328                 
       
   329                 iCmPluginBaseEng.SetIntAttributeL( ECmNextLayerIapId, selection.iId );
       
   330                 break;
       
   331                 }
       
   332             default:
       
   333                 {
       
   334                 User::Leave( KErrNotSupported );
       
   335                 }
       
   336             }
       
   337         UpdateListBoxContentL();
       
   338         
       
   339         // update the title pane with the new name
       
   340         HBufC* newCmName = iCmPluginBaseEng.GetStringAttributeL( ECmName );
       
   341         CleanupStack::PushL( newCmName );
       
   342         iTitlePane->SetTextL( *newCmName );
       
   343         CleanupStack::PopAndDestroy( newCmName );
       
   344         
       
   345         retVal = ETrue;
       
   346         }
       
   347     CleanupStack::PopAndDestroy( &cmArray );
       
   348     CleanupStack::PopAndDestroy( settings );
       
   349     return retVal;
       
   350     }
       
   351 
       
   352 // --------------------------------------------------------------------------
       
   353 // CmPluginVpnSettingsDlg::ProcessCommandL
       
   354 // --------------------------------------------------------------------------
       
   355 //
       
   356 void CmPluginVpnSettingsDlg::ProcessCommandL( TInt aCommandId )
       
   357     {
       
   358     if ( MenuShowing() )
       
   359         {
       
   360         HideMenu();
       
   361         }
       
   362 
       
   363     switch ( aCommandId )
       
   364         {
       
   365         case EAknSoftkeyOk:
       
   366         case EPluginBaseCmdChange:
       
   367             {
       
   368             ShowPopupSettingPageL( 
       
   369                     iSettingIndex->At( iListbox->CurrentItemIndex() ), 
       
   370                                         aCommandId );
       
   371             break;            
       
   372             }
       
   373         case EVpnIapId:
       
   374         case ECmNextLayerIapId:
       
   375         case ECmProxyServerName:
       
   376         case ECmProxyPortNumber:
       
   377             {
       
   378             TInt attrib = iSettingIndex->At( iListbox->CurrentItemIndex() );
       
   379             ShowPopupSettingPageL( attrib, aCommandId );  
       
   380             break;
       
   381             }
       
   382         case EVpnServicePolicyName:
       
   383             {
       
   384             CmPluginVpnPolicySelectionDlg* dlg = 
       
   385                     CmPluginVpnPolicySelectionDlg::NewL( iCmPluginBaseEng );
       
   386             CleanupStack::PushL( dlg );
       
   387             if ( dlg->ShowPolicySelectionDlgL() )
       
   388                 {
       
   389                 // update the setting
       
   390                 UpdateListBoxContentL();
       
   391                 }
       
   392             // we might need to update even if not accepted
       
   393             
       
   394             CleanupStack::PopAndDestroy();
       
   395             break;
       
   396             }
       
   397         default:
       
   398             {
       
   399             CmPluginBaseSettingsDlg::ProcessCommandL( aCommandId );
       
   400             break;            
       
   401             }
       
   402         }
       
   403     }
       
   404 
       
   405 
       
   406 // --------------------------------------------------------------------------
       
   407 // CmPluginVpnSettingsDlg::CompulsoryFilledL
       
   408 // --------------------------------------------------------------------------
       
   409 //
       
   410 TBool CmPluginVpnSettingsDlg::CompulsoryFilledL()
       
   411     {
       
   412     LOGGER_ENTERFN( "CmPluginVpnSettingsDlg::CompulsoryFilledL" );
       
   413     
       
   414     TBool retval = ETrue;
       
   415     // compulsory settings are ECmName, EVpnIapId, EVpnServicePolicy
       
   416     
       
   417     // check name first
       
   418     HBufC* name = iCmPluginBaseEng.GetStringAttributeL( ECmName );
       
   419     if ( ( name->Compare( KNullDesC() ) ) == 0 )
       
   420         {
       
   421         retval = EFalse;
       
   422         }        
       
   423     delete name;
       
   424     
       
   425     // check VPN IAP ID
       
   426     TUint32 iapid = iCmPluginBaseEng.GetIntAttributeL( EVpnIapId );
       
   427     if ( !iapid )
       
   428         {
       
   429         TUint32 nextiapid = iCmPluginBaseEng.GetIntAttributeL( ECmNextLayerIapId  );
       
   430         TUint32 snapid = iCmPluginBaseEng.GetIntAttributeL( ECmNextLayerSNAPId );
       
   431         if ( !(nextiapid ^ snapid) )
       
   432             {
       
   433             retval = EFalse;
       
   434             }
       
   435         }
       
   436         
       
   437     // check policy
       
   438     HBufC* polId = iCmPluginBaseEng.GetStringAttributeL( EVpnServicePolicy );
       
   439     if ( ( polId->Compare( KNullDesC() ) ) == 0 )
       
   440         {
       
   441         retval = EFalse;
       
   442         }
       
   443     delete polId;
       
   444 
       
   445     // check policy name
       
   446     HBufC* polname = iCmPluginBaseEng.GetStringAttributeL( EVpnServicePolicyName );
       
   447     if ( ( polname->Compare( KNullDesC() ) ) == 0 )
       
   448         {
       
   449         retval = EFalse;
       
   450         }
       
   451     delete polname;
       
   452     
       
   453     return retval;
       
   454     }
       
   455 
       
   456 
       
   457 // --------------------------------------------------------------------------
       
   458 // CmPluginVpnSettingsDlg::OkToExitL
       
   459 // Good to know : EAknSoftkeyCancel is never called, because
       
   460 // EEikDialogFlagNotifyEsc flag is not set in the resource.
       
   461 // --------------------------------------------------------------------------
       
   462 //
       
   463 TBool CmPluginVpnSettingsDlg::OkToExitL( TInt aButtonId )
       
   464     {
       
   465     // Translate the button presses into commands for the appui & current
       
   466     // view to handle
       
   467     TBool retval( EFalse );
       
   468     
       
   469     switch ( aButtonId )
       
   470         {
       
   471         case EAknSoftkeyBack:
       
   472             {
       
   473             if ( CompulsoryFilledL() )
       
   474                 {
       
   475                 if( iIsPossibleToSaveSetting && iHasSettingChanged )
       
   476                 {
       
   477                     iCmPluginBaseEng.UpdateL();
       
   478                     iHasSettingChanged = EFalse;
       
   479                 }
       
   480                 retval = ETrue;
       
   481 
       
   482                 iCmPluginBaseEng.CmMgr().WatcherUnRegister();
       
   483                 }
       
   484             else
       
   485                 {
       
   486                 // If there are compulsory fields empty, a confirmation query
       
   487                 // Incomplete VPN access point details. Exit without saving?
       
   488                 // §qtn.vpn.quest.vpn.iap.incomplete.delete§ is displayed.
       
   489                 // show note that compulsory settings are not filled
       
   490                 TInt res = TCmCommonUi::ShowConfirmationQueryL( 
       
   491                                 R_QTN_VPN_QUEST_VPN_IAP_INCOMPLETE_DELETE );
       
   492                 if ( res )
       
   493                     { // quit without save
       
   494                     retval = ETrue;
       
   495                     TUint32 id = iCmPluginBaseEng.GetIntAttributeL( ECmId );
       
   496                     iCmPluginBaseEng.RestoreAttributeL( ECmName );
       
   497                     iCmPluginBaseEng.RestoreAttributeL( EVpnServicePolicyName );
       
   498                     // EVpnServicePolicy has been restored when EVpnServicePolicyName
       
   499                     // is restored.
       
   500                     //iCmPluginBaseEng.RestoreAttributeL( EVpnServicePolicy );
       
   501                     iCmPluginBaseEng.RestoreAttributeL( EVpnIapId );
       
   502                     iCmPluginBaseEng.RestoreAttributeL( ECmNextLayerIapId );
       
   503                     iCmPluginBaseEng.RestoreAttributeL( ECmNextLayerSNAPId );
       
   504                     iCmPluginBaseEng.RestoreAttributeL( ECmProxyServerName );
       
   505                     iCmPluginBaseEng.RestoreAttributeL( ECmProxyPortNumber );
       
   506                     
       
   507                     iCmPluginBaseEng.CmMgr().WatcherUnRegister();
       
   508                     }
       
   509                 else
       
   510                     { // do not save, reconfigure
       
   511                     retval = EFalse;                    
       
   512                     }
       
   513                 }
       
   514             break;
       
   515             }
       
   516         default:
       
   517             {
       
   518             if( aButtonId == EPluginBaseCmdExit )
       
   519                 {
       
   520                 iCmPluginBaseEng.CmMgr().WatcherUnRegister();
       
   521                 }
       
   522             
       
   523             retval = CmPluginBaseSettingsDlg::OkToExitL( aButtonId );
       
   524             break;
       
   525             }
       
   526         }
       
   527 
       
   528     return retval;
       
   529     }
       
   530     
       
   531 // --------------------------------------------------------------------------
       
   532 // CmPluginVpnSettingsDlg::GetHelpContext
       
   533 // --------------------------------------------------------------------------
       
   534 //
       
   535     
       
   536 void CmPluginVpnSettingsDlg::GetHelpContext( TCoeHelpContext& aContext ) const
       
   537     {
       
   538     LOGGER_ENTERFN( "CmPluginVpnSettingsDlg::GetHelpContext" );
       
   539     aContext.iMajor = KHelpUidPlugin;
       
   540     aContext.iContext = KSET_HLP_VPN_AP_SETTINGS_VIEW;
       
   541     }
       
   542 
       
   543 // --------------------------------------------------------------------------
       
   544 // CmPluginVpnSettingsDlg::CommsDatChangesL
       
   545 // --------------------------------------------------------------------------
       
   546 //
       
   547 void CmPluginVpnSettingsDlg::CommsDatChangesL()
       
   548     {
       
   549     CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
       
   550     CCmDestinationImpl* parentDest = iCmPluginBaseEng.ParentDestination();
       
   551 
       
   552     if ( parentDest )
       
   553         {
       
   554         if( !cmMgr.DestinationStillExistedL( parentDest ) )
       
   555             {
       
   556             cmMgr.WatcherUnRegister();
       
   557             // If parent destination diappears with some reason 
       
   558             // then the view must exit back to main view for it
       
   559             // may be danger if going back to parent view
       
   560             iExitReason = KDialogUserExit;
       
   561             TryExitL( iExitReason );
       
   562             
       
   563             cmMgr.RemoveDestFromPool( parentDest );
       
   564             delete parentDest;
       
   565             return;
       
   566             }
       
   567         
       
   568         if( !cmMgr.IsIapStillInDestL( parentDest, iCmPluginBaseEng ) )
       
   569             {
       
   570             cmMgr.WatcherUnRegister();
       
   571             // In this case, the view can go back to the parent view
       
   572             TryExitL( iExitReason );
       
   573             
       
   574             cmMgr.RemoveDestFromPool( parentDest );
       
   575             delete parentDest;
       
   576             return;            
       
   577             }
       
   578         
       
   579         // We may have to go back to parent view even though this Iap is still in CommsDat
       
   580         // for cmMgr ( = iCmPluginBaseEng.CmMgr() ) can not be accessed any more
       
   581         // after this call when some Iap is deleted.
       
   582         cmMgr.WatcherUnRegister();
       
   583         TryExitL( iExitReason );
       
   584         
       
   585         cmMgr.RemoveDestFromPool( parentDest );
       
   586         delete parentDest;
       
   587         }
       
   588     else
       
   589         {
       
   590         if( !cmMgr.IapStillExistedL( iCmPluginBaseEng ) )
       
   591             {
       
   592             cmMgr.WatcherUnRegister();
       
   593             // In this case, the dialog can go back to the parent view
       
   594             TryExitL( iExitReason );
       
   595             return;
       
   596             }
       
   597         
       
   598         // We may have to go back to parent view even though this Iap is still in CommsDat
       
   599         // for cmMgr ( = iCmPluginBaseEng.CmMgr() ) can not be accessed any more
       
   600         // after this call when some Iap is deleted.
       
   601         cmMgr.WatcherUnRegister();
       
   602         TryExitL( iExitReason );
       
   603         }
       
   604     }