|
1 // Copyright (c) 2007-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 : CSipCSSessionReceiver.cpp |
|
15 // Part of : SIPServerCore |
|
16 // Version : SIP/6.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "CSipCSSessionReceiver.h" |
|
22 #include "CSipCSSession.h" |
|
23 #include "TSipCSReceiveItem.h" |
|
24 #include "sipinternalerr.h" |
|
25 #include "siperr.h" |
|
26 #include "CSipCSServerITC.h" |
|
27 #include "CSIPCSSerializer.h" |
|
28 #include "sipresponse.h" |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CSipCSSessionReceiver::NewL |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CSipCSSessionReceiver* CSipCSSessionReceiver::NewL(CSipCSServerITC& aITC, |
|
35 MSipCSSession& aSession) |
|
36 { |
|
37 CSipCSSessionReceiver* self = CSipCSSessionReceiver::NewLC(aITC,aSession); |
|
38 CleanupStack::Pop(self); |
|
39 return self; |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CSipCSSessionReceiver::NewLC |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CSipCSSessionReceiver* CSipCSSessionReceiver::NewLC(CSipCSServerITC& aITC, |
|
47 MSipCSSession& aSession) |
|
48 { |
|
49 CSipCSSessionReceiver* self = |
|
50 new(ELeave)CSipCSSessionReceiver(aITC,aSession); |
|
51 CleanupStack::PushL (self); |
|
52 self->ConstructL(); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CSipCSSessionReceiver::CSipCSSessionReceiver |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CSipCSSessionReceiver::CSipCSSessionReceiver(CSipCSServerITC& aITC, |
|
61 MSipCSSession& aSession) |
|
62 : CSipCSReceiverBase(aITC,*this), |
|
63 iHttpDigestObserverType(ESipNoHttpDigestObserver), |
|
64 iSession(aSession) |
|
65 { |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CSipCSSessionReceiver::~CSipCSSessionReceiver |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CSipCSSessionReceiver::~CSipCSSessionReceiver() |
|
73 { |
|
74 iPendingErrorItems.Close(); |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CSipCSSessionReceiver::SetHttpDigestObserver |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CSipCSSessionReceiver::SetHttpDigestObserver( |
|
82 TSipHttpDigestObserverType aType) |
|
83 { |
|
84 iHttpDigestObserverType = aType; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CSipCSSessionReceiver::MovePendingErrorsL |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CSipCSSessionReceiver::MovePendingErrorsL(TUint32 aIapId, |
|
92 CSipCSReceiverBase& aReceiver) |
|
93 { |
|
94 for (TInt i=iPendingErrorItems.Count()-1; i >= 0; i--) |
|
95 { |
|
96 const TSipCSReceiveItem& item = iPendingErrorItems[i]; |
|
97 if (item.Ids().iIapId == aIapId) |
|
98 { |
|
99 aReceiver.AddItemL(item); |
|
100 iPendingErrorItems.Remove(i); |
|
101 } |
|
102 } |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CSipCSSessionReceiver::ReceiveL |
|
107 // From MTransactionOwner: |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CSipCSSessionReceiver::ReceiveL(TUint32 aIapId, |
|
111 TTransactionId aTransactionId, |
|
112 CSIPRequest* aRequest) |
|
113 { |
|
114 MTransactionOwner& owner = iSession.FindOwner(aIapId); |
|
115 if (&owner == this) |
|
116 { |
|
117 SipRequestReceivedL(aIapId,aTransactionId,aRequest); |
|
118 } |
|
119 else |
|
120 { |
|
121 // Subsession with matching IAP ID exists. Route request to it. |
|
122 owner.ReceiveL(aIapId,aTransactionId,aRequest); |
|
123 } |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CSipCSSessionReceiver::TransactionEnded |
|
128 // From MTransactionOwner: |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 TInt CSipCSSessionReceiver::TransactionEnded(TUint32 aIapId, |
|
132 TTransactionId aTransactionId, |
|
133 TInt aReason) |
|
134 { |
|
135 MTransactionOwner& owner = iSession.FindOwner(aIapId); |
|
136 if (&owner != this) |
|
137 { |
|
138 // Subsession with matching IAP ID exists. Route callback to it. |
|
139 return owner.TransactionEnded(aIapId,aTransactionId,aReason); |
|
140 } |
|
141 if (aReason != KErrTimedOut && aReason != KErrNone) |
|
142 { |
|
143 // For other errors than KErrTimedOut there is no callback |
|
144 // in SIP Client API. Put these errors waiting until the |
|
145 // user has created CSIPConnection (C/S subsession). |
|
146 TSIPIds ids; |
|
147 ids.iIapId = aIapId; |
|
148 ids.iRequestId = aTransactionId; |
|
149 TSipCSReceiveItem item(ids,aReason); |
|
150 return iPendingErrorItems.Append(item); |
|
151 } |
|
152 return CSipCSReceiverBase::TransactionEnded(aIapId,aTransactionId,aReason); |
|
153 } |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CSipCSSessionReceiver::ReceiveL |
|
157 // From MTransactionOwner: |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void CSipCSSessionReceiver::ReceiveL(TTransactionId /*aTransactionId*/, |
|
161 CSIPResponse* /*aResponse*/) |
|
162 { |
|
163 User::Leave(KErrNotSupported); |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CSipCSSessionReceiver::PassOnlyRealmsToUser |
|
168 // From MSIPSecUser: |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 TBool CSipCSSessionReceiver::PassOnlyRealmsToUser() const |
|
172 { |
|
173 return (iHttpDigestObserverType == ESipRealmHttpDigestObserver); |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CSipCSSessionReceiver::RequestCredentialsL |
|
178 // From MSIPSecUser: |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 void CSipCSSessionReceiver::RequestCredentialsL(const TDesC8& aRealm) |
|
182 { |
|
183 __ASSERT_ALWAYS(iHttpDigestObserverType == ESipRealmHttpDigestObserver, |
|
184 User::Leave(KErrSIPForbidden)); |
|
185 |
|
186 HBufC8* dummyContent = KNullDesC8().AllocLC(); |
|
187 |
|
188 const TInt KRealmBufExpandSize = 50; |
|
189 CBufFlat* realmBuf = CBufFlat::NewL(KRealmBufExpandSize); |
|
190 CleanupStack::PushL(realmBuf); |
|
191 realmBuf->InsertL(0,aRealm); |
|
192 |
|
193 TSIPIds dummyIds; |
|
194 TSipCSReceiveItem item(dummyIds,realmBuf,dummyContent, |
|
195 EFalse,KChallengeReceived); |
|
196 |
|
197 HandleNewReceiveItemL(item); |
|
198 |
|
199 CleanupStack::Pop(realmBuf); |
|
200 CleanupStack::Pop(dummyContent); |
|
201 } |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CSipCSSessionReceiver::RequestCredentialsL |
|
205 // From MSIPSecUser: |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 void CSipCSSessionReceiver::RequestCredentialsL(CSIPResponse& aResponse, |
|
209 TTransactionId aTransactionId, |
|
210 TRefreshId aRefreshId) |
|
211 { |
|
212 __ASSERT_ALWAYS(iHttpDigestObserverType == ESipResponseHttpDigestObserver, |
|
213 User::Leave(KErrSIPForbidden)); |
|
214 |
|
215 TSIPIds ids; |
|
216 ids.iRequestId = aTransactionId; |
|
217 ids.iRefreshId = aRefreshId; |
|
218 |
|
219 CBufFlat* headers = iITC.Serializer().ExternalizeLC(aResponse); |
|
220 HBufC8* content = aResponse.Content().AllocLC(); |
|
221 TSipCSReceiveItem item(ids,headers,content,EFalse,KChallengeReceived); |
|
222 |
|
223 HandleNewReceiveItemL(item); |
|
224 |
|
225 CleanupStack::Pop(content); |
|
226 CleanupStack::Pop(headers); |
|
227 } |
|
228 |
|
229 // ----------------------------------------------------------------------------- |
|
230 // CSipCSSessionReceiver::TrustedUser |
|
231 // From MSIPSecUser: |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 const MSIPSecUser* CSipCSSessionReceiver::TrustedUser( |
|
235 TRegistrationId aRegistrationId) |
|
236 { |
|
237 return iSession.SIPSecUser(aRegistrationId); |
|
238 } |
|
239 |
|
240 // ----------------------------------------------------------------------------- |
|
241 // CSipCSSessionReceiver::ByPassSIPSec |
|
242 // From MSIPSecUser: |
|
243 // ----------------------------------------------------------------------------- |
|
244 // |
|
245 TBool CSipCSSessionReceiver::ByPassSIPSec() const |
|
246 { |
|
247 return iSession.ByPassSIPSec(); |
|
248 } |