|
1 /* |
|
2 * Copyright (c) 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 device object |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDE FILES |
|
24 |
|
25 #include "upnpavdevice.h" |
|
26 |
|
27 // CONSTANTS |
|
28 const TInt KMaxStringLen = 255; |
|
29 const TInt KBufferGranularity = 100; |
|
30 |
|
31 _LIT( KComponentLogfile, "upnpavcontrollerclient.txt"); |
|
32 #include "upnplog.h" |
|
33 |
|
34 // CONSTANTS |
|
35 _LIT8( KAudioSupport, "audio/" ); |
|
36 _LIT8( KImageSupport, "image/" ); |
|
37 _LIT8( KVideoSupport, "video/" ); |
|
38 |
|
39 // ============================ MEMBER FUNCTIONS ============================ |
|
40 |
|
41 // -------------------------------------------------------------------------- |
|
42 // CUpnpAVDevice::CUpnpAVDevice |
|
43 // C++ default constructor can NOT contain any code, that |
|
44 // might leave. |
|
45 // -------------------------------------------------------------------------- |
|
46 EXPORT_C CUpnpAVDevice::CUpnpAVDevice() |
|
47 { |
|
48 } |
|
49 |
|
50 // -------------------------------------------------------------------------- |
|
51 // CUpnpAVDevice::ConstructL |
|
52 // Symbian 2nd phase constructor can leave. |
|
53 // -------------------------------------------------------------------------- |
|
54 void CUpnpAVDevice::ConstructL() |
|
55 { |
|
56 } |
|
57 |
|
58 // -------------------------------------------------------------------------- |
|
59 // CUpnpAVDevice::NewL |
|
60 // Two-phased constructor. |
|
61 // -------------------------------------------------------------------------- |
|
62 EXPORT_C CUpnpAVDevice* CUpnpAVDevice::NewL() |
|
63 { |
|
64 CUpnpAVDevice* self = NewLC(); |
|
65 CleanupStack::Pop( self ); |
|
66 return self; |
|
67 } |
|
68 |
|
69 // -------------------------------------------------------------------------- |
|
70 // CUpnpAVDevice::NewL |
|
71 // Two-phased constructor. |
|
72 // -------------------------------------------------------------------------- |
|
73 EXPORT_C CUpnpAVDevice* CUpnpAVDevice::NewL( const CUpnpAVDevice& aDevice ) |
|
74 { |
|
75 CUpnpAVDevice* self = NewLC(); |
|
76 |
|
77 self->CopyFromL( aDevice ); |
|
78 |
|
79 CleanupStack::Pop( self ); |
|
80 return self; |
|
81 } |
|
82 |
|
83 // -------------------------------------------------------------------------- |
|
84 // CUpnpAVDevice::NewLC |
|
85 // Two-phased constructor. |
|
86 // -------------------------------------------------------------------------- |
|
87 EXPORT_C CUpnpAVDevice* CUpnpAVDevice::NewLC() |
|
88 { |
|
89 CUpnpAVDevice* self = new( ELeave ) |
|
90 CUpnpAVDevice; |
|
91 CleanupStack::PushL( self ); |
|
92 self->ConstructL(); |
|
93 return self; |
|
94 } |
|
95 |
|
96 |
|
97 // -------------------------------------------------------------------------- |
|
98 // CUpnpAVDevice::~CUpnpAVDevice |
|
99 // Destructor |
|
100 // -------------------------------------------------------------------------- |
|
101 EXPORT_C CUpnpAVDevice::~CUpnpAVDevice() |
|
102 { |
|
103 delete iName; |
|
104 delete iUuid; |
|
105 } |
|
106 |
|
107 // -------------------------------------------------------------------------- |
|
108 // CUpnpAVDevice::ExternalizeL |
|
109 // See upnpavdevice.h |
|
110 // -------------------------------------------------------------------------- |
|
111 EXPORT_C void CUpnpAVDevice::ExternalizeL( RWriteStream& aStream ) const |
|
112 { |
|
113 __ASSERTD( iUuid, __FILE__, __LINE__ ); |
|
114 __ASSERTD( iName, __FILE__, __LINE__ ); |
|
115 |
|
116 aStream << *iUuid; |
|
117 aStream << *iName; |
|
118 aStream.WriteInt32L( (TInt)iDeviceType ); |
|
119 aStream.WriteInt32L( (TInt)iCopyCapability ); |
|
120 aStream.WriteInt32L( (TInt)iSearchCapability ); |
|
121 aStream.WriteInt32L( (TInt)iPauseCapability ); |
|
122 aStream.WriteInt32L( (TInt)iVolumeCapability ); |
|
123 aStream.WriteInt32L( (TInt)iMuteCapability ); |
|
124 aStream.WriteInt32L( (TInt)iAudioMediaCapability ); |
|
125 aStream.WriteInt32L( (TInt)iImageMediaCapability ); |
|
126 aStream.WriteInt32L( (TInt)iVideoMediaCapability ); |
|
127 aStream.WriteInt32L( (TInt)iNextAVTransportUri ); |
|
128 aStream.WriteInt32L( (TInt)iMaxVolume ); |
|
129 aStream.WriteInt32L( (TInt)iDlnaCompatible ); |
|
130 } |
|
131 |
|
132 // -------------------------------------------------------------------------- |
|
133 // CUpnpAVDevice::InternalizeL |
|
134 // See upnpavdevice.h |
|
135 // -------------------------------------------------------------------------- |
|
136 EXPORT_C void CUpnpAVDevice::InternalizeL( RReadStream& aStream ) |
|
137 { |
|
138 delete iUuid; |
|
139 iUuid = NULL; |
|
140 iUuid = HBufC8::NewL( aStream, KMaxStringLen ); |
|
141 |
|
142 delete iName; |
|
143 iName = NULL; |
|
144 iName = HBufC8::NewL( aStream, KMaxStringLen ); |
|
145 |
|
146 iDeviceType = (TUpnpAVDeviceType)aStream.ReadInt32L(); |
|
147 iCopyCapability = (TBool)aStream.ReadInt32L(); |
|
148 iSearchCapability = (TBool)aStream.ReadInt32L(); |
|
149 iPauseCapability = (TBool)aStream.ReadInt32L(); |
|
150 iVolumeCapability = (TBool)aStream.ReadInt32L(); |
|
151 iMuteCapability = (TBool)aStream.ReadInt32L(); |
|
152 iAudioMediaCapability = (TBool)aStream.ReadInt32L(); |
|
153 iImageMediaCapability = (TBool)aStream.ReadInt32L(); |
|
154 iVideoMediaCapability = (TBool)aStream.ReadInt32L(); |
|
155 iNextAVTransportUri = (TBool)aStream.ReadInt32L(); |
|
156 iMaxVolume = (TInt)aStream.ReadInt32L(); |
|
157 iDlnaCompatible = (TBool)aStream.ReadInt32L(); |
|
158 } |
|
159 |
|
160 // -------------------------------------------------------------------------- |
|
161 // CUpnpAVDevice::ToDes8L |
|
162 // See upnpavdevice.h |
|
163 // -------------------------------------------------------------------------- |
|
164 EXPORT_C HBufC8* CUpnpAVDevice::ToDes8L() const |
|
165 { |
|
166 // serialize object |
|
167 CBufFlat* tempFlatBuf = CBufFlat::NewL( KBufferGranularity ); |
|
168 CleanupStack::PushL( tempFlatBuf ); |
|
169 |
|
170 RBufWriteStream stream( *tempFlatBuf ); |
|
171 CleanupClosePushL( stream ); |
|
172 |
|
173 stream << *this; |
|
174 |
|
175 // create heap descriptor |
|
176 HBufC8* tempBuf = HBufC8::NewLC( tempFlatBuf->Size() ); |
|
177 TPtr8 ptr( tempBuf->Des() ); |
|
178 tempFlatBuf->Read( 0, ptr, tempFlatBuf->Size() ); |
|
179 |
|
180 // clean up |
|
181 CleanupStack::Pop( tempBuf ); |
|
182 CleanupStack::PopAndDestroy( &stream ); |
|
183 CleanupStack::PopAndDestroy( tempFlatBuf ); |
|
184 |
|
185 return tempBuf; |
|
186 } |
|
187 |
|
188 // -------------------------------------------------------------------------- |
|
189 // CUpnpAVDevice::CopyFromL |
|
190 // See upnpavdevice.h |
|
191 // -------------------------------------------------------------------------- |
|
192 EXPORT_C void CUpnpAVDevice::CopyFromL( const CUpnpAVDevice& aDevice ) |
|
193 { |
|
194 iDeviceType = aDevice.DeviceType(); |
|
195 SetFriendlyNameL( aDevice.FriendlyName() ); |
|
196 SetUuidL( aDevice.Uuid() ); |
|
197 iCopyCapability = aDevice.CopyCapability(); |
|
198 iSearchCapability = aDevice.SearchCapability(); |
|
199 iPauseCapability = aDevice.PauseCapability(); |
|
200 iVolumeCapability = aDevice.VolumeCapability(); |
|
201 iMuteCapability = aDevice.MuteCapability(); |
|
202 iAudioMediaCapability = aDevice.AudioCapability(); |
|
203 iImageMediaCapability = aDevice.ImageCapability(); |
|
204 iVideoMediaCapability = aDevice.VideoCapability(); |
|
205 iNextAVTransportUri = aDevice.NextAVTransportUri(); |
|
206 iMaxVolume = aDevice.MaxVolume(); |
|
207 iDlnaCompatible = aDevice.DlnaCompatible(); |
|
208 } |
|
209 |
|
210 // -------------------------------------------------------------------------- |
|
211 // CUpnpAVDevice::SetFriendlyNameL |
|
212 // See upnpavdevice.h |
|
213 // -------------------------------------------------------------------------- |
|
214 EXPORT_C void CUpnpAVDevice::SetFriendlyNameL( const TDesC8& aName ) |
|
215 { |
|
216 HBufC8* tempBuf = aName.AllocL(); |
|
217 delete iName; |
|
218 iName = tempBuf; |
|
219 } |
|
220 |
|
221 // -------------------------------------------------------------------------- |
|
222 // CUpnpAVDevice::FriendlyName |
|
223 // See upnpavdevice.h |
|
224 // -------------------------------------------------------------------------- |
|
225 EXPORT_C const TDesC8& CUpnpAVDevice::FriendlyName() const |
|
226 { |
|
227 if( iName ) |
|
228 { |
|
229 return *iName; |
|
230 } |
|
231 else |
|
232 { |
|
233 return KNullDesC8; |
|
234 } |
|
235 } |
|
236 |
|
237 |
|
238 // -------------------------------------------------------------------------- |
|
239 // CUpnpAVDevice::SetUuidL |
|
240 // See upnpavdevice.h |
|
241 // -------------------------------------------------------------------------- |
|
242 EXPORT_C void CUpnpAVDevice::SetUuidL( const TDesC8& aUuid ) |
|
243 { |
|
244 HBufC8* tempBuf = aUuid.AllocL(); |
|
245 delete iUuid; |
|
246 iUuid = tempBuf; |
|
247 } |
|
248 |
|
249 // -------------------------------------------------------------------------- |
|
250 // CUpnpAVDevice::Uuid |
|
251 // See upnpavdevice.h |
|
252 // -------------------------------------------------------------------------- |
|
253 EXPORT_C const TDesC8& CUpnpAVDevice::Uuid() const |
|
254 { |
|
255 if( iUuid ) |
|
256 { |
|
257 return *iUuid; |
|
258 } |
|
259 else |
|
260 { |
|
261 return KNullDesC8; |
|
262 } |
|
263 } |
|
264 |
|
265 |
|
266 // -------------------------------------------------------------------------- |
|
267 // CUpnpAVDevice::SetDeviceType |
|
268 // See upnpavdevice.h |
|
269 // -------------------------------------------------------------------------- |
|
270 EXPORT_C void CUpnpAVDevice::SetDeviceType( TUpnpAVDeviceType aDeviceType ) |
|
271 { |
|
272 iDeviceType = aDeviceType; |
|
273 } |
|
274 |
|
275 // -------------------------------------------------------------------------- |
|
276 // CUpnpAVDevice::DeviceType |
|
277 // See upnpavdevice.h |
|
278 // -------------------------------------------------------------------------- |
|
279 EXPORT_C CUpnpAVDevice::TUpnpAVDeviceType CUpnpAVDevice::DeviceType() const |
|
280 { |
|
281 return iDeviceType; |
|
282 } |
|
283 |
|
284 // -------------------------------------------------------------------------- |
|
285 // CUpnpAVDevice::SetCapabilitiesBySupportedMimeTypesL |
|
286 // See upnpavdevice.h |
|
287 // -------------------------------------------------------------------------- |
|
288 EXPORT_C void CUpnpAVDevice::SetCapabilitiesBySupportedMimeTypesL( |
|
289 const TDesC8& aListOfMimeTypes ) |
|
290 { |
|
291 if( aListOfMimeTypes == KNullDesC8 ) |
|
292 { |
|
293 User::Leave( KErrArgument ); |
|
294 } |
|
295 else |
|
296 { |
|
297 // Update the audio media capability |
|
298 if( aListOfMimeTypes.Find( KAudioSupport ) >= 0 ) |
|
299 { |
|
300 iAudioMediaCapability = ETrue; |
|
301 } |
|
302 else |
|
303 { |
|
304 iAudioMediaCapability = EFalse; |
|
305 } |
|
306 |
|
307 // Update the image media capability |
|
308 if( aListOfMimeTypes.Find( KImageSupport ) >= 0 ) |
|
309 { |
|
310 iImageMediaCapability = ETrue; |
|
311 } |
|
312 else |
|
313 { |
|
314 iImageMediaCapability = EFalse; |
|
315 } |
|
316 |
|
317 // Update the video media capability |
|
318 if( aListOfMimeTypes.Find( KVideoSupport ) >= 0 ) |
|
319 { |
|
320 iVideoMediaCapability = ETrue; |
|
321 } |
|
322 else |
|
323 { |
|
324 iVideoMediaCapability = EFalse; |
|
325 } |
|
326 } |
|
327 } |
|
328 |
|
329 // -------------------------------------------------------------------------- |
|
330 // CUpnpAVDevice::LinkOffset |
|
331 // See upnpavdevice.h |
|
332 // -------------------------------------------------------------------------- |
|
333 EXPORT_C TInt CUpnpAVDevice::LinkOffset() |
|
334 { |
|
335 return _FOFF( CUpnpAVDevice, iSlink ); |
|
336 } |
|
337 |
|
338 // -------------------------------------------------------------------------- |
|
339 // CUpnpAVDevice::SetCopyCapability |
|
340 // Sets the copy capability of the device |
|
341 // -------------------------------------------------------------------------- |
|
342 EXPORT_C void CUpnpAVDevice::SetCopyCapability( TBool aCopyCap ) |
|
343 { |
|
344 iCopyCapability = aCopyCap; |
|
345 } |
|
346 |
|
347 // -------------------------------------------------------------------------- |
|
348 // CUpnpAVDevice::CopyCapability |
|
349 // Gets the copy capability of the device |
|
350 // -------------------------------------------------------------------------- |
|
351 EXPORT_C TBool CUpnpAVDevice::CopyCapability() const |
|
352 { |
|
353 return iCopyCapability; |
|
354 } |
|
355 |
|
356 // -------------------------------------------------------------------------- |
|
357 // CUpnpAVDevice::SetSearchCapability |
|
358 // Sets the search capability of the device |
|
359 // -------------------------------------------------------------------------- |
|
360 EXPORT_C void CUpnpAVDevice::SetSearchCapability( TBool aSearchCap ) |
|
361 { |
|
362 iSearchCapability = aSearchCap; |
|
363 } |
|
364 |
|
365 // -------------------------------------------------------------------------- |
|
366 // CUpnpAVDevice::SearchCapability |
|
367 // Gets the search capability of the device |
|
368 // -------------------------------------------------------------------------- |
|
369 EXPORT_C TBool CUpnpAVDevice::SearchCapability() const |
|
370 { |
|
371 return iSearchCapability; |
|
372 } |
|
373 |
|
374 // -------------------------------------------------------------------------- |
|
375 // CUpnpAVDevice::SetPauseCapability |
|
376 // Sets the pause capability of the device |
|
377 // -------------------------------------------------------------------------- |
|
378 EXPORT_C void CUpnpAVDevice::SetPauseCapability( TBool aPauseCap ) |
|
379 { |
|
380 iPauseCapability = aPauseCap; |
|
381 } |
|
382 |
|
383 // -------------------------------------------------------------------------- |
|
384 // CUpnpAVDevice::PauseCapability |
|
385 // Gets the pause capability of the device |
|
386 // -------------------------------------------------------------------------- |
|
387 EXPORT_C TBool CUpnpAVDevice::PauseCapability() const |
|
388 { |
|
389 return iPauseCapability; |
|
390 } |
|
391 |
|
392 // -------------------------------------------------------------------------- |
|
393 // CUpnpAVDevice::SetVolumeCapability |
|
394 // Sets the volume capability of the device |
|
395 // -------------------------------------------------------------------------- |
|
396 EXPORT_C void CUpnpAVDevice::SetVolumeCapability( TBool aVolumeCap ) |
|
397 { |
|
398 iVolumeCapability = aVolumeCap; |
|
399 } |
|
400 |
|
401 // -------------------------------------------------------------------------- |
|
402 // CUpnpAVDevice::VolumeCapability |
|
403 // Gets the volume capability of the device |
|
404 // -------------------------------------------------------------------------- |
|
405 EXPORT_C TBool CUpnpAVDevice::VolumeCapability() const |
|
406 { |
|
407 return iVolumeCapability; |
|
408 } |
|
409 |
|
410 // -------------------------------------------------------------------------- |
|
411 // CUpnpAVDevice::SetMuteCapability |
|
412 // Sets the mute capability of the device |
|
413 // -------------------------------------------------------------------------- |
|
414 EXPORT_C void CUpnpAVDevice::SetMuteCapability( TBool aMuteCap ) |
|
415 { |
|
416 iMuteCapability = aMuteCap; |
|
417 } |
|
418 |
|
419 // -------------------------------------------------------------------------- |
|
420 // CUpnpAVDevice::MuteCapability |
|
421 // Gets the mute capability of the device |
|
422 // -------------------------------------------------------------------------- |
|
423 EXPORT_C TBool CUpnpAVDevice::MuteCapability() const |
|
424 { |
|
425 return iMuteCapability; |
|
426 } |
|
427 |
|
428 // -------------------------------------------------------------------------- |
|
429 // CUpnpAVDevice::SetMaxVolume |
|
430 // Sets the maximum volume of the device |
|
431 // -------------------------------------------------------------------------- |
|
432 EXPORT_C void CUpnpAVDevice::SetMaxVolume( TInt aVolume ) |
|
433 { |
|
434 iMaxVolume = aVolume; |
|
435 } |
|
436 |
|
437 // -------------------------------------------------------------------------- |
|
438 // CUpnpAVDevice::MaxVolume |
|
439 // Gets the maximum volume of the device |
|
440 // -------------------------------------------------------------------------- |
|
441 EXPORT_C TInt CUpnpAVDevice::MaxVolume() const |
|
442 { |
|
443 return iMaxVolume; |
|
444 } |
|
445 |
|
446 // -------------------------------------------------------------------------- |
|
447 // CUpnpAVDevice::SetNextAVTransportUri |
|
448 // See upnpavdevice.h |
|
449 // -------------------------------------------------------------------------- |
|
450 EXPORT_C void CUpnpAVDevice::SetNextAVTransportUri( TBool aCap ) |
|
451 { |
|
452 iNextAVTransportUri = aCap; |
|
453 __LOG1( "CUpnpAVDevice::SetNextAVTransportUri: iNextAVTransportUri %d", |
|
454 iNextAVTransportUri ); |
|
455 } |
|
456 |
|
457 // -------------------------------------------------------------------------- |
|
458 // CUpnpAVDevice::NextAVTransportUri |
|
459 // See upnpavdevice.h |
|
460 // -------------------------------------------------------------------------- |
|
461 EXPORT_C TBool CUpnpAVDevice::NextAVTransportUri() const |
|
462 { |
|
463 __LOG1( "CUpnpAVDevice::NextAVTransportUri: iNextAVTransportUri %d", |
|
464 iNextAVTransportUri ); |
|
465 // Do not support NextAVTransportUri for now |
|
466 __LOG( "return EFalse" ); |
|
467 return EFalse; |
|
468 } |
|
469 |
|
470 // -------------------------------------------------------------------------- |
|
471 // CUpnpAVDevice::SetAudioCapability |
|
472 // See upnpavdevice.h |
|
473 // -------------------------------------------------------------------------- |
|
474 EXPORT_C void CUpnpAVDevice::SetAudioCapability( TBool aCap ) |
|
475 { |
|
476 iAudioMediaCapability = aCap; |
|
477 } |
|
478 |
|
479 // -------------------------------------------------------------------------- |
|
480 // CUpnpAVDevice::AudioCapability |
|
481 // See upnpavdevice.h |
|
482 // -------------------------------------------------------------------------- |
|
483 EXPORT_C TBool CUpnpAVDevice::AudioCapability() const |
|
484 { |
|
485 return iAudioMediaCapability; |
|
486 } |
|
487 |
|
488 // -------------------------------------------------------------------------- |
|
489 // CUpnpAVDevice::SetImageCapability |
|
490 // See upnpavdevice.h |
|
491 // -------------------------------------------------------------------------- |
|
492 EXPORT_C void CUpnpAVDevice::SetImageCapability( TBool aCap ) |
|
493 { |
|
494 iImageMediaCapability = aCap; |
|
495 } |
|
496 |
|
497 // -------------------------------------------------------------------------- |
|
498 // CUpnpAVDevice::ImageCapability |
|
499 // See upnpavdevice.h |
|
500 // -------------------------------------------------------------------------- |
|
501 EXPORT_C TBool CUpnpAVDevice::ImageCapability() const |
|
502 { |
|
503 return iImageMediaCapability; |
|
504 } |
|
505 |
|
506 // -------------------------------------------------------------------------- |
|
507 // CUpnpAVDevice::SetVideoCapability |
|
508 // See upnpavdevice.h |
|
509 // -------------------------------------------------------------------------- |
|
510 EXPORT_C void CUpnpAVDevice::SetVideoCapability( TBool aCap ) |
|
511 { |
|
512 iVideoMediaCapability = aCap; |
|
513 } |
|
514 |
|
515 // -------------------------------------------------------------------------- |
|
516 // CUpnpAVDevice::VideoCapability |
|
517 // See upnpavdevice.h |
|
518 // -------------------------------------------------------------------------- |
|
519 EXPORT_C TBool CUpnpAVDevice::VideoCapability() const |
|
520 { |
|
521 return iVideoMediaCapability; |
|
522 } |
|
523 |
|
524 // -------------------------------------------------------------------------- |
|
525 // CUpnpAVDevice::SetDlnaCompatible |
|
526 // See upnpavdeviceextended.h |
|
527 // -------------------------------------------------------------------------- |
|
528 EXPORT_C void CUpnpAVDevice::SetDlnaCompatible( TBool aDlnaCompatible ) |
|
529 { |
|
530 iDlnaCompatible = aDlnaCompatible; |
|
531 } |
|
532 |
|
533 // -------------------------------------------------------------------------- |
|
534 // CUpnpAVDevice::DlnaCompatible |
|
535 // See upnpavdeviceextended.h |
|
536 // -------------------------------------------------------------------------- |
|
537 EXPORT_C TBool CUpnpAVDevice::DlnaCompatible() const |
|
538 { |
|
539 return iDlnaCompatible; |
|
540 } |
|
541 |
|
542 // End of File |
|
543 |