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