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 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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
17 * Interface : SDK API, SIP Codec API
32 #include "_sipcodecdefs.h"
34 // FORWARD DECLARATIONS
42 * Class provides functions for setting and getting parameters in SIP
47 class CSIPAddress : public CBase
49 public: // Constructors and destructor
52 * Constructs a CSIPAddress from textual representation
53 * @param aValue SIP name-addr as text
54 * @return a new instance of CSIPAddress
56 IMPORT_C static CSIPAddress* DecodeL(const TDesC8& aValue);
59 * Creates a new instance of CSIPAddress
61 * @param aUri the ownership is transferred.
62 * @return a new instance of CSIPAddress
64 IMPORT_C static CSIPAddress* NewL(CUri8* aUri8);
67 * Creates a new instance of CSIPAddress and puts it to CleanupStack
69 * @param aUri the ownership is transferred.
70 * @return a new instance of CSIPAddress
72 IMPORT_C static CSIPAddress* NewLC(CUri8* aUri8);
75 * Creates a new instance of CSIPAddress
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
81 IMPORT_C static CSIPAddress* NewL(const TDesC8& aDisplayName,
85 * Creates a new instance of CSIPAddress and puts it to CleanupStack
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
91 IMPORT_C static CSIPAddress* NewLC(const TDesC8& aDisplayName,
95 * Creates a deep-copy of a CSIPAddress
96 * @param aSIPAddress the address to be copied
97 * @return a new instance of CSIPAddress
99 IMPORT_C static CSIPAddress* NewL(const CSIPAddress& aSIPAddress);
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
106 IMPORT_C static CSIPAddress* NewLC(const CSIPAddress& aSIPAddress);
109 * Destructor, deletes the resources of CSIPAddress.
111 IMPORT_C ~CSIPAddress();
114 public: // New functions
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
121 IMPORT_C TBool operator==(const CSIPAddress& aSIPAddress) const;
124 * Gets the display name
125 * @return the display name if present,
126 * otherwise a zero-length descriptor
128 IMPORT_C const TDesC8& DisplayName() const;
131 * Sets the display name
132 * @param aDisplayName a SIP token or a SIP quoted-string
134 IMPORT_C void SetDisplayNameL(const TDesC8& aDisplayName);
137 * Gets the URI part of the address as const
138 * @return a reference to the URI object
140 IMPORT_C const CUri8& Uri8() const;
143 * Sets the URI part of the address
145 * @param aUri a pointer to the URI object, the ownership is transferred
147 IMPORT_C void SetUri8L(CUri8* aUri8);
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
155 IMPORT_C HBufC8* ToTextLC(TBool aUseAngleBrackets=EFalse) const;
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
162 IMPORT_C static CSIPAddress* InternalizeL(RReadStream& aReadStream);
165 * Writes the object to a RWriteStream
166 * @param aWriteStream a stream where the object is to be externalized
168 IMPORT_C void ExternalizeL(RWriteStream& aWriteStream);
171 public: // For internal use:
173 IMPORT_C CURIContainer& URI();
174 IMPORT_C const CURIContainer& URI() const;
175 static CSIPAddress* NewLC(CURIContainer* aURI);
178 private: // Constructors
182 void ConstructL(CUri8* aUri);
183 void ConstructL(const TDesC8& aDisplayName, CUri8* aUri);
184 void ConstructL(const CSIPAddress& aSIPAddress);
185 void ConstructL(CURIContainer* aURI);
187 private: // New functions
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;
199 HBufC8* iDisplayName;
202 private: // For testing purposes
204 UNIT_TEST(CSIPAddressTest)
207 #endif // end of __SIP_ADDRESS_H__