예제 #1
0
  protected void setDeviceStats(String USN, String stat_key, long value) {
    String key = "upnp.device.stats." + stat_key;

    PluginConfig pc = plugin_interface.getPluginconfig();

    Map counts = pc.getPluginMapParameter(key, new HashMap());

    counts.put(USN, new Long(value));

    pc.getPluginMapParameter(key, counts);
  }
예제 #2
0
  protected void ignoreDevice(String USN, URL location) {
    // only take note of this if enabled to do so

    if (ignore_bad_devices.getValue()) {

      try {
        PluginConfig pc = plugin_interface.getPluginconfig();

        Map ignored = pc.getPluginMapParameter("upnp.device.ignorelist", new HashMap());

        Map entry = (Map) ignored.get(USN);

        if (entry == null) {

          entry = new HashMap();

          entry.put("Location", location.toString().getBytes());

          ignored.put(USN, entry);

          pc.setPluginMapParameter("upnp.device.ignorelist", ignored);

          updateIgnoreList();

          String text =
              plugin_interface
                  .getUtilities()
                  .getLocaleUtilities()
                  .getLocalisedMessageText(
                      "upnp.ignorebaddevices.alert", new String[] {location.toString()});

          log.logAlertRepeatable(LoggerChannel.LT_WARNING, text);
        }
      } catch (Throwable e) {

        Debug.printStackTrace(e);
      }
    }
  }
예제 #3
0
  protected void logNoRepeat(String usn, String msg) {
    synchronized (log_no_repeat_map) {
      String last = (String) log_no_repeat_map.get(usn);

      if (last != null && last.equals(msg)) {

        return;
      }

      log_no_repeat_map.put(usn, msg);
    }

    log.log(msg);
  }
예제 #4
0
  public void rootDeviceFound(UPnPRootDevice device) {
    incrementDeviceStats(device.getUSN(), "found");

    checkDeviceStats(device);

    try {
      int interesting = processDevice(device.getDevice());

      if (interesting > 0) {

        try {
          this_mon.enter();

          root_info_map.put(device.getLocation(), device.getInfo());

          Iterator<String> it = root_info_map.values().iterator();

          String all_info = "";

          List reported_info = new ArrayList();

          while (it.hasNext()) {

            String info = (String) it.next();

            if (info != null && !reported_info.contains(info)) {

              reported_info.add(info);

              all_info += (all_info.length() == 0 ? "" : ",") + info;
            }
          }

          if (all_info.length() > 0) {

            plugin_interface.getPluginconfig().setPluginParameter("plugin.info", all_info);
          }

        } finally {

          this_mon.exit();
        }
      }
    } catch (Throwable e) {

      log.log("Root device processing fails", e);
    }
  }
예제 #5
0
  protected long incrementDeviceStats(String USN, String stat_key) {
    String key = "upnp.device.stats." + stat_key;

    PluginConfig pc = plugin_interface.getPluginconfig();

    Map counts = pc.getPluginMapParameter(key, new HashMap());

    Long count = (Long) counts.get(USN);

    if (count == null) {

      count = new Long(1);

    } else {

      count = new Long(count.longValue() + 1);
    }

    counts.put(USN, count);

    pc.getPluginMapParameter(key, counts);

    return (count.longValue());
  }