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.
15 * Name : sipcontactheader.h
17 * Interface : SDK API, SIP Codec API
25 #ifndef CSIPCONTACTHEADER_H
26 #define CSIPCONTACTHEADER_H
29 #include "sipparameterheaderbase.h"
31 // FORWARD DECLARATIONS
33 class CSIPContactHeaderParams;
40 * Class provides functions for setting and getting SIP "Contact"
45 class CSIPContactHeader : public CSIPParameterHeaderBase
47 public: // Constructors and destructor
50 * Constructs a CSIPContactHeader from textual representation
51 * of the header's value part.
52 * Note that "Contact: *" can be only created using this function.
53 * @param aValue a value part of a "Contact"-header
54 * @return an array containing 1..n instances of CSIPContactHeader
56 IMPORT_C static RPointerArray<CSIPContactHeader>
57 DecodeL(const TDesC8& aValue);
60 * Creates a new instance of CSIPContactHeader
61 * @pre aSIPAddress != 0
62 * @param aSIPAddress a name-address, the ownership is transferred
63 * @return a new instance of CSIPContactHeader
65 IMPORT_C static CSIPContactHeader* NewL(CSIPAddress* aSIPAddress);
68 * Creates a new instance of CSIPContactHeader and puts it to CleanupStack
69 * @pre aSIPAddress != 0
70 * @param aSIPAddress a name-address, the ownership is transferred
71 * @return a new instance of CSIPContactHeader
73 IMPORT_C static CSIPContactHeader* NewLC(CSIPAddress* aSIPAddress);
76 * Destructor, deletes the resources of CSIPContactHeader.
78 IMPORT_C ~CSIPContactHeader();
81 public: // New functions
84 * Compares this object to another instance of CSIPContactHeader
85 * @param aHeader a CSIPContactHeader header to compare to
86 * @return ETrue if the objects are equal otherwise EFalse
88 IMPORT_C TBool operator==(const CSIPContactHeader& aHeader) const;
91 * Checks if the address is set to a STAR ("*")
92 * @return ETrue, if the address is a "*" otherwise EFalse
94 IMPORT_C TBool Star() const;
97 * Gets the value of the "expires"-parameter
98 * @return the "expires"-parameter, or
99 * KErrNotFound if the parameter is not present.
101 IMPORT_C TInt ExpiresParameter() const;
104 * Sets the "expires"-parameter
105 * @pre aExpiresParam >= 0
106 * @param aExpiresParam a "expires"-parameter value to set
108 IMPORT_C void SetExpiresParameterL(TInt aExpiresParam);
111 * Gets the value of "q"-parameter
112 * @pre Star() == EFalse
113 * @return the "q"-parameter value,
114 * or zero if the parameter is not present.
116 IMPORT_C TReal QParameter() const;
119 * Sets the "q"-parameter value in the "Contact" header
120 * @pre Star() == EFalse
121 * @param aQValue a "q"-parameter value to set
123 IMPORT_C void SetQParameterL(TReal aQValue);
126 * Gets the name-address as const
127 * @return name-address or 0 if not present
128 * The ownership is NOT transferred.
130 IMPORT_C const CSIPAddress* SIPAddress() const;
133 * Gets the name-address
134 * @return name-address or 0 if not present
135 * The ownership is NOT transferred.
137 IMPORT_C CSIPAddress* SIPAddress();
140 * Sets the name-address
141 * @pre Star() == EFalse
142 * @pre aSIPAddress != 0
143 * @param aSIPAddress a name-address to set, the ownership is transferred
145 IMPORT_C void SetSIPAddressL(CSIPAddress* aSIPAddress);
148 * Constructs an instance of a CSIPContactHeader from a RReadStream
149 * @param aReadStream a stream containing the value of the
150 * externalized object (header name not included).
151 * @return an instance of a CSIPContactHeader
153 IMPORT_C static CSIPHeaderBase*
154 InternalizeValueL(RReadStream& aReadStream);
156 public: // From CSIPHeaderBase
159 * From CSIPHeaderBase CloneL
161 IMPORT_C CSIPHeaderBase* CloneL() const;
164 * From CSIPHeaderBase Name
166 IMPORT_C RStringF Name() const;
168 public: //New Function
171 * Removes the "expires"-parameter
173 IMPORT_C void RemoveExpiresParam();
176 public: // From CSIPHeaderBase, for internal use
181 TBool MoreThanOneAllowed() const;
186 TBool HasCompactName() const;
191 RStringF CompactName() const;
196 TPreferredPlace PreferredPlaceInMessage() const;
198 public: // New functions, for internal use
200 static RPointerArray<CSIPHeaderBase> BaseDecodeL(const TDesC8& aValue);
202 private: // From CSIPHeaderBase
204 void ExternalizeValueL(RWriteStream& aWriteStream) const;
206 private: // From CSIPParameterHeaderBase
208 TBool ParamInsertionAllowed() const;
209 HBufC8* ToTextMandatoryPartLC() const;
210 void ParseMandatoryPartL(const TDesC8& aMandatoryPart);
211 const CSIPParamContainerBase& Params() const;
212 CSIPParamContainerBase& Params();
214 private: // Constructors
216 CSIPContactHeader(TBool aIsStar=EFalse);
218 void ConstructL(CSIPAddress* aSIPAddress);
219 void ConstructL(const CSIPContactHeader& aContactHeader);
221 private: // New functions
223 void DoInternalizeValueL(RReadStream& aReadStream);
227 CSIPAddress* iSIPAddress;
228 CSIPContactHeaderParams* iParams;
231 private: // For testing purposes
233 friend class CSIPContactHeaderTest;
237 #endif // CSIPCONTACTHEADER_H