|
1 /* |
|
2 * Copyright (c) 2003-2009 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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Name : SdpTimeField.h |
|
16 * Part of : SDP Codec |
|
17 * Interface : SDK API, SDP Codec API |
|
18 * Version : 1.0 |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 #ifndef CSDPTIMESFIELD_H |
|
25 #define CSDPTIMESFIELD_H |
|
26 |
|
27 // INCLUDES |
|
28 #include <e32base.h> |
|
29 #include <stringpool.h> |
|
30 #include "_sdpdefs.h" |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class RReadStream; |
|
34 class RWriteStream; |
|
35 class CSdpRepeatField; |
|
36 |
|
37 // CLASS DECLARATION |
|
38 /** |
|
39 * @publishedAll |
|
40 * @released |
|
41 * |
|
42 * This class encapsulates the time field and the related zero or |
|
43 * more repeat times fields and an optional time zone adjustment |
|
44 * field of the Session Description Protocol. |
|
45 * |
|
46 * The normative reference for correct formatting and values is |
|
47 * draft-ietf-mmusic-sdp-new-14 unless specified otherwise in |
|
48 * member documentation. The implementation supports this normative |
|
49 * reference, but does not enforce it fully. |
|
50 * |
|
51 * @lib sdpcodec.lib |
|
52 */ |
|
53 class CSdpTimeField : public CBase |
|
54 { |
|
55 public: // Constructors and destructor |
|
56 /** |
|
57 * Constructs a time field. |
|
58 * |
|
59 * @param aText A correctly formatted time field value |
|
60 * terminated by a CRLF followed by zero or more repeat |
|
61 * times and zero or one time zone adjustment fields |
|
62 * separeted by a CRLF. |
|
63 * @param aRecurse Flag to specify whether to decode subfields |
|
64 * also (ETrue) or only the time field (EFalse). |
|
65 * @return a new instance. |
|
66 */ |
|
67 IMPORT_C static CSdpTimeField * DecodeL(const TDesC8& aText, |
|
68 TBool aRecurse = ETrue); |
|
69 |
|
70 /** |
|
71 * Constructs a time field and adds the pointer to the cleanup stack. |
|
72 * |
|
73 * @param aText A correctly formatted time field value |
|
74 * terminated by a CRLF followed by zero or more repeat |
|
75 * times and zero or one time zone adjustment fields |
|
76 * separeted by a CRLF. |
|
77 * @param aRecurse Flag to specify whether to decode subfields |
|
78 * also (ETrue) or only the time field (EFalse). |
|
79 * @return a new instance. |
|
80 */ |
|
81 IMPORT_C static CSdpTimeField * DecodeLC(const TDesC8& aText, |
|
82 TBool aRecurse = ETrue); |
|
83 |
|
84 /** |
|
85 * Constructs a time field. |
|
86 * |
|
87 * @param aStartTime Session start time. |
|
88 * @param aStopTime Session end time that must be |
|
89 * greater than or equal to the start time. |
|
90 * @return a new instance. |
|
91 */ |
|
92 IMPORT_C static CSdpTimeField * NewL(const TDesC8& aStartTime, |
|
93 const TDesC8& aStopTime); |
|
94 |
|
95 /** |
|
96 * Constructs a time field and adds the pointer to the cleanup stack. |
|
97 * |
|
98 * @param aStartTime Session start time. |
|
99 * @param aStopTime Session end time that must be |
|
100 * greater than or equal to the start time. |
|
101 * @return a new instance. |
|
102 */ |
|
103 IMPORT_C static CSdpTimeField * NewLC(const TDesC8& aStartTime, |
|
104 const TDesC8& aStopTime); |
|
105 |
|
106 /** |
|
107 * Deletes the resources held by the instance. |
|
108 */ |
|
109 IMPORT_C ~CSdpTimeField(); |
|
110 |
|
111 public: // New functions |
|
112 /** |
|
113 * Outputs the field formatted according to SDP syntax and including |
|
114 * the terminating CRLF. Optionally output also the related repeat |
|
115 * times. |
|
116 * |
|
117 * @param aStream Stream used for output. On return |
|
118 * the stream includes correctly formatted time field with |
|
119 * repeat fields if aRecurse is ETrue. |
|
120 * @param aRecurse Flag to specify whether to output subfields |
|
121 * also (ETrue) or only the time field (EFalse). |
|
122 */ |
|
123 IMPORT_C void EncodeL(RWriteStream& aStream, TBool aRecurse = ETrue) const; |
|
124 |
|
125 /** |
|
126 * Creates a new instance that is equal to the target. |
|
127 * Optionally also related repeat times are cloned. |
|
128 * |
|
129 * @param aRecurse Flag to specify whether to clone subfields |
|
130 * also (ETrue) or only the time field (EFalse). |
|
131 * @return a new instance. |
|
132 */ |
|
133 IMPORT_C CSdpTimeField * CloneL(TBool aRecurse = ETrue) const; |
|
134 |
|
135 /** |
|
136 * Compares this instance to another for equality. Subfields are |
|
137 * included in comparison if present. |
|
138 * |
|
139 * @param aObj The instance to compare to. |
|
140 * @return ETrue if equal, EFalse if not. |
|
141 */ |
|
142 IMPORT_C TBool operator == (const CSdpTimeField & aObj) const; |
|
143 |
|
144 /** |
|
145 * Checks the consistency of the time description and it's subfields. |
|
146 *. |
|
147 * @return ETrue if time description is valid and EFalse if not. |
|
148 */ |
|
149 IMPORT_C TBool IsValid() const; |
|
150 |
|
151 /** |
|
152 * Gets the session start time. |
|
153 * |
|
154 * @return The session start time. |
|
155 */ |
|
156 IMPORT_C const TDesC8& StartTime() const; |
|
157 |
|
158 /** |
|
159 * Gets the session stop time. |
|
160 * |
|
161 * @return The session stop time. |
|
162 */ |
|
163 IMPORT_C const TDesC8& StopTime() const; |
|
164 |
|
165 /** |
|
166 * Sets the session start and stop times. |
|
167 * |
|
168 * @param aStartTime Session start time.. |
|
169 * @param aStopTime Session end time that must be |
|
170 * greater than or equal to the start time. |
|
171 * @leave KErrSdpCodecTimeField if start time and stop time are not |
|
172 * correct as defined draft-ietf-mmusic-sdp-new-14. |
|
173 */ |
|
174 IMPORT_C void SetTimesL(const TDesC8& aStartTime, const TDesC8& aStopTime); |
|
175 |
|
176 /** |
|
177 * Gets the set of repeat times fields related to this time field. |
|
178 * This array is used directly for element insertion and removal. |
|
179 * |
|
180 * The objects referenced from the array are owned by the media field |
|
181 * instance and must not be deleted. An object can be removed from the |
|
182 * media description by setting the corresponding element to zero. By |
|
183 * doing so, the calling party receives ownership of the removed object. |
|
184 * |
|
185 * @return The set of repeat fields. |
|
186 */ |
|
187 IMPORT_C RPointerArray<CSdpRepeatField>& RepeatFields(); |
|
188 |
|
189 public: |
|
190 /** |
|
191 * Externalizes the object to stream |
|
192 * |
|
193 * @param aStream Stream where the object's state will be stored |
|
194 */ |
|
195 void ExternalizeL(RWriteStream& aStream) const; |
|
196 |
|
197 /** |
|
198 * Creates object from the stream data |
|
199 * |
|
200 * @param aStream Stream where the object's state will be read |
|
201 * @return Initialized object |
|
202 */ |
|
203 static CSdpTimeField* InternalizeL(RReadStream& aStream); |
|
204 |
|
205 /** |
|
206 * Creates object from the stream data. |
|
207 * Does the "2nd phase construction" of internalization. |
|
208 * |
|
209 * @param aStream Stream where the object's state will be read |
|
210 */ |
|
211 void DoInternalizeL(RReadStream& aStream); |
|
212 |
|
213 private: |
|
214 CSdpTimeField(); |
|
215 |
|
216 void ConstructL(const TDesC8& aText, TBool aRecurse=ETrue); |
|
217 void ConstructL(const TDesC8& aStartTime, const TDesC8& aStopTime); |
|
218 |
|
219 TBool RepeatFieldsCompare(const CSdpTimeField& aObj) const; |
|
220 |
|
221 private: // Data |
|
222 HBufC8* iStartTime; |
|
223 HBufC8* iStopTime; |
|
224 RPointerArray<CSdpRepeatField> iRFields; |
|
225 RStringPool iStringPool; |
|
226 |
|
227 __DECLARE_TEST; |
|
228 }; |
|
229 |
|
230 #endif // CSDPTIMESFIELD_H |