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 "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".
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>
31 // FORWARD DECLARATIONS
34 class CSdpRepeatField;
41 * This class encapsulates the time field and the related zero or
42 * more repeat times fields and an optional time zone adjustment
43 * field of the Session Description Protocol.
45 * The normative reference for correct formatting and values is
46 * draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
47 * member documentation. The implementation supports this normative
48 * reference, but does not enforce it fully.
52 class CSdpTimeField : public CBase
54 public: // Constructors and destructor
56 * Constructs a time field.
58 * @param aText A correctly formatted time field value
59 * terminated by a CRLF followed by zero or more repeat
60 * times and zero or one time zone adjustment fields
61 * separeted by a CRLF.
62 * @param aRecurse Flag to specify whether to decode subfields
63 * also (ETrue) or only the time field (EFalse).
64 * @return a new instance.
66 IMPORT_C static CSdpTimeField * DecodeL(const TDesC8& aText,
67 TBool aRecurse = ETrue);
70 * Constructs a time field and adds the pointer to the cleanup stack.
72 * @param aText A correctly formatted time field value
73 * terminated by a CRLF followed by zero or more repeat
74 * times and zero or one time zone adjustment fields
75 * separeted by a CRLF.
76 * @param aRecurse Flag to specify whether to decode subfields
77 * also (ETrue) or only the time field (EFalse).
78 * @return a new instance.
80 IMPORT_C static CSdpTimeField * DecodeLC(const TDesC8& aText,
81 TBool aRecurse = ETrue);
84 * Constructs a time field.
86 * @param aStartTime Session start time.
87 * @param aStopTime Session end time that must be
88 * greater than or equal to the start time.
89 * @return a new instance.
91 IMPORT_C static CSdpTimeField * NewL(const TDesC8& aStartTime,
92 const TDesC8& aStopTime);
95 * Constructs a time field and adds the pointer to the cleanup stack.
97 * @param aStartTime Session start time.
98 * @param aStopTime Session end time that must be
99 * greater than or equal to the start time.
100 * @return a new instance.
102 IMPORT_C static CSdpTimeField * NewLC(const TDesC8& aStartTime,
103 const TDesC8& aStopTime);
106 * Deletes the resources held by the instance.
108 IMPORT_C ~CSdpTimeField();
110 public: // New functions
112 * Outputs the field formatted according to SDP syntax and including
113 * the terminating CRLF. Optionally output also the related repeat
116 * @param aStream Stream used for output. On return
117 * the stream includes correctly formatted time field with
118 * repeat fields if aRecurse is ETrue.
119 * @param aRecurse Flag to specify whether to output subfields
120 * also (ETrue) or only the time field (EFalse).
122 IMPORT_C void EncodeL(RWriteStream& aStream, TBool aRecurse = ETrue) const;
125 * Creates a new instance that is equal to the target.
126 * Optionally also related repeat times are cloned.
128 * @param aRecurse Flag to specify whether to clone subfields
129 * also (ETrue) or only the time field (EFalse).
130 * @return a new instance.
132 IMPORT_C CSdpTimeField * CloneL(TBool aRecurse = ETrue) const;
135 * Compares this instance to another for equality. Subfields are
136 * included in comparison if present.
138 * @param aObj The instance to compare to.
139 * @return ETrue if equal, EFalse if not.
141 IMPORT_C TBool operator == (const CSdpTimeField & aObj) const;
144 * Checks the consistency of the time description and it's subfields.
146 * @return ETrue if time description is valid and EFalse if not.
148 IMPORT_C TBool IsValid() const;
151 * Gets the session start time.
153 * @return The session start time.
155 IMPORT_C const TDesC8& StartTime() const;
158 * Gets the session stop time.
160 * @return The session stop time.
162 IMPORT_C const TDesC8& StopTime() const;
165 * Sets the session start and stop times.
167 * @param aStartTime Session start time..
168 * @param aStopTime Session end time that must be
169 * greater than or equal to the start time.
170 * @leave KErrSdpCodecTimeField if start time and stop time are not
171 * correct as defined draft-ietf-mmusic-sdp-new-14.
173 IMPORT_C void SetTimesL(const TDesC8& aStartTime, const TDesC8& aStopTime);
176 * Gets the set of repeat times fields related to this time field.
177 * This array is used directly for element insertion and removal.
179 * The objects referenced from the array are owned by the media field
180 * instance and must not be deleted. An object can be removed from the
181 * media description by setting the corresponding element to zero. By
182 * doing so, the calling party receives ownership of the removed object.
184 * @return The set of repeat fields.
186 IMPORT_C RPointerArray<CSdpRepeatField>& RepeatFields();
190 * Externalizes the object to stream
192 * @param aStream Stream where the object's state will be stored
194 void ExternalizeL(RWriteStream& aStream) const;
197 * Creates object from the stream data
199 * @param aStream Stream where the object's state will be read
200 * @return Initialized object
202 static CSdpTimeField* InternalizeL(RReadStream& aStream);
205 * Creates object from the stream data.
206 * Does the "2nd phase construction" of internalization.
208 * @param aStream Stream where the object's state will be read
210 void DoInternalizeL(RReadStream& aStream);
215 void ConstructL(const TDesC8& aText, TBool aRecurse=ETrue);
216 void ConstructL(const TDesC8& aStartTime, const TDesC8& aStopTime);
218 TBool RepeatFieldsCompare(const CSdpTimeField& aObj) const;
223 RPointerArray<CSdpRepeatField> iRFields;
224 RStringPool iStringPool;
226 void __DbgTestInvariant() const;
230 #endif // CSDPTIMESFIELD_H