Search in sources :

Example 1 with StringParameterImpl

use of com.biglybt.pifimpl.local.ui.config.StringParameterImpl in project BiglyBT by BiglySoftware.

the class ConfigSectionConnectionDNS method build.

@Override
public void build() {
    add(new LabelParameterImpl("ConfigView.section.dns.info"));
    add(new HyperlinkParameterImpl("ConfigView.label.please.visit.here", Wiki.DNS));
    add(new StringParameterImpl(Connection.SCFG_DNS_ALT_SERVERS, "ConfigView.section.dns.alts"));
    add(new BooleanParameterImpl(Connection.BCFG_DNS_ALT_SERVERS_SOCKS_ENABLE, "ConfigView.section.dns.allow_socks"));
}
Also used : LabelParameterImpl(com.biglybt.pifimpl.local.ui.config.LabelParameterImpl) HyperlinkParameterImpl(com.biglybt.pifimpl.local.ui.config.HyperlinkParameterImpl) StringParameterImpl(com.biglybt.pifimpl.local.ui.config.StringParameterImpl) BooleanParameterImpl(com.biglybt.pifimpl.local.ui.config.BooleanParameterImpl)

Example 2 with StringParameterImpl

use of com.biglybt.pifimpl.local.ui.config.StringParameterImpl in project BiglyBT by BiglySoftware.

the class ConfigSectionConnectionProxySWT method configSectionCreate.

@Override
public void configSectionCreate(Composite parent, Map<ParameterImpl, BaseSwtParameter> mapParamToSwtParam) {
    BooleanParameterImpl enableProxy = (BooleanParameterImpl) getPluginParam(BCFG_ENABLE_PROXY);
    BooleanParameterImpl enableSocks = (BooleanParameterImpl) getPluginParam(BCFG_ENABLE_SOCKS);
    StringParameterImpl pHost = (StringParameterImpl) getPluginParam(SCFG_PROXY_HOST);
    IntParameterImpl pPort = (IntParameterImpl) getPluginParam(SCFG_PROXY_PORT);
    StringParameterImpl pUser = (StringParameterImpl) getPluginParam(SCFG_PROXY_USERNAME);
    StringParameterImpl pPass = (StringParameterImpl) getPluginParam(SCFG_PROXY_PASSWORD);
    BooleanParameterImpl trackerDNSKill = (BooleanParameterImpl) getPluginParam(BCFG_PROXY_SOCKS_TRACKER_DNS_DISABLE);
    ParameterImpl paramButtonTest = getPluginParam(ConfigSectionConnectionProxy.ID_BTN_TEST);
    ParameterImpl[] socks_params = { enableProxy, enableSocks, pHost, pPort, pUser, pPass, trackerDNSKill };
    ParameterListener socks_adapter = param -> {
        boolean enabled = enableProxy.getValue() && enableSocks.getValue() && pHost.getValue().trim().length() > 0 && pPort.getValue() > 0;
        boolean socks_enabled = enableProxy.getValue() && enableSocks.getValue();
        trackerDNSKill.setEnabled(socks_enabled);
        if (enabled) {
            try {
                NetworkAdminSocksProxy nasp = NetworkAdmin.getSingleton().createSocksProxy(pHost.getValue(), pPort.getValue(), pUser.getValue(), pPass.getValue());
                synchronized (test_proxy) {
                    test_proxy[0] = nasp;
                }
            } catch (Throwable e) {
                enabled = false;
            }
        }
        if (!enabled) {
            synchronized (test_proxy) {
                test_proxy[0] = null;
            }
        }
        final boolean f_enabled = enabled;
        Utils.execSWTThread(() -> paramButtonTest.setEnabled(f_enabled));
    };
    for (ParameterImpl socks_param : socks_params) {
        socks_param.addListener(socks_adapter);
    }
    // init settings
    socks_adapter.parameterChanged(null);
}
Also used : IntParameterImpl(com.biglybt.pifimpl.local.ui.config.IntParameterImpl) ParameterImpl(com.biglybt.pifimpl.local.ui.config.ParameterImpl) TextViewerWindow(com.biglybt.ui.swt.TextViewerWindow) BooleanParameterImpl(com.biglybt.pifimpl.local.ui.config.BooleanParameterImpl) MessageText(com.biglybt.core.internat.MessageText) ConfigSectionConnectionProxy(com.biglybt.ui.config.ConfigSectionConnectionProxy) Connection(com.biglybt.core.config.ConfigKeys.Connection) StringParameterImpl(com.biglybt.pifimpl.local.ui.config.StringParameterImpl) Debug(com.biglybt.core.util.Debug) Utils(com.biglybt.ui.swt.Utils) Composite(org.eclipse.swt.widgets.Composite) Map(java.util.Map) ParameterListener(com.biglybt.pif.ui.config.ParameterListener) NetworkAdmin(com.biglybt.core.networkmanager.admin.NetworkAdmin) AESemaphore(com.biglybt.core.util.AESemaphore) NetworkAdminSocksProxy(com.biglybt.core.networkmanager.admin.NetworkAdminSocksProxy) BaseSwtParameter(com.biglybt.ui.swt.config.BaseSwtParameter) AEThread2(com.biglybt.core.util.AEThread2) IntParameterImpl(com.biglybt.pifimpl.local.ui.config.IntParameterImpl) ParameterImpl(com.biglybt.pifimpl.local.ui.config.ParameterImpl) BooleanParameterImpl(com.biglybt.pifimpl.local.ui.config.BooleanParameterImpl) StringParameterImpl(com.biglybt.pifimpl.local.ui.config.StringParameterImpl) IntParameterImpl(com.biglybt.pifimpl.local.ui.config.IntParameterImpl) NetworkAdminSocksProxy(com.biglybt.core.networkmanager.admin.NetworkAdminSocksProxy) StringParameterImpl(com.biglybt.pifimpl.local.ui.config.StringParameterImpl) ParameterListener(com.biglybt.pif.ui.config.ParameterListener) BooleanParameterImpl(com.biglybt.pifimpl.local.ui.config.BooleanParameterImpl)

Aggregations

BooleanParameterImpl (com.biglybt.pifimpl.local.ui.config.BooleanParameterImpl)2 StringParameterImpl (com.biglybt.pifimpl.local.ui.config.StringParameterImpl)2 Connection (com.biglybt.core.config.ConfigKeys.Connection)1 MessageText (com.biglybt.core.internat.MessageText)1 NetworkAdmin (com.biglybt.core.networkmanager.admin.NetworkAdmin)1 NetworkAdminSocksProxy (com.biglybt.core.networkmanager.admin.NetworkAdminSocksProxy)1 AESemaphore (com.biglybt.core.util.AESemaphore)1 AEThread2 (com.biglybt.core.util.AEThread2)1 Debug (com.biglybt.core.util.Debug)1 ParameterListener (com.biglybt.pif.ui.config.ParameterListener)1 HyperlinkParameterImpl (com.biglybt.pifimpl.local.ui.config.HyperlinkParameterImpl)1 IntParameterImpl (com.biglybt.pifimpl.local.ui.config.IntParameterImpl)1 LabelParameterImpl (com.biglybt.pifimpl.local.ui.config.LabelParameterImpl)1 ParameterImpl (com.biglybt.pifimpl.local.ui.config.ParameterImpl)1 ConfigSectionConnectionProxy (com.biglybt.ui.config.ConfigSectionConnectionProxy)1 TextViewerWindow (com.biglybt.ui.swt.TextViewerWindow)1 Utils (com.biglybt.ui.swt.Utils)1 BaseSwtParameter (com.biglybt.ui.swt.config.BaseSwtParameter)1 Map (java.util.Map)1 Composite (org.eclipse.swt.widgets.Composite)1