Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
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();
}
Exemplo n.º 4
0
void CpProxyAvOpenhomeOrgRadio1::PropertyIdArray(Brh& aIdArray) const
{
    PropertyReadLock();
    ASSERT(iCpSubscriptionStatus == CpProxy::eSubscribed);
    aIdArray.Set(iIdArray->Value());
    PropertyReadUnlock();
}
Exemplo n.º 5
0
void CpProxyOpenhomeOrgTestBasic1::PropertyVarBin(Brh& aVarBin) const
{
    AutoMutex a(iCpProxy.PropertyReadLock());
    if (iCpProxy.GetSubscriptionStatus() != CpProxy::eSubscribed) {
        THROW(ProxyNotSubscribed);
    }
    aVarBin.Set(iVarBin->Value());
}
Exemplo n.º 6
0
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;
}
Exemplo n.º 7
0
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);
}
Exemplo n.º 8
0
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();
}
Exemplo n.º 10
0
void DvProviderAvOpenhomeOrgRadio1C::GetPropertyIdArray(Brh& aValue)
{
    ASSERT(iPropertyIdArray != NULL);
    aValue.Set(iPropertyIdArray->Value());
}
Exemplo n.º 11
0
void InvocationDv::InvocationReadBinary(const TChar* aName, Brh& aData)
{
    ArgumentBinary* arg = static_cast<ArgumentBinary*>(InputArgument(aName));
    aData.Set(arg->Value());
}
Exemplo n.º 12
0
void DvProviderAvOpenhomeOrgPlaylist1::GetPropertyIdArray(Brh& aValue)
{
    aValue.Set(iPropertyIdArray->Value());
}
Exemplo n.º 13
0
void DvProviderOpenhomeOrgTestBasic1::GetPropertyVarBin(Brh& aValue)
{
    ASSERT(iPropertyVarBin != NULL);
    aValue.Set(iPropertyVarBin->Value());
}