realtimenetprots/sipfw/SIP/Codec/inc/siphostport.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2004-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 "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 * Name          : siphostport.h
       
    16 * Part of       : SIP Codec
       
    17 * Version       : SIP/4.0 
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @internalComponent
       
    26 */
       
    27 
       
    28 
       
    29 #ifndef SIPHOSTPORT_H
       
    30 #define SIPHOSTPORT_H
       
    31 
       
    32 //  INCLUDES
       
    33 #include <e32base.h>
       
    34 #include "_sipcodecdefs.h"
       
    35 
       
    36 // CLASS DECLARATION
       
    37 /**
       
    38 * Class provides functions for setting and getting host and port
       
    39 * in hostport structure (host[":"port]) with syntax checking
       
    40 *
       
    41 * @lib sipcodec.lib
       
    42 */
       
    43 class CSIPHostPort : public CBase
       
    44 	{
       
    45 	public: // Enumerations
       
    46 
       
    47 		/** SIP host types */
       
    48 		enum TType
       
    49 			{
       
    50 			ESIPNoHost=0,
       
    51 			ESIPIpv4=1,
       
    52 			ESIPIpv6=2,
       
    53 			ESIPHostName=3 // fully qualified domain name
       
    54 			};
       
    55 
       
    56 
       
    57 	public:	// Constructors and destructor
       
    58 
       
    59 		/**
       
    60 		* Constructs a CSIPHostPort from textual representation 
       
    61 		* @param aValue BNF: host[":"port]
       
    62 		* @return a new instance of CSIPHostPort
       
    63 		*/
       
    64 		IMPORT_C static CSIPHostPort* DecodeL(const TDesC8& aValue);
       
    65 
       
    66         /**
       
    67         * Creates a deep copy of the given CSIPHostPort instance
       
    68         * @param aHostPort CSIPHostPort to be copied
       
    69         * @return a new instance of CSIPHostPort
       
    70         */
       
    71         IMPORT_C static CSIPHostPort* NewL (const CSIPHostPort& aHostPort);
       
    72 
       
    73 	    /**
       
    74 	    * Creates a deep copy of the given CSIPHostPort instance and 
       
    75         * pushes it to CleanupStack.
       
    76         * @param aHostPort CSIPHostPort to be copied
       
    77         * @return a new instance of CSIPHostPort
       
    78         */
       
    79 	    IMPORT_C static CSIPHostPort* NewLC (const CSIPHostPort& aHostPort);
       
    80 
       
    81 		/**
       
    82 		* Destructor, deletes the resources of CSIPHostPort.
       
    83 		*/
       
    84 		IMPORT_C ~CSIPHostPort();
       
    85 
       
    86 
       
    87 	public: // New functions
       
    88 
       
    89 		/**
       
    90 		* Sets the host
       
    91 		* @param aHost host (host name / IPv4 / IPv6)
       
    92 		*/
       
    93 		IMPORT_C void SetHostL(const TDesC8& aHost);
       
    94 	
       
    95 		/**
       
    96 		* Gets the host
       
    97 		* @return the host 
       
    98 		*/
       
    99 		IMPORT_C const TDesC8& Host() const;
       
   100 	
       
   101 		/**
       
   102 		* Gets the type of the host 
       
   103 		* @return the host type (host name / IPv4 / IPv6)
       
   104 		*/	
       
   105 		IMPORT_C TType HostType() const;
       
   106 
       
   107 		/**
       
   108 		* Checks if port is present
       
   109 		* @pre HasHost() == ETrue
       
   110 		* @return ETrue if present, otherwise EFalse 
       
   111 		*/
       
   112 		IMPORT_C TBool HasPort() const;
       
   113 
       
   114 		/**
       
   115 		* Gets the port
       
   116 		* @return the port
       
   117 		*/	
       
   118 		IMPORT_C TUint Port() const;
       
   119 
       
   120 		/**
       
   121 		* Sets the port
       
   122 		* @param aPort the port to set
       
   123 		*/	
       
   124 		IMPORT_C void SetPort(TUint aPort);
       
   125 
       
   126 		/**
       
   127 		* Deletes the port part
       
   128 		* @pre HasPort() == ETrue
       
   129 		* @return KErrNotFound, if port was not present, otherwise KErrNone, 
       
   130 		*         if deletion was successful
       
   131 		*/	
       
   132 		IMPORT_C TInt DeletePort();
       
   133 
       
   134 		/**
       
   135 		* Compares this object to another instance of CSIPHostPort
       
   136 		* @param aURI a CSIPHostPort instance to compare to
       
   137 		* @return ETrue if the objects are equal otherwise EFalse
       
   138 		*/
       
   139 		IMPORT_C TBool operator==(const CSIPHostPort& aHostPort) const;
       
   140 
       
   141 
       
   142 	public: // For internal use
       
   143 
       
   144 		HBufC8* ToTextLC() const;
       
   145 
       
   146 	private: // Constructors
       
   147 
       
   148 		CSIPHostPort();
       
   149 		void ConstructL();
       
   150 		void ConstructL(const CSIPHostPort& aHostPort);
       
   151 
       
   152 	private: // New functions
       
   153 
       
   154 		static TUint ParsePortL(const TDesC8& aValue);
       
   155 	
       
   156 	private: // Data
       
   157 
       
   158 		HBufC8* iHost;
       
   159 		TType iHostType;
       
   160 		TBool iHasPort;
       
   161 		TUint iPort;
       
   162 
       
   163 	private: // For testing purposes
       
   164 	
       
   165 		UNIT_TEST(CSIPHostPortTest)
       
   166 	};
       
   167 
       
   168 #endif // end of SIPHOSTPORT_H
       
   169 
       
   170 // End of File