|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CMCECLIENRESOLVER_H |
|
22 #define CMCECLIENRESOLVER_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <sipclientdiscoveryobserver.h> |
|
26 |
|
27 #include "mcesrv.h" |
|
28 |
|
29 |
|
30 class CSIPClientDiscovery; |
|
31 class CSIPServerTransaction; |
|
32 class CMceSipConnection; |
|
33 class CSIPRequestElements; |
|
34 class CSIPHeaderBase; |
|
35 |
|
36 /** |
|
37 * Client resolver observer |
|
38 * |
|
39 * @lib |
|
40 */ |
|
41 class MMceClientResolverObserver |
|
42 { |
|
43 public: |
|
44 |
|
45 /** |
|
46 * Called when client discovery subsystem has resolved |
|
47 * the client the transaction should go to |
|
48 * |
|
49 * @param aClientUid Client's uid |
|
50 * @param aConnection the connection used |
|
51 * @param aRequest the transaction |
|
52 */ |
|
53 virtual void IncomingResolvedRequest( TUid aClientUid, |
|
54 CMceSipConnection& aConnection, |
|
55 CSIPServerTransaction* aRequest ) = 0; |
|
56 |
|
57 |
|
58 }; |
|
59 |
|
60 |
|
61 |
|
62 /** |
|
63 * Client resolver class |
|
64 * |
|
65 * @lib |
|
66 */ |
|
67 class CMceClientResolver : public CBase, |
|
68 public MSIPClientDiscoveryObserver |
|
69 { |
|
70 |
|
71 |
|
72 /** |
|
73 * Routing request class |
|
74 * |
|
75 * @lib |
|
76 */ |
|
77 class CMceRoutingRequest : public CBase |
|
78 { |
|
79 |
|
80 public: // Constructors and destructor |
|
81 |
|
82 /** |
|
83 * Constructor |
|
84 * |
|
85 * @param aResolverRequestId request id given by the client discovery |
|
86 * @param aConnection the connection |
|
87 * @param aRequest the request whose information has been given to CD |
|
88 */ |
|
89 CMceRoutingRequest( TUint32 aResolverRequestId, |
|
90 CMceSipConnection& aConnection, |
|
91 CSIPServerTransaction* aRequest ); |
|
92 |
|
93 /** |
|
94 * Destructor |
|
95 */ |
|
96 ~CMceRoutingRequest (); |
|
97 |
|
98 public: // New functions |
|
99 |
|
100 /** |
|
101 * Link offset |
|
102 */ |
|
103 static TInt LinkOffset(); |
|
104 |
|
105 /** |
|
106 * Returns request id given by the client discovery |
|
107 * @return request id given by the client discovery |
|
108 */ |
|
109 TUint32 ResolverRequestId() const; |
|
110 |
|
111 /** |
|
112 * Returns request. Ownership is transferred |
|
113 * @return the request |
|
114 */ |
|
115 CSIPServerTransaction* Request(); |
|
116 |
|
117 /** |
|
118 * Returns connection. |
|
119 * @return the connection |
|
120 */ |
|
121 CMceSipConnection& Connection() const; |
|
122 |
|
123 private: // Data |
|
124 |
|
125 TSglQueLink iLink; |
|
126 TUint32 iResolverRequestId; |
|
127 CSIPServerTransaction* iRequest; |
|
128 CMceSipConnection& iConnection; |
|
129 |
|
130 //definitions for unit testing |
|
131 MCESRV_UT_DEFINITIONS |
|
132 |
|
133 }; |
|
134 |
|
135 |
|
136 public: // Contstructors and destructor |
|
137 |
|
138 /** |
|
139 * Constructor |
|
140 * |
|
141 * @param aRequestHandler who is handling the resolved request |
|
142 */ |
|
143 static CMceClientResolver* NewL( MMceClientResolverObserver& aRequestHandler ); |
|
144 |
|
145 /** |
|
146 * Constructor |
|
147 * |
|
148 * @param aRequestHandler who is handling the resolved request |
|
149 */ |
|
150 static CMceClientResolver* NewLC( MMceClientResolverObserver& aRequestHandler ); |
|
151 |
|
152 /** |
|
153 * Destructor |
|
154 */ |
|
155 ~CMceClientResolver (); |
|
156 |
|
157 public: // New functions |
|
158 |
|
159 /** |
|
160 * Registers client |
|
161 * |
|
162 * @param aClientUid the client's uid |
|
163 */ |
|
164 void RegisterClientL( TUid aClientUid ); |
|
165 |
|
166 /** |
|
167 * De-registers client |
|
168 * |
|
169 * @param aClientUid the client's uid |
|
170 */ |
|
171 void DeregisterClient( TUid aClientUid ); |
|
172 |
|
173 /** |
|
174 * Starts client resolving process for a transaction |
|
175 * |
|
176 * @param aRequest the transaction. Ownership is transferred |
|
177 * @param aConnection the connection |
|
178 */ |
|
179 void RegisterIncomingRequestL( CSIPServerTransaction* aRequest, |
|
180 CMceSipConnection& aConnection ); |
|
181 |
|
182 |
|
183 public: // from MSIPClientDiscoveryObserver |
|
184 |
|
185 /** |
|
186 * Channel UID was resolved for the SIP request |
|
187 * @param aChannel a channel UID to which the SIP request |
|
188 * must be routed |
|
189 * @param aRequest a request ID |
|
190 */ |
|
191 void ChannelResolvedL(TUid aChannel, TUint32 aRequestId); |
|
192 |
|
193 /** |
|
194 * The client channel UID was not found. |
|
195 * The implementation of this callback should generate |
|
196 * a SIP response with the provided elements and send it to network. |
|
197 * @param aRequest a request ID |
|
198 * @param aStatusCode contains a SIP response status code |
|
199 * for the SIP response that should be generated. |
|
200 * @param aReasonPhrase contains a SIP response reason phrase |
|
201 * for the SIP response that should be generated. |
|
202 * @param aHeaders contains well-formed optional SIP headers |
|
203 * that include additional information why the client |
|
204 * could not be found. For example Accept-headers that describe |
|
205 * the content-types currently supported. |
|
206 * The ownership is transferred. |
|
207 * @param aContent the body of the response. NULL if not present. |
|
208 * The ownership is transferred. |
|
209 */ |
|
210 void ClientNotFoundL(TUint32 aRequestId, |
|
211 TUint aStatusCode, |
|
212 RStringF aReasonPhrase, |
|
213 RPointerArray<CSIPHeaderBase> aHeaders, |
|
214 HBufC8* aContent); |
|
215 |
|
216 /** |
|
217 * Error occurred during resolution of the client's channel UID. |
|
218 * This callback will also be called if one of the callbacks |
|
219 * ChannelResolvedL or ClientNotFoundL leaves using the leave code. |
|
220 * @param aError error code. |
|
221 */ |
|
222 void ErrorOccurred(TInt aError, TUint32 aRequestId); |
|
223 |
|
224 |
|
225 |
|
226 private: // Second phase constructors |
|
227 |
|
228 /** |
|
229 * Constructor |
|
230 * |
|
231 * @param aRequestHandler who is handling the resolved request |
|
232 */ |
|
233 CMceClientResolver ( MMceClientResolverObserver& aRequestHandler ); |
|
234 |
|
235 /** |
|
236 * Second phase constructor |
|
237 * |
|
238 */ |
|
239 void ConstructL (); |
|
240 |
|
241 CMceClientResolver::CMceRoutingRequest* Find( TUint32 aRequestId ); |
|
242 void RemoveAndDelete( CMceClientResolver::CMceRoutingRequest* aRequest ); |
|
243 |
|
244 void AllHeadersL( const CSIPRequestElements& aRequestElements, |
|
245 RPointerArray<CSIPHeaderBase>& aAllHeaders ); |
|
246 |
|
247 |
|
248 private: // Data |
|
249 |
|
250 CSIPClientDiscovery* iDiscovery; |
|
251 MMceClientResolverObserver& iRequestHandler; |
|
252 TSglQue<CMceClientResolver::CMceRoutingRequest> iList; |
|
253 |
|
254 //definitions for unit testing |
|
255 MCESRV_UT_DEFINITIONS |
|
256 |
|
257 }; |
|
258 |
|
259 #endif // CMCECLIENRESOLVER_H |
|
260 |
|
261 // End of File |