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