use of com.biglybt.core.util.Wiki in project BiglyBT by BiglySoftware.
the class ConfigSectionSecurity method build.
@Override
public void build() {
if (cbCreateCert != null) {
ActionParameterImpl cert_button = new ActionParameterImpl("ConfigView.section.tracker.createcert", "ConfigView.section.tracker.createbutton");
add(cert_button);
cert_button.addListener(param -> cbCreateCert.run(mapPluginParams));
}
// row
ActionParameterImpl reset_certs_button = new ActionParameterImpl("ConfigView.section.security.resetcerts", "Button.reset");
add(reset_certs_button);
reset_certs_button.addListener(param -> {
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions == null) {
SESecurityManager.resetTrustStore(false);
return;
}
UIFunctionsUserPrompter prompter = uiFunctions.getUserPrompter(MessageText.getString("ConfigView.section.security.resetcerts.warning.title"), MessageText.getString("ConfigView.section.security.resetcerts.warning.msg"), new String[] { MessageText.getString("Button.ok"), MessageText.getString("Button.cancel") }, 1);
if (prompter == null) {
SESecurityManager.resetTrustStore(false);
return;
}
prompter.setIconResource(UIFunctionsUserPrompter.ICON_WARNING);
prompter.open(returnVal -> {
if (returnVal != 0) {
return;
}
if (SESecurityManager.resetTrustStore(false)) {
UIFunctionsUserPrompter promptComplete = uiFunctions.getUserPrompter(MessageText.getString("ConfigView.section.security.restart.title"), MessageText.getString("ConfigView.section.security.restart.msg"), new String[] { MessageText.getString("Button.ok") }, 0);
if (promptComplete != null) {
promptComplete.open(null);
}
uiFunctions.dispose(true);
} else {
UIFunctionsUserPrompter promptErr = uiFunctions.getUserPrompter(MessageText.getString("ConfigView.section.security.resetcerts.error.title"), MessageText.getString("ConfigView.section.security.resetcerts.error.msg"), new String[] { MessageText.getString("Button.ok") }, 0);
if (promptErr != null) {
promptErr.setIconResource(UIFunctionsUserPrompter.ICON_ERROR);
promptErr.open(null);
}
}
});
});
reset_certs_button.setEnabled(SESecurityManager.resetTrustStore(true));
// row
BooleanParameterImpl auto_install = add(new BooleanParameterImpl(BCFG_SECURITY_CERT_AUTO_INSTALL, "security.cert.auto.install"));
// row
BooleanParameterImpl auto_decline = add(new BooleanParameterImpl(BCFG_SECURITY_CERT_AUTO_DECLINE, "security.cert.auto.decline"));
ParameterListener pl = (n) -> {
if (auto_install.getValue() && auto_decline.getValue()) {
// shouldn't have both set...
auto_decline.setValue(false);
}
if (auto_install.getValue()) {
auto_decline.setEnabled(false);
} else {
auto_decline.setEnabled(true);
}
if (auto_decline.getValue()) {
auto_install.setEnabled(false);
} else {
auto_install.setEnabled(true);
}
};
pl.parameterChanged(null);
auto_install.addListener(pl);
auto_decline.addListener(pl);
// row
add(new LabelParameterImpl("ConfigView.section.security.toolsinfo"));
// row
DirectoryParameterImpl pathParameter = new DirectoryParameterImpl(SCFG_SECURITY_JAR_TOOLS_DIR, "ConfigView.section.security.toolsdir");
add(pathParameter);
pathParameter.setDialogTitleKey("ConfigView.section.security.choosetoolssavedir");
// row
ActionParameterImpl pw_button = new ActionParameterImpl("ConfigView.section.security.clearpasswords", "ConfigView.section.security.clearpasswords.button");
add(pw_button);
pw_button.addListener(param -> {
SESecurityManager.clearPasswords();
CryptoManagerFactory.getSingleton().clearPasswords();
});
CryptoManager crypt_man = CryptoManagerFactory.getSingleton();
List<Parameter> listCrypto = new ArrayList<>();
// wiki link
add(new HyperlinkParameterImpl("ConfigView.label.please.visit.here", Wiki.PUBLIC_PRIVATE_KEYS), listCrypto);
// publick key display
byte[] public_key = crypt_man.getECCHandler().peekPublicKey();
String key = public_key == null ? MessageText.getString("ConfigView.section.security.publickey.undef") : Base32.encode(public_key);
ActionParameterImpl paramPublicKey = new ActionParameterImpl("ConfigView.section.security.publickey", "!" + key + "!");
add(paramPublicKey, listCrypto);
paramPublicKey.setStyle(ActionParameter.STYLE_LINK);
// TODO: Tooltip
// Messages.setLanguageText(public_key_value, "ConfigView.copy.to.clipboard.tooltip", true);
paramPublicKey.addListener(param -> {
UIFunctions uif = UIFunctionsManager.getUIFunctions();
if (uif == null) {
return;
}
uif.copyToClipboard(key);
});
cryptoManagerKeyListener = new CryptoManagerKeyListener() {
@Override
public void keyChanged(final CryptoHandler handler) {
if (handler.getType() == CryptoManager.HANDLER_ECC) {
byte[] public_key = handler.peekPublicKey();
String key = public_key == null ? MessageText.getString("ConfigView.section.security.publickey.undef") : Base32.encode(public_key);
paramPublicKey.setActionResource("!" + key + "!");
}
}
@Override
public void keyLockStatusChanged(CryptoHandler handler) {
}
};
crypt_man.addKeyListener(cryptoManagerKeyListener);
// manage keys
//
// final BooleanParameter manage_keys = new BooleanParameter(
// crypto_group, "crypto.keys.system.managed.temp",
// "ConfigView.section.security.system.managed");
//
// manage_keys.setLayoutData( gridData );
//
// final ClientCryptoManager crypto_man = CryptoManagerFactory.getSingleton();
// final CryptoHandler ecc_handler = crypto_man.getECCHandler();
//
// manage_keys.setSelected(
// ecc_handler.getDefaultPasswordHandlerType() == CryptoManagerPasswordHandler.HANDLER_TYPE_SYSTEM );
//
//
// manage_keys.addChangeListener(
// new ParameterChangeListener ()
// {
// public void
// parameterChanged(
// Parameter p,
// boolean caused_internally )
// {
// boolean existing_value = ecc_handler.getDefaultPasswordHandlerType() == CryptoManagerPasswordHandler.HANDLER_TYPE_SYSTEM;
//
// if ( existing_value == manage_keys.isSelected()){
//
// return;
// }
//
// String error = null;
//
// int new_type = manage_keys.isSelected()?CryptoManagerPasswordHandler.HANDLER_TYPE_SYSTEM:CryptoManagerPasswordHandler.HANDLER_TYPE_USER;
//
// try{
// ecc_handler.setDefaultPasswordHandlerType( new_type );
//
// error = null;
//
// }catch( CryptoManagerPasswordException e ){
//
// if ( e.wasIncorrect()){
//
// error = MessageText.getString( "ConfigView.section.security.unlockkey.error" );
//
// }else{
//
// if ( existing_value || !ecc_handler.isUnlocked()){
//
// error = MessageText.getString( "Torrent.create.progress.cancelled" );
//
// }else{
//
// error = MessageText.getString( "ConfigView.section.security.vuze.login" );
// }
// }
// }catch( Throwable e ){
//
// error = Debug.getNestedExceptionMessage( e );
// }
//
// if ( error != null ){
//
// MessageBoxShell mb = new MessageBoxShell(
// SWT.ICON_ERROR | SWT.OK,
// MessageText.getString("ConfigView.section.security.op.error.title"),
// MessageText.getString("ConfigView.section.security.op.error",
// new String[] { error }));
// mb.setParent(parent.getShell());
// mb.open(null);
// }
//
// boolean new_value = ecc_handler.getDefaultPasswordHandlerType() == CryptoManagerPasswordHandler.HANDLER_TYPE_SYSTEM;
//
// if ( new_value != manage_keys.isSelected()){
//
// manage_keys.setSelected( new_value );
// }
// }
// });
// reset keys
ActionParameterImpl reset_key_button = new ActionParameterImpl("ConfigView.section.security.resetkey", "ConfigView.section.security.clearpasswords.button");
add(reset_key_button, listCrypto);
reset_key_button.addListener(param -> {
UIFunctions uif = UIFunctionsManager.getUIFunctions();
if (uif != null) {
UIFunctionsUserPrompter prompter = uif.getUserPrompter(MessageText.getString("ConfigView.section.security.resetkey.warning.title"), MessageText.getString("ConfigView.section.security.resetkey.warning"), new String[] { MessageText.getString("Button.ok"), MessageText.getString("Button.cancel") }, 1);
if (prompter != null) {
prompter.setIconResource(UIFunctionsUserPrompter.ICON_WARNING);
prompter.open(returnVal -> {
if (returnVal != 0) {
return;
}
try {
crypt_man.getECCHandler().resetKeys("Manual key reset");
} catch (Throwable e) {
UIFunctionsUserPrompter warningPrompt = uif.getUserPrompter(MessageText.getString("ConfigView.section.security.resetkey.error.title"), getError(e), new String[] { MessageText.getString("Button.ok") }, 0);
if (warningPrompt != null) {
warningPrompt.setIconResource(UIFunctionsUserPrompter.ICON_ERROR);
warningPrompt.open(null);
}
}
});
}
return;
}
// fallback
try {
crypt_man.getECCHandler().resetKeys("Manual key reset (no prompt)");
} catch (Throwable e) {
Debug.out(e);
}
});
// unlock
ActionParameterImpl priv_key_button = new ActionParameterImpl("ConfigView.section.security.unlockkey", "ConfigView.section.security.unlockkey.button");
add(priv_key_button, listCrypto);
priv_key_button.addListener(param -> {
try {
crypt_man.getECCHandler().getEncryptedPrivateKey("Manual unlock");
} catch (Throwable e) {
UIFunctions uif = UIFunctionsManager.getUIFunctions();
if (uif == null) {
Debug.out(e);
} else {
UIFunctionsUserPrompter warningPrompt = uif.getUserPrompter(MessageText.getString("ConfigView.section.security.resetkey.error.title"), getError(e), new String[] { MessageText.getString("Button.ok") }, 0);
if (warningPrompt != null) {
warningPrompt.setIconResource(UIFunctionsUserPrompter.ICON_ERROR);
warningPrompt.open(null);
}
}
}
});
if (cbBackupKeys != null) {
ActionParameterImpl backup_keys_button = new ActionParameterImpl("ConfigView.section.security.backupkeys", "ConfigView.section.security.backupkeys.button");
add(backup_keys_button, listCrypto);
backup_keys_button.addListener(param -> cbBackupKeys.run(mapPluginParams));
}
if (cbRestoreKeys != null) {
ActionParameterImpl restore_keys_button = new ActionParameterImpl("ConfigView.section.security.restorekeys", "ConfigView.section.security.restorekeys.button");
add(restore_keys_button, listCrypto);
reset_certs_button.addListener(param -> cbRestoreKeys.run(mapPluginParams));
}
add("pgCrypto", new ParameterGroupImpl("ConfigView.section.security.group.crypto", listCrypto));
}
use of com.biglybt.core.util.Wiki in project BiglyBT by BiglySoftware.
the class ConfigSectionBackupRestore method build.
@Override
public void build() {
Core core = CoreFactory.getSingleton();
BackupManager backup_manager = BackupManagerFactory.getManager(core);
List<Parameter> listBackupParams = new ArrayList<>();
add("overview", new LabelParameterImpl("ConfigView.section.br.overview"));
// wiki link
add(SECTION_ID + ".link", new HyperlinkParameterImpl("ConfigView.label.please.visit.here", Wiki.BACKUP_AND_RESTORE));
// backup
long backup_time = backup_manager.getLastBackupTime();
InfoParameterImpl paramInfoLastTime = new InfoParameterImpl(null, "br.backup.last.time", backup_time == 0 ? "" : String.valueOf(new Date(backup_time)));
add(PP_BACKUP_LAST_TIME, paramInfoLastTime, listBackupParams);
InfoParameterImpl paramInfoLastErr = new InfoParameterImpl(null, "br.backup.last.error", backup_manager.getLastBackupError());
add(PP_BACKUP_LAST_ERR, paramInfoLastErr, listBackupParams);
if (cbManualBackup != null) {
ActionParameterImpl paramBackupButton = new ActionParameterImpl("br.backup.manual.info", "br.backup");
paramBackupButton.setStyle(ActionParameter.STYLE_BUTTON);
paramBackupButton.addListener(param -> cbManualBackup.run(mapPluginParams));
add("btnManualBackup", paramBackupButton, listBackupParams);
}
BooleanParameterImpl paramEnableBackup = new BooleanParameterImpl(BCFG_BACKUP_AUTO_ENABLE, "br.backup.auto.enable");
add(paramEnableBackup, listBackupParams);
//
DirectoryParameterImpl paramPath = new DirectoryParameterImpl(SCFG_BACKUP_AUTO_DIR, "ConfigView.section.file.defaultdir.ask");
add(paramPath, listBackupParams);
paramPath.setDialogTitleKey("ConfigView.section.file.defaultdir.ask");
paramPath.setDialogMessageKey("br.backup.auto.dir.select");
if (paramPath.getValue().length() == 0) {
String def_dir = COConfigurationManager.getStringParameter(SCFG_BACKUP_FOLDER_DEFAULT);
paramPath.setValue(def_dir);
}
paramPath.addListener(p -> {
String path = ((DirectoryParameter) p).getValue();
COConfigurationManager.setParameter(SCFG_BACKUP_FOLDER_DEFAULT, path);
});
//
BooleanParameterImpl paramDoPlugins = new BooleanParameterImpl(BCFG_BACKUP_PLUGINS, "br.backup.do.plugins");
add(paramDoPlugins, listBackupParams);
IntParameterImpl paramBackupDays = new IntParameterImpl(ICFG_BACKUP_AUTO_EVERYDAYS, ICFG_BACKUP_AUTO_EVERYDAYS, 0, Integer.MAX_VALUE);
add(paramBackupDays, listBackupParams);
IntParameterImpl paramBackupHours = new IntParameterImpl(ICFG_BACKUP_AUTO_EVERYHOURS, ICFG_BACKUP_AUTO_EVERYHOURS, 0, Integer.MAX_VALUE);
add(paramBackupHours, listBackupParams);
IntParameterImpl paramAutoRetain = new IntParameterImpl(ICFG_BACKUP_AUTO_RETAIN, ICFG_BACKUP_AUTO_RETAIN, 1, Integer.MAX_VALUE);
add(paramAutoRetain, listBackupParams);
BooleanParameterImpl paramNotify = new BooleanParameterImpl(BCFG_BACKUP_NOTIFY, "br.backup.notify");
paramNotify.setAllowedUiTypes(UIInstance.UIT_SWT);
add(paramNotify, listBackupParams);
ActionParameterImpl paramBackupNow = new ActionParameterImpl("br.backup.auto.now", "br.test");
add("backupNow", paramBackupNow, listBackupParams);
paramBackupNow.addListener(param -> {
if (cbBackupNow == null) {
backup_manager.runAutoBackup(null);
} else {
cbBackupNow.run(mapPluginParams);
}
});
ParameterListener enableListener = (n) -> {
boolean enable = paramEnableBackup.getValue();
boolean hoursEnable = enable && paramBackupDays.getValue() == 0;
paramPath.setEnabled(enable);
paramBackupDays.setEnabled(enable);
paramBackupHours.setEnabled(hoursEnable);
paramAutoRetain.setEnabled(enable);
paramNotify.setEnabled(enable);
paramBackupNow.setEnabled(enable);
};
paramEnableBackup.addListener(enableListener);
paramBackupDays.addListener(enableListener);
enableListener.parameterChanged(null);
add(new ParameterGroupImpl("br.backup", listBackupParams));
if (cbRestore != null) {
List<Parameter> listRestoreParams = new ArrayList<>();
ActionParameterImpl paramButtonRestore = new ActionParameterImpl("br.restore.info", "br.restore");
add(SECTION_ID + ".restore", paramButtonRestore, listRestoreParams);
paramButtonRestore.addListener(param -> cbRestore.run(mapPluginParams));
add(new BooleanParameterImpl(BCFG_RESTORE_AUTOPAUSE, BCFG_RESTORE_AUTOPAUSE), listRestoreParams);
add(new ParameterGroupImpl("br.restore", listRestoreParams));
}
}
use of com.biglybt.core.util.Wiki in project BiglyBT by BiglySoftware.
the class ConfigSectionTransfer method build.
@Override
public void build() {
// store the initial d/l speed so we can do something sensible later
final int[] manual_max_download_speed = { COConfigurationManager.getIntParameter(ICFG_MAX_DOWNLOAD_SPEED_KBS) };
// max upload speed
IntParameterImpl paramMaxUploadSpeed = new IntParameterImpl(ICFG_MAX_UPLOAD_SPEED_KBS, "ConfigView.label.maxuploadspeed", 0, Integer.MAX_VALUE);
add(paramMaxUploadSpeed);
// max upload speed when seeding
BooleanParameterImpl enable_seeding_rate = new BooleanParameterImpl(BCFG_ENABLE_SEEDINGONLY_UPLOAD_RATE, "ConfigView.label.maxuploadspeedseeding");
add(enable_seeding_rate);
IntParameterImpl paramMaxUploadSpeedSeeding = new IntParameterImpl(ICFG_MAX_UPLOAD_SPEED_SEEDING_KBS, null, 0, Integer.MAX_VALUE);
add(paramMaxUploadSpeedSeeding);
enable_seeding_rate.addEnabledOnSelection(paramMaxUploadSpeedSeeding);
add("cMaxUploadSpeedOptionsArea", new ParameterGroupImpl(null, enable_seeding_rate, paramMaxUploadSpeedSeeding).setNumberOfColumns2(2));
int userMode = COConfigurationManager.getIntParameter(ICFG_USER_MODE);
// todo: Create a Parameter.setMaximumRequiredUserMode
if (userMode < Parameter.MODE_ADVANCED) {
// wiki link
add(new HyperlinkParameterImpl("ConfigView.section.transfer.speeds.wiki", "Utils.link.visit", Wiki.GOOD_SETTINGS));
}
add(new IntParameterImpl(ICFG_MAX_UPLOADS_WHEN_BUSY_INC_MIN_SECS, "ConfigView.label.maxuploadswhenbusymin", 0, Integer.MAX_VALUE), Parameter.MODE_ADVANCED);
// max download speed
IntParameterImpl paramMaxDownSpeed = new IntParameterImpl(ICFG_MAX_DOWNLOAD_SPEED_KBS, "ConfigView.label.maxdownloadspeed", 0, Integer.MAX_VALUE);
add(paramMaxDownSpeed);
// max upload/download limit dependencies
ParameterListener l = param -> {
boolean disableAuto;
boolean disableAutoSeeding;
if (enable_seeding_rate.getValue()) {
disableAutoSeeding = param == paramMaxUploadSpeedSeeding;
disableAuto = param == paramMaxDownSpeed || param == paramMaxUploadSpeed;
} else {
disableAuto = true;
disableAutoSeeding = true;
}
if (disableAuto)
COConfigurationManager.setParameter(TransferSpeedValidator.AUTO_UPLOAD_ENABLED_CONFIGKEY, false);
if (disableAutoSeeding)
COConfigurationManager.setParameter(TransferSpeedValidator.AUTO_UPLOAD_SEEDING_ENABLED_CONFIGKEY, false);
};
paramMaxDownSpeed.addListener(l);
paramMaxUploadSpeed.addListener(l);
paramMaxUploadSpeedSeeding.addListener(l);
paramMaxUploadSpeed.addListener(param -> CoreFactory.addCoreRunningListener(core -> {
if (TransferSpeedValidator.isAutoSpeedActive(core.getGlobalManager())) {
return;
}
int up_val = paramMaxUploadSpeed.getValue();
int down_val = paramMaxDownSpeed.getValue();
if (up_val != 0 && up_val < COConfigurationManager.CONFIG_DEFAULT_MIN_MAX_UPLOAD_SPEED) {
if ((down_val == 0) || down_val > (up_val * 2)) {
paramMaxDownSpeed.setValue(up_val * 2);
}
} else {
if (down_val != manual_max_download_speed[0]) {
paramMaxDownSpeed.setValue(manual_max_download_speed[0]);
}
}
}));
paramMaxDownSpeed.addListener(param -> CoreFactory.addCoreRunningListener(core -> {
if (TransferSpeedValidator.isAutoSpeedActive(core.getGlobalManager())) {
return;
}
int up_val = paramMaxUploadSpeed.getValue();
int down_val = paramMaxDownSpeed.getValue();
manual_max_download_speed[0] = down_val;
if (up_val < COConfigurationManager.CONFIG_DEFAULT_MIN_MAX_UPLOAD_SPEED) {
if (up_val != 0 && up_val < (down_val * 2)) {
paramMaxUploadSpeed.setValue((down_val + 1) / 2);
} else if (down_val == 0) {
paramMaxUploadSpeed.setValue(0);
}
}
}));
// bias upload to incomplete
BooleanParameterImpl bias_upload = new BooleanParameterImpl(BCFG_BIAS_UPLOAD_ENABLE, "ConfigView.label.xfer.bias_up");
add(bias_upload, Parameter.MODE_INTERMEDIATE);
IntParameterImpl bias_slack = new IntParameterImpl(ICFG_BIAS_UPLOAD_SLACK_KBS, "ConfigView.label.xfer.bias_slack", 1, Integer.MAX_VALUE);
add(bias_slack, Parameter.MODE_INTERMEDIATE);
bias_slack.setIndent(1, true);
BooleanParameterImpl bias_no_limit = new BooleanParameterImpl(BCFG_BIAS_UPLOAD_HANDLE_NO_LIMIT, "ConfigView.label.xfer.bias_no_limit");
add(bias_no_limit, Parameter.MODE_INTERMEDIATE);
bias_no_limit.setIndent(1, true);
bias_upload.addEnabledOnSelection(bias_slack, bias_no_limit);
List<Parameter> listAuto = new ArrayList<>();
// AUTO GROUP
BooleanParameterImpl auto_adjust = new BooleanParameterImpl(BCFG_AUTO_ADJUST_TRANSFER_DEFAULTS, "ConfigView.label.autoadjust");
add(auto_adjust, Parameter.MODE_INTERMEDIATE);
// max uploads
IntParameterImpl paramMaxUploads = new IntParameterImpl(ICFG_MAX_UPLOADS, "ConfigView.label.maxuploads", 2, Integer.MAX_VALUE);
add(paramMaxUploads, Parameter.MODE_INTERMEDIATE, listAuto);
// max uploads when seeding
BooleanParameterImpl enable_seeding_uploads = new BooleanParameterImpl(BCFG_ENABLE_SEEDINGONLY_MAXUPLOADS, "ConfigView.label.maxuploadsseeding");
add(enable_seeding_uploads, Parameter.MODE_INTERMEDIATE);
IntParameterImpl paramMaxUploadsSeeding = new IntParameterImpl(ICFG_MAX_UPLOADS_SEEDING, null, 2, Integer.MAX_VALUE);
add(paramMaxUploadsSeeding, Parameter.MODE_INTERMEDIATE);
add("Transfer.pgMaxUpSeeding", new ParameterGroupImpl(null, enable_seeding_uploads, paramMaxUploadsSeeding).setNumberOfColumns2(2), listAuto);
// //
IntParameterImpl paramMaxClients = new IntParameterImpl(ICFG_MAX_PEER_CONNECTIONS_PER_TORRENT, "ConfigView.label.max_peers_per_torrent");
add(paramMaxClients, Parameter.MODE_INTERMEDIATE, listAuto);
// ///
// max peers when seeding
BooleanParameterImpl enable_max_peers_seeding = new BooleanParameterImpl(BCFG_MAX_PEER_CONNECTIONS_PER_TORRENT_WHEN_SEEDING_ENABLE, "ConfigView.label.maxuploadsseeding");
add(enable_max_peers_seeding, Parameter.MODE_INTERMEDIATE);
IntParameterImpl paramMaxPeersSeeding = new IntParameterImpl(ICFG_MAX_PEER_CONNECTIONS_PER_TORRENT_WHEN_SEEDING, null, 0, Integer.MAX_VALUE);
add(paramMaxPeersSeeding, Parameter.MODE_INTERMEDIATE);
add("Transfer.pgMaxPeersSeeding", new ParameterGroupImpl(null, enable_max_peers_seeding, paramMaxPeersSeeding).setNumberOfColumns2(2), listAuto);
// ///
IntParameterImpl paramMaxClientsTotal = new IntParameterImpl(ICFG_MAX_PEER_CONNECTIONS_TOTAL, "ConfigView.label.max_peers_total");
add(paramMaxClientsTotal, Parameter.MODE_INTERMEDIATE, listAuto);
IntParameterImpl max_seeds_per_torrent = new IntParameterImpl(ICFG_MAX_SEEDS_PER_TORRENT, "ConfigView.label.maxseedspertorrent");
add(max_seeds_per_torrent, Parameter.MODE_INTERMEDIATE, listAuto);
auto_adjust.addDisabledOnSelection(listAuto.toArray(new Parameter[0]));
enable_seeding_uploads.addEnabledOnSelection(paramMaxUploadsSeeding);
enable_max_peers_seeding.addEnabledOnSelection(paramMaxPeersSeeding);
listAuto.add(0, auto_adjust);
add("Transfer.gAuto", new ParameterGroupImpl("group.auto", listAuto));
// NON PUBLIC PEERS GROUP
List<Parameter> listNPP = new ArrayList<>();
add(new IntParameterImpl(ICFG_NON_PUBLIC_PEER_EXTRA_SLOTS_PER_TORRENT, "ConfigView.label.npp.slots", 0, Integer.MAX_VALUE), Parameter.MODE_INTERMEDIATE, listNPP);
add(new IntParameterImpl(ICFG_NON_PUBLIC_PEER_EXTRA_CONNECTIONS_PER_TORRENT, "ConfigView.label.npp.connections", 0, Integer.MAX_VALUE), Parameter.MODE_INTERMEDIATE, listNPP);
add("Transfer.NPP", new ParameterGroupImpl("label.non.public.peers", listNPP));
// END NON PUBLIC PEERS GROUP
BooleanParameterImpl useReqLimiting = new BooleanParameterImpl(BCFG_USE_REQUEST_LIMITING, "ConfigView.label.userequestlimiting");
add(useReqLimiting, Parameter.MODE_INTERMEDIATE);
BooleanParameterImpl useReqLimitingPrios = new BooleanParameterImpl(BCFG_USE_REQUEST_LIMITING_PRIORITIES, "ConfigView.label.userequestlimitingpriorities");
add(useReqLimitingPrios, Parameter.MODE_INTERMEDIATE);
useReqLimitingPrios.setIndent(1, true);
useReqLimiting.addEnabledOnSelection(useReqLimitingPrios);
// up limits include protocol
BooleanParameterImpl upIncludesProt = new BooleanParameterImpl(BCFG_UP_RATE_LIMITS_INCLUDE_PROTOCOL, "ConfigView.label.up.includes.prot");
add(upIncludesProt, Parameter.MODE_INTERMEDIATE);
// down limits include protocol
BooleanParameterImpl downIncludesProt = new BooleanParameterImpl(BCFG_DOWN_RATE_LIMITS_INCLUDE_PROTOCOL, "ConfigView.label.down.includes.prot");
add(downIncludesProt, Parameter.MODE_INTERMEDIATE);
// same IP
BooleanParameterImpl allowSameIP = new BooleanParameterImpl(BCFG_ALLOW_SAME_IP_PEERS, "ConfigView.label.allowsameip");
add(allowSameIP, Parameter.MODE_INTERMEDIATE);
// both IPv4 and IPv6 connections
int[] values = { 0, 1, 2 };
String[] labels = { MessageText.getString("label.allow.both"), MessageText.getString("label.ban.ipv4"), MessageText.getString("label.ban.ipv6") };
IntListParameterImpl paramDualIPAction = new IntListParameterImpl(ICFG_IPv4_IPv6_CONN_ACTION, "ConfigView.label.dual.con.behaviour", values, labels);
add(paramDualIPAction, Parameter.MODE_INTERMEDIATE);
// lazy bit field
BooleanParameterImpl lazybf = new BooleanParameterImpl(BCFG_USE_LAZY_BITFIELD, "ConfigView.label.lazybitfield");
add(lazybf, Parameter.MODE_INTERMEDIATE);
// don't declare completion
BooleanParameterImpl hap = new BooleanParameterImpl(BCFG_PEERCONTROL_HIDE_PIECE, "ConfigView.label.hap");
add(hap, Parameter.MODE_ADVANCED);
BooleanParameterImpl hapds = new BooleanParameterImpl(BCFG_PEERCONTROL_HIDE_PIECE_DS, "ConfigView.label.hapds");
add(hapds, Parameter.MODE_ADVANCED);
hapds.setIndent(1, true);
hap.addEnabledOnSelection(hapds);
// prioritise first/last pieces
BooleanParameterImpl pfp = new BooleanParameterImpl(BCFG_PRIORITIZE_FIRST_PIECE, "ConfigView.label.prioritizefirstpiece");
add(pfp, Parameter.MODE_INTERMEDIATE);
IntParameterImpl pMB = new IntParameterImpl(ICFG_PRIORITIZE_FIRST_MB, "", 0, Integer.MAX_VALUE);
String[] units = { DisplayFormatters.getUnit(DisplayFormatters.UNIT_MB) };
pMB.setLabelText(MessageText.getString("ConfigView.label.prioritizefirstmb", units));
pMB.setIndent(1, true);
add(pMB, Parameter.MODE_INTERMEDIATE);
// prioritise first/last pieces Force
BooleanParameterImpl pfpf = new BooleanParameterImpl(BCFG_PRIORITIZE_FIRST_PIECE_FORCE, "ConfigView.label.prioritizefirstpiece.force");
pfpf.setIndent(1, true);
add(pfpf, Parameter.MODE_INTERMEDIATE);
pfp.addEnabledOnSelection(pfpf);
pfp.addEnabledOnSelection(pMB);
// Further prioritize High priority files according to % complete and size of file
add(new BooleanParameterImpl(BCFG_PRIORITIZE_MOST_COMPLETED_FILES, "ConfigView.label.prioritizemostcompletedfiles"), Parameter.MODE_INTERMEDIATE);
// ignore ports
StringParameterImpl paramIgnorePeerPorts = new StringParameterImpl(SCFG_IGNORE_PEER_PORTS, "ConfigView.label.transfer.ignorepeerports");
add(paramIgnorePeerPorts, Parameter.MODE_INTERMEDIATE);
add("gIgnore.peer.ports", new ParameterGroupImpl(null, paramIgnorePeerPorts));
}
use of com.biglybt.core.util.Wiki in project BiglyBT by BiglySoftware.
the class StartStopConfigModel method initDownloadingSection.
public void initDownloadingSection() {
UIManager manager = pi.getUIManager();
BasicPluginConfigModel model = manager.createBasicPluginConfigModel(SECTION_ID_Q, SECTION_ID_Q_DL);
// Seeding Automation Setup
// wiki link
model.addHyperlinkParameter2("ConfigView.label.please.visit.here", Wiki.DOWNLOADING_RULES);
// sort type
String[] orderLabels = { MessageText.getString("label.order"), MessageText.getString("label.seed.count"), MessageText.getString("label.reverse.seed.count"), MessageText.getString("TableColumn.header.size"), MessageText.getString("label.reverse.size"), MessageText.getString("label.speed"), MessageText.getString("TableColumn.header.eta") };
int[] orderValues = { DefaultRankCalculator.DOWNLOAD_ORDER_INDEX, DefaultRankCalculator.DOWNLOAD_ORDER_SEED_COUNT, DefaultRankCalculator.DOWNLOAD_ORDER_REVERSE_SEED_COUNT, DefaultRankCalculator.DOWNLOAD_ORDER_SIZE, DefaultRankCalculator.DOWNLOAD_ORDER_REVERSE_SIZE, DefaultRankCalculator.DOWNLOAD_ORDER_SPEED, DefaultRankCalculator.DOWNLOAD_ORDER_ETA };
IntListParameter sort_type = model.addIntListParameter2("StartStopManager_Downloading_iSortType", "label.prioritize.downloads.based.on", orderValues, orderLabels, DefaultRankCalculator.DOWNLOAD_ORDER_INDEX);
List<Parameter> listSpeed = new ArrayList<>();
// info
listSpeed.add(model.addLabelParameter2("ConfigView.label.downloading.info"));
// test time
IntParameter testTime = model.addIntParameter2("StartStopManager_Downloading_iTestTimeSecs", "ConfigView.label.downloading.testTime", 120);
listSpeed.add(testTime);
testTime.setMinValue(60);
// re-test
IntParameter reTest = model.addIntParameter2("StartStopManager_Downloading_iRetestTimeMins", "ConfigView.label.downloading.reTest", 30);
listSpeed.add(reTest);
reTest.setMinValue(0);
BooleanParameter testActive = model.addBooleanParameter2("StartStopManager_Downloading_bTestActive", "ConfigView.label.downloading.testActive", false);
listSpeed.add(testActive);
ParameterListener sortTypeListener = p -> {
int type = sort_type.getValue();
boolean is_speed = type == DefaultRankCalculator.DOWNLOAD_ORDER_SPEED || type == DefaultRankCalculator.DOWNLOAD_ORDER_ETA;
testTime.setEnabled(is_speed);
reTest.setEnabled(is_speed);
testActive.setEnabled(is_speed);
};
sort_type.addListener(sortTypeListener);
sortTypeListener.parameterChanged(null);
model.createGroup("label.speed.options", listSpeed.toArray(new Parameter[0]));
model.addBooleanParameter2("StartStopManager_bAddForDownloadingSR1", "ConfigView.label.downloading.addsr1", true);
}
Aggregations