coreapplicationuis/Rfs/src/rfsConnectionObserver.cpp
branchRCL_3
changeset 19 924385140d98
parent 18 0818dd463d41
child 20 c2c61fdca848
equal deleted inserted replaced
18:0818dd463d41 19:924385140d98
    18 */
    18 */
    19 
    19 
    20 // SYSTEM INCLUDES
    20 // SYSTEM INCLUDES
    21 #include <rfs.rsg>                      
    21 #include <rfs.rsg>                      
    22 #include <PSVariables.h>
    22 #include <PSVariables.h>
    23 
       
    24 #include <featmgr.h>
    23 #include <featmgr.h>
       
    24 #include <eikenv.h>  
    25 #include <centralrepository.h>
    25 #include <centralrepository.h>
    26 #include <pdpcontextmanagerpskeys.h>
       
    27 #include <pdpcontextmanagerinternalcrkeys.h>
    26 #include <pdpcontextmanagerinternalcrkeys.h>
       
    27 #include <StringLoader.h> 
       
    28 
    28 
    29 
    29 
    30 
    30 // USER INCLUDES
    31 // USER INCLUDES
    31 #include "rfsConnectionObserver.h"
    32 #include "rfsConnectionObserver.h"
    32 #include "RfsTraces.h"
    33 #include "RfsTraces.h"
   104     
   105     
   105     // After finding out which type of connections need RFS notifications, we will 
   106     // After finding out which type of connections need RFS notifications, we will 
   106     // proceed further to create a common dialog. This will be a wait for dialog which will be 
   107     // proceed further to create a common dialog. This will be a wait for dialog which will be 
   107     // of synchrnous type and can only be closed inside the RunL() of this active class.
   108     // of synchrnous type and can only be closed inside the RunL() of this active class.
   108     // Provisions needed to be added to know whether this dialog needs resetting the pointer,
   109     // Provisions needed to be added to know whether this dialog needs resetting the pointer,
   109     // this will be the case when dialog is actually started using 'ExecuteLD()', 
   110     // this will be the case when dialog is actually started using 'showl()', 
   110     // Otherwise we need to delete this dialog and reset the pointer to NULL.
   111     // Otherwise we need to delete this dialog and reset the pointer to NULL.
   111     if (iIsDialogNeedToBeDisplayed)
   112    if (iIsDialogNeedToBeDisplayed)
   112         {
   113        {
   113         iWaitDialog = new( ELeave ) CAknWaitDialog(reinterpret_cast<CEikDialog**>( &iWaitDialog ) );
   114        iDialog = CHbDeviceProgressDialogSymbian::NewL(CHbDeviceProgressDialogSymbian::EWaitDialog);
   114         }
   115        }
   115    
   116    
   116     // Now we proceed further to setting of the next state i,e, enter the state machine of this active object
   117     // Now we proceed further to setting of the next state i,e, enter the state machine of this active object
   117     // which will start from closing of the active connections and proceed to close the other connections
   118     // which will start from closing of the active connections and proceed to close the other connections
   118     // serially in a state wise manner.
   119     // serially in a state wise manner.
   119     // N.B the states are put in order and should be maintained. High Priority
   120     // N.B the states are put in order and should be maintained. High Priority
   172     if(iRfsConTimer)
   173     if(iRfsConTimer)
   173         {
   174         {
   174         delete iRfsConTimer;
   175         delete iRfsConTimer;
   175         }
   176         }
   176     Cancel();
   177     Cancel();
       
   178     delete iWait;
   177     TRACES("CRfsConnectionObserver::~CRfsConnectionObserver(): End");
   179     TRACES("CRfsConnectionObserver::~CRfsConnectionObserver(): End");
   178     }
   180     }
   179 
   181 
   180 // ---------------------------------------------------------------------------
   182 // ---------------------------------------------------------------------------
   181 // CRfsConnectionObserver::CloseAlwaysOnConnectionL
   183 // CRfsConnectionObserver::CloseAlwaysOnConnectionL
   214     
   216     
   215     // Leave from here is there is any error setting the intial handshake information
   217     // Leave from here is there is any error setting the intial handshake information
   216     // This means that RFS has failed as there was some problem setting the P&S keys
   218     // This means that RFS has failed as there was some problem setting the P&S keys
   217     User::LeaveIfError(err);
   219     User::LeaveIfError(err);
   218     
   220     
   219     // we set the flag to indicate ExecuteLD is called and the dialog needs to be
   221     // we set the flag to indicate showl is called and the dialog needs to be
   220     // dismissed from within the RunL()
   222     // dismissed from within the RunL()
   221     iIsWaitForDialogExecuted = ETrue;
   223     iIsWaitForDialogExecuted = ETrue;
   222     // Start displaying the dialog which will then be closed form the RunL()
   224     // Start displaying the dialog which will then be closed form the RunL()
   223     // Here the code execution blocks and we will proceed further only when 
   225     // Here the code execution blocks and we will proceed further only when 
   224     // this dialog is canceled
   226     // this dialog is canceled
   225     err = iWaitDialog->ExecuteLD( R_CLOSING_CONNECTIONS );
   227 
   226     
   228     HBufC* prompt = StringLoader::LoadLC( R_CLOSING_CONNECTIONS ); 
   227     
   229     
       
   230     iDialog->SetTextL(*prompt);
       
   231              
       
   232     //observer interface is used since showl is aynchronous and we have to have callbacks 
       
   233     //if cancel is pressed or dialog is closed
       
   234     iDialog->SetObserver(this);   
       
   235     iDialog->ShowL();
       
   236     //activeschedulerwait is used since we want synchronous execution and control goes into 
       
   237     //a loop here and returns to start when dialog is cancelled or closed.              
       
   238     iWait = new (ELeave) CActiveSchedulerWait;
       
   239     iWait->Start();
       
   240     delete iWait;
       
   241     iWait=NULL;
       
   242     CleanupStack::PopAndDestroy( prompt );
       
   243               
       
   244     return iAllConnectionClosed;
       
   245      }
       
   246 
       
   247 void CRfsConnectionObserver::ProgressDialogCancelled(const CHbDeviceProgressDialogSymbian* iDialog)
       
   248 {
   228     // following is the case when the user presses the Cancel button from the wait 
   249     // following is the case when the user presses the Cancel button from the wait 
   229     // for dialog and in that case we need to resend the notificaiton of RFS failed
   250     // for dialog and in that case we need to resend the notificaiton of RFS failed
   230     // to whom all we have told previous of this to close the RFS connection
   251     // to whom all we have told previous of this to close the RFS connection 
   231     if (err == EEikBidCancel)
   252     
   232         {
   253     if (iIsSipInformedForClosingAllConnection)
   233         if (iIsSipInformedForClosingAllConnection)
   254                 {
   234             {
   255              TInt    err = iSIPProperty.Set(KPSSipRfsUid, KSipRfsState, ESipRfsFailed );
   235             err = iSIPProperty.Set(KPSSipRfsUid, KSipRfsState, ESipRfsFailed );
   256                 }
   236             }
   257     if (iIsPDPInformedforClosingAllConnection)
   237         if (iIsPDPInformedforClosingAllConnection)
   258                 {
   238             {
   259                 iPDPProperty.Set(KPDPContextManager2,KPDPContextManagerFactorySettingsReset,EPDPContextManagerFactorySettingsResetStop);
   239             iPDPProperty.Set(KPDPContextManager2,KPDPContextManagerFactorySettingsReset,EPDPContextManagerFactorySettingsResetStop);
   260                 }
   240             }
   261     if(iRfsConTimer)
   241         if(iRfsConTimer)
       
   242             {
   262             {
   243             // Cancel the Active timer if the user cancel the Rfs operation
   263             // Cancel the Active timer if the user cancel the Rfs operation
   244             iRfsConTimer->Cancel();
   264             iRfsConTimer->Cancel();
   245             }
   265             }        
   246         }
   266 }
   247     return iAllConnectionClosed;
   267 
   248     }
   268 
       
   269 void CRfsConnectionObserver::ProgressDialogClosed(const CHbDeviceProgressDialogSymbian *  iDialog)
       
   270 {
       
   271     //this function is called when the dialog is closed ,note that the control from progressdialogcancelled  
       
   272     //comes to ProgressDialogClosed once dialog is closed
       
   273       iWait->AsyncStop(); //from here the control goes to iWait->start();
       
   274 }
       
   275 
   249 
   276 
   250 void CRfsConnectionObserver::ReportRfsCompletionToSip()
   277 void CRfsConnectionObserver::ReportRfsCompletionToSip()
   251     {
   278     {
   252     TRACES("CRfsConnectionObserver::ReportRfsCompletionToSip()");
   279     TRACES("CRfsConnectionObserver::ReportRfsCompletionToSip()");
   253     
   280     
   382                 // Now we may proceed to dsmiss the dialog and also set the state to the True for 
   409                 // Now we may proceed to dsmiss the dialog and also set the state to the True for 
   383                 // all active connections closed
   410                 // all active connections closed
   384                 iAllConnectionClosed = ETrue;
   411                 iAllConnectionClosed = ETrue;
   385                 iRfsConTimer->Cancel();                                    
   412                 iRfsConTimer->Cancel();                                    
   386                 DismissWaitDialog();
   413                 DismissWaitDialog();
   387                 }                        
   414                 }
   388             }
   415             }
   389         } // end switch-case block
   416         } // end switch-case block
   390     }
   417     }
   391 
   418 
   392 
   419 
   460 // ---------------------------------------------------------------------------
   487 // ---------------------------------------------------------------------------
   461 void CRfsConnectionObserver::DismissWaitDialog()
   488 void CRfsConnectionObserver::DismissWaitDialog()
   462     {
   489     {
   463     TRACES("CRfsConnectionObserver::DismissWaitDialog()");
   490     TRACES("CRfsConnectionObserver::DismissWaitDialog()");
   464     
   491     
   465     if ( iWaitDialog && iIsWaitForDialogExecuted)
   492     if ( iDialog && iIsWaitForDialogExecuted)
   466         {
   493         {
   467         TRAP_IGNORE( iWaitDialog->ProcessFinishedL() );
   494         iDialog->Close();
   468         }
   495         }
   469     
   496     
   470     // Sanity Check:
   497     // Sanity Check:
   471     // It can be a case when dialog was need to be displayed but was not due to some error
   498     // It can be a case when dialog was need to be displayed but was not due to some error
   472     // this means that the 'iWaitDialog' was constructed but never used and destroyed
   499     // this means that the 'iDialog' was constructed but never used and destroyed
   473     // i.e. the ExecuteLD() was never called
   500     // i.e. the showl() was never called
   474     else if(iIsDialogNeedToBeDisplayed && !iIsWaitForDialogExecuted)
   501    else if(iIsDialogNeedToBeDisplayed && !iIsWaitForDialogExecuted)
   475         {
   502         {
   476         delete iWaitDialog;
   503         delete iDialog;
   477         }
   504         }
   478     
   505       // Reset the pointer to NULL
   479     // Reset the pointer to NULL
   506     iDialog = NULL;
   480     iWaitDialog = NULL;
       
   481     
   507     
   482     TRACES("CRfsConnectionObserver::DismissWaitDialog(): End");
   508     TRACES("CRfsConnectionObserver::DismissWaitDialog(): End");
   483     }
   509     }
   484 
   510