Search in sources :

Example 21 with Device

use of org.cybergarage.upnp.Device in project i2p.i2p by i2p.

the class UPnP method discoverService.

/**
 * Traverses the structure of the router device looking for the port mapping service.
 */
private void discoverService() {
    synchronized (lock) {
        for (Device current : _router.getDeviceList()) {
            String type = current.getDeviceType();
            if (!(WAN_DEVICE.equals(type) || WAN_DEVICE_2.equals(type)))
                continue;
            DeviceList l = current.getDeviceList();
            for (int i = 0; i < current.getDeviceList().size(); i++) {
                Device current2 = l.getDevice(i);
                type = current2.getDeviceType();
                if (!(WANCON_DEVICE.equals(type) || WANCON_DEVICE_2.equals(type)))
                    continue;
                _service = current2.getService(WAN_IP_CONNECTION_2);
                if (_service == null) {
                    _service = current2.getService(WAN_IP_CONNECTION);
                    if (_service == null) {
                        _service = current2.getService(WAN_PPP_CONNECTION);
                        if (_service == null) {
                            if (_log.shouldWarn())
                                _log.warn(_router.getFriendlyName() + " doesn't have any recognized connection type; we won't be able to use it!");
                        }
                    }
                }
                if (_log.shouldWarn()) {
                    Service svc2 = current2.getService(WAN_IPV6_CONNECTION);
                    if (svc2 != null)
                        _log.warn(_router.getFriendlyName() + " supports WANIPv6Connection, but we don't");
                }
                _serviceLacksAPM = false;
                return;
            }
        }
    }
}
Also used : Device(org.cybergarage.upnp.Device) Service(org.cybergarage.upnp.Service) DeviceList(org.cybergarage.upnp.DeviceList) ControlPoint(org.cybergarage.upnp.ControlPoint)

Aggregations

Device (org.cybergarage.upnp.Device)21 UPnPDevice (org.osgi.service.upnp.UPnPDevice)15 ControlPoint (org.cybergarage.upnp.ControlPoint)10 DeviceList (org.cybergarage.upnp.DeviceList)9 Service (org.cybergarage.upnp.Service)6 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)5 ServiceRegistration (org.osgi.framework.ServiceRegistration)5 ServiceReference (org.osgi.framework.ServiceReference)4 Node (org.cybergarage.xml.Node)3 UPnPService (org.osgi.service.upnp.UPnPService)3 Enumeration (java.util.Enumeration)2 Properties (java.util.Properties)2 Vector (java.util.Vector)2 UPnPDeviceImpl (org.apache.felix.upnp.basedriver.importer.core.upnp.UPnPDeviceImpl)2 ServiceList (org.cybergarage.upnp.ServiceList)2 DeviceData (org.cybergarage.upnp.xml.DeviceData)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Dictionary (java.util.Dictionary)1 HashMap (java.util.HashMap)1