|
1 /* |
|
2 * Copyright (c) 2005-2006 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: The Mus ECOM interface implementation of the SIP |
|
15 * stack client. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include "mussipcrplugin.h" |
|
22 #include "muscommon.h" |
|
23 #include "muslogger.h" |
|
24 #include "musmanager.h" |
|
25 #include "musuid.hrh" |
|
26 #include "musunittesting.h" |
|
27 #include "mussettings.h" |
|
28 |
|
29 #include <mussettingskeys.h> |
|
30 #include <sipstrings.h> |
|
31 #include <sipstrconsts.h> |
|
32 #include <sdpdocument.h> |
|
33 #include <sdpmediafield.h> |
|
34 #include <sdpcodecstringpool.h> |
|
35 #include <sdpcodecstringconstants.h> |
|
36 #include <sdpattributefield.h> |
|
37 |
|
38 _LIT8( KSendRecv, "sendrecv"); // For attribute checks |
|
39 _LIT8( KRecvOnly, "recvonly"); // For attribute checks |
|
40 _LIT8( KSendOnly, "sendonly" ); // For attribute checks |
|
41 |
|
42 _LIT8(KCapabilities, |
|
43 "<SIP_CLIENT ALLOW_STARTING=\"YES\">\ |
|
44 <SIP_HEADERS>\ |
|
45 <ACCEPT value=\"application/sdp\"/>\ |
|
46 <ACCEPT_CONTACT value=\"*;+g.3gpp.cs-voice\"/>\ |
|
47 </SIP_HEADERS>\ |
|
48 <SDP_LINES>\ |
|
49 <LINE name=\"m\" value=\"video 0 RTP/AVP 96\">\ |
|
50 <MEDIA_ATTRIBUTE value=\"application:com.nokia.rtvs\"/>\ |
|
51 <MEDIA_ATTRIBUTE value=\"X-application:com.nokia.rtvs\"/>\ |
|
52 </LINE>\ |
|
53 <LINE name=\"m\" value=\"audio 0 RTP/AVP 97\">\ |
|
54 </LINE>\ |
|
55 </SDP_LINES>\ |
|
56 </SIP_CLIENT>"); |
|
57 |
|
58 |
|
59 // ------------------------------------------------------------------------- |
|
60 // Two-phased constructor. |
|
61 // ------------------------------------------------------------------------- |
|
62 // |
|
63 CMusSipCrPlugin* CMusSipCrPlugin::NewL() |
|
64 { |
|
65 MUS_LOG( "mus: [MUSSCR] -> CMusSipCrPlugin::NewL()" ); |
|
66 CMusSipCrPlugin* self = new(ELeave) CMusSipCrPlugin; |
|
67 CleanupStack::PushL( self ); |
|
68 self->ConstructL(); |
|
69 CleanupStack::Pop( self ); |
|
70 MUS_LOG( "mus: [MUSSCR] <- CMusSipCrPlugin::NewL()" ); |
|
71 return self; |
|
72 } |
|
73 |
|
74 |
|
75 // ------------------------------------------------------------------------- |
|
76 // C++ destructor. |
|
77 // ------------------------------------------------------------------------- |
|
78 // |
|
79 CMusSipCrPlugin::~CMusSipCrPlugin() |
|
80 { |
|
81 MUS_LOG( "mus: [MUSSCR] -> CMusSipCrPlugin::~CMusSipCrPlugin()" ); |
|
82 delete iManager; |
|
83 if ( iCloseStringPool ) |
|
84 { |
|
85 SdpCodecStringPool::Close(); |
|
86 } |
|
87 MUS_LOG( "mus: [MUSSCR] <- CMusSipCrPlugin::~CMusSipCrPlugin()" ); |
|
88 } |
|
89 |
|
90 |
|
91 // ------------------------------------------------------------------------- |
|
92 // C++ constructor. |
|
93 // ------------------------------------------------------------------------- |
|
94 // |
|
95 CMusSipCrPlugin::CMusSipCrPlugin() |
|
96 { |
|
97 } |
|
98 |
|
99 |
|
100 // ------------------------------------------------------------------------- |
|
101 // Symbian second-phase constructor. |
|
102 // ------------------------------------------------------------------------- |
|
103 // |
|
104 void CMusSipCrPlugin::ConstructL() |
|
105 { |
|
106 MUS_LOG( "mus: [MUSSCR] -> CMusSipCrPlugin::ConstructL()" ); |
|
107 iManager = CMusManager::NewL(); |
|
108 |
|
109 TRAPD( err, SdpCodecStringPool::OpenL() ); |
|
110 |
|
111 switch ( err ) |
|
112 { |
|
113 case KErrNone: |
|
114 { |
|
115 //close pool at destructor, not opened by others |
|
116 iCloseStringPool = ETrue; |
|
117 break; |
|
118 } |
|
119 |
|
120 case KErrAlreadyExists: |
|
121 { |
|
122 //already opened, do not try to close at destructor |
|
123 iCloseStringPool = EFalse; |
|
124 break; |
|
125 } |
|
126 |
|
127 default: |
|
128 { |
|
129 User::Leave( err ); |
|
130 } |
|
131 } |
|
132 |
|
133 MUS_LOG( "mus: [MUSSCR] <- CMusSipCrPlugin::ConstructL()" ); |
|
134 } |
|
135 |
|
136 |
|
137 // ------------------------------------------------------------------------- |
|
138 // CMusSipCrPlugin::ChannelL |
|
139 // ------------------------------------------------------------------------- |
|
140 // |
|
141 TUid CMusSipCrPlugin::ChannelL( RStringF aMethod, |
|
142 const TDesC8& /*aRequestUri*/, |
|
143 const RPointerArray<CSIPHeaderBase>& /*aHeaders*/, |
|
144 const TDesC8& aContent, |
|
145 const CSIPContentTypeHeader* /*aContentType*/ ) |
|
146 { |
|
147 MUS_LOG( "mus: [MUSSCR] -> CMusSipCrPlugin::ChannelL()" ); |
|
148 |
|
149 if ( aMethod == SIPStrings::StringF( SipStrConsts::EOptions ) ) |
|
150 { |
|
151 TUid uid; |
|
152 uid.iUid = ( TInt ) CMusManager::ESipOptions; |
|
153 MUS_LOG1( "mus: [MUSSCR] <- CMusSipCrPlugin::ChannelL(): KSipOptions %d", |
|
154 uid.iUid ); |
|
155 return uid; |
|
156 } |
|
157 else |
|
158 { |
|
159 MultimediaSharing::TMusAvailabilityStatus capability |
|
160 = iManager->AvailabilityL(); |
|
161 |
|
162 if( capability < KErrNone || |
|
163 capability >= MultimediaSharing::EErrServerShutDown ) |
|
164 { |
|
165 TUid uid; |
|
166 uid.iUid = ( TInt ) CMusManager::ESipInviteNotDesired; |
|
167 MUS_LOG1( "mus: [MUSSCR] <- CMusSipCrPlugin::ChannelL(): \ |
|
168 KNotAllowedSipInvite %d", uid.iUid ); |
|
169 return uid; |
|
170 } |
|
171 else |
|
172 { |
|
173 TUid uid; |
|
174 uid.iUid = ( TInt ) CMusManager::ESipInviteDesired; |
|
175 TBool twoWaySupported = MultimediaSharingSettings::VideoDirectionL() == |
|
176 MusSettingsKeys::ETwoWayVideo; |
|
177 |
|
178 if ( ( aContent.Length() > 0 ) && twoWaySupported ) |
|
179 { |
|
180 MUS_LOG( "mus: [MUSSCR] 2 way supported, parsing SDP..." ); |
|
181 CSdpDocument* sdpDocument = CSdpDocument::DecodeLC( aContent ); |
|
182 TBool sendRecv = CheckForSendRecvAttributeL( sdpDocument->MediaFields() ); |
|
183 if ( sendRecv ) |
|
184 { |
|
185 uid.iUid = ( TInt ) CMusManager::ESipInviteDesired2WayVideo; |
|
186 } |
|
187 |
|
188 CleanupStack::PopAndDestroy( sdpDocument ); |
|
189 } |
|
190 |
|
191 MUS_LOG1( "mus: [MUSSCR] <- CMusSipCrPlugin::ChannelL(): \ |
|
192 KAllowedSipInvite %d", uid.iUid ); |
|
193 return uid; |
|
194 } |
|
195 } |
|
196 } |
|
197 |
|
198 // ------------------------------------------------------------------------- |
|
199 // CMusSipCrPlugin::CheckForSendRecvAttribute |
|
200 // ------------------------------------------------------------------------- |
|
201 // |
|
202 TBool CMusSipCrPlugin::CheckForSendRecvAttributeL( |
|
203 RPointerArray<CSdpMediaField>& aFields ) const |
|
204 { |
|
205 MUS_LOG( "mus: [MUSSCR] -> CMusSipCrPlugin::CheckForSendRecvAttribute()" ); |
|
206 |
|
207 TBool sendRecv = EFalse; |
|
208 TBool sendAttrFound = EFalse; |
|
209 TBool videoFound = EFalse; |
|
210 RStringF videoType = SdpCodecStringPool::StringPoolL().StringF( |
|
211 SdpCodecStringConstants::EMediaVideo, |
|
212 SdpCodecStringPool::StringTableL() ); |
|
213 const TInt fieldcount = aFields.Count(); |
|
214 |
|
215 for ( TInt i = 0; i < fieldcount && !videoFound; i++ ) |
|
216 { |
|
217 CSdpMediaField* mField = aFields[i]; |
|
218 |
|
219 //only check video fields |
|
220 videoFound = mField->Media() == videoType; |
|
221 |
|
222 if ( videoFound ) |
|
223 { |
|
224 RPointerArray< CSdpAttributeField > attrList = |
|
225 mField->AttributeFields(); |
|
226 |
|
227 TInt attrCount = attrList.Count(); |
|
228 for (TInt j = 0; j < attrCount && !sendAttrFound; j++ ) |
|
229 { |
|
230 CSdpAttributeField* attributeField = attrList[j]; |
|
231 RStringF attribute = attributeField->Attribute(); |
|
232 |
|
233 if ( KErrNotFound != attribute.DesC().FindF( KSendRecv ) ) |
|
234 { |
|
235 sendRecv = ETrue; |
|
236 sendAttrFound = ETrue; |
|
237 MUS_LOG( "mus: [MUSSCR] <sendrecv> attribute found!" ); |
|
238 } |
|
239 else if ( ( KErrNotFound != attribute.DesC().FindF( KSendOnly ) ) || |
|
240 ( KErrNotFound != attribute.DesC().FindF( KRecvOnly ) ) ) |
|
241 { |
|
242 MUS_LOG( "mus: [MUSSCR] <sendonly>/<recvonly> attribute found!" ); |
|
243 sendAttrFound = ETrue; |
|
244 } |
|
245 } |
|
246 |
|
247 if ( !sendAttrFound ) |
|
248 { |
|
249 MUS_LOG( "mus: [MUSSCR] no send/recv related attributes found!" ); |
|
250 sendRecv = ETrue; |
|
251 } |
|
252 } |
|
253 } |
|
254 MUS_LOG1( "mus: [MUSSCR] <- CMusSipCrPlugin::CheckForSendRecvAttribute(), \ |
|
255 sendrecv: %d", sendRecv ); |
|
256 |
|
257 return sendRecv; |
|
258 } |
|
259 |
|
260 // ------------------------------------------------------------------------- |
|
261 // CMusSipCrPlugin::ConnectL |
|
262 // ------------------------------------------------------------------------- |
|
263 // |
|
264 void CMusSipCrPlugin::ConnectL( TUid aUid ) |
|
265 { |
|
266 MUS_LOG1( "mus: [MUSSCR] -> CMusSipCrPlugin::ConnectL( %d )", aUid.iUid ); |
|
267 if ( aUid.iUid == CMusManager::ESipOptions || |
|
268 aUid.iUid == CMusManager::ESipInviteDesired || |
|
269 aUid.iUid == CMusManager::ESipInviteDesired2WayVideo || |
|
270 aUid.iUid == CMusManager::ESipInviteNotDesired ) |
|
271 { |
|
272 iManager->HandleSipRequestL(( CMusManager::TRequestType ) aUid.iUid ); |
|
273 } |
|
274 else |
|
275 { |
|
276 MUS_LOG( "mus: [MUSSCR] <- CMusSipCrPlugin::ChannelL()\ |
|
277 ( User::Leave KErrNotSupported )" ); |
|
278 User::Leave( KErrNotSupported ); |
|
279 } |
|
280 MUS_LOG( "mus: [MUSSCR] <- CMusSipCrPlugin::ConnectL()" ); |
|
281 } |
|
282 |
|
283 |
|
284 // ------------------------------------------------------------------------- |
|
285 // CMusSipCrPlugin::Capabilities() |
|
286 // ------------------------------------------------------------------------- |
|
287 // |
|
288 const TDesC8& CMusSipCrPlugin::Capabilities() |
|
289 { |
|
290 MUS_LOG( "mus: [MUSSCR] -> CMusSipCrPlugin::Capabilities()" ); |
|
291 MUS_LOG( "mus: [MUSSCR] <- CMusSipCrPlugin::Capabilities()" ); |
|
292 return KCapabilities; |
|
293 } |
|
294 |
|
295 |
|
296 |
|
297 |