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