TBool CpiDeviceUpnp::GetAttribute(const char* aKey, Brh& aValue) const { Brn key(aKey); Parser parser(key); if (parser.Next('.') == Brn("Upnp")) { Brn property = parser.Remaining(); if (property == Brn("Location")) { aValue.Set(iLocation); return (true); } if (property == Brn("DeviceXml")) { aValue.Set(iXml); return (true); } const DeviceXml* device = iDeviceXml; if (parser.Next('.') == Brn("Root")) { device = &iDeviceXmlDocument->Root(); property.Set(parser.Remaining()); } try { if (property == Brn("FriendlyName")) { device->GetFriendlyName(aValue); return (true); } if (property == Brn("PresentationUrl")) { device->GetPresentationUrl(aValue); return (true); } Parser parser(property); Brn token = parser.Next('.'); if (token == Brn("Service")) { aValue.Set(device->ServiceVersion(parser.Remaining())); return (true); } } catch (XmlError&) { } } return (false); }
int32_t STDCALL DvProviderAvOpenhomeOrgRadio1SetPropertyIdArray(THandle aProvider, const char* aValue, uint32_t aValueLen, uint32_t* aChanged) { Brh buf; buf.Set((const TByte*)aValue, aValueLen); *aChanged = (reinterpret_cast<DvProviderAvOpenhomeOrgRadio1C*>(aProvider)->SetPropertyIdArray(buf)? 1 : 0); return 0; }
void DvProviderAvOpenhomeOrgRadio1C::DoIdArray(IDviInvocation& aInvocation) { DvInvocationCPrivate invocationWrapper(aInvocation); IDvInvocationC* invocationC; void* invocationCPtr; invocationWrapper.GetInvocationC(&invocationC, &invocationCPtr); aInvocation.InvocationReadStart(); aInvocation.InvocationReadEnd(); DviInvocation invocation(aInvocation); uint32_t Token; char* Array; uint32_t ArrayLen; ASSERT(iCallbackIdArray != NULL); if (0 != iCallbackIdArray(iPtrIdArray, invocationC, invocationCPtr, &Token, &Array, &ArrayLen)) { invocation.Error(502, Brn("Action failed")); return; } DviInvocationResponseUint respToken(aInvocation, "Token"); DviInvocationResponseBinary respArray(aInvocation, "Array"); invocation.StartResponse(); respToken.Write(Token); Brh bufArray; bufArray.Set((const TByte*)Array, ArrayLen); OhNetFreeExternal(Array); respArray.Write(bufArray); respArray.WriteFlush(); invocation.EndResponse(); }
void CpProxyAvOpenhomeOrgRadio1::PropertyIdArray(Brh& aIdArray) const { PropertyReadLock(); ASSERT(iCpSubscriptionStatus == CpProxy::eSubscribed); aIdArray.Set(iIdArray->Value()); PropertyReadUnlock(); }
void CpProxyOpenhomeOrgTestBasic1::PropertyVarBin(Brh& aVarBin) const { AutoMutex a(iCpProxy.PropertyReadLock()); if (iCpProxy.GetSubscriptionStatus() != CpProxy::eSubscribed) { THROW(ProxyNotSubscribed); } aVarBin.Set(iVarBin->Value()); }
TBool CpiDeviceDv::GetAttribute(const char* aKey, Brh& aValue) const { const TChar* value = NULL; iDeviceDv.GetAttribute(aKey, &value); if (value != NULL) { aValue.Set(value); } return false; }
void CpiSubscription::DoSubscribe() { CpStack& cpStack = iDevice.GetCpStack(); Bws<Uri::kMaxUriBytes> uri; uri.Append(Http::kSchemeHttp); NetworkAdapter* nif = cpStack.Env().NetworkAdapterList().CurrentAdapter("CpiSubscription::DoSubscribe"); if (nif == NULL) { THROW(NetworkError); } TIpAddress nifAddr = nif->Address(); nif->RemoveRef("CpiSubscription::DoSubscribe"); Endpoint endpt(cpStack.SubscriptionManager().EventServerPort(), nifAddr); Endpoint::EndpointBuf buf; endpt.AppendEndpoint(buf); uri.Append(buf); uri.Append('/'); Uri subscriber(uri); LOG(kEvent, "Subscribing - service = "); LOG(kEvent, iServiceType.FullName()); LOG(kEvent, "\n subscriber = "); LOG(kEvent, subscriber.AbsoluteUri()); LOG(kEvent, "\n"); iNextSequenceNumber = 0; TUint renewSecs; try { renewSecs = iDevice.Subscribe(*this, subscriber); } catch (XmlError&) { // we don't expect to ever get here. Its worth capturing some debug info if we do. Brh deviceXml; if (!iDevice.GetAttribute("Upnp.DeviceXml", deviceXml)) { deviceXml.Set("[missing]"); } const Brx& udn = iDevice.Udn(); cpStack.Env().Mutex().Wait(); Log::Print("XmlError attempting to subscribe to device "); Log::Print(udn); Log::Print(", with xml\n\n"); Log::Print(deviceXml); Log::Print("\n\n"); cpStack.Env().Mutex().Signal(); THROW(XmlError); } cpStack.SubscriptionManager().Add(*this); LOG(kEvent, "Subscription for "); LOG(kEvent, iServiceType.FullName()); LOG(kEvent, " completed\n Sid is "); LOG(kEvent, iSid); LOG(kEvent, "\n Renew in %u secs\n", renewSecs); SetRenewTimer(renewSecs); }
uint32_t STDCALL ServicePropertySetValueBinary(ServiceProperty aProperty, uint8_t* aValue, uint32_t aLen) { PropertyBinary* prop = reinterpret_cast<PropertyBinary*>(aProperty); ASSERT(prop != NULL); Brh data; data.Set(aValue, aLen); if (prop->SetValue(data)) { return 1; } return 0; }
void DvProviderAvOpenhomeOrgCredentials1C::DoGet(IDviInvocation& aInvocation) { DvInvocationCPrivate invocationWrapper(aInvocation); IDvInvocationC* invocationC; void* invocationCPtr; invocationWrapper.GetInvocationC(&invocationC, &invocationCPtr); aInvocation.InvocationReadStart(); Brhz Id; aInvocation.InvocationReadString("Id", Id); aInvocation.InvocationReadEnd(); DviInvocation invocation(aInvocation); char* UserName; char* Password; uint32_t PasswordLen; uint32_t Enabled; char* Status; char* Data; ASSERT(iCallbackGet != NULL); if (0 != iCallbackGet(iPtrGet, invocationC, invocationCPtr, (const char*)Id.Ptr(), &UserName, &Password, &PasswordLen, &Enabled, &Status, &Data)) { invocation.Error(502, Brn("Action failed")); return; } DviInvocationResponseString respUserName(aInvocation, "UserName"); DviInvocationResponseBinary respPassword(aInvocation, "Password"); DviInvocationResponseBool respEnabled(aInvocation, "Enabled"); DviInvocationResponseString respStatus(aInvocation, "Status"); DviInvocationResponseString respData(aInvocation, "Data"); invocation.StartResponse(); Brhz bufUserName((const TChar*)UserName); OhNetFreeExternal(UserName); respUserName.Write(bufUserName); respUserName.WriteFlush(); Brh bufPassword; bufPassword.Set((const TByte*)Password, PasswordLen); OhNetFreeExternal(Password); respPassword.Write(bufPassword); respPassword.WriteFlush(); respEnabled.Write((Enabled!=0)); Brhz bufStatus((const TChar*)Status); OhNetFreeExternal(Status); respStatus.Write(bufStatus); respStatus.WriteFlush(); Brhz bufData((const TChar*)Data); OhNetFreeExternal(Data); respData.Write(bufData); respData.WriteFlush(); invocation.EndResponse(); }
void DvProviderAvOpenhomeOrgRadio1C::GetPropertyIdArray(Brh& aValue) { ASSERT(iPropertyIdArray != NULL); aValue.Set(iPropertyIdArray->Value()); }
void InvocationDv::InvocationReadBinary(const TChar* aName, Brh& aData) { ArgumentBinary* arg = static_cast<ArgumentBinary*>(InputArgument(aName)); aData.Set(arg->Value()); }
void DvProviderAvOpenhomeOrgPlaylist1::GetPropertyIdArray(Brh& aValue) { aValue.Set(iPropertyIdArray->Value()); }
void DvProviderOpenhomeOrgTestBasic1::GetPropertyVarBin(Brh& aValue) { ASSERT(iPropertyVarBin != NULL); aValue.Set(iPropertyVarBin->Value()); }