coreapplicationuis/Rfs/src/rfsConnectionObserver.cpp
branchRCL_3
changeset 18 0818dd463d41
parent 0 2e3d3ce01487
child 19 924385140d98
equal deleted inserted replaced
17:5e7d68cc22e0 18:0818dd463d41
     1 /*
     1 /*
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    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 #include <AknWaitDialog.h>
    23 
    24 #include <featmgr.h>
    24 #include <featmgr.h>
    25 #include <centralrepository.h>
    25 #include <centralrepository.h>
    26 #include <AknWaitDialog.h>
       
    27 #include <pdpcontextmanagerpskeys.h>
    26 #include <pdpcontextmanagerpskeys.h>
    28 #include <pdpcontextmanagerinternalcrkeys.h>
    27 #include <pdpcontextmanagerinternalcrkeys.h>
    29 
    28 
    30 // P&S KEYS FROM SIP & PDP CONNECTION
       
    31 #include <e32property.h>
       
    32 #include <pdpcontextmanagerpskeys.h>
       
    33 #include <sipsystemstatemonitorpskeys.h>
       
    34 
    29 
    35 // USER INCLUDES
    30 // USER INCLUDES
    36 #include "rfsConnectionObserver.h"
    31 #include "rfsConnectionObserver.h"
    37 #include "RfsTraces.h"
    32 #include "RfsTraces.h"
    38 
    33 
   139     if (iIsSIPConnectionsPresent || iIsPDPFeatureEnabled)
   134     if (iIsSIPConnectionsPresent || iIsPDPFeatureEnabled)
   140         {
   135         {
   141         Subscribe();
   136         Subscribe();
   142         }
   137         }
   143     
   138     
       
   139     // Create the Timer Active Object
       
   140     iRfsConTimer = CRfsConTimer :: NewL(this);
       
   141     
   144     TRACES("CRfsConnectionObserver::ConstructL(): End");
   142     TRACES("CRfsConnectionObserver::ConstructL(): End");
   145     }
   143     }
   146 
   144 
   147 // ---------------------------------------------------------------------------
   145 // ---------------------------------------------------------------------------
   148 // C++ constructor
   146 // C++ constructor
   168 // C++ destructor
   166 // C++ destructor
   169 // ---------------------------------------------------------------------------
   167 // ---------------------------------------------------------------------------
   170 CRfsConnectionObserver::~CRfsConnectionObserver()
   168 CRfsConnectionObserver::~CRfsConnectionObserver()
   171     {
   169     {
   172     TRACES("CRfsConnectionObserver::~CRfsConnectionObserver()");
   170     TRACES("CRfsConnectionObserver::~CRfsConnectionObserver()");
       
   171     
       
   172     if(iRfsConTimer)
       
   173         {
       
   174         delete iRfsConTimer;
       
   175         }
   173     Cancel();
   176     Cancel();
   174     TRACES("CRfsConnectionObserver::~CRfsConnectionObserver(): End");
   177     TRACES("CRfsConnectionObserver::~CRfsConnectionObserver(): End");
   175     }
   178     }
   176 
   179 
   177 // ---------------------------------------------------------------------------
   180 // ---------------------------------------------------------------------------
   188         }
   191         }
   189 
   192 
   190     // only perform the following operation if the 'iIsClosingConnectionsApplicable' is ETrue 
   193     // only perform the following operation if the 'iIsClosingConnectionsApplicable' is ETrue 
   191     iAllConnectionClosed = EFalse;
   194     iAllConnectionClosed = EFalse;
   192       
   195       
   193     // Send P&S notification to SIP that RFS has started
       
   194     TInt err(KErrNone);
   196     TInt err(KErrNone);
   195     if (iIsSIPConnectionsPresent && iState == ESipConnectionClose)
   197     if (iIsSIPConnectionsPresent && iState == ESipConnectionClose)
   196         {
   198         {
       
   199         // Send P&S notification to SIP that RFS has started and start the timer
       
   200    
   197         err = iSIPProperty.Set(KPSSipRfsUid, KSipRfsState, ESipRfsStarted );
   201         err = iSIPProperty.Set(KPSSipRfsUid, KSipRfsState, ESipRfsStarted );
       
   202         iRfsConTimer->IssueTimerRequest();
   198         iIsSipInformedForClosingAllConnection = ETrue;
   203         iIsSipInformedForClosingAllConnection = ETrue;
   199         }
   204         }
   200     else if (iIsPDPFeatureEnabled && iState == EPdpConnectionClose)
   205     else if (iIsPDPFeatureEnabled && iState == EPdpConnectionClose)
   201         {
   206         {
       
   207         // Send P&S notification to PDP that RFS has started and start the timer
       
   208     
   202         err = iPDPProperty.Set(KPDPContextManager2,KPDPContextManagerFactorySettingsReset,EPDPContextManagerFactorySettingsResetStart );
   209         err = iPDPProperty.Set(KPDPContextManager2,KPDPContextManagerFactorySettingsReset,EPDPContextManagerFactorySettingsResetStart );
       
   210         iRfsConTimer->IssueTimerRequest();
   203         iIsPDPInformedforClosingAllConnection = ETrue;
   211         iIsPDPInformedforClosingAllConnection = ETrue;
   204         }
   212         }
   205     
   213     
   206     
   214     
   207     // 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
   208     // 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
   209     User::LeaveIfError(err);
   217     User::LeaveIfError(err);
   210     if(err != KErrNone)
       
   211         {
       
   212         TRACES1("CRfsConnectionObserver::CloseAlwaysOnConnectionL(): Err = %d", err);
       
   213         // This means that the RFS has failed
       
   214         return EFalse; 
       
   215         }
       
   216     
   218     
   217     // we set the flag to indicate ExecuteLD is called and the dialog needs to be
   219     // we set the flag to indicate ExecuteLD is called and the dialog needs to be
   218     // dismissed from within the RunL()
   220     // dismissed from within the RunL()
   219     iIsWaitForDialogExecuted = ETrue;
   221     iIsWaitForDialogExecuted = ETrue;
   220     // 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()
   233             err = iSIPProperty.Set(KPSSipRfsUid, KSipRfsState, ESipRfsFailed );
   235             err = iSIPProperty.Set(KPSSipRfsUid, KSipRfsState, ESipRfsFailed );
   234             }
   236             }
   235         if (iIsPDPInformedforClosingAllConnection)
   237         if (iIsPDPInformedforClosingAllConnection)
   236             {
   238             {
   237             iPDPProperty.Set(KPDPContextManager2,KPDPContextManagerFactorySettingsReset,EPDPContextManagerFactorySettingsResetStop);
   239             iPDPProperty.Set(KPDPContextManager2,KPDPContextManagerFactorySettingsReset,EPDPContextManagerFactorySettingsResetStop);
       
   240             }
       
   241         if(iRfsConTimer)
       
   242             {
       
   243             // Cancel the Active timer if the user cancel the Rfs operation
       
   244             iRfsConTimer->Cancel();
   238             }
   245             }
   239         }
   246         }
   240     return iAllConnectionClosed;
   247     return iAllConnectionClosed;
   241     }
   248     }
   242 
   249 
   314                 {
   321                 {
   315                 if (iIsWaitForDialogExecuted && !iIsPDPFeatureEnabled)
   322                 if (iIsWaitForDialogExecuted && !iIsPDPFeatureEnabled)
   316                     {
   323                     {
   317                     // set the information that we have closed all the active connections
   324                     // set the information that we have closed all the active connections
   318                     // here itself because the PDP connection/feature doen't exist
   325                     // here itself because the PDP connection/feature doen't exist
       
   326                     // Cancel the outstanding timer request
   319                     iAllConnectionClosed = ETrue;
   327                     iAllConnectionClosed = ETrue;
       
   328                     iRfsConTimer->Cancel();
   320                     DismissWaitDialog();
   329                     DismissWaitDialog();
   321                     }
   330                     }
   322                 
   331                 
   323                 if (iIsPDPFeatureEnabled)
   332                 if (iIsPDPFeatureEnabled)
   324                     {
   333                     {
   325                     iPDPProperty.Set(KPDPContextManager2,KPDPContextManagerFactorySettingsReset,EPDPContextManagerFactorySettingsResetStart );
   334                     iPDPProperty.Set(KPDPContextManager2,KPDPContextManagerFactorySettingsReset,EPDPContextManagerFactorySettingsResetStart );
   326                     
   335                     
   327                     // change the state to the next from within this as we are done with closing the SIP connection
   336                     // change the state to the next from within this as we are done with closing the SIP connection
   328                     iState = EPdpConnectionClose;
   337                     // Cancel the Outstanding SIP  and timer request
       
   338                     // Subscribe to PDP  and start the timer
       
   339                     Cancel();
       
   340                     iRfsConTimer->Cancel();
       
   341                     iState = EPdpConnectionClose;                                        
       
   342                     Subscribe(); 
       
   343                     iRfsConTimer->IssueTimerRequest();
       
   344                                         
   329                     //
   345                     //
   330                     // Under following cases the 'iIsPDPInformedforClosingAllConnection' will be set
   346                     // Under following cases the 'iIsPDPInformedforClosingAllConnection' will be set
   331                     //
   347                     //
   332                     // CASE 1:
   348                     // CASE 1:
   333                     //          When from within CloseAlwaysOnConnectionL we inform the PDP to 
   349                     //          When from within CloseAlwaysOnConnectionL we inform the PDP to 
   364                 {
   380                 {
   365                 // The response from PDP of closing all its connections have been recieved 
   381                 // The response from PDP of closing all its connections have been recieved 
   366                 // 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 
   367                 // all active connections closed
   383                 // all active connections closed
   368                 iAllConnectionClosed = ETrue;
   384                 iAllConnectionClosed = ETrue;
       
   385                 iRfsConTimer->Cancel();                                    
   369                 DismissWaitDialog();
   386                 DismissWaitDialog();
   370                 }
   387                 }                        
   371             }
   388             }
   372         } // end switch-case block
   389         } // end switch-case block
   373     }
   390     }
   374 
   391 
   375 
   392 
   398 // ---------------------------------------------------------------------------
   415 // ---------------------------------------------------------------------------
   399 void CRfsConnectionObserver::DoCancel()
   416 void CRfsConnectionObserver::DoCancel()
   400     {
   417     {
   401     TRACES("CRfsConnectionObserver::DoCancel()");
   418     TRACES("CRfsConnectionObserver::DoCancel()");
   402     
   419     
   403     if(iIsPDPFeatureEnabled)
   420     if(iIsSIPConnectionsPresent && iState == ESipConnectionClose)
       
   421         {
       
   422         iSIPProperty.Cancel();
       
   423         if(!iIsPDPFeatureEnabled)
       
   424             {
       
   425             DismissWaitDialog();
       
   426             }
       
   427         }
       
   428     if(iIsPDPFeatureEnabled && iState == EPdpConnectionClose)
   404         {
   429         {
   405         iPDPProperty.Cancel();
   430         iPDPProperty.Cancel();
   406         }
   431         DismissWaitDialog();            
   407     if(iIsSIPConnectionsPresent)
   432         }
   408         {
       
   409         iSIPProperty.Cancel();
       
   410         }
       
   411 
       
   412     DismissWaitDialog();
       
   413     
       
   414     TRACES("CRfsConnectionObserver::DoCancel(): End");
   433     TRACES("CRfsConnectionObserver::DoCancel(): End");
   415     }
   434     }
   416 
   435 
   417 // ---------------------------------------------------------------------------
   436 // ---------------------------------------------------------------------------
   418 // CRfsConnectionObserver::Subscribe
   437 // CRfsConnectionObserver::Subscribe