|
1 |
|
2 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 // All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of "Eclipse Public License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Nokia Corporation - initial contribution. |
|
11 // |
|
12 // Contributors: |
|
13 // |
|
14 // Description: |
|
15 // |
|
16 |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "SIPExSIPIdleState.h" |
|
21 #include "SIPExSIPEngine.h" |
|
22 |
|
23 #include <uri8.h> |
|
24 #include <sipstrings.h> |
|
25 #include <sipstrconsts.h> |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CSIPExSIPIdleState::CSIPExSIPIdleState |
|
31 // (other items were commented in a header). |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CSIPExSIPIdleState::CSIPExSIPIdleState() |
|
35 { |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CSIPExSIPIdleState::~CSIPExSIPIdleState |
|
40 // (other items were commented in a header). |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C CSIPExSIPIdleState::~CSIPExSIPIdleState() |
|
44 { |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CSIPExSIPIdleState::NewL() |
|
49 // (other items were commented in a header). |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 EXPORT_C CSIPExSIPIdleState* CSIPExSIPIdleState::NewL() |
|
53 { |
|
54 CSIPExSIPIdleState* self = new (ELeave) CSIPExSIPIdleState(); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CSIPExSIPIdleState::LinkStates() |
|
60 // (other items were commented in a header). |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 void CSIPExSIPIdleState::LinkStates( |
|
64 CSIPExSIPStateBase& aClientEstablishingState, |
|
65 CSIPExSIPStateBase& aServerOfferingState) |
|
66 { |
|
67 iClientEstablishingState = &aClientEstablishingState; |
|
68 iServerOfferingState = &aServerOfferingState; |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CSIPExSIPIdleState::SendInviteL() |
|
73 // Create and send an INVITE request to the recipient. |
|
74 // ----------------------------------------------------------------------------- |
|
75 void CSIPExSIPIdleState::SendInviteL( |
|
76 CSIPExSIPEngine& aEngine, |
|
77 const TDesC8& aSipUri ) |
|
78 { |
|
79 // Retrieve the active profile and connection |
|
80 CSIPProfile& prof = aEngine.Profile(); |
|
81 CSIPConnection& conn = aEngine.ConnectionL(); |
|
82 |
|
83 // Create CUri8 from passed descriptor |
|
84 CUri8* uri8 = aEngine.ConvertToUri8LC( aSipUri ); |
|
85 |
|
86 // Get dialog association, save for future use |
|
87 // The ownership of uri8 is transferred |
|
88 CSIPInviteDialogAssoc* dialogAssoc = |
|
89 CSIPInviteDialogAssoc::NewL( conn, uri8, prof ); |
|
90 CleanupStack::Pop( uri8 ); |
|
91 |
|
92 aEngine.SetDialogAssoc( *dialogAssoc ); //Ownership is transferred!! |
|
93 |
|
94 // Create the necessary message elements |
|
95 CSIPMessageElements* msgElements = aEngine.CreateMessageElementsLC(); |
|
96 |
|
97 // Send the INVITE in the dialog |
|
98 // The ownership of msgElements is transferred |
|
99 CSIPClientTransaction* tx = dialogAssoc->SendInviteL( msgElements ); |
|
100 CleanupStack::Pop( msgElements ); |
|
101 |
|
102 // Save the pointer to the transaction to the Engine |
|
103 aEngine.SetClientTx( tx ); |
|
104 |
|
105 // Change machine state |
|
106 aEngine.SetCurrentState( iClientEstablishingState ); |
|
107 } |
|
108 |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CSIPExSIPIdleState::InviteReceivedL() |
|
112 // (other items were commented in a header). |
|
113 // ----------------------------------------------------------------------------- |
|
114 void CSIPExSIPIdleState::InviteReceivedL( |
|
115 CSIPExSIPEngine& aEngine, |
|
116 CSIPServerTransaction* aTransaction ) |
|
117 { |
|
118 _LIT8( KLogEntry, "180 Ringing sent" ); |
|
119 |
|
120 // Get dialog association, save for future use |
|
121 CSIPInviteDialogAssoc* dialogAssoc = |
|
122 CSIPInviteDialogAssoc::NewL( *aTransaction ); |
|
123 aEngine.SetDialogAssoc( *dialogAssoc ); |
|
124 |
|
125 // Create the necessary response elements and send |
|
126 CSIPResponseElements* elem = |
|
127 CSIPResponseElements::NewLC( |
|
128 180, SIPStrings::StringF( SipStrConsts::EPhraseRinging ) ); |
|
129 aTransaction->SendResponseL( elem ); |
|
130 CleanupStack::Pop( elem ); |
|
131 aEngine.Observer()->WriteLog( KLogEntry ); |
|
132 |
|
133 // Get the From header from the request |
|
134 const CSIPRequestElements* reqElem = aTransaction->RequestElements(); |
|
135 const CSIPFromHeader* fromHeader = reqElem->FromHeader(); |
|
136 |
|
137 // Change machine state |
|
138 aEngine.SetCurrentState( iServerOfferingState ); |
|
139 |
|
140 TUint32 iapId( 0 ); |
|
141 User::LeaveIfError( |
|
142 aEngine.Profile().GetParameter( KSIPAccessPointId, iapId ) ); |
|
143 |
|
144 // Send user name from the From header to the Engine Observer |
|
145 // as a parameter. Send also id of used IAP. |
|
146 aEngine.Observer()->InviteReceived( |
|
147 fromHeader->SIPAddress().Uri8().Uri().Extract( EUriUserinfo ), iapId ); |
|
148 } |
|
149 |
|
150 // End of file |