|
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: device with extended information - used in AVC server |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 // upnp stack api |
|
25 #include <upnpdlnaprotocolinfo.h> |
|
26 #include <upnpitem.h> |
|
27 |
|
28 // upnpframework / avcontroller helper api |
|
29 #include "upnpitemutility.h" |
|
30 #include "upnpconstantdefs.h" // for upnp-specific stuff |
|
31 |
|
32 // upnpframework / internal api's |
|
33 #include "upnpcommonutils.h" |
|
34 |
|
35 // avcontroller internal |
|
36 #include "upnpavdeviceextended.h" |
|
37 |
|
38 |
|
39 _LIT8( KAudioSupport, "audio/" ); |
|
40 _LIT8( KImageSupport, "image/" ); |
|
41 _LIT8( KVideoSupport, "video/" ); |
|
42 _LIT8( KDlnaPn, "DLNA.ORG_PN" ); |
|
43 |
|
44 |
|
45 const TInt KProtocolInfoDelimeter = 44; |
|
46 const TInt KUnicodeC0RangeStart = 0;// the begin character of C0 range |
|
47 const TInt KUnicodeC0RangeEnd = 32;// the end character of C0 range |
|
48 const TInt KUnicodeC1RangeStart = 127;// the begin character of C1 range |
|
49 const TInt KUnicodeC1RangeEnd = 159;// the end character of C1 range |
|
50 const TInt KSlash = 92; |
|
51 _LIT8( KProtocolInfo, "protocolInfo" ); |
|
52 _LIT8( KAsterisk, "*" ); |
|
53 |
|
54 _LIT( KComponentLogfile, "upnpavcontrollerserver.txt"); |
|
55 #include "upnplog.h" |
|
56 |
|
57 // ============================ MEMBER FUNCTIONS ============================ |
|
58 |
|
59 // -------------------------------------------------------------------------- |
|
60 // CUpnpAVDeviceExtended::NewL |
|
61 // See upnpavdeviceextended.h |
|
62 // -------------------------------------------------------------------------- |
|
63 CUpnpAVDeviceExtended* CUpnpAVDeviceExtended::NewL( |
|
64 const CUpnpAVDevice& aDevice ) |
|
65 { |
|
66 CUpnpAVDeviceExtended* dev = new(ELeave) CUpnpAVDeviceExtended(); |
|
67 CleanupStack::PushL( dev ); |
|
68 |
|
69 dev->iDeviceType = aDevice.DeviceType(); |
|
70 dev->SetFriendlyNameL( aDevice.FriendlyName() ); |
|
71 dev->SetUuidL( aDevice.Uuid() ); |
|
72 dev->iCopyCapability = aDevice.CopyCapability(); |
|
73 dev->iSearchCapability = aDevice.SearchCapability(); |
|
74 dev->iPauseCapability = aDevice.PauseCapability(); |
|
75 dev->iVolumeCapability = aDevice.VolumeCapability(); |
|
76 dev->iMuteCapability = aDevice.MuteCapability(); |
|
77 dev->iAudioMediaCapability = aDevice.AudioCapability(); |
|
78 dev->iImageMediaCapability = aDevice.ImageCapability(); |
|
79 dev->iVideoMediaCapability = aDevice.VideoCapability(); |
|
80 dev->iNextAVTransportUri = aDevice.NextAVTransportUri(); |
|
81 dev->iMaxVolume = aDevice.MaxVolume(); |
|
82 dev->iDlnaCompatible = aDevice.DlnaCompatible(); |
|
83 |
|
84 dev->ConstructL(); |
|
85 CleanupStack::Pop(); |
|
86 return dev; |
|
87 } |
|
88 |
|
89 // -------------------------------------------------------------------------- |
|
90 // CUpnpAVDeviceExtended::NewL |
|
91 // See upnpavdeviceextended.h |
|
92 // -------------------------------------------------------------------------- |
|
93 CUpnpAVDeviceExtended* CUpnpAVDeviceExtended::NewL( |
|
94 const CUpnpAVDeviceExtended& aDevice ) |
|
95 { |
|
96 CUpnpAVDeviceExtended* dev = new(ELeave) CUpnpAVDeviceExtended(); |
|
97 CleanupStack::PushL( dev ); |
|
98 |
|
99 dev->iDeviceType = aDevice.DeviceType(); |
|
100 dev->SetFriendlyNameL( aDevice.FriendlyName() ); |
|
101 dev->SetUuidL( aDevice.Uuid() ); |
|
102 dev->iCopyCapability = aDevice.CopyCapability(); |
|
103 dev->iSearchCapability = aDevice.SearchCapability(); |
|
104 dev->iPauseCapability = aDevice.PauseCapability(); |
|
105 dev->iVolumeCapability = aDevice.VolumeCapability(); |
|
106 dev->iMuteCapability = aDevice.MuteCapability(); |
|
107 dev->iAudioMediaCapability = aDevice.AudioCapability(); |
|
108 dev->iImageMediaCapability = aDevice.ImageCapability(); |
|
109 dev->iVideoMediaCapability = aDevice.VideoCapability(); |
|
110 dev->iNextAVTransportUri = aDevice.NextAVTransportUri(); |
|
111 dev->iMaxVolume = aDevice.MaxVolume(); |
|
112 dev->iDlnaCompatible = aDevice.DlnaCompatible(); |
|
113 |
|
114 dev->SetSinkProtocolInfoL( aDevice.SinkProtocolInfo() ); |
|
115 dev->SetSourceProtocolInfoL( aDevice.SourceProtocolInfo() ); |
|
116 dev->iSubscriptionCount = aDevice.SubscriptionCount(); |
|
117 dev->iLocal = aDevice.Local(); |
|
118 dev->iAudioUpload = aDevice.AudioUpload(); |
|
119 dev->iImageUpload = aDevice.ImageUpload(); |
|
120 dev->iVideoUpload = aDevice.VideoUpload(); |
|
121 dev->iCreateChildContainer = aDevice.CreateChildContainer(); |
|
122 dev->iDestroyObject = aDevice.DestroyObject(); |
|
123 dev->iPInfoReceived = aDevice.PInfoReceived(); |
|
124 dev->iDLNADeviceType = aDevice.DLNADeviceType(); |
|
125 |
|
126 dev->ConstructL(); |
|
127 CleanupStack::Pop(); |
|
128 return dev; |
|
129 } |
|
130 |
|
131 // -------------------------------------------------------------------------- |
|
132 // CUpnpAVDeviceExtended::NewL |
|
133 // See upnpavdeviceextended.h |
|
134 // -------------------------------------------------------------------------- |
|
135 CUpnpAVDeviceExtended* CUpnpAVDeviceExtended::NewL() |
|
136 { |
|
137 CUpnpAVDeviceExtended* dev = new(ELeave) CUpnpAVDeviceExtended(); |
|
138 CleanupStack::PushL( dev ); |
|
139 dev->ConstructL(); |
|
140 CleanupStack::Pop(); |
|
141 return dev; |
|
142 } |
|
143 |
|
144 // -------------------------------------------------------------------------- |
|
145 // CUpnpAVDeviceExtended::~CUpnpAVDeviceExtended |
|
146 // See upnpavdeviceextended.h |
|
147 // -------------------------------------------------------------------------- |
|
148 CUpnpAVDeviceExtended::~CUpnpAVDeviceExtended() |
|
149 { |
|
150 iSinkProtocolInfo.ResetAndDestroy(); |
|
151 iSourceProtocolInfo.ResetAndDestroy(); |
|
152 } |
|
153 |
|
154 |
|
155 // -------------------------------------------------------------------------- |
|
156 // CUpnpAVDeviceExtended::CUpnpAVDeviceExtended |
|
157 // See upnpavdeviceextended.h |
|
158 // -------------------------------------------------------------------------- |
|
159 CUpnpAVDeviceExtended::CUpnpAVDeviceExtended() : |
|
160 CUpnpAVDevice() |
|
161 { |
|
162 } |
|
163 |
|
164 // -------------------------------------------------------------------------- |
|
165 // CUpnpAVDeviceExtended::IncreaseSubscriptionCount |
|
166 // See upnpavdeviceextended.h |
|
167 // -------------------------------------------------------------------------- |
|
168 TInt CUpnpAVDeviceExtended::IncreaseSubscriptionCount() |
|
169 { |
|
170 return ++iSubscriptionCount; |
|
171 } |
|
172 |
|
173 // -------------------------------------------------------------------------- |
|
174 // CUpnpAVDeviceExtended::DecreaseSubscriptionCount |
|
175 // See upnpavdeviceextended.h |
|
176 // -------------------------------------------------------------------------- |
|
177 TInt CUpnpAVDeviceExtended::DecreaseSubscriptionCount() |
|
178 { |
|
179 iSubscriptionCount--; |
|
180 if( iSubscriptionCount < 0 ) |
|
181 { |
|
182 iSubscriptionCount = 0; |
|
183 } |
|
184 return iSubscriptionCount; |
|
185 } |
|
186 |
|
187 // -------------------------------------------------------------------------- |
|
188 // CUpnpAVDeviceExtended::SubscriptionCount |
|
189 // See upnpavdeviceextended.h |
|
190 // -------------------------------------------------------------------------- |
|
191 TInt CUpnpAVDeviceExtended::SubscriptionCount() const |
|
192 { |
|
193 return iSubscriptionCount; |
|
194 } |
|
195 |
|
196 // -------------------------------------------------------------------------- |
|
197 // CUpnpAVDeviceExtended::ConstructL |
|
198 // See upnpavdeviceextended.h |
|
199 // -------------------------------------------------------------------------- |
|
200 void CUpnpAVDeviceExtended::ConstructL() |
|
201 { |
|
202 } |
|
203 |
|
204 // -------------------------------------------------------------------------- |
|
205 // CUpnpAVDeviceExtended::SetSinkProtocolInfoL |
|
206 // See upnpavdeviceextended.h |
|
207 // -------------------------------------------------------------------------- |
|
208 void CUpnpAVDeviceExtended::SetSinkProtocolInfoL( |
|
209 const TDesC8& aProtocolInfo ) |
|
210 { |
|
211 __LOG( "CUpnpAVDeviceExtended::SetSinkProtocolInfoL" ); |
|
212 HBufC8* buffer = RemoveIllegalCharactersL( aProtocolInfo ); |
|
213 if( buffer ) |
|
214 { |
|
215 CleanupStack::PushL( buffer ); |
|
216 TLex8 input( *buffer ); |
|
217 |
|
218 while( !input.Eos() ) |
|
219 { |
|
220 ParseToDelimeter( input, TChar( KProtocolInfoDelimeter ) ); |
|
221 CUpnpDlnaProtocolInfo* tmpInfo = NULL; |
|
222 TRAPD( err, tmpInfo = CUpnpDlnaProtocolInfo::NewL( |
|
223 input.MarkedToken() ) ); |
|
224 |
|
225 if( err == KErrNone && tmpInfo ) |
|
226 { |
|
227 // Transfer ownership of tmpInfo |
|
228 iSinkProtocolInfo.Append( tmpInfo ); |
|
229 } |
|
230 else |
|
231 { |
|
232 __LOG1( "CUpnpDlnaProtocolInfo::NewL failed: %d", err ); |
|
233 } |
|
234 |
|
235 if( !input.Eos() ) |
|
236 { |
|
237 input.SkipAndMark( 1 ); // Skip the delimeter |
|
238 } |
|
239 } |
|
240 CleanupStack::PopAndDestroy( buffer ); |
|
241 } |
|
242 __LOG( "CUpnpAVDeviceExtended::SetSinkProtocolInfoL end" ); |
|
243 } |
|
244 |
|
245 // -------------------------------------------------------------------------- |
|
246 // CUpnpAVDeviceExtended::SinkProtocolInfo |
|
247 // See upnpavdeviceextended.h |
|
248 // -------------------------------------------------------------------------- |
|
249 const RPointerArray<CUpnpDlnaProtocolInfo>& |
|
250 CUpnpAVDeviceExtended::SinkProtocolInfo() const |
|
251 { |
|
252 return iSinkProtocolInfo; |
|
253 } |
|
254 |
|
255 // -------------------------------------------------------------------------- |
|
256 // CUpnpAVDeviceExtended::SetSourceProtocolInfoL |
|
257 // See upnpavdeviceextended.h |
|
258 // -------------------------------------------------------------------------- |
|
259 void CUpnpAVDeviceExtended::SetSourceProtocolInfoL( |
|
260 const TDesC8& aProtocolInfo ) |
|
261 { |
|
262 __LOG( "CUpnpAVDeviceExtended::SetSourceProtocolInfoL" ); |
|
263 HBufC8* buffer = RemoveIllegalCharactersL( aProtocolInfo ); |
|
264 if( buffer ) |
|
265 { |
|
266 CleanupStack::PushL( buffer ); |
|
267 TLex8 input( *buffer ); |
|
268 |
|
269 while( !input.Eos() ) |
|
270 { |
|
271 ParseToDelimeter( input, TChar( KProtocolInfoDelimeter ) ); |
|
272 CUpnpDlnaProtocolInfo* tmpInfo = NULL; |
|
273 TRAPD( err, tmpInfo = CUpnpDlnaProtocolInfo::NewL( |
|
274 input.MarkedToken() ) ); |
|
275 |
|
276 if( err == KErrNone && tmpInfo ) |
|
277 { |
|
278 // Transfer ownership of tmpInfo |
|
279 iSourceProtocolInfo.Append( tmpInfo ); |
|
280 } |
|
281 else |
|
282 { |
|
283 __LOG1( "CUpnpDlnaProtocolInfo::NewL failed: %d", err ); |
|
284 } |
|
285 |
|
286 if( !input.Eos() ) |
|
287 { |
|
288 input.SkipAndMark( 1 ); // Skip the delimeter |
|
289 } |
|
290 } |
|
291 CleanupStack::PopAndDestroy( buffer ); |
|
292 } |
|
293 __LOG( "CUpnpAVDeviceExtended::SetSourceProtocolInfoL end" ); |
|
294 } |
|
295 // -------------------------------------------------------------------------- |
|
296 // CUpnpAVDeviceExtended::SourceProtocolInfo |
|
297 // See upnpavdeviceextended.h |
|
298 // -------------------------------------------------------------------------- |
|
299 const RPointerArray<CUpnpDlnaProtocolInfo>& |
|
300 CUpnpAVDeviceExtended::SourceProtocolInfo() const |
|
301 { |
|
302 return iSourceProtocolInfo; |
|
303 } |
|
304 |
|
305 // -------------------------------------------------------------------------- |
|
306 // CUpnpAVDeviceExtended::SetLocal |
|
307 // See upnpavdeviceextended.h |
|
308 // -------------------------------------------------------------------------- |
|
309 void CUpnpAVDeviceExtended::SetLocal( TBool aLocal ) |
|
310 { |
|
311 iLocal = aLocal; |
|
312 } |
|
313 |
|
314 // -------------------------------------------------------------------------- |
|
315 // CUpnpAVDeviceExtended::Local |
|
316 // See upnpavdeviceextended.h |
|
317 // -------------------------------------------------------------------------- |
|
318 TBool CUpnpAVDeviceExtended::Local() const |
|
319 { |
|
320 return iLocal; |
|
321 } |
|
322 |
|
323 // -------------------------------------------------------------------------- |
|
324 // CUpnpAVDeviceExtended::MatchSinkProtocolInfo |
|
325 // See upnpavdeviceextended.h |
|
326 // -------------------------------------------------------------------------- |
|
327 TBool CUpnpAVDeviceExtended::MatchSinkProtocolInfo( |
|
328 const TDesC8& aInfo ) const |
|
329 { |
|
330 __LOG( "CUpnpAVDeviceExtended::MatchSinkProtocolInfo" ); |
|
331 |
|
332 TBool match = EFalse; |
|
333 |
|
334 if( DlnaCompatible() ) |
|
335 { |
|
336 // The device is DLNA compatible |
|
337 |
|
338 // Try try find PN parameter to determine if it's dlna content |
|
339 if( aInfo.Find( KDlnaPn ) != KErrNotFound ) |
|
340 { |
|
341 __LOG( "MatchSinkProtocolInfo - DLNA content and the renderer \ |
|
342 is DLNA compatible, start matching..." ); |
|
343 |
|
344 match = MatchSinkProfileId( aInfo ); |
|
345 } |
|
346 else |
|
347 { |
|
348 __LOG( "MatchSinkProtocolInfo - Non DLNA content and the \ |
|
349 renderer is DLNA compatible, start matching..." ); |
|
350 match = MatchSinkMime( aInfo ); |
|
351 } |
|
352 } |
|
353 else |
|
354 { |
|
355 __LOG( "MatchSinkProtocolInfo - Renderer is not DLNA compatible, \ |
|
356 start matching..." ); |
|
357 match = MatchSinkMime( aInfo ); |
|
358 } |
|
359 |
|
360 return match; |
|
361 } |
|
362 |
|
363 // -------------------------------------------------------------------------- |
|
364 // CUpnpAVDeviceExtended::MatchSourceProtocolInfo |
|
365 // See upnpavdeviceextended.h |
|
366 // -------------------------------------------------------------------------- |
|
367 TBool CUpnpAVDeviceExtended::ValidateTransfer( |
|
368 const TDesC8& aInfo ) const |
|
369 { |
|
370 __LOG( "CUpnpAVDeviceExtended::MatchSourceProtocolInfo" ); |
|
371 |
|
372 // Try try find PN parameter to determine if it's dlna content |
|
373 TBool match = EFalse; |
|
374 if( aInfo.Find( KDlnaPn ) != KErrNotFound ) |
|
375 { |
|
376 match = MatchSourceProfileId( aInfo ); |
|
377 } |
|
378 |
|
379 return match; |
|
380 } |
|
381 |
|
382 // -------------------------------------------------------------------------- |
|
383 // CUpnpAVDeviceExtended::MatchSinkProfileId |
|
384 // See upnpavdeviceextended.h |
|
385 // -------------------------------------------------------------------------- |
|
386 TBool CUpnpAVDeviceExtended::MatchSinkProfileId( |
|
387 const TDesC8& aInfo ) const |
|
388 { |
|
389 __LOG( "CUpnpAVDeviceExtended::MatchSinkProfileId" ); |
|
390 |
|
391 TBool match = EFalse; |
|
392 CUpnpDlnaProtocolInfo* tmpInfo = NULL; |
|
393 TRAPD( err, tmpInfo = CUpnpDlnaProtocolInfo::NewL( aInfo ) ); |
|
394 if ( err == KErrNone ) |
|
395 { |
|
396 // Match the first parameter and PN parameter |
|
397 TInt count = iSinkProtocolInfo.Count(); |
|
398 for( TInt i = 0; i < count; i++ ) |
|
399 { |
|
400 if( iSinkProtocolInfo[ i ]->PnParameter() == |
|
401 tmpInfo->PnParameter() || |
|
402 iSinkProtocolInfo[ i ]->FourthField() == KAsterisk ) |
|
403 { |
|
404 // PN parameter matches, try matching the first |
|
405 // parameter |
|
406 if( iSinkProtocolInfo[ i ]->FirstField() == |
|
407 tmpInfo->FirstField() || |
|
408 iSinkProtocolInfo[ i ]->FirstField() == |
|
409 KAsterisk ) |
|
410 { |
|
411 __LOG( "MatchSinkProfileId - a match" ); |
|
412 |
|
413 // We have a match! |
|
414 i = count; |
|
415 match = ETrue; |
|
416 } |
|
417 } |
|
418 } |
|
419 delete tmpInfo; |
|
420 } |
|
421 return match; |
|
422 } |
|
423 |
|
424 // -------------------------------------------------------------------------- |
|
425 // CUpnpAVDeviceExtended::MatchSourceProfileId |
|
426 // See upnpavdeviceextended.h |
|
427 // -------------------------------------------------------------------------- |
|
428 TBool CUpnpAVDeviceExtended::MatchSourceProfileId( |
|
429 const TDesC8& aInfo ) const |
|
430 { |
|
431 __LOG( "CUpnpAVDeviceExtended::MatchSourceProfileId" ); |
|
432 |
|
433 TBool match = EFalse; |
|
434 CUpnpDlnaProtocolInfo* tmpInfo = NULL; |
|
435 TRAPD( err, tmpInfo = CUpnpDlnaProtocolInfo::NewL( aInfo ) ); |
|
436 if ( err == KErrNone ) |
|
437 { |
|
438 // Match the first parameter and PN parameter |
|
439 TInt count = iSourceProtocolInfo.Count(); |
|
440 for( TInt i = 0; i < count; i++ ) |
|
441 { |
|
442 if( iSourceProtocolInfo[ i ]->PnParameter() == |
|
443 tmpInfo->PnParameter() ) |
|
444 { |
|
445 // PN parameter matches, try matching the first |
|
446 // parameter |
|
447 if( iSourceProtocolInfo[ i ]->FirstField() == |
|
448 tmpInfo->FirstField() || |
|
449 iSourceProtocolInfo[ i ]->FirstField() == |
|
450 KAsterisk ) |
|
451 { |
|
452 __LOG( "MatchSourceProfileId - a match" ); |
|
453 |
|
454 // We have a match! |
|
455 i = count; |
|
456 match = ETrue; |
|
457 } |
|
458 } |
|
459 } |
|
460 delete tmpInfo; |
|
461 } |
|
462 return match; |
|
463 } |
|
464 |
|
465 // -------------------------------------------------------------------------- |
|
466 // CUpnpAVDeviceExtended::MatchSinkMime |
|
467 // See upnpavdeviceextended.h |
|
468 // -------------------------------------------------------------------------- |
|
469 TBool CUpnpAVDeviceExtended::MatchSinkMime( const TDesC8& aInfo ) const |
|
470 { |
|
471 __LOG( "CUpnpAVDeviceExtended::MatchSinkMime" ); |
|
472 |
|
473 TBool match = EFalse; |
|
474 CUpnpDlnaProtocolInfo* tmpInfo = NULL; |
|
475 TRAPD( err, tmpInfo = CUpnpDlnaProtocolInfo::NewL( aInfo ) ); |
|
476 if ( err == KErrNone ) |
|
477 { |
|
478 // Match the first parameter and mime-type |
|
479 TInt count = iSinkProtocolInfo.Count(); |
|
480 for( TInt i = 0; i < count; i++ ) |
|
481 { |
|
482 if( iSinkProtocolInfo[ i ]->ThirdField() == |
|
483 tmpInfo->ThirdField() ) |
|
484 { |
|
485 // Mime-parameter matches, try matching the first |
|
486 // parameter |
|
487 if( iSinkProtocolInfo[ i ]->FirstField() == |
|
488 tmpInfo->FirstField() ) |
|
489 { |
|
490 __LOG( "MatchSinkMime - a match" ); |
|
491 |
|
492 // We have a match! |
|
493 i = count; |
|
494 match = ETrue; |
|
495 } |
|
496 } |
|
497 } |
|
498 delete tmpInfo; |
|
499 } |
|
500 return match; |
|
501 } |
|
502 |
|
503 // -------------------------------------------------------------------------- |
|
504 // CUpnpAVDeviceExtended::FindFirstMatchingInSinkL |
|
505 // See upnpavdeviceextended.h |
|
506 // -------------------------------------------------------------------------- |
|
507 const TDesC8& CUpnpAVDeviceExtended::FindFirstMatchingInSinkL( |
|
508 const CUpnpItem& aItem ) const |
|
509 { |
|
510 __LOG( "CUpnpAVDeviceExtended::FindFirstMatchingInSinkL" ); |
|
511 |
|
512 RUPnPElementsArray array; |
|
513 CleanupClosePushL( array ); |
|
514 |
|
515 UPnPItemUtility::GetResElements( aItem, array ); |
|
516 TBool match = EFalse; |
|
517 TInt i; |
|
518 |
|
519 TInt count = array.Count(); |
|
520 for( i = 0; i < count; i ++ ) |
|
521 { |
|
522 const CUpnpAttribute& protocolInfo = |
|
523 UPnPItemUtility::FindAttributeByNameL( |
|
524 *array[ i ], KProtocolInfo ); |
|
525 |
|
526 if( MatchType( aItem.ObjectClass(), protocolInfo.Value() ) ) |
|
527 { |
|
528 if( MatchSinkProtocolInfo( protocolInfo.Value() ) ) |
|
529 { |
|
530 // We have a match! |
|
531 __LOG( "FindFirstMatchingInSinkL - a match" ); |
|
532 |
|
533 match = ETrue; |
|
534 break; |
|
535 } |
|
536 else |
|
537 { |
|
538 __LOG( "FindFirstMatchingInSinkL - not a match" ); |
|
539 } |
|
540 } |
|
541 else |
|
542 { |
|
543 // Res-elements mime-type does not match to object-class |
|
544 // Ignore |
|
545 __LOG( "FindFirstMatchingInSinkL - Res doesn't match \ |
|
546 to objectclass" ); |
|
547 } |
|
548 } |
|
549 |
|
550 if( !match ) |
|
551 { |
|
552 __LOG( "FindFirstMatchingInSinkL - No match" ); |
|
553 |
|
554 User::Leave( KErrNotSupported ); |
|
555 } |
|
556 |
|
557 const TDesC8& uri = array[ i ]->Value(); |
|
558 |
|
559 CleanupStack::PopAndDestroy( &array ); |
|
560 |
|
561 return uri; |
|
562 } |
|
563 |
|
564 // -------------------------------------------------------------------------- |
|
565 // CUpnpAVDeviceExtended::MatchType |
|
566 // See upnpavdeviceextended.h |
|
567 // -------------------------------------------------------------------------- |
|
568 TBool CUpnpAVDeviceExtended::MatchType( const TDesC8& aObjectClass, |
|
569 const TDesC8& aProtocolInfo ) const |
|
570 { |
|
571 __LOG( "CUpnpAVDeviceExtended::MatchType" ); |
|
572 |
|
573 TBool retVal = EFalse; |
|
574 if( aObjectClass.Find( KClassAudio ) == 0 ) |
|
575 { |
|
576 if( aProtocolInfo.Find( KAudioSupport ) >= 0 ) |
|
577 { |
|
578 retVal = ETrue; |
|
579 } |
|
580 } |
|
581 else if( aObjectClass.Find( KClassImage ) == 0 ) |
|
582 { |
|
583 if( aProtocolInfo.Find( KImageSupport ) >= 0 ) |
|
584 { |
|
585 retVal = ETrue; |
|
586 } |
|
587 } |
|
588 else if( aObjectClass.Find( KClassVideo ) == 0 ) |
|
589 { |
|
590 if( aProtocolInfo.Find( KVideoSupport ) >= 0 ) |
|
591 { |
|
592 retVal = ETrue; |
|
593 } |
|
594 } |
|
595 else |
|
596 { |
|
597 __PANICD( __FILE__, __LINE__ ); |
|
598 } |
|
599 return retVal; |
|
600 } |
|
601 |
|
602 // -------------------------------------------------------------------------- |
|
603 // CUpnpAVDeviceExtended::SetCapabilitiesBySupportedMimeTypesL |
|
604 // See upnpavdeviceextended.h |
|
605 // -------------------------------------------------------------------------- |
|
606 void CUpnpAVDeviceExtended::SetCapabilitiesBySupportedMimeTypesL( |
|
607 const TDesC8& aListOfMimeTypes ) |
|
608 { |
|
609 __LOG( "CUpnpAVDeviceExtended::SetCapabilitiesBySupportedMimeTypesL" ); |
|
610 |
|
611 if( aListOfMimeTypes != KNullDesC8 ) |
|
612 { |
|
613 // Update the audio media capability |
|
614 if( UPnPCommonUtils::IsAudioSupported( aListOfMimeTypes ) ) |
|
615 { |
|
616 iAudioMediaCapability = ETrue; |
|
617 } |
|
618 else |
|
619 { |
|
620 iAudioMediaCapability = EFalse; |
|
621 } |
|
622 |
|
623 // Update the audio media capability |
|
624 if( UPnPCommonUtils::IsImageSupported( aListOfMimeTypes ) ) |
|
625 { |
|
626 iImageMediaCapability = ETrue; |
|
627 } |
|
628 else |
|
629 { |
|
630 iImageMediaCapability = EFalse; |
|
631 } |
|
632 |
|
633 // Update the video media capability |
|
634 if( UPnPCommonUtils::IsVideoSupported( aListOfMimeTypes ) ) |
|
635 { |
|
636 iVideoMediaCapability = ETrue; |
|
637 } |
|
638 else |
|
639 { |
|
640 iVideoMediaCapability = EFalse; |
|
641 } |
|
642 } |
|
643 } |
|
644 |
|
645 // -------------------------------------------------------------------------- |
|
646 // CUpnpAVDeviceExtended::SetSourceProtocolInfoL |
|
647 // See upnpavdeviceextended.h |
|
648 // -------------------------------------------------------------------------- |
|
649 void CUpnpAVDeviceExtended::SetSourceProtocolInfoL( |
|
650 const RPointerArray<CUpnpDlnaProtocolInfo>& aProtocolInfo ) |
|
651 { |
|
652 __LOG( "CUpnpAVDeviceExtended::SetSourceProtocolInfoL" ); |
|
653 |
|
654 for( TInt i = 0; i < aProtocolInfo.Count(); i++ ) |
|
655 { |
|
656 CUpnpDlnaProtocolInfo* tmpInfo = CUpnpDlnaProtocolInfo::NewL( |
|
657 aProtocolInfo[ i ]->ProtocolInfoL() ); |
|
658 iSourceProtocolInfo.Append( tmpInfo ); // Ownership is transferred |
|
659 } |
|
660 } |
|
661 |
|
662 // -------------------------------------------------------------------------- |
|
663 // CUpnpAVDeviceExtended::SetSinkProtocolInfoL |
|
664 // See upnpavdeviceextended.h |
|
665 // -------------------------------------------------------------------------- |
|
666 void CUpnpAVDeviceExtended::SetSinkProtocolInfoL( |
|
667 const RPointerArray<CUpnpDlnaProtocolInfo>& aProtocolInfo ) |
|
668 { |
|
669 __LOG( "CUpnpAVDeviceExtended::SetSinkProtocolInfoL" ); |
|
670 |
|
671 for( TInt i = 0; i < aProtocolInfo.Count(); i++ ) |
|
672 { |
|
673 CUpnpDlnaProtocolInfo* tmpInfo = CUpnpDlnaProtocolInfo::NewL( |
|
674 aProtocolInfo[ i ]->ProtocolInfoL() ); |
|
675 iSinkProtocolInfo.Append( tmpInfo ); // Ownership is transferred |
|
676 } |
|
677 } |
|
678 |
|
679 // -------------------------------------------------------------------------- |
|
680 // CUpnpAVDeviceExtended::ParseToDelimeter |
|
681 // See upnpavdeviceextended.h |
|
682 // -------------------------------------------------------------------------- |
|
683 void CUpnpAVDeviceExtended::ParseToDelimeter( TLex8& aLex, TChar aDelimeter ) |
|
684 { |
|
685 aLex.Mark(); |
|
686 |
|
687 TChar chr = 0; |
|
688 TChar edchr = 0; |
|
689 |
|
690 while( !aLex.Eos() ) |
|
691 { |
|
692 edchr = chr; |
|
693 |
|
694 chr = aLex.Peek(); |
|
695 if( chr == aDelimeter && edchr != TChar( KSlash ) ) |
|
696 { |
|
697 break; |
|
698 } |
|
699 |
|
700 aLex.Inc(); |
|
701 } |
|
702 } |
|
703 |
|
704 // -------------------------------------------------------------------------- |
|
705 // CUpnpAVDeviceExtended::RemoveIllegalCharactersL |
|
706 // See upnpavdeviceextended.h |
|
707 // -------------------------------------------------------------------------- |
|
708 HBufC8* CUpnpAVDeviceExtended::RemoveIllegalCharactersL( |
|
709 const TDesC8& aPtr ) const |
|
710 { |
|
711 HBufC8* ptrResult = NULL; |
|
712 TInt i = KErrNotFound; |
|
713 if ( aPtr.Length() != 0 ) |
|
714 { |
|
715 ptrResult = aPtr.AllocL(); |
|
716 CleanupStack::PushL( ptrResult ); |
|
717 TPtr8 ptr = ptrResult->Des(); |
|
718 while( ++i < ptr.Length() ) |
|
719 { |
|
720 if( IsIllegalCharacter( ptr[i] ) ) |
|
721 { |
|
722 ptr.Delete( i, 1 ); |
|
723 i--; |
|
724 } |
|
725 |
|
726 } |
|
727 CleanupStack::Pop( ptrResult ); |
|
728 } |
|
729 return ptrResult; |
|
730 |
|
731 } |
|
732 |
|
733 // -------------------------------------------------------------------------- |
|
734 // CUpnpAVDeviceExtended::IsIllegalCharacter |
|
735 // See upnpavdeviceextended.h |
|
736 // -------------------------------------------------------------------------- |
|
737 TBool CUpnpAVDeviceExtended::IsIllegalCharacter( TChar aCharacter ) const |
|
738 { |
|
739 |
|
740 TBool retVal = EFalse; |
|
741 if ( ( ( aCharacter >= TChar( KUnicodeC0RangeStart ) |
|
742 && aCharacter <= TChar( KUnicodeC0RangeEnd ) ) |
|
743 || ( aCharacter >= TChar( KUnicodeC1RangeStart ) |
|
744 && aCharacter <= TChar( KUnicodeC1RangeEnd ) ) ) ) |
|
745 { |
|
746 retVal = ETrue; |
|
747 } |
|
748 return retVal; |
|
749 |
|
750 } |
|
751 |
|
752 // -------------------------------------------------------------------------- |
|
753 // CUpnpAVDeviceExtended::SetAudioUpload |
|
754 // See upnpavdeviceextended.h |
|
755 // -------------------------------------------------------------------------- |
|
756 void CUpnpAVDeviceExtended::SetAudioUpload( TBool aAudioUpload ) |
|
757 { |
|
758 iAudioUpload = aAudioUpload; |
|
759 } |
|
760 |
|
761 // -------------------------------------------------------------------------- |
|
762 // CUpnpAVDeviceExtended::AudioUpload |
|
763 // See upnpavdeviceextended.h |
|
764 // -------------------------------------------------------------------------- |
|
765 TBool CUpnpAVDeviceExtended::AudioUpload() const |
|
766 { |
|
767 return iAudioUpload; |
|
768 } |
|
769 |
|
770 // -------------------------------------------------------------------------- |
|
771 // CUpnpAVDeviceExtended::SetImageUpload |
|
772 // See upnpavdeviceextended.h |
|
773 // -------------------------------------------------------------------------- |
|
774 void CUpnpAVDeviceExtended::SetImageUpload( TBool aImageUpload ) |
|
775 { |
|
776 iImageUpload = aImageUpload; |
|
777 } |
|
778 |
|
779 // -------------------------------------------------------------------------- |
|
780 // CUpnpAVDeviceExtended::ImageUpload |
|
781 // See upnpavdeviceextended.h |
|
782 // -------------------------------------------------------------------------- |
|
783 TBool CUpnpAVDeviceExtended::ImageUpload() const |
|
784 { |
|
785 return iImageUpload; |
|
786 } |
|
787 |
|
788 // -------------------------------------------------------------------------- |
|
789 // CUpnpAVDeviceExtended::SetVideoUpload |
|
790 // See upnpavdeviceextended.h |
|
791 // -------------------------------------------------------------------------- |
|
792 void CUpnpAVDeviceExtended::SetVideoUpload( TBool aVideoUpload ) |
|
793 { |
|
794 iVideoUpload = aVideoUpload; |
|
795 } |
|
796 |
|
797 // -------------------------------------------------------------------------- |
|
798 // CUpnpAVDeviceExtended::VideoUpload |
|
799 // See upnpavdeviceextended.h |
|
800 // -------------------------------------------------------------------------- |
|
801 TBool CUpnpAVDeviceExtended::VideoUpload() const |
|
802 { |
|
803 return iVideoUpload; |
|
804 } |
|
805 |
|
806 // -------------------------------------------------------------------------- |
|
807 // CUpnpAVDeviceExtended::SetCreateChildContainer |
|
808 // See upnpavdeviceextended.h |
|
809 // -------------------------------------------------------------------------- |
|
810 void CUpnpAVDeviceExtended::SetCreateChildContainer( |
|
811 TBool aCreateChildContainer ) |
|
812 { |
|
813 iCreateChildContainer = aCreateChildContainer; |
|
814 } |
|
815 |
|
816 // -------------------------------------------------------------------------- |
|
817 // CUpnpAVDeviceExtended::CreateChildContainer |
|
818 // See upnpavdeviceextended.h |
|
819 // -------------------------------------------------------------------------- |
|
820 TBool CUpnpAVDeviceExtended::CreateChildContainer() const |
|
821 { |
|
822 return iCreateChildContainer; |
|
823 } |
|
824 |
|
825 // -------------------------------------------------------------------------- |
|
826 // CUpnpAVDeviceExtended::SetDestroyObject |
|
827 // See upnpavdeviceextended.h |
|
828 // -------------------------------------------------------------------------- |
|
829 void CUpnpAVDeviceExtended::SetDestroyObject( TBool aDestroyObject ) |
|
830 { |
|
831 iDestroyObject = aDestroyObject; |
|
832 } |
|
833 |
|
834 // -------------------------------------------------------------------------- |
|
835 // CUpnpAVDeviceExtended::DestroyObject |
|
836 // See upnpavdeviceextended.h |
|
837 // -------------------------------------------------------------------------- |
|
838 TBool CUpnpAVDeviceExtended::DestroyObject() const |
|
839 { |
|
840 return iDestroyObject; |
|
841 } |
|
842 |
|
843 // -------------------------------------------------------------------------- |
|
844 // CUpnpAVDeviceExtended::SetPInfoReceived |
|
845 // See upnpavdeviceextended.h |
|
846 // -------------------------------------------------------------------------- |
|
847 void CUpnpAVDeviceExtended::SetPInfoReceived( TBool aPInfoReceived ) |
|
848 { |
|
849 iPInfoReceived = aPInfoReceived; |
|
850 } |
|
851 |
|
852 // -------------------------------------------------------------------------- |
|
853 // CUpnpAVDeviceExtended::PInfoReceived |
|
854 // See upnpavdeviceextended.h |
|
855 // -------------------------------------------------------------------------- |
|
856 TBool CUpnpAVDeviceExtended::PInfoReceived() const |
|
857 { |
|
858 return iPInfoReceived; |
|
859 } |
|
860 |
|
861 void CUpnpAVDeviceExtended::SetDLNADeviceType( TDLNADeviceType aDeviceType ) |
|
862 { |
|
863 iDLNADeviceType = aDeviceType; |
|
864 } |
|
865 |
|
866 CUpnpAVDeviceExtended::TDLNADeviceType |
|
867 CUpnpAVDeviceExtended::DLNADeviceType() const |
|
868 { |
|
869 return iDLNADeviceType; |
|
870 } |
|
871 |
|
872 |
|
873 |
|
874 // end of file |