Example #1
0
  protected int processDevice(UPnPDevice device) throws UPnPException {

    int interesting = processServices(device, device.getServices());

    UPnPDevice[] kids = device.getSubDevices();

    for (int i = 0; i < kids.length; i++) {

      interesting += processDevice(kids[i]);
    }

    return (interesting);
  }
Example #2
0
  public UPnPPluginService[] getServices(UPnPDevice device) {
    String target_usn = device.getRootDevice().getUSN();

    List<UPnPPluginService> res = new ArrayList<UPnPPluginService>();

    try {
      this_mon.enter();

      for (UPnPPluginService service : services) {

        String this_usn =
            service.getService().getGenericService().getDevice().getRootDevice().getUSN();

        if (this_usn.equals(target_usn)) {

          res.add(service);
        }
      }
    } finally {

      this_mon.exit();
    }

    return (res.toArray(new UPnPPluginService[res.size()]));
  }
Example #3
0
  protected int processServices(UPnPDevice device, UPnPService[] device_services)
      throws UPnPException {
    int interesting = 0;

    for (int i = 0; i < device_services.length; i++) {

      UPnPService s = device_services[i];

      String service_type = s.getServiceType();

      if (service_type.equalsIgnoreCase("urn:schemas-upnp-org:service:WANIPConnection:1")
          || service_type.equalsIgnoreCase("urn:schemas-upnp-org:service:WANPPPConnection:1")) {

        final UPnPWANConnection wan_service = (UPnPWANConnection) s.getSpecificService();

        device
            .getRootDevice()
            .addListener(
                new UPnPRootDeviceListener() {
                  public void lost(UPnPRootDevice root, boolean replaced) {
                    removeService(wan_service, replaced);
                  }
                });

        addService(wan_service);

        interesting++;

      } else if (service_type.equalsIgnoreCase(
          "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")) {

        /* useless stats
        try{
        	UPnPWANCommonInterfaceConfig	config = (UPnPWANCommonInterfaceConfig)s.getSpecificService();

        	long[]	speeds = config.getCommonLinkProperties();

        	if ( speeds[0] > 0 && speeds[1] > 0 ){

        		log.log( "Device speed: down=" +
        					plugin_interface.getUtilities().getFormatters().formatByteCountToKiBEtcPerSec(speeds[0]/8) + ", up=" +
        					plugin_interface.getUtilities().getFormatters().formatByteCountToKiBEtcPerSec(speeds[1]/8));
        	}
        }catch( Throwable e ){

        	log.log(e);
        }
        */
      }
    }

    return (interesting);
  }