|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Utility class to add sip headers. This class will just have |
|
15 * static utility functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "musavasipheaderutil.h" |
|
21 #include "muscleanupresetanddestroy.h" |
|
22 #include <escapeutils.h> |
|
23 #include <sipconnection.h> |
|
24 #include <sipprofile.h> |
|
25 #include <sipclienttransaction.h> |
|
26 #include <sipmessageelements.h> |
|
27 #include <siprequestelements.h> |
|
28 #include <sipextensionheader.h> |
|
29 #include <sipacceptcontactheader.h> |
|
30 #include <sipcontactheader.h> |
|
31 #include <sipstrings.h> |
|
32 #include <sipstrconsts.h> |
|
33 #include <sipresponseelements.h> |
|
34 #include <sipacceptencodingheader.h> |
|
35 #include <sipacceptlanguageheader.h> |
|
36 #include <sipcontenttypeheader.h> |
|
37 #include <sipunsupportedheader.h> |
|
38 #include <sdpdocument.h> |
|
39 #include "sipextensionheader.h" |
|
40 #include <sdporiginfield.h> |
|
41 #include <sdpconnectionfield.h> |
|
42 #include <sdpattributefield.h> |
|
43 #include <sdpmediafield.h> |
|
44 #include <sipacceptheader.h> |
|
45 #include <sipaddress.h> |
|
46 #include <sdpcodecstringpool.h> |
|
47 |
|
48 #include "muslogger.h" |
|
49 |
|
50 // -------------------------------------------------------------------------- |
|
51 // CMusAvaSipheaderUtil::AddAcceptContactHeaderL |
|
52 // -------------------------------------------------------------------------- |
|
53 // |
|
54 void CMusAvaSipheaderUtil::AddAcceptContactHeaderL( |
|
55 RPointerArray<CSIPHeaderBase>& aRequestHeaders, |
|
56 const RStringF& aFeatureTag ) |
|
57 { |
|
58 MUS_LOG("mus: [MUSAVA] -> CMusAvaSipheaderUtil::AddAcceptContactHeaderL" ) |
|
59 CSIPAcceptContactHeader* header = CSIPAcceptContactHeader::NewLC(); |
|
60 header->SetParamL( aFeatureTag ); |
|
61 header->SetParamL( SIPStrings::StringF( SipStrConsts::EExplicit ) ); |
|
62 aRequestHeaders.AppendL( header ); // ownership transferred. |
|
63 CleanupStack::Pop( header ); |
|
64 MUS_LOG("mus: [MUSAVA] <- CMusAvaSipheaderUtil::AddAcceptContactHeaderL" ) |
|
65 } |
|
66 |
|
67 |
|
68 // -------------------------------------------------------------------------- |
|
69 // CMusAvaSipheaderUtil::AddAcceptEncodingHeaderL |
|
70 // -------------------------------------------------------------------------- |
|
71 // |
|
72 void CMusAvaSipheaderUtil::AddAcceptEncodingHeaderL( |
|
73 RPointerArray<CSIPHeaderBase>& aRequestHeaders ) |
|
74 { |
|
75 MUS_LOG("mus: [MUSAVA] -> CMusAvaSipheaderUtil::AddAcceptEncodingHeaderL" ) |
|
76 _LIT8(KHeader,"gzip"); |
|
77 RPointerArray<CSIPAcceptEncodingHeader> |
|
78 headers(CSIPAcceptEncodingHeader::DecodeL(KHeader)); |
|
79 MusCleanupResetAndDestroyPushL(headers); |
|
80 |
|
81 TInt count = headers.Count(); |
|
82 CSIPHeaderBase* header = NULL;; |
|
83 TInt status = NULL; |
|
84 |
|
85 for (TInt i=0; i < count; i++) |
|
86 { |
|
87 header = headers[i]; |
|
88 status = aRequestHeaders.Append(header); |
|
89 if ( status != KErrNone ) |
|
90 { |
|
91 header = NULL; |
|
92 } |
|
93 else |
|
94 { |
|
95 headers.Remove( i ); |
|
96 } |
|
97 } |
|
98 CleanupStack::PopAndDestroy( &headers ); |
|
99 MUS_LOG("mus: [MUSAVA] <- CMusAvaSipheaderUtil::AddAcceptEncodingHeaderL" ) |
|
100 } |
|
101 |
|
102 |
|
103 // -------------------------------------------------------------------------- |
|
104 // CMusAvaSipheaderUtil::AddAcceptLanguageHeaderL |
|
105 // -------------------------------------------------------------------------- |
|
106 // |
|
107 void CMusAvaSipheaderUtil::AddAcceptLanguageHeaderL( |
|
108 RPointerArray<CSIPHeaderBase>& aRequestHeaders ) |
|
109 { |
|
110 MUS_LOG("mus: [MUSAVA] -> CMusAvaSipheaderUtil::AddAcceptLanguageHeaderL" ) |
|
111 _LIT8(KHeader,"en"); |
|
112 RPointerArray<CSIPAcceptLanguageHeader> |
|
113 headers(CSIPAcceptLanguageHeader::DecodeL(KHeader)); |
|
114 MusCleanupResetAndDestroyPushL(headers); |
|
115 |
|
116 TInt count = headers.Count(); |
|
117 CSIPHeaderBase* header = NULL;; |
|
118 TInt status = NULL; |
|
119 |
|
120 for (TInt i=0; i < count; i++) |
|
121 { |
|
122 header = headers[i]; |
|
123 status = aRequestHeaders.Append(header); |
|
124 if ( status != KErrNone ) |
|
125 { |
|
126 header = NULL; |
|
127 } |
|
128 else |
|
129 { |
|
130 headers.Remove( i ); |
|
131 } |
|
132 } |
|
133 CleanupStack::PopAndDestroy( &headers ); |
|
134 MUS_LOG("mus: [MUSAVA] <- CMusAvaSipheaderUtil::AddAcceptLanguageHeaderL" ) |
|
135 } |
|
136 |
|
137 // -------------------------------------------------------------------------- |
|
138 // CMusAvaSipheaderUtil::AddSdpL |
|
139 // -------------------------------------------------------------------------- |
|
140 // |
|
141 void CMusAvaSipheaderUtil::AddSdpL( CSIPRequestElements* aRequest, |
|
142 HBufC8* aContent ) |
|
143 { |
|
144 MUS_LOG("mus: [MUSAVA] -> CMusAvaSipheaderUtil::AddSdpL" ) |
|
145 _LIT8(contentType,"application/sdp"); |
|
146 CSIPContentTypeHeader* type = CSIPContentTypeHeader::DecodeL( |
|
147 contentType); |
|
148 CleanupStack::PushL( type ); |
|
149 CSIPMessageElements& messageElements = aRequest->MessageElements(); |
|
150 messageElements.SetContentL(aContent,type); |
|
151 CleanupStack::Pop( type );//Ownership transferred |
|
152 MUS_LOG( "mus: [MUSAVA] <- CMusAvaSipheaderUtil::AddSdpL" ) |
|
153 } |
|
154 |
|
155 // -------------------------------------------------------------------------- |
|
156 // CMusAvaSipheaderUtil::AddPreferredIdentityHeaderL |
|
157 // -------------------------------------------------------------------------- |
|
158 // |
|
159 void CMusAvaSipheaderUtil::AddPreferredIdentityHeaderL( |
|
160 RPointerArray<CSIPHeaderBase>& aRequestHeaders, |
|
161 const TDesC8& aVal ) |
|
162 { |
|
163 MUS_LOG_TDESC8( " mus: [MUSAVA] -> CMusAvaSipheaderUtil::\ |
|
164 AddPreferredIdentityHeaderL", aVal); |
|
165 _LIT8(KHeader,"P-Preferred-Identity"); |
|
166 CSIPExtensionHeader* header = CSIPExtensionHeader::NewLC( |
|
167 KHeader,aVal) ; |
|
168 aRequestHeaders.AppendL( header ); |
|
169 CleanupStack::Pop( header );//Ownership transferred. |
|
170 MUS_LOG("mus: [MUSAVA] <- CMusAvaSipheaderUtil::AddPreferredIdentityHeaderL") |
|
171 } |
|
172 |
|
173 // ---------------------------------------------------------------------------- |
|
174 // MusAvaCapabilityContext::LocalHostL |
|
175 // ---------------------------------------------------------------------------- |
|
176 // |
|
177 void CMusAvaSipheaderUtil::LocalHostL(const CSIPConnection& aConn, |
|
178 TPtrC8& aLocalHost) |
|
179 { |
|
180 MUS_LOG( "mus: [MUSAVA] -> CMusAvaSipheaderUtil::LocalHostL" ) |
|
181 RStringPool strPool = SdpCodecStringPool::StringPoolL(); |
|
182 TInetAddr aAddr(0); |
|
183 aConn.GetLocalAddrL(aAddr); |
|
184 TBuf<50> ipAddress; |
|
185 aAddr.Output(ipAddress); |
|
186 MUS_LOG_TDESC( "mus: [MUSAVA] ipAddress",ipAddress ) |
|
187 HBufC8 * ipaddr8=HBufC8::NewLC(ipAddress.Length()); |
|
188 ipaddr8->Des().Copy(ipAddress); |
|
189 aLocalHost.Set( *ipaddr8 ); |
|
190 CleanupStack::PopAndDestroy(1);//ipaddr8 |
|
191 MUS_LOG( "mus: [MUSAVA] <- CMusAvaSipheaderUtil::LocalHostL" ) |
|
192 } |
|
193 |
|
194 |
|
195 // -------------------------------------------------------------------------- |
|
196 // CMusAvaSipheaderUtil::AddAcceptSdpHeaderL |
|
197 // -------------------------------------------------------------------------- |
|
198 // |
|
199 void CMusAvaSipheaderUtil::AddAcceptSdpHeaderL( |
|
200 RPointerArray<CSIPHeaderBase>& aRequestHeaders ) |
|
201 { |
|
202 MUS_LOG("mus: [MUSAVA] -> CMusAvaSipheaderUtil::AddAcceptSDPHeaderL" ) |
|
203 _LIT8(KHeader,"application/sdp"); |
|
204 RPointerArray<CSIPAcceptHeader> headers(CSIPAcceptHeader::DecodeL(KHeader)); |
|
205 MusCleanupResetAndDestroyPushL(headers); |
|
206 |
|
207 TInt count = headers.Count(); |
|
208 CSIPHeaderBase* header = NULL;; |
|
209 TInt status = NULL; |
|
210 |
|
211 for (TInt i=0; i < count; i++) |
|
212 { |
|
213 header = headers[i]; |
|
214 status = aRequestHeaders.Append(header); |
|
215 if ( status != KErrNone ) |
|
216 { |
|
217 header = NULL; |
|
218 } |
|
219 else |
|
220 { |
|
221 headers.Remove( i ); |
|
222 } |
|
223 } |
|
224 CleanupStack::PopAndDestroy( &headers ); |
|
225 MUS_LOG( |
|
226 "mus: [MUSAVA] <- CMusAvaSipheaderUtil::AddAcceptSDPHeaderL" ) |
|
227 } |
|
228 |
|
229 |
|
230 |
|
231 |