realtimenetprots/sipfw/SIP/sipapi/api/sipmessageelements.h
author Petteri Saari <petteri.saari@digia.com>
Thu, 25 Nov 2010 13:59:42 +0200
branchMSRP_FrameWork
changeset 58 cdb720e67852
parent 17 bfe1f539b721
permissions -rw-r--r--
This release addresses the following issues: 1. The crash bug fix when receiving file 2. Now the sending is based on MSRP messages, there is no longer file receiving or sending. Client sends data as MSRP was designed. 3. Soma MSRP stack was created so that the client told the correct session-id, Symbian stack generated it by itself. This is not allowed, it was changed so that clients tell the session-id (same as used in SIP INVITE). 4. Unnecessary division of data to chunks removed when there is no need to interrupt sending. The message is sent in as few chunks as possible. 5. Stack can now receive files and chunks with ?unlimited? size. Old stack wrote the incoming data to memory and did not utilize disk space until the end of chunk was reached (large chunks from another client crashed it). 6. Now when writing the incoming data to file, it will take into account the byte-range header values. So, this complies with the RFC4975 requirements that stack must be able to handle chunks that come in any sequence. 7. Some buffering changes to outgoing/incoming data. 8. The outgoing data is now checked that it does not contain the created transaction-id before sending the data. 9. MSRP success reports are now implemented and tested against servers. 10. Progress report system fixed so progress is now visible on client (all the way to 100%). 11. Message Cancel receiving / Cancel sending now corrected and made to work as rfc4975 requires. (termination from sender and error code from receiver when cancelling). 12. Bug correction related to messages received not belonging to any session, old stack implementation did send error response, but after response was written it did give the buffer to client anyway. Now corrected.

/*
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
* Name        : sipmessageelements.h
* Part of     : SIP Client
* Interface   : SDK API, SIP API
* Version     : 1.0
*
*/



#ifndef CSIPMESSAGEELEMENTS_H
#define CSIPMESSAGEELEMENTS_H

// INCLUDES
#include <e32base.h>
#include <s32strm.h>
#include <stringpool.h>

// FORWARD DECLARATIONS
class CSIPHeaderBase;
class CSIPContentTypeHeader;
class CSIPFromHeader;
class CSIPToHeader;
class CSIPCSeqHeader;
class CSIPExtensionHeader;

// CLASS DECLARATION

/**
* @publishedAll
* @released
*
* Class for creation and manipulation optional elements in a SIP message.
* 
* Class provides functions for setting and getting optional elements in a 
* SIP message. Optional elements include user SIP message headers, 
* content and content type.
* Following headers are not considered to be user SIP message headers and 
* cannot be set or retrieved using functions of this class: 
* "Authentication-Info", "Call-Id", "CSeq", "From" 
* "Max-Forwards", "Min-Expires", "Record-Route",
* "Security-Verify", "Service-Route", "To", "Via", "Security-Server" and
* "Proxy-Authorization".
*
*  @lib sipclient.lib
*/
class CSIPMessageElements : public CBase
	{
    public:  // Constructors and destructor    
	    /**
        * Two-phased constructor.
        */
		IMPORT_C static CSIPMessageElements* NewL();

	    /**
        * Two-phased constructor.
        */
		IMPORT_C static CSIPMessageElements* NewLC();

        /**
        * Destructor.
        */
		IMPORT_C ~CSIPMessageElements();

    public: //new functions
		/**
		* Sets an array of user headers i.e. headers that user is allowed
		* manipulate to a SIP message. An empty array resets the user headers.
		* Note that the Content-Type header must be set using SetContentL. 
		*
		* @param aHeaders an array of SIP headers.
        *        The ownership of objects in the array is transferred.
		*/
		IMPORT_C void SetUserHeadersL(RPointerArray<CSIPHeaderBase>& aHeaders);

		/**
		* Gets all user SIP headers this class contains
		* @return SIP headers. Ownership is not transferred.
		*/
		IMPORT_C const RPointerArray<CSIPHeaderBase>& UserHeaders() const;

		/**
		* Sets the SIP message content and its type.
		* A zero length content can be set by providing a pointer
		* to a zero length HBufC8 instance (the ownership is transferred).
		* @pre aContent != 0 && aContentType != 0
		* @param aContent the content of a SIP message,
		*        		  the ownership is transferred
		* @param aContentType the SIP message content type,
		*        			  the ownership is transferred
		* @leave KErrArgument if aContent == 0 or
		*						 aContentType == 0
		*/
		IMPORT_C void SetContentL(HBufC8* aContent,
							      CSIPContentTypeHeader* aContentType);

		/**
		* Gets the SIP message content
		* @return SIP message content. If content does not exist, an empty
        *   descriptor is returned.
		*/
		IMPORT_C const TDesC8& Content() const;

		/**
		* Gets the content type
		* @return Content-Type-header or a 0-pointer if not present; the ownership
        *         is not transferred.
		*/
		IMPORT_C const CSIPContentTypeHeader* ContentType() const;

		/*
		* Removes the SIP message content and destroys
        * Content-Type header as well.
		* @return SIP message content; the ownership is transferred.
		*/
		IMPORT_C HBufC8* ExtractContent();

    public: // New functions, for internal use

	    static CSIPMessageElements* InternalizeL(RReadStream& aReadStream);
    	void ExternalizeL(RWriteStream& aWriteStream) const;
        TInt UserHeaderCount(RStringF aName) const;
        const RPointerArray<CSIPHeaderBase> UserHeadersL(RStringF aName) const;
        TInt RemoveHeaders(RStringF aName);
        void DetachUserHeader(CSIPHeaderBase* aHeader);
	    void AddHeaderL(CSIPHeaderBase* aHeader);
        void SetToL(CSIPToHeader* aTo);
        const CSIPToHeader* To() const;
        void SetFromL (CSIPFromHeader* aFrom);
        const CSIPFromHeader* From() const;
        const CSIPCSeqHeader* CSeq() const;
        void SetContent(HBufC8* aContent);
        void DetachContent();

    private:

        CSIPMessageElements();
	    void ConstructL();
	    void DoInternalizeL(RReadStream& aReadStream);
	    void CheckUserHeaderL(const CSIPHeaderBase* aHeader) const;
        void ExternalizeUserHeadersL(RWriteStream& aWriteStream) const;
        void ExternalizeL(const CSIPExtensionHeader* aHeader,
                          RWriteStream& aWriteStream) const;

	private: // Data
	
	    RPointerArray<CSIPHeaderBase> iUserHeaders;
	    HBufC8* iContent;
        CSIPFromHeader* iFromHeader;
        CSIPToHeader* iToHeader;
        CSIPCSeqHeader* iCSeqHeader;
        CSIPContentTypeHeader* iContentTypeHeader;
        TBool iHeaderLookupOpen;

	private: // For testing purposes
#ifdef CPPUNIT_TEST
	    friend class CSIPMessageElementsTest;
#endif
	};

#endif