realtimenetprots/sipfw/ProfileAgent/profile_fsm/src/sipprflregisterdelayrequestedstate.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Name        : sipprflregisterdelayrequested.cpp
       
    15 // Part of     : sip profile fsm
       
    16 // implementation
       
    17 // Version     : %version: 3.1.1 %
       
    18 //
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include	"sipprflregisterdelayrequestedstate.h"
       
    24 #include	"sipconcreteprofile.h"
       
    25 #include	"sipmessageelements.h"
       
    26 #include	"sipregistrationbinding.h"
       
    27 #include	"sipconnection.h"
       
    28 #include	"sipclienttransaction.h"
       
    29 #include	"sipprofileagentobserver.h"
       
    30 #include    "SipProfileLog.h"
       
    31 #include    "sipprofilefsmuser.h"
       
    32 
       
    33 
       
    34 // ============================ MEMBER FUNCTIONS ===============================
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CSIPPrflRegisterDelayRequestedState::NewL()
       
    38 // (other items were commented in a header).
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 EXPORT_C CSIPPrflRegisterDelayRequestedState* 
       
    42 CSIPPrflRegisterDelayRequestedState::NewL(MSIPProfileFSMUser& aUser)
       
    43 	{
       
    44 	return new (ELeave) CSIPPrflRegisterDelayRequestedState(aUser);
       
    45 	}
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CSIPPrflRegisterDelayRequestedState::CSIPPrflRegisterDelayRequestedState()
       
    49 // (other items were commented in a header).
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 CSIPPrflRegisterDelayRequestedState::CSIPPrflRegisterDelayRequestedState(
       
    53     MSIPProfileFSMUser& aUser)
       
    54     : CSIPPrflStateBase(aUser,MSIPProfileContext::EDelayedRegisterRequested)
       
    55 	{
       
    56 	}
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CSIPPrflRegisterDelayRequestedState::~CSIPPrflRegisterDelayRequestedState()
       
    60 // (other items were commented in a header).
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 EXPORT_C CSIPPrflRegisterDelayRequestedState::~CSIPPrflRegisterDelayRequestedState()
       
    64 	{
       
    65 	}
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CSIPPrflRegisterDelayRequestedState::LinkStates()
       
    69 // (other items were commented in a header).
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 EXPORT_C void CSIPPrflRegisterDelayRequestedState::LinkStates(
       
    73     CSIPPrflStateBase& aInitState)
       
    74 	{
       
    75 	iInitState = &aInitState;
       
    76 	}
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CSIPPrflRegisterDelayRequestedState::ConcreteProfileState()
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 CSIPConcreteProfile::TStatus 
       
    83 CSIPPrflRegisterDelayRequestedState::ConcreteProfileState() const
       
    84     {
       
    85     return CSIPConcreteProfile::ERegistrationInProgress;
       
    86     }
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // CSIPPrflRegisterDelayRequestedState::DeregisterL()
       
    90 // (other items were commented in a header).
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 void CSIPPrflRegisterDelayRequestedState::DeregisterL(
       
    94 	MSIPProfileContext& aContext)
       
    95 	{
       
    96 	PROFILE_DEBUG1("CSIPPrflRegisterDelayRequestedState::DeregisterL")
       
    97 	__ASSERT_DEBUG(aContext.Profile()!=0, User::Invariant());
       
    98 	
       
    99 	CSIPConcreteProfile& profile = *aContext.Profile();
       
   100 	TUint32 contextId = 0;
       
   101 	
       
   102 	aContext.ForgetProfile();
       
   103 	
       
   104 	// aContext.ForgetProfile() does not set profile to NULL since
       
   105 	// iRetryPossible is ETrue. so must set profile to NULL here.
       
   106 	// because soon the profile will be deleted from function
       
   107 	// aItem.ClearOldProfile
       
   108     aContext.SetProfile(NULL);
       
   109     aContext.SetTransaction(NULL);	
       
   110 	aContext.RemoveDeltaTimerEntry();
       
   111 	
       
   112 	CSIPRegistrationBinding* regBinding = aContext.Registration();
       
   113 	if ( regBinding )
       
   114 	    {
       
   115 	    contextId = aContext.Registration()->ContextId();
       
   116 	    aContext.DestroyRegistration();
       
   117 	    }
       
   118 	    
       
   119 	aContext.SetNextState(*iInitState);
       
   120 	aContext.AgentObserver().SIPProfileStatusEvent(profile,contextId);
       
   121 	}
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // CSIPPrflRegisterDelayRequestedState::ChangeRegistrationStateL()
       
   125 // (other items were commented in a header).
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 void CSIPPrflRegisterDelayRequestedState::ChangeRegistrationStateL(
       
   129 	MSIPProfileContext& aContext)
       
   130 	{
       
   131 	PROFILE_DEBUG1(
       
   132 	    "CSIPPrflRegisterDelayRequestedState::ChangeRegistrationStateL")
       
   133 	TUint32	contextId(0);
       
   134 	CSIPConcreteProfile& profile = DoCleanup(aContext,contextId);
       
   135 	aContext.SetNextState(*iInitState);
       
   136 	iUser.RetryProfileRegistrationL(profile);
       
   137 	}
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // CSIPPrflRegisterDelayRequestedState::RegisterL()
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 void CSIPPrflRegisterDelayRequestedState::RegisterL(
       
   144 					MSIPProfileContext& aContext)
       
   145 	{
       
   146 	aContext.Connection().RefreshConnection();	
       
   147 	}
       
   148 
       
   149 void CSIPPrflRegisterDelayRequestedState::ConnectionStateChanged(
       
   150 		MSIPProfileContext& aContext,CSIPConnection::TState aState)
       
   151 	{
       
   152 	switch(aState)
       
   153  		{
       
   154 		case CSIPConnection::EActive:
       
   155 			{
       
   156 			aContext.RemoveDeltaTimerEntry();
       
   157 			TRAPD(err, ChangeRegistrationStateL(aContext));		
       
   158 			if (err)
       
   159 				{
       
   160 				HandleError(aContext, err, iInitState);
       
   161 				}
       
   162 			break;
       
   163 			}
       
   164 		/* When State EUnavailable is received, the registration Binding in the SIPStack 
       
   165 		 * is no longer present. Hence we have to do the cleanup here and propagate the 
       
   166 		 * error back to clients of profiles.
       
   167 		 */
       
   168 		case CSIPConnection::EUnavailable:
       
   169 			{
       
   170 			HandleError(aContext, KErrCouldNotConnect, iInitState);
       
   171 			break;
       
   172 			}
       
   173 		default:break;
       
   174 		}
       
   175 
       
   176 	}