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