1 /* |
1 /* |
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
59 __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator: constructor" ); |
59 __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator: constructor" ); |
60 |
60 |
61 iState = EStateIdle; |
61 iState = EStateIdle; |
62 iErrorCode = KErrNone; |
62 iErrorCode = KErrNone; |
63 iMode = aMode; |
63 iMode = aMode; |
64 iLocalMSSCompleted = EFalse; |
64 |
65 |
65 if ( iMode & EResourceSelectDevice ) |
66 if ( iMode & EResourceLocalMediaServer || |
66 { |
67 iMode & EResourceSelectDevice ) |
67 // AVCONTROLLER flag is mandatory. |
68 { |
|
69 // if any of these flags are set, AVCONTROLLER flag is mandatory. |
|
70 // assert that. |
68 // assert that. |
71 __ASSERTD( iMode & EResourceAvController, __FILE__, __LINE__ ); |
69 __ASSERTD( iMode & EResourceAvController, __FILE__, __LINE__ ); |
72 } |
70 } |
73 |
|
74 if ( iMode & EResourceLocalMediaServer ) |
|
75 { |
|
76 // if this flag is set, one of the device selection flags is mandatory. |
|
77 __ASSERTD( iMode & EResourceSelectDevice, __FILE__, __LINE__ ); |
|
78 } |
|
79 |
|
80 } |
71 } |
81 |
72 |
82 // -------------------------------------------------------------------------- |
73 // -------------------------------------------------------------------------- |
83 // CUpnpTaskResourceAllocator::~CUpnpTaskResourceAllocator |
74 // CUpnpTaskResourceAllocator::~CUpnpTaskResourceAllocator |
84 // -------------------------------------------------------------------------- |
75 // -------------------------------------------------------------------------- |
105 { |
96 { |
106 __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::Cleanup" ); |
97 __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::Cleanup" ); |
107 |
98 |
108 delete iSelectedDevice; |
99 delete iSelectedDevice; |
109 iSelectedDevice = 0; |
100 iSelectedDevice = 0; |
110 |
101 |
111 if ( iMediaServerSession ) |
|
112 { |
|
113 // Stop local file sharing (release) |
|
114 TRAPD( error, iMediaServerSession->ReleaseLocalMSServicesL() ); |
|
115 if( error != KErrNone ) |
|
116 { |
|
117 __LOG1( "[UpnpCommand]\t CUpnpTaskResourceAllocator::\ |
|
118 ReleaseLocalMSService failed %d", error ); |
|
119 } |
|
120 |
|
121 // Stop observing the rendering session |
|
122 iMediaServerSession->RemoveObserver(); |
|
123 |
|
124 // Stop session |
|
125 iAVController->StopBrowsingSession( *iMediaServerSession ); |
|
126 iMediaServerSession = NULL; |
|
127 } |
|
128 |
|
129 if( iAVController ) |
102 if( iAVController ) |
130 { |
103 { |
131 iAVController->RemoveDeviceObserver(); |
104 iAVController->RemoveDeviceObserver(); |
132 iAVController->Release(); // Fixes ESLX-7BMJBN |
105 iAVController->Release(); // Fixes ESLX-7BMJBN |
133 iAVController = NULL; |
106 iAVController = NULL; |
134 } |
107 } |
135 |
108 } |
136 } |
|
137 |
|
138 |
|
139 |
109 |
140 |
110 |
141 // -------------------------------------------------------------------------- |
111 // -------------------------------------------------------------------------- |
142 // CUpnpTaskResourceAllocator::AllocateL |
112 // CUpnpTaskResourceAllocator::AllocateL |
143 // -------------------------------------------------------------------------- |
113 // -------------------------------------------------------------------------- |
221 SelectDeviceL not done in state %d", iState ); |
191 SelectDeviceL not done in state %d", iState ); |
222 } |
192 } |
223 // make sure we are still on the go |
193 // make sure we are still on the go |
224 if ( iState == EStateAllocating ) |
194 if ( iState == EStateAllocating ) |
225 { |
195 { |
226 // start the local mediaserver |
196 // close the wait note |
227 StartLocalMediaServerL(); |
197 __ASSERTD( iNoteHandler, __FILE__, __LINE__ ); |
228 } |
198 iNoteHandler->CloseWaitNote(); |
229 else |
|
230 { |
|
231 __LOG1( "[UpnpCommand]\t CUpnpTaskResourceAllocator::RunL \ |
|
232 StartLocalMediaServerL not done in state %d", iState ); |
|
233 } |
|
234 // make sure we are still on the go |
|
235 if ( iState == EStateAllocating ) |
|
236 { |
|
237 // if local media server was started but not yet completed, |
|
238 // wait for callback |
|
239 if ( iMode & EResourceLocalMediaServer |
|
240 && !iLocalMSSCompleted ) |
|
241 { |
|
242 __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::RunL \ |
|
243 waiting for ReserveLocalMSServicesCompleted" ); |
|
244 iState = EStateWaitingForLMS; |
|
245 } |
|
246 // otherwise we are done now |
|
247 else |
|
248 { |
|
249 // close the wait note |
|
250 __ASSERTD( iNoteHandler, __FILE__, __LINE__ ); |
|
251 iNoteHandler->CloseWaitNote(); |
|
252 } |
|
253 } |
199 } |
254 else |
200 else |
255 { |
201 { |
256 __LOG1( "[UpnpCommand]\t CUpnpTaskResourceAllocator::RunL \ |
202 __LOG1( "[UpnpCommand]\t CUpnpTaskResourceAllocator::RunL \ |
257 CloseWaitNote not done in state %d", iState ); |
203 CloseWaitNote not done in state %d", iState ); |
297 { |
243 { |
298 __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::\ |
244 __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::\ |
299 AvController not started" ); |
245 AvController not started" ); |
300 } |
246 } |
301 } |
247 } |
302 |
|
303 // -------------------------------------------------------------------------- |
|
304 // CUpnpTaskResourceAllocator::StartLocalMediaServerL |
|
305 // -------------------------------------------------------------------------- |
|
306 void CUpnpTaskResourceAllocator::StartLocalMediaServerL() |
|
307 { |
|
308 if ( iMode & EResourceLocalMediaServer ) |
|
309 { |
|
310 __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::\ |
|
311 StartLocalMediaServerL" ); |
|
312 |
|
313 // create a dummy device |
|
314 CUpnpAVDevice* dummyDevice = CUpnpAVDevice::NewLC(); |
|
315 dummyDevice->SetUuidL( KNullDesC8 ); |
|
316 dummyDevice->SetDeviceType(CUpnpAVDevice::EMediaServer); |
|
317 // create a session for mediaserver resources keepalive |
|
318 iMediaServerSession = |
|
319 &iAVController->StartBrowsingSessionL( *dummyDevice ); |
|
320 iMediaServerSession->SetObserver( *this ); |
|
321 CleanupStack::PopAndDestroy( dummyDevice ); |
|
322 // now reserve |
|
323 iMediaServerSession->ReserveLocalMSServicesL(); |
|
324 } |
|
325 } |
|
326 |
|
327 |
248 |
328 // -------------------------------------------------------------------------- |
249 // -------------------------------------------------------------------------- |
329 // CUpnpTaskResourceAllocator::SelectDeviceL |
250 // CUpnpTaskResourceAllocator::SelectDeviceL |
330 // -------------------------------------------------------------------------- |
251 // -------------------------------------------------------------------------- |
331 // |
252 // |
416 // -------------------------------------------------------------------------- |
337 // -------------------------------------------------------------------------- |
417 void CUpnpTaskResourceAllocator::WLANConnectionLost() |
338 void CUpnpTaskResourceAllocator::WLANConnectionLost() |
418 { |
339 { |
419 __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::WLANConnectionLost" ); |
340 __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::WLANConnectionLost" ); |
420 |
341 |
421 if ( iState == EStateAllocating || iState == EStateWaitingForLMS ) |
342 if ( iState == EStateAllocating ) |
422 { |
343 { |
423 __ASSERTD( iNoteHandler, __FILE__, __LINE__ ); |
344 __ASSERTD( iNoteHandler, __FILE__, __LINE__ ); |
424 SetErrorCode( KErrDisconnected ); |
345 SetErrorCode( KErrDisconnected ); |
425 iNoteHandler->CloseWaitNote(); |
346 iNoteHandler->CloseWaitNote(); |
426 iState = EStateError; |
347 iState = EStateError; |
434 |
355 |
435 void CUpnpTaskResourceAllocator::UPnPDeviceDisappeared( |
356 void CUpnpTaskResourceAllocator::UPnPDeviceDisappeared( |
436 const CUpnpAVDevice& aDevice ) |
357 const CUpnpAVDevice& aDevice ) |
437 { |
358 { |
438 __ASSERTD( iNoteHandler, __FILE__, __LINE__ ); |
359 __ASSERTD( iNoteHandler, __FILE__, __LINE__ ); |
439 if ( ( iState == EStateAllocating || iState == EStateWaitingForLMS ) |
360 if ( ( iState == EStateAllocating ) |
440 && iSelectedDevice != 0 ) |
361 && iSelectedDevice != 0 ) |
441 { |
362 { |
442 if ( aDevice.Uuid() == iSelectedDevice->Uuid() ) |
363 if ( aDevice.Uuid() == iSelectedDevice->Uuid() ) |
443 { |
364 { |
444 __LOG( "[UpnpCommand]\t selected device lost !" ); |
365 __LOG( "[UpnpCommand]\t selected device lost !" ); |
446 iNoteHandler->CloseWaitNote(); |
367 iNoteHandler->CloseWaitNote(); |
447 iState = EStateError; |
368 iState = EStateError; |
448 } |
369 } |
449 } |
370 } |
450 } |
371 } |
451 |
|
452 |
|
453 // ========================================================================== |
|
454 // Methods for AVController browsing session observer |
|
455 // ========================================================================== |
|
456 |
|
457 // -------------------------------------------------------------------------- |
|
458 // CUpnpTaskResourceAllocator::ReserveLocalMSServicesCompleted |
|
459 // -------------------------------------------------------------------------- |
|
460 void CUpnpTaskResourceAllocator::ReserveLocalMSServicesCompleted( TInt aError ) |
|
461 { |
|
462 __LOG1( "[UpnpCommand]\t CUpnpTaskResourceAllocator::\ |
|
463 ReserveLocalMSServicesCompleted: %d", aError ); |
|
464 |
|
465 if ( iState == EStateAllocating |
|
466 || iState == EStateWaitingForLMS ) |
|
467 { |
|
468 iLocalMSSCompleted = ETrue; |
|
469 SetErrorCode( aError ); |
|
470 if ( aError == KErrNone ) |
|
471 { |
|
472 iLocalMSStarted = ETrue; |
|
473 iMediaServerSession->RemoveObserver(); |
|
474 } |
|
475 // allocation done, just waiting for this callback |
|
476 // close note and we are done |
|
477 if( iState == EStateWaitingForLMS ) |
|
478 { |
|
479 iNoteHandler->CloseWaitNote(); |
|
480 } |
|
481 } |
|
482 } |
|
483 |
|
484 |
|
485 void CUpnpTaskResourceAllocator::BrowseResponse( |
|
486 const TDesC8& /*aBrowseResponse*/, |
|
487 TInt /*aError*/, |
|
488 TInt /*aMatches*/, |
|
489 TInt /*aTotalCount*/, |
|
490 const TDesC8& /*aUpdateId*/ ) |
|
491 { |
|
492 } |
|
493 |
|
494 void CUpnpTaskResourceAllocator::SearchResponse( |
|
495 const TDesC8& /*aSearchResponse*/, |
|
496 TInt /*aError*/, |
|
497 TInt /*aMatches*/, |
|
498 TInt /*aTotalCount*/, |
|
499 const TDesC8& /*aUpdateId*/ ) |
|
500 { |
|
501 } |
|
502 |
|
503 void CUpnpTaskResourceAllocator::SearchCapabilitiesResponse( |
|
504 TInt /*aError*/, |
|
505 const TDesC8& /*aSearchCapabilities*/ ) |
|
506 { |
|
507 } |
|
508 |
|
509 void CUpnpTaskResourceAllocator::CreateContainerResponse( |
|
510 TInt /*aError*/, |
|
511 const TDesC8& /*aObjectId*/ ) |
|
512 { |
|
513 } |
|
514 |
|
515 void CUpnpTaskResourceAllocator::DeleteObjectResponse( |
|
516 TInt /*aError*/ ) |
|
517 { |
|
518 } |
|
519 |
|
520 void CUpnpTaskResourceAllocator::MediaServerDisappeared( |
|
521 TUPnPDeviceDisconnectedReason /*aReason*/ ) |
|
522 { |
|
523 } |
|
524 |
|
525 |
|
526 |
372 |
527 // -------------------------------------------------------------------------- |
373 // -------------------------------------------------------------------------- |
528 // CUpnpTaskResourceAllocator::SetNoteHandlerL |
374 // CUpnpTaskResourceAllocator::SetNoteHandlerL |
529 // Sets the pointer to the note handler. |
375 // Sets the pointer to the note handler. |
530 // -------------------------------------------------------------------------- |
376 // -------------------------------------------------------------------------- |