|
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 MCEPRECONDITIONS_H |
|
22 #define MCEPRECONDITIONS_H |
|
23 |
|
24 #include <e32std.h> |
|
25 #include "mcemediadefs.h" |
|
26 #include "mcesrv.h" |
|
27 #include "mcesip.h" |
|
28 |
|
29 class CMceComMediaStream; |
|
30 class CSdpMediaField; |
|
31 class CSdpAttributeField; |
|
32 class RStringF; |
|
33 class RStringPool; |
|
34 class TStringTable; |
|
35 |
|
36 /** |
|
37 * |
|
38 * |
|
39 * @lib |
|
40 */ |
|
41 |
|
42 class TMcePreconditions |
|
43 { |
|
44 |
|
45 |
|
46 public: // |
|
47 |
|
48 enum TState |
|
49 { |
|
50 ECreated, |
|
51 ENegotiating, |
|
52 EReserved |
|
53 }; |
|
54 |
|
55 enum TPreconditionType |
|
56 { |
|
57 EQosPreconds = 1, |
|
58 ESecPreconds |
|
59 }; |
|
60 |
|
61 public: // Constructors & Destructor |
|
62 |
|
63 |
|
64 /** |
|
65 * C++ default constructor. |
|
66 */ |
|
67 TMcePreconditions( CMceComMediaStream& aStream ); |
|
68 |
|
69 virtual ~TMcePreconditions(); |
|
70 void ConstructL(); |
|
71 |
|
72 |
|
73 public: // API |
|
74 |
|
75 virtual void EncodeL( CSdpMediaField& aMedia ) = 0; |
|
76 virtual TMceSipWarningCode DecodeL( CSdpMediaField& aMedia ) = 0; |
|
77 virtual void Reserved() = 0; |
|
78 virtual TBool ReservationNeeded() const = 0; |
|
79 virtual TBool RemoteReservationNeeded() const = 0; |
|
80 virtual TMcePreconditions* CloneL( CMceComMediaStream& aStream ) = 0; |
|
81 |
|
82 TBool IsMet() const; |
|
83 |
|
84 TPreconditionType Type(); |
|
85 |
|
86 |
|
87 protected: //methods |
|
88 |
|
89 virtual void DoConstructL() = 0; |
|
90 void ConstrucL( const TMcePreconditions& aPreconditions ); |
|
91 |
|
92 protected: //data |
|
93 |
|
94 CMceComMediaStream& iStream; |
|
95 TState iState; |
|
96 RStringPool iStringPool; |
|
97 const TStringTable* iStringTable; |
|
98 TPreconditionType iType; |
|
99 |
|
100 |
|
101 protected: //data |
|
102 |
|
103 RStringF iKAttributeCurr; |
|
104 RStringF iKAttributeDes; |
|
105 RStringF iKAttributeConf; |
|
106 RStringF iKAttributeNone; |
|
107 RStringF iKAttributeSend; |
|
108 RStringF iKAttributeRecv; |
|
109 RStringF iKAttributeSendRecv; |
|
110 RStringF iKAttributeRemote; |
|
111 RStringF iKAttributeLocal; |
|
112 RStringF iKAttributeMandatory; |
|
113 RStringF iKAttributeOptional; |
|
114 RStringF iKAttributeFailure; |
|
115 RStringF iKAttributeUnknown; |
|
116 RStringF iKAttributeEnd2End; |
|
117 |
|
118 private: |
|
119 friend class TMcePreconditionsFactory; |
|
120 |
|
121 }; |
|
122 |
|
123 |
|
124 /** |
|
125 * |
|
126 * |
|
127 * @lib |
|
128 */ |
|
129 class TMceSegmentedPreconditions : public TMcePreconditions |
|
130 { |
|
131 |
|
132 |
|
133 public: // Constructors & Destructor |
|
134 |
|
135 |
|
136 /** |
|
137 * C++ default constructor. |
|
138 */ |
|
139 TMceSegmentedPreconditions( CMceComMediaStream& aStream ); |
|
140 |
|
141 |
|
142 public: // from TMcePreconditions |
|
143 |
|
144 void EncodeL( CSdpMediaField& aMedia ); |
|
145 TMceSipWarningCode DecodeL( CSdpMediaField& aMedia ); |
|
146 void Reserved(); |
|
147 TBool ReservationNeeded() const; |
|
148 TBool RemoteReservationNeeded() const; |
|
149 TMcePreconditions* CloneL( CMceComMediaStream& aStream ); |
|
150 |
|
151 private: //from TMcePreconditions |
|
152 |
|
153 void DoConstructL(); |
|
154 |
|
155 private: //encode |
|
156 |
|
157 void EncodeCurrentStatusL( CSdpMediaField& aMedia, |
|
158 RStringF aAccessNetwork ) const; |
|
159 void EncodeDesiredStatusL( CSdpMediaField& aMedia, |
|
160 RStringF aAccessNetwork ) const; |
|
161 void EncodeConfirmationL( CSdpMediaField& aMedia ); |
|
162 |
|
163 HBufC8* CurrentStausTextLC( const TDesC8& aAccessNetwork, |
|
164 const TDesC8& aMediaDirection ) const; |
|
165 HBufC8* DesiredStausTextLC( const TDesC8& aStrength, |
|
166 const TDesC8& aAccessNetwork, |
|
167 const TDesC8& aMediaDirection ) const; |
|
168 |
|
169 private: //decode |
|
170 |
|
171 TUint DecodeCurrentStatusL( CSdpAttributeField& aAttribute ); |
|
172 TUint DecodeDesiredStatusL( CSdpAttributeField& aAttribute ); |
|
173 TUint DecodeConfStatusL( CSdpAttributeField& aAttribute ); |
|
174 TInt ParseCurrentStatus( const TDesC8& aLine, |
|
175 TPtrC8& aAccessNetwork, |
|
176 TPtrC8& aMediaDirection ); |
|
177 TInt ParseDesiredStatus( const TDesC8& aLine, |
|
178 TPtrC8& aStrength, |
|
179 TPtrC8& aAccessNetwork, |
|
180 TPtrC8& aMediaDirection ); |
|
181 |
|
182 RStringF DecodeMediaDirectionL( const TDesC8& aMediaDirection ); |
|
183 RStringF DecodeStrengthL( const TDesC8& aStrength ); |
|
184 |
|
185 private: |
|
186 |
|
187 void SetState(); |
|
188 void SetRemoteStatus( RStringF aDirection ); |
|
189 RStringF DesiredDirection( RStringF aAccessNetwork ); |
|
190 void SetDesiredStatus( RStringF aAccessNetwork, |
|
191 RStringF aDirection, |
|
192 RStringF sStrength ); |
|
193 void ConstrucL( const TMceSegmentedPreconditions& aPreconditions ); |
|
194 |
|
195 |
|
196 private: //data |
|
197 |
|
198 |
|
199 RStringF iCurrentLocalStatus; |
|
200 RStringF iCurrentRemoteStatus; |
|
201 RStringF iDesiredLocalSend; |
|
202 RStringF iDesiredLocalRecv; |
|
203 RStringF iDesiredRemoteSend; |
|
204 RStringF iDesiredRemoteRecv; |
|
205 RStringF iConfirmation; |
|
206 |
|
207 |
|
208 //definitions for unit testing |
|
209 MCEMM_UT_DEFINITIONS |
|
210 |
|
211 |
|
212 }; |
|
213 |
|
214 /** |
|
215 * |
|
216 * |
|
217 * @lib |
|
218 */ |
|
219 class TMceSecurePreconditions : public TMcePreconditions |
|
220 { |
|
221 |
|
222 |
|
223 public: // Constructors & Destructor |
|
224 |
|
225 |
|
226 /** |
|
227 * C++ default constructor. |
|
228 */ |
|
229 TMceSecurePreconditions( CMceComMediaStream& aStream ); |
|
230 |
|
231 |
|
232 public: // from TMcePreconditions |
|
233 |
|
234 void EncodeL( CSdpMediaField& aMedia ); |
|
235 TMceSipWarningCode DecodeL( CSdpMediaField& aMedia ); |
|
236 void Reserved(); |
|
237 TBool ReservationNeeded() const; |
|
238 TBool RemoteReservationNeeded() const; |
|
239 TMcePreconditions* CloneL( CMceComMediaStream& aStream ); |
|
240 |
|
241 private: //from TMcePreconditions |
|
242 |
|
243 void DoConstructL(); |
|
244 |
|
245 private: //encode |
|
246 |
|
247 void EncodeCurrentStatusL( CSdpMediaField& aMedia, |
|
248 TMceNegotiationRole aRole ); |
|
249 |
|
250 void EncodeDesiredStatusL( CSdpMediaField& aMedia ); |
|
251 |
|
252 void EncodeConfirmationL( CSdpMediaField& aMedia ); |
|
253 |
|
254 HBufC8* CurrentStatusTextLC( const TDesC8& aMediaDirection ) const; |
|
255 |
|
256 HBufC8* DesiredStatusTextLC( const TDesC8& aStrength, |
|
257 const TDesC8& aMediaDirection ) const; |
|
258 |
|
259 |
|
260 protected: //decode |
|
261 |
|
262 TUint DecodeCurrentStatusL( CSdpAttributeField& aAttribute ); |
|
263 |
|
264 TUint DecodeDesiredStatusL( CSdpAttributeField& aAttribute ); |
|
265 |
|
266 TUint DecodeConfStatusL( CSdpAttributeField& aAttribute ); |
|
267 |
|
268 TBool ParseCurrentStatus( const TDesC8& aLine, |
|
269 TPtrC8& aMediaDirection ); |
|
270 |
|
271 TBool ParseDesiredStatus( const TDesC8& aLine, |
|
272 TPtrC8& aStrength, |
|
273 TPtrC8& aMediaDirection ); |
|
274 |
|
275 RStringF DecodeMediaDirectionL( const TDesC8& aMediaDirection ); |
|
276 |
|
277 RStringF DecodeStrengthL( const TDesC8& aStrength ); |
|
278 |
|
279 private: |
|
280 |
|
281 void SetState(); |
|
282 |
|
283 void SetRemoteStatus( RStringF aDirection ); |
|
284 |
|
285 void SetDesiredStatus( RStringF aEntity, RStringF sStrength ); |
|
286 |
|
287 TBool FindSecPreconds( CSdpMediaField& aMedia ); |
|
288 |
|
289 TBool StrengthDowngraded( RStringF aStrength ); |
|
290 |
|
291 void ConstrucL( const TMceSecurePreconditions& aPreconditions ); |
|
292 |
|
293 private: //data |
|
294 |
|
295 RStringF iCurrentLocalStatus; |
|
296 RStringF iCurrentRemoteStatus; |
|
297 RStringF iDesiredLocalSendRecv; |
|
298 RStringF iDesiredRemoteSendRecv; |
|
299 RStringF iConfirmation; |
|
300 |
|
301 //definitions for unit testing |
|
302 MCEMM_UT_DEFINITIONS |
|
303 }; |
|
304 |
|
305 |
|
306 class TMcePreconditionsFactory |
|
307 { |
|
308 public: |
|
309 TMcePreconditions* CreateL( CMceComMediaStream& aMediaStream, CSdpMediaField& aMediaLine ); |
|
310 TMcePreconditions* CreateL( CMceComMediaStream& aMediaStream ); |
|
311 |
|
312 TInt iDummy; |
|
313 }; |
|
314 |
|
315 #endif //MCEPRECONDITIONS_H |