use of com.biglybt.ui.swt.auth.CertificateCreatorWindow in project BiglyBT by BiglySoftware.
the class ConfigSectionSecurity method configSectionCreate.
@Override
public Composite configSectionCreate(final Composite parent) {
int userMode = COConfigurationManager.getIntParameter("User Mode");
java.util.List<Button> buttons = new ArrayList<>();
GridData gridData;
Composite gSecurity = new Composite(parent, SWT.NULL);
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
gSecurity.setLayoutData(gridData);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
gSecurity.setLayout(layout);
// row
Label cert_label = new Label(gSecurity, SWT.NULL);
Messages.setLanguageText(cert_label, "ConfigView.section.tracker.createcert");
Button cert_button = new Button(gSecurity, SWT.PUSH);
buttons.add(cert_button);
Messages.setLanguageText(cert_button, "ConfigView.section.tracker.createbutton");
cert_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
new CertificateCreatorWindow();
}
});
new Label(gSecurity, SWT.NULL);
// row
Label reset_certs_label = new Label(gSecurity, SWT.NULL);
Messages.setLanguageText(reset_certs_label, "ConfigView.section.security.resetcerts");
Button reset_certs_button = new Button(gSecurity, SWT.PUSH);
buttons.add(reset_certs_button);
Messages.setLanguageText(reset_certs_button, "Button.reset");
reset_certs_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_WARNING | SWT.OK | SWT.CANCEL, MessageText.getString("ConfigView.section.security.resetcerts.warning.title"), MessageText.getString("ConfigView.section.security.resetcerts.warning.msg"));
mb.setDefaultButtonUsingStyle(SWT.CANCEL);
mb.setParent(parent.getShell());
mb.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int returnVal) {
if (returnVal != SWT.OK) {
return;
}
if (SESecurityManager.resetTrustStore(false)) {
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_INFORMATION | SWT.OK, MessageText.getString("ConfigView.section.security.restart.title"), MessageText.getString("ConfigView.section.security.restart.msg"));
mb.setParent(parent.getShell());
mb.open(null);
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null) {
uiFunctions.dispose(true, false);
}
} else {
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_ERROR | SWT.OK, MessageText.getString("ConfigView.section.security.resetcerts.error.title"), MessageText.getString("ConfigView.section.security.resetcerts.error.msg"));
mb.setParent(parent.getShell());
mb.open(null);
}
}
});
}
});
reset_certs_button.setEnabled(SESecurityManager.resetTrustStore(true));
new Label(gSecurity, SWT.NULL);
// row
gridData = new GridData();
gridData.horizontalSpan = 3;
new BooleanParameter(gSecurity, "security.cert.auto.install", "security.cert.auto.install").setLayoutData(gridData);
// row
Label info_label = new Label(gSecurity, SWT.WRAP);
Messages.setLanguageText(info_label, "ConfigView.section.security.toolsinfo");
info_label.setLayoutData(Utils.getWrappableLabelGridData(3, 0));
// row
Label lStatsPath = new Label(gSecurity, SWT.NULL);
// $NON-NLS-1$
Messages.setLanguageText(lStatsPath, "ConfigView.section.security.toolsdir");
ImageLoader imageLoader = ImageLoader.getInstance();
Image imgOpenFolder = imageLoader.getImage("openFolderButton");
gridData = new GridData();
gridData.widthHint = 150;
// $NON-NLS-1$ //$NON-NLS-2$
final StringParameter pathParameter = new StringParameter(gSecurity, "Security.JAR.tools.dir", "");
pathParameter.setLayoutData(gridData);
Button browse = new Button(gSecurity, SWT.PUSH);
browse.setImage(imgOpenFolder);
imgOpenFolder.setBackground(browse.getBackground());
browse.setToolTipText(MessageText.getString("ConfigView.button.browse"));
browse.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
DirectoryDialog dialog = new DirectoryDialog(parent.getShell(), SWT.APPLICATION_MODAL);
dialog.setFilterPath(pathParameter.getValue());
// $NON-NLS-1$
dialog.setText(MessageText.getString("ConfigView.section.security.choosetoolssavedir"));
String path = dialog.open();
if (path != null) {
pathParameter.setValue(path);
}
}
});
// row
Label pw_label = new Label(gSecurity, SWT.NULL);
Messages.setLanguageText(pw_label, "ConfigView.section.security.clearpasswords");
Button pw_button = new Button(gSecurity, SWT.PUSH);
buttons.add(pw_button);
Messages.setLanguageText(pw_button, "ConfigView.section.security.clearpasswords.button");
pw_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
SESecurityManager.clearPasswords();
CryptoManagerFactory.getSingleton().clearPasswords();
}
});
new Label(gSecurity, SWT.NULL);
if (userMode >= 2) {
final CryptoManager crypt_man = CryptoManagerFactory.getSingleton();
final Group crypto_group = new Group(gSecurity, SWT.NULL);
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 3;
crypto_group.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 3;
crypto_group.setLayout(layout);
Messages.setLanguageText(crypto_group, "ConfigView.section.security.group.crypto");
// wiki link
final Label linkLabel = new Label(crypto_group, SWT.NULL);
linkLabel.setText(MessageText.getString("ConfigView.label.please.visit.here"));
linkLabel.setData(Constants.URL_WIKI + "w/Public_Private_Keys");
linkLabel.setCursor(linkLabel.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
linkLabel.setForeground(Colors.blue);
gridData = new GridData();
gridData.horizontalSpan = 3;
linkLabel.setLayoutData(gridData);
linkLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent arg0) {
Utils.launch((String) ((Label) arg0.widget).getData());
}
@Override
public void mouseDown(MouseEvent arg0) {
Utils.launch((String) ((Label) arg0.widget).getData());
}
});
ClipboardCopy.addCopyToClipMenu(linkLabel);
// publick key display
byte[] public_key = crypt_man.getECCHandler().peekPublicKey();
Label public_key_label = new Label(crypto_group, SWT.NULL);
Messages.setLanguageText(public_key_label, "ConfigView.section.security.publickey");
final Label public_key_value = new Label(crypto_group, SWT.NULL);
if (public_key == null) {
Messages.setLanguageText(public_key_value, "ConfigView.section.security.publickey.undef");
} else {
public_key_value.setText(Base32.encode(public_key));
}
Messages.setLanguageText(public_key_value, "ConfigView.copy.to.clipboard.tooltip", true);
public_key_value.setCursor(public_key_value.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
public_key_value.setForeground(Colors.blue);
public_key_value.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent arg0) {
copyToClipboard();
}
@Override
public void mouseDown(MouseEvent arg0) {
copyToClipboard();
}
protected void copyToClipboard() {
new Clipboard(parent.getDisplay()).setContents(new Object[] { public_key_value.getText() }, new Transfer[] { TextTransfer.getInstance() });
}
});
final CryptoManagerKeyListener cryptoManagerKeyListener = new CryptoManagerKeyListener() {
@Override
public void keyChanged(final CryptoHandler handler) {
final CryptoManagerKeyListener me = this;
Utils.execSWTThread(new Runnable() {
@Override
public void run() {
if (public_key_value.isDisposed()) {
crypt_man.removeKeyListener(me);
} else {
if (handler.getType() == CryptoManager.HANDLER_ECC) {
byte[] public_key = handler.peekPublicKey();
if (public_key == null) {
Messages.setLanguageText(public_key_value, "ConfigView.section.security.publickey.undef");
} else {
public_key_value.setText(Base32.encode(public_key));
}
crypto_group.layout();
}
}
}
});
}
@Override
public void keyLockStatusChanged(CryptoHandler handler) {
}
};
crypt_man.addKeyListener(cryptoManagerKeyListener);
parent.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (cryptoManagerKeyListener != null) {
CryptoManagerFactory.getSingleton().removeKeyListener(cryptoManagerKeyListener);
}
}
});
new Label(crypto_group, SWT.NULL);
// manage keys
/*
gridData = new GridData();
gridData.horizontalSpan = 3;
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 ParameterChangeAdapter ()
{
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
Label reset_key_label = new Label(crypto_group, SWT.NULL);
Messages.setLanguageText(reset_key_label, "ConfigView.section.security.resetkey");
Button reset_key_button = new Button(crypto_group, SWT.PUSH);
buttons.add(reset_key_button);
Messages.setLanguageText(reset_key_button, "ConfigView.section.security.clearpasswords.button");
reset_key_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_WARNING | SWT.OK | SWT.CANCEL, MessageText.getString("ConfigView.section.security.resetkey.warning.title"), MessageText.getString("ConfigView.section.security.resetkey.warning"));
mb.setDefaultButtonUsingStyle(SWT.CANCEL);
mb.setParent(parent.getShell());
mb.open(new UserPrompterResultListener() {
@Override
public void prompterClosed(int returnVal) {
if (returnVal != SWT.OK) {
return;
}
try {
crypt_man.getECCHandler().resetKeys("Manual key reset");
} catch (Throwable e) {
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_ERROR | SWT.OK, MessageText.getString("ConfigView.section.security.resetkey.error.title"), getError(e));
mb.setParent(parent.getShell());
mb.open(null);
}
}
});
}
});
new Label(crypto_group, SWT.NULL);
// unlock
Label priv_key_label = new Label(crypto_group, SWT.NULL);
Messages.setLanguageText(priv_key_label, "ConfigView.section.security.unlockkey");
Button priv_key_button = new Button(crypto_group, SWT.PUSH);
buttons.add(priv_key_button);
Messages.setLanguageText(priv_key_button, "ConfigView.section.security.unlockkey.button");
priv_key_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
try {
crypt_man.getECCHandler().getEncryptedPrivateKey("Manual unlock");
} catch (Throwable e) {
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_ERROR | SWT.OK, MessageText.getString("ConfigView.section.security.resetkey.error.title"), getError(e));
mb.setParent(parent.getShell());
mb.open(null);
}
}
});
new Label(crypto_group, SWT.NULL);
// backup
Label backup_keys_label = new Label(crypto_group, SWT.NULL);
Messages.setLanguageText(backup_keys_label, "ConfigView.section.security.backupkeys");
final Button backup_keys_button = new Button(crypto_group, SWT.PUSH);
buttons.add(backup_keys_button);
Messages.setLanguageText(backup_keys_button, "ConfigView.section.security.backupkeys.button");
backup_keys_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
FileDialog dialog = new FileDialog(backup_keys_button.getShell(), SWT.APPLICATION_MODAL);
String target = dialog.open();
if (target != null) {
try {
String keys = crypt_man.getECCHandler().exportKeys();
PrintWriter pw = new PrintWriter(new FileWriter(target));
pw.println(keys);
pw.close();
} catch (Throwable e) {
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[] { getError(e) }));
mb.setParent(parent.getShell());
mb.open(null);
}
}
}
});
new Label(crypto_group, SWT.NULL);
// restore
Label restore_keys_label = new Label(crypto_group, SWT.NULL);
Messages.setLanguageText(restore_keys_label, "ConfigView.section.security.restorekeys");
final Button restore_keys_button = new Button(crypto_group, SWT.PUSH);
buttons.add(restore_keys_button);
Messages.setLanguageText(restore_keys_button, "ConfigView.section.security.restorekeys.button");
restore_keys_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
FileDialog dialog = new FileDialog(backup_keys_button.getShell(), SWT.APPLICATION_MODAL);
String target = dialog.open();
if (target != null) {
try {
LineNumberReader reader = new LineNumberReader(new FileReader(target));
String str = "";
try {
while (true) {
String line = reader.readLine();
if (line == null) {
break;
}
str += line + "\r\n";
}
} finally {
reader.close();
}
boolean restart = crypt_man.getECCHandler().importKeys(str);
if (restart) {
MessageBoxShell mb = new MessageBoxShell(SWT.ICON_INFORMATION | SWT.OK, MessageText.getString("ConfigView.section.security.restart.title"), MessageText.getString("ConfigView.section.security.restart.msg"));
mb.setParent(parent.getShell());
mb.open(null);
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null) {
uiFunctions.dispose(true, false);
}
}
} catch (Throwable e) {
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[] { getError(e) }));
mb.setParent(parent.getShell());
mb.open(null);
}
}
}
});
new Label(crypto_group, SWT.NULL);
}
Utils.makeButtonsEqualWidth(buttons);
return gSecurity;
}
use of com.biglybt.ui.swt.auth.CertificateCreatorWindow in project BiglyBT by BiglySoftware.
the class ConfigSectionTrackerServer method configSectionCreate.
@Override
public Composite configSectionCreate(final Composite parent) {
GridData gridData;
GridLayout layout;
Label label;
// main tab set up
Composite gMainTab = new Composite(parent, SWT.NULL);
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
gMainTab.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 4;
gMainTab.setLayout(layout);
int userMode = COConfigurationManager.getIntParameter("User Mode");
if (userMode < REQUIRED_MODE) {
label = new Label(gMainTab, SWT.WRAP);
gridData = new GridData();
label.setLayoutData(gridData);
final String[] modeKeys = { "ConfigView.section.mode.beginner", "ConfigView.section.mode.intermediate", "ConfigView.section.mode.advanced" };
String param1, param2;
if (REQUIRED_MODE < modeKeys.length)
param1 = MessageText.getString(modeKeys[REQUIRED_MODE]);
else
param1 = String.valueOf(REQUIRED_MODE);
if (userMode < modeKeys.length)
param2 = MessageText.getString(modeKeys[userMode]);
else
param2 = String.valueOf(userMode);
label.setText(MessageText.getString("ConfigView.notAvailableForMode", new String[] { param1, param2 }));
return gMainTab;
}
if (userMode > 0) {
// XXX
label = new Label(gMainTab, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.ip");
final StringParameter tracker_ip = new StringParameter(gMainTab, "Tracker IP", "");
gridData = new GridData();
gridData.widthHint = 120;
tracker_ip.setLayoutData(gridData);
Button check_button = new Button(gMainTab, SWT.PUSH);
gridData = new GridData();
gridData.horizontalSpan = 2;
check_button.setLayoutData(gridData);
// $NON-NLS-1$
Messages.setLanguageText(check_button, "ConfigView.section.tracker.checkip");
final Display display = gMainTab.getDisplay();
check_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
IpCheckerWizard wizard = new IpCheckerWizard();
wizard.setIpSetterCallBack(new IpSetterCallBack() {
@Override
public void setIp(final String ip) {
if (display == null || display.isDisposed())
return;
display.asyncExec(new AERunnable() {
@Override
public void runSupport() {
if (tracker_ip != null)
tracker_ip.setValue(ip);
}
});
}
});
// setIPSetterCallback
}
});
// row
final BooleanParameter nonsslEnable = new BooleanParameter(gMainTab, "Tracker Port Enable", "ConfigView.section.tracker.port");
IntParameter tracker_port = new IntParameter(gMainTab, "Tracker Port", 0, 65535);
gridData = new GridData();
tracker_port.setLayoutData(gridData);
final StringParameter tracker_port_backup = new StringParameter(gMainTab, "Tracker Port Backups", "");
gridData = new GridData();
gridData.widthHint = 100;
tracker_port_backup.setLayoutData(gridData);
Label tracker_port_backup_label = new Label(gMainTab, SWT.NULL);
Messages.setLanguageText(tracker_port_backup_label, "ConfigView.section.tracker.portbackup");
// row
final BooleanParameter sslEnable = new BooleanParameter(gMainTab, "Tracker Port SSL Enable", "ConfigView.section.tracker.sslport");
IntParameter tracker_port_ssl = new IntParameter(gMainTab, "Tracker Port SSL", 0, 65535);
gridData = new GridData();
tracker_port_ssl.setLayoutData(gridData);
final StringParameter tracker_port_ssl_backup = new StringParameter(gMainTab, "Tracker Port SSL Backups", "");
gridData = new GridData();
gridData.widthHint = 100;
tracker_port_ssl_backup.setLayoutData(gridData);
Label tracker_port_ssl_backup_label = new Label(gMainTab, SWT.NULL);
Messages.setLanguageText(tracker_port_ssl_backup_label, "ConfigView.section.tracker.portbackup");
// create cert row
Label cert_label = new Label(gMainTab, SWT.NULL);
Messages.setLanguageText(cert_label, "ConfigView.section.tracker.createcert");
Button cert_button = new Button(gMainTab, SWT.PUSH);
Messages.setLanguageText(cert_button, "ConfigView.section.tracker.createbutton");
cert_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
new CertificateCreatorWindow();
}
});
Label ssl_faq_label = new Label(gMainTab, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 2;
ssl_faq_label.setLayoutData(gridData);
Messages.setLanguageText(ssl_faq_label, "ConfigView.section.tracker.sslport.info");
final String linkFAQ = Constants.PLUGINS_WEB_SITE + "faq.php#19";
ssl_faq_label.setCursor(ssl_faq_label.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
ssl_faq_label.setData(linkFAQ);
ssl_faq_label.setForeground(Colors.blue);
ssl_faq_label.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent arg0) {
Utils.launch(linkFAQ);
}
@Override
public void mouseDown(MouseEvent arg0) {
Utils.launch(linkFAQ);
}
});
ClipboardCopy.addCopyToClipMenu(ssl_faq_label);
Control[] ssl_controls = { tracker_port_ssl.getControl(), tracker_port_ssl_backup.getControl(), tracker_port_ssl_backup_label, ssl_faq_label, cert_label, cert_button };
sslEnable.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(ssl_controls));
// enable I2P
gridData = new GridData();
gridData.horizontalSpan = 1;
final BooleanParameter i2p_enable = new BooleanParameter(gMainTab, "Tracker I2P Enable", "label.enable.i2p");
i2p_enable.setLayoutData(gridData);
final Label i2p_dest = label = new Label(gMainTab, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 3;
label.setLayoutData(gridData);
ClipboardCopy.addCopyToClipMenu(i2p_dest);
COConfigurationManager.addAndFireParameterListener("Tracker I2P Host Port", new ParameterListener() {
ParameterListener l = this;
@Override
public void parameterChanged(String parameterName) {
Utils.execSWTThread(new Runnable() {
@Override
public void run() {
if (i2p_dest.isDisposed()) {
COConfigurationManager.removeParameterListener(parameterName, l);
} else {
String val = "http://" + COConfigurationManager.getStringParameter(parameterName) + "/announce";
i2p_dest.setText(val);
i2p_dest.setData(val);
i2p_dest.getParent().layout(true, true);
}
}
});
}
});
// enable Tor
gridData = new GridData();
gridData.horizontalSpan = 1;
final BooleanParameter tor_enable = new BooleanParameter(gMainTab, "Tracker Tor Enable", "label.enable.tor");
i2p_enable.setLayoutData(gridData);
final Label tor_dest = label = new Label(gMainTab, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 3;
label.setLayoutData(gridData);
ClipboardCopy.addCopyToClipMenu(tor_dest);
COConfigurationManager.addAndFireParameterListener("Tracker Tor Host Port", new ParameterListener() {
ParameterListener l = this;
@Override
public void parameterChanged(String parameterName) {
Utils.execSWTThread(new Runnable() {
@Override
public void run() {
if (tor_dest.isDisposed()) {
COConfigurationManager.removeParameterListener(parameterName, l);
} else {
String val = "http://" + COConfigurationManager.getStringParameter(parameterName) + "/announce";
tor_dest.setText(val);
tor_dest.setData(val);
tor_dest.getParent().layout(true, true);
}
}
});
}
});
Control[] non_ssl_controls = new Control[5];
non_ssl_controls[0] = tracker_port.getControl();
non_ssl_controls[1] = tracker_port_backup.getControl();
non_ssl_controls[2] = tracker_port_backup_label;
non_ssl_controls[3] = i2p_enable.getControl();
non_ssl_controls[4] = tor_enable.getControl();
nonsslEnable.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(non_ssl_controls));
// row
gridData = new GridData();
gridData.horizontalSpan = 1;
new BooleanParameter(gMainTab, "Tracker Public Enable", "ConfigView.section.tracker.publicenable").setLayoutData(gridData);
label = new Label(gMainTab, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.publicenable.info");
gridData = new GridData();
gridData.horizontalSpan = 3;
label.setLayoutData(gridData);
// row
BooleanParameter forcePortDetails = new BooleanParameter(gMainTab, "Tracker Port Force External", "ConfigView.section.tracker.forceport");
label = new Label(gMainTab, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 3;
label.setLayoutData(gridData);
Control[] f_controls = new Control[1];
f_controls[0] = forcePortDetails.getControl();
IAdditionalActionPerformer f_enabler = new GenericActionPerformer(f_controls) {
@Override
public void performAction() {
boolean selected = nonsslEnable.isSelected() || sslEnable.isSelected();
controls[0].setEnabled(selected);
}
};
nonsslEnable.setAdditionalActionPerformer(f_enabler);
sslEnable.setAdditionalActionPerformer(f_enabler);
// row
// add announce urls to hosted torrents
BooleanParameter hostAddURLs = new BooleanParameter(gMainTab, "Tracker Host Add Our Announce URLs", "ConfigView.section.tracker.host.addurls");
gridData = new GridData();
gridData.horizontalSpan = 2;
hostAddURLs.setLayoutData(gridData);
label = new Label(gMainTab, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 2;
label.setLayoutData(gridData);
// row
gridData = new GridData();
gridData.horizontalSpan = 1;
final BooleanParameter passwordEnableWeb = new BooleanParameter(gMainTab, "Tracker Password Enable Web", "ConfigView.section.tracker.passwordenableweb");
passwordEnableWeb.setLayoutData(gridData);
gridData = new GridData();
gridData.horizontalSpan = 3;
final BooleanParameter passwordWebHTTPSOnly = new BooleanParameter(gMainTab, "Tracker Password Web HTTPS Only", "ConfigView.section.tracker.passwordwebhttpsonly");
passwordWebHTTPSOnly.setLayoutData(gridData);
IAdditionalActionPerformer web_https_enabler = new GenericActionPerformer(passwordWebHTTPSOnly.getControls()) {
@Override
public void performAction() {
boolean selected = passwordEnableWeb.isSelected() && sslEnable.isSelected();
for (int i = 0; i < controls.length; i++) {
controls[i].setEnabled(selected);
}
}
};
passwordEnableWeb.setAdditionalActionPerformer(web_https_enabler);
sslEnable.setAdditionalActionPerformer(web_https_enabler);
// row
final BooleanParameter passwordEnableTorrent = new BooleanParameter(gMainTab, "Tracker Password Enable Torrent", "ConfigView.section.tracker.passwordenabletorrent");
label = new Label(gMainTab, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.passwordenabletorrent.info");
gridData = new GridData();
gridData.horizontalSpan = 3;
label.setLayoutData(gridData);
// row
label = new Label(gMainTab, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.username");
final StringParameter tracker_username = new StringParameter(gMainTab, "Tracker Username", "");
gridData = new GridData();
gridData.widthHint = 100;
tracker_username.setLayoutData(gridData);
label = new Label(gMainTab, SWT.NULL);
label = new Label(gMainTab, SWT.NULL);
// row
label = new Label(gMainTab, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.password");
final PasswordParameter tracker_password = new PasswordParameter(gMainTab, "Tracker Password");
gridData = new GridData();
gridData.widthHint = 100;
tracker_password.setLayoutData(gridData);
label = new Label(gMainTab, SWT.NULL);
label = new Label(gMainTab, SWT.NULL);
Control[] x_controls = new Control[2];
x_controls[0] = tracker_username.getControl();
x_controls[1] = tracker_password.getControl();
IAdditionalActionPerformer enabler = new GenericActionPerformer(x_controls) {
@Override
public void performAction() {
boolean selected = passwordEnableWeb.isSelected() || passwordEnableTorrent.isSelected();
for (int i = 0; i < controls.length; i++) {
controls[i].setEnabled(selected);
}
}
};
passwordEnableWeb.setAdditionalActionPerformer(enabler);
passwordEnableTorrent.setAdditionalActionPerformer(enabler);
// Poll Group //
Group gPollStuff = new Group(gMainTab, SWT.NULL);
Messages.setLanguageText(gPollStuff, "ConfigView.section.tracker.pollinterval");
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
gridData.horizontalSpan = 4;
gPollStuff.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 4;
gPollStuff.setLayout(layout);
label = new Label(gPollStuff, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.pollintervalmin");
gridData = new GridData();
label.setLayoutData(gridData);
IntParameter pollIntervalMin = new IntParameter(gPollStuff, "Tracker Poll Interval Min");
gridData = new GridData();
pollIntervalMin.setLayoutData(gridData);
label = new Label(gPollStuff, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.pollintervalmax");
gridData = new GridData();
label.setLayoutData(gridData);
IntParameter pollIntervalMax = new IntParameter(gPollStuff, "Tracker Poll Interval Max");
gridData = new GridData();
pollIntervalMax.setLayoutData(gridData);
// row
label = new Label(gPollStuff, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.pollintervalincby");
gridData = new GridData();
label.setLayoutData(gridData);
IntParameter pollIntervalIncBy = new IntParameter(gPollStuff, "Tracker Poll Inc By");
gridData = new GridData();
pollIntervalIncBy.setLayoutData(gridData);
label = new Label(gPollStuff, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.pollintervalincper");
gridData = new GridData();
label.setLayoutData(gridData);
IntParameter pollIntervalIncPer = new IntParameter(gPollStuff, "Tracker Poll Inc Per");
gridData = new GridData();
pollIntervalIncPer.setLayoutData(gridData);
// scrape + cache group
Group gScrapeCache = new Group(gMainTab, SWT.NULL);
Messages.setLanguageText(gScrapeCache, "ConfigView.section.tracker.scrapeandcache");
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
gridData.horizontalSpan = 4;
gScrapeCache.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 4;
gScrapeCache.setLayout(layout);
// row
label = new Label(gScrapeCache, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.announcescrapepercentage");
IntParameter scrapeannouncepercentage = new IntParameter(gScrapeCache, "Tracker Scrape Retry Percentage");
gridData = new GridData();
scrapeannouncepercentage.setLayoutData(gridData);
label = new Label(gScrapeCache, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.scrapecacheperiod");
gridData = new GridData();
label.setLayoutData(gridData);
IntParameter scrapeCachePeriod = new IntParameter(gScrapeCache, "Tracker Scrape Cache");
gridData = new GridData();
scrapeCachePeriod.setLayoutData(gridData);
// row
label = new Label(gScrapeCache, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.announcecacheminpeers");
IntParameter announceCacheMinPeers = new IntParameter(gScrapeCache, "Tracker Announce Cache Min Peers");
gridData = new GridData();
announceCacheMinPeers.setLayoutData(gridData);
label = new Label(gScrapeCache, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.announcecacheperiod");
gridData = new GridData();
label.setLayoutData(gridData);
IntParameter announceCachePeriod = new IntParameter(gScrapeCache, "Tracker Announce Cache");
gridData = new GridData();
announceCachePeriod.setLayoutData(gridData);
// main tab again
// row
label = new Label(gMainTab, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.maxpeersreturned");
gridData = new GridData();
label.setLayoutData(gridData);
IntParameter maxPeersReturned = new IntParameter(gMainTab, "Tracker Max Peers Returned");
gridData = new GridData();
maxPeersReturned.setLayoutData(gridData);
label = new Label(gMainTab, SWT.NULL);
label = new Label(gMainTab, SWT.NULL);
// seed retention limit
label = new Label(gMainTab, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.seedretention");
gridData = new GridData();
label.setLayoutData(gridData);
IntParameter seedRetentionLimit = new IntParameter(gMainTab, "Tracker Max Seeds Retained");
gridData = new GridData();
seedRetentionLimit.setLayoutData(gridData);
label = new Label(gMainTab, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.seedretention.info");
gridData = new GridData();
gridData.horizontalSpan = 2;
label.setLayoutData(gridData);
// row
gridData = new GridData();
gridData.horizontalSpan = 2;
new BooleanParameter(gMainTab, "Tracker NAT Check Enable", "ConfigView.section.tracker.natcheckenable").setLayoutData(gridData);
Composite gNATDetails = new Composite(gMainTab, SWT.NULL);
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
gridData.horizontalSpan = 2;
gNATDetails.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
gNATDetails.setLayout(layout);
// row
label = new Label(gNATDetails, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.natchecktimeout");
gridData = new GridData();
label.setLayoutData(gridData);
IntParameter NATTimeout = new IntParameter(gNATDetails, "Tracker NAT Check Timeout");
gridData = new GridData();
NATTimeout.setLayoutData(gridData);
// row
gridData = new GridData();
gridData.horizontalSpan = 4;
new BooleanParameter(gMainTab, "Tracker Send Peer IDs", "ConfigView.section.tracker.sendpeerids").setLayoutData(gridData);
// row
gridData = new GridData();
gridData.horizontalSpan = 4;
BooleanParameter enable_udp = new BooleanParameter(gMainTab, "Tracker Port UDP Enable", "ConfigView.section.tracker.enableudp");
enable_udp.setLayoutData(gridData);
// row
Label udp_version_label = new Label(gMainTab, SWT.NULL);
Messages.setLanguageText(udp_version_label, "ConfigView.section.tracker.udpversion");
gridData = new GridData();
IntParameter udp_version = new IntParameter(gMainTab, "Tracker Port UDP Version");
udp_version.setLayoutData(gridData);
label = new Label(gMainTab, SWT.NULL);
label = new Label(gMainTab, SWT.NULL);
enable_udp.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(new Control[] { udp_version_label, udp_version.getControl() }));
// row
gridData = new GridData();
gridData.horizontalSpan = 4;
new BooleanParameter(gMainTab, "Tracker Compact Enable", "ConfigView.section.tracker.enablecompact").setLayoutData(gridData);
// row
gridData = new GridData();
gridData.horizontalSpan = 4;
BooleanParameter log_enable = new BooleanParameter(gMainTab, "Tracker Log Enable", "ConfigView.section.tracker.logenable");
log_enable.setLayoutData(gridData);
if (userMode > 1) {
// XXX
// row
gridData = new GridData();
gridData.horizontalSpan = 4;
new BooleanParameter(gMainTab, "Tracker Key Enable Server", "ConfigView.section.tracker.enablekey").setLayoutData(gridData);
// banned peers
Label banned_peers_label = new Label(gMainTab, SWT.NULL);
Messages.setLanguageText(banned_peers_label, "ConfigView.section.tracker.banned.clients");
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 3;
new StringParameter(gMainTab, "Tracker Banned Clients", "").setLayoutData(gridData);
// Networks Group //
Group networks_group = new Group(gMainTab, SWT.NULL);
Messages.setLanguageText(networks_group, "ConfigView.section.tracker.server.group.networks");
GridData networks_layout = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
networks_layout.horizontalSpan = 4;
networks_group.setLayoutData(networks_layout);
layout = new GridLayout();
layout.numColumns = 2;
networks_group.setLayout(layout);
label = new Label(networks_group, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.server.group.networks.info");
GridData grid_data = new GridData();
grid_data.horizontalSpan = 2;
label.setLayoutData(grid_data);
for (int i = 0; i < AENetworkClassifier.AT_NETWORKS.length; i++) {
String nn = AENetworkClassifier.AT_NETWORKS[i];
String config_name = "Tracker Network Selection Default." + nn;
String msg_text = "ConfigView.section.connection.networks." + nn;
BooleanParameter network = new BooleanParameter(networks_group, config_name, msg_text);
grid_data = new GridData();
grid_data.horizontalSpan = 2;
network.setLayoutData(grid_data);
}
// processing limits group //
Group gProcessing = new Group(gMainTab, SWT.NULL);
Messages.setLanguageText(gProcessing, "ConfigView.section.tracker.processinglimits");
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
gridData.horizontalSpan = 4;
gProcessing.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 3;
gProcessing.setLayout(layout);
// row annouce/scrape max process time
label = new Label(gProcessing, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.maxgettime");
gridData = new GridData();
label.setLayoutData(gridData);
IntParameter maxGetTime = new IntParameter(gProcessing, "Tracker Max GET Time");
gridData = new GridData();
maxGetTime.setLayoutData(gridData);
label = new Label(gProcessing, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.maxgettime.info");
// row post multiplier
label = new Label(gProcessing, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.maxposttimemultiplier");
gridData = new GridData();
label.setLayoutData(gridData);
IntParameter maxPostTimeMultiplier = new IntParameter(gProcessing, "Tracker Max POST Time Multiplier");
gridData = new GridData();
maxPostTimeMultiplier.setLayoutData(gridData);
label = new Label(gProcessing, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.maxposttimemultiplier.info");
// row max threads
label = new Label(gProcessing, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.maxthreads");
gridData = new GridData();
label.setLayoutData(gridData);
IntParameter maxThreadsTime = new IntParameter(gProcessing, "Tracker Max Threads");
maxThreadsTime.setMinimumValue(1);
maxThreadsTime.setMaximumValue(4096);
gridData = new GridData();
maxThreadsTime.setLayoutData(gridData);
label = new Label(gProcessing, SWT.NULL);
// non-blocking tracker group //
Group gNBTracker = new Group(gMainTab, SWT.NULL);
Messages.setLanguageText(gNBTracker, "ConfigView.section.tracker.nonblocking");
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
gridData.horizontalSpan = 4;
gNBTracker.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 3;
gNBTracker.setLayout(layout);
// row
gridData = new GridData();
gridData.horizontalSpan = 3;
BooleanParameter nb_enable = new BooleanParameter(gNBTracker, "Tracker TCP NonBlocking", "ConfigView.section.tracker.tcpnonblocking");
nb_enable.setLayoutData(gridData);
// row max conc connections
label = new Label(gNBTracker, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.section.tracker.nonblockingconcmax");
gridData = new GridData();
label.setLayoutData(gridData);
IntParameter maxConcConn = new IntParameter(gNBTracker, "Tracker TCP NonBlocking Conc Max");
gridData = new GridData();
maxConcConn.setLayoutData(gridData);
label = new Label(gNBTracker, SWT.NULL);
nb_enable.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(maxConcConn.getControls()));
}
}
return gMainTab;
}
Aggregations