cmmanager/cmmgr/Plugins/cmpluginpacketdata/src/cmppacketdatasettingsdlgadv.cpp
branchRCL_3
changeset 24 c45d4fe2ff0a
parent 0 5a93021fdf25
equal deleted inserted replaced
19:22c3c67e5001 24:c45d4fe2ff0a
    94 // CmPluginPacketDataSettingsDlgAdv::ConstructAndRunLD
    94 // CmPluginPacketDataSettingsDlgAdv::ConstructAndRunLD
    95 // --------------------------------------------------------------------------
    95 // --------------------------------------------------------------------------
    96 //
    96 //
    97 TInt CmPluginPacketDataSettingsDlgAdv::ConstructAndRunLD()
    97 TInt CmPluginPacketDataSettingsDlgAdv::ConstructAndRunLD()
    98     {
    98     {
       
    99     // Set this flag to allow edit continue
       
   100     iCanEditingContinue = ETrue;
       
   101     
    99     CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
   102     CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
   100     cmMgr.WatcherRegisterL( this );
   103     cmMgr.WatcherRegisterL( this );
   101     
   104     
   102     return CmPluginBaseSettingsDlgAdv::ConstructAndRunLD();
   105     return CmPluginBaseSettingsDlgAdv::ConstructAndRunLD();
   103     }
   106     }
   311 // CmPluginPacketDataSettingsDlgAdv::ProcessCommandL
   314 // CmPluginPacketDataSettingsDlgAdv::ProcessCommandL
   312 // --------------------------------------------------------------------------
   315 // --------------------------------------------------------------------------
   313 //
   316 //
   314 void CmPluginPacketDataSettingsDlgAdv::ProcessCommandL( TInt aCommandId )
   317 void CmPluginPacketDataSettingsDlgAdv::ProcessCommandL( TInt aCommandId )
   315     {
   318     {
       
   319     if ( !iCanEditingContinue )
       
   320         {
       
   321         // We have to block all editing activity if database changed by
       
   322         // other application
       
   323         return;
       
   324         }
       
   325 
   316     if ( MenuShowing() )
   326     if ( MenuShowing() )
   317         {
   327         {
   318         HideMenu();
   328         HideMenu();
   319         }
   329         }
   320 
   330     
   321     switch ( aCommandId )
   331     switch ( aCommandId )
   322         {
   332         {
   323         case EPluginBaseCmdExit:
   333         case EPluginBaseCmdExit:
   324             {
   334             {
   325             iExitReason = KDialogUserExit; //  flow to EAknSoftkeyBack
   335             iExitReason = KDialogUserExit; //  flow to EAknSoftkeyBack
   358 // CmPluginPacketDataSettingsDlgAdv::OkToExitL
   368 // CmPluginPacketDataSettingsDlgAdv::OkToExitL
   359 // --------------------------------------------------------------------------
   369 // --------------------------------------------------------------------------
   360 //
   370 //
   361 TBool CmPluginPacketDataSettingsDlgAdv::OkToExitL( TInt aButtonId )
   371 TBool CmPluginPacketDataSettingsDlgAdv::OkToExitL( TInt aButtonId )
   362     {
   372     {
       
   373     // Database has been changed by other application so exit from this view
       
   374     // without update editings to database
       
   375     if ( !iCanEditingContinue )
       
   376         {
       
   377         if ( iExitReason == KDialogUserExit )
       
   378             {
       
   379             iCmPluginBaseEng.CmMgr().WatcherUnRegister();
       
   380             
       
   381             // Set iExitReason back to KDialogUserBack so as to exit from this view through else in the next call
       
   382             TInt exitValue = KDialogUserExit;
       
   383             iExitReason = KDialogUserBack;
       
   384             // If destination has been deleted by other application
       
   385             // then we may have to exit from Cmmgr
       
   386             TryExitL( exitValue );
       
   387             return EFalse;
       
   388             }
       
   389         else
       
   390             {
       
   391             // Exit from this view here to avoid possible update to databse
       
   392             return ETrue;
       
   393             }
       
   394         }
       
   395     
   363     TBool retval( EFalse );
   396     TBool retval( EFalse );
   364     switch ( aButtonId )
   397     switch ( aButtonId )
   365         {
   398         {
   366         case EPluginBaseCmdExit:
   399         case EPluginBaseCmdExit:
   367         case EAknSoftkeyBack:
   400         case EAknSoftkeyBack:
   368             {
   401             {
   369             CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
   402             CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
   370             cmMgr.WatcherUnRegister();
   403             cmMgr.WatcherUnRegister();
   371             }
   404             
       
   405             iExitReason = KDialogUserBack;
       
   406             retval = ETrue;
       
   407             }
       
   408             break;
   372         default:
   409         default:
   373             {
   410             {
   374             retval = CmPluginBaseSettingsDlgAdv::OkToExitL( aButtonId );
   411             retval = CmPluginBaseSettingsDlgAdv::OkToExitL( aButtonId );
   375             break;
   412             break;
   376             }
   413             }
   412 // CmPluginPacketDataSettingsDlgAdv::CommsDatChangesL
   449 // CmPluginPacketDataSettingsDlgAdv::CommsDatChangesL
   413 // --------------------------------------------------------------------------
   450 // --------------------------------------------------------------------------
   414 //
   451 //
   415 void CmPluginPacketDataSettingsDlgAdv::CommsDatChangesL()
   452 void CmPluginPacketDataSettingsDlgAdv::CommsDatChangesL()
   416     {
   453     {
       
   454     if ( !iCanEditingContinue )
       
   455         {
       
   456         return;
       
   457         }
       
   458     
   417     CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
   459     CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
   418     CCmDestinationImpl* parentDest = iCmPluginBaseEng.ParentDestination();
   460     CCmDestinationImpl* parentDest = iCmPluginBaseEng.ParentDestination();
   419 
   461 
   420     if ( parentDest )
   462     if ( parentDest )
   421         {
   463         {
   424             if( iParent )
   466             if( iParent )
   425                 {
   467                 {
   426                 iParent->NotifyParentView( KCmNotifiedDestinationDisappear );
   468                 iParent->NotifyParentView( KCmNotifiedDestinationDisappear );
   427                 }
   469                 }
   428             
   470             
   429             cmMgr.WatcherUnRegister();
   471             iCanEditingContinue = EFalse;
   430             // If parent destination is deleted by somebody then the dialog must exit back to main view
       
   431             iExitReason = KDialogUserExit;
   472             iExitReason = KDialogUserExit;
   432             TryExitL( iExitReason );
       
   433             
   473             
   434             cmMgr.RemoveDestFromPool( parentDest );
   474             cmMgr.RemoveDestFromPool( parentDest );
   435             delete parentDest;
   475             delete parentDest;
   436             return;
   476             return;
   437             }
   477             }
   438         
   478 
   439         if( !cmMgr.IsIapStillInDestL( parentDest, iCmPluginBaseEng ) )
   479         // We may have to go back to parent view if database is changed by other application
   440             {
       
   441             if( iParent )
       
   442                 {
       
   443                 iParent->NotifyParentView( KCmNotifiedIapIsNotInThisDestination );
       
   444                 }
       
   445             
       
   446             cmMgr.WatcherUnRegister();
       
   447             // In this case, the dialog can go back to the parent view
       
   448             TryExitL( iExitReason );
       
   449             
       
   450             cmMgr.RemoveDestFromPool( parentDest );
       
   451             delete parentDest;
       
   452             return;
       
   453             }
       
   454         
       
   455         // We may have to notify parent view to go back to its parent view even though this Iap is still in CommsDat
       
   456         // for cmMgr ( = iCmPluginBaseEng.CmMgr() ) can not be accessed any more
       
   457         // after this call when some Iap is deleted.
       
   458         if( iParent )
   480         if( iParent )
   459             {
   481             {
   460             iParent->NotifyParentView( KCmNotifiedIapDisappear );
   482             iParent->NotifyParentView( KCmNotifiedIapDisappear );
   461             }
   483             }
   462         cmMgr.WatcherUnRegister();
   484         iCanEditingContinue = EFalse;
   463         TryExitL( iExitReason );
   485 
   464         
       
   465         cmMgr.RemoveDestFromPool( parentDest );
   486         cmMgr.RemoveDestFromPool( parentDest );
   466         delete parentDest;
   487         delete parentDest;
   467         }
   488         }
   468     else
   489     else // Legacy
   469         {
   490         {
   470         if( !cmMgr.IapStillExistedL(iCmPluginBaseEng) )
   491         // We may have to go back to parent view if database is changed by other application
   471             {
       
   472             if( iParent )
       
   473                 {
       
   474                 iParent->NotifyParentView( KCmNotifiedIapDisappear );
       
   475                 }
       
   476             
       
   477             cmMgr.WatcherUnRegister();
       
   478             // In this case, the dialog can go back to the parent view
       
   479             TryExitL( iExitReason );
       
   480             return;
       
   481             }
       
   482         
       
   483         // We may have to notify parent view to go back to its parent view even though this Iap is still in CommsDat
       
   484         // for cmMgr ( = iCmPluginBaseEng.CmMgr() ) can not be accessed any more
       
   485         // after this call when some Iap is deleted.
       
   486         if( iParent )
   492         if( iParent )
   487             {
   493             {
   488             iParent->NotifyParentView( KCmNotifiedIapDisappear );
   494             iParent->NotifyParentView( KCmNotifiedIapDisappear );
   489             }
   495             }
   490         cmMgr.WatcherUnRegister();
   496         iCanEditingContinue = EFalse;
   491         TryExitL( iExitReason );
   497         }
   492         }
   498     }
   493     }