DviProtocolUpnp::DviProtocolUpnp(DviDevice& aDevice) : iDevice(aDevice) , iDvStack(aDevice.GetDvStack()) , iLock("DMUP") , iUpdateCount(0) , iSuppressScheduledEvents(false) { SetAttribute(kAttributeKeyVersionMajor, "1"); SetAttribute(kAttributeKeyVersionMinor, "1"); iLock.Wait(); iServer = &(iDvStack.ServerUpnp()); NetworkAdapterList& adapterList = iDvStack.Env().NetworkAdapterList(); Functor functor = MakeFunctor(*this, &DviProtocolUpnp::HandleInterfaceChange); iCurrentAdapterChangeListenerId = adapterList.AddCurrentChangeListener(functor); iSubnetListChangeListenerId = adapterList.AddSubnetListChangeListener(functor); std::vector<NetworkAdapter*>* subnetList = adapterList.CreateSubnetList(); AutoNetworkAdapterRef ref(iDvStack.Env(), "DviProtocolUpnp ctor"); const NetworkAdapter* current = ref.Adapter(); if (current != NULL) { AddInterface(*current); } else { for (TUint i=0; i<subnetList->size(); i++) { NetworkAdapter* subnet = (*subnetList)[i]; try { AddInterface(*subnet); } catch (NetworkError& ) { // some hosts may have adapters that don't support multicast // we can't differentiate between no support ever and transient failure // (typical on Windows & Mac after hibernation) so just ignore this exception // and trust that we'll get advertised on another interface. char* adapterName = subnet->FullName(); LOG2(kTrace, kError, "DvDevice unable to use adapter %s\n", adapterName); delete adapterName; } } } NetworkAdapterList::DestroySubnetList(subnetList); iAliveTimer = new Timer(iDvStack.Env(), MakeFunctor(*this, &DviProtocolUpnp::SendAliveNotifications), "DviProtocolUpnp"); iLock.Signal(); }
char* STDCALL OhNetNetworkAdapterFullName(OhNetHandleNetworkAdapter aNif) { NetworkAdapter* nif = reinterpret_cast<NetworkAdapter*>(aNif); ASSERT(nif != NULL); return nif->FullName(); }