|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : SIPExSIPIdleState.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 "SIPExSIPIdleState.h" 00018 #include "SIPExSIPEngine.h" 00019 00020 #include <Uri8.h> 00021 #include <sipstrings.h> 00022 #include <SipStrConsts.h> 00023 00024 // ============================ MEMBER FUNCTIONS =============================== 00025 00026 // ----------------------------------------------------------------------------- 00027 // CSIPExSIPIdleState::CSIPExSIPIdleState 00028 // (other items were commented in a header). 00029 // ----------------------------------------------------------------------------- 00030 // 00031 CSIPExSIPIdleState::CSIPExSIPIdleState() 00032 { 00033 } 00034 00035 // ----------------------------------------------------------------------------- 00036 // CSIPExSIPIdleState::~CSIPExSIPIdleState 00037 // (other items were commented in a header). 00038 // ----------------------------------------------------------------------------- 00039 // 00040 EXPORT_C CSIPExSIPIdleState::~CSIPExSIPIdleState() 00041 { 00042 } 00043 00044 // ----------------------------------------------------------------------------- 00045 // CSIPExSIPIdleState::NewL() 00046 // (other items were commented in a header). 00047 // ----------------------------------------------------------------------------- 00048 // 00049 EXPORT_C CSIPExSIPIdleState* CSIPExSIPIdleState::NewL() 00050 { 00051 CSIPExSIPIdleState* self = new (ELeave) CSIPExSIPIdleState(); 00052 return self; 00053 } 00054 00055 // ----------------------------------------------------------------------------- 00056 // CSIPExSIPIdleState::LinkStates() 00057 // (other items were commented in a header). 00058 // ----------------------------------------------------------------------------- 00059 // 00060 void CSIPExSIPIdleState::LinkStates( 00061 CSIPExSIPStateBase& aClientEstablishingState, 00062 CSIPExSIPStateBase& aServerOfferingState) 00063 { 00064 iClientEstablishingState = &aClientEstablishingState; 00065 iServerOfferingState = &aServerOfferingState; 00066 } 00067 00068 // ----------------------------------------------------------------------------- 00069 // CSIPExSIPIdleState::SendInviteL() 00070 // Create and send an INVITE request to the recipient. 00071 // ----------------------------------------------------------------------------- 00072 void CSIPExSIPIdleState::SendInviteL( 00073 CSIPExSIPEngine& aEngine, 00074 const TDesC8& aSipUri ) 00075 { 00076 // Retrieve the active profile and connection 00077 CSIPProfile& prof = aEngine.Profile(); 00078 CSIPConnection& conn = aEngine.ConnectionL(); 00079 00080 // Create CUri8 from passed descriptor 00081 CUri8* uri8 = aEngine.ConvertToUri8LC( aSipUri ); 00082 00083 // Get dialog association, save for future use 00084 // The ownership of uri8 is transferred 00085 CSIPInviteDialogAssoc* dialogAssoc = 00086 CSIPInviteDialogAssoc::NewL( conn, uri8, prof ); 00087 CleanupStack::Pop( uri8 ); 00088 00089 aEngine.SetDialogAssoc( *dialogAssoc ); //Ownership is transferred!! 00090 00091 // Create the necessary message elements 00092 CSIPMessageElements* msgElements = aEngine.CreateMessageElementsLC(); 00093 00094 // Send the INVITE in the dialog 00095 // The ownership of msgElements is transferred 00096 CSIPClientTransaction* tx = dialogAssoc->SendInviteL( msgElements ); 00097 CleanupStack::Pop( msgElements ); 00098 00099 // Save the pointer to the transaction to the Engine 00100 aEngine.SetClientTx( tx ); 00101 00102 // Change machine state 00103 aEngine.SetCurrentState( iClientEstablishingState ); 00104 } 00105 00106 00107 // ----------------------------------------------------------------------------- 00108 // CSIPExSIPIdleState::InviteReceivedL() 00109 // (other items were commented in a header). 00110 // ----------------------------------------------------------------------------- 00111 void CSIPExSIPIdleState::InviteReceivedL( 00112 CSIPExSIPEngine& aEngine, 00113 CSIPServerTransaction* aTransaction ) 00114 { 00115 _LIT8( KLogEntry, "180 Ringing sent" ); 00116 00117 // Get dialog association, save for future use 00118 CSIPInviteDialogAssoc* dialogAssoc = 00119 CSIPInviteDialogAssoc::NewL( *aTransaction ); 00120 aEngine.SetDialogAssoc( *dialogAssoc ); 00121 00122 // Create the necessary response elements and send 00123 CSIPResponseElements* elem = 00124 CSIPResponseElements::NewLC( 00125 180, SIPStrings::StringF( SipStrConsts::EPhraseRinging ) ); 00126 aTransaction->SendResponseL( elem ); 00127 CleanupStack::Pop( elem ); 00128 aEngine.Observer()->WriteLog( KLogEntry ); 00129 00130 // Get the From header from the request 00131 const CSIPRequestElements* reqElem = aTransaction->RequestElements(); 00132 const CSIPFromHeader* fromHeader = reqElem->FromHeader(); 00133 00134 // Change machine state 00135 aEngine.SetCurrentState( iServerOfferingState ); 00136 00137 TUint32 iapId( 0 ); 00138 User::LeaveIfError( 00139 aEngine.Profile().GetParameter( KSIPAccessPointId, iapId ) ); 00140 00141 // Send user name from the From header to the Engine Observer 00142 // as a parameter. Send also id of used IAP. 00143 aEngine.Observer()->InviteReceived( 00144 fromHeader->SIPAddress().Uri8().Uri().Extract( EUriUserinfo ), iapId ); 00145 } 00146 00147 // End of file
|
© Nokia 2006 |