1.1 --- a/epoc32/include/sdptimefield.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/sdptimefield.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,230 @@
1.4 -sdptimefield.h
1.5 +/*
1.6 +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.7 +* All rights reserved.
1.8 +* This component and the accompanying materials are made available
1.9 +* 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
1.10 +* which accompanies this distribution, and is available
1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.12 +*
1.13 +* Initial Contributors:
1.14 +* Nokia Corporation - initial contribution.
1.15 +*
1.16 +* Contributors:
1.17 +*
1.18 +* Description:
1.19 +* Name : SdpTimeField.h
1.20 +* Part of : SDP Codec
1.21 +* Interface : SDK API, SDP Codec API
1.22 +* Version : 1.0
1.23 +*
1.24 +*/
1.25 +
1.26 +
1.27 +
1.28 +#ifndef CSDPTIMESFIELD_H
1.29 +#define CSDPTIMESFIELD_H
1.30 +
1.31 +// INCLUDES
1.32 +#include <e32base.h>
1.33 +#include <stringpool.h>
1.34 +#include "_sdpdefs.h"
1.35 +
1.36 +// FORWARD DECLARATIONS
1.37 +class RReadStream;
1.38 +class RWriteStream;
1.39 +class CSdpRepeatField;
1.40 +
1.41 +// CLASS DECLARATION
1.42 +/**
1.43 + * @publishedAll
1.44 + * @released
1.45 + *
1.46 + * This class encapsulates the time field and the related zero or
1.47 + * more repeat times fields and an optional time zone adjustment
1.48 + * field of the Session Description Protocol.
1.49 + *
1.50 + * The normative reference for correct formatting and values is
1.51 + * draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
1.52 + * member documentation. The implementation supports this normative
1.53 + * reference, but does not enforce it fully.
1.54 + *
1.55 + * @lib sdpcodec.lib
1.56 + */
1.57 +class CSdpTimeField : public CBase
1.58 + {
1.59 + public: // Constructors and destructor
1.60 + /**
1.61 + * Constructs a time field.
1.62 + *
1.63 + * @param aText A correctly formatted time field value
1.64 + * terminated by a CRLF followed by zero or more repeat
1.65 + * times and zero or one time zone adjustment fields
1.66 + * separeted by a CRLF.
1.67 + * @param aRecurse Flag to specify whether to decode subfields
1.68 + * also (ETrue) or only the time field (EFalse).
1.69 + * @return a new instance.
1.70 + */
1.71 + IMPORT_C static CSdpTimeField * DecodeL(const TDesC8& aText,
1.72 + TBool aRecurse = ETrue);
1.73 +
1.74 + /**
1.75 + * Constructs a time field and adds the pointer to the cleanup stack.
1.76 + *
1.77 + * @param aText A correctly formatted time field value
1.78 + * terminated by a CRLF followed by zero or more repeat
1.79 + * times and zero or one time zone adjustment fields
1.80 + * separeted by a CRLF.
1.81 + * @param aRecurse Flag to specify whether to decode subfields
1.82 + * also (ETrue) or only the time field (EFalse).
1.83 + * @return a new instance.
1.84 + */
1.85 + IMPORT_C static CSdpTimeField * DecodeLC(const TDesC8& aText,
1.86 + TBool aRecurse = ETrue);
1.87 +
1.88 + /**
1.89 + * Constructs a time field.
1.90 + *
1.91 + * @param aStartTime Session start time.
1.92 + * @param aStopTime Session end time that must be
1.93 + * greater than or equal to the start time.
1.94 + * @return a new instance.
1.95 + */
1.96 + IMPORT_C static CSdpTimeField * NewL(const TDesC8& aStartTime,
1.97 + const TDesC8& aStopTime);
1.98 +
1.99 + /**
1.100 + * Constructs a time field and adds the pointer to the cleanup stack.
1.101 + *
1.102 + * @param aStartTime Session start time.
1.103 + * @param aStopTime Session end time that must be
1.104 + * greater than or equal to the start time.
1.105 + * @return a new instance.
1.106 + */
1.107 + IMPORT_C static CSdpTimeField * NewLC(const TDesC8& aStartTime,
1.108 + const TDesC8& aStopTime);
1.109 +
1.110 + /**
1.111 + * Deletes the resources held by the instance.
1.112 + */
1.113 + IMPORT_C ~CSdpTimeField();
1.114 +
1.115 + public: // New functions
1.116 + /**
1.117 + * Outputs the field formatted according to SDP syntax and including
1.118 + * the terminating CRLF. Optionally output also the related repeat
1.119 + * times.
1.120 + *
1.121 + * @param aStream Stream used for output. On return
1.122 + * the stream includes correctly formatted time field with
1.123 + * repeat fields if aRecurse is ETrue.
1.124 + * @param aRecurse Flag to specify whether to output subfields
1.125 + * also (ETrue) or only the time field (EFalse).
1.126 + */
1.127 + IMPORT_C void EncodeL(RWriteStream& aStream, TBool aRecurse = ETrue) const;
1.128 +
1.129 + /**
1.130 + * Creates a new instance that is equal to the target.
1.131 + * Optionally also related repeat times are cloned.
1.132 + *
1.133 + * @param aRecurse Flag to specify whether to clone subfields
1.134 + * also (ETrue) or only the time field (EFalse).
1.135 + * @return a new instance.
1.136 + */
1.137 + IMPORT_C CSdpTimeField * CloneL(TBool aRecurse = ETrue) const;
1.138 +
1.139 + /**
1.140 + * Compares this instance to another for equality. Subfields are
1.141 + * included in comparison if present.
1.142 + *
1.143 + * @param aObj The instance to compare to.
1.144 + * @return ETrue if equal, EFalse if not.
1.145 + */
1.146 + IMPORT_C TBool operator == (const CSdpTimeField & aObj) const;
1.147 +
1.148 + /**
1.149 + * Checks the consistency of the time description and it's subfields.
1.150 + *.
1.151 + * @return ETrue if time description is valid and EFalse if not.
1.152 + */
1.153 + IMPORT_C TBool IsValid() const;
1.154 +
1.155 + /**
1.156 + * Gets the session start time.
1.157 + *
1.158 + * @return The session start time.
1.159 + */
1.160 + IMPORT_C const TDesC8& StartTime() const;
1.161 +
1.162 + /**
1.163 + * Gets the session stop time.
1.164 + *
1.165 + * @return The session stop time.
1.166 + */
1.167 + IMPORT_C const TDesC8& StopTime() const;
1.168 +
1.169 + /**
1.170 + * Sets the session start and stop times.
1.171 + *
1.172 + * @param aStartTime Session start time..
1.173 + * @param aStopTime Session end time that must be
1.174 + * greater than or equal to the start time.
1.175 + * @leave KErrSdpCodecTimeField if start time and stop time are not
1.176 + * correct as defined draft-ietf-mmusic-sdp-new-14.
1.177 + */
1.178 + IMPORT_C void SetTimesL(const TDesC8& aStartTime, const TDesC8& aStopTime);
1.179 +
1.180 + /**
1.181 + * Gets the set of repeat times fields related to this time field.
1.182 + * This array is used directly for element insertion and removal.
1.183 + *
1.184 + * The objects referenced from the array are owned by the media field
1.185 + * instance and must not be deleted. An object can be removed from the
1.186 + * media description by setting the corresponding element to zero. By
1.187 + * doing so, the calling party receives ownership of the removed object.
1.188 + *
1.189 + * @return The set of repeat fields.
1.190 + */
1.191 + IMPORT_C RPointerArray<CSdpRepeatField>& RepeatFields();
1.192 +
1.193 + public:
1.194 + /**
1.195 + * Externalizes the object to stream
1.196 + *
1.197 + * @param aStream Stream where the object's state will be stored
1.198 + */
1.199 + void ExternalizeL(RWriteStream& aStream) const;
1.200 +
1.201 + /**
1.202 + * Creates object from the stream data
1.203 + *
1.204 + * @param aStream Stream where the object's state will be read
1.205 + * @return Initialized object
1.206 + */
1.207 + static CSdpTimeField* InternalizeL(RReadStream& aStream);
1.208 +
1.209 + /**
1.210 + * Creates object from the stream data.
1.211 + * Does the "2nd phase construction" of internalization.
1.212 + *
1.213 + * @param aStream Stream where the object's state will be read
1.214 + */
1.215 + void DoInternalizeL(RReadStream& aStream);
1.216 +
1.217 + private:
1.218 + CSdpTimeField();
1.219 +
1.220 + void ConstructL(const TDesC8& aText, TBool aRecurse=ETrue);
1.221 + void ConstructL(const TDesC8& aStartTime, const TDesC8& aStopTime);
1.222 +
1.223 + TBool RepeatFieldsCompare(const CSdpTimeField& aObj) const;
1.224 +
1.225 + private: // Data
1.226 + HBufC8* iStartTime;
1.227 + HBufC8* iStopTime;
1.228 + RPointerArray<CSdpRepeatField> iRFields;
1.229 + RStringPool iStringPool;
1.230 +
1.231 + __DECLARE_TEST;
1.232 + };
1.233 +
1.234 +#endif // CSDPTIMESFIELD_H