コード例 #1
0
ファイル: DviProtocolUpnp.cpp プロジェクト: Jacik/ohNet
DviProtocolUpnpAdapterSpecificData* DviProtocolUpnp::AddInterface(const NetworkAdapter& aAdapter)
{
    TIpAddress addr = aAdapter.Address();
    Bws<Uri::kMaxUriBytes> uriBase;
    TUint port = iServer->Port(addr);
    DviDevice* root = (iDevice.IsRoot()? &iDevice : iDevice.Root());
    root->GetUriBase(uriBase, addr, port, *this);
    DviProtocolUpnpAdapterSpecificData* adapter = new DviProtocolUpnpAdapterSpecificData(iDvStack, *this, aAdapter, uriBase, port);
    iAdapters.push_back(adapter);
    return adapter;
}
コード例 #2
0
ファイル: DviProtocolUpnp.cpp プロジェクト: Jacik/ohNet
void DviProtocolUpnp::Enable()
{
    iLock.Wait();
    
    // check we have at least the basic attributes requried for advertisement
    ASSERT(Domain().Bytes() > 0);
    ASSERT(Type().Bytes() > 0);
    ASSERT(Version() > 0);
    
    for (TUint i=0; i<iAdapters.size(); i++) {
        DviProtocolUpnpAdapterSpecificData* adapter = iAdapters[i];
        Bws<Uri::kMaxUriBytes> uriBase;
        DviDevice* root = (iDevice.IsRoot()? &iDevice : iDevice.Root());
        adapter->UpdateServerPort(*iServer);
        root->GetUriBase(uriBase, adapter->Interface(), adapter->ServerPort(), *this);
        adapter->UpdateUriBase(uriBase);
        adapter->ClearDeviceXml();
        if (iDevice.ResourceManager() != NULL) {
            const TChar* name = 0;
            GetAttribute("FriendlyName", &name);
            adapter->BonjourRegister(name, iDevice.Udn(), kProtocolName, iDevice.kResourceDir);
            /*GetAttribute("MdnsHostName", &name);
            if (name != NULL) {
                iDvStack.MdnsProvider()->MdnsSetHostName(name);
                Bwh redirectedPath(iDevice.Udn().Bytes() + kProtocolName.Bytes() + iDevice.kResourceDir.Bytes() + 4);
                redirectedPath.Append('/');
                Uri::Escape(redirectedPath, iDevice.Udn());
                redirectedPath.Append('/');
                redirectedPath.Append(kProtocolName);
                redirectedPath.Append('/');
                redirectedPath.Append(iDevice.kResourceDir);
                redirectedPath.Append('/');
                iDvStack.ServerUpnp().Redirect(Brn("/"), redirectedPath);
            }*/
        }
    }
    for (TUint i=0; i<iAdapters.size(); i++) {
        iAdapters[i]->SendByeByeThenAlive(*this);
    }
    iLock.Signal();
    QueueAliveTimer();
}