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.
15 * Name : sipcontactheader.h
17 * Interface : SDK API, SIP Codec API
25 #ifndef CSIPCONTACTHEADER_H
26 #define CSIPCONTACTHEADER_H
29 #include "sipparameterheaderbase.h"
30 #include "_sipcodecdefs.h"
32 // FORWARD DECLARATIONS
34 class CSIPContactHeaderParams;
41 * Class provides functions for setting and getting SIP "Contact"
46 class CSIPContactHeader : public CSIPParameterHeaderBase
48 public: // Constructors and destructor
51 * Constructs a CSIPContactHeader from textual representation
52 * of the header's value part.
53 * Note that "Contact: *" can be only created using this function.
54 * @param aValue a value part of a "Contact"-header
55 * @return an array containing 1..n instances of CSIPContactHeader
57 IMPORT_C static RPointerArray<CSIPContactHeader>
58 DecodeL(const TDesC8& aValue);
61 * Creates a new instance of CSIPContactHeader
62 * @pre aSIPAddress != 0
63 * @param aSIPAddress a name-address, the ownership is transferred
64 * @return a new instance of CSIPContactHeader
66 IMPORT_C static CSIPContactHeader* NewL(CSIPAddress* aSIPAddress);
69 * Creates a new instance of CSIPContactHeader and puts it to CleanupStack
70 * @pre aSIPAddress != 0
71 * @param aSIPAddress a name-address, the ownership is transferred
72 * @return a new instance of CSIPContactHeader
74 IMPORT_C static CSIPContactHeader* NewLC(CSIPAddress* aSIPAddress);
77 * Destructor, deletes the resources of CSIPContactHeader.
79 IMPORT_C ~CSIPContactHeader();
82 public: // New functions
85 * Compares this object to another instance of CSIPContactHeader
86 * @param aHeader a CSIPContactHeader header to compare to
87 * @return ETrue if the objects are equal otherwise EFalse
89 IMPORT_C TBool operator==(const CSIPContactHeader& aHeader) const;
92 * Checks if the address is set to a STAR ("*")
93 * @return ETrue, if the address is a "*" otherwise EFalse
95 IMPORT_C TBool Star() const;
98 * Gets the value of the "expires"-parameter
99 * @return the "expires"-parameter, or
100 * KErrNotFound if the parameter is not present.
102 IMPORT_C TInt ExpiresParameter() const;
105 * Sets the "expires"-parameter
106 * @pre aExpiresParam >= 0
107 * @param aExpiresParam a "expires"-parameter value to set
109 IMPORT_C void SetExpiresParameterL(TInt aExpiresParam);
112 * Gets the value of "q"-parameter
113 * @pre Star() == EFalse
114 * @return the "q"-parameter value,
115 * or zero if the parameter is not present.
117 IMPORT_C TReal QParameter() const;
120 * Sets the "q"-parameter value in the "Contact" header
121 * @pre Star() == EFalse
122 * @param aQValue a "q"-parameter value to set
124 IMPORT_C void SetQParameterL(TReal aQValue);
127 * Gets the name-address as const
128 * @return name-address or 0 if not present
129 * The ownership is NOT transferred.
131 IMPORT_C const CSIPAddress* SIPAddress() const;
134 * Gets the name-address
135 * @return name-address or 0 if not present
136 * The ownership is NOT transferred.
138 IMPORT_C CSIPAddress* SIPAddress();
141 * Sets the name-address
142 * @pre Star() == EFalse
143 * @pre aSIPAddress != 0
144 * @param aSIPAddress a name-address to set, the ownership is transferred
146 IMPORT_C void SetSIPAddressL(CSIPAddress* aSIPAddress);
149 * Constructs an instance of a CSIPContactHeader from a RReadStream
150 * @param aReadStream a stream containing the value of the
151 * externalized object (header name not included).
152 * @return an instance of a CSIPContactHeader
154 IMPORT_C static CSIPHeaderBase*
155 InternalizeValueL(RReadStream& aReadStream);
158 public: // From CSIPHeaderBase
161 * From CSIPHeaderBase CloneL
163 IMPORT_C CSIPHeaderBase* CloneL() const;
166 * From CSIPHeaderBase Name
168 IMPORT_C RStringF Name() const;
171 public: // From CSIPHeaderBase, for internal use
176 TBool MoreThanOneAllowed() const;
181 TBool HasCompactName() const;
186 RStringF CompactName() const;
191 TPreferredPlace PreferredPlaceInMessage() const;
193 public: // New functions, for internal use
195 static RPointerArray<CSIPHeaderBase> BaseDecodeL(const TDesC8& aValue);
197 private: // From CSIPHeaderBase
199 void ExternalizeValueL(RWriteStream& aWriteStream) const;
201 private: // From CSIPParameterHeaderBase
203 TBool ParamInsertionAllowed() const;
204 HBufC8* ToTextMandatoryPartLC() const;
205 void ParseMandatoryPartL(const TDesC8& aMandatoryPart);
206 const CSIPParamContainerBase& Params() const;
207 CSIPParamContainerBase& Params();
209 private: // Constructors
211 CSIPContactHeader(TBool aIsStar=EFalse);
213 void ConstructL(CSIPAddress* aSIPAddress);
214 void ConstructL(const CSIPContactHeader& aContactHeader);
216 private: // New functions
218 void DoInternalizeValueL(RReadStream& aReadStream);
222 CSIPAddress* iSIPAddress;
223 CSIPContactHeaderParams* iParams;
226 private: // For testing purposes
228 UNIT_TEST(CSIPContactHeaderTest)
231 #endif // CSIPCONTACTHEADER_H