realtimenetprots/sipfw/SIP/Codec/inc/uricontainer.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          : uricontainer.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 CURICONTAINER_H
       
    30 #define CURICONTAINER_H
       
    31 
       
    32 //  INCLUDES
       
    33 #include <e32base.h>
       
    34 #include <s32mem.h>
       
    35 #include <uri8.h>
       
    36 #include <stringpool.h>
       
    37 #include "_sipcodecdefs.h"
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 class CSIPURI;
       
    41 
       
    42 // CLASS DECLARATION
       
    43 /**
       
    44 * A wrapper class for a generic URI that encapsulates 
       
    45 * a CUri8 or a CSIPURI instance 
       
    46 *
       
    47 * @lib sipcodec.lib
       
    48 */
       
    49 class CURIContainer : public CBase
       
    50 	{
       
    51 	public:	// Constructors and destructor
       
    52 
       
    53 		/**
       
    54 		* Constructs a CURIContainer from textual representation 
       
    55 		* @param aValue a generic URI as text
       
    56 		* @return a new instance of CURIContainer
       
    57 		*/
       
    58 		IMPORT_C static CURIContainer* DecodeL(const TDesC8& aValue);
       
    59 
       
    60 		/**
       
    61 		* Creates a new CURIContainer instance
       
    62 		* @pre aUri8 != 0
       
    63 		* @param aUri8 the ownership is transferred
       
    64 		* @return a new instance of CURIContainer
       
    65 		*/
       
    66 		IMPORT_C static CURIContainer* NewL(CUri8* aUri8);
       
    67 
       
    68 		/**
       
    69 		* Creates a new CURIContainer instance and pushes it to CleanupStack
       
    70 		* @pre aUri8 != 0
       
    71 		* @param aUri8 the ownership is transferred
       
    72 		* @return a new instance of CURIContainer
       
    73 		*/
       
    74 		IMPORT_C static CURIContainer* NewLC(CUri8* aUri8);
       
    75 
       
    76 		/**
       
    77 		* Creates a deep copy of the given CURIContainer instance
       
    78 		* @param aURI CURIContainer to be copied
       
    79 		* @return a new instance of CURIContainer
       
    80 		*/
       
    81 		IMPORT_C static CURIContainer* NewL(const CURIContainer& aURI);
       
    82 	
       
    83 		/**
       
    84 		* Creates a deep copy of the given CURIContainer instance and 
       
    85 		* pushes it to CleanupStack.
       
    86 		* @param aURI CURIContainer to be copied
       
    87 		* @return a new instance of CURIContainer
       
    88 		*/
       
    89 		IMPORT_C static CURIContainer* NewLC(const CURIContainer& aURI);
       
    90 
       
    91 		/**
       
    92 		* Destructor, deletes the resources of CURIContainer.
       
    93 		*/
       
    94 		IMPORT_C ~CURIContainer();
       
    95 	
       
    96 
       
    97 	public: // New functions
       
    98 
       
    99 		/**
       
   100 		* Checks if the wrapped URI is SIP/SIPS-URI
       
   101 		* @return ETrue if the wrapped URI is SIP/SIPS-URI, otherwise EFalse
       
   102 		*/
       
   103 		IMPORT_C TBool IsSIPURI() const;
       
   104 
       
   105 		/**
       
   106 		* Gets the SIP URI if present.
       
   107 		* @pre IsSIPURI()==ETrue
       
   108 		* @return a modifiable CSIPURI or NULL if not present.
       
   109 		*/
       
   110 		IMPORT_C CSIPURI* SIPURI();
       
   111 
       
   112 		/**
       
   113 		* Gets the SIP URI if present.
       
   114 		* @pre IsSIPURI()==ETrue
       
   115 		* @return a non-modifiable CSIPURI or NULL if not present.
       
   116 		*/
       
   117 		IMPORT_C const CSIPURI* SIPURI() const;
       
   118 
       
   119 		/**
       
   120 		* Gets the CUri8.
       
   121 		* @return a non-modifiable CUri8 or NULL if IsSIPURI()==ETrue
       
   122 		*/
       
   123 		IMPORT_C const CUri8* Uri8() const;
       
   124 
       
   125 		/**
       
   126 		* Compares this object to another instance of CURIContainer
       
   127 		* @param  aURI a URI to compare to
       
   128 		* @return ETrue, if the objects are equal otherwise EFalse
       
   129 		*/
       
   130 		IMPORT_C TBool operator==(const CURIContainer& aURI) const;
       
   131 	
       
   132 		/**
       
   133 		* Encodes the object into a textual representation.
       
   134 		* @return a textual representation of the object,
       
   135 		*         the ownership is transferred
       
   136 		*/
       
   137 		IMPORT_C HBufC8* ToTextL() const;	
       
   138 	
       
   139 		/**
       
   140 		* Constructs an instance of a CURIContainer from a RReadStream
       
   141 		*
       
   142 		* @param aReadStream a stream containing the externalized object
       
   143 		* @return a new instance of CURIContainer
       
   144 		*/ 
       
   145 		IMPORT_C static CURIContainer* InternalizeL(RReadStream& aReadStream);
       
   146 	
       
   147 		/**
       
   148 		* Externalizes the object to stream
       
   149 		*
       
   150 		* @param aWriteStream a stream where the object is to be externalized
       
   151 		*/
       
   152 		IMPORT_C void ExternalizeL(RWriteStream& aWriteStream) const;
       
   153 	
       
   154 		/**
       
   155 		* Clones the contained URI as CUri8.
       
   156 		* SIP-URIs are also converted to CUri8s.
       
   157 		* @return a new instance of CUri8, the ownership is transferred
       
   158 		*/		
       
   159 		IMPORT_C CUri8* CloneAsUri8L() const;
       
   160 
       
   161     public: // New functions, for internal use
       
   162 
       
   163         static CUri8* CreateUri8L(const TDesC8& aValue);
       
   164 
       
   165 	private: // Constructors
       
   166 
       
   167 		void ConstructL();
       
   168 		void ConstructL(CUri8* aUri8);
       
   169 		void ConstructL(const CURIContainer& aURI);
       
   170 
       
   171 	private: // New functions
       
   172 
       
   173 		void DoInternalizeL(RReadStream& aReadStream);
       
   174         static TBool FindSIP(const TDesC8& aValue);
       
   175 
       
   176 	private: // Data
       
   177 	
       
   178 		CSIPURI* iSIPURI;
       
   179 		CUri8* iUri8;
       
   180 
       
   181     private: // For testing purposes
       
   182 
       
   183         UNIT_TEST(CURIContainerTest)
       
   184 	};
       
   185 
       
   186 #endif // CURICONTAINER_H
       
   187 
       
   188 // End of File