use of org.freenetproject.ForwardPortCallback in project i2p.i2p by i2p.
the class UPnP method deviceRemoved.
/**
* DeviceChangeListener
*/
public void deviceRemoved(Device dev) {
String udn = dev.getUDN();
if (_log.shouldLog(Log.WARN))
_log.warn("UP&P device removed : " + dev.getFriendlyName() + " UDN: " + udn);
ForwardPortCallback fpc = null;
Map<ForwardPort, ForwardPortStatus> removeMap = null;
synchronized (lock) {
if (udn != null)
_otherUDNs.remove(udn);
else
_otherUDNs.remove("???");
if (_router == null)
return;
// I2P this wasn't working
// if(_router.equals(dev)) {
String type = dev.getDeviceType();
if ((ROUTER_DEVICE.equals(type) || ROUTER_DEVICE_2.equals(type)) && dev.isRootDevice() && stringEquals(_router.getFriendlyName(), dev.getFriendlyName()) && stringEquals(_router.getUDN(), udn)) {
if (_log.shouldLog(Log.WARN))
_log.warn("UP&P IGD device removed : " + dev.getFriendlyName());
// TODO promote an IGD from _otherUDNs ??
// For now, just clear the others so they can be promoted later
// after a rescan.
_otherUDNs.clear();
_router = null;
_service = null;
_eventVars.clear();
_serviceLacksAPM = false;
if (!portsForwarded.isEmpty()) {
fpc = forwardCallback;
removeMap = new HashMap<ForwardPort, ForwardPortStatus>(portsForwarded.size());
for (ForwardPort port : portsForwarded) {
ForwardPortStatus fps = new ForwardPortStatus(ForwardPortStatus.DEFINITE_FAILURE, "UPnP device removed", port.portNumber);
}
}
portsForwarded.clear();
}
}
if (fpc != null) {
fpc.portForwardStatus(removeMap);
}
}
Aggregations