|
1 // Copyright (c) 2005-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 : sipconnection.cpp |
|
15 // Part of : SIPAPI |
|
16 // Version : SIP/4.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "SipConnectionImplementation.h" |
|
22 #include "sip.h" |
|
23 #include "siperr.h" |
|
24 #include "siprequestelements.h" |
|
25 #include "sipregistrationcontext.h" |
|
26 #include "sipclientconnection.h" |
|
27 |
|
28 |
|
29 #ifdef CPPUNIT_TEST |
|
30 |
|
31 #include "TestCleanupStack.h" |
|
32 |
|
33 #undef EXPORT_C |
|
34 #define EXPORT_C |
|
35 |
|
36 #endif |
|
37 |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CSIPConnection::NewL |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C CSIPConnection* |
|
44 CSIPConnection::NewL(CSIP& aSip, |
|
45 TUint32 aIapId, |
|
46 MSIPConnectionObserver& aObserver) |
|
47 { |
|
48 CSIPConnection* self = CSIPConnection::NewLC(aSip, aIapId, aObserver); |
|
49 CleanupStack::Pop(self); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CSIPConnection::NewLC |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 EXPORT_C CSIPConnection* |
|
58 CSIPConnection::NewLC(CSIP& aSIP, |
|
59 TUint32 aIapId, |
|
60 MSIPConnectionObserver& aObserver) |
|
61 { |
|
62 CSIPConnection* self = new (ELeave) CSIPConnection(); |
|
63 CleanupStack::PushL(self); |
|
64 self->ConstructL(aSIP, aIapId, aObserver); |
|
65 return self; |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CSIPConnection::CSIPConnection |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CSIPConnection::CSIPConnection() |
|
73 { |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CSIPConnection::ConstructL |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 void CSIPConnection::ConstructL(CSIP& aSIP, |
|
81 TUint32 aIapId, |
|
82 MSIPConnectionObserver& aObserver) |
|
83 { |
|
84 iImplementation = |
|
85 CSIPConnectionImplementation::NewL(aSIP, *this, aIapId, aObserver); |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CSIPConnection::~CSIPConnection |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 EXPORT_C CSIPConnection::~CSIPConnection() |
|
93 { |
|
94 delete iImplementation; |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CSIPConnection::State |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 EXPORT_C CSIPConnection::TState CSIPConnection::State() const |
|
102 { |
|
103 __TEST_INVARIANT; |
|
104 return iImplementation->State(); |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CSIPConnection::SendRequestL |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 EXPORT_C CSIPClientTransaction* |
|
112 CSIPConnection::SendRequestL(CSIPRequestElements* aElements, |
|
113 const MSIPRegistrationContext& aContext) |
|
114 { |
|
115 __TEST_INVARIANT; |
|
116 __ASSERT_ALWAYS(aContext.IsContextActive(), |
|
117 User::Leave(KErrSIPInvalidRegistrationState)); |
|
118 |
|
119 TUint32 registrationId = aContext.ContextId(); |
|
120 return iImplementation->SendRequestL(aElements, ®istrationId, NULL); |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CSIPConnection::SendRequestL |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 EXPORT_C CSIPClientTransaction* |
|
128 CSIPConnection::SendRequestL(CSIPRequestElements* aElements, |
|
129 const MSIPRegistrationContext& aContext, |
|
130 CSIPRefresh& aRefresh) |
|
131 { |
|
132 __TEST_INVARIANT; |
|
133 __ASSERT_ALWAYS(aContext.IsContextActive(), |
|
134 User::Leave(KErrSIPInvalidRegistrationState)); |
|
135 |
|
136 TUint32 registrationId = aContext.ContextId(); |
|
137 return iImplementation->SendRequestL(aElements, ®istrationId, &aRefresh); |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CSIPConnection::SendRequestL |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 EXPORT_C CSIPClientTransaction* |
|
145 CSIPConnection::SendRequestL(CSIPRequestElements* aElements) |
|
146 { |
|
147 __TEST_INVARIANT; |
|
148 return iImplementation->SendRequestL(aElements, NULL, NULL); |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CSIPConnection::SendRequestL |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 EXPORT_C CSIPClientTransaction* |
|
156 CSIPConnection::SendRequestL(CSIPRequestElements* aElements, |
|
157 CSIPRefresh& aRefresh) |
|
158 { |
|
159 __TEST_INVARIANT; |
|
160 return iImplementation->SendRequestL(aElements, NULL, &aRefresh); |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CSIPConnection::FetchRegistrationsL |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 EXPORT_C CSIPClientTransaction* |
|
168 CSIPConnection::FetchRegistrationsL(CSIPRequestElements* aElements) |
|
169 { |
|
170 __TEST_INVARIANT; |
|
171 __ASSERT_ALWAYS(aElements, User::Leave(KErrArgument)); |
|
172 __ASSERT_ALWAYS(aElements->Method().DesC().Length() == 0, |
|
173 User::Leave(KErrArgument)); |
|
174 |
|
175 return iImplementation->FetchRegistrationsL(aElements); |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CSIPConnection::IapId |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 EXPORT_C TUint32 CSIPConnection::IapId() const |
|
183 { |
|
184 __TEST_INVARIANT; |
|
185 return iImplementation->IapId(); |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CSIPConnection::SIP |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 EXPORT_C CSIP* CSIPConnection::SIP() |
|
193 { |
|
194 __TEST_INVARIANT; |
|
195 return iImplementation->SIP(); |
|
196 } |
|
197 |
|
198 // ----------------------------------------------------------------------------- |
|
199 // CSIPConnection::SIP |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 EXPORT_C const CSIP* CSIPConnection::SIP() const |
|
203 { |
|
204 __TEST_INVARIANT; |
|
205 return iImplementation->SIP(); |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CSIPConnection::SetOptL |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 EXPORT_C void CSIPConnection::SetOptL(TUint aOptionName, |
|
213 TUint aOptionLevel, |
|
214 const TDesC8& aOption) |
|
215 { |
|
216 __TEST_INVARIANT; |
|
217 return iImplementation->SetOptL(aOptionName, aOptionLevel, aOption); |
|
218 } |
|
219 |
|
220 // ----------------------------------------------------------------------------- |
|
221 // CSIPConnection::SetOptL |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 EXPORT_C void CSIPConnection::SetOptL(TUint aOptionName, |
|
225 TUint aOptionLevel, |
|
226 TInt aOption) |
|
227 { |
|
228 __TEST_INVARIANT; |
|
229 return iImplementation->SetOptL(aOptionName, aOptionLevel, aOption); |
|
230 } |
|
231 |
|
232 // ----------------------------------------------------------------------------- |
|
233 // CSIPConnection::GetLocalAddrL |
|
234 // ----------------------------------------------------------------------------- |
|
235 // |
|
236 EXPORT_C void CSIPConnection::GetLocalAddrL(TInetAddr& aAddr) const |
|
237 { |
|
238 __TEST_INVARIANT; |
|
239 iImplementation->ClientConnectionL().GetLocalAddrL(aAddr); |
|
240 } |
|
241 |
|
242 // ----------------------------------------------------------------------------- |
|
243 // CSIPConnection::Implementation |
|
244 // ----------------------------------------------------------------------------- |
|
245 // |
|
246 CSIPConnectionImplementation& CSIPConnection::Implementation() |
|
247 { |
|
248 __TEST_INVARIANT; |
|
249 return *iImplementation; |
|
250 } |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // CSIPConnection::RefreshConnection |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 EXPORT_C void CSIPConnection::RefreshConnection() const |
|
257 { |
|
258 iImplementation->ClientConnection()->RefreshConnection(); |
|
259 } |
|
260 |
|
261 // ----------------------------------------------------------------------------- |
|
262 // CSIPConnection::GetConnectionErrorL |
|
263 // ----------------------------------------------------------------------------- |
|
264 // |
|
265 EXPORT_C void CSIPConnection::GetConnectionErrorL(TInt &aError) const |
|
266 { |
|
267 aError = iImplementation->ClientConnection()->ConnectionErrorL(); |
|
268 } |
|
269 |
|
270 // ----------------------------------------------------------------------------- |
|
271 // CSIPConnection::__DbgTestInvariant |
|
272 // ----------------------------------------------------------------------------- |
|
273 |
|
274 void CSIPConnection::__DbgTestInvariant() const |
|
275 { |
|
276 if (!iImplementation) |
|
277 { |
|
278 User::Invariant(); |
|
279 } |
|
280 } |