epoc32/include/sipaddress.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 sipaddress.h
     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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Name        : sipaddress.h
       
    16 * Part of     : SIP Codec
       
    17 * Interface   : SDK API, SIP Codec API
       
    18 * Version     : SIP/4.0 
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 #ifndef CSIPADDRESS_H
       
    26 #define CSIPADDRESS_H
       
    27 
       
    28 //  INCLUDES
       
    29 #include <e32base.h>
       
    30 #include <s32mem.h>
       
    31 #include <uri8.h>
       
    32 #include "_sipcodecdefs.h"
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class CURIContainer;
       
    36 
       
    37 // CLASS DECLARATION
       
    38 /**
       
    39 * @publishedAll
       
    40 * @released
       
    41 *
       
    42 * Class provides functions for setting and getting parameters in SIP 
       
    43 * name-addr structure
       
    44 *
       
    45 * @lib sipcodec.lib
       
    46 */
       
    47 class CSIPAddress : public CBase
       
    48 	{
       
    49 	public:	// Constructors and destructor
       
    50 
       
    51 		/**
       
    52 		* Constructs a CSIPAddress from textual representation 
       
    53 		* @param aValue SIP name-addr as text
       
    54 		* @return a new instance of CSIPAddress
       
    55 		*/
       
    56 		IMPORT_C static CSIPAddress* DecodeL(const TDesC8& aValue);
       
    57 
       
    58 		/**
       
    59 		* Creates a new instance of CSIPAddress
       
    60 		* @pre aUri != 0
       
    61 		* @param aUri the ownership is transferred.
       
    62 		* @return a new instance of CSIPAddress
       
    63 		*/
       
    64 		IMPORT_C static CSIPAddress* NewL(CUri8* aUri8);
       
    65 
       
    66 		/**
       
    67 		* Creates a new instance of CSIPAddress and puts it to CleanupStack
       
    68 		* @pre aUri != 0 
       
    69 		* @param aUri the ownership is transferred.
       
    70 		* @return a new instance of CSIPAddress
       
    71 		*/
       
    72 		IMPORT_C static CSIPAddress* NewLC(CUri8* aUri8);
       
    73 
       
    74 		/**
       
    75 		* Creates a new instance of CSIPAddress
       
    76 		* @pre aUri != 0
       
    77 		* @param aDisplayName a SIP token or a SIP quoted-string
       
    78 		* @param aUri the ownership is transferred.
       
    79 		* @return a new instance of CSIPAddress
       
    80 		*/
       
    81 		IMPORT_C static CSIPAddress* NewL(const TDesC8& aDisplayName, 
       
    82 		                                  CUri8* aUri8);
       
    83 
       
    84 		/**
       
    85 		* Creates a new instance of CSIPAddress and puts it to CleanupStack
       
    86 		* @pre aUri != 0
       
    87 		* @param aDisplayName a SIP token or a SIP quoted-string
       
    88 		* @param aUri the ownership is transferred.
       
    89 		* @return a new instance of CSIPAddress
       
    90 		*/
       
    91 		IMPORT_C static CSIPAddress* NewLC(const TDesC8& aDisplayName,
       
    92 									       CUri8* aUri8);
       
    93 
       
    94 		/**
       
    95 		* Creates a deep-copy of a CSIPAddress
       
    96 		* @param aSIPAddress the address to be copied
       
    97 		* @return a new instance of CSIPAddress
       
    98 		*/
       
    99 		IMPORT_C static CSIPAddress* NewL(const CSIPAddress& aSIPAddress);
       
   100 
       
   101 		/**
       
   102 		* Creates a deep-copy of a CSIPAddress and puts it to CleanupStack
       
   103 		* @param aSIPAddress the address to be copied
       
   104 		* @return a new instance of CSIPAddress
       
   105 		*/
       
   106 		IMPORT_C static CSIPAddress* NewLC(const CSIPAddress& aSIPAddress);
       
   107 
       
   108 		/**
       
   109 		* Destructor, deletes the resources of CSIPAddress.
       
   110 		*/
       
   111 		IMPORT_C ~CSIPAddress();
       
   112 
       
   113 
       
   114 	public: // New functions
       
   115 
       
   116 		/**
       
   117 		* Compares this object to another instance of CSIPAddress
       
   118 		* @param aSIPAddress a CSIPAddress to compare to
       
   119 		* @return ETrue if the objects are equal otherwise EFalse
       
   120 		*/
       
   121 		IMPORT_C TBool operator==(const CSIPAddress& aSIPAddress) const;
       
   122 	
       
   123 		/**
       
   124 		* Gets the display name
       
   125 		* @return the display name if present, 
       
   126 		* 		   otherwise a zero-length descriptor 
       
   127 		*/
       
   128 		IMPORT_C const TDesC8& DisplayName() const;
       
   129 	
       
   130 		/**
       
   131 		* Sets the display name
       
   132 		* @param aDisplayName a SIP token or a SIP quoted-string
       
   133 		*/
       
   134 		IMPORT_C void SetDisplayNameL(const TDesC8& aDisplayName);
       
   135 
       
   136 		/**
       
   137 		* Gets the URI part of the address as const
       
   138 		* @return a reference to the URI object
       
   139 		*/
       
   140 		IMPORT_C const CUri8& Uri8() const;
       
   141 	
       
   142 		/**
       
   143 		* Sets the URI part of the address
       
   144 		* @pre aUri!= 0
       
   145 		* @param aUri a pointer to the URI object, the ownership is transferred
       
   146 		*/
       
   147 		IMPORT_C void SetUri8L(CUri8* aUri8);
       
   148 
       
   149 		/**
       
   150 		* Creates a textual representation and pushes it to CleanupStack
       
   151 		* @param aUseAngleBrackets if ETrue, sets the anglebrackets
       
   152 		* @return a textual representation of the object,
       
   153 		*          the ownership is transferred
       
   154 		*/
       
   155 		IMPORT_C HBufC8* ToTextLC(TBool aUseAngleBrackets=EFalse) const;
       
   156 
       
   157 		/**
       
   158 		* Constructs an instance of a CSIPAddress from a RReadStream
       
   159 		* @param aReadStream a stream containing the externalized object
       
   160 		* @return an instance of a CSIPAddress
       
   161 		*/
       
   162 		IMPORT_C static CSIPAddress* InternalizeL(RReadStream& aReadStream);
       
   163 	
       
   164 		/**
       
   165 		* Writes the object to a RWriteStream
       
   166 		* @param aWriteStream a stream where the object is to be externalized
       
   167 		*/
       
   168 		IMPORT_C void ExternalizeL(RWriteStream& aWriteStream);
       
   169 
       
   170 
       
   171 	public: // For internal use:
       
   172 
       
   173 		IMPORT_C CURIContainer& URI();
       
   174 		IMPORT_C const CURIContainer& URI() const;
       
   175 		static CSIPAddress* NewLC(CURIContainer* aURI);
       
   176 		
       
   177 
       
   178 	private: // Constructors
       
   179 	
       
   180 		CSIPAddress();
       
   181 		void ConstructL();
       
   182 		void ConstructL(CUri8* aUri);
       
   183 		void ConstructL(const TDesC8& aDisplayName, CUri8* aUri);
       
   184 		void ConstructL(const CSIPAddress& aSIPAddress);
       
   185 		void ConstructL(CURIContainer* aURI);
       
   186 
       
   187 	private: // New functions
       
   188 
       
   189 		void DoInternalizeL(RReadStream& aReadStream);
       
   190 		TInt QuotedStringLength(const TDesC8& aValue);
       
   191 		TBool CheckDisplayName(const TDesC8& aValue);
       
   192 		void ParseURIInAngleBracketsL(const TDesC8& aValue);
       
   193 		void ParseURIL(const TDesC8& aValue);
       
   194 		TBool ContainsSeparators(const TDesC8& aValue) const;
       
   195 		TBool HasDisplayName() const;
       
   196 
       
   197 	private: // Data
       
   198 
       
   199 		HBufC8* iDisplayName;
       
   200 		CURIContainer* iURI;
       
   201 
       
   202 	private: // For testing purposes
       
   203 	
       
   204 		UNIT_TEST(CSIPAddressTest)
       
   205     };
       
   206 
       
   207 #endif // end of __SIP_ADDRESS_H__
       
   208 
       
   209 // End of File