|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : SIPExSIPServerOfferingState.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 "SIPExSIPServerOfferingState.h" 00018 #include "SIPExSIPEngine.h" 00019 00020 #include <sipstrings.h> 00021 #include <SipStrConsts.h> 00022 00023 // ============================ MEMBER FUNCTIONS =============================== 00024 00025 // ----------------------------------------------------------------------------- 00026 // CSIPExSIPServerOfferingState::CSIPExSIPServerOfferingState 00027 // (other items were commented in a header). 00028 // ----------------------------------------------------------------------------- 00029 // 00030 CSIPExSIPServerOfferingState::CSIPExSIPServerOfferingState() 00031 { 00032 } 00033 00034 // ----------------------------------------------------------------------------- 00035 // CSIPExSIPServerOfferingState::~CSIPExSIPServerOfferingState 00036 // (other items were commented in a header). 00037 // ----------------------------------------------------------------------------- 00038 // 00039 EXPORT_C CSIPExSIPServerOfferingState::~CSIPExSIPServerOfferingState() 00040 { 00041 } 00042 00043 // ----------------------------------------------------------------------------- 00044 // CSIPExSIPServerOfferingState::NewL() 00045 // (other items were commented in a header). 00046 // ----------------------------------------------------------------------------- 00047 // 00048 EXPORT_C CSIPExSIPServerOfferingState* CSIPExSIPServerOfferingState::NewL() 00049 { 00050 CSIPExSIPServerOfferingState* self = 00051 new (ELeave) CSIPExSIPServerOfferingState(); 00052 return self; 00053 } 00054 00055 // ----------------------------------------------------------------------------- 00056 // CSIPExSIPServerOfferingState::LinkStates() 00057 // (other items were commented in a header). 00058 // ----------------------------------------------------------------------------- 00059 // 00060 void CSIPExSIPServerOfferingState::LinkStates( 00061 CSIPExSIPStateBase& aServerEstablishingState, 00062 CSIPExSIPStateBase& aTerminatedState ) 00063 { 00064 iServerEstablishingState = &aServerEstablishingState; 00065 iTerminatedState = &aTerminatedState; 00066 } 00067 00068 // ----------------------------------------------------------------------------- 00069 // CSIPExSIPServerOfferingState::ByeReceivedL() 00070 // (other items were commented in a header). 00071 // ----------------------------------------------------------------------------- 00072 void CSIPExSIPServerOfferingState::ByeReceivedL( 00073 CSIPExSIPEngine& aEngine, 00074 CSIPServerTransaction& aTransaction ) 00075 { 00076 // Create and send response 00077 CSIPResponseElements* elem = 00078 CSIPResponseElements::NewLC( 00079 200, SIPStrings::StringF( SipStrConsts::EPhraseOk ) ); 00080 aTransaction.SendResponseL( elem ); 00081 CleanupStack::Pop( elem ); 00082 00083 // Inform observer 00084 aEngine.Observer()->SessionEnded(); 00085 00086 // Set state 00087 aEngine.SetCurrentState( iTerminatedState ); 00088 } 00089 00090 // ----------------------------------------------------------------------------- 00091 // CSIPExSIPServerOfferingState::CancelReceivedL() 00092 // (other items were commented in a header). 00093 // ----------------------------------------------------------------------------- 00094 void CSIPExSIPServerOfferingState::CancelReceivedL( 00095 CSIPExSIPEngine& aEngine, 00096 CSIPClientTransaction& /*aTransaction */ ) 00097 { 00098 aEngine.Observer()->SessionEnded(); 00099 aEngine.SetCurrentState( iTerminatedState ); 00100 } 00101 00102 // ----------------------------------------------------------------------------- 00103 // CSIPExSIPServerOfferingState::AcceptInviteL() 00104 // (other items were commented in a header). 00105 // ----------------------------------------------------------------------------- 00106 void CSIPExSIPServerOfferingState::AcceptInviteL( CSIPExSIPEngine& aEngine) 00107 { 00108 _LIT8( KMediaType, "application" ); 00109 _LIT8( KMediaSubType, "sdp" ); 00110 _LIT8( KLogEntry, "200 OK sent" ); 00111 00112 // Get the current transaction 00113 CSIPServerTransaction& tx = aEngine.ServerTx(); 00114 // Create the Response Elements object 00115 CSIPResponseElements* respElem = 00116 CSIPResponseElements::NewLC( 00117 200, SIPStrings::StringF( SipStrConsts::EPhraseOk ) ); 00118 00119 // Set the message body - we need to communicate our IP Address 00120 CSIPMessageElements& msgElem = respElem->MessageElements(); 00121 00122 CSdpDocument* sdpDocument = aEngine.SdpDocumentLC(); 00123 HBufC8* sdpBody = aEngine.SdpBodyL( sdpDocument ); 00124 CleanupStack::PushL( sdpBody ); 00125 00126 CSIPContentTypeHeader* ct = 00127 CSIPContentTypeHeader::NewLC( KMediaType, KMediaSubType ); 00128 msgElem.SetContentL( sdpBody, ct ); 00129 00130 // Use the transaction to send 200 (OK) 00131 tx.SendResponseL( respElem ); 00132 00133 CleanupStack::Pop( ct ); 00134 CleanupStack::Pop( sdpBody ); 00135 CleanupStack::PopAndDestroy( sdpDocument ); 00136 CleanupStack::Pop( respElem ); 00137 00138 aEngine.SetCurrentState( iServerEstablishingState ); 00139 aEngine.Observer()->WriteLog( KLogEntry ); 00140 } 00141 00142 00143 00144 // ----------------------------------------------------------------------------- 00145 // CSIPExSIPServerOfferingState::DeclineInviteL() 00146 // (other items were commented in a header). 00147 // ----------------------------------------------------------------------------- 00148 void CSIPExSIPServerOfferingState::DeclineInviteL( CSIPExSIPEngine& aEngine ) 00149 { 00150 // Get the current transaction 00151 CSIPServerTransaction& tx = aEngine.ServerTx(); 00152 // Create the Response Elements object 00153 CSIPResponseElements* elem = 00154 CSIPResponseElements::NewLC( 486, 00155 SIPStrings::StringF( SipStrConsts::EPhraseBusyHere ) ); 00156 00157 // Use the transaction to send 486 (Busy Here) 00158 tx.SendResponseL( elem ); 00159 00160 CleanupStack::Pop( elem ); 00161 aEngine.Observer()->SessionEnded(); 00162 aEngine.SetCurrentState( iTerminatedState ); 00163 } 00164 00165 // End of file
|
© Nokia 2006 |