|
1 // Copyright (c) 2006-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 : SIPRegistrationBinding.cpp |
|
15 // Part of : SIPAPI |
|
16 // Version : SIP/5.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include <uri8.h> |
|
22 #include "sipdefs.h" |
|
23 #include "sipregistrationbinding.h" |
|
24 #include "RegBindingImplementation.h" |
|
25 #include "sipclienttransaction.h" |
|
26 #include "sipmessageelements.h" |
|
27 #include "sipcontactheader.h" |
|
28 #include "sipstrings.h" |
|
29 #include "sipstrconsts.h" |
|
30 |
|
31 |
|
32 #ifdef CPPUNIT_TEST |
|
33 |
|
34 #include "TestCleanupStack.h" |
|
35 |
|
36 #undef EXPORT_C |
|
37 #define EXPORT_C |
|
38 |
|
39 #endif |
|
40 |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CSIPRegistrationBinding::NewL |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 EXPORT_C CSIPRegistrationBinding* |
|
47 CSIPRegistrationBinding::NewL(CSIPConnection& aConnection, |
|
48 CSIPToHeader* aAor, |
|
49 CSIPContactHeader* aContact, |
|
50 CSIPRefresh* aRefresh, |
|
51 CSIPRouteHeader* aOutboundProxy, |
|
52 CUri8* aRemoteUri, |
|
53 CSIPFromHeader* aFrom) |
|
54 { |
|
55 CSIPRegistrationBinding* self = |
|
56 CSIPRegistrationBinding::NewLC(aConnection, |
|
57 aAor, |
|
58 aContact, |
|
59 aRefresh, |
|
60 aOutboundProxy, |
|
61 aRemoteUri, |
|
62 aFrom); |
|
63 CleanupStack::Pop(self); |
|
64 return self; |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CSIPRegistrationBinding::NewLC |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 EXPORT_C CSIPRegistrationBinding* |
|
72 CSIPRegistrationBinding::NewLC(CSIPConnection& aConnection, |
|
73 CSIPToHeader* aAor, |
|
74 CSIPContactHeader* aContact, |
|
75 CSIPRefresh* aRefresh, |
|
76 CSIPRouteHeader* aOutboundProxy, |
|
77 CUri8* aRemoteUri, |
|
78 CSIPFromHeader* aFrom) |
|
79 { |
|
80 __ASSERT_ALWAYS(aAor && aContact, User::Leave(KErrArgument)); |
|
81 |
|
82 if (aContact->HasParam(SIPStrings::StringF(SipStrConsts::EExpires))) |
|
83 { |
|
84 TUint expires = aContact->ExpiresParameter(); |
|
85 __ASSERT_ALWAYS(expires >= KSIPMinExpirationValue, |
|
86 User::Leave(KErrArgument)); |
|
87 } |
|
88 |
|
89 CSIPRegistrationBinding* self = |
|
90 new (ELeave) CSIPRegistrationBinding(); |
|
91 CleanupStack::PushL(self); |
|
92 self->ConstructL(aConnection, |
|
93 aAor, |
|
94 aContact, |
|
95 aRefresh, |
|
96 aOutboundProxy, |
|
97 aRemoteUri, |
|
98 aFrom); |
|
99 return self; |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CSIPRegistrationBinding::CSIPRegistrationBinding |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 CSIPRegistrationBinding::CSIPRegistrationBinding() |
|
107 { |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CSIPRegistrationBinding::ConstructL |
|
112 // aAor and aContact have been checked in NewLC so they aren't checked again |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void CSIPRegistrationBinding::ConstructL(CSIPConnection& aConnection, |
|
116 CSIPToHeader* aAor, |
|
117 CSIPContactHeader* aContact, |
|
118 CSIPRefresh* aRefresh, |
|
119 CSIPRouteHeader* aOutboundProxy, |
|
120 CUri8* aRemoteUri, |
|
121 CSIPFromHeader* aFrom) |
|
122 { |
|
123 iImplementation = CRegBindingImplementation::NewL(*this, |
|
124 aConnection, |
|
125 aAor, |
|
126 aContact, |
|
127 aRefresh, |
|
128 aOutboundProxy, |
|
129 aRemoteUri, |
|
130 aFrom); |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CSIPRegistrationBinding::~CSIPRegistrationBinding |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 EXPORT_C CSIPRegistrationBinding::~CSIPRegistrationBinding() |
|
138 { |
|
139 delete iImplementation; |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CSIPRegistrationBinding::IsContextActive |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 EXPORT_C TBool CSIPRegistrationBinding::IsContextActive() const |
|
147 { |
|
148 __TEST_INVARIANT; |
|
149 return iImplementation->IsContextActive(); |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CSIPRegistrationBinding::ContextId |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 EXPORT_C TUint32 CSIPRegistrationBinding::ContextId() const |
|
157 { |
|
158 __TEST_INVARIANT; |
|
159 return iImplementation->ContextId(); |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // CSIPRegistrationBinding::RegisterL |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 EXPORT_C CSIPClientTransaction* |
|
167 CSIPRegistrationBinding::RegisterL(CSIPMessageElements* aElements) |
|
168 { |
|
169 __TEST_INVARIANT; |
|
170 return iImplementation->RegisterL(aElements); |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CSIPRegistrationBinding::DeregisterL |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 EXPORT_C CSIPClientTransaction* |
|
178 CSIPRegistrationBinding::DeregisterL(CSIPMessageElements* aElements) |
|
179 { |
|
180 __TEST_INVARIANT; |
|
181 return iImplementation->DeregisterL(aElements); |
|
182 } |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // CSIPRegistrationBinding::UpdateL |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 EXPORT_C CSIPClientTransaction* |
|
189 CSIPRegistrationBinding::UpdateL(CSIPMessageElements* aElements) |
|
190 { |
|
191 __TEST_INVARIANT; |
|
192 __ASSERT_ALWAYS(aElements, User::Leave(KErrArgument)); |
|
193 |
|
194 return iImplementation->UpdateL(aElements); |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CSIPRegistrationBinding::UpdateL |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 EXPORT_C CSIPClientTransaction* |
|
202 CSIPRegistrationBinding::UpdateL(TUint aExpirationValue, |
|
203 CSIPMessageElements* aElements) |
|
204 { |
|
205 __TEST_INVARIANT; |
|
206 __ASSERT_ALWAYS(aExpirationValue >= KSIPMinExpirationValue, |
|
207 User::Leave(KErrArgument)); |
|
208 |
|
209 return iImplementation->UpdateL(aElements, &aExpirationValue); |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CSIPRegistrationBinding::SetOutboundProxyL |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 EXPORT_C void |
|
217 CSIPRegistrationBinding::SetOutboundProxyL(CSIPRouteHeader* aOutboundProxy) |
|
218 { |
|
219 __TEST_INVARIANT; |
|
220 |
|
221 iImplementation->SetOutboundProxyL(aOutboundProxy); |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CSIPRegistrationBinding::Aor |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 EXPORT_C const CSIPToHeader& CSIPRegistrationBinding::Aor() const |
|
229 { |
|
230 __TEST_INVARIANT; |
|
231 return iImplementation->Aor(); |
|
232 } |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // CSIPRegistrationBinding::ContactHeader |
|
236 // ----------------------------------------------------------------------------- |
|
237 // |
|
238 EXPORT_C const CSIPContactHeader& CSIPRegistrationBinding::ContactHeader() const |
|
239 { |
|
240 __TEST_INVARIANT; |
|
241 return iImplementation->ContactHeader(); |
|
242 } |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // CSIPRegistrationBinding::ContactHeader |
|
246 // ----------------------------------------------------------------------------- |
|
247 // |
|
248 EXPORT_C CSIPContactHeader& CSIPRegistrationBinding::ContactHeader() |
|
249 { |
|
250 __TEST_INVARIANT; |
|
251 return iImplementation->ContactHeader(); |
|
252 } |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // CSIPRegistrationBinding::OutboundProxy |
|
256 // ----------------------------------------------------------------------------- |
|
257 // |
|
258 EXPORT_C const CSIPRouteHeader* CSIPRegistrationBinding::OutboundProxy() const |
|
259 { |
|
260 __TEST_INVARIANT; |
|
261 return iImplementation->OutboundProxy(); |
|
262 } |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // CSIPRegistrationBinding::SIPRefresh |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 EXPORT_C const CSIPRefresh* CSIPRegistrationBinding::SIPRefresh() const |
|
269 { |
|
270 __TEST_INVARIANT; |
|
271 return iImplementation->SIPRefresh(); |
|
272 } |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // CSIPRegistrationBinding::SIPRefresh |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 EXPORT_C CSIPRefresh* CSIPRegistrationBinding::SIPRefresh() |
|
279 { |
|
280 __TEST_INVARIANT; |
|
281 return iImplementation->SIPRefresh(); |
|
282 } |
|
283 |
|
284 // ----------------------------------------------------------------------------- |
|
285 // CSIPRegistrationBinding::Connection |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 EXPORT_C CSIPConnection* CSIPRegistrationBinding::Connection() |
|
289 { |
|
290 __TEST_INVARIANT; |
|
291 return iImplementation->Connection(); |
|
292 } |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // CSIPRegistrationBinding::Connection |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 EXPORT_C const CSIPConnection* CSIPRegistrationBinding::Connection() const |
|
299 { |
|
300 __TEST_INVARIANT; |
|
301 return iImplementation->Connection(); |
|
302 } |
|
303 |
|
304 // ----------------------------------------------------------------------------- |
|
305 // CSIPRegistrationBinding::operator== |
|
306 // ----------------------------------------------------------------------------- |
|
307 // |
|
308 EXPORT_C TBool CSIPRegistrationBinding::operator==( |
|
309 const CSIPRegistrationBinding& aRegistration) const |
|
310 { |
|
311 __TEST_INVARIANT; |
|
312 return *iImplementation == *aRegistration.iImplementation; |
|
313 } |
|
314 |
|
315 // ----------------------------------------------------------------------------- |
|
316 // CSIPRegistrationBinding::RegisteredContact |
|
317 // ----------------------------------------------------------------------------- |
|
318 // |
|
319 EXPORT_C const CSIPContactHeader* |
|
320 CSIPRegistrationBinding::RegisteredContact() const |
|
321 { |
|
322 __TEST_INVARIANT; |
|
323 return iImplementation->RegisteredContact(); |
|
324 } |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // CSIPRegistrationBinding::SetProperty |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 EXPORT_C TInt CSIPRegistrationBinding::SetProperty(TUint32 aProperty,TBool aValue) |
|
331 { |
|
332 __TEST_INVARIANT; |
|
333 TRAPD(err, iImplementation->SetPropertyL(aProperty,aValue)); |
|
334 return err; |
|
335 } |
|
336 |
|
337 // ----------------------------------------------------------------------------- |
|
338 // CSIPRegistrationBinding::Implementation |
|
339 // ----------------------------------------------------------------------------- |
|
340 // |
|
341 CRegBindingImplementation& CSIPRegistrationBinding::Implementation() |
|
342 { |
|
343 __TEST_INVARIANT; |
|
344 return *iImplementation; |
|
345 } |
|
346 |
|
347 // ----------------------------------------------------------------------------- |
|
348 // CSIPRegistrationBinding::__DbgTestInvariant |
|
349 // ----------------------------------------------------------------------------- |
|
350 // |
|
351 |
|
352 void CSIPRegistrationBinding::__DbgTestInvariant() const |
|
353 { |
|
354 if (!iImplementation) |
|
355 { |
|
356 User::Invariant(); |
|
357 } |
|
358 } |
|
359 |