S60 3rd Edition SDK for Symbian OS
Example Applications Guide

SIPExSIPClientOfferingState.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : SIPExSIPClientOfferingState.cpp
00004 *  Part of     : SIPExSIPEngine
00005 *  Interface   : 
00006 *  Description : 
00007 *  Version     : 
00008 *
00009 *  Copyright (c) 2004-2006 Nokia Corporation.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 // INCLUDE FILES
00017 #include        "SIPExSIPClientOfferingState.h"
00018 #include        "SIPExSIPEngine.h"
00019 
00020 // ============================ MEMBER FUNCTIONS ===============================
00021 
00022 // -----------------------------------------------------------------------------
00023 // CSIPExSIPClientOfferingState::CSIPExSIPClientOfferingState
00024 // (other items were commented in a header).
00025 // -----------------------------------------------------------------------------
00026 //
00027 CSIPExSIPClientOfferingState::CSIPExSIPClientOfferingState()
00028         {
00029         }
00030 
00031 // -----------------------------------------------------------------------------
00032 // CSIPExSIPClientOfferingState::~CSIPExSIPClientOfferingState
00033 // (other items were commented in a header).
00034 // -----------------------------------------------------------------------------
00035 //
00036 EXPORT_C CSIPExSIPClientOfferingState::~CSIPExSIPClientOfferingState()
00037         {
00038         }
00039 
00040 // -----------------------------------------------------------------------------
00041 // CSIPExSIPClientOfferingState::NewL()
00042 // (other items were commented in a header).
00043 // -----------------------------------------------------------------------------
00044 //
00045 EXPORT_C CSIPExSIPClientOfferingState* CSIPExSIPClientOfferingState::NewL()
00046         {
00047         CSIPExSIPClientOfferingState* self =
00048                 new (ELeave) CSIPExSIPClientOfferingState();
00049         return self;
00050         }
00051 
00052 // -----------------------------------------------------------------------------
00053 // CSIPExSIPClientOfferingState::LinkStates()
00054 // (other items were commented in a header).
00055 // -----------------------------------------------------------------------------
00056 //
00057 void CSIPExSIPClientOfferingState::LinkStates(
00058         CSIPExSIPStateBase& aIdleState,
00059         CSIPExSIPStateBase& aEstablishedState,
00060         CSIPExSIPStateBase& aTerminatedState )
00061         {
00062         iIdleState = &aIdleState;
00063         iEstablishedState = &aEstablishedState;
00064         iTerminatedState = &aTerminatedState;
00065         }
00066 
00067 
00068 // -----------------------------------------------------------------------------
00069 // CSIPExSIPClientOfferingState::CancelInviteL()
00070 // (other items were commented in a header).
00071 // -----------------------------------------------------------------------------
00072 void CSIPExSIPClientOfferingState::CancelInviteL( CSIPExSIPEngine& aEngine )
00073         {
00074         // Get the current Client Transaction
00075         CSIPClientTransaction& clientTA = aEngine.ClientTx();
00076 
00077         // Use it the to send CANCEL request
00078     CSIPClientTransaction* ta = clientTA.CancelL();
00079     delete ta;
00080 
00081         aEngine.SetCurrentState( iIdleState );
00082         aEngine.Observer()->InvitationCancelled();
00083         }
00084 
00085 
00086 
00087 // -----------------------------------------------------------------------------
00088 // CSIPExSIPClientOfferingState::ResponseReceivedL()
00089 // (other items were commented in a header).
00090 // -----------------------------------------------------------------------------
00091 void CSIPExSIPClientOfferingState::ResponseReceivedL( 
00092     CSIPExSIPEngine& aEngine,
00093     CSIPClientTransaction& aTransaction )
00094         {
00095         const CSIPResponseElements* respElem = aTransaction.ResponseElements();
00096 
00097         TUint statusCode = respElem->StatusCode();
00098 
00099         if ( statusCode >= 200 && statusCode < 300 )
00100                 {
00101                 // Final Response received from network.
00102                 // Get the IP Address of the remote party from the Response Elements
00103                 const TInetAddr addr = 
00104                             aEngine.IPAddressFromResponseElementsL( *respElem );
00105 
00106 
00107                 // Then, send ACK to remote party
00108                 CSIPInviteDialogAssoc& dialogAssoc = aEngine.DialogAssoc();
00109                 dialogAssoc.SendAckL( aTransaction );
00110 
00111         // Get used iap's id
00112                 TUint32 iapId( 0 );
00113                 CSIPConnection* conn = aEngine.DialogAssoc().Dialog().Connection();
00114                 if ( conn )
00115                     {
00116                     iapId = conn->IapId();
00117                     }
00118 
00119                 // After ACKing, notify observer, giving IP Address and IAP id
00120                 // as parameter
00121                 aEngine.Observer()->InviteAcceptedByRemote( addr, iapId );
00122 
00123 
00124                 // Finally, change engine state
00125                 aEngine.SetCurrentState( iEstablishedState );
00126                 }
00127         else if ( statusCode >= 100 && statusCode < 200 )
00128                 {
00129                 // Provisional Response received from network.
00130                 aEngine.Observer()->InviteReceivedByRemote( statusCode );
00131                 }
00132         else
00133                 {
00134                 aEngine.Observer()->InviteDeclinedByRemote( statusCode );
00135                 aEngine.SetCurrentState( iTerminatedState );
00136                 }
00137         }
00138 
00139 // End of file
00140 

© Nokia 2006

Back to top