epoc32/include/mw/sipaddress.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.
     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        : 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 
    33 // FORWARD DECLARATIONS
    34 class CURIContainer;
    35 
    36 // CLASS DECLARATION
    37 /**
    38 * @publishedAll
    39 * @released
    40 *
    41 * Class provides functions for setting and getting parameters in SIP 
    42 * name-addr structure
    43 *
    44 * @lib sipcodec.lib
    45 */
    46 class CSIPAddress : public CBase
    47 	{
    48 	public:	// Constructors and destructor
    49 
    50 		/**
    51 		* Constructs a CSIPAddress from textual representation 
    52 		* @param aValue SIP name-addr as text
    53 		* @return a new instance of CSIPAddress
    54 		*/
    55 		IMPORT_C static CSIPAddress* DecodeL(const TDesC8& aValue);
    56 
    57 		/**
    58 		* Creates a new instance of CSIPAddress
    59 		* @pre aUri != 0
    60 		* @param aUri the ownership is transferred.
    61 		* @return a new instance of CSIPAddress
    62 		*/
    63 		IMPORT_C static CSIPAddress* NewL(CUri8* aUri8);
    64 
    65 		/**
    66 		* Creates a new instance of CSIPAddress and puts it to CleanupStack
    67 		* @pre aUri != 0 
    68 		* @param aUri the ownership is transferred.
    69 		* @return a new instance of CSIPAddress
    70 		*/
    71 		IMPORT_C static CSIPAddress* NewLC(CUri8* aUri8);
    72 
    73 		/**
    74 		* Creates a new instance of CSIPAddress
    75 		* @pre aUri != 0
    76 		* @param aDisplayName a SIP token or a SIP quoted-string
    77 		* @param aUri the ownership is transferred.
    78 		* @return a new instance of CSIPAddress
    79 		*/
    80 		IMPORT_C static CSIPAddress* NewL(const TDesC8& aDisplayName, 
    81 		                                  CUri8* aUri8);
    82 
    83 		/**
    84 		* Creates a new instance of CSIPAddress and puts it to CleanupStack
    85 		* @pre aUri != 0
    86 		* @param aDisplayName a SIP token or a SIP quoted-string
    87 		* @param aUri the ownership is transferred.
    88 		* @return a new instance of CSIPAddress
    89 		*/
    90 		IMPORT_C static CSIPAddress* NewLC(const TDesC8& aDisplayName,
    91 									       CUri8* aUri8);
    92 
    93 		/**
    94 		* Creates a deep-copy of a CSIPAddress
    95 		* @param aSIPAddress the address to be copied
    96 		* @return a new instance of CSIPAddress
    97 		*/
    98 		IMPORT_C static CSIPAddress* NewL(const CSIPAddress& aSIPAddress);
    99 
   100 		/**
   101 		* Creates a deep-copy of a CSIPAddress and puts it to CleanupStack
   102 		* @param aSIPAddress the address to be copied
   103 		* @return a new instance of CSIPAddress
   104 		*/
   105 		IMPORT_C static CSIPAddress* NewLC(const CSIPAddress& aSIPAddress);
   106 
   107 		/**
   108 		* Destructor, deletes the resources of CSIPAddress.
   109 		*/
   110 		IMPORT_C ~CSIPAddress();
   111 
   112 
   113 	public: // New functions
   114 
   115 		/**
   116 		* Compares this object to another instance of CSIPAddress
   117 		* @param aSIPAddress a CSIPAddress to compare to
   118 		* @return ETrue if the objects are equal otherwise EFalse
   119 		*/
   120 		IMPORT_C TBool operator==(const CSIPAddress& aSIPAddress) const;
   121 	
   122 		/**
   123 		* Gets the display name
   124 		* @return the display name if present, 
   125 		* 		   otherwise a zero-length descriptor 
   126 		*/
   127 		IMPORT_C const TDesC8& DisplayName() const;
   128 	
   129 		/**
   130 		* Sets the display name
   131 		* @param aDisplayName a SIP token or a SIP quoted-string
   132 		*/
   133 		IMPORT_C void SetDisplayNameL(const TDesC8& aDisplayName);
   134 
   135 		/**
   136 		* Gets the URI part of the address as const
   137 		* @return a reference to the URI object
   138 		*/
   139 		IMPORT_C const CUri8& Uri8() const;
   140 	
   141 		/**
   142 		* Sets the URI part of the address
   143 		* @pre aUri!= 0
   144 		* @param aUri a pointer to the URI object, the ownership is transferred
   145 		*/
   146 		IMPORT_C void SetUri8L(CUri8* aUri8);
   147 
   148 		/**
   149 		* Creates a textual representation and pushes it to CleanupStack
   150 		* @param aUseAngleBrackets if ETrue, sets the anglebrackets
   151 		* @return a textual representation of the object,
   152 		*          the ownership is transferred
   153 		*/
   154 		IMPORT_C HBufC8* ToTextLC(TBool aUseAngleBrackets=EFalse) const;
   155 
   156 		/**
   157 		* Constructs an instance of a CSIPAddress from a RReadStream
   158 		* @param aReadStream a stream containing the externalized object
   159 		* @return an instance of a CSIPAddress
   160 		*/
   161 		IMPORT_C static CSIPAddress* InternalizeL(RReadStream& aReadStream);
   162 	
   163 		/**
   164 		* Writes the object to a RWriteStream
   165 		* @param aWriteStream a stream where the object is to be externalized
   166 		*/
   167 		IMPORT_C void ExternalizeL(RWriteStream& aWriteStream);
   168 
   169 
   170 	public: // For internal use:
   171 
   172 		IMPORT_C CURIContainer& URI();
   173 		IMPORT_C const CURIContainer& URI() const;
   174 		static CSIPAddress* NewLC(CURIContainer* aURI);
   175 		
   176 
   177 	private: // Constructors
   178 	
   179 		CSIPAddress();
   180 		void ConstructL();
   181 		void ConstructL(CUri8* aUri);
   182 		void ConstructL(const TDesC8& aDisplayName, CUri8* aUri);
   183 		void ConstructL(const CSIPAddress& aSIPAddress);
   184 		void ConstructL(CURIContainer* aURI);
   185 
   186 	private: // New functions
   187 
   188 		void DoInternalizeL(RReadStream& aReadStream);
   189 		TInt QuotedStringLength(const TDesC8& aValue);
   190 		TBool CheckDisplayName(const TDesC8& aValue);
   191 		void ParseURIInAngleBracketsL(const TDesC8& aValue);
   192 		void ParseURIL(const TDesC8& aValue);
   193 		TBool ContainsSeparators(const TDesC8& aValue) const;
   194 		TBool HasDisplayName() const;
   195 
   196 	private: // Data
   197 
   198 		HBufC8* iDisplayName;
   199 		CURIContainer* iURI;
   200 
   201 	private: // For testing purposes
   202 #ifdef CPPUNIT_TEST	
   203 		friend class CSIPAddressTest;
   204 #endif
   205     };
   206 
   207 #endif // end of __SIP_ADDRESS_H__
   208 
   209 // End of File