use of com.biglybt.pif.PluginConfigListener in project BiglyBT by BiglySoftware.
the class LocalTrackerPlugin method initialize.
@Override
public void initialize(PluginInterface _plugin_interface) {
plugin_interface = _plugin_interface;
ta_networks = plugin_interface.getTorrentManager().getAttribute(TorrentAttribute.TA_NETWORKS);
ta_peer_sources = plugin_interface.getTorrentManager().getAttribute(TorrentAttribute.TA_PEER_SOURCES);
mon = plugin_interface.getUtilities().getMonitor();
log = plugin_interface.getLogger().getTimeStampedChannel(PLUGIN_NAME);
UIManager ui_manager = plugin_interface.getUIManager();
BasicPluginConfigModel config = ui_manager.createBasicPluginConfigModel(ConfigSection.SECTION_PLUGINS, PLUGIN_CONFIGSECTION_ID);
config.addLabelParameter2("Plugin.localtracker.info");
enabled = config.addBooleanParameter2("Plugin.localtracker.enable", "Plugin.localtracker.enable", true);
config.addLabelParameter2("Plugin.localtracker.networks.info");
final StringParameter subnets = config.addStringParameter2("Plugin.localtracker.networks", "Plugin.localtracker.networks", "");
final BooleanParameter include_wellknown = config.addBooleanParameter2("Plugin.localtracker.wellknownlocals", "Plugin.localtracker.wellknownlocals", true);
config.addLabelParameter2("Plugin.localtracker.autoadd.info");
final StringParameter autoadd = config.addStringParameter2("Plugin.localtracker.autoadd", "Plugin.localtracker.autoadd", "");
/*
* actually these parameters affect LAN detection as a whole, not just the local tracker,
* so leave them enabled...
*
enabled.addEnabledOnSelection( lp1 );
enabled.addEnabledOnSelection( subnets );
enabled.addEnabledOnSelection( lp2 );
enabled.addEnabledOnSelection( autoadd );
*/
final BasicPluginViewModel view_model = plugin_interface.getUIManager().createBasicPluginViewModel("Plugin.localtracker.name");
view_model.setConfigSectionID(PLUGIN_CONFIGSECTION_ID);
view_model.getActivity().setVisible(false);
view_model.getProgress().setVisible(false);
log.addListener(new LoggerChannelListener() {
@Override
public void messageLogged(int type, String content) {
view_model.getLogArea().appendText(content + "\n");
}
@Override
public void messageLogged(String str, Throwable error) {
if (str.length() > 0) {
view_model.getLogArea().appendText(str + "\n");
}
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
error.printStackTrace(pw);
pw.flush();
view_model.getLogArea().appendText(sw.toString() + "\n");
}
});
plugin_start_time = plugin_interface.getUtilities().getCurrentSystemTime();
// Assume we have a core, since this is a plugin
instance_manager = CoreFactory.getSingleton().getInstanceManager();
instance_manager.addListener(this);
plugin_interface.getPluginconfig().addListener(new PluginConfigListener() {
@Override
public void configSaved() {
processSubNets(subnets.getValue(), include_wellknown.getValue());
processAutoAdd(autoadd.getValue());
}
});
processSubNets(subnets.getValue(), include_wellknown.getValue());
processAutoAdd(autoadd.getValue());
final DelayedTask dt = plugin_interface.getUtilities().createDelayedTask(new Runnable() {
@Override
public void run() {
plugin_interface.getDownloadManager().addListener(LocalTrackerPlugin.this);
}
});
dt.queue();
}
use of com.biglybt.pif.PluginConfigListener in project BiglyBT by BiglySoftware.
the class SubscriptionManagerUI method createConfigModel.
private void createConfigModel() {
final SubscriptionManager subs_man = SubscriptionManagerFactory.getSingleton();
configModel = ui_manager.createBasicPluginConfigModel(ConfigSection.SECTION_ROOT, CONFIG_SECTION_ID);
final IntParameter max_results = configModel.addIntParameter2("subscriptions.config.maxresults", "subscriptions.config.maxresults", subs_man.getMaxNonDeletedResults());
// search
final BooleanParameter search_enable = configModel.addBooleanParameter2("subscriptions.search.enable", "subscriptions.search.enable", subs_man.isSearchEnabled());
search_enable.addListener(new ParameterListener() {
@Override
public void parameterChanged(Parameter param) {
subs_man.setSearchEnabled(search_enable.getValue());
}
});
// download subs enable
final BooleanParameter download_subs_enable = configModel.addBooleanParameter2("subscriptions.dl_subs.enable", "subscriptions.dl_subs.enable", subs_man.isSubsDownloadEnabled());
download_subs_enable.addListener(new ParameterListener() {
@Override
public void parameterChanged(Parameter param) {
subs_man.setSubsDownloadEnabled(download_subs_enable.getValue());
}
});
// download subs enable
final BooleanParameter activate_subs_enable = configModel.addBooleanParameter2("subscriptions.activate.on.change.enable", "subscriptions.activate.on.change.enable", subs_man.getActivateSubscriptionOnChange());
activate_subs_enable.addListener(new ParameterListener() {
@Override
public void parameterChanged(Parameter param) {
subs_man.setActivateSubscriptionOnChange(activate_subs_enable.getValue());
}
});
// rate limits
final StringParameter rate_limits = configModel.addStringParameter2("subscriptions.config.ratelimits", "subscriptions.config.ratelimits", subs_man.getRateLimits());
rate_limits.addListener(new ParameterListener() {
@Override
public void parameterChanged(Parameter param) {
subs_man.setRateLimits(rate_limits.getValue());
}
});
// auto
final BooleanParameter auto_start = configModel.addBooleanParameter2("subscriptions.config.autostartdls", "subscriptions.config.autostartdls", subs_man.getAutoStartDownloads());
auto_start.addListener(new ParameterListener() {
@Override
public void parameterChanged(Parameter param) {
subs_man.setAutoStartDownloads(auto_start.getValue());
}
});
final IntParameter min_auto_start_size = configModel.addIntParameter2("subscriptions.config.autostart.min", "subscriptions.config.autostart.min", subs_man.getAutoStartMinMB());
final IntParameter max_auto_start_size = configModel.addIntParameter2("subscriptions.config.autostart.max", "subscriptions.config.autostart.max", subs_man.getAutoStartMaxMB());
auto_start.addEnabledOnSelection(min_auto_start_size);
auto_start.addEnabledOnSelection(max_auto_start_size);
final IntParameter mark_as_read_after = configModel.addIntParameter2("subscriptions.config.mark.read.after", "subscriptions.config.mark.read.after", subs_man.getAutoDownloadMarkReadAfterDays());
configModel.createGroup("subscriptions.config.auto", new Parameter[] { auto_start, min_auto_start_size, max_auto_start_size, mark_as_read_after });
// int param fires intermediate events so we have to rely on the save :(
pluginConfigListener = new PluginConfigListener() {
@Override
public void configSaved() {
subs_man.setMaxNonDeletedResults(max_results.getValue());
subs_man.setAutoStartMinMB(min_auto_start_size.getValue());
subs_man.setAutoStartMaxMB(max_auto_start_size.getValue());
subs_man.setAutoDownloadMarkReadAfterDays(mark_as_read_after.getValue());
}
};
default_pi.getPluginconfig().addListener(pluginConfigListener);
// rss
final BooleanParameter rss_enable = configModel.addBooleanParameter2("subscriptions.rss.enable", "subscriptions.rss.enable", subs_man.isRSSPublishEnabled());
rss_enable.addListener(new ParameterListener() {
@Override
public void parameterChanged(Parameter param) {
subs_man.setRSSPublishEnabled(rss_enable.getValue());
}
});
HyperlinkParameter rss_view = configModel.addHyperlinkParameter2("device.rss.view", subs_man.getRSSLink());
rss_enable.addEnabledOnSelection(rss_view);
configModel.createGroup("device.rss.group", new Parameter[] { rss_enable, rss_view });
}
Aggregations