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