22 |
22 |
23 // INCLUDES |
23 // INCLUDES |
24 // upnp stack api |
24 // upnp stack api |
25 #include <upnpsettings.h> |
25 #include <upnpsettings.h> |
26 |
26 |
27 // upnpframework / avcontroller api |
27 // dlnasrv / avcontroller api |
28 #include "upnpavdevice.h" |
28 #include "upnpavdevice.h" |
29 #include "upnpavdeviceobserver.h" |
29 #include "upnpavdeviceobserver.h" |
30 #include "upnpavdevicelist.h" |
30 #include "upnpavdevicelist.h" |
31 |
31 |
32 // avcontroller internal |
32 // dlnasrv / avcontroller internal |
33 #include "upnpavcontrolleractive.h" |
33 #include "upnpavcontrolleractive.h" |
34 #include "upnpavrenderingsessionimpl.h" |
34 #include "upnpavrenderingsessionimpl.h" |
35 #include "upnpavbrowsingsessionimpl.h" |
35 #include "upnpavbrowsingsessionimpl.h" |
36 #include "upnpavconnectionactive.h" |
36 #include "upnpavconnectionactive.h" |
37 #include "upnpfileuploadsessionimpl.h" |
37 #include "upnpfileuploadsessionimpl.h" |
139 User::LeaveIfError( iap ); |
139 User::LeaveIfError( iap ); |
140 User::LeaveIfError( iServer.Connect() ); |
140 User::LeaveIfError( iServer.Connect() ); |
141 |
141 |
142 iConnectionActive = CUPnPAVConnectionActive::NewL( iServer, *this ); |
142 iConnectionActive = CUPnPAVConnectionActive::NewL( iServer, *this ); |
143 iConnectionActive->StartMonitoring(); |
143 iConnectionActive->StartMonitoring(); |
144 |
144 |
145 iServer.StartUp( iStatus ); // Start up the AV Control Point and wait |
145 // Startup AV control point |
146 // until it has been started. |
146 User::LeaveIfError( iServer.StartUp() ); |
147 SetActive(); |
|
148 iWait.Start(); |
|
149 __LOG1( "ConstructL - iStatus = %d", iStatus.Int() ); |
|
150 User::LeaveIfError( iStatus.Int() ); |
|
151 } |
147 } |
152 |
148 |
153 // -------------------------------------------------------------------------- |
149 // -------------------------------------------------------------------------- |
154 // CUPnPAVControllerActive::RunL |
150 // CUPnPAVControllerActive::RunL |
155 // From CActive |
151 // From CActive |
156 // -------------------------------------------------------------------------- |
152 // -------------------------------------------------------------------------- |
157 void CUPnPAVControllerActive::RunL() |
153 void CUPnPAVControllerActive::RunL() |
158 { |
154 { |
159 __LOG( "CUPnPAVControllerActive::RunL" ); |
155 __LOG( "CUPnPAVControllerActive::RunL" ); |
160 |
|
161 if( iWait.IsStarted() ) |
|
162 { |
|
163 iWait.AsyncStop(); // AV Control Point has been started, continue |
|
164 // Construction |
|
165 return; |
|
166 } |
|
167 |
156 |
168 switch( iStatus.Int() ) |
157 switch( iStatus.Int() ) |
169 { |
158 { |
170 case EAVControllerDeviceCompleted: |
159 case EAVControllerDeviceCompleted: |
171 { |
160 { |
183 if( iDiscovered == EAVDeviceDiscovered ) |
172 if( iDiscovered == EAVDeviceDiscovered ) |
184 { |
173 { |
185 // Discovered a device |
174 // Discovered a device |
186 iDeviceObserver->UPnPDeviceDiscovered( *tempDev ); |
175 iDeviceObserver->UPnPDeviceDiscovered( *tempDev ); |
187 } |
176 } |
|
177 else if ( iDiscovered == EAVDeviceIconDownloaded ) |
|
178 { |
|
179 // Device icon download completed |
|
180 iDeviceObserver->UPnPDeviceIconDownloaded( *tempDev ); |
|
181 } |
188 else |
182 else |
189 { |
183 { |
190 // Device disappeared |
184 // Device disappeared |
191 iDeviceObserver->UPnPDeviceDisappeared( *tempDev ); |
185 iDeviceObserver->UPnPDeviceDisappeared( *tempDev ); |
192 } |
186 } |
193 CleanupStack::PopAndDestroy( tempDev ); |
187 CleanupStack::PopAndDestroy( tempDev ); |
194 |
188 |
195 // Activate again if needed (it's possible to remove and set |
189 // Activate again if needed (it's possible to remove and set |
196 // the device obs from the UPnPDeviceDiscovered or |
190 // the device obs from the UPnPDeviceDiscovered or |
197 // UPnPDeviceDisappeared callbacks |
191 // UPnPDeviceDisappeared callbacks |
198 if( !IsActive() ) |
192 if( iDeviceObserver ) |
199 { |
193 { |
200 iServer.DeviceRequest( iDiscoveredPkg, iRespBufSizePkg, |
194 iServer.DeviceRequest( iDiscoveredPkg, iRespBufSizePkg, |
201 iStatus ); |
195 iStatus ); |
202 SetActive(); |
196 SetActive(); |
203 } |
197 } |
311 User::Leave( KErrDisconnected ); |
311 User::Leave( KErrDisconnected ); |
312 } |
312 } |
313 |
313 |
314 CUpnpAVDeviceList* tempList = NULL; |
314 CUpnpAVDeviceList* tempList = NULL; |
315 |
315 |
316 TPckg<TAVControllerDeviceListType> type( EAVMediaServer ); |
316 TPckgBuf<TAVControllerDeviceListType> type( EAVMediaServer ); |
317 |
317 |
318 TInt respBufSize = 0; |
318 TInt respBufSize = 0; |
319 TPckg<TInt> respBufSizePkg( respBufSize ); |
319 TPckg<TInt> respBufSizePkg( respBufSize ); |
320 TInt err = iServer.GetDeviceListSize( type, respBufSizePkg ); |
320 TInt err = iServer.GetDeviceListSize( type, respBufSizePkg ); |
321 |
321 |
414 { |
414 { |
415 User::Leave( KErrNotSupported ); |
415 User::Leave( KErrNotSupported ); |
416 } |
416 } |
417 CUPnPAVBrowsingSessionImpl* sessionImpl = |
417 CUPnPAVBrowsingSessionImpl* sessionImpl = |
418 CUPnPAVBrowsingSessionImpl::NewL( iServer, aDevice ); |
418 CUPnPAVBrowsingSessionImpl::NewL( iServer, aDevice ); |
419 iBrowsingSessions.AppendL( sessionImpl ); |
419 iBrowsingSessions.Append( sessionImpl ); |
420 return *sessionImpl; |
420 return *sessionImpl; |
421 } |
421 } |
422 |
422 |
423 // -------------------------------------------------------------------------- |
423 // -------------------------------------------------------------------------- |
424 // CUPnPAVControllerActive::StopBrowsingSession |
424 // CUPnPAVControllerActive::StopBrowsingSession |
461 { |
461 { |
462 User::Leave( KErrNotSupported ); |
462 User::Leave( KErrNotSupported ); |
463 } |
463 } |
464 CUPnPAVRenderingSessionImpl* sessionImpl = |
464 CUPnPAVRenderingSessionImpl* sessionImpl = |
465 CUPnPAVRenderingSessionImpl::NewL( iServer, aDevice ); |
465 CUPnPAVRenderingSessionImpl::NewL( iServer, aDevice ); |
466 iRenderingSessions.AppendL( sessionImpl ); |
466 iRenderingSessions.Append( sessionImpl ); |
467 return *sessionImpl; |
467 return *sessionImpl; |
468 } |
468 } |
469 |
469 |
470 // -------------------------------------------------------------------------- |
470 // -------------------------------------------------------------------------- |
471 // CUPnPAVControllerActive::StopRenderingSession |
471 // CUPnPAVControllerActive::StopRenderingSession |
508 { |
508 { |
509 User::Leave( KErrNotSupported ); |
509 User::Leave( KErrNotSupported ); |
510 } |
510 } |
511 CUPnPFileUploadSessionImpl* sessionImpl = |
511 CUPnPFileUploadSessionImpl* sessionImpl = |
512 CUPnPFileUploadSessionImpl::NewL( iServer, aDevice ); |
512 CUPnPFileUploadSessionImpl::NewL( iServer, aDevice ); |
513 iUploadSessions.AppendL( sessionImpl ); |
513 iUploadSessions.Append( sessionImpl ); |
514 return *sessionImpl; |
514 return *sessionImpl; |
515 } |
515 } |
516 |
516 |
517 // -------------------------------------------------------------------------- |
517 // -------------------------------------------------------------------------- |
518 // CUPnPAVControllerActive::StopUploadSession |
518 // CUPnPAVControllerActive::StopUploadSession |
556 { |
556 { |
557 User::Leave( KErrNotSupported ); |
557 User::Leave( KErrNotSupported ); |
558 } |
558 } |
559 CUPnPFileDownloadSessionImpl* sessionImpl = |
559 CUPnPFileDownloadSessionImpl* sessionImpl = |
560 CUPnPFileDownloadSessionImpl::NewL( iServer, aDevice ); |
560 CUPnPFileDownloadSessionImpl::NewL( iServer, aDevice ); |
561 iDownloadSessions.AppendL( sessionImpl ); |
561 iDownloadSessions.Append( sessionImpl ); |
562 return *sessionImpl; |
562 return *sessionImpl; |
563 } |
563 } |
564 |
564 |
565 // -------------------------------------------------------------------------- |
565 // -------------------------------------------------------------------------- |
566 // CUPnPAVControllerActive::StopDownloadSession |
566 // CUPnPAVControllerActive::StopDownloadSession |
586 } |
586 } |
587 |
587 |
588 } |
588 } |
589 |
589 |
590 // -------------------------------------------------------------------------- |
590 // -------------------------------------------------------------------------- |
|
591 // CUPnPAVControllerActive::GetDeviceIconL |
|
592 // -------------------------------------------------------------------------- |
|
593 HBufC8* CUPnPAVControllerActive::GetDeviceIconL( const TDesC8& aUuid ) |
|
594 { |
|
595 __LOG( "CUPnPAVControllerActive::GetDeviceIconL" ); |
|
596 |
|
597 RFile file; |
|
598 CleanupClosePushL( file ); |
|
599 User::LeaveIfError( iServer.GetDeviceIcon( aUuid, file ) ); |
|
600 TInt fileSize( 0 ); |
|
601 User::LeaveIfError( file.Size( fileSize ) ); |
|
602 HBufC8* ret = HBufC8::NewLC( fileSize ); |
|
603 TPtr8 ptr( ret->Des() ); |
|
604 User::LeaveIfError( file.Read( ptr ) ); |
|
605 CleanupStack::Pop( ret ); |
|
606 CleanupStack::PopAndDestroy( &file ); |
|
607 return ret; |
|
608 } |
|
609 |
|
610 // -------------------------------------------------------------------------- |
591 // CUPnPAVControllerActive::ConnectionLost |
611 // CUPnPAVControllerActive::ConnectionLost |
592 // Wlan disconnected |
612 // Wlan disconnected |
593 // -------------------------------------------------------------------------- |
613 // -------------------------------------------------------------------------- |
594 void CUPnPAVControllerActive::ConnectionLost() |
614 void CUPnPAVControllerActive::ConnectionLost( TBool /*aUserOriented*/ ) |
595 { |
615 { |
596 __LOG( "CUPnPAVControllerActive::ConnectionLost" ); |
616 __LOG( "CUPnPAVControllerActive::ConnectionLost" ); |
597 |
617 |
598 iAlive = EFalse; |
618 iAlive = EFalse; |
599 |
619 |