realtimenetprots/sipfw/SIP/sipapi/src/registering.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2006-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          : registering.cpp
       
    15 // Part of       : SIPAPI
       
    16 // Version       : SIP/5.0 
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 #include "SipAssert.h"
       
    22 #include "registering.h"
       
    23 #include "RegBindingImplementation.h"
       
    24 #include "sipclienttransaction.h"
       
    25 #include "sipresponseelements.h"
       
    26 #include "sipconnectioncallback.h"
       
    27 
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CRegistering::NewL
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CRegistering* CRegistering::NewL()
       
    34 	{
       
    35 	return new (ELeave) CRegistering();
       
    36 	}
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CRegistering::CRegistering
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 CRegistering::CRegistering()
       
    43 	{
       
    44 	}
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CRegistering::~CRegistering
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 CRegistering::~CRegistering()
       
    51 	{
       
    52 	}
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CRegistering::SetNeighbourStates
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 void CRegistering::SetNeighbourStates(CRegistrationState& aRegistered,
       
    59 							          CRegistrationState& aUnregistered)                                      
       
    60     {    
       
    61     iRegistered = &aRegistered;
       
    62     iUnregistered = &aUnregistered;
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CRegistering::IncomingResponseL
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 TBool CRegistering::IncomingResponseL(CRegBindingImplementation& aRegistration,
       
    70                                       CSIPResponseElements* aElements,
       
    71 		                              TUint32 aRequestId,
       
    72 				                      TUint32 aRegistrationId,
       
    73 				                      TUint32 aRefreshId,
       
    74                                       CConnectionCallback& aCallback) const
       
    75     {
       
    76     CSIPClientTransaction* ta = aRegistration.FindTransaction(aRequestId);
       
    77     if (ta)
       
    78         {
       
    79         TUint statusCode = aElements->StatusCode();
       
    80 
       
    81 		if (aRegistration.SIPRefresh())
       
    82 			{
       
    83 			aRegistration.SIPRefresh()->SetRefreshIdIfEmpty(aRefreshId);
       
    84 			}
       
    85 
       
    86         if (statusCode >= 200 && statusCode < 300)
       
    87             {
       
    88             aRegistration.SetRegistrationId(aRegistrationId);
       
    89             aRegistration.UpdateRegisteredContactL();
       
    90             aRegistration.ChangeState(iRegistered);
       
    91             }
       
    92 
       
    93         if (statusCode >= 300)
       
    94             {
       
    95             aRegistration.ChangeState(iUnregistered);
       
    96             }
       
    97             
       
    98         // Set response elements after calling all the leaving functions    
       
    99         ta->SetResponseElements(aElements); 
       
   100 
       
   101         aCallback.Set(CConnectionCallback::EIncomingResponseInRegistration,
       
   102                       ta,
       
   103                       &aRegistration.Binding());
       
   104         return ETrue;
       
   105         }
       
   106     
       
   107     delete aElements;
       
   108     return EFalse;
       
   109     }
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CRegistering::ErrorOccured
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 TBool CRegistering::ErrorOccured(CRegBindingImplementation& aRegistration,
       
   116                                  TInt aError,
       
   117                                  TUint32 aRequestId,
       
   118                                  CConnectionCallback& aCallback) const
       
   119     {    
       
   120     return aRegistration.HandleError(aCallback,
       
   121     								 aError,
       
   122     								 aRequestId,
       
   123     								 *iUnregistered);
       
   124     }
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // CRegistering::RefreshState
       
   128 // Registering has been started but isn't yet active.
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 CSIPRefresh::TState CRegistering::RefreshState() const
       
   132     {
       
   133     return CSIPRefresh::EInactive;
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // CRegistering::ConnectionLost
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 void
       
   141 CRegistering::ConnectionLost(CRegBindingImplementation& aRegistration) const
       
   142     {
       
   143     aRegistration.ChangeState(iUnregistered);
       
   144     }