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