williamr@2: /* williamr@2: * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * Name : SdpTimeField.h williamr@2: * Part of : SDP Codec williamr@2: * Interface : SDK API, SDP Codec API williamr@2: * Version : 1.0 williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: #ifndef CSDPTIMESFIELD_H williamr@2: #define CSDPTIMESFIELD_H williamr@2: williamr@2: // INCLUDES williamr@2: #include williamr@2: #include williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: class RReadStream; williamr@2: class RWriteStream; williamr@2: class CSdpRepeatField; williamr@2: williamr@2: // CLASS DECLARATION williamr@2: /** williamr@2: * @publishedAll williamr@2: * @released williamr@2: * williamr@2: * This class encapsulates the time field and the related zero or williamr@2: * more repeat times fields and an optional time zone adjustment williamr@2: * field of the Session Description Protocol. williamr@2: * williamr@2: * The normative reference for correct formatting and values is williamr@2: * draft-ietf-mmusic-sdp-new-14 unless specified otherwise in williamr@2: * member documentation. The implementation supports this normative williamr@2: * reference, but does not enforce it fully. williamr@2: * williamr@2: * @lib sdpcodec.lib williamr@2: */ williamr@2: class CSdpTimeField : public CBase williamr@2: { williamr@2: public: // Constructors and destructor williamr@2: /** williamr@2: * Constructs a time field. williamr@2: * williamr@2: * @param aText A correctly formatted time field value williamr@2: * terminated by a CRLF followed by zero or more repeat williamr@2: * times and zero or one time zone adjustment fields williamr@2: * separeted by a CRLF. williamr@2: * @param aRecurse Flag to specify whether to decode subfields williamr@2: * also (ETrue) or only the time field (EFalse). williamr@2: * @return a new instance. williamr@2: */ williamr@2: IMPORT_C static CSdpTimeField * DecodeL(const TDesC8& aText, williamr@2: TBool aRecurse = ETrue); williamr@2: williamr@2: /** williamr@2: * Constructs a time field and adds the pointer to the cleanup stack. williamr@2: * williamr@2: * @param aText A correctly formatted time field value williamr@2: * terminated by a CRLF followed by zero or more repeat williamr@2: * times and zero or one time zone adjustment fields williamr@2: * separeted by a CRLF. williamr@2: * @param aRecurse Flag to specify whether to decode subfields williamr@2: * also (ETrue) or only the time field (EFalse). williamr@2: * @return a new instance. williamr@2: */ williamr@2: IMPORT_C static CSdpTimeField * DecodeLC(const TDesC8& aText, williamr@2: TBool aRecurse = ETrue); williamr@2: williamr@2: /** williamr@2: * Constructs a time field. williamr@2: * williamr@2: * @param aStartTime Session start time. williamr@2: * @param aStopTime Session end time that must be williamr@2: * greater than or equal to the start time. williamr@2: * @return a new instance. williamr@2: */ williamr@2: IMPORT_C static CSdpTimeField * NewL(const TDesC8& aStartTime, williamr@2: const TDesC8& aStopTime); williamr@2: williamr@2: /** williamr@2: * Constructs a time field and adds the pointer to the cleanup stack. williamr@2: * williamr@2: * @param aStartTime Session start time. williamr@2: * @param aStopTime Session end time that must be williamr@2: * greater than or equal to the start time. williamr@2: * @return a new instance. williamr@2: */ williamr@2: IMPORT_C static CSdpTimeField * NewLC(const TDesC8& aStartTime, williamr@2: const TDesC8& aStopTime); williamr@2: williamr@2: /** williamr@2: * Deletes the resources held by the instance. williamr@2: */ williamr@2: IMPORT_C ~CSdpTimeField(); williamr@2: williamr@2: public: // New functions williamr@2: /** williamr@2: * Outputs the field formatted according to SDP syntax and including williamr@2: * the terminating CRLF. Optionally output also the related repeat williamr@2: * times. williamr@2: * williamr@2: * @param aStream Stream used for output. On return williamr@2: * the stream includes correctly formatted time field with williamr@2: * repeat fields if aRecurse is ETrue. williamr@2: * @param aRecurse Flag to specify whether to output subfields williamr@2: * also (ETrue) or only the time field (EFalse). williamr@2: */ williamr@2: IMPORT_C void EncodeL(RWriteStream& aStream, TBool aRecurse = ETrue) const; williamr@2: williamr@2: /** williamr@2: * Creates a new instance that is equal to the target. williamr@2: * Optionally also related repeat times are cloned. williamr@2: * williamr@2: * @param aRecurse Flag to specify whether to clone subfields williamr@2: * also (ETrue) or only the time field (EFalse). williamr@2: * @return a new instance. williamr@2: */ williamr@2: IMPORT_C CSdpTimeField * CloneL(TBool aRecurse = ETrue) const; williamr@2: williamr@2: /** williamr@2: * Compares this instance to another for equality. Subfields are williamr@2: * included in comparison if present. williamr@2: * williamr@2: * @param aObj The instance to compare to. williamr@2: * @return ETrue if equal, EFalse if not. williamr@2: */ williamr@2: IMPORT_C TBool operator == (const CSdpTimeField & aObj) const; williamr@2: williamr@2: /** williamr@2: * Checks the consistency of the time description and it's subfields. williamr@2: *. williamr@2: * @return ETrue if time description is valid and EFalse if not. williamr@2: */ williamr@2: IMPORT_C TBool IsValid() const; williamr@2: williamr@2: /** williamr@2: * Gets the session start time. williamr@2: * williamr@2: * @return The session start time. williamr@2: */ williamr@2: IMPORT_C const TDesC8& StartTime() const; williamr@2: williamr@2: /** williamr@2: * Gets the session stop time. williamr@2: * williamr@2: * @return The session stop time. williamr@2: */ williamr@2: IMPORT_C const TDesC8& StopTime() const; williamr@2: williamr@2: /** williamr@2: * Sets the session start and stop times. williamr@2: * williamr@2: * @param aStartTime Session start time.. williamr@2: * @param aStopTime Session end time that must be williamr@2: * greater than or equal to the start time. williamr@2: * @leave KErrSdpCodecTimeField if start time and stop time are not williamr@2: * correct as defined draft-ietf-mmusic-sdp-new-14. williamr@2: */ williamr@2: IMPORT_C void SetTimesL(const TDesC8& aStartTime, const TDesC8& aStopTime); williamr@2: williamr@2: /** williamr@2: * Gets the set of repeat times fields related to this time field. williamr@2: * This array is used directly for element insertion and removal. williamr@2: * williamr@2: * The objects referenced from the array are owned by the media field williamr@2: * instance and must not be deleted. An object can be removed from the williamr@2: * media description by setting the corresponding element to zero. By williamr@2: * doing so, the calling party receives ownership of the removed object. williamr@2: * williamr@2: * @return The set of repeat fields. williamr@2: */ williamr@2: IMPORT_C RPointerArray& RepeatFields(); williamr@2: williamr@2: public: williamr@2: /** williamr@2: * Externalizes the object to stream williamr@2: * williamr@2: * @param aStream Stream where the object's state will be stored williamr@2: */ williamr@2: void ExternalizeL(RWriteStream& aStream) const; williamr@2: williamr@2: /** williamr@2: * Creates object from the stream data williamr@2: * williamr@2: * @param aStream Stream where the object's state will be read williamr@2: * @return Initialized object williamr@2: */ williamr@2: static CSdpTimeField* InternalizeL(RReadStream& aStream); williamr@2: williamr@2: /** williamr@2: * Creates object from the stream data. williamr@2: * Does the "2nd phase construction" of internalization. williamr@2: * williamr@2: * @param aStream Stream where the object's state will be read williamr@2: */ williamr@2: void DoInternalizeL(RReadStream& aStream); williamr@2: williamr@2: private: williamr@2: CSdpTimeField(); williamr@2: williamr@2: void ConstructL(const TDesC8& aText, TBool aRecurse=ETrue); williamr@2: void ConstructL(const TDesC8& aStartTime, const TDesC8& aStopTime); williamr@2: williamr@2: TBool RepeatFieldsCompare(const CSdpTimeField& aObj) const; williamr@2: williamr@2: private: // Data williamr@2: HBufC8* iStartTime; williamr@2: HBufC8* iStopTime; williamr@2: RPointerArray iRFields; williamr@2: RStringPool iStringPool; williamr@2: williamr@4: void __DbgTestInvariant() const; williamr@4: williamr@2: }; williamr@2: williamr@2: #endif // CSDPTIMESFIELD_H