|
1 /* |
|
2 * Copyright (c) 2007-2008 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: header file for sipmxresolver |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CSIPMXRESOLVER_H |
|
19 #define CSIPMXRESOLVER_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <apgcli.h> |
|
23 #include <e32base.h> |
|
24 #include <implementationproxy.h> |
|
25 #include <sipresolvedclient2.h> |
|
26 #include "sipmxresolverdebug.h" |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class CSdpDocument; |
|
30 class CSdpMediaField; |
|
31 class CMusManager; |
|
32 |
|
33 /** |
|
34 * SIP MX Resolver |
|
35 * |
|
36 * SIP MX Resolver implements CSIPResolvedClient2 ECOM API. |
|
37 * It aids SIP Client Resolver component to route the incoming invites |
|
38 * either to Multimedia Sharing / VoIP client according to |
|
39 * request headers and content. It also takes relevant phone state |
|
40 * variables into account when resolving. |
|
41 * |
|
42 * @lib sipmxresolver |
|
43 * @since Series 60 3.2 |
|
44 */ |
|
45 class CSipMXResolver : public CSIPResolvedClient2 |
|
46 { |
|
47 public: // Constructors and destructor |
|
48 |
|
49 /** |
|
50 * Two-phased constructor. |
|
51 */ |
|
52 static CSipMXResolver* NewL(); |
|
53 |
|
54 /** |
|
55 * Destructor. |
|
56 */ |
|
57 virtual ~CSipMXResolver(); |
|
58 |
|
59 |
|
60 public: // From CSIPResolvedClient2 |
|
61 |
|
62 /** |
|
63 * Matches the Accept-Contact-headers |
|
64 * to the client(s) represented by this plug-in. |
|
65 * This function is called for an incoming SIP request |
|
66 * if it contains Accept-Contact-header(s). |
|
67 * |
|
68 * @param aMethod the method of the SIP request |
|
69 * @param aRequestUri the request-URI of the SIP request |
|
70 * @param aHeaders all the headers in the SIP request |
|
71 * @param aContent SIP request body; |
|
72 * zero-length descriptor if not present |
|
73 * @param aContentType the content-type of the SIP request. |
|
74 * Zero-pointer if body is not present. |
|
75 * @param aClientUid indicates client's UID for |
|
76 * SIP e.g. the one passed as a parameter to CSIP::NewL(). |
|
77 * @return ETrue, if the Accept-Contact-headers match to the client |
|
78 * represented by this plug-in, otherwise EFalse. |
|
79 */ |
|
80 TBool MatchAcceptContactsL( |
|
81 RStringF aMethod, |
|
82 const CUri8& aRequestUri, |
|
83 const RPointerArray<CSIPHeaderBase>& aHeaders, |
|
84 const TDesC8& aContent, |
|
85 const CSIPContentTypeHeader* aContentType, |
|
86 TUid& aClientUid ); |
|
87 |
|
88 /** |
|
89 * Matches the Event-header to the client(s) represented by this plug-in. |
|
90 * This function is called for an incoming SIP request, |
|
91 * if it contains an Event-header and |
|
92 * MatchAcceptContactsL returned EFalse. |
|
93 * |
|
94 * @param aMethod the method of the SIP request |
|
95 * @param aRequestUri the request-URI of the SIP request |
|
96 * @param aHeaders all the headers in the SIP request |
|
97 * @param aContent SIP request body; |
|
98 * zero-length descriptor if not present |
|
99 * @param aContentType the content-type of the SIP request. |
|
100 * Zero-pointer if body is not present. |
|
101 * @param aClientUid indicates client's UID for |
|
102 * SIP e.g. the one passed as a parameter to CSIP::NewL(). |
|
103 * @return ETrue, if the Event-header matches to the client |
|
104 * represented by this plug-in, otherwise EFalse. |
|
105 */ |
|
106 TBool MatchEventL( |
|
107 RStringF aMethod, |
|
108 const CUri8& aRequestUri, |
|
109 const RPointerArray<CSIPHeaderBase>& aHeaders, |
|
110 const TDesC8& aContent, |
|
111 const CSIPContentTypeHeader* aContentType, |
|
112 TUid& aClientUid ); |
|
113 |
|
114 /** |
|
115 * Matches the whole SIP request to the client(s) |
|
116 * represented by this plug-in. |
|
117 * This function is called if the SIP request does not contain |
|
118 * Accept- or Event-headers or |
|
119 * MatchAcceptContactsL and MatchEventL returned EFalse. |
|
120 * |
|
121 * @param aMethod the method of the SIP request |
|
122 * @param aRequestUri the request-URI of the SIP request |
|
123 * @param aHeaders all the headers in the SIP request |
|
124 * @param aContent SIP request body; |
|
125 * zero-length descriptor if not present |
|
126 * @param aContentType the content-type of the SIP request. |
|
127 * Zero-pointer if body is not present. |
|
128 * @param aClientUid indicates client's UID for |
|
129 * SIP e.g. the one passed as a parameter to CSIP::NewL(). |
|
130 * @return ETrue, if the request can be handled by the client |
|
131 * represented by this plug-in, otherwise EFalse. |
|
132 */ |
|
133 TBool MatchRequestL( |
|
134 RStringF aMethod, |
|
135 const CUri8& aRequestUri, |
|
136 const RPointerArray<CSIPHeaderBase>& aHeaders, |
|
137 const TDesC8& aContent, |
|
138 const CSIPContentTypeHeader* aContentType, |
|
139 TUid& aClientUid ); |
|
140 |
|
141 /** |
|
142 * Indicates whether the plug-in implements CSIPResolvedClient2::ConnectL |
|
143 * and by calling CSIPResolvedClient2::ConnectL |
|
144 * SIP stack is able to force the client to connect to SIP stack. |
|
145 * |
|
146 * @return ETrue, if the plug-in supports |
|
147 * CSIPResolvedClient2::ConnectL, otherwise EFalse. |
|
148 */ |
|
149 TBool ConnectSupported(); |
|
150 |
|
151 /** |
|
152 * Requests the client to connect to SIP with resolved |
|
153 * UID in case there's no connection with resolved channel UID. |
|
154 * |
|
155 * @param aClientUid previously resolved channel UID |
|
156 * @leave KErrNoMemory if out of memory |
|
157 * @leave KErrNotFound in case non-existing channel UID was provided |
|
158 */ |
|
159 void ConnectL( const TUid& aClientUid ); |
|
160 |
|
161 /** |
|
162 * Cancels a ConnectL request for a client. |
|
163 * Is called when for example a CANCEL for an INVITE is received |
|
164 * before the client connects to SIP stack. |
|
165 * |
|
166 * @param aClientUid a UID for which ConnectL was previously called |
|
167 */ |
|
168 void CancelConnect( const TUid& aClientUid ); |
|
169 |
|
170 /** |
|
171 * Gets all the SIP message content types supported by the client. |
|
172 * |
|
173 * @return 0..n SIP Content-Type-headers. |
|
174 * The ownership of the headers is transferred. |
|
175 */ |
|
176 RPointerArray<CSIPContentTypeHeader> SupportedContentTypesL(); |
|
177 |
|
178 /** |
|
179 * Gets all the SDP media-fields supported by the client. |
|
180 * |
|
181 * @return 0..n SDP media-fields describing the client's media support. |
|
182 * The ownership of the media-fields is transferred. |
|
183 */ |
|
184 RPointerArray<CSdpMediaField> SupportedSdpMediasL(); |
|
185 |
|
186 /** |
|
187 * Adds client specific SIP-headers for the 200 OK for OPTIONS. |
|
188 * Each plug-in must check that the header to be added |
|
189 * is not yet in the array. For example when adding header |
|
190 * "Allow: INVITE" the client must check that |
|
191 * the header is not already present in the array. |
|
192 * |
|
193 * @param aHeaders headers to be added to 200 OK for OPTIONS. |
|
194 * The ownership of the added headers is transferred to the caller. |
|
195 */ |
|
196 void AddClientSpecificHeadersForOptionsResponseL( |
|
197 RPointerArray<CSIPHeaderBase>& aHeaders ); |
|
198 |
|
199 |
|
200 private: // Constructors |
|
201 |
|
202 /** |
|
203 * C++ default constructor. |
|
204 */ |
|
205 CSipMXResolver(); |
|
206 |
|
207 /** |
|
208 * By default Symbian 2nd phase constructor is private. |
|
209 */ |
|
210 void ConstructL(); |
|
211 |
|
212 |
|
213 private: // New functions |
|
214 |
|
215 /** |
|
216 * Checks given header array for accept-contact (AC) headers and |
|
217 * returns ETrue if there is an AC header and it contains |
|
218 * given feature tag. |
|
219 * |
|
220 * @param aHeaders Headers from request to check |
|
221 * @param aTag Feature specific tag to check AC header for |
|
222 * @ret ETrue if the AC header contain the given feature tag |
|
223 */ |
|
224 TBool CheckForACHeaderTagL( |
|
225 const RPointerArray<CSIPHeaderBase>& aHeaders, |
|
226 const TDesC8& aTag ) const; |
|
227 |
|
228 /** |
|
229 * Checks a SDP document for specified media type lines |
|
230 * |
|
231 * @param aSpdDoc pointer to sdp document to check for medias |
|
232 * @param aMediaType specifies the media type to check for |
|
233 * @return ETrue if aSpdDoc contains m lines with |
|
234 * given media type. |
|
235 */ |
|
236 TBool CheckForMedia( |
|
237 CSdpDocument* aSdpDoc, |
|
238 const RStringF& aMediaType ) const; |
|
239 |
|
240 /** |
|
241 * Checks given sdp media fields array for VS specific attributes |
|
242 * |
|
243 * @aFields array of media fields to check |
|
244 * @return ETrue if the given media fields contain |
|
245 * VS specific attributes |
|
246 */ |
|
247 TBool CheckForVSAttributes( |
|
248 RPointerArray<CSdpMediaField>& aFields ) const; |
|
249 |
|
250 /** |
|
251 * Checks if a CS call is ongoing. This information is |
|
252 * used in the resolving logic. |
|
253 * |
|
254 * @return ETrue if there is an active CS call |
|
255 */ |
|
256 TBool IsCSCallActive() const; |
|
257 |
|
258 /** |
|
259 * Resolves the Uid to return in VS cases based on request method |
|
260 * |
|
261 * @param aMethod SIP request method |
|
262 * @return Uid that corresponds to the given method. KNullUid if no match. |
|
263 */ |
|
264 TUid ResolveVSUidL( const RStringF& aMethod ); |
|
265 |
|
266 /** |
|
267 * Resolves the Uid of CCP plugin if VoIP is recogniced |
|
268 * |
|
269 * @param aUid Resolved UID |
|
270 * @param aRequestUri URI received in request |
|
271 */ |
|
272 void ResolveCPPluginUidL( TUid& aUid, const CUri8& aRequestUri ); |
|
273 |
|
274 |
|
275 private: // Data |
|
276 |
|
277 ///own: VoIP availability status |
|
278 TBool iVoIPEnabled; |
|
279 ///own: Multimedia Sharing client for Uid resolving |
|
280 CMusManager* iMuSManager; |
|
281 ///own: RStringF handles to video/audio media strings from SIPStrings |
|
282 RStringF iVideoType; |
|
283 RStringF iAudioType; |
|
284 ///own: String pool closing control; if ETrue, pool is closed in dtor |
|
285 TBool iCloseStringPool; |
|
286 |
|
287 SIPMXR_TEST( UT_CSipMXResolver ) // for unit tests |
|
288 |
|
289 }; |
|
290 |
|
291 #endif // CSIPMXRESOLVER_H |
|
292 |
|
293 // End of File |
|
294 |