epoc32/include/mw/sipmessageelements.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/sipmessageelements.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     1 /*
     2 * Copyright (c) 2005-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 * Name        : sipmessageelements.h
    16 * Part of     : SIP Client
    17 * Interface   : SDK API, SIP API
    18 * Version     : 1.0
    19 *
    20 */
    21 
    22 
    23 
    24 #ifndef CSIPMESSAGEELEMENTS_H
    25 #define CSIPMESSAGEELEMENTS_H
    26 
    27 // INCLUDES
    28 #include <e32base.h>
    29 #include <s32strm.h>
    30 #include <stringpool.h>
    31 #include "_sipcodecdefs.h"
    32 
    33 // FORWARD DECLARATIONS
    34 class CSIPHeaderBase;
    35 class CSIPContentTypeHeader;
    36 class CSIPFromHeader;
    37 class CSIPToHeader;
    38 class CSIPCSeqHeader;
    39 class CSIPExtensionHeader;
    40 
    41 // CLASS DECLARATION
    42 
    43 /**
    44 * @publishedAll
    45 * @released
    46 *
    47 * Class for creation and manipulation optional elements in a SIP message.
    48 * 
    49 * Class provides functions for setting and getting optional elements in a 
    50 * SIP message. Optional elements include user SIP message headers, 
    51 * content and content type.
    52 * Following headers are not considered to be user SIP message headers and 
    53 * cannot be set or retrieved using functions of this class: 
    54 * "Authentication-Info", "Call-Id", "CSeq", "From" 
    55 * "Max-Forwards", "Min-Expires", "Record-Route",
    56 * "Security-Verify", "Service-Route", "To", "Via", "Security-Server" and
    57 * "Proxy-Authorization".
    58 *
    59 *  @lib sipclient.lib
    60 */
    61 class CSIPMessageElements : public CBase
    62 	{
    63     public:  // Constructors and destructor    
    64 	    /**
    65         * Two-phased constructor.
    66         */
    67 		IMPORT_C static CSIPMessageElements* NewL();
    68 
    69 	    /**
    70         * Two-phased constructor.
    71         */
    72 		IMPORT_C static CSIPMessageElements* NewLC();
    73 
    74         /**
    75         * Destructor.
    76         */
    77 		IMPORT_C ~CSIPMessageElements();
    78 
    79     public: //new functions
    80 		/**
    81 		* Sets an array of user headers i.e. headers that user is allowed
    82 		* manipulate to a SIP message. An empty array resets the user headers.
    83 		* Note that the Content-Type header must be set using SetContentL. 
    84 		*
    85 		* @param aHeaders an array of SIP headers.
    86         *        The ownership of objects in the array is transferred.
    87 		*/
    88 		IMPORT_C void SetUserHeadersL(RPointerArray<CSIPHeaderBase>& aHeaders);
    89 
    90 		/**
    91 		* Gets all user SIP headers this class contains
    92 		* @return SIP headers. Ownership is not transferred.
    93 		*/
    94 		IMPORT_C const RPointerArray<CSIPHeaderBase>& UserHeaders() const;
    95 
    96 		/**
    97 		* Sets the SIP message content and its type.
    98 		* A zero length content can be set by providing a pointer
    99 		* to a zero length HBufC8 instance (the ownership is transferred).
   100 		* @pre aContent != 0 && aContentType != 0
   101 		* @param aContent the content of a SIP message,
   102 		*        		  the ownership is transferred
   103 		* @param aContentType the SIP message content type,
   104 		*        			  the ownership is transferred
   105 		* @leave KErrArgument if aContent == 0 or
   106 		*						 aContentType == 0
   107 		*/
   108 		IMPORT_C void SetContentL(HBufC8* aContent,
   109 							      CSIPContentTypeHeader* aContentType);
   110 
   111 		/**
   112 		* Gets the SIP message content
   113 		* @return SIP message content. If content does not exist, an empty
   114         *   descriptor is returned.
   115 		*/
   116 		IMPORT_C const TDesC8& Content() const;
   117 
   118 		/**
   119 		* Gets the content type
   120 		* @return Content-Type-header or a 0-pointer if not present; the ownership
   121         *         is not transferred.
   122 		*/
   123 		IMPORT_C const CSIPContentTypeHeader* ContentType() const;
   124 
   125 		/*
   126 		* Removes the SIP message content and destroys
   127         * Content-Type header as well.
   128 		* @return SIP message content; the ownership is transferred.
   129 		*/
   130 		IMPORT_C HBufC8* ExtractContent();
   131 
   132     public: // New functions, for internal use
   133 
   134 	    static CSIPMessageElements* InternalizeL(RReadStream& aReadStream);
   135     	void ExternalizeL(RWriteStream& aWriteStream) const;
   136         TInt UserHeaderCount(RStringF aName) const;
   137         const RPointerArray<CSIPHeaderBase> UserHeadersL(RStringF aName) const;
   138         TInt RemoveHeaders(RStringF aName);
   139         void DetachUserHeader(CSIPHeaderBase* aHeader);
   140 	    void AddHeaderL(CSIPHeaderBase* aHeader);
   141         void SetToL(CSIPToHeader* aTo);
   142         const CSIPToHeader* To() const;
   143         void SetFromL (CSIPFromHeader* aFrom);
   144         const CSIPFromHeader* From() const;
   145         const CSIPCSeqHeader* CSeq() const;
   146         void SetContent(HBufC8* aContent);
   147         void DetachContent();
   148 
   149     private:
   150 
   151         CSIPMessageElements();
   152 	    void ConstructL();
   153 	    void DoInternalizeL(RReadStream& aReadStream);
   154 	    void CheckUserHeaderL(const CSIPHeaderBase* aHeader) const;
   155         void ExternalizeUserHeadersL(RWriteStream& aWriteStream) const;
   156         void ExternalizeL(const CSIPExtensionHeader* aHeader,
   157                           RWriteStream& aWriteStream) const;
   158 
   159 	private: // Data
   160 	
   161 	    RPointerArray<CSIPHeaderBase> iUserHeaders;
   162 	    HBufC8* iContent;
   163         CSIPFromHeader* iFromHeader;
   164         CSIPToHeader* iToHeader;
   165         CSIPCSeqHeader* iCSeqHeader;
   166         CSIPContentTypeHeader* iContentTypeHeader;
   167         TBool iHeaderLookupOpen;
   168 
   169 	private: // For testing purposes
   170 
   171 	    UNIT_TEST(CSIPMessageElementsTest)
   172 	};
   173 
   174 #endif