Search in sources :

Example 6 with PluginConfig

use of com.biglybt.pif.PluginConfig in project BiglyBT by BiglySoftware.

the class UPnPPlugin method updateIgnoreList.

protected void updateIgnoreList() {
    try {
        String param = "";
        if (ignore_bad_devices.getValue()) {
            PluginConfig pc = plugin_interface.getPluginconfig();
            Map ignored = pc.getPluginMapParameter("upnp.device.ignorelist", new HashMap());
            Iterator it = ignored.entrySet().iterator();
            while (it.hasNext()) {
                Map.Entry entry = (Map.Entry) it.next();
                Map value = (Map) entry.getValue();
                param += "\n    " + entry.getKey() + ": " + new String((byte[]) value.get("Location"));
            }
            if (ignored.size() > 0) {
                log.log("Devices currently being ignored: " + param);
            }
        }
        String text = plugin_interface.getUtilities().getLocaleUtilities().getLocalisedMessageText("upnp.ignorebaddevices.info", new String[] { param });
        ignored_devices_list.setLabelText(text);
    } catch (Throwable e) {
        Debug.printStackTrace(e);
    }
}
Also used : PluginConfig(com.biglybt.pif.PluginConfig)

Example 7 with PluginConfig

use of com.biglybt.pif.PluginConfig in project BiglyBT by BiglySoftware.

the class DHTPluginImpl method updateStats.

public void updateStats(int sample_stats_ticks) {
    stats_ticks++;
    if (transport != null) {
        PluginConfig conf = plugin_interface.getPluginconfig();
        boolean current_reachable = transport.isReachable();
        if (current_reachable != conf.getPluginBooleanParameter("dht.reachable." + network, true)) {
            // reachability has changed
            conf.setPluginParameter("dht.reachable." + network, current_reachable);
            if (!current_reachable) {
                String msg = "If you have a router/firewall, please check that you have port " + port + " UDP open.\nDecentralised tracking requires this.";
                int warned_port = plugin_interface.getPluginconfig().getPluginIntParameter("udp_warned_port", 0);
                if (warned_port == port || !warn_user_param.getValue()) {
                    log.log(msg);
                } else {
                    plugin_interface.getPluginconfig().setPluginParameter("udp_warned_port", port);
                    log.logAlert(LoggerChannel.LT_WARNING, msg);
                }
            } else {
                log.log("Reachability changed for the better");
            }
        }
        if (stats_ticks % sample_stats_ticks == 0) {
            logStats();
        }
    }
}
Also used : PluginConfig(com.biglybt.pif.PluginConfig)

Example 8 with PluginConfig

use of com.biglybt.pif.PluginConfig in project BiglyBT by BiglySoftware.

the class UPnPPlugin method setDeviceStats.

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);
}
Also used : PluginConfig(com.biglybt.pif.PluginConfig)

Example 9 with PluginConfig

use of com.biglybt.pif.PluginConfig in project BiglyBT by BiglySoftware.

the class UPnPPlugin method getDeviceStats.

protected long getDeviceStats(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) {
        return (0);
    }
    return (count.longValue());
}
Also used : PluginConfig(com.biglybt.pif.PluginConfig)

Example 10 with PluginConfig

use of com.biglybt.pif.PluginConfig in project BiglyBT by BiglySoftware.

the class UPnPPlugin method startUp.

