|
1 /** @file |
|
2 * Copyright (c) 2007-2007 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 Discovery class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32base.h> |
|
21 |
|
22 #include <upnpdevice.h> |
|
23 #include <upnpdevicedescription.h> |
|
24 |
|
25 #include <upnphttpmessagefactory.h> |
|
26 |
|
27 #include "upnpcontrolpoint.h" |
|
28 #include "upnpcpbdescriptionagent.h" |
|
29 #include "upnpcpbdevicerepository.h" |
|
30 #include "upnpcpbsimpledevicedescription.h" |
|
31 #include "upnpcpbembeddeddevicedescription.h" |
|
32 #include "upnpcpbhttpmessagecontroller.h" |
|
33 #include "upnpcontenthandlerscontroller.h" |
|
34 #include "upnpcommonupnplits.h" |
|
35 #include "upnpcpstackrequestor.h" |
|
36 |
|
37 #define KLogFile _L("UPnPControlPoint.txt") |
|
38 #include <upnpcustomlog.h> |
|
39 |
|
40 // Time window reserved for single device discovery |
|
41 static const TInt KDeviceDiscoveryTimeout = 30000000; |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CUpnpCpbDescriptionAgent::NewL |
|
45 // Two-phased constructor |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CUpnpCpbDescriptionAgent* CUpnpCpbDescriptionAgent::NewL( |
|
49 CUpnpControlPoint& aBaseCP, |
|
50 MUpnpCpbHttpMessageController& aMessanger, |
|
51 CUpnpCpbDeviceRepository& aRepository) |
|
52 { |
|
53 LOG_FUNC_NAME; |
|
54 CUpnpCpbDescriptionAgent* self = |
|
55 new (ELeave) CUpnpCpbDescriptionAgent( |
|
56 aBaseCP, aMessanger, aRepository ); |
|
57 |
|
58 CleanupStack::PushL(self); |
|
59 self->ConstructL(); |
|
60 CleanupStack::Pop(self); |
|
61 |
|
62 return self; |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CUpnpCpbDescriptionAgent::~CUpnpCpbDescriptionAgent |
|
67 // Destructor |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CUpnpCpbDescriptionAgent::~CUpnpCpbDescriptionAgent() |
|
71 { |
|
72 LOG_FUNC_NAME; |
|
73 |
|
74 iIncomingDevices.ResetAndDestroy(); |
|
75 iIncomingDevices.Close(); |
|
76 |
|
77 if (iTimer) |
|
78 { |
|
79 iTimer->Cancel(); |
|
80 } |
|
81 delete iTimer; |
|
82 |
|
83 iUuid.Close(); |
|
84 delete iSaxController; |
|
85 delete iSimpleDiscoveryEngine; |
|
86 delete iEmbeddedDiscoveryEngine; |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CUpnpCpbDescriptionAgent::CUpnpCpbDescriptionAgent |
|
91 // Constructor |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 CUpnpCpbDescriptionAgent::CUpnpCpbDescriptionAgent( |
|
95 CUpnpControlPoint& aBaseCP, |
|
96 MUpnpCpbHttpMessageController& aMessanger, |
|
97 CUpnpCpbDeviceRepository& aRepository ) |
|
98 : iBaseCP( aBaseCP ), iMessanger( aMessanger ), iDeviceRepository( aRepository), |
|
99 iPendingDiscovery( EFalse ), iDescriptionSession( KErrNotFound ) |
|
100 { |
|
101 LOG_FUNC_NAME; |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CUpnpCpbDescriptionAgent::ConstructL |
|
106 // Second phase constructor |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void CUpnpCpbDescriptionAgent::ConstructL() |
|
110 { |
|
111 LOG_FUNC_NAME; |
|
112 iSimpleDiscoveryEngine = |
|
113 CUpnpCpbSimpleDeviceDescription::NewL(iMessanger, iDeviceRepository); |
|
114 iEmbeddedDiscoveryEngine = |
|
115 CUpnpCpbEmbeddedDeviceDescription::NewL(iMessanger, iDeviceRepository); |
|
116 // Sax paresr for device description |
|
117 iSaxController = CUpnpContentHandlersController::NewL(); |
|
118 |
|
119 iTimer = CUpnpNotifyTimer::NewL(this); |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CUpnpCpbDescriptionAgent::DeviceAliveNotificationL |
|
124 // New device found |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 void CUpnpCpbDescriptionAgent::DeviceAliveNotificationL( CUpnpDevice* aDevice ) |
|
128 { |
|
129 LOG_FUNC_NAME; |
|
130 |
|
131 TPtrC8 deviceType; |
|
132 deviceType.Set( aDevice->DeviceType() ); |
|
133 |
|
134 if ( (iDeviceRepository.MatchTargetDevice(deviceType) |
|
135 || (UpnpSSDP::KUPnPRootDevice().Find( deviceType ) != KErrNotFound)) |
|
136 && !iDeviceRepository.IsKnownDevice( aDevice->Uuid() ) ) |
|
137 { |
|
138 CUpnpDevice* tmp = aDevice->CloneL(); |
|
139 CleanupStack::PushL( tmp ); |
|
140 |
|
141 if ( iPendingDiscovery ) |
|
142 { |
|
143 iIncomingDevices.AppendL(tmp); |
|
144 } |
|
145 else |
|
146 { |
|
147 GetDeviceDescriptionL( tmp ); |
|
148 } |
|
149 |
|
150 CleanupStack::Pop(tmp); |
|
151 } |
|
152 else |
|
153 { |
|
154 CUpnpDevice* device = iDeviceRepository.FindDevice( aDevice->Uuid() ); |
|
155 if ( device ) |
|
156 { |
|
157 device->SetExpired( EFalse ); |
|
158 } |
|
159 } |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // CUpnpCpbDescriptionAgent::ProcessDeviceMessageL |
|
164 // Process device message |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 void CUpnpCpbDescriptionAgent::ProcessDeviceMessageL( |
|
168 CUpnpHttpMessage* aHttpMessage ) |
|
169 { |
|
170 if( iDescriptionSession != aHttpMessage->SessionId() ) |
|
171 { |
|
172 return; |
|
173 } |
|
174 |
|
175 iDescriptionSession = KErrNotFound; |
|
176 // No response |
|
177 if ( !aHttpMessage->Is2xx() ) |
|
178 { |
|
179 LOGS("CUpnpCpbDescriptionAgent::ProcessDeviceMessageL - " |
|
180 "Request timed out. Max Retries reached. Ignoring device."); |
|
181 if( iUuid.Length() ) |
|
182 { |
|
183 iTimer->Cancel(); |
|
184 iPendingDiscovery = EFalse; |
|
185 StopIgnoringUuidL(iUuid); |
|
186 } |
|
187 DiscoverNextDeviceL(); |
|
188 } |
|
189 // Process description |
|
190 else |
|
191 { |
|
192 ConstructAndValidateDeviceTreeL( aHttpMessage->Body( ), |
|
193 aHttpMessage->Sender( ), aHttpMessage->SenderPath( ) ); |
|
194 } |
|
195 } |
|
196 |
|
197 |
|
198 // ----------------------------------------------------------------------------- |
|
199 // CUpnpCpbDescriptionAgent::ConstructAndValidateDeviceTreeL |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 void CUpnpCpbDescriptionAgent::ConstructAndValidateDeviceTreeL( |
|
203 const TDesC8& aDeviceDescXml, const TInetAddr& aAddr, |
|
204 const TDesC8& aDeviceDescPath ) |
|
205 { |
|
206 CUpnpDevice* device = NULL; |
|
207 TInt error; |
|
208 if(iDeviceRepository.MatchTargetDevice(_L8("*"))) |
|
209 { |
|
210 CUpnpDeviceDescription* deviceDescription =new CUpnpDeviceDescription(); |
|
211 TRAP( error, iSaxController->ParseDeviceL( aDeviceDescXml,deviceDescription ) ); |
|
212 if(!error) |
|
213 { |
|
214 CleanupStack::PushL( deviceDescription ); |
|
215 RBuf8 description; |
|
216 if(deviceDescription->UrlBase().Length()!=0) |
|
217 { |
|
218 description.Create(aDeviceDescPath.Length()+deviceDescription->UrlBase().Length()); |
|
219 description.Copy(deviceDescription->UrlBase()); |
|
220 TInt firstSlash(aDeviceDescPath.Locate( KSlash8()[0] ) ); |
|
221 if(firstSlash==0) |
|
222 description.Append( aDeviceDescPath.Mid( firstSlash+1,aDeviceDescPath.Length()-1 ) ); |
|
223 else |
|
224 description.Append(aDeviceDescPath); |
|
225 deviceDescription->SetDescriptionUrlL(description); |
|
226 description.Close(); |
|
227 } |
|
228 else |
|
229 { |
|
230 TBuf<25> ipBuf; |
|
231 description.Create(KUrlMaxLength); |
|
232 description.Copy(KHttp()); |
|
233 |
|
234 aAddr.Output ( ipBuf); |
|
235 description.Append(ipBuf); |
|
236 description.Append(_L8(":")); |
|
237 ipBuf.Num(aAddr.Port()); |
|
238 description.Append(ipBuf); |
|
239 description.Append(aDeviceDescPath); |
|
240 deviceDescription->SetDescriptionUrlL(description); |
|
241 description.Close(); |
|
242 } |
|
243 CleanupStack::Pop(deviceDescription); |
|
244 device=deviceDescription; |
|
245 } |
|
246 } |
|
247 else |
|
248 { |
|
249 TRAP( error, device = iSaxController->ParseDeviceL( aDeviceDescXml ) ); |
|
250 } |
|
251 |
|
252 if ( error || ( !device ) ) // Description is wrong |
|
253 { |
|
254 if( iUuid.Length() ) |
|
255 { |
|
256 iTimer->Cancel(); |
|
257 iPendingDiscovery = EFalse; |
|
258 StopIgnoringUuidL(iUuid); |
|
259 } |
|
260 DiscoverNextDeviceL(); |
|
261 return; |
|
262 } |
|
263 |
|
264 if ( aDeviceDescPath.Length() != 0 ) |
|
265 { |
|
266 SetUrlBaseL( device, aDeviceDescPath ); |
|
267 } |
|
268 |
|
269 // Device is invalid |
|
270 if( !IsDeviceValid( device ) ) |
|
271 { |
|
272 delete device; |
|
273 if( iUuid.Length() ) |
|
274 { |
|
275 iTimer->Cancel(); |
|
276 iPendingDiscovery = EFalse; |
|
277 StopIgnoringUuidL(iUuid); |
|
278 } |
|
279 DiscoverNextDeviceL(); |
|
280 return; |
|
281 } |
|
282 |
|
283 // Check if device is know now |
|
284 if( iDeviceRepository.IsKnownDevice( device->Uuid() )) |
|
285 { |
|
286 delete device; |
|
287 iTimer->Cancel(); |
|
288 iPendingDiscovery = EFalse; |
|
289 DiscoverNextDeviceL(); |
|
290 return; |
|
291 } |
|
292 // Is device partialy discovered |
|
293 CUpnpDevice* oldDevice = |
|
294 iDeviceRepository.FindIncompliteDevice( device->Uuid() ); |
|
295 if( oldDevice ) |
|
296 { |
|
297 iDeviceRepository.RemoveDevice( oldDevice ); |
|
298 delete device; |
|
299 device = oldDevice; |
|
300 } |
|
301 |
|
302 RPointerArray<CUpnpDevice> devices; |
|
303 device->GetAllDevices( devices ); |
|
304 devices.AppendL( device ); |
|
305 |
|
306 CUpnpDevice::TUpnpDeviceNetwork network = FindNetworkForDeviceTree( devices ); |
|
307 |
|
308 for (TInt i = 0; i < devices.Count(); i++ ) |
|
309 { |
|
310 devices[i]->SetAddress( aAddr ); |
|
311 devices[i]->SetDeviceNetwork( network ); |
|
312 } |
|
313 devices.Reset(); |
|
314 devices.Close(); |
|
315 |
|
316 ChooseDesriptionProcesor(device); |
|
317 HandleDiscoveryResultL(iDiscoveryEngine->DiscoverDeviceL(device)); |
|
318 } |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // This function sets UrlBase value based on the relative path of the description URL |
|
322 // ----------------------------------------------------------------------------- |
|
323 // |
|
324 void CUpnpCpbDescriptionAgent::SetUrlBaseL( |
|
325 CUpnpDevice* aDevice, const TDesC8& aPath ) |
|
326 { |
|
327 if ( aDevice->UrlBase().Length( ) == 0 ) |
|
328 { |
|
329 TInt firstSlash(aPath.Locate( KSlash8()[0] ) ); |
|
330 TInt lastSlash(aPath.LocateReverse( KSlash8()[0] ) ); |
|
331 if ( firstSlash == lastSlash ) |
|
332 { |
|
333 aDevice->SetUrlBaseL( KSlash8( ) ); |
|
334 } |
|
335 else |
|
336 { |
|
337 aDevice->SetUrlBaseL( aPath.Mid( firstSlash, lastSlash ) ); |
|
338 } |
|
339 } |
|
340 TPtrC8 baseURL(aDevice->UrlBase( ) ); |
|
341 |
|
342 RPointerArray<CUpnpDevice> devices; |
|
343 aDevice->GetAllDevices( devices ); |
|
344 CleanupClosePushL( devices ); |
|
345 |
|
346 for ( TInt i(0); i< devices.Count( ); i++ ) |
|
347 { |
|
348 if ( devices[i]->UrlBase().Length( ) == 0 ) |
|
349 { |
|
350 devices[i]->SetUrlBaseL( baseURL ); |
|
351 } |
|
352 } |
|
353 CleanupStack::PopAndDestroy( &devices ); |
|
354 } |
|
355 |
|
356 // ----------------------------------------------------------------------------- |
|
357 // CUpnpCpbDescriptionAgent::ChooseDesriptionProcesor |
|
358 // ----------------------------------------------------------------------------- |
|
359 // |
|
360 void CUpnpCpbDescriptionAgent::ChooseDesriptionProcesor(CUpnpDevice* aDevice) |
|
361 { |
|
362 if( aDevice->DeviceList().Count() ) |
|
363 { |
|
364 iDiscoveryEngine = iEmbeddedDiscoveryEngine; |
|
365 } |
|
366 else |
|
367 { |
|
368 iDiscoveryEngine = iSimpleDiscoveryEngine; |
|
369 } |
|
370 } |
|
371 |
|
372 // ----------------------------------------------------------------------------- |
|
373 // CUpnpCpbDescriptionAgent::FindNetworkForDeviceTree |
|
374 // ----------------------------------------------------------------------------- |
|
375 // |
|
376 CUpnpDevice::TUpnpDeviceNetwork CUpnpCpbDescriptionAgent::FindNetworkForDeviceTree( |
|
377 RPointerArray<CUpnpDevice>& aDevices ) |
|
378 { |
|
379 CUpnpDevice::TUpnpDeviceNetwork network = CUpnpDevice::EUnknown; |
|
380 for (TInt i = 0; i < aDevices.Count(); i++ ) |
|
381 { |
|
382 CUpnpDevice* ssdpDevice = |
|
383 iDeviceRepository.RemoveIncomingDevice( aDevices[i]->Uuid() ); |
|
384 if ( ssdpDevice ) |
|
385 { |
|
386 aDevices[i]->SetExpired( EFalse ); |
|
387 network = ssdpDevice->DeviceNetwork(); |
|
388 delete ssdpDevice; |
|
389 if ( network != CUpnpDevice::EUnknown ) |
|
390 { |
|
391 break; |
|
392 } |
|
393 } |
|
394 } |
|
395 return network; |
|
396 } |
|
397 |
|
398 |
|
399 // ----------------------------------------------------------------------------- |
|
400 // CUpnpCpbDescriptionAgent::ProcessServiceMessageL |
|
401 // Process service message |
|
402 // ----------------------------------------------------------------------------- |
|
403 // |
|
404 void CUpnpCpbDescriptionAgent::ProcessServiceMessageL( |
|
405 CUpnpHttpMessage* aHttpMessage) |
|
406 { |
|
407 if(iDiscoveryEngine) |
|
408 { |
|
409 HandleDiscoveryResultL( |
|
410 iDiscoveryEngine->ServiceDescriptionL(aHttpMessage) ); |
|
411 } |
|
412 } |
|
413 |
|
414 // ----------------------------------------------------------------------------- |
|
415 // CUpnpCpbDescriptionAgent::DiscoverNextDeviceL |
|
416 // Start next device discovery |
|
417 // ----------------------------------------------------------------------------- |
|
418 // |
|
419 void CUpnpCpbDescriptionAgent::DiscoverNextDeviceL() |
|
420 { |
|
421 // search for new target device |
|
422 while( iIncomingDevices.Count() > 0 ) |
|
423 { |
|
424 CUpnpDevice* tempDevice = iIncomingDevices[0]; |
|
425 iIncomingDevices.Remove(0); |
|
426 CleanupStack::PushL( tempDevice ); |
|
427 |
|
428 CUpnpDevice* tempDevice2 = |
|
429 iDeviceRepository.FindDevice( tempDevice->Uuid() ); |
|
430 |
|
431 if( !tempDevice2 ) |
|
432 { |
|
433 GetDeviceDescriptionL( tempDevice ); |
|
434 CleanupStack::Pop( tempDevice ); |
|
435 break; |
|
436 } |
|
437 else |
|
438 { |
|
439 tempDevice2->SetExpired( EFalse ); |
|
440 CleanupStack::PopAndDestroy( tempDevice ); |
|
441 } |
|
442 } |
|
443 } |
|
444 |
|
445 // ----------------------------------------------------------------------------- |
|
446 // CUpnpCpbDescriptionAgent::GetDeviceDescriptionL |
|
447 // Send get message |
|
448 // ----------------------------------------------------------------------------- |
|
449 // |
|
450 void CUpnpCpbDescriptionAgent::GetDeviceDescriptionL( CUpnpDevice* aDevice ) |
|
451 { |
|
452 iUuid.Close(); |
|
453 iUuid.CreateL( aDevice->Uuid()); |
|
454 if( iDiscoveryEngine ) |
|
455 { |
|
456 iDiscoveryEngine->DeleteTargetDevice(); |
|
457 iDiscoveryEngine = NULL; |
|
458 } |
|
459 |
|
460 iDeviceRepository.AddIncomingDeviceL( aDevice ); |
|
461 |
|
462 iTimer->Start( KDeviceDiscoveryTimeout ); |
|
463 iPendingDiscovery = ETrue; |
|
464 |
|
465 iDescriptionSession = iMessanger.GetDeviceDescriptionL( aDevice ); |
|
466 } |
|
467 |
|
468 // ----------------------------------------------------------------------------- |
|
469 // CUpnpCpbDescriptionAgent::HandleDiscoveryResultL |
|
470 // Function processing disscovery result |
|
471 // ----------------------------------------------------------------------------- |
|
472 // |
|
473 void CUpnpCpbDescriptionAgent::HandleDiscoveryResultL(TInt aResult) |
|
474 { |
|
475 if(aResult == KErrNotFound || aResult == KDisscoveryInProgress) |
|
476 { |
|
477 return; |
|
478 } |
|
479 iTimer->Cancel(); |
|
480 iPendingDiscovery = EFalse; |
|
481 |
|
482 TBool result; |
|
483 if(aResult == KDisscoveryFinished) |
|
484 { |
|
485 result = CopyResult(); |
|
486 if(!result) |
|
487 { |
|
488 StopIgnoringUuidL(iDiscoveryEngine->FailedUuidsL()); |
|
489 } |
|
490 else |
|
491 { |
|
492 iDiscoveryEngine->NullTargetDevice(); |
|
493 ReportDiscoveredDevicesL(); |
|
494 } |
|
495 DiscoverNextDeviceL(); |
|
496 } |
|
497 else if(aResult == KDisscoveryIncorrect) |
|
498 { |
|
499 result = CopyResult(); |
|
500 if(!result) |
|
501 { |
|
502 StopIgnoringUuidL(iDiscoveryEngine->GetTargetDevice()->Uuid()); |
|
503 } |
|
504 else |
|
505 { |
|
506 StopIgnoringUuidL(iDiscoveryEngine->FailedUuidsL()); |
|
507 CUpnpDevice* dev = iDiscoveryEngine->GetIncompliteRootDevice(); |
|
508 if(dev) |
|
509 { |
|
510 iDeviceRepository.AddIncompliteDeviceL(dev); |
|
511 } |
|
512 iDiscoveryEngine->NullTargetDevice(); |
|
513 ReportDiscoveredDevicesL(); |
|
514 } |
|
515 DiscoverNextDeviceL(); |
|
516 } |
|
517 }; |
|
518 |
|
519 // ----------------------------------------------------------------------------- |
|
520 // CUpnpCpbDescriptionAgent::CopyResultL |
|
521 // Copy devices to repository |
|
522 // ----------------------------------------------------------------------------- |
|
523 // |
|
524 TBool CUpnpCpbDescriptionAgent::CopyResult() |
|
525 { |
|
526 TRAPD(error, CopyResultL()); |
|
527 if(error) |
|
528 { |
|
529 RPointerArray<CUpnpDevice> devices; |
|
530 iDiscoveryEngine->GetTargetDevice()->GetAllDevices(devices); |
|
531 for (TInt i(0); i < devices.Count(); i++) |
|
532 { |
|
533 iDeviceRepository.RemoveDevice(devices[i]); |
|
534 } |
|
535 iDeviceRepository.RemoveDevice(iDiscoveryEngine->GetTargetDevice()); |
|
536 devices.Close(); |
|
537 return EFalse; |
|
538 } |
|
539 return ETrue; |
|
540 } |
|
541 |
|
542 // ----------------------------------------------------------------------------- |
|
543 // CUpnpCpbDescriptionAgent::CopyResultL |
|
544 // Copy devices to repository |
|
545 // ----------------------------------------------------------------------------- |
|
546 // |
|
547 void CUpnpCpbDescriptionAgent::CopyResultL() |
|
548 { |
|
549 RPointerArray<CUpnpDevice> devices; |
|
550 CleanupClosePushL(devices); |
|
551 iDiscoveryEngine->GetUninterestingDeviceL(devices, ETrue); |
|
552 iDeviceRepository.AddUninterestingDevicesL(devices); |
|
553 devices.Reset(); |
|
554 iDiscoveryEngine->GetUnnededDeviceL(devices, ETrue); |
|
555 iDeviceRepository.AddUnneddedDevicesL(devices); |
|
556 devices.Reset(); |
|
557 iDiscoveryEngine->GetDiscoveredDeviceL(devices, ETrue); |
|
558 iDeviceRepository.AddDiscoveredDevicesL(devices); |
|
559 CleanupStack::PopAndDestroy(&devices); |
|
560 } |
|
561 |
|
562 // ----------------------------------------------------------------------------- |
|
563 // CUpnpCpbDescriptionAgent::ReportDiscoveredDevicesL |
|
564 // Report discovered devices to the client |
|
565 // ----------------------------------------------------------------------------- |
|
566 // |
|
567 void CUpnpCpbDescriptionAgent::ReportDiscoveredDevicesL() |
|
568 { |
|
569 RPointerArray<CUpnpDevice> devices; |
|
570 CleanupClosePushL(devices); |
|
571 iDiscoveryEngine->GetDiscoveredDeviceL(devices); |
|
572 for (TInt i(0); i < devices.Count(); i++) |
|
573 { |
|
574 iBaseCP.DeviceDiscovered(devices[i]); |
|
575 } |
|
576 CleanupStack::PopAndDestroy(&devices); |
|
577 } |
|
578 |
|
579 // ----------------------------------------------------------------------------- |
|
580 // CUpnpCpbDescriptionAgent::StopIgnoringUidL |
|
581 // Send stop filtering message to MH |
|
582 // ----------------------------------------------------------------------------- |
|
583 // |
|
584 void CUpnpCpbDescriptionAgent::StopIgnoringUuidL(const TDesC8& aUuids) |
|
585 { |
|
586 iMessanger.StopIgnoringUuidL(aUuids); |
|
587 } |
|
588 |
|
589 // ----------------------------------------------------------------------------- |
|
590 // CUpnpCpbDescriptionAgent::IsDeviceValid |
|
591 // Check if device is valid |
|
592 // ----------------------------------------------------------------------------- |
|
593 // |
|
594 TBool CUpnpCpbDescriptionAgent::IsDeviceValid( CUpnpDevice* aDevice ) |
|
595 { |
|
596 const TDesC8& targetUuid = aDevice->Uuid(); |
|
597 return !( aDevice->DeviceType() == KNullDesC8() |
|
598 || targetUuid == KNullDesC8() ); |
|
599 } |
|
600 |
|
601 // ----------------------------------------------------------------------------- |
|
602 // CUpnpCpbDescriptionAgent::TimerEventL |
|
603 // Callback function |
|
604 // ----------------------------------------------------------------------------- |
|
605 // |
|
606 void CUpnpCpbDescriptionAgent::TimerEventL( CUpnpNotifyTimer* aTimer ) |
|
607 { |
|
608 if( !(aTimer->iStatus == KErrNone) ) |
|
609 { |
|
610 return; |
|
611 } |
|
612 |
|
613 if ( iPendingDiscovery ) |
|
614 { |
|
615 iPendingDiscovery = FALSE; |
|
616 if(iDiscoveryEngine) |
|
617 { |
|
618 StopIgnoringUuidL(iDiscoveryEngine->FailedUuidsL()); |
|
619 DiscoverNextDeviceL(); |
|
620 } |
|
621 else |
|
622 { |
|
623 if( iUuid.Length() ) |
|
624 { |
|
625 StopIgnoringUuidL(iUuid); |
|
626 } |
|
627 } |
|
628 } |
|
629 } |
|
630 |
|
631 // End of File |