|
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 : sipcontactheader.h |
|
16 * Part of : SIP Codec |
|
17 * Interface : SDK API, SIP Codec API |
|
18 * Version : SIP/4.0 |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 #ifndef CSIPCONTACTHEADER_H |
|
26 #define CSIPCONTACTHEADER_H |
|
27 |
|
28 // INCLUDES |
|
29 #include "sipparameterheaderbase.h" |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class CSIPAddress; |
|
33 class CSIPContactHeaderParams; |
|
34 |
|
35 // CLASS DECLARATION |
|
36 /** |
|
37 * @publishedAll |
|
38 * @released |
|
39 * |
|
40 * Class provides functions for setting and getting SIP "Contact" |
|
41 * header fields. |
|
42 * |
|
43 * @lib sipcodec.lib |
|
44 */ |
|
45 class CSIPContactHeader : public CSIPParameterHeaderBase |
|
46 { |
|
47 public: // Constructors and destructor |
|
48 |
|
49 /** |
|
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 |
|
55 */ |
|
56 IMPORT_C static RPointerArray<CSIPContactHeader> |
|
57 DecodeL(const TDesC8& aValue); |
|
58 |
|
59 /** |
|
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 |
|
64 */ |
|
65 IMPORT_C static CSIPContactHeader* NewL(CSIPAddress* aSIPAddress); |
|
66 |
|
67 /** |
|
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 |
|
72 */ |
|
73 IMPORT_C static CSIPContactHeader* NewLC(CSIPAddress* aSIPAddress); |
|
74 |
|
75 /** |
|
76 * Destructor, deletes the resources of CSIPContactHeader. |
|
77 */ |
|
78 IMPORT_C ~CSIPContactHeader(); |
|
79 |
|
80 |
|
81 public: // New functions |
|
82 |
|
83 /** |
|
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 |
|
87 */ |
|
88 IMPORT_C TBool operator==(const CSIPContactHeader& aHeader) const; |
|
89 |
|
90 /** |
|
91 * Checks if the address is set to a STAR ("*") |
|
92 * @return ETrue, if the address is a "*" otherwise EFalse |
|
93 */ |
|
94 IMPORT_C TBool Star() const; |
|
95 |
|
96 /** |
|
97 * Gets the value of the "expires"-parameter |
|
98 * @return the "expires"-parameter, or |
|
99 * KErrNotFound if the parameter is not present. |
|
100 */ |
|
101 IMPORT_C TInt ExpiresParameter() const; |
|
102 |
|
103 /** |
|
104 * Sets the "expires"-parameter |
|
105 * @pre aExpiresParam >= 0 |
|
106 * @param aExpiresParam a "expires"-parameter value to set |
|
107 */ |
|
108 IMPORT_C void SetExpiresParameterL(TInt aExpiresParam); |
|
109 |
|
110 /** |
|
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. |
|
115 */ |
|
116 IMPORT_C TReal QParameter() const; |
|
117 |
|
118 /** |
|
119 * Sets the "q"-parameter value in the "Contact" header |
|
120 * @pre Star() == EFalse |
|
121 * @param aQValue a "q"-parameter value to set |
|
122 */ |
|
123 IMPORT_C void SetQParameterL(TReal aQValue); |
|
124 |
|
125 /** |
|
126 * Gets the name-address as const |
|
127 * @return name-address or 0 if not present |
|
128 * The ownership is NOT transferred. |
|
129 */ |
|
130 IMPORT_C const CSIPAddress* SIPAddress() const; |
|
131 |
|
132 /** |
|
133 * Gets the name-address |
|
134 * @return name-address or 0 if not present |
|
135 * The ownership is NOT transferred. |
|
136 */ |
|
137 IMPORT_C CSIPAddress* SIPAddress(); |
|
138 |
|
139 /** |
|
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 |
|
144 */ |
|
145 IMPORT_C void SetSIPAddressL(CSIPAddress* aSIPAddress); |
|
146 |
|
147 /** |
|
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 |
|
152 */ |
|
153 IMPORT_C static CSIPHeaderBase* |
|
154 InternalizeValueL(RReadStream& aReadStream); |
|
155 |
|
156 public: // From CSIPHeaderBase |
|
157 |
|
158 /** |
|
159 * From CSIPHeaderBase CloneL |
|
160 */ |
|
161 IMPORT_C CSIPHeaderBase* CloneL() const; |
|
162 |
|
163 /** |
|
164 * From CSIPHeaderBase Name |
|
165 */ |
|
166 IMPORT_C RStringF Name() const; |
|
167 |
|
168 public: //New Function |
|
169 |
|
170 /** |
|
171 * Removes the "expires"-parameter |
|
172 */ |
|
173 IMPORT_C void RemoveExpiresParam(); |
|
174 |
|
175 |
|
176 public: // From CSIPHeaderBase, for internal use |
|
177 |
|
178 /** |
|
179 * @internalComponent |
|
180 */ |
|
181 TBool MoreThanOneAllowed() const; |
|
182 |
|
183 /** |
|
184 * @internalComponent |
|
185 */ |
|
186 TBool HasCompactName() const; |
|
187 |
|
188 /** |
|
189 * @internalComponent |
|
190 */ |
|
191 RStringF CompactName() const; |
|
192 |
|
193 /** |
|
194 * @internalComponent |
|
195 */ |
|
196 TPreferredPlace PreferredPlaceInMessage() const; |
|
197 |
|
198 public: // New functions, for internal use |
|
199 |
|
200 static RPointerArray<CSIPHeaderBase> BaseDecodeL(const TDesC8& aValue); |
|
201 |
|
202 private: // From CSIPHeaderBase |
|
203 |
|
204 void ExternalizeValueL(RWriteStream& aWriteStream) const; |
|
205 |
|
206 private: // From CSIPParameterHeaderBase |
|
207 |
|
208 TBool ParamInsertionAllowed() const; |
|
209 HBufC8* ToTextMandatoryPartLC() const; |
|
210 void ParseMandatoryPartL(const TDesC8& aMandatoryPart); |
|
211 const CSIPParamContainerBase& Params() const; |
|
212 CSIPParamContainerBase& Params(); |
|
213 |
|
214 private: // Constructors |
|
215 |
|
216 CSIPContactHeader(TBool aIsStar=EFalse); |
|
217 void ConstructL(); |
|
218 void ConstructL(CSIPAddress* aSIPAddress); |
|
219 void ConstructL(const CSIPContactHeader& aContactHeader); |
|
220 |
|
221 private: // New functions |
|
222 |
|
223 void DoInternalizeValueL(RReadStream& aReadStream); |
|
224 |
|
225 private: // Data |
|
226 |
|
227 CSIPAddress* iSIPAddress; |
|
228 CSIPContactHeaderParams* iParams; |
|
229 TBool iIsStar; |
|
230 |
|
231 private: // For testing purposes |
|
232 #ifdef CPPUNIT_TEST |
|
233 friend class CSIPContactHeaderTest; |
|
234 #endif |
|
235 }; |
|
236 |
|
237 #endif // CSIPCONTACTHEADER_H |
|
238 |
|
239 // End of File |