protected void startUp() {
    if (upnp != null) {
        // already started up, must have been re-enabled
        refreshMappings();
        return;
    }
    final LoggerChannel core_log = plugin_interface.getLogger().getChannel("UPnP Core");
    try {
        upnp = UPnPFactory.getSingleton(new UPnPAdapter() {

            Set exception_traces = new HashSet();

            @Override
            public SimpleXMLParserDocument parseXML(String data) throws SimpleXMLParserDocumentException {
                return (plugin_interface.getUtilities().getSimpleXMLParserDocumentFactory().create(data));
            }

            @Override
            public ResourceDownloaderFactory getResourceDownloaderFactory() {
                return (plugin_interface.getUtilities().getResourceDownloaderFactory());
            }

            @Override
            public UTTimer createTimer(String name) {
                return (plugin_interface.getUtilities().createTimer(name, true));
            }

            @Override
            public void createThread(String name, Runnable runnable) {
                plugin_interface.getUtilities().createThread(name, runnable);
            }

            @Override
            public Comparator getAlphanumericComparator() {
                return (plugin_interface.getUtilities().getFormatters().getAlphanumericComparator(true));
            }

            @Override
            public void trace(String str) {
                core_log.log(str);
                if (trace_to_log.getValue()) {
                    upnp_log_listener.log(str);
                }
            }

            @Override
            public void log(Throwable e) {
                String nested = Debug.getNestedExceptionMessage(e);
                if (!exception_traces.contains(nested)) {
                    exception_traces.add(nested);
                    if (exception_traces.size() > 128) {
                        exception_traces.clear();
                    }
                    core_log.log(e);
                } else {
                    core_log.log(nested);
                }
            }

            @Override
            public void log(String str) {
                log.log(str);
            }

            @Override
            public String getTraceDir() {
                return (plugin_interface.getUtilities().getUserDir());
            }
        }, getSelectedInterfaces());
        upnp.addRootDeviceListener(this);
        upnp_log_listener = new UPnPLogListener() {

            @Override
            public void log(String str) {
                log.log(str);
            }

            @Override
            public void logAlert(String str, boolean error, int type) {
                boolean logged = false;
                if (alert_device_probs_param.getValue()) {
                    if (type == UPnPLogListener.TYPE_ALWAYS) {
                        log.logAlertRepeatable(error ? LoggerChannel.LT_ERROR : LoggerChannel.LT_WARNING, str);
                        logged = true;
                    } else {
                        boolean do_it = false;
                        if (type == UPnPLogListener.TYPE_ONCE_EVER) {
                            byte[] fp = plugin_interface.getUtilities().getSecurityManager().calculateSHA1(str.getBytes());
                            String key = "upnp.alert.fp." + plugin_interface.getUtilities().getFormatters().encodeBytesToString(fp);
                            PluginConfig pc = plugin_interface.getPluginconfig();
                            if (!pc.getPluginBooleanParameter(key, false)) {
                                pc.setPluginParameter(key, true);
                                do_it = true;
                            }
                        } else {
                            do_it = true;
                        }
                        if (do_it) {
                            log.logAlert(error ? LoggerChannel.LT_ERROR : LoggerChannel.LT_WARNING, str);
                            logged = true;
                        }
                    }
                }
                if (!logged) {
                    log.log(str);
                }
            }
        };
        upnp.addLogListener(upnp_log_listener);
        mapping_manager.addListener(new UPnPMappingManagerListener() {

            @Override
            public void mappingAdded(UPnPMapping mapping) {
                addMapping(mapping);
            }
        });
        UPnPMapping[] upnp_mappings = mapping_manager.getMappings();
        for (int i = 0; i < upnp_mappings.length; i++) {
            addMapping(upnp_mappings[i]);
        }
        setNATPMPEnableState();
    } catch (Throwable e) {
        log.log(e);
    }
}
Also used : PluginConfig(com.biglybt.pif.PluginConfig) LoggerChannel(com.biglybt.pif.logging.LoggerChannel)

Aggregations

PluginConfig (com.biglybt.pif.PluginConfig)12 DownloadManager (com.biglybt.core.download.DownloadManager)1 MessageText (com.biglybt.core.internat.MessageText)1 CryptoHandler (com.biglybt.core.security.CryptoHandler)1 CryptoManager (com.biglybt.core.security.CryptoManager)1 CryptoManagerKeyListener (com.biglybt.core.security.CryptoManagerKeyListener)1 Tag (com.biglybt.core.tag.Tag)1 UPnPWANConnectionPortMapping (com.biglybt.net.upnp.services.UPnPWANConnectionPortMapping)1 PluginListener (com.biglybt.pif.PluginListener)1 Download (com.biglybt.pif.download.Download)1 DownloadScrapeResult (com.biglybt.pif.download.DownloadScrapeResult)1 LoggerChannel (com.biglybt.pif.logging.LoggerChannel)1 LoggerChannelListener (com.biglybt.pif.logging.LoggerChannelListener)1 Torrent (com.biglybt.pif.torrent.Torrent)1 UIInputReceiverListener (com.biglybt.pif.ui.UIInputReceiverListener)1 UIManager (com.biglybt.pif.ui.UIManager)1 UIManagerEvent (com.biglybt.pif.ui.UIManagerEvent)1 BasicPluginConfigModel (com.biglybt.pif.ui.model.BasicPluginConfigModel)1 BasicPluginViewModel (com.biglybt.pif.ui.model.BasicPluginViewModel)1 DelayedTask (com.biglybt.pif.utils.DelayedTask)1