|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Provide interface for the client requestin network availability. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __MUSAVADEFAULTOPTIONEHANDLER_H__ |
|
21 #define __MUSAVADEFAULTOPTIONEHANDLER_H__ |
|
22 |
|
23 |
|
24 #include "musavaavailability.h" |
|
25 #include "musavaobserver.h" |
|
26 #include "musavainviteresponderobserver.h" |
|
27 #include "musavasipconnectionadapter.h" |
|
28 #include "musavasipadapter.h" |
|
29 #include "mussettingskeys.h" |
|
30 #include "musunittesting.h" |
|
31 #include <e32base.h> |
|
32 #include <sipstrconsts.h> |
|
33 |
|
34 |
|
35 class CSIPServerTransaction; |
|
36 class CMusAvaInviteResponder; |
|
37 class CMusAvaSharedObject; |
|
38 class CSIPResponseElements; |
|
39 class MMusAvaAvailabilityObserver; |
|
40 class CSIPResponse; |
|
41 class CSdpDocument; |
|
42 class CSdpOriginField; |
|
43 class RStringF; |
|
44 class CSdpMediaField; |
|
45 class CSdpFmtAttributeField; |
|
46 class CMusAvaSettingsImp; |
|
47 |
|
48 |
|
49 /** |
|
50 * Implements handling of non-desired SIP invites. |
|
51 * |
|
52 * Provide interface for the client to availability class. |
|
53 * |
|
54 * @lib musavailabilityplugin.lib |
|
55 * @since S60 v3.2 |
|
56 */ |
|
57 class CMusAvaDefaultOptionHandler : public CMusAvaAvailability, |
|
58 public MMusAvaSipConnectionAdapter, |
|
59 public MMusAvaSipAdapter |
|
60 { |
|
61 public: |
|
62 /** |
|
63 * Two-phased constructor |
|
64 * |
|
65 * @param aObserver Pointer to observer intercase |
|
66 * @param aName availability name |
|
67 * @param aModules is data container |
|
68 * @return Returns pointer to CMusAvaInterface object |
|
69 */ |
|
70 |
|
71 static CMusAvaDefaultOptionHandler* NewL( |
|
72 MMusAvaAvailabilityObserver& aObserver, |
|
73 CMusAvaSettingsImp& aConcreteSettings ); |
|
74 |
|
75 /** |
|
76 * Two-phased constructor |
|
77 * |
|
78 * @param aObserver Pointer to observer intercase |
|
79 * @param aName availability name |
|
80 * @param aModules is data container |
|
81 * @return Returns pointer to CMusAvaInterface object |
|
82 */ |
|
83 |
|
84 static CMusAvaDefaultOptionHandler* NewLC( |
|
85 MMusAvaAvailabilityObserver& aObserver, |
|
86 CMusAvaSettingsImp& aConcreteSettings ); |
|
87 |
|
88 /** |
|
89 * Destructor. |
|
90 */ |
|
91 ~CMusAvaDefaultOptionHandler(); |
|
92 |
|
93 private: |
|
94 |
|
95 /** |
|
96 * Handles incoming Option request |
|
97 * |
|
98 * @param aTransaction Pointer to CSIPServerTransaction |
|
99 */ |
|
100 void IncomingOptionRequestL( CSIPServerTransaction* aTransaction ); |
|
101 |
|
102 /** |
|
103 * Send Response to reques. |
|
104 * |
|
105 * @param aResponseElements Pointer to CSIPResponseElements |
|
106 * @param aTransaction Pointer to CSIPServerTransaction |
|
107 */ |
|
108 void ResponseL( CSIPResponseElements* aResponseElements, |
|
109 CSIPServerTransaction* aTransaction ); |
|
110 |
|
111 /** |
|
112 * Send No capability response to request. |
|
113 * |
|
114 * @param aTransaction Reference to CSIPServerTransaction |
|
115 * @param aStatusCode a known SIP response status code |
|
116 * @param aReason reason string |
|
117 */ |
|
118 void NoCapabilityResponseL( CSIPServerTransaction* aTransaction, |
|
119 TUint aStatusCode, |
|
120 SipStrConsts::TStrings aReason ); |
|
121 |
|
122 /** |
|
123 * Create CSIPResponseElements for the OPTION response. |
|
124 * |
|
125 * @param aTransaction Reference to CSIPServerTransaction |
|
126 * @return CSIPResponseElements is returned, |
|
127 */ |
|
128 CSIPResponseElements* CreateResponseL( |
|
129 CSIPServerTransaction& aTransaction ); |
|
130 |
|
131 /** |
|
132 * Create Sdp for the OPTION response. |
|
133 * |
|
134 * @param aTransaction Pointer to CSIPServerTransaction |
|
135 * @return CSdpDocument is returned, |
|
136 */ |
|
137 CSdpDocument* CreateSDPL( CSIPServerTransaction& aTransaction ); |
|
138 |
|
139 /** |
|
140 * Create Origin Field for SDP. |
|
141 * |
|
142 * @param aLocalHost Reference to IP address |
|
143 * @param aHostType Reference to IP address type |
|
144 * @return CSdpOriginField is returned. |
|
145 */ |
|
146 CSdpOriginField* CreateOriginFieldL( |
|
147 const TDesC8& aLocalHost, |
|
148 const RStringF& aHostType) const; |
|
149 /** |
|
150 * Creates SDP string to pool |
|
151 * |
|
152 * @param aString the string as descriptor |
|
153 * @return SDP String |
|
154 */ |
|
155 static RStringF SDPStringL( const TDesC8& aString ); |
|
156 |
|
157 /** |
|
158 * Creates SDP string to pool |
|
159 * |
|
160 * @param aStringIndex index for SDP strings |
|
161 * @return SDP String |
|
162 */ |
|
163 static RStringF SDPStringL( TInt aStringIndex ); |
|
164 |
|
165 /** |
|
166 * Resolves local host |
|
167 * |
|
168 * @param aLocalHost IP address to be set |
|
169 * @param aHostType IP address type to be set |
|
170 * @return feature set |
|
171 */ |
|
172 static void LocalHostL( const CSIPServerTransaction& aRequest, |
|
173 TPtrC8& aLocalHost, |
|
174 RStringF& aHostType); |
|
175 |
|
176 /** |
|
177 * Creates media line |
|
178 * |
|
179 * @param aMedia name of the media |
|
180 * @param aFormatList format list |
|
181 * @return media line |
|
182 */ |
|
183 CSdpMediaField* MediaLineLC( const RStringF& aMedia, |
|
184 const TDesC8& aFormatList ) const; |
|
185 |
|
186 |
|
187 /** |
|
188 * Creates rtpmap line |
|
189 * |
|
190 * @param aCodec name of coded |
|
191 * @param aPayloadType payload type |
|
192 * @param aClockRate clockrate |
|
193 * @param aParams optional params |
|
194 * @return rtpmap line |
|
195 */ |
|
196 CSdpFmtAttributeField* RtpMapLineLC( const TDesC8& aCodec, |
|
197 const TUint64 aPayloadType, |
|
198 const TUint64 aClockRate, |
|
199 const TDesC8& aParams = KNullDesC8 ) const; |
|
200 |
|
201 /** |
|
202 * Helper to transform SDP document to text |
|
203 * |
|
204 * @param aSdpContent SDP document |
|
205 * @return SDP document as text |
|
206 */ |
|
207 static HBufC8* ToTextL( CSdpDocument& aSdpContent ); |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 public: //From MMusAvaSipConnectionAdapter |
|
213 |
|
214 /** |
|
215 * A SIP request outside a dialog has been received from the network. |
|
216 * |
|
217 * @pre aTransaction != 0 |
|
218 * @param aTransaction SIP server transaction. The ownership is |
|
219 * transferred. |
|
220 */ |
|
221 virtual TInt IncomingRequest (CSIPServerTransaction* aTransaction); |
|
222 |
|
223 public: //From MMusAvaSipAdapter |
|
224 |
|
225 /** |
|
226 * A SIP request has been received from the network. |
|
227 * This function is called when the SIP request was received using such |
|
228 * an IAP, for which the application has not created a CSIPConnection |
|
229 * object. |
|
230 * @pre aTransaction != 0 |
|
231 * @param aIapId The IapId from which the SIP request was received. |
|
232 * @param aTransaction contains local address, remote address of a SIP |
|
233 * message, as well as optional SIP message method, headers and |
|
234 * body. The ownership is transferred. |
|
235 */ |
|
236 virtual TInt IncomingRequest(TUint32 aIapId, |
|
237 CSIPServerTransaction* aTransaction); |
|
238 |
|
239 /** |
|
240 * The received SIP request time-outed and it is invalid i.e. cannot be used |
|
241 * anymore. |
|
242 * This will be called if the user fails to create a SIP connection and |
|
243 * does not send an appropriate SIP response. |
|
244 * @param aTransaction The time-outed transaction. |
|
245 */ |
|
246 virtual TInt TimedOut(CSIPServerTransaction& aTransaction); |
|
247 |
|
248 protected: |
|
249 |
|
250 /** |
|
251 * Constructor |
|
252 * |
|
253 * @since S60 v3.2 |
|
254 * @param aObserver Pointer to observer intercase |
|
255 * @param aName availability name |
|
256 * @param aModules is data container |
|
257 * @return |
|
258 */ |
|
259 |
|
260 CMusAvaDefaultOptionHandler( |
|
261 MMusAvaAvailabilityObserver& aObserver, |
|
262 CMusAvaSettingsImp& aConcreteSettings ); |
|
263 |
|
264 |
|
265 |
|
266 /** |
|
267 * Perform the second phase construction of a |
|
268 * CMusAvaDefaultOptionHandler object |
|
269 * |
|
270 * @since S60 v3.2 |
|
271 * @param |
|
272 * @return |
|
273 */ |
|
274 |
|
275 void ConstructL(); |
|
276 |
|
277 |
|
278 |
|
279 // from base class CMusAvaAvailability |
|
280 |
|
281 public: |
|
282 |
|
283 /** |
|
284 * Executes for the availability. |
|
285 * |
|
286 * @since S60 v3.2 |
|
287 * @return KErrNone if ExecutePatternL operation was |
|
288 * successfully executed; system wide error otherwise |
|
289 */ |
|
290 virtual void DoExecuteL(); |
|
291 |
|
292 |
|
293 /** |
|
294 * Return availability name. |
|
295 * |
|
296 * @since S60 v3.2 |
|
297 * @param |
|
298 * @return TAvailabilityName is returned |
|
299 */ |
|
300 virtual MMusAvaObserver::TAvailabilityName Name(); |
|
301 |
|
302 |
|
303 private: |
|
304 |
|
305 /** |
|
306 * Reference to availability settings (data store) |
|
307 */ |
|
308 CMusAvaSettingsImp& iSettings; |
|
309 |
|
310 /** |
|
311 * Pointer to CMusAvaSharedObject object |
|
312 */ |
|
313 CMusAvaSharedObject* iSharedObj; |
|
314 |
|
315 /** |
|
316 * Operator variant indicator |
|
317 */ |
|
318 MusSettingsKeys::TOperatorVariant iOperatorVariant; |
|
319 |
|
320 MUS_UNITTEST ( UT_CMusAvaDefaultOptionHandler ) |
|
321 }; |
|
322 |
|
323 |
|
324 #endif // __MUSAVADEFAULTOPTIONEHANDLER_H__ |