2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Name : SdpTimeField.h
17 * Interface : SDK API, SDP Codec API
24 #ifndef CSDPTIMESFIELD_H
25 #define CSDPTIMESFIELD_H
29 #include <stringpool.h>
32 // FORWARD DECLARATIONS
35 class CSdpRepeatField;
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.
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.
53 class CSdpTimeField : public CBase
55 public: // Constructors and destructor
57 * Constructs a time field.
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.
67 IMPORT_C static CSdpTimeField * DecodeL(const TDesC8& aText,
68 TBool aRecurse = ETrue);
71 * Constructs a time field and adds the pointer to the cleanup stack.
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.
81 IMPORT_C static CSdpTimeField * DecodeLC(const TDesC8& aText,
82 TBool aRecurse = ETrue);
85 * Constructs a time field.
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.
92 IMPORT_C static CSdpTimeField * NewL(const TDesC8& aStartTime,
93 const TDesC8& aStopTime);
96 * Constructs a time field and adds the pointer to the cleanup stack.
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.
103 IMPORT_C static CSdpTimeField * NewLC(const TDesC8& aStartTime,
104 const TDesC8& aStopTime);
107 * Deletes the resources held by the instance.
109 IMPORT_C ~CSdpTimeField();
111 public: // New functions
113 * Outputs the field formatted according to SDP syntax and including
114 * the terminating CRLF. Optionally output also the related repeat
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).
123 IMPORT_C void EncodeL(RWriteStream& aStream, TBool aRecurse = ETrue) const;
126 * Creates a new instance that is equal to the target.
127 * Optionally also related repeat times are cloned.
129 * @param aRecurse Flag to specify whether to clone subfields
130 * also (ETrue) or only the time field (EFalse).
131 * @return a new instance.
133 IMPORT_C CSdpTimeField * CloneL(TBool aRecurse = ETrue) const;
136 * Compares this instance to another for equality. Subfields are
137 * included in comparison if present.
139 * @param aObj The instance to compare to.
140 * @return ETrue if equal, EFalse if not.
142 IMPORT_C TBool operator == (const CSdpTimeField & aObj) const;
145 * Checks the consistency of the time description and it's subfields.
147 * @return ETrue if time description is valid and EFalse if not.
149 IMPORT_C TBool IsValid() const;
152 * Gets the session start time.
154 * @return The session start time.
156 IMPORT_C const TDesC8& StartTime() const;
159 * Gets the session stop time.
161 * @return The session stop time.
163 IMPORT_C const TDesC8& StopTime() const;
166 * Sets the session start and stop times.
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.
174 IMPORT_C void SetTimesL(const TDesC8& aStartTime, const TDesC8& aStopTime);
177 * Gets the set of repeat times fields related to this time field.
178 * This array is used directly for element insertion and removal.
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.
185 * @return The set of repeat fields.
187 IMPORT_C RPointerArray<CSdpRepeatField>& RepeatFields();
191 * Externalizes the object to stream
193 * @param aStream Stream where the object's state will be stored
195 void ExternalizeL(RWriteStream& aStream) const;
198 * Creates object from the stream data
200 * @param aStream Stream where the object's state will be read
201 * @return Initialized object
203 static CSdpTimeField* InternalizeL(RReadStream& aStream);
206 * Creates object from the stream data.
207 * Does the "2nd phase construction" of internalization.
209 * @param aStream Stream where the object's state will be read
211 void DoInternalizeL(RReadStream& aStream);
216 void ConstructL(const TDesC8& aText, TBool aRecurse=ETrue);
217 void ConstructL(const TDesC8& aStartTime, const TDesC8& aStopTime);
219 TBool RepeatFieldsCompare(const CSdpTimeField& aObj) const;
224 RPointerArray<CSdpRepeatField> iRFields;
225 RStringPool iStringPool;
230 #endif // CSDPTIMESFIELD_H