DviService* DviDevice::ServiceReference(const ServiceType& aServiceType) { DviService* service = NULL; iServiceLock.Wait(); const Brx& fullNameUpnp = aServiceType.FullNameUpnp(); const TUint count = (TUint)iServices.size(); for (TUint i=0; i<count; i++) { DviService* s = iServices[i]; if (s->ServiceType().FullNameUpnp() == fullNameUpnp) { s->AddRef(); service = s; break; } } iServiceLock.Signal(); return service; }
void DviProviderSubscriptionLongPoll::Subscribe(IDvInvocation& aInvocation, const Brx& aClientId, const Brx& aUdn, const Brx& aService, TUint aRequestedDuration, IDvInvocationResponseString& aSid, IDvInvocationResponseUint& aDuration) { if (aRequestedDuration > kTimeoutLongPollSecs) { aRequestedDuration = kTimeoutLongPollSecs; } DviDevice* device = iDvStack.DeviceMap().Find(aUdn); if (device == NULL) { aInvocation.Error(kErrorCodeBadDevice, kErrorDescBadDevice); } DviService* service = NULL; const TUint serviceCount = device->ServiceCount(); for (TUint i=0; i<serviceCount; i++) { DviService* s = &device->Service(i); if (s->ServiceType().PathUpnp() == aService) { service = s; break; } } if (service == NULL) { aInvocation.Error(kErrorCodeBadService, kErrorDescBadService); } Brh sid; device->CreateSid(sid); TUint timeout = aRequestedDuration; DviSubscription* subscription = new DviSubscription(iDvStack, *device, iPropertyUpdateCollection, NULL, sid, timeout); aInvocation.StartResponse(); aSid.Write(subscription->Sid()); aSid.WriteFlush(); aDuration.Write(timeout); aInvocation.EndResponse(); // Start subscription, prompting availability of the first update (covering all state variables) iPropertyUpdateCollection.AddSubscription(aClientId, subscription); iDvStack.SubscriptionManager().AddSubscription(*subscription); service->AddSubscription(subscription); }
TBool DviSessionLpec::SubscriptionData::Matches(DviDevice& aDevice, DviService& aService) const { return (iDevice->Udn() == aDevice.Udn() && iService->ServiceType().FullName() == aService.ServiceType().FullName()); }