|
1 /** @file |
|
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: Declares ControlPoint class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <e32cons.h> |
|
23 #include <e32std.h> |
|
24 #include <in_sock.h> |
|
25 #include <charconv.h> |
|
26 #include <utf.h> |
|
27 |
|
28 #include "upnpdispatcher.h" |
|
29 #include "upnphttpmessage.h" |
|
30 #include "upnpsoapmessage.h" |
|
31 #include "upnpicon.h" |
|
32 #include "upnpdevice.h" |
|
33 #include "upnpstring.h" |
|
34 #include "upnphttpmessagefactory.h" |
|
35 #include "upnpsoapmessagefactory.h" |
|
36 #include "upnpgenamessagefactory.h" |
|
37 #include "upnpserviceinfo.h" |
|
38 #include "upnpcontrolpoint.h" |
|
39 #include "upnpcommonupnplits.h" |
|
40 #include "upnpcons.h" |
|
41 #include "upnpcpbhttpmessagecontroller.h" |
|
42 #include "upnpcpbcurrenthttpclient.h" |
|
43 #include "upnpcpbdescriptionagent.h" |
|
44 #include "upnpcpbdiscoveryagent.h" |
|
45 #include "upnpcpbdevicerepository.h" |
|
46 #include "upnpcpstackrequestor.h" |
|
47 #include "upnpcontenthandlerscontroller.h" |
|
48 #include "upnpconnectionmanagernetworkeventprovider.h" |
|
49 #include "upnpcpbinitialeventretryhandler.h" |
|
50 |
|
51 #define KLogFile _L("UPnPCP.txt") |
|
52 #include "upnpcustomlog.h" |
|
53 |
|
54 using namespace UpnpHTTP; |
|
55 |
|
56 static const TInt KDTargetDeviceTypesGranularity = 1; |
|
57 |
|
58 // ============================ MEMBER FUNCTIONS =============================== |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CUpnpControlPoint::CUpnpControlPoint |
|
62 // C++ default constructor |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 EXPORT_C CUpnpControlPoint::CUpnpControlPoint() |
|
66 : iPredefinedStackRequestor( NULL ), iPredefinedHttpRequestor( NULL ) |
|
67 { |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CUpnpControlPoint::CUpnpControlPoint |
|
72 // C++ constructor for internal, automated test cases use |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 EXPORT_C CUpnpControlPoint::CUpnpControlPoint( |
|
76 MUpnpCpStackRequestor& aStackRequestor, MUpnpCpHttpRequestor& aHttpRequestor ) |
|
77 : iPredefinedStackRequestor( &aStackRequestor ), |
|
78 iPredefinedHttpRequestor( &aHttpRequestor ) |
|
79 { |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CUpnpControlPoint::~CUpnpControlPoint |
|
84 // C++ default destructor |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 EXPORT_C CUpnpControlPoint::~CUpnpControlPoint() |
|
88 { |
|
89 LOG_FUNC_NAME; |
|
90 |
|
91 delete iCpbHttpClient; |
|
92 |
|
93 iSubscribedServicesInfos.ResetAndDestroy(); |
|
94 iActionList.ResetAndDestroy(); |
|
95 |
|
96 if ( iTargetDeviceTypes ) |
|
97 { |
|
98 iTargetDeviceTypes->Reset(); |
|
99 delete iTargetDeviceTypes; |
|
100 } |
|
101 |
|
102 delete iDescriptionAgent; |
|
103 delete iDiscoveryAgent; |
|
104 |
|
105 delete iNetworkEventProvider; |
|
106 |
|
107 delete iSaxController; |
|
108 delete iDeviceRepository; |
|
109 delete iInitialEventRetry; |
|
110 LOGS("CUpnpControlPoint::~CUpnpControlPoint - END"); |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CUpnpControlPoint::ConstructL |
|
115 // Two-phased constructor |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 EXPORT_C void CUpnpControlPoint::ConstructL( const CDesC8Array& aTargetDeviceTypes ) |
|
119 { |
|
120 iNetworkEventProvider = CUpnpConnectionManagerNetworkEventProvider::NewL( *this ); |
|
121 |
|
122 iCpbHttpClient = |
|
123 CUpnpCpbCurrentHttpClient::NewL( |
|
124 *this, iPredefinedHttpRequestor, iPredefinedStackRequestor ); |
|
125 iTargetDeviceTypes = new( ELeave ) CDesC8ArrayFlat( KDTargetDeviceTypesGranularity ); |
|
126 |
|
127 for ( TInt i( 0 ); i < aTargetDeviceTypes.Count(); i++ ) |
|
128 { |
|
129 iTargetDeviceTypes->AppendL( aTargetDeviceTypes[i]); |
|
130 } |
|
131 iDeviceRepository = CUpnpCpbDeviceRepository::NewL(*iTargetDeviceTypes); |
|
132 |
|
133 iSaxController = CUpnpContentHandlersController::NewL(); |
|
134 iDiscoveryAgent = CUpnpCpbDiscoveryAgent::NewL( *iCpbHttpClient ); |
|
135 iDescriptionAgent = |
|
136 CUpnpCpbDescriptionAgent::NewL( |
|
137 *this, *iCpbHttpClient, *iDeviceRepository ); |
|
138 |
|
139 iInitialEventRetry = new( ELeave ) CUpnpCpbInitialEventRetryHandler( *this ); |
|
140 |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CUpnpControlPoint::ConstructL |
|
145 // Two-phased constructor |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 EXPORT_C void CUpnpControlPoint::ConstructL( const TDesC8& aTargetDeviceType ) |
|
149 { |
|
150 CDesC8ArrayFlat* targetDeviceTypes = |
|
151 new (ELeave) CDesC8ArrayFlat( KDTargetDeviceTypesGranularity ); |
|
152 CleanupStack::PushL( targetDeviceTypes ); |
|
153 targetDeviceTypes->AppendL( aTargetDeviceType ); |
|
154 ConstructL( *targetDeviceTypes ); |
|
155 CleanupStack::PopAndDestroy( targetDeviceTypes ); |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CUpnpControlPoint::SearchL |
|
160 // Search intresting Device Types from network |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 EXPORT_C void CUpnpControlPoint::SearchL( const TDesC8& aSearchString ) |
|
164 { |
|
165 if( aSearchString.Length() == 0 ) |
|
166 { |
|
167 User::Leave( KErrCorrupt ); |
|
168 } |
|
169 iDiscoveryAgent->SearchL( aSearchString ); |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CUpnpControlPoint::SendL |
|
174 // Send an action message. |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 EXPORT_C void CUpnpControlPoint::SendL( CUpnpAction* aAction ) |
|
178 { |
|
179 iCpbHttpClient->SendActionL( aAction ); |
|
180 iActionList.AppendL( aAction ); |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // CUpnpControlPoint::SendL |
|
185 // Send HTTP message |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 EXPORT_C void CUpnpControlPoint::SendL( CUpnpHttpMessage* aHttpMessage ) |
|
189 { |
|
190 iCpbHttpClient->SendFileByPostL(aHttpMessage); |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CUpnpControlPoint::SendResponseMessageLD |
|
195 // Send HTTP message and destroy it (leave safe) |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 void CUpnpControlPoint::SendResponseMessageLD( CUpnpHttpMessage* aHttpMessage ) |
|
199 { |
|
200 CleanupStack::PushL( aHttpMessage ); |
|
201 iCpbHttpClient->SendL( aHttpMessage ); |
|
202 CleanupStack::PopAndDestroy( aHttpMessage ); |
|
203 } |
|
204 |
|
205 // ----------------------------------------------------------------------------- |
|
206 // CUpnpControlPoint::DeviceList |
|
207 // |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 EXPORT_C const RPointerArray<CUpnpDevice>& CUpnpControlPoint::DeviceList() const |
|
211 { |
|
212 return iDeviceRepository->DiscoveredDeviceList(); |
|
213 } |
|
214 |
|
215 // ----------------------------------------------------------------------------- |
|
216 // CUpnpControlPoint::SubscribeL |
|
217 // |
|
218 // ----------------------------------------------------------------------------- |
|
219 // |
|
220 EXPORT_C void CUpnpControlPoint::SubscribeL( CUpnpService* aService ) |
|
221 { |
|
222 LOG_FUNC_NAME; |
|
223 |
|
224 if ( !aService ) |
|
225 { |
|
226 return; |
|
227 } |
|
228 |
|
229 if( FindServiceInfoByService( aService ) ) |
|
230 { |
|
231 return; |
|
232 } |
|
233 |
|
234 LOGS("CUpnpControlPoint::SubscribeL - Subscribing service"); |
|
235 |
|
236 CUpnpServiceInfo* serviceInfo = CUpnpServiceInfo::NewLC( this, aService ); |
|
237 iSubscribedServicesInfos.AppendL( serviceInfo ); |
|
238 CleanupStack::Pop( serviceInfo ); |
|
239 |
|
240 iCpbHttpClient->SendSubscribeL( serviceInfo ); |
|
241 |
|
242 LOGS("CUpnpControlPoint::SubscribeL - end"); |
|
243 |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // CUpnpControlPoint::UnsubscribeL |
|
248 // |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 EXPORT_C void CUpnpControlPoint::UnsubscribeL( const CUpnpService* aService ) |
|
252 { |
|
253 UnsubscribeL( const_cast<CUpnpService*>( aService ) , ETrue ); |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------------- |
|
257 // CUpnpControlPoint::UnsubscribeL |
|
258 // |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 void CUpnpControlPoint::UnsubscribeL( CUpnpService* aService, |
|
262 TBool aSendUnsubscribeMessage ) |
|
263 { |
|
264 LOG_FUNC_NAME; |
|
265 |
|
266 if ( !aService ) |
|
267 { |
|
268 return; |
|
269 } |
|
270 |
|
271 CUpnpServiceInfo* subscribedServiceInfo = |
|
272 FindServiceInfoByService( aService ); |
|
273 if ( !subscribedServiceInfo ) |
|
274 { |
|
275 return; |
|
276 } |
|
277 |
|
278 LOGS("CUpnpControlPoint::UnsubscribeL - Unsubscribing service"); |
|
279 |
|
280 RemoveFromSubscribedList( subscribedServiceInfo ); |
|
281 |
|
282 if ( aSendUnsubscribeMessage ) |
|
283 { |
|
284 CleanupStack::PushL( subscribedServiceInfo ); |
|
285 iCpbHttpClient->SendUnsubscribeL( subscribedServiceInfo ); |
|
286 CleanupStack::Pop( subscribedServiceInfo ); |
|
287 } |
|
288 |
|
289 delete subscribedServiceInfo; |
|
290 |
|
291 LOGS("CUpnpControlPoint::UnsubscribeL - end"); |
|
292 } |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // CUpnpControlPoint::ResubscribeL |
|
296 // |
|
297 // ----------------------------------------------------------------------------- |
|
298 // |
|
299 void CUpnpControlPoint::ResubscribeL( CUpnpServiceInfo* aServiceInfo ) |
|
300 { |
|
301 iCpbHttpClient->SendResubscribeL( aServiceInfo ); |
|
302 } |
|
303 |
|
304 // ----------------------------------------------------------------------------- |
|
305 // CUpnpControlPoint::RemoveFromSubscribedList |
|
306 // |
|
307 // ----------------------------------------------------------------------------- |
|
308 // |
|
309 void CUpnpControlPoint::RemoveFromSubscribedList( |
|
310 CUpnpServiceInfo* aServiceInfoToRemove ) |
|
311 { |
|
312 const TInt idx = iSubscribedServicesInfos.Find( aServiceInfoToRemove ); |
|
313 if ( KErrNotFound != idx ) |
|
314 { |
|
315 iSubscribedServicesInfos.Remove( idx ); |
|
316 } |
|
317 iSubscribedServicesInfos.GranularCompress(); |
|
318 } |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // CUpnpControlPoint::DeviceFoundL |
|
322 // |
|
323 // ----------------------------------------------------------------------------- |
|
324 // |
|
325 EXPORT_C void CUpnpControlPoint::DeviceFoundL( CUpnpDevice& aDevice ) |
|
326 { |
|
327 iDescriptionAgent->DeviceAliveNotificationL(&aDevice); |
|
328 } |
|
329 |
|
330 // ----------------------------------------------------------------------------- |
|
331 // CUpnpControlPoint::DeviceLostL |
|
332 // Callback function - remove device |
|
333 // ----------------------------------------------------------------------------- |
|
334 // |
|
335 EXPORT_C void CUpnpControlPoint::DeviceLostL( CUpnpDevice& aDevice ) |
|
336 { |
|
337 LOG_FUNC_NAME; |
|
338 |
|
339 //device from ssdp |
|
340 CUpnpDevice* ssdpDevice = |
|
341 iDeviceRepository->RemoveIncomingDevice( aDevice.Uuid() ); |
|
342 if ( ssdpDevice ) |
|
343 { |
|
344 delete ssdpDevice; |
|
345 } |
|
346 CUpnpDevice* device = NULL; |
|
347 |
|
348 device = iDeviceRepository->FindDevice( aDevice.Uuid() ); |
|
349 |
|
350 if ( !device ) |
|
351 { |
|
352 return; |
|
353 } |
|
354 |
|
355 if ( aDevice.Expired() ) |
|
356 { |
|
357 device->SetExpired( ETrue ); |
|
358 if ( !AllDevicesExpired( device ) ) |
|
359 { |
|
360 return; |
|
361 } |
|
362 } |
|
363 |
|
364 // always remove whole device tree |
|
365 if ( device->IsEmbeddDevice() ) |
|
366 { |
|
367 CUpnpDevice* rootDevice = iDeviceRepository->FindRoot( device->Uuid() ); |
|
368 // In case of error when root device is not found during discovery |
|
369 if ( rootDevice ) |
|
370 { |
|
371 device = rootDevice; |
|
372 } |
|
373 } |
|
374 |
|
375 RemoveRootDeviceLD( device ); |
|
376 } |
|
377 |
|
378 // ----------------------------------------------------------------------------- |
|
379 // CUpnpControlPoint::AllDevicesExpired |
|
380 // |
|
381 // ----------------------------------------------------------------------------- |
|
382 // |
|
383 TBool CUpnpControlPoint::AllDevicesExpired( CUpnpDevice* aDevice ) |
|
384 { |
|
385 // notification about expiration of cache-control time of aDevice |
|
386 if ( aDevice->IsEmbeddDevice() ) // take root device |
|
387 { |
|
388 aDevice = iDeviceRepository->FindRoot( aDevice->Uuid() ); |
|
389 } |
|
390 // if root device not expired then return |
|
391 if ( !aDevice || !aDevice->Expired() ) |
|
392 { |
|
393 return EFalse; |
|
394 } |
|
395 RPointerArray<CUpnpDevice> devices; |
|
396 aDevice->GetAllDevices( devices ); // take all embedded devices |
|
397 for ( TInt k = 0; k < devices.Count(); k++ ) |
|
398 { |
|
399 // if not all embedded devices expired then return |
|
400 if ( !devices[k]->Expired() ) |
|
401 { |
|
402 devices.Close(); |
|
403 return EFalse; |
|
404 } |
|
405 } |
|
406 devices.Close(); |
|
407 return ETrue; |
|
408 } |
|
409 |
|
410 // ----------------------------------------------------------------------------- |
|
411 // CUpnpControlPoint::Path |
|
412 // |
|
413 // ----------------------------------------------------------------------------- |
|
414 // |
|
415 EXPORT_C const TDesC8& CUpnpControlPoint::Path() |
|
416 { |
|
417 return KPath(); |
|
418 } |
|
419 |
|
420 // ----------------------------------------------------------------------------- |
|
421 // CUpnpControlPoint::MessageReceived |
|
422 // Callback funtion - HTTP message received |
|
423 // ----------------------------------------------------------------------------- |
|
424 // |
|
425 void CUpnpControlPoint::MessageReceived( CUpnpHttpMessage* aHttpMessage ) |
|
426 { |
|
427 HttpResponseReceived( aHttpMessage ); |
|
428 } |
|
429 |
|
430 // ----------------------------------------------------------------------------- |
|
431 // CUpnpControlPoint::MapHttpError |
|
432 // |
|
433 // ----------------------------------------------------------------------------- |
|
434 // |
|
435 TInt CUpnpControlPoint::MapHttpError( TInt aError ) |
|
436 { |
|
437 if ( aError >= EHttpBadRequest && aError < EHttpInternalServerError ) |
|
438 { |
|
439 return KErrCouldNotConnect; |
|
440 } |
|
441 else if ( aError > EHttpInternalServerError ) |
|
442 { |
|
443 return KErrServerBusy; |
|
444 } |
|
445 else |
|
446 { |
|
447 return KErrUnknown; |
|
448 } |
|
449 |
|
450 } |
|
451 |
|
452 // ----------------------------------------------------------------------------- |
|
453 // CUpnpControlPoint::CheckEventKey |
|
454 // |
|
455 // ----------------------------------------------------------------------------- |
|
456 // |
|
457 TInt CUpnpControlPoint::CheckEventKey( const TDesC8& aIncomingSeq, |
|
458 TUint32 aExistingSeq ) |
|
459 { |
|
460 const TUint KMaxSeq = 2146583647; |
|
461 const TUint KMinSeq = 1; |
|
462 |
|
463 TUint IncomingSeq; |
|
464 TInt error = KErrNone; |
|
465 |
|
466 TLex8 lex(aIncomingSeq); |
|
467 lex.Mark(); |
|
468 error = lex.Val( IncomingSeq ); |
|
469 |
|
470 //--- check if SEQ is a number |
|
471 if ( !error ) |
|
472 { |
|
473 lex.UnGetToMark(); |
|
474 |
|
475 for ( TInt i(0); i < aIncomingSeq.Length(); i++ ) |
|
476 { |
|
477 TChar character = lex.Get(); |
|
478 if ( !(character.IsDigit() ) ) |
|
479 { |
|
480 error = KErrGeneral; |
|
481 break; |
|
482 } |
|
483 } |
|
484 } |
|
485 |
|
486 //--- check SEQ incrementing/wrapping |
|
487 if ( !error ) |
|
488 { |
|
489 // when initial event appears, don't check SEQ increment |
|
490 if ( (IncomingSeq == 0 ) && (aExistingSeq == 0 ) ) |
|
491 return KErrNone; |
|
492 |
|
493 if ( aExistingSeq < KMaxSeq ) |
|
494 { |
|
495 aExistingSeq++; |
|
496 } |
|
497 else |
|
498 { |
|
499 aExistingSeq = KMinSeq; |
|
500 } |
|
501 |
|
502 // if 'incoming SEQ' == 'incremented existing SEQ' -> OK |
|
503 if ( IncomingSeq == aExistingSeq ) |
|
504 { |
|
505 error = KErrNone; |
|
506 } |
|
507 else |
|
508 { |
|
509 error = KErrCancel; |
|
510 } |
|
511 } |
|
512 |
|
513 return error; |
|
514 } |
|
515 |
|
516 // ----------------------------------------------------------------------------- |
|
517 // CUpnpControlPoint::ThrowErrorL |
|
518 // |
|
519 // ----------------------------------------------------------------------------- |
|
520 // |
|
521 void CUpnpControlPoint::SendErrorResponseL( CUpnpHttpMessage* aHttpMessage, |
|
522 THttpStatusCode aCode ) |
|
523 { |
|
524 CUpnpHttpMessage* msg = RUpnpHttpMessageFactory::HttpResponseErrorL( |
|
525 aHttpMessage, aCode ); |
|
526 SendResponseMessageLD( msg ); |
|
527 } |
|
528 |
|
529 // ----------------------------------------------------------------------------- |
|
530 // CUpnpControlPoint::SubscriptionResponseReceivedL |
|
531 // |
|
532 // ----------------------------------------------------------------------------- |
|
533 // |
|
534 void CUpnpControlPoint::SubscriptionResponseReceivedL( |
|
535 CUpnpHttpMessage& aHttpMessage ) |
|
536 { |
|
537 LOG_FUNC_NAME; |
|
538 CUpnpGenaMessage* genaMsg = |
|
539 reinterpret_cast <CUpnpGenaMessage*> ( &aHttpMessage ); |
|
540 |
|
541 CUpnpServiceInfo* tmpServiceInfo = FindServiceInfoByGenaMessage( genaMsg ); |
|
542 if ( !tmpServiceInfo ) |
|
543 { |
|
544 return; |
|
545 } |
|
546 |
|
547 tmpServiceInfo->SetSidL( genaMsg->Sid() ); |
|
548 tmpServiceInfo->StartTimerL( genaMsg->Timeout() ); |
|
549 if(iDeviceRepository->MatchTargetDevice(_L8("*"))) |
|
550 { |
|
551 aHttpMessage.SetType(ESubscription); |
|
552 aHttpMessage.SetDestinationPathL(tmpServiceInfo->Service()->SubscriptionUrl()); |
|
553 TRAP_IGNORE( HttpResponseReceivedL( &aHttpMessage ) ); |
|
554 } |
|
555 |
|
556 LOGS("CUpnpControlPoint::SubscRespRcvdL - end"); |
|
557 } |
|
558 |
|
559 // ----------------------------------------------------------------------------- |
|
560 // CUpnpControlPoint::HandlePostponedInitialEventL |
|
561 // |
|
562 // ----------------------------------------------------------------------------- |
|
563 // |
|
564 void CUpnpControlPoint::HandlePostponedInitialEventL( CUpnpGenaMessage& aGenaMsg ) |
|
565 { |
|
566 CUpnpServiceInfo* serviceInfo = FindServiceInfoBySid( |
|
567 iSubscribedServicesInfos, aGenaMsg.Sid() ); |
|
568 if ( serviceInfo ) |
|
569 { |
|
570 if(iDeviceRepository->MatchTargetDevice(_L8("*"))) |
|
571 { |
|
572 aGenaMsg.SetDestinationPathL(serviceInfo->Service()->SubscriptionUrl()); |
|
573 TRAP_IGNORE( HttpResponseReceivedL( &aGenaMsg) ); |
|
574 } |
|
575 ParseEventUpdateStateVariablesL( aGenaMsg, *serviceInfo ); |
|
576 SendResponseMessageLD( RUpnpHttpMessageFactory::HttpResponseOkL( |
|
577 &aGenaMsg ) ); |
|
578 } |
|
579 else |
|
580 { |
|
581 SendErrorResponseL( &aGenaMsg, EHttpPreconditionFailed ); |
|
582 } |
|
583 } |
|
584 |
|
585 // ----------------------------------------------------------------------------- |
|
586 // CUpnpControlPoint::UnSubscriptionResponseReceived |
|
587 // |
|
588 // ----------------------------------------------------------------------------- |
|
589 // |
|
590 void CUpnpControlPoint::UnSubscriptionResponseReceived() |
|
591 { |
|
592 LOG_FUNC_NAME; |
|
593 } |
|
594 |
|
595 // ----------------------------------------------------------------------------- |
|
596 // CUpnpControlPoint::NotifyReceivedL |
|
597 // |
|
598 // ----------------------------------------------------------------------------- |
|
599 // |
|
600 void CUpnpControlPoint::NotifyReceivedL( CUpnpHttpMessage& aHttpMessage ) |
|
601 { |
|
602 LOGS( "CUpnpControlPoint::NotifyReceivedL - start" ); |
|
603 CUpnpGenaMessage* genaMsg = |
|
604 reinterpret_cast<CUpnpGenaMessage*> ( &aHttpMessage ); |
|
605 CleanupStack::PushL(genaMsg); |
|
606 |
|
607 THttpStatusCode code = ValidateEventResolveHttpResponseCode( *genaMsg ); |
|
608 if ( code != EHttp200Ok ) |
|
609 { |
|
610 //--- If some of conditions are not fulfilled, send error |
|
611 SendErrorResponseL(genaMsg, code); |
|
612 CleanupStack::PopAndDestroy(genaMsg); |
|
613 LOGS( "CUpnpControlPoint::NotifyReceivedL - end" ); |
|
614 return; |
|
615 } |
|
616 //--- checking if genaMsg SID is the same like the one in subscribed service. |
|
617 CUpnpServiceInfo* subscribedServiceInfo = FindServiceInfoBySid( |
|
618 iSubscribedServicesInfos, genaMsg->Sid()); |
|
619 |
|
620 if ( subscribedServiceInfo ) |
|
621 { |
|
622 //===== Checking validity of SEQ header |
|
623 TInt seqError = KErrNone; |
|
624 seqError = CheckEventKey( genaMsg->Seq(), subscribedServiceInfo->Seq() ); |
|
625 if ( seqError ) |
|
626 { |
|
627 if ( seqError == KErrCancel ) |
|
628 { |
|
629 //------ if SEQ's order invalid |
|
630 //-> e.g 0,1,2 and then 1 -> Unsubscribe/Subscribe |
|
631 ResubscribeL( *subscribedServiceInfo ); |
|
632 } |
|
633 else |
|
634 { |
|
635 LOGS( "CUpnpControlPoint::NotifyReceivedL - SEQ INAVLID" ); |
|
636 SendErrorResponseL( genaMsg, EHttpBadRequest ); |
|
637 User::Leave(seqError); |
|
638 } |
|
639 } |
|
640 else |
|
641 { |
|
642 if(iDeviceRepository->MatchTargetDevice(_L8("*"))) |
|
643 { |
|
644 genaMsg->SetDestinationPathL(subscribedServiceInfo->Service()->SubscriptionUrl()); |
|
645 TRAP_IGNORE( HttpResponseReceivedL( genaMsg) ); |
|
646 } |
|
647 ParseEventUpdateStateVariablesL( *genaMsg, *subscribedServiceInfo ); |
|
648 SendResponseMessageLD(RUpnpHttpMessageFactory::HttpResponseOkL( genaMsg )); |
|
649 LOGS( "CUpnpControlPoint::NotifyReceivedL - send OK" ); |
|
650 } |
|
651 CleanupStack::PopAndDestroy( genaMsg ); |
|
652 |
|
653 } |
|
654 else |
|
655 { |
|
656 TInt seq; |
|
657 TLex8 lex( genaMsg->Seq() ); |
|
658 TInt error = lex.Val(seq); |
|
659 |
|
660 if ( !error && seq == 0 ) |
|
661 { |
|
662 CleanupStack::Pop( genaMsg ); |
|
663 //ownership is passed through |
|
664 iInitialEventRetry->AddL( genaMsg ); |
|
665 } |
|
666 else |
|
667 { |
|
668 SendErrorResponseL( genaMsg, EHttpPreconditionFailed ); |
|
669 CleanupStack::PopAndDestroy( genaMsg ); |
|
670 } |
|
671 } |
|
672 |
|
673 } |
|
674 |
|
675 |
|
676 // ----------------------------------------------------------------------------- |
|
677 // CUpnpControlPoint::Device |
|
678 // This function returns a pointer to device identified by UUID. |
|
679 // (other items were commented in a header).es |
|
680 // ----------------------------------------------------------------------------- |
|
681 // |
|
682 CUpnpServiceInfo* CUpnpControlPoint::FindServiceInfoBySid( RPointerArray<CUpnpServiceInfo>& aInfos, |
|
683 const TDesC8& aSid ) |
|
684 { |
|
685 for ( TInt i=0; i < aInfos.Count(); i++ ) |
|
686 { |
|
687 CUpnpServiceInfo* subscribedServiceInfo = aInfos[i]; |
|
688 if ( (subscribedServiceInfo->Sid().Length()> 0 ) |
|
689 && (subscribedServiceInfo->Sid() == aSid ) ) |
|
690 { |
|
691 return subscribedServiceInfo; |
|
692 } |
|
693 } |
|
694 return NULL; |
|
695 } |
|
696 |
|
697 // ----------------------------------------------------------------------------- |
|
698 // CUpnpControlPoint::ResubscribeL |
|
699 // |
|
700 // ----------------------------------------------------------------------------- |
|
701 // |
|
702 void CUpnpControlPoint::ResubscribeL( CUpnpServiceInfo& aInfo ) |
|
703 { |
|
704 //------ if SEQ's order invalid |
|
705 //-> e.g 0,1,2 and then 1 -> Unsubscribe/Subscribe |
|
706 CUpnpService* service = |
|
707 aInfo.Service(); // remember the service |
|
708 |
|
709 UnsubscribeL( service ); |
|
710 // after unsubscribing -> subscribe again |
|
711 SubscribeL( service ); |
|
712 |
|
713 } |
|
714 |
|
715 // ----------------------------------------------------------------------------- |
|
716 // CUpnpControlPoint::ParseEventUpdateStateVariablesL |
|
717 // |
|
718 // ----------------------------------------------------------------------------- |
|
719 // |
|
720 void CUpnpControlPoint::ParseEventUpdateStateVariablesL( |
|
721 CUpnpGenaMessage& aGenaMsg, CUpnpServiceInfo& aInfo ) |
|
722 { |
|
723 TInt parsingError = KErrNone; |
|
724 TRAP( parsingError, iSaxController->AttachL( |
|
725 aGenaMsg.Body(), *( aInfo.Service() ) ) ); |
|
726 if ( parsingError ) |
|
727 { |
|
728 LOGS( "CUpnpControlPoint::NotifyReceivedL - " |
|
729 "parsing gena or parsing SEQ - FAILED" ); |
|
730 SendErrorResponseL( &aGenaMsg, EHttpBadRequest ); |
|
731 User::Leave( parsingError ); |
|
732 } |
|
733 |
|
734 // if SEQ ok -> put the value to the service |
|
735 TInt seq; |
|
736 TLex8 lex( aGenaMsg.Seq() ); |
|
737 TInt error = lex.Val( seq ); |
|
738 // error ignored, it is fully checked in CheckEventKey() |
|
739 |
|
740 aInfo.SetSeq( seq ); |
|
741 StateUpdated( aInfo.Service() ); |
|
742 |
|
743 } |
|
744 |
|
745 // ----------------------------------------------------------------------------- |
|
746 // CUpnpControlPoint::ValidateEventResolveHttpResponseCode |
|
747 // |
|
748 // ----------------------------------------------------------------------------- |
|
749 // |
|
750 THttpStatusCode CUpnpControlPoint::ValidateEventResolveHttpResponseCode( |
|
751 CUpnpGenaMessage& aGenaMsg ) |
|
752 |
|
753 { |
|
754 THttpStatusCode code = EHttp200Ok; |
|
755 //--- NOTIFY message syntax - checking if headers: NT and NTS exists |
|
756 |
|
757 if ( aGenaMsg.Method() != UpnpGENA::KGenaNotify() |
|
758 || aGenaMsg.Nt() == KNoHeader |
|
759 || aGenaMsg.Nts() == KNoHeader ) |
|
760 { |
|
761 // headers NT or NTS are missing |
|
762 code = EHttpBadRequest; |
|
763 LOGS( "CUpnpControlPoint::NotifyReceivedL - bad request" ); |
|
764 } |
|
765 |
|
766 //--- NOTIFY message syntax |
|
767 //- checking if headers: NT and NTS has proper structure [name: value] |
|
768 else if (aGenaMsg.Nt() != UpnpGENA::KDefaultNt || aGenaMsg.Nts() |
|
769 != UpnpGENA::KDefaultNts) |
|
770 { |
|
771 // headers NT or NTS are invalid |
|
772 code = EHttpPreconditionFailed; |
|
773 LOGS( "CUpnpControlPoint::NotifyReceivedL - headers NT or NTS are invalid" ); |
|
774 } |
|
775 return code; |
|
776 } |
|
777 |
|
778 |
|
779 // ----------------------------------------------------------------------------- |
|
780 // CUpnpControlPoint::Device |
|
781 // This function returns a pointer to device identified by UUID. |
|
782 // (other items were commented in a header).es |
|
783 // ----------------------------------------------------------------------------- |
|
784 // |
|
785 EXPORT_C const CUpnpDevice* CUpnpControlPoint::Device(const TDesC8& aUuid) |
|
786 { |
|
787 RPointerArray<CUpnpDevice> devices = DeviceList(); |
|
788 for( TInt i(0); i < devices.Count(); i++) |
|
789 { |
|
790 if(aUuid.Compare( devices[i]->Uuid() ) == 0) |
|
791 { |
|
792 return devices[i]; |
|
793 } |
|
794 } |
|
795 return NULL; |
|
796 } |
|
797 |
|
798 // ----------------------------------------------------------------------------- |
|
799 // CUpnpControlPoint::AddressChangedL |
|
800 // |
|
801 // ----------------------------------------------------------------------------- |
|
802 // |
|
803 void CUpnpControlPoint::AddressChangedL() |
|
804 { |
|
805 LOG_FUNC_NAME; |
|
806 TInt i(0); |
|
807 RPointerArray<CUpnpDevice> devices = iDeviceRepository->DiscoveredDeviceList(); |
|
808 RPointerArray<CUpnpDevice> rootDevices; |
|
809 CleanupClosePushL(rootDevices); |
|
810 for( i = 0; i < devices.Count(); i++) |
|
811 { |
|
812 if(!devices[i]->IsEmbeddDevice()) |
|
813 { |
|
814 rootDevices.AppendL(devices[i]); |
|
815 } |
|
816 } |
|
817 devices = iDeviceRepository->UnneddedDeviceList(); |
|
818 for( i = 0; i < devices.Count(); i++) |
|
819 { |
|
820 if(!devices[i]->IsEmbeddDevice()) |
|
821 { |
|
822 rootDevices.AppendL(devices[i]); |
|
823 } |
|
824 } |
|
825 devices = iDeviceRepository->UninterestingDeviceList(); |
|
826 for( i = 0; i < devices.Count(); i++) |
|
827 { |
|
828 if(!devices[i]->IsEmbeddDevice()) |
|
829 { |
|
830 rootDevices.AppendL(devices[i]); |
|
831 } |
|
832 } |
|
833 devices = iDeviceRepository->IncompliteDeviceList(); |
|
834 for( i = 0; i < devices.Count(); i++) |
|
835 { |
|
836 if(!devices[i]->IsEmbeddDevice()) |
|
837 { |
|
838 rootDevices.AppendL(devices[i]); |
|
839 } |
|
840 } |
|
841 |
|
842 for( i = 0; i < rootDevices.Count(); i++) |
|
843 { |
|
844 RemoveRootDeviceLD( rootDevices[i] ); |
|
845 } |
|
846 CleanupStack::PopAndDestroy(&rootDevices); |
|
847 |
|
848 } |
|
849 |
|
850 // ----------------------------------------------------------------------------- |
|
851 // CUpnpControlPoint::GiveAddressL |
|
852 // |
|
853 // ----------------------------------------------------------------------------- |
|
854 // |
|
855 TInetAddr CUpnpControlPoint::GiveAddressL( const TDesC8& aUrl ) |
|
856 { |
|
857 TInetAddr result= INET_ADDR(0,0,0,0); |
|
858 result.SetPort( 0 ); |
|
859 TInt colonPos = aUrl.Find( KColon() ) ; |
|
860 if ( colonPos != KErrNotFound ) |
|
861 { |
|
862 TPtrC8 addressStr = aUrl.Left( colonPos ); |
|
863 HBufC* buffer = HBufC::NewL( addressStr.Length() ); |
|
864 TPtr bufferPtr(buffer->Des() ); |
|
865 bufferPtr.Copy( addressStr ); |
|
866 result.Input( *buffer ); |
|
867 delete buffer; |
|
868 const TDesC8& portStr = aUrl.Mid( colonPos + 1 ); |
|
869 TLex8 lexer(portStr); |
|
870 TInt port(0); |
|
871 lexer.Val( port ); |
|
872 result.SetPort( port ); |
|
873 } |
|
874 else |
|
875 { |
|
876 HBufC* buffer = HBufC::NewL( aUrl.Length() ); |
|
877 TPtr bufferPtr(buffer->Des() ); |
|
878 bufferPtr.Copy( aUrl ); |
|
879 result.Input( *buffer ); |
|
880 delete buffer; |
|
881 } |
|
882 return result; |
|
883 } |
|
884 |
|
885 // ----------------------------------------------------------------------------- |
|
886 // CUpnpControlPoint::RemoveRootDeviceLD |
|
887 // |
|
888 // ----------------------------------------------------------------------------- |
|
889 // |
|
890 void CUpnpControlPoint::RemoveRootDeviceLD( CUpnpDevice* aDevice ) |
|
891 { |
|
892 TBool isDiscovered = EFalse; |
|
893 |
|
894 iCpbHttpClient->StopIgnoringL( aDevice ); |
|
895 |
|
896 RemoveActionsL( aDevice ); |
|
897 RemoveServicesL( aDevice ); |
|
898 |
|
899 //find all children of the device to be removed |
|
900 RPointerArray<CUpnpDevice> devices; |
|
901 aDevice->GetAllDevices( devices ); |
|
902 CleanupClosePushL( devices ); |
|
903 |
|
904 for ( TInt k = 0; k < devices.Count(); k++ ) |
|
905 { |
|
906 RemoveActionsL( devices[k] ); |
|
907 isDiscovered |
|
908 = iDeviceRepository->IsDiscoveredDevice( devices[k]->Uuid() ); |
|
909 iDeviceRepository->RemoveDevice( devices[k] ); |
|
910 if ( isDiscovered ) |
|
911 { |
|
912 DeviceDisappeared( devices[k] ); |
|
913 } |
|
914 RemoveServicesL( devices[k] ); |
|
915 } |
|
916 |
|
917 CleanupStack::PopAndDestroy( &devices ); |
|
918 |
|
919 iActionList.Compress(); |
|
920 isDiscovered = iDeviceRepository->IsDiscoveredDevice( aDevice->Uuid() ); |
|
921 iDeviceRepository->RemoveDevice( aDevice ); |
|
922 if ( isDiscovered ) |
|
923 { |
|
924 DeviceDisappeared( aDevice ); |
|
925 } |
|
926 |
|
927 delete aDevice; |
|
928 aDevice = NULL; |
|
929 } |
|
930 |
|
931 // ----------------------------------------------------------------------------- |
|
932 // CUpnpControlPoint::RemoveActionsL |
|
933 // |
|
934 // ----------------------------------------------------------------------------- |
|
935 // |
|
936 void CUpnpControlPoint::RemoveActionsL( CUpnpDevice* aDevice ) |
|
937 { |
|
938 for ( TInt i = 0; i < iActionList.Count(); ++i ) |
|
939 { |
|
940 if( ( iActionList[i]->Service().Device().Uuid()).Compare( |
|
941 aDevice->Uuid() ) == 0 ) |
|
942 { |
|
943 CUpnpAction* action = iActionList[i]; |
|
944 |
|
945 CUpnpSoapMessage* errorMsg = |
|
946 RUpnpSoapMessageFactory::SoapResponseL( action, |
|
947 EActionFailed ); |
|
948 |
|
949 CleanupStack::PushL( errorMsg ); |
|
950 iSaxController->UpdateActionWithErrorResponseL( errorMsg, action ); |
|
951 ActionResponseReceived( action ); |
|
952 iActionList.Remove( i ); |
|
953 delete action; |
|
954 CleanupStack::PopAndDestroy( errorMsg ); |
|
955 //as a action is removed from the list the |
|
956 //index is kept as same for the next loop. |
|
957 --i; |
|
958 } |
|
959 } |
|
960 } |
|
961 |
|
962 // ----------------------------------------------------------------------------- |
|
963 // CUpnpControlPoint::RemoveServicesL |
|
964 // |
|
965 // ----------------------------------------------------------------------------- |
|
966 // |
|
967 void CUpnpControlPoint::RemoveServicesL( CUpnpDevice* aDevice ) |
|
968 { |
|
969 RPointerArray<CUpnpService>& services = aDevice->ServiceList(); |
|
970 for ( TInt j = 0; j < services.Count(); j++ ) |
|
971 { |
|
972 UnsubscribeL( services[j], EFalse ); |
|
973 } |
|
974 } |
|
975 |
|
976 // ----------------------------------------------------------------------------- |
|
977 // CUpnpControlPoint::FindServiceInfoByService |
|
978 // |
|
979 // ----------------------------------------------------------------------------- |
|
980 // |
|
981 CUpnpServiceInfo* CUpnpControlPoint::FindServiceInfoByService( |
|
982 CUpnpService* aService ) |
|
983 { |
|
984 for ( TInt i=0; i < iSubscribedServicesInfos.Count() ; i++ ) |
|
985 { |
|
986 if ( iSubscribedServicesInfos[i]->Service() == aService ) |
|
987 { |
|
988 return iSubscribedServicesInfos[i]; |
|
989 } |
|
990 } |
|
991 return NULL; |
|
992 } |
|
993 |
|
994 // ----------------------------------------------------------------------------- |
|
995 // CUpnpControlPoint::FindServiceInfoByHttpMessage |
|
996 // |
|
997 // ----------------------------------------------------------------------------- |
|
998 // |
|
999 CUpnpServiceInfo* CUpnpControlPoint::FindServiceInfoByGenaMessage( |
|
1000 CUpnpGenaMessage* aGenaMsg ) |
|
1001 { |
|
1002 for ( TInt i=0; i < iSubscribedServicesInfos.Count() ; i++ ) |
|
1003 { |
|
1004 if ( iSubscribedServicesInfos[i]->SessionId() |
|
1005 == aGenaMsg->SessionId() ) |
|
1006 { |
|
1007 return iSubscribedServicesInfos[i]; |
|
1008 } |
|
1009 } |
|
1010 return NULL; |
|
1011 } |
|
1012 |
|
1013 void CUpnpControlPoint::ProcessDeviceMessageL( CUpnpHttpMessage* aHttpMessage ) |
|
1014 { |
|
1015 iDescriptionAgent->ProcessDeviceMessageL( aHttpMessage ); |
|
1016 } |
|
1017 |
|
1018 void CUpnpControlPoint::ProcessServiceMessageL( CUpnpHttpMessage* aHttpMessage ) |
|
1019 { |
|
1020 iDescriptionAgent->ProcessServiceMessageL( aHttpMessage ); |
|
1021 } |
|
1022 |
|
1023 void CUpnpControlPoint::ProcessActionMessageL( CUpnpHttpMessage* aHttpMessage ) |
|
1024 { |
|
1025 |
|
1026 TInt idx(0); |
|
1027 // Match request action |
|
1028 for ( ; idx < iActionList.Count() && iActionList[idx]->SessionId() |
|
1029 != aHttpMessage->SessionId(); idx++ ) |
|
1030 { |
|
1031 } |
|
1032 if ( idx == iActionList.Count() ) |
|
1033 { |
|
1034 return; |
|
1035 } |
|
1036 |
|
1037 CUpnpAction* tmpAction = iActionList[idx]; |
|
1038 |
|
1039 |
|
1040 TInt error(KErrNone); |
|
1041 switch ( aHttpMessage->Error() ) |
|
1042 { |
|
1043 case EHttp200Ok: |
|
1044 { |
|
1045 TRAP( error, |
|
1046 iSaxController->UpdateActionWithOKResponseL( |
|
1047 static_cast<CUpnpSoapMessage*>(aHttpMessage), tmpAction ); |
|
1048 ); |
|
1049 } |
|
1050 break; |
|
1051 case EHttpInternalServerError: |
|
1052 { |
|
1053 TRAP( error, |
|
1054 iSaxController->UpdateActionWithErrorResponseL( |
|
1055 static_cast<CUpnpSoapMessage*>(aHttpMessage), tmpAction ); |
|
1056 ); |
|
1057 break; |
|
1058 } |
|
1059 default: |
|
1060 { |
|
1061 if ( aHttpMessage->InternalError() ) |
|
1062 { |
|
1063 tmpAction->SetError( aHttpMessage->InternalError() ); |
|
1064 } |
|
1065 else |
|
1066 { |
|
1067 tmpAction->SetError( MapHttpError( aHttpMessage->Error() ) ); |
|
1068 } |
|
1069 break; |
|
1070 } |
|
1071 } |
|
1072 if ( KErrNone != error ) |
|
1073 { |
|
1074 tmpAction->SetError( error ); |
|
1075 } |
|
1076 |
|
1077 ActionResponseReceived( tmpAction ); |
|
1078 delete tmpAction; |
|
1079 iActionList.Remove( idx ); |
|
1080 } |
|
1081 |
|
1082 // ----------------------------------------------------------------------------- |
|
1083 // CUpnpControlPoint::StateUpdated |
|
1084 // |
|
1085 // ----------------------------------------------------------------------------- |
|
1086 // |
|
1087 void CUpnpControlPoint::StateUpdated( CUpnpService* aService ) |
|
1088 { |
|
1089 TRAP_IGNORE( StateUpdatedL( aService ) ); |
|
1090 } |
|
1091 |
|
1092 // ----------------------------------------------------------------------------- |
|
1093 // CUpnpControlPoint::DeviceDiscovered |
|
1094 // |
|
1095 // ----------------------------------------------------------------------------- |
|
1096 // |
|
1097 void CUpnpControlPoint::DeviceDiscovered( CUpnpDevice* aDevice ) |
|
1098 { |
|
1099 TRAP_IGNORE( DeviceDiscoveredL( aDevice ) ); |
|
1100 } |
|
1101 |
|
1102 // ----------------------------------------------------------------------------- |
|
1103 // CUpnpControlPoint::DeviceDisappeared |
|
1104 // |
|
1105 // ----------------------------------------------------------------------------- |
|
1106 // |
|
1107 void CUpnpControlPoint::DeviceDisappeared( CUpnpDevice* aDevice ) |
|
1108 { |
|
1109 TRAP_IGNORE( DeviceDisappearedL( aDevice ) ); |
|
1110 } |
|
1111 |
|
1112 // ----------------------------------------------------------------------------- |
|
1113 // CUpnpControlPoint::ActionResponseReceived |
|
1114 // |
|
1115 // ----------------------------------------------------------------------------- |
|
1116 // |
|
1117 void CUpnpControlPoint::ActionResponseReceived( CUpnpAction* aAction ) |
|
1118 { |
|
1119 TRAP_IGNORE( ActionResponseReceivedL( aAction ) ); |
|
1120 } |
|
1121 |
|
1122 // ----------------------------------------------------------------------------- |
|
1123 // CUpnpControlPoint::HttpResponseReceived |
|
1124 // |
|
1125 // ----------------------------------------------------------------------------- |
|
1126 // |
|
1127 void CUpnpControlPoint::HttpResponseReceived( CUpnpHttpMessage* aMessage ) |
|
1128 { |
|
1129 TRAP_IGNORE( HttpResponseReceivedL( aMessage ) ); |
|
1130 } |
|
1131 |
|
1132 // ----------------------------------------------------------------------------- |
|
1133 // CUpnpControlPoint::EnableRadaDeviceL |
|
1134 // |
|
1135 // ----------------------------------------------------------------------------- |
|
1136 // |
|
1137 #ifdef RD_UPNP_REMOTE_ACCESS |
|
1138 EXPORT_C void CUpnpControlPoint::EnableRadaDeviceL( TRequestStatus& aStatus ) |
|
1139 #else |
|
1140 EXPORT_C void CUpnpControlPoint::EnableRadaDeviceL( TRequestStatus& /*aStatus*/ ) |
|
1141 #endif |
|
1142 { |
|
1143 #ifdef RD_UPNP_REMOTE_ACCESS |
|
1144 iDiscoveryAgent->EnableRadaDeviceL( aStatus ); |
|
1145 #endif |
|
1146 } |
|
1147 |
|
1148 // ----------------------------------------------------------------------------- |
|
1149 // CUpnpControlPoint::EnableRadaDeviceL |
|
1150 // |
|
1151 // ----------------------------------------------------------------------------- |
|
1152 // |
|
1153 EXPORT_C TInt CUpnpControlPoint::EnableRadaDeviceL() |
|
1154 { |
|
1155 #ifdef RD_UPNP_REMOTE_ACCESS |
|
1156 return iDiscoveryAgent->EnableRadaDeviceL(); |
|
1157 #else |
|
1158 return KErrNotSupported; |
|
1159 #endif |
|
1160 } |
|
1161 |
|
1162 // ----------------------------------------------------------------------------- |
|
1163 // CUpnpControlPoint::DisableRadaDeviceL |
|
1164 // |
|
1165 // ----------------------------------------------------------------------------- |
|
1166 // |
|
1167 EXPORT_C void CUpnpControlPoint::DisableRadaDeviceL() |
|
1168 { |
|
1169 #ifdef RD_UPNP_REMOTE_ACCESS |
|
1170 iDiscoveryAgent->DisableRadaDeviceL(); |
|
1171 #endif |
|
1172 } |
|
1173 |
|
1174 // ----------------------------------------------------------------------------- |
|
1175 // CUpnpControlPoint::StartIPFilteringL |
|
1176 // |
|
1177 // ----------------------------------------------------------------------------- |
|
1178 // |
|
1179 #ifdef RD_UPNP_REMOTE_ACCESS |
|
1180 EXPORT_C void CUpnpControlPoint::StartIPFilteringL( TFilteringMode aMode ) |
|
1181 #else |
|
1182 EXPORT_C void CUpnpControlPoint::StartIPFilteringL( TFilteringMode /*aMode*/ ) |
|
1183 #endif |
|
1184 { |
|
1185 #ifdef RD_UPNP_REMOTE_ACCESS |
|
1186 switch( aMode ) |
|
1187 { |
|
1188 case EBoth: |
|
1189 { |
|
1190 iCpbHttpClient->StartIPFilteringL(); |
|
1191 iDiscoveryAgent->StartIPFilteringL(); |
|
1192 break; |
|
1193 } |
|
1194 case ERada: |
|
1195 { |
|
1196 iDiscoveryAgent->StartIPFilteringL(); |
|
1197 break; |
|
1198 } |
|
1199 case EControlPoint: |
|
1200 { |
|
1201 iCpbHttpClient->StartIPFilteringL(); |
|
1202 break; |
|
1203 } |
|
1204 default: |
|
1205 { |
|
1206 User::Leave( KErrNotSupported ); |
|
1207 break; |
|
1208 } |
|
1209 } |
|
1210 #endif |
|
1211 } |
|
1212 |
|
1213 // ----------------------------------------------------------------------------- |
|
1214 // CUpnpControlPoint::StopIPFilteringL |
|
1215 // |
|
1216 // ----------------------------------------------------------------------------- |
|
1217 // |
|
1218 #ifdef RD_UPNP_REMOTE_ACCESS |
|
1219 EXPORT_C void CUpnpControlPoint::StopIPFilteringL( TFilteringMode aMode ) |
|
1220 #else |
|
1221 EXPORT_C void CUpnpControlPoint::StopIPFilteringL( TFilteringMode /*aMode*/ ) |
|
1222 #endif |
|
1223 { |
|
1224 #ifdef RD_UPNP_REMOTE_ACCESS |
|
1225 switch( aMode ) |
|
1226 { |
|
1227 case EBoth: |
|
1228 { |
|
1229 iCpbHttpClient->StopIPFiltering(); |
|
1230 iDiscoveryAgent->StopIPFiltering(); |
|
1231 break; |
|
1232 } |
|
1233 case ERada: |
|
1234 { |
|
1235 iDiscoveryAgent->StopIPFiltering(); |
|
1236 break; |
|
1237 } |
|
1238 case EControlPoint: |
|
1239 { |
|
1240 iCpbHttpClient->StopIPFiltering(); |
|
1241 break; |
|
1242 } |
|
1243 default: |
|
1244 { |
|
1245 User::Leave( KErrNotSupported ); |
|
1246 break; |
|
1247 } |
|
1248 } |
|
1249 #endif |
|
1250 } |
|
1251 |
|
1252 // ----------------------------------------------------------------------------- |
|
1253 // CUpnpControlPoint::NetworkEvent |
|
1254 // ----------------------------------------------------------------------------- |
|
1255 // |
|
1256 EXPORT_C void CUpnpControlPoint::NetworkEvent( CUpnpNetworkEventBase* aEvent ) |
|
1257 { |
|
1258 LOG_FUNC_NAME; |
|
1259 |
|
1260 switch ( aEvent->Type() ) |
|
1261 { |
|
1262 case EWlanLostEvent: |
|
1263 { |
|
1264 iCpbHttpClient->WlanLostOccurs(); |
|
1265 } |
|
1266 break; |
|
1267 |
|
1268 case EAddressChangeEvent: |
|
1269 { |
|
1270 TRAP_IGNORE( iCpbHttpClient->AddressChangedL(); AddressChangedL() ); |
|
1271 } |
|
1272 break; |
|
1273 } |
|
1274 } |
|
1275 |
|
1276 // End of File |