2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
17 * Interface : SDK API, SIP Codec API
33 // FORWARD DECLARATIONS
41 * Class provides functions for setting and getting parameters in SIP
46 class CSIPAddress : public CBase
48 public: // Constructors and destructor
51 * Constructs a CSIPAddress from textual representation
52 * @param aValue SIP name-addr as text
53 * @return a new instance of CSIPAddress
55 IMPORT_C static CSIPAddress* DecodeL(const TDesC8& aValue);
58 * Creates a new instance of CSIPAddress
60 * @param aUri the ownership is transferred.
61 * @return a new instance of CSIPAddress
63 IMPORT_C static CSIPAddress* NewL(CUri8* aUri8);
66 * Creates a new instance of CSIPAddress and puts it to CleanupStack
68 * @param aUri the ownership is transferred.
69 * @return a new instance of CSIPAddress
71 IMPORT_C static CSIPAddress* NewLC(CUri8* aUri8);
74 * Creates a new instance of CSIPAddress
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
80 IMPORT_C static CSIPAddress* NewL(const TDesC8& aDisplayName,
84 * Creates a new instance of CSIPAddress and puts it to CleanupStack
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
90 IMPORT_C static CSIPAddress* NewLC(const TDesC8& aDisplayName,
94 * Creates a deep-copy of a CSIPAddress
95 * @param aSIPAddress the address to be copied
96 * @return a new instance of CSIPAddress
98 IMPORT_C static CSIPAddress* NewL(const CSIPAddress& aSIPAddress);
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
105 IMPORT_C static CSIPAddress* NewLC(const CSIPAddress& aSIPAddress);
108 * Destructor, deletes the resources of CSIPAddress.
110 IMPORT_C ~CSIPAddress();
113 public: // New functions
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
120 IMPORT_C TBool operator==(const CSIPAddress& aSIPAddress) const;
123 * Gets the display name
124 * @return the display name if present,
125 * otherwise a zero-length descriptor
127 IMPORT_C const TDesC8& DisplayName() const;
130 * Sets the display name
131 * @param aDisplayName a SIP token or a SIP quoted-string
133 IMPORT_C void SetDisplayNameL(const TDesC8& aDisplayName);
136 * Gets the URI part of the address as const
137 * @return a reference to the URI object
139 IMPORT_C const CUri8& Uri8() const;
142 * Sets the URI part of the address
144 * @param aUri a pointer to the URI object, the ownership is transferred
146 IMPORT_C void SetUri8L(CUri8* aUri8);
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
154 IMPORT_C HBufC8* ToTextLC(TBool aUseAngleBrackets=EFalse) const;
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
161 IMPORT_C static CSIPAddress* InternalizeL(RReadStream& aReadStream);
164 * Writes the object to a RWriteStream
165 * @param aWriteStream a stream where the object is to be externalized
167 IMPORT_C void ExternalizeL(RWriteStream& aWriteStream);
170 public: // For internal use:
172 IMPORT_C CURIContainer& URI();
173 IMPORT_C const CURIContainer& URI() const;
174 static CSIPAddress* NewLC(CURIContainer* aURI);
177 private: // Constructors
181 void ConstructL(CUri8* aUri);
182 void ConstructL(const TDesC8& aDisplayName, CUri8* aUri);
183 void ConstructL(const CSIPAddress& aSIPAddress);
184 void ConstructL(CURIContainer* aURI);
186 private: // New functions
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;
198 HBufC8* iDisplayName;
201 private: // For testing purposes
203 friend class CSIPAddressTest;
207 #endif // end of __SIP_ADDRESS_H__