26 #include <e32svr.h> |
26 #include <e32svr.h> |
27 #include <f32file.h> |
27 #include <f32file.h> |
28 |
28 |
29 // upnp stack |
29 // upnp stack |
30 #include <upnpdevice.h> |
30 #include <upnpdevice.h> |
31 |
31 #include <upnpsettings.h> |
32 // upnpframework / avcontroller api |
32 |
|
33 // dlnasrv / avcontroller api |
33 #include "upnpavcontrollerglobals.h" |
34 #include "upnpavcontrollerglobals.h" |
34 |
35 |
35 // upnpframework / internal api's |
36 // dlnasrv / internal api's |
36 #include "upnpconnectionmonitor.h" |
37 #include "upnpconnectionmonitor.h" |
37 |
38 |
38 #include "upnpsecaccesscontroller.h" |
39 // dlnasrv / avcontroller server internal |
39 |
|
40 |
|
41 // avcontroller server internal |
|
42 #include "upnpavcontrollerserver.h" |
40 #include "upnpavcontrollerserver.h" |
43 #include "upnpavcontrollersession.h" |
41 #include "upnpavcontrollersession.h" |
44 |
|
45 #include <upnpsettings.h> |
|
46 |
|
47 #include "upnpavcontrolpoint.h" |
42 #include "upnpavcontrolpoint.h" |
48 |
|
49 |
|
50 #include "upnpavdispatcher.h" |
43 #include "upnpavdispatcher.h" |
51 #include "upnpdevicerepository.h" |
44 #include "upnpdevicerepository.h" |
52 #include "upnpavdeviceextended.h" |
45 #include "upnpavdeviceextended.h" |
53 #include "upnpaverrorhandler.h" |
46 #include "upnpaverrorhandler.h" |
|
47 #include "upnpavcpstrings.h" |
54 |
48 |
55 _LIT( KComponentLogfile, "upnpavcontrollerserver.txt" ); |
49 _LIT( KComponentLogfile, "upnpavcontrollerserver.txt" ); |
56 #include "upnplog.h" |
50 #include "upnplog.h" |
57 |
51 |
|
52 using namespace UpnpAVCPStrings; |
|
53 |
58 // CONSTANTS |
54 // CONSTANTS |
59 _LIT8( KMediaServer, "MediaServer" ); |
|
60 _LIT8( KUPnPRootDevice, "upnp:rootdevice" ); |
55 _LIT8( KUPnPRootDevice, "upnp:rootdevice" ); |
61 |
56 |
62 const TInt KMaxDepth = 4; |
57 const TUint KMyRangeCount = 3; |
63 const TInt KMaxDeviceCount = 6; |
58 |
64 |
59 const TInt KMyRanges[ KMyRangeCount ] = |
65 const TUint myRangeCount = 3; |
|
66 |
|
67 const TInt myRanges[ myRangeCount ] = |
|
68 { |
60 { |
69 0, // numbers 0-18 |
61 0, // numbers 0-18 |
70 18, // numbers 18-81 |
62 18, // numbers 18-EAVControllerRqstLast |
71 81 // numbers 81-KMaxInt |
63 EAVControllerRqstLast // numbers EAVControllerRqstLast-KMaxInt |
72 }; |
64 }; |
73 |
65 |
74 const TUint8 myElementsIndex[ myRangeCount ] = |
66 const TUint8 KMyElementsIndex[ KMyRangeCount ] = |
75 { |
67 { |
76 0, |
68 0, |
77 1, |
69 1, |
78 CPolicyServer::ENotSupported |
70 CPolicyServer::ENotSupported |
79 }; |
71 }; |
80 |
72 |
81 const CPolicyServer::TPolicyElement myElements[] = |
73 const CPolicyServer::TPolicyElement KMyElements[] = |
82 { |
74 { |
83 {_INIT_SECURITY_POLICY_C3(ECapabilityNetworkServices, |
75 {_INIT_SECURITY_POLICY_C3(ECapabilityNetworkServices, |
84 ECapabilityReadUserData, ECapabilityWriteUserData ), |
76 ECapabilityReadUserData, ECapabilityWriteUserData ), |
85 CPolicyServer::EFailClient }, |
77 CPolicyServer::EFailClient }, |
86 {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkServices), |
78 {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkServices), |
87 CPolicyServer::EFailClient} |
79 CPolicyServer::EFailClient} |
88 }; |
80 }; |
89 |
81 |
90 const CPolicyServer::TPolicy myPolicy = |
82 const CPolicyServer::TPolicy KMyPolicy = |
91 { |
83 { |
92 CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass |
84 CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass |
93 myRangeCount, |
85 KMyRangeCount, |
94 myRanges, |
86 KMyRanges, |
95 myElementsIndex, |
87 KMyElementsIndex, |
96 myElements, |
88 KMyElements, |
97 }; |
89 }; |
98 |
90 |
99 // ============================ MEMBER FUNCTIONS ============================ |
91 // ============================ MEMBER FUNCTIONS ============================ |
100 |
92 |
101 // -------------------------------------------------------------------------- |
93 // -------------------------------------------------------------------------- |
102 // CUpnpAVControllerServer::CUpnpAVControllerServer |
94 // CUpnpAVControllerServer::CUpnpAVControllerServer |
103 // See upnpavcontrollerserver.h |
95 // See upnpavcontrollerserver.h |
104 // -------------------------------------------------------------------------- |
96 // -------------------------------------------------------------------------- |
105 CUpnpAVControllerServer::CUpnpAVControllerServer( TInt aPriority ): |
97 CUpnpAVControllerServer::CUpnpAVControllerServer( TInt aPriority ): |
106 CPolicyServer( aPriority, myPolicy ), |
98 CPolicyServer( aPriority, KMyPolicy ), |
107 iShutdownTimeoutValue( KTimerCycle10 ), |
99 iShutdownTimeoutValue( KTimerCycle10 ), |
108 iServerState( EStateUndefined ) |
100 iState( EStateUndefined ) |
109 { |
101 { |
110 } |
102 } |
111 |
103 |
112 // -------------------------------------------------------------------------- |
104 // -------------------------------------------------------------------------- |
113 // CUpnpAVControllerServer::ConstructL |
105 // CUpnpAVControllerServer::ConstructL |
114 // See upnpavcontrollerserver.h |
106 // See upnpavcontrollerserver.h |
115 // -------------------------------------------------------------------------- |
107 // -------------------------------------------------------------------------- |
116 void CUpnpAVControllerServer::ConstructL() |
108 void CUpnpAVControllerServer::ConstructL() |
117 { |
109 { |
118 __LOG( "CUpnpAVControllerServer::ConstructL" ); |
110 __LOG( "CUpnpAVControllerServer::ConstructL" ); |
119 |
111 |
|
112 ChangeState( EStateStartingServer ); |
|
113 |
|
114 __LOG( "ConstructL - Starting server" ); |
|
115 |
|
116 // create av dispatcher |
120 iDispatcher = CUPnPAVDispatcher::NewL( *this ); |
117 iDispatcher = CUPnPAVDispatcher::NewL( *this ); |
121 |
118 |
122 iServerState = EStateStartingUp; |
119 // create av control point |
123 |
120 iAVControlPoint = CUpnpAVControlPoint::NewL( *iDispatcher ); |
124 CUpnpSettings* settings = CUpnpSettings::NewL( KCRUidUPnPStack ); |
121 |
125 settings->Get( CUpnpSettings::KUPnPStackIapId, iIAP ); |
122 // create device repository |
126 delete settings; |
123 iDeviceRepository = CUPnPDeviceRepository::NewL( *iAVControlPoint ); |
127 |
124 |
128 User::LeaveIfError( iMediaServer.Connect() ); |
125 iUpnpSettings = CUpnpSettings::NewL( KCRUidUPnPStack ); |
129 iMonitor = CUPnPConnectionMonitor::NewL( *this, iIAP ); |
126 iUpnpSettings->Get( CUpnpSettings::KUPnPStackIapId, iIAP ); |
|
127 |
|
128 iMonitor = CUPnPConnectionMonitor::NewL( iIAP ); |
|
129 iMonitor->SetObserver( *this ); |
130 |
130 |
131 StartL( KAVControllerName ); |
131 StartL( KAVControllerName ); |
132 |
132 |
133 iServerTimer = CUPnPAVTimer::NewL( *this, |
133 iServerTimer = CUPnPAVTimer::NewL( *this, |
134 CUPnPAVTimer::ETimerServerShutdown ); |
134 CUPnPAVTimer::ETimerServerShutdown ); |
135 |
135 |
136 iServerTimer->Start( iShutdownTimeoutValue ); |
136 iServerTimer->Start( iShutdownTimeoutValue ); |
137 |
137 |
138 iMSTimer = CUPnPAVTimer::NewL( *this, CUPnPAVTimer::ETimerMediaServer ); |
138 iIconDownloader = CUpnpDeviceIconDownloader::NewL( *this, iIAP ); |
|
139 |
139 __LOG( "CUpnpAVControllerServer::ConstructL - Finished" ); |
140 __LOG( "CUpnpAVControllerServer::ConstructL - Finished" ); |
140 } |
141 } |
141 |
142 |
142 // -------------------------------------------------------------------------- |
143 // -------------------------------------------------------------------------- |
143 // CUpnpAVControllerServer::StartUpL |
144 // CUpnpAVControllerServer::StartUpL |
145 // -------------------------------------------------------------------------- |
146 // -------------------------------------------------------------------------- |
146 void CUpnpAVControllerServer::StartUpL() |
147 void CUpnpAVControllerServer::StartUpL() |
147 { |
148 { |
148 __LOG( "CUpnpAVControllerServer::StartUpL" ); |
149 __LOG( "CUpnpAVControllerServer::StartUpL" ); |
149 |
150 |
150 TInt error = KErrNone; |
151 if( iState == EStateStartingServer ) |
151 if( iServerState == EStateStartingUp ) |
152 { |
152 { |
153 ChangeState( EStateStartingControlPoint ); |
153 __LOG( "StartUpL - Starting up" ); |
154 |
154 |
155 __LOG( "StartUpL - Starting control point" ); |
155 |
156 |
156 if( !iAVControlPoint ) |
157 // start SSPD search |
157 { |
158 TInt err = KErrNone; |
158 __LOG( "CUpnpAVControllerServer::StartUpL - CP" ); |
159 TRAP( err, iAVControlPoint->StartUpL() ); |
159 |
160 if( err == KErrNone ) |
160 TRAP( error, iAVControlPoint = CUpnpAVControlPoint::NewL( |
161 { |
161 *iDispatcher )); |
162 __LOG( "StartUpL - Searching root device" ); |
162 // If operation fails for some reason , the 10 second timeout |
163 |
163 // is completely useless and wrong in this case. |
164 iAVControlPoint->SearchL( KUPnPRootDevice ); |
164 // The server should be shut down immediately |
165 ChangeState( EStateRunning ); |
165 if( error != KErrNone ) |
|
166 { |
|
167 iShutdownTimeoutValue = 0; |
|
168 User::Leave( error ); |
|
169 } |
|
170 } |
166 } |
171 if( !iDeviceRepository ) |
167 else |
172 { |
168 { |
173 iDeviceRepository = CUPnPDeviceRepository::NewL( *iAVControlPoint ); |
169 iShutdownTimeoutValue = 0; |
|
170 User::Leave( err ); |
174 } |
171 } |
175 iServerState = EStateRunning; |
172 } |
176 } |
173 else if( iState == EStateShuttingDown ) |
177 else if( iServerState == EStateShuttingDown ) |
|
178 { |
174 { |
179 __LOG( "StartUpL - Wlan disconnected or shutting down, leave" ); |
175 __LOG( "StartUpL - Wlan disconnected or shutting down, leave" ); |
180 User::Leave( KErrDisconnected ); |
176 User::Leave( KErrDisconnected ); |
181 } |
177 } |
|
178 else if( iState == EStateStartingControlPoint ) |
|
179 { |
|
180 __LOG( "StartUpL - Already starting control point" ); |
|
181 } |
182 else |
182 else |
183 { |
183 { |
184 __LOG( "StartUpL - Server running" ); |
184 __LOG( "StartUpL - Server already running" ); |
185 } |
185 } |
186 |
186 |
187 __LOG( "StartUpL - Completed" ); |
187 __LOG( "StartUpL - Completed" ); |
188 } |
188 } |
189 |
189 |
190 void CUpnpAVControllerServer::CancelStartUp() |
190 void CUpnpAVControllerServer::CancelStartUp() |
227 delete iDispatcher; |
227 delete iDispatcher; |
228 delete iDeviceRepository; |
228 delete iDeviceRepository; |
229 |
229 |
230 delete iMonitor; |
230 delete iMonitor; |
231 delete iServerTimer; |
231 delete iServerTimer; |
232 delete iMSTimer; |
232 |
233 |
233 delete iUpnpSettings; |
234 iMediaServer.Close(); |
234 delete iIconDownloader; |
235 |
|
236 for( TInt i = 0; i < iStartMessages.Count(); i++ ) |
|
237 { |
|
238 iStartMessages[ i ]->Complete( KErrCancel ); |
|
239 } |
|
240 iStartMessages.ResetAndDestroy(); |
|
241 } |
235 } |
242 |
236 |
243 // -------------------------------------------------------------------------- |
237 // -------------------------------------------------------------------------- |
244 // CUpnpAVControllerServer::NewSessionL |
238 // CUpnpAVControllerServer::NewSessionL |
245 // See upnpavcontrollerserver.h |
239 // See upnpavcontrollerserver.h |
246 // -------------------------------------------------------------------------- |
240 // -------------------------------------------------------------------------- |
247 CSession2* CUpnpAVControllerServer::NewSessionL( const TVersion& aVersion, |
241 CSession2* CUpnpAVControllerServer::NewSessionL( const TVersion& aVersion, |
248 const RMessage2& aMessage ) const |
242 const RMessage2& /*aMessage*/ ) const |
249 { |
243 { |
250 __LOG( "CUpnpAVControllerServer::NewSessionL" ); |
244 __LOG( "CUpnpAVControllerServer::NewSessionL" ); |
251 |
245 |
252 if( iServerState == EStateShuttingDown ) |
246 TInt err = KErrNone; |
253 { |
247 |
254 __LOG( "NewSessionL - server shutting down, no new sessions \ |
248 // check if the server is shutting down |
255 are allowed at this point" ); |
249 if( iState == EStateShuttingDown ) |
256 User::Leave( KErrDisconnected ); |
250 { |
257 } |
251 __LOG( "NewSessionL - server shutting down, no new sessions are allowed at this point" ); |
258 else if( iServerState == EStateStartingUp && iSessionCount > 0 ) |
252 err = KErrDisconnected; |
259 { |
|
260 __LOG( "NewSessionL - server starting up, no new sessions \ |
|
261 are allowed at this point" ); |
|
262 User::Leave( KErrServerBusy ); |
|
263 } |
253 } |
264 |
254 |
265 // Check we're the right version |
255 // Check we're the right version |
266 if ( !User::QueryVersionSupported( TVersion( |
256 else if ( !User::QueryVersionSupported( TVersion( |
267 KAVControllerMajorVersionNumber, |
257 KAVControllerMajorVersionNumber, |
268 KAVControllerMinorVersionNumber, |
258 KAVControllerMinorVersionNumber, |
269 KAVControllerBuildVersionNumber ), |
259 KAVControllerBuildVersionNumber ), |
270 aVersion ) ) |
260 aVersion ) ) |
271 { |
261 { |
272 User::Leave( KErrNotSupported ); |
262 __LOG( "NewSessionL - incorrect client version" ); |
273 } |
263 err = KErrNotSupported; |
|
264 } |
|
265 |
|
266 // leave if error |
|
267 User::LeaveIfError( err ); |
274 |
268 |
275 // Make new session |
269 // Make new session |
276 RThread client; |
|
277 aMessage.Client(client); |
|
278 return CUpnpAVControllerSession::NewL( |
270 return CUpnpAVControllerSession::NewL( |
279 *(CUpnpAVControllerServer*)this ); |
271 const_cast<CUpnpAVControllerServer&>( *this ) ); |
280 } |
272 } |
281 |
273 |
|
274 // -------------------------------------------------------------------------- |
|
275 // CUpnpAVControllerServer::ActionResponseL |
|
276 // From MUpnpAVControlPointObserver |
|
277 // -------------------------------------------------------------------------- |
|
278 void CUpnpAVControllerServer::ActionResponseL( CUpnpAction* aAction ) |
|
279 { |
|
280 if (aAction->Name().Compare( KGetProtocolInfo ) == 0) |
|
281 { |
|
282 const TDesC8& uuid = aAction->Service().Device().Uuid(); |
|
283 CmProtocolInfoResponse( |
|
284 uuid, |
|
285 aAction->Error(), |
|
286 aAction->ArgumentValue( KSource ), |
|
287 aAction->ArgumentValue( KSink ) |
|
288 ); |
|
289 iDispatcher->UnRegister(aAction->SessionId()); |
|
290 } |
|
291 } |
|
292 |
|
293 // -------------------------------------------------------------------------- |
|
294 // CUpnpAVControllerServer::StateUpdatedL |
|
295 // From MUpnpAVControlPointObserver |
|
296 // -------------------------------------------------------------------------- |
|
297 void CUpnpAVControllerServer::StateUpdatedL( CUpnpService* /*aService*/ ) |
|
298 { |
|
299 // No implementation required |
|
300 } |
|
301 |
|
302 // -------------------------------------------------------------------------- |
|
303 // CUpnpAVControllerServer::HttpResponseL |
|
304 // From MUpnpAVControlPointObserver |
|
305 // -------------------------------------------------------------------------- |
|
306 void CUpnpAVControllerServer::HttpResponseL( CUpnpHttpMessage* /*aMessage*/ ) |
|
307 { |
|
308 // No implementation required |
|
309 } |
|
310 |
|
311 // -------------------------------------------------------------------------- |
|
312 // CUpnpAVControllerServer::DeviceDiscoveredL |
|
313 // From MUpnpAVControlPointObserver |
|
314 // -------------------------------------------------------------------------- |
|
315 void CUpnpAVControllerServer::DeviceDiscoveredL( CUpnpDevice* /*aDevice*/ ) |
|
316 { |
|
317 // No implementation required |
|
318 } |
|
319 |
|
320 // -------------------------------------------------------------------------- |
|
321 // CUpnpAVControllerServer::DeviceDisappearedL |
|
322 // From MUpnpAVControlPointObserver |
|
323 // -------------------------------------------------------------------------- |
|
324 void CUpnpAVControllerServer::DeviceDisappearedL(CUpnpDevice* /*aDevice*/) |
|
325 { |
|
326 // No implementation required |
|
327 } |
282 |
328 |
283 // -------------------------------------------------------------------------- |
329 // -------------------------------------------------------------------------- |
284 // CUpnpAVControllerServer::UPnPAVTimerCallback |
330 // CUpnpAVControllerServer::UPnPAVTimerCallback |
285 // See upnpavcontrollerserver.h |
331 // See upnpavcontrollerserver.h |
286 // -------------------------------------------------------------------------- |
332 // -------------------------------------------------------------------------- |
290 __LOG( "CUpnpAVControllerServer::UPnPAVTimerCallback" ); |
336 __LOG( "CUpnpAVControllerServer::UPnPAVTimerCallback" ); |
291 |
337 |
292 |
338 |
293 if( aType == CUPnPAVTimer::ETimerServerShutdown ) |
339 if( aType == CUPnPAVTimer::ETimerServerShutdown ) |
294 { |
340 { |
295 iServerState = EStateShuttingDown; |
341 ChangeState( EStateShutDown ); |
296 |
|
297 if( iMSTimer->IsActive() ) |
|
298 { |
|
299 // if the Media Server timer is still running for some reason |
|
300 iMSTimer->Cancel(); |
|
301 StopMediaServer(); |
|
302 } |
|
303 CActiveScheduler::Stop(); |
342 CActiveScheduler::Stop(); |
304 } |
343 } |
305 else if( aType == CUPnPAVTimer::ETimerMediaServer ) |
|
306 { |
|
307 if( iStartingMS ) |
|
308 { |
|
309 StopMediaServer(); |
|
310 TInt count = iStartMessages.Count(); |
|
311 for( TInt i = 0; i < count; i++ ) |
|
312 { |
|
313 iStartMessages[ i ]->Complete( KErrTimedOut ); |
|
314 } |
|
315 iStartMessages.ResetAndDestroy(); |
|
316 |
|
317 iStartingMS = EFalse; |
|
318 } |
|
319 else // Shutting down |
|
320 { |
|
321 StopMediaServer(); |
|
322 } |
|
323 } |
|
324 else |
|
325 { |
|
326 |
|
327 } |
|
328 } |
344 } |
329 |
345 |
330 // -------------------------------------------------------------------------- |
346 // -------------------------------------------------------------------------- |
331 // CUpnpAVControllerServer::ConnectionLost |
347 // CUpnpAVControllerServer::ConnectionLost |
332 // See upnpavcontrollerserver.h |
348 // See upnpavcontrollerserver.h |
333 // -------------------------------------------------------------------------- |
349 // -------------------------------------------------------------------------- |
334 void CUpnpAVControllerServer::ConnectionLost() |
350 void CUpnpAVControllerServer::ConnectionLost( TBool /*aUserOriented*/ ) |
335 { |
351 { |
336 __LOG( "CUpnpAVControllerServer::ConnectionLost" ); |
352 __LOG( "CUpnpAVControllerServer::ConnectionLost" ); |
337 |
353 |
338 iShutdownTimeoutValue = 0; // Set shutdown timer value to 0, we want to |
354 iShutdownTimeoutValue = 0; // Set shutdown timer value to 0, we want to |
339 // shut down the server immidiately after the last session has been |
355 // shut down the server immidiately after the last session has been |
340 // closed |
356 // closed |
341 |
357 |
342 if( iServerState == EStateRunning && iDeviceRepository ) |
358 if( iState == EStateRunning && iDeviceRepository ) |
343 { |
359 { |
344 __LOG( "ConnectionLost - Server running" ); |
360 __LOG( "ConnectionLost - Server running" ); |
|
361 |
345 iDeviceRepository->ConnectionLost(); |
362 iDeviceRepository->ConnectionLost(); |
346 |
363 |
347 CSession2* s; |
364 CSession2* s; |
348 iSessionIter.SetToFirst(); |
365 iSessionIter.SetToFirst(); |
349 while ( ( s = iSessionIter++ ) != NULL ) |
366 while ( ( s = iSessionIter++ ) != NULL ) |
405 // See upnpavcontrollerserver.h |
424 // See upnpavcontrollerserver.h |
406 // -------------------------------------------------------------------------- |
425 // -------------------------------------------------------------------------- |
407 void CUpnpAVControllerServer::PanicClient(const RMessage2& aMessage, |
426 void CUpnpAVControllerServer::PanicClient(const RMessage2& aMessage, |
408 TAVControllerServerPanic aPanic) |
427 TAVControllerServerPanic aPanic) |
409 { |
428 { |
410 __LOG( "CUpnpAVControllerServer::PanicClient" ); |
429 __LOG1( "CUpnpAVControllerServer::PanicClient %d", aPanic ); |
411 |
430 |
412 aMessage.Panic( KAVControllerName, aPanic ); |
431 aMessage.Panic( KAVControllerName, aPanic ); |
413 } |
432 } |
414 |
433 |
415 // -------------------------------------------------------------------------- |
434 // -------------------------------------------------------------------------- |
416 // CUpnpAVControllerServer::PanicServer |
435 // CUpnpAVControllerServer::PanicServer |
417 // See upnpavcontrollerserver.h |
436 // See upnpavcontrollerserver.h |
418 // -------------------------------------------------------------------------- |
437 // -------------------------------------------------------------------------- |
419 void CUpnpAVControllerServer::PanicServer(TAVControllerServerPanic aPanic) |
438 void CUpnpAVControllerServer::PanicServer(TAVControllerServerPanic aPanic) |
420 { |
439 { |
421 __LOG( "CUpnpAVControllerServer::PanicServer" ); |
440 __LOG1( "CUpnpAVControllerServer::PanicServer %d", aPanic ); |
422 |
441 |
423 User::Panic( KAVControllerName, aPanic ); |
442 User::Panic( KAVControllerName, aPanic ); |
424 } |
443 } |
425 |
444 |
426 |
445 |
447 // Start handling requests |
466 // Start handling requests |
448 CActiveScheduler::Start(); |
467 CActiveScheduler::Start(); |
449 |
468 |
450 CleanupStack::PopAndDestroy( server ); |
469 CleanupStack::PopAndDestroy( server ); |
451 CleanupStack::PopAndDestroy( activeScheduler ); |
470 CleanupStack::PopAndDestroy( activeScheduler ); |
452 |
471 |
453 } |
472 __LOG( "CUpnpAVControllerServer::ThreadFunctionL end" ); |
454 |
|
455 // -------------------------------------------------------------------------- |
|
456 // CUpnpAVControllerServer::HandleEmbeddedDiscoveredDevicesL |
|
457 // See upnpavcontrollerserver.h |
|
458 // -------------------------------------------------------------------------- |
|
459 void CUpnpAVControllerServer::HandleEmbeddedDiscoveredDevicesL( |
|
460 CUpnpDevice& aDevice, TInt aDepth ) |
|
461 { |
|
462 __LOG( "CUpnpAVControllerServer::HandleEmbeddedDiscoveredDevicesL" ); |
|
463 |
|
464 if( aDepth <= KMaxDepth && iDiscoveredDeviceCount <= KMaxDeviceCount ) |
|
465 { |
|
466 RPointerArray<CUpnpDevice>& devList = aDevice.DeviceList(); |
|
467 TInt count = devList.Count(); |
|
468 for( TInt i = 0; i < count; i++ ) |
|
469 { |
|
470 iDeviceRepository->AddDeviceL( *devList[ i ] ); |
|
471 TInt sessionId = iAVControlPoint->CmProtocolInfoActionL( |
|
472 devList[ i ]->Uuid() ); |
|
473 iDiscoveredDeviceCount++; |
|
474 |
|
475 HandleEmbeddedDiscoveredDevicesL( *devList[ i ], ++aDepth ); |
|
476 } |
|
477 } |
|
478 else |
|
479 { |
|
480 __LOG( "HandleEmbeddedDiscoveredDevicesL - max depth \ |
|
481 or count reached" ); |
|
482 } |
|
483 } |
|
484 |
|
485 // -------------------------------------------------------------------------- |
|
486 // CUpnpAVControllerServer::HandleEmbeddedDisappearedDevicesL |
|
487 // See upnpavcontrollerserver.h |
|
488 // -------------------------------------------------------------------------- |
|
489 void CUpnpAVControllerServer::HandleEmbeddedDisappearedDevicesL( |
|
490 CUpnpDevice& aDevice, TInt aDepth ) |
|
491 { |
|
492 __LOG( "CUpnpAVControllerServer::HandleEmbeddedDisappearedDevicesL" ); |
|
493 |
|
494 if( aDepth <= KMaxDepth && iDisappearedDeviceCount <= KMaxDeviceCount ) |
|
495 { |
|
496 RPointerArray<CUpnpDevice>& devList = aDevice.DeviceList(); |
|
497 TInt count = devList.Count(); |
|
498 for( TInt i = 0; i < count; i++ ) |
|
499 { |
|
500 CUpnpAVDeviceExtended& ext = iDeviceRepository->FindDeviceL( |
|
501 devList[ i ]->Uuid() ); |
|
502 |
|
503 CSession2* s; |
|
504 iSessionIter.SetToFirst(); |
|
505 while ( ( s = iSessionIter++ ) != NULL ) |
|
506 { |
|
507 CUpnpAVControllerSession* sess = |
|
508 static_cast<CUpnpAVControllerSession*>(s); |
|
509 if( sess ) |
|
510 { |
|
511 sess->DeviceDisappearedL( ext ); |
|
512 } |
|
513 }; |
|
514 |
|
515 iDeviceRepository->Remove( ext.Uuid() ); |
|
516 |
|
517 iDisappearedDeviceCount++; |
|
518 |
|
519 HandleEmbeddedDisappearedDevicesL( *devList[ i ], ++aDepth ); |
|
520 } |
|
521 } |
|
522 else |
|
523 { |
|
524 __LOG( "HandleEmbeddedDisappearedDevicesL - max depth \ |
|
525 or count reached" ); |
|
526 } |
|
527 } |
|
528 |
|
529 // -------------------------------------------------------------------------- |
|
530 // CUpnpAVControllerServer::StopMediaServer |
|
531 // See upnpavcontrollerserver.h |
|
532 // -------------------------------------------------------------------------- |
|
533 void CUpnpAVControllerServer::StopMediaServer() |
|
534 { |
|
535 __LOG( "CUpnpAVControllerServer::StopMediaServer" ); |
|
536 |
|
537 if( iShutdownTimeoutValue ) |
|
538 { |
|
539 __LOG( "StopMediaServer - normal shutdown" ); |
|
540 iMediaServer.Stop( RUpnpMediaServerClient::EStopNormal ); |
|
541 } |
|
542 else |
|
543 { |
|
544 __LOG( "StopMediaServer - silent shutdown" ); |
|
545 iMediaServer.Stop( RUpnpMediaServerClient::EStopSilent ); |
|
546 } |
|
547 } |
473 } |
548 |
474 |
549 // -------------------------------------------------------------------------- |
475 // -------------------------------------------------------------------------- |
550 // CUpnpAVControllerServer::ThreadFunction |
476 // CUpnpAVControllerServer::ThreadFunction |
551 // See upnpavcontrollerserver.h |
477 // See upnpavcontrollerserver.h |
574 delete cleanupStack; |
500 delete cleanupStack; |
575 cleanupStack = NULL; |
501 cleanupStack = NULL; |
576 |
502 |
577 __UHEAP_MARKEND; |
503 __UHEAP_MARKEND; |
578 |
504 |
|
505 __LOG1( "CUpnpAVControllerServer::ThreadFunction end %d", err ); |
|
506 |
579 return err; |
507 return err; |
580 } |
508 } |
581 |
509 |
582 // -------------------------------------------------------------------------- |
510 // -------------------------------------------------------------------------- |
583 // CUpnpAVControllerServer::IncrementSessions |
511 // CUpnpAVControllerServer::IncrementSessions |
584 // See upnpavcontrollerserver.h |
512 // See upnpavcontrollerserver.h |
585 // -------------------------------------------------------------------------- |
513 // -------------------------------------------------------------------------- |
586 void CUpnpAVControllerServer::IncrementSessions() |
514 void CUpnpAVControllerServer::IncrementSessions() |
587 { |
515 { |
588 __LOG( "CUpnpAVControllerServer::IncrementSessions" ); |
516 __LOG2( "CUpnpAVControllerServer::IncrementSessions, %d, %d", |
|
517 iSessionCount, iState ); |
589 |
518 |
590 iSessionCount++; |
519 iSessionCount++; |
591 if( iServerTimer->IsActive() ) |
520 if( iServerTimer->IsActive() ) |
592 { |
521 { |
593 iServerTimer->Cancel(); |
522 iServerTimer->Cancel(); |
594 __LOG( "IncrementSessions - make a search" ); |
523 } |
595 if( iAVControlPoint ) |
524 } |
596 { |
525 |
597 TRAP_IGNORE( iAVControlPoint->SearchL( KUPnPRootDevice ) ); |
526 // -------------------------------------------------------------------------- |
|
527 // CUpnpAVControllerServer::DecrementSessions |
|
528 // See upnpavcontrollerserver.h |
|
529 // -------------------------------------------------------------------------- |
|
530 void CUpnpAVControllerServer::DecrementSessions() |
|
531 { |
|
532 __LOG2( "CUpnpAVControllerServer::DecrementSessions, %d, %d", |
|
533 iSessionCount, iState ); |
|
534 |
|
535 iSessionCount--; |
|
536 if( iState != EStateShutDown ) |
|
537 { |
|
538 if ( iSessionCount <= 0 ) |
|
539 { |
|
540 if( iServerTimer->IsActive() ) |
|
541 { |
|
542 iServerTimer->Cancel(); |
|
543 } |
|
544 iServerTimer->Start( iShutdownTimeoutValue ); |
598 } |
545 } |
599 } |
|
600 } |
|
601 |
|
602 // -------------------------------------------------------------------------- |
|
603 // CUpnpAVControllerServer::DecrementSessions |
|
604 // See upnpavcontrollerserver.h |
|
605 // -------------------------------------------------------------------------- |
|
606 void CUpnpAVControllerServer::DecrementSessions() |
|
607 { |
|
608 __LOG( "CUpnpAVControllerServer::DecrementSessions" ); |
|
609 |
|
610 iSessionCount--; |
|
611 if ( iSessionCount <= 0 ) |
|
612 { |
|
613 if( iServerTimer->IsActive() ) |
|
614 { |
|
615 iServerTimer->Cancel(); |
|
616 } |
|
617 iServerTimer->Start( iShutdownTimeoutValue ); |
|
618 } |
546 } |
619 } |
547 } |
620 |
548 |
621 // -------------------------------------------------------------------------- |
549 // -------------------------------------------------------------------------- |
622 // CUpnpAVControllerServer::DeviceDiscoveredL |
550 // CUpnpAVControllerServer::DeviceDiscoveredL |
624 // -------------------------------------------------------------------------- |
552 // -------------------------------------------------------------------------- |
625 void CUpnpAVControllerServer::DeviceDiscoveredL( CUpnpDevice& aDevice ) |
553 void CUpnpAVControllerServer::DeviceDiscoveredL( CUpnpDevice& aDevice ) |
626 { |
554 { |
627 __LOG( "CUpnpAVControllerServer::DeviceDiscoveredL" ); |
555 __LOG( "CUpnpAVControllerServer::DeviceDiscoveredL" ); |
628 |
556 |
629 if( aDevice.Local() && aDevice.DeviceType().Find( KMediaServer ) |
|
630 != KErrNotFound ) |
|
631 { |
|
632 // It's the local S60 MS |
|
633 |
|
634 if( iStartingMS ) |
|
635 { |
|
636 iMSTimer->Cancel(); |
|
637 } |
|
638 CUpnpSecAccessController* accessController = |
|
639 CUpnpSecAccessController::NewL(); |
|
640 __LOG( "CUpnpAVControllerServer::DeviceDiscoveredL \ |
|
641 adding the local media server IP to the list of authorized addresses." ); |
|
642 |
|
643 accessController->AddAllowedAddress( aDevice.Address() ); |
|
644 delete accessController; |
|
645 accessController = NULL; |
|
646 } |
|
647 |
|
648 iDeviceRepository->AddDeviceL( aDevice ); |
557 iDeviceRepository->AddDeviceL( aDevice ); |
649 TInt sessionId = iAVControlPoint->CmProtocolInfoActionL( |
558 |
650 aDevice.Uuid() ); |
559 CUpnpAction* action = iAVControlPoint->CreateActionLC( |
651 iDiscoveredDeviceCount = 1; // First (root) device |
560 &aDevice, KConnectionManager, KGetProtocolInfo ); |
652 |
561 |
|
562 iAVControlPoint->SendL( action ); // takes ownership |
|
563 CleanupStack::Pop( action ); |
|
564 iDispatcher->RegisterL( action->SessionId(), *this ); |
653 } |
565 } |
654 |
566 |
655 // -------------------------------------------------------------------------- |
567 // -------------------------------------------------------------------------- |
656 // CUpnpAVControllerServer::DeviceDisappearedL |
568 // CUpnpAVControllerServer::DeviceDisappearedL |
657 // See upnpavcontrollerserver.h |
569 // See upnpavcontrollerserver.h |
658 // -------------------------------------------------------------------------- |
570 // -------------------------------------------------------------------------- |
659 void CUpnpAVControllerServer::DeviceDisappearedL( CUpnpDevice& aDevice ) |
571 void CUpnpAVControllerServer::DeviceDisappearedL( CUpnpDevice& aDevice ) |
660 { |
572 { |
661 __LOG( "CUpnpAVControllerServer::DeviceDisappearedL" ); |
573 __LOG( "CUpnpAVControllerServer::DeviceDisappearedL" ); |
662 |
|
663 if( aDevice.Local() && aDevice.DeviceType().Find( KMediaServer ) |
|
664 != KErrNotFound ) |
|
665 { |
|
666 // It's the local S60 MS |
|
667 iMediaServerOnline = EFalse; |
|
668 } |
|
669 |
574 |
670 // Get a corresponding device from the device repository |
575 // Get a corresponding device from the device repository |
671 CUpnpAVDeviceExtended& tmp = iDeviceRepository->FindDeviceL( |
576 CUpnpAVDeviceExtended& tmp = iDeviceRepository->FindDeviceL( |
672 aDevice.Uuid() ); |
577 aDevice.Uuid() ); |
673 |
578 |
712 sess->DeviceDisappearedL( tmp ); |
618 sess->DeviceDisappearedL( tmp ); |
713 } |
619 } |
714 } |
620 } |
715 // Remove from the device repository |
621 // Remove from the device repository |
716 iDeviceRepository->Remove( aUuid ); |
622 iDeviceRepository->Remove( aUuid ); |
717 iDisappearedDeviceCount = 1; |
623 // Ensure that icon download is canceled |
|
624 iIconDownloader->CancelDownload( aUuid ); |
|
625 |
718 __LOG( "CUpnpAVControllerServer::DeviceDisappearedL uid End" ); |
626 __LOG( "CUpnpAVControllerServer::DeviceDisappearedL uid End" ); |
719 } |
627 } |
720 |
628 |
721 // -------------------------------------------------------------------------- |
629 // -------------------------------------------------------------------------- |
722 // CUpnpAVControllerServer::StartMediaServerL |
|
723 // See upnpavcontrollerserver.h |
|
724 // -------------------------------------------------------------------------- |
|
725 void CUpnpAVControllerServer::StartMediaServerL( const RMessage2& aMessage ) |
|
726 { |
|
727 __LOG( "CUpnpAVControllerServer::StartMediaServerL" ); |
|
728 |
|
729 if( iMediaServerOnline ) |
|
730 { |
|
731 // Started already, complete the msg |
|
732 iMSTimer->Cancel(); |
|
733 aMessage.Complete( EAVControllerStartMediaServerCompleted ); |
|
734 iServerUserCount++; |
|
735 } |
|
736 else |
|
737 { |
|
738 // Start the media server and timer |
|
739 if( iStartMessages.Count() > 0 ) |
|
740 { |
|
741 RMessage2* message = new (ELeave) RMessage2( aMessage ); |
|
742 iStartMessages.AppendL( message ); |
|
743 } |
|
744 else |
|
745 { |
|
746 // Check if the stack's security is enabled |
|
747 TBool upnpSecurityEnabled = EFalse; |
|
748 TRAPD( secCheckError, upnpSecurityEnabled = |
|
749 CUpnpSecAccessController::IsMediaServerSecurityEnabledL() ); |
|
750 |
|
751 // If the security is not enabled, enable it now |
|
752 if( secCheckError == KErrNone && |
|
753 !upnpSecurityEnabled ) |
|
754 { |
|
755 TRAP_IGNORE( |
|
756 CUpnpSecAccessController::EnableMediaServerSecurityL() ); |
|
757 } |
|
758 |
|
759 RMessage2* message = new(ELeave) RMessage2( aMessage ); |
|
760 iStartMessages.AppendL( message ); |
|
761 User::LeaveIfError( iMediaServer.Start() ); |
|
762 iMSTimer->Start( iShutdownTimeoutValue ); |
|
763 iStartingMS = ETrue; |
|
764 } |
|
765 } |
|
766 } |
|
767 |
|
768 // -------------------------------------------------------------------------- |
|
769 // CUpnpAVControllerServer::CancelStartMediaServerL |
|
770 // See upnpavcontrollerserver.h |
|
771 // -------------------------------------------------------------------------- |
|
772 void CUpnpAVControllerServer::CancelStartMediaServerL( |
|
773 const RMessage2& aMessage ) |
|
774 { |
|
775 __LOG( "CUpnpAVControllerServer::CancelStartMediaServerL" ); |
|
776 |
|
777 if( !iMSActivatedBeforeStart ) |
|
778 { |
|
779 StopMediaServer(); |
|
780 } |
|
781 |
|
782 TInt count = iStartMessages.Count(); |
|
783 for( TInt i = 0; i < count; i++ ) |
|
784 { |
|
785 iStartMessages[ i ]->Complete( KErrCancel ); |
|
786 } |
|
787 iStartMessages.ResetAndDestroy(); |
|
788 iMSTimer->Cancel(); |
|
789 |
|
790 aMessage.Complete( KErrNone ); |
|
791 |
|
792 } |
|
793 |
|
794 // -------------------------------------------------------------------------- |
|
795 // CUpnpAVControllerServer::StopMediaServerL |
|
796 // See upnpavcontrollerserver.h |
|
797 // -------------------------------------------------------------------------- |
|
798 void CUpnpAVControllerServer::StopMediaServerL( const RMessage2& aMessage ) |
|
799 { |
|
800 __LOG( "CUpnpAVControllerServer::StopMediaServerL" ); |
|
801 |
|
802 if( iMediaServerOnline ) |
|
803 { |
|
804 iServerUserCount--; |
|
805 if( iServerUserCount <= 0 ) |
|
806 { |
|
807 if( !iMSActivatedBeforeStart ) |
|
808 { |
|
809 iMSTimer->Start( iShutdownTimeoutValue ); |
|
810 } |
|
811 iServerUserCount = 0; |
|
812 } |
|
813 } |
|
814 aMessage.Complete( KErrNone ); |
|
815 } |
|
816 |
|
817 // -------------------------------------------------------------------------- |
|
818 // CUpnpAVControllerServer::MSServicesInUse |
|
819 // See upnpavcontrollerserver.h |
|
820 // -------------------------------------------------------------------------- |
|
821 void CUpnpAVControllerServer::MSServicesInUse( const RMessage2& aMessage ) |
|
822 { |
|
823 if( iServerUserCount > 0 || iStartingMS |
|
824 || iMSTimer->IsActive() |
|
825 ) |
|
826 { |
|
827 TPckg<TBool> resp0( ETrue ); |
|
828 aMessage.Write( 0, resp0 ); |
|
829 } |
|
830 else |
|
831 { |
|
832 TPckg<TBool> resp0( EFalse ); |
|
833 aMessage.Write( 0, resp0 ); |
|
834 } |
|
835 aMessage.Complete( KErrNone ); |
|
836 } |
|
837 |
|
838 // -------------------------------------------------------------------------- |
|
839 // CUpnpAVControllerServer::CmProtocolInfoResponse |
630 // CUpnpAVControllerServer::CmProtocolInfoResponse |
840 // See upnpavcontrollerserver.h |
631 // See upnpavcontrollerserver.h |
841 // -------------------------------------------------------------------------- |
632 // -------------------------------------------------------------------------- |
842 void CUpnpAVControllerServer::CmProtocolInfoResponse( const TDesC8& aUuid, |
633 void CUpnpAVControllerServer::CmProtocolInfoResponse( const TDesC8& aUuid, |
843 TInt /*aSessionId*/, TInt aErr, const TDesC8& aSource, |
634 TInt aErr, const TDesC8& aSource, |
844 const TDesC8& aSink ) |
635 const TDesC8& aSink ) |
845 { |
636 { |
846 __LOG1( "CUpnpAVControllerServer::CmProtocolInfoResponse, \ |
637 __LOG1( "CUpnpAVControllerServer::CmProtocolInfoResponse, \ |
847 aErr = %d", aErr ); |
638 aErr = %d", aErr ); |
848 |
639 |
856 aUuid, aSource, aSink ) ); |
647 aUuid, aSource, aSink ) ); |
857 |
648 |
858 if( err == KErrNone ) |
649 if( err == KErrNone ) |
859 { |
650 { |
860 // Device discovered and protocolinfo was retrieved successfully |
651 // Device discovered and protocolinfo was retrieved successfully |
|
652 // Start icon download if icon url is defined |
|
653 TPtrC8 iconUrl( dev->IconUrl() ); |
|
654 if ( iconUrl.Length() > 0 ) |
|
655 { |
|
656 TRAP_IGNORE( iIconDownloader->StartDownloadL( dev->Uuid(), iconUrl ) ); |
|
657 } |
861 CSession2* s; |
658 CSession2* s; |
862 iSessionIter.SetToFirst(); |
659 iSessionIter.SetToFirst(); |
863 while ( ( s = iSessionIter++ ) != NULL ) |
660 while ( ( s = iSessionIter++ ) != NULL ) |
864 { |
661 { |
865 CUpnpAVControllerSession* sess = |
662 CUpnpAVControllerSession* sess = |
866 static_cast<CUpnpAVControllerSession*>(s); |
663 static_cast<CUpnpAVControllerSession*>(s); |
867 if( sess ) |
664 if( sess ) |
868 { |
665 { |
869 TRAP_IGNORE( sess->DeviceDiscoveredL( *dev ) ); |
666 TRAP_IGNORE( sess->DeviceDiscoveredL( *dev ) ); |
870 } |
667 } |
871 }; |
668 }; |
872 |
|
873 if( dev->Local() ) |
|
874 { |
|
875 iMediaServerOnline = ETrue; |
|
876 |
|
877 if( iStartingMS ) |
|
878 { |
|
879 TInt count = iStartMessages.Count(); |
|
880 for( TInt i = 0; i < count; i++ ) |
|
881 { |
|
882 iStartMessages[ i ]->Complete( |
|
883 EAVControllerStartMediaServerCompleted ); |
|
884 iServerUserCount++; |
|
885 } |
|
886 iStartMessages.ResetAndDestroy(); |
|
887 |
|
888 iStartingMS = EFalse; |
|
889 } |
|
890 else |
|
891 { |
|
892 __LOG( "Sharing was enabled before AVC server start" ); |
|
893 iMSActivatedBeforeStart = ETrue; |
|
894 } |
|
895 |
|
896 } |
|
897 } |
669 } |
898 else |
670 else |
899 { |
671 { |
900 // Could not add protocolinfo, it's invalid or corrupted |
672 // Could not add protocolinfo, it's invalid or corrupted |
901 // Device cannot be used |
673 // Device cannot be used |
908 // Device cannot be used |
680 // Device cannot be used |
909 HandleFailedProtocolInfoResponse( aUuid ); |
681 HandleFailedProtocolInfoResponse( aUuid ); |
910 } |
682 } |
911 } |
683 } |
912 |
684 |
|
685 // -------------------------------------------------------------------------- |
|
686 // CUpnpAVControllerServer::TransferDeviceIconFileToClientL |
|
687 // See upnpavcontrollerserver.h |
|
688 // -------------------------------------------------------------------------- |
|
689 void CUpnpAVControllerServer::TransferDeviceIconFileToClientL( |
|
690 const RMessage2& aMessage, TInt aSlot, const TDesC8& aDeviceUuid ) |
|
691 { |
|
692 return iIconDownloader->TransferFileToClientL( aMessage, aSlot, aDeviceUuid ); |
|
693 } |
|
694 |
|
695 // -------------------------------------------------------------------------- |
|
696 // CUpnpAVControllerServer::HandleFailedProtocolInfoResponse |
|
697 // See upnpavcontrollerserver.h |
|
698 // -------------------------------------------------------------------------- |
913 void CUpnpAVControllerServer::HandleFailedProtocolInfoResponse( |
699 void CUpnpAVControllerServer::HandleFailedProtocolInfoResponse( |
914 const TDesC8& aUuid ) |
700 const TDesC8& aUuid ) |
915 { |
701 { |
916 __LOG( "CUpnpAVControllerServer::HandleFailedProtocolInfoResponse" ); |
702 __LOG( "CUpnpAVControllerServer::HandleFailedProtocolInfoResponse" ); |
917 |
703 |
918 CUpnpAVDeviceExtended* dev = NULL; |
704 iDeviceRepository->Remove( aUuid ); |
919 TRAPD( err, dev = &iDeviceRepository->FindDeviceL( aUuid ) ) |
705 } |
920 if( err == KErrNone ) |
706 |
921 { |
707 // -------------------------------------------------------------------------- |
922 if( iStartingMS && dev->Local() ) |
708 // CUpnpAVControllerServer::ChangeState |
923 { |
709 // See upnpavcontrollerserver.h |
924 __LOG( "HandleFailedProtocolInfoResponse - local, stop and \ |
710 // -------------------------------------------------------------------------- |
925 complete messages" ); |
711 void CUpnpAVControllerServer::ChangeState( TAVControllerServerState aState ) |
926 |
712 { |
927 StopMediaServer(); |
713 __LOG( "CUpnpAVControllerServer::ChangeState" ); |
928 |
714 |
929 TInt count = iStartMessages.Count(); |
715 if( iState != aState ) |
930 for( TInt i = 0; i < count; i++ ) |
716 { |
|
717 __LOG2( "ChangeState: Changing state [%d] -> [%d]", |
|
718 iState, aState ); |
|
719 iState = aState; |
|
720 } |
|
721 } |
|
722 |
|
723 // -------------------------------------------------------------------------- |
|
724 // CUpnpAVControllerServer::ControlPoint |
|
725 // See upnpavcontrollerserver.h |
|
726 // -------------------------------------------------------------------------- |
|
727 CUpnpAVControlPoint& CUpnpAVControllerServer::ControlPoint() |
|
728 { |
|
729 return *iAVControlPoint; |
|
730 } |
|
731 |
|
732 // -------------------------------------------------------------------------- |
|
733 // CUpnpAVControllerServer::Dispatcher |
|
734 // See upnpavcontrollerserver.h |
|
735 // -------------------------------------------------------------------------- |
|
736 CUPnPAVDispatcher& CUpnpAVControllerServer::Dispatcher() |
|
737 { |
|
738 return *iDispatcher; |
|
739 } |
|
740 |
|
741 // -------------------------------------------------------------------------- |
|
742 // CUpnpAVControllerServer::DeviceRepository |
|
743 // See upnpavcontrollerserver.h |
|
744 // -------------------------------------------------------------------------- |
|
745 CUPnPDeviceRepository& CUpnpAVControllerServer::DeviceRepository() |
|
746 { |
|
747 return *iDeviceRepository; |
|
748 } |
|
749 |
|
750 // -------------------------------------------------------------------------- |
|
751 // CUpnpAVControllerServer::IAP |
|
752 // See upnpavcontrollerserver.h |
|
753 // -------------------------------------------------------------------------- |
|
754 TInt CUpnpAVControllerServer::IAP() |
|
755 { |
|
756 return iIAP; |
|
757 } |
|
758 |
|
759 // -------------------------------------------------------------------------- |
|
760 // CUpnpAVControllerServer::DeviceIconDownloadedL |
|
761 // See upnpavcontrollerserver.h |
|
762 // -------------------------------------------------------------------------- |
|
763 void CUpnpAVControllerServer::DeviceIconDownloadedL( const TDesC8& aDeviceUuid, |
|
764 TInt aError ) |
|
765 { |
|
766 __LOG( "CUpnpAVControllerServer::DeviceIconDownloadedL" ); |
|
767 if ( aError == KErrNone ) |
|
768 { |
|
769 // Get a corresponding device from the device repository |
|
770 CUpnpAVDeviceExtended& tmp = iDeviceRepository->FindDeviceL( |
|
771 aDeviceUuid ); |
|
772 // Let the clients know about downloaded icon |
|
773 CSession2* s; |
|
774 iSessionIter.SetToFirst(); |
|
775 while ( ( s = iSessionIter++ ) != NULL ) |
|
776 { |
|
777 CUpnpAVControllerSession* sess = |
|
778 static_cast<CUpnpAVControllerSession*>( s ); |
|
779 if ( sess ) |
931 { |
780 { |
932 iStartMessages[ i ]->Complete( err ); |
781 sess->DeviceIconDownloadedL( tmp ); |
933 iServerUserCount++; |
|
934 } |
782 } |
935 iStartMessages.ResetAndDestroy(); |
783 } |
936 |
784 } |
937 iStartingMS = EFalse; |
785 __LOG( "CUpnpAVControllerServer::DeviceIconDownloadedL End" ); |
938 } |
786 } |
939 } |
787 |
940 else |
|
941 { |
|
942 // Not found, no can do |
|
943 __LOG( "HandleFailedProtocolInfoResponse - not found" ); |
|
944 } |
|
945 iDeviceRepository->Remove( aUuid ); |
|
946 } |
|
947 |
|
948 // -------------------------------------------------------------------------- |
|
949 // CUpnpAVControllerServer::ControlPoint |
|
950 // See upnpavcontrollerserver.h |
|
951 // -------------------------------------------------------------------------- |
|
952 CUpnpAVControlPoint& CUpnpAVControllerServer::ControlPoint() |
|
953 { |
|
954 return *iAVControlPoint; |
|
955 } |
|
956 |
|
957 // -------------------------------------------------------------------------- |
|
958 // CUpnpAVControllerServer::MediaServer |
|
959 // See upnpavcontrollerserver.h |
|
960 // -------------------------------------------------------------------------- |
|
961 RUpnpMediaServerClient& CUpnpAVControllerServer::MediaServer() |
|
962 { |
|
963 return iMediaServer; |
|
964 } |
|
965 |
|
966 // -------------------------------------------------------------------------- |
|
967 // CUpnpAVControllerServer::Dispatcher |
|
968 // See upnpavcontrollerserver.h |
|
969 // -------------------------------------------------------------------------- |
|
970 CUPnPAVDispatcher& CUpnpAVControllerServer::Dispatcher() |
|
971 { |
|
972 return *iDispatcher; |
|
973 } |
|
974 |
|
975 // -------------------------------------------------------------------------- |
|
976 // CUpnpAVControllerServer::DeviceRepository |
|
977 // See upnpavcontrollerserver.h |
|
978 // -------------------------------------------------------------------------- |
|
979 CUPnPDeviceRepository& CUpnpAVControllerServer::DeviceRepository() |
|
980 { |
|
981 return *iDeviceRepository; |
|
982 } |
|
983 |
|
984 TInt CUpnpAVControllerServer::IAP() |
|
985 { |
|
986 return iIAP; |
|
987 } |
|
988 |
|
989 // ============================= LOCAL FUNCTIONS ============================ |
788 // ============================= LOCAL FUNCTIONS ============================ |
990 |
789 |
991 // -------------------------------------------------------------------------- |
790 // -------------------------------------------------------------------------- |
992 // E32Main entry point. |
791 // E32Main entry point. |
993 // Returns: KErrNone |
792 // Returns: KErrNone |