realtimenetprots/sipfw/SDP/api/SdpTimeField.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Name          : SdpTimeField.h
       
    16 * Part of       : SDP Codec
       
    17 * Interface     : SDK API, SDP Codec API
       
    18 * Version       : 1.0
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 #ifndef CSDPTIMESFIELD_H
       
    25 #define CSDPTIMESFIELD_H
       
    26 
       
    27 //  INCLUDES
       
    28 #include <e32base.h>
       
    29 #include <stringpool.h>
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class RReadStream;
       
    33 class RWriteStream;
       
    34 class CSdpRepeatField;
       
    35 
       
    36 // CLASS DECLARATION
       
    37 /**
       
    38  *  @publishedAll
       
    39  *  @released
       
    40  *
       
    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.
       
    44  *
       
    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. 
       
    49  *
       
    50  *  @lib sdpcodec.lib
       
    51  */
       
    52 class CSdpTimeField : public CBase
       
    53 	{
       
    54     public: // Constructors and destructor
       
    55         /**
       
    56          *	Constructs a time field.
       
    57 		 * 
       
    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.
       
    65          */
       
    66 		IMPORT_C static CSdpTimeField * DecodeL(const TDesC8& aText, 
       
    67                                                 TBool aRecurse = ETrue);
       
    68 
       
    69         /**
       
    70          *	Constructs a time field and adds the pointer to the cleanup stack.
       
    71 		 *	
       
    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.
       
    79          */
       
    80 		IMPORT_C static CSdpTimeField * DecodeLC(const TDesC8& aText,
       
    81                                                 TBool aRecurse = ETrue);
       
    82 
       
    83         /**
       
    84          *	Constructs a time field.
       
    85 		 *	
       
    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.
       
    90          */
       
    91 		IMPORT_C static CSdpTimeField * NewL(const TDesC8& aStartTime,
       
    92 									        const TDesC8& aStopTime);
       
    93 
       
    94         /**
       
    95          *	Constructs a time field and adds the pointer to the cleanup stack.
       
    96 		 *	
       
    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.
       
   101          */
       
   102 		IMPORT_C static CSdpTimeField * NewLC(const TDesC8& aStartTime,
       
   103 									        const TDesC8& aStopTime);
       
   104 
       
   105 		/**
       
   106 		 *	Deletes the resources held by the instance.
       
   107 		 */
       
   108 		IMPORT_C ~CSdpTimeField();
       
   109 
       
   110     public: // New functions
       
   111 		/**
       
   112 		 *	Outputs the field formatted according to SDP syntax and including
       
   113 		 *  the terminating CRLF. Optionally output also the related repeat
       
   114 		 *  times.
       
   115 		 * 
       
   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).
       
   121 		 */
       
   122 		IMPORT_C void EncodeL(RWriteStream& aStream, TBool aRecurse = ETrue) const;
       
   123 
       
   124 		/**
       
   125 		 *	Creates a new instance that is equal to the target.
       
   126 		 *  Optionally also related repeat times are cloned.
       
   127 		 *
       
   128 		 *	@param aRecurse Flag to specify whether to clone subfields 
       
   129 		 *         also (ETrue) or only the time field (EFalse).
       
   130 		 *	@return a new instance.
       
   131 		 */
       
   132 		IMPORT_C CSdpTimeField * CloneL(TBool aRecurse = ETrue) const;
       
   133 
       
   134 		/**	
       
   135 		 *	Compares this instance to another for equality. Subfields are
       
   136 		 *	included in comparison if present.
       
   137 		 *
       
   138 		 *	@param aObj The instance to compare to.
       
   139 		 *	@return ETrue if equal, EFalse if not.
       
   140 		 */
       
   141 		IMPORT_C TBool operator == (const CSdpTimeField & aObj) const;
       
   142 
       
   143 		/**
       
   144 		 *	Checks the consistency of the time description and it's subfields.
       
   145 		 *.
       
   146 		 *	@return	ETrue if time description is valid and EFalse if not.
       
   147 		 */
       
   148 		IMPORT_C TBool IsValid() const;
       
   149 
       
   150 		/**
       
   151 		 *	Gets the session start time.
       
   152 		 *
       
   153 		 *	@return The session start time.
       
   154 		 */
       
   155 		IMPORT_C const TDesC8& StartTime() const;
       
   156 
       
   157 		/**
       
   158 		 *	Gets the session stop time.
       
   159 		 *
       
   160 		 *	@return The session stop time.
       
   161 		 */
       
   162 		IMPORT_C const TDesC8& StopTime() const;
       
   163 
       
   164 		/**
       
   165 		 *	Sets the session start and stop times.
       
   166 		 *
       
   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.
       
   172 		 */
       
   173 		IMPORT_C void SetTimesL(const TDesC8& aStartTime, const TDesC8& aStopTime);
       
   174 
       
   175 		/**
       
   176 		 *	Gets the set of repeat times fields related to this time field.
       
   177 		 *  This array is used directly for element insertion and removal.
       
   178 		 *
       
   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.
       
   183 		 *
       
   184 		 *	@return The set of repeat fields.
       
   185 		 */
       
   186 		IMPORT_C RPointerArray<CSdpRepeatField>& RepeatFields();
       
   187 	
       
   188     public:
       
   189 		/**
       
   190          *  Externalizes the object to stream
       
   191          *
       
   192          *  @param aStream Stream where the object's state will be stored
       
   193          */
       
   194 		void ExternalizeL(RWriteStream& aStream) const;
       
   195 		
       
   196 		/**
       
   197          *  Creates object from the stream data
       
   198          *
       
   199          *  @param aStream Stream where the object's state will be read
       
   200          *  @return Initialized object
       
   201          */
       
   202 		static CSdpTimeField* InternalizeL(RReadStream& aStream);
       
   203         
       
   204         /**
       
   205          *  Creates object from the stream data.
       
   206          *	Does the "2nd phase construction" of internalization.
       
   207          *
       
   208          *  @param aStream Stream where the object's state will be read
       
   209          */
       
   210         void DoInternalizeL(RReadStream& aStream);
       
   211 
       
   212 	private:
       
   213    		CSdpTimeField();
       
   214 
       
   215 		void ConstructL(const TDesC8& aText, TBool aRecurse=ETrue);
       
   216 		void ConstructL(const TDesC8& aStartTime, const TDesC8& aStopTime);
       
   217 
       
   218         TBool RepeatFieldsCompare(const CSdpTimeField& aObj) const;
       
   219 
       
   220     private: // Data
       
   221 		HBufC8* iStartTime;
       
   222 		HBufC8* iStopTime;
       
   223 		RPointerArray<CSdpRepeatField> iRFields;
       
   224         RStringPool iStringPool;
       
   225 
       
   226 		void __DbgTestInvariant() const;
       
   227 
       
   228 	};
       
   229 
       
   230 #endif // CSDPTIMESFIELD_H