Search in sources :

Example 11 with IPCInterface

use of com.biglybt.pif.ipc.IPCInterface in project BiglyBT by BiglySoftware.

the class AEPluginProxyHandler method getPluginDHTProxy.

public static DHTPluginInterface getPluginDHTProxy(String reason, String network, Map<String, Object> options) {
    waitForPlugins(plugin_init_max_wait);
    checkPluginInstallation(network, reason);
    PluginInterface pi = getPluginProxyForNetwork(network, false);
    if (pi == null) {
        return (null);
    }
    try {
        IPCInterface ipc = pi.getIPC();
        DHTPluginInterface reply = (DHTPluginInterface) ipc.invoke("getProxyDHT", new Object[] { reason, options });
        return (reply);
    } catch (Throwable e) {
    }
    return (null);
}
Also used : DHTPluginInterface(com.biglybt.plugin.dht.DHTPluginInterface) PluginInterface(com.biglybt.pif.PluginInterface) DHTPluginInterface(com.biglybt.plugin.dht.DHTPluginInterface) IPCInterface(com.biglybt.pif.ipc.IPCInterface)

Example 12 with IPCInterface

use of com.biglybt.pif.ipc.IPCInterface in project BiglyBT by BiglySoftware.

the class AZPluginConnection method connect.

@Override
public void connect() throws IOException {
    String url = getURL().toString();
    int pos = url.indexOf("?");
    if (pos == -1) {
        throw (new IOException("Malformed URL - ? missing"));
    }
    url = url.substring(pos + 1);
    String[] bits = url.split("&");
    Map args = new HashMap();
    for (int i = 0; i < bits.length; i++) {
        String bit = bits[i];
        String[] x = bit.split("=");
        if (x.length == 2) {
            String lhs = x[0];
            String rhs = UrlUtils.decode(x[1]);
            args.put(lhs.toLowerCase(), rhs);
        }
    }
    String plugin_id = (String) args.get("id");
    if (plugin_id == null) {
        throw (new IOException("Plugin id missing"));
    }
    String plugin_name = (String) args.get("name");
    String arg = (String) args.get("arg");
    if (arg == null) {
        arg = "";
    }
    String plugin_str;
    if (plugin_name == null) {
        plugin_str = "with id '" + plugin_id + "'";
    } else {
        plugin_str = "'" + plugin_name + "' (id " + plugin_id + ")";
    }
    if (plugin_id.equals("subscription")) {
        SubscriptionManager manager = SubscriptionManagerFactory.getSingleton();
        if (manager == null) {
            throw (new IOException("Subscriptions are not available"));
        }
        try {
            manager.subscribeToSubscription(arg);
            input_stream = new ByteArrayInputStream(VuzeFileHandler.getSingleton().create().exportToBytes());
        } catch (Throwable e) {
            throw (new IOException("Subscription addition failed: " + Debug.getNestedExceptionMessage(e)));
        }
    } else {
        // AZPluginConnection is called via reflection
        // Let's just assume that the Core is avail..
        PluginInterface pi = CoreFactory.getSingleton().getPluginManager().getPluginInterfaceByID(plugin_id);
        if (pi == null) {
            throw (new IOException("Plugin " + plugin_str + " is required - go to 'Tools->Plugins->Installation Wizard' to install."));
        }
        IPCInterface ipc = pi.getIPC();
        try {
            if (ipc.canInvoke("handleURLProtocol", new Object[] { this, arg })) {
                input_stream = (InputStream) ipc.invoke("handleURLProtocol", new Object[] { this, arg });
            } else {
                input_stream = (InputStream) ipc.invoke("handleURLProtocol", new Object[] { arg });
            }
        } catch (IPCException ipce) {
            Throwable e = ipce;
            if (e.getCause() != null) {
                e = e.getCause();
            }
            throw (new IOException("Communication error with plugin '" + plugin_str + "': " + Debug.getNestedExceptionMessage(e)));
        }
    }
}
Also used : HashMap(java.util.HashMap) ByteArrayInputStream(java.io.ByteArrayInputStream) PluginInterface(com.biglybt.pif.PluginInterface) IPCException(com.biglybt.pif.ipc.IPCException) IOException(java.io.IOException) SubscriptionManager(com.biglybt.core.subs.SubscriptionManager) HashMap(java.util.HashMap) Map(java.util.Map) IPCInterface(com.biglybt.pif.ipc.IPCInterface)

Example 13 with IPCInterface

use of com.biglybt.pif.ipc.IPCInterface in project BiglyBT by BiglySoftware.

the class PrivacyView method initialize.

private void initialize() {
    if (cMainComposite == null || cMainComposite.isDisposed()) {
        if (parent == null || parent.isDisposed()) {
            return;
        }
        sc = new ScrolledComposite(parent, SWT.V_SCROLL);
        sc.setExpandHorizontal(true);
        sc.setExpandVertical(true);
        sc.getVerticalBar().setIncrement(16);
        Layout parentLayout = parent.getLayout();
        if (parentLayout instanceof GridLayout) {
            GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
            Utils.setLayoutData(sc, gd);
        } else if (parentLayout instanceof FormLayout) {
            Utils.setLayoutData(sc, Utils.getFilledFormData());
        }
        cMainComposite = new Composite(sc, SWT.NONE);
        sc.setContent(cMainComposite);
    } else {
        Utils.disposeComposite(cMainComposite, false);
    }
    GridLayout layout = new GridLayout(1, false);
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    cMainComposite.setLayout(layout);
    GridData gd;
    // overview
    Composite overview_comp = new Composite(cMainComposite, SWT.NULL);
    overview_comp.setLayout(new GridLayout(3, false));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(overview_comp, gd);
    Label label = new Label(overview_comp, SWT.NULL);
    label.setText(MessageText.getString("privacy.view.intro"));
    LinkLabel link = new LinkLabel(overview_comp, "label.read.more", MessageText.getString("privacy.view.wiki.url"));
    // slider component
    Composite slider_comp = new Composite(cMainComposite, SWT.NULL);
    layout = new GridLayout(3, false);
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    // layout.marginWidth = 0;
    slider_comp.setLayout(layout);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(slider_comp, gd);
    label = new Label(slider_comp, SWT.NULL);
    label.setText(MessageText.getString("privacy.view.level") + ":");
    Composite slider2_comp = new Composite(slider_comp, SWT.NULL);
    slider2_comp.setLayout(new GridLayout(6, true));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(slider2_comp, gd);
    label = new Label(slider2_comp, SWT.NULL);
    label.setText(MessageText.getString("privacy.view.public.only"));
    label = new Label(slider2_comp, SWT.NULL);
    label.setText(MessageText.getString("privacy.view.public.anon"));
    label.setAlignment(SWT.CENTER);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    Utils.setLayoutData(label, gd);
    label = new Label(slider2_comp, SWT.NULL);
    label.setText(MessageText.getString("privacy.view.anon.only"));
    label.setAlignment(SWT.CENTER);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    Utils.setLayoutData(label, gd);
    label = new Label(slider2_comp, SWT.NULL);
    label.setText(MessageText.getString("label.invalid"));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = SWT.END;
    Utils.setLayoutData(label, gd);
    privacy_scale = new Scale(slider2_comp, SWT.HORIZONTAL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 6;
    Utils.setLayoutData(privacy_scale, gd);
    privacy_scale.setMinimum(0);
    privacy_scale.setMaximum(30);
    final boolean[] slider_mouse_down = { false };
    privacy_scale.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent e) {
            int pos = privacy_scale.getSelection();
            int level = ((pos + 5) / 10);
            if (level * 10 != pos) {
                privacy_scale.setSelection(level * 10);
            }
            setPrivacyLevel(level);
            slider_mouse_down[0] = false;
        }

        @Override
        public void mouseDown(MouseEvent e) {
            slider_mouse_down[0] = true;
        }
    });
    privacy_scale.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            if (!slider_mouse_down[0]) {
                int pos = privacy_scale.getSelection();
                int level = ((pos + 5) / 10);
                setPrivacyLevel(level);
            }
        }
    });
    // network selection
    Composite network_comp = new Composite(slider_comp, SWT.NULL);
    gd = new GridData();
    Utils.setLayoutData(network_comp, gd);
    network_buttons = new Button[AENetworkClassifier.AT_NETWORKS.length];
    network_comp.setLayout(new GridLayout(1, false));
    label = new Label(network_comp, SWT.NULL);
    label.setText(MessageText.getString("ConfigView.section.connection.group.networks") + ":");
    for (int i = 0; i < network_buttons.length; i++) {
        final String nn = AENetworkClassifier.AT_NETWORKS[i];
        String msg_text = "ConfigView.section.connection.networks." + nn;
        Button button = new Button(network_comp, SWT.CHECK);
        Messages.setLanguageText(button, msg_text);
        network_buttons[i] = button;
        button.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean selected = ((Button) e.widget).getSelection();
                if (current_dm != null) {
                    current_dm.getDownloadState().setNetworkEnabled(nn, selected);
                }
            }
        });
        GridData gridData = new GridData();
        Utils.setLayoutData(button, gridData);
    }
    label = new Label(slider_comp, SWT.NULL);
    final Composite tracker_webseed_comp = new Composite(slider_comp, SWT.NULL);
    layout = new GridLayout(2, true);
    layout.marginTop = layout.marginBottom = layout.marginLeft = layout.marginRight = 1;
    tracker_webseed_comp.setLayout(layout);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    Utils.setLayoutData(tracker_webseed_comp, gd);
    tracker_webseed_comp.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            Rectangle client_area = tracker_webseed_comp.getClientArea();
            Rectangle rect = new Rectangle(0, 0, client_area.width - 1, client_area.height - 1);
            e.gc.setAlpha(50);
            e.gc.drawRectangle(rect);
        }
    });
    // Tracker Info
    Composite tracker_comp = new Composite(tracker_webseed_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(tracker_comp, gd);
    tracker_comp.setLayout(new GridLayout(2, false));
    label = new Label(tracker_comp, SWT.NULL);
    label.setText(MessageText.getString("label.trackers") + ":");
    tracker_info = new BufferedLabel(tracker_comp, SWT.DOUBLE_BUFFERED);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(tracker_info, gd);
    // Webseed Info
    Composite webseed_comp = new Composite(tracker_webseed_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(webseed_comp, gd);
    webseed_comp.setLayout(new GridLayout(2, false));
    label = new Label(webseed_comp, SWT.NULL);
    label.setText(MessageText.getString("label.webseeds") + ":");
    webseed_info = new BufferedLabel(webseed_comp, SWT.DOUBLE_BUFFERED);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(webseed_info, gd);
    // Peer Info
    // label = new Label( slider_comp, SWT.NULL );
    Composite peer_comp = new Composite(tracker_webseed_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(peer_comp, gd);
    peer_comp.setLayout(new GridLayout(2, false));
    label = new Label(peer_comp, SWT.NULL);
    label.setText(MessageText.getString("TableColumn.header.peers") + ":");
    peer_info = new BufferedLabel(peer_comp, SWT.DOUBLE_BUFFERED);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(peer_info, gd);
    // I2P install state
    Group i2p_group = new Group(cMainComposite, SWT.NULL);
    i2p_group.setText("I2P");
    // Composite i2p_group = new Composite( cMainComposite, SWT.NULL );
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(i2p_group, gd);
    i2p_group.setLayout(new GridLayout(4, false));
    label = new Label(i2p_group, SWT.NULL);
    label.setText(MessageText.getString("privacy.view.lookup.info"));
    gd = new GridData();
    gd.horizontalSpan = 2;
    Utils.setLayoutData(label, gd);
    label = new Label(i2p_group, SWT.NULL);
    label.setText(MessageText.getString("label.lookup.status") + ":");
    i2p_result_summary = new BufferedLabel(i2p_group, SWT.DOUBLE_BUFFERED);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    // gd.horizontalIndent = 4;
    Utils.setLayoutData(i2p_result_summary, gd);
    Composite i2p_button_comp = new Composite(i2p_group, SWT.NULL);
    i2p_button_comp.setLayout(new GridLayout(2, false));
    gd = new GridData(GridData.FILL_VERTICAL);
    Utils.setLayoutData(i2p_button_comp, gd);
    label = new Label(i2p_button_comp, SWT.NULL);
    label.setText(MessageText.getString("GeneralView.section.availability"));
    i2p_install_button = new Button(i2p_button_comp, SWT.PUSH);
    i2p_install_button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            final boolean[] result = { false };
            I2PHelpers.installI2PHelper(null, result, new Runnable() {

                @Override
                public void run() {
                    Utils.execSWTThread(new Runnable() {

                        @Override
                        public void run() {
                            updateI2PState();
                        }
                    });
                }
            });
        }
    });
    // I2P peer lookup
    i2p_lookup_comp = new Composite(i2p_group, SWT.BORDER);
    gd = new GridData();
    gd.widthHint = 300;
    gd.heightHint = 150;
    Utils.setLayoutData(i2p_lookup_comp, gd);
    i2p_lookup_comp.setBackground(Colors.white);
    // i2p results
    i2p_result_list = new Text(i2p_group, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP | SWT.NO_FOCUS);
    gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    Utils.setLayoutData(i2p_result_list, gd);
    i2p_result_list.setEditable(false);
    // i2p lookup button
    label = new Label(i2p_button_comp, SWT.NULL);
    label.setText(MessageText.getString("button.lookup.peers"));
    i2p_lookup_button = new Button(i2p_button_comp, SWT.PUSH);
    i2p_lookup_button.setText(MessageText.getString("button.search.dht"));
    i2p_lookup_button.addSelectionListener(new SelectionAdapter() {

        private int search_count;

        @Override
        public void widgetSelected(SelectionEvent event) {
            Utils.disposeComposite(i2p_lookup_comp, false);
            i2p_result_summary.setText("");
            i2p_result_list.setText("");
            PluginInterface i2p_pi = CoreFactory.getSingleton().getPluginManager().getPluginInterfaceByID("azneti2phelper", true);
            if (i2p_pi != null) {
                IPCInterface ipc = i2p_pi.getIPC();
                Map<String, Object> options = new HashMap<>();
                options.put("server_id", "Scraper");
                options.put("server_id_transient", true);
                options.put("ui_composite", i2p_lookup_comp);
                final byte[] hash = (byte[]) i2p_lookup_button.getData("hash");
                search_count++;
                final int search_id = search_count;
                IPCInterface callback = new IPCInterface() {

                    @Override
                    public Object invoke(String methodName, final Object[] params) throws IPCException {
                        if (search_id != search_count) {
                            return (null);
                        }
                        if (methodName.equals("statusUpdate")) {
                            final int status = (Integer) params[0];
                            if (status != TrackerPeerSource.ST_INITIALISING && status != TrackerPeerSource.ST_UPDATING) {
                                Utils.execSWTThread(new Runnable() {

                                    @Override
                                    public void run() {
                                        if (i2p_lookup_button.isDisposed() || hash != i2p_lookup_button.getData("hash")) {
                                            return;
                                        }
                                        i2p_lookup_button.setEnabled(true);
                                        if (i2p_result_list.getText().length() == 0 && status != TrackerPeerSource.ST_UNAVAILABLE) {
                                            i2p_result_summary.setText(MessageText.getString("label.no.peers.found"));
                                        }
                                    }
                                });
                            }
                            if (params.length == 4) {
                                Utils.execSWTThread(new Runnable() {

                                    @Override
                                    public void run() {
                                        if (i2p_result_summary.isDisposed() || hash != i2p_lookup_button.getData("hash")) {
                                            return;
                                        }
                                        int seeds = (Integer) params[1];
                                        int leechers = (Integer) params[2];
                                        int peers = (Integer) params[3];
                                        i2p_result_summary.setText(MessageText.getString("privacy.view.lookup.msg", new String[] { String.valueOf(seeds), String.valueOf(leechers), String.valueOf(peers) }));
                                    }
                                });
                            }
                        } else if (methodName.equals("msgUpdate")) {
                            Utils.execSWTThread(new Runnable() {

                                @Override
                                public void run() {
                                    if (i2p_result_summary.isDisposed() || hash != i2p_lookup_button.getData("hash")) {
                                        return;
                                    }
                                    String msg = (String) params[0];
                                    i2p_result_summary.setText(msg);
                                }
                            });
                        } else if (methodName.equals("peerFound")) {
                            Utils.execSWTThread(new Runnable() {

                                @Override
                                public void run() {
                                    if (i2p_result_list.isDisposed() || hash != i2p_lookup_button.getData("hash")) {
                                        return;
                                    }
                                    String host = (String) params[0];
                                    int peer_type = (Integer) params[1];
                                    i2p_result_list.append(host + "\r\n");
                                }
                            });
                        }
                        return (null);
                    }

                    @Override
                    public boolean canInvoke(String methodName, Object[] params) {
                        return (true);
                    }
                };
                i2p_lookup_button.setEnabled(false);
                i2p_result_summary.setText(MessageText.getString("label.searching"));
                try {
                    ipc.invoke("lookupTorrent", new Object[] { "", hash, options, callback });
                } catch (Throwable e) {
                    i2p_lookup_button.setEnabled(true);
                    e.printStackTrace();
                }
            }
        }
    });
    Label i2p_options_info = new Label(i2p_button_comp, SWT.WRAP);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    gd.widthHint = 150;
    Utils.setLayoutData(i2p_options_info, gd);
    i2p_options_info.setText(MessageText.getString("privacy.view.check.bw.info"));
    if (!COConfigurationManager.getBooleanParameter("privacy.view.check.bw.clicked", false)) {
        FontData fontData = i2p_options_info.getFont().getFontData()[0];
        final Font bold_font = new Font(i2p_options_info.getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
        i2p_options_info.setFont(bold_font);
        i2p_options_info.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                bold_font.dispose();
            }
        });
    }
    i2p_options_link = new Label(i2p_button_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    Utils.setLayoutData(i2p_options_link, gd);
    i2p_options_link.setText(MessageText.getString("privacy.view.check.bw"));
    i2p_options_link.setCursor(i2p_options_link.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
    i2p_options_link.setForeground(Colors.blue);
    i2p_options_link.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent arg0) {
            openOptions();
        }

        @Override
        public void mouseUp(MouseEvent arg0) {
            openOptions();
        }

        private void openOptions() {
            COConfigurationManager.setParameter("privacy.view.check.bw.clicked", true);
            UIFunctions uif = UIFunctionsManager.getUIFunctions();
            if (uif != null) {
                uif.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_CONFIG, "azi2phelper.name");
            }
        }
    });
    updateI2PState();
    Utils.makeButtonsEqualWidth(Arrays.asList(new Button[] { i2p_install_button, i2p_lookup_button }));
    label = new Label(i2p_button_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    Utils.setLayoutData(label, gd);
    Group bottom_comp = new Group(cMainComposite, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(bottom_comp, gd);
    bottom_comp.setLayout(new GridLayout(2, false));
    // Torrent Info
    label = new Label(bottom_comp, SWT.NULL);
    label.setText(MessageText.getString("authenticator.torrent") + ":");
    Composite torrent_comp = new Composite(bottom_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(torrent_comp, gd);
    torrent_comp.setLayout(removeMarginsAndSpacing(new GridLayout(2, false)));
    torrent_info = new BufferedLabel(torrent_comp, SWT.DOUBLE_BUFFERED);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(torrent_info, gd);
    // source selection
    label = new Label(bottom_comp, SWT.NULL);
    label.setText(MessageText.getString("ConfigView.section.connection.group.peersources") + ":");
    Composite sources_comp = new Composite(bottom_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(sources_comp, gd);
    source_buttons = new Button[PEPeerSource.PS_SOURCES.length];
    sources_comp.setLayout(removeMargins(new GridLayout(source_buttons.length + 1, false)));
    for (int i = 0; i < source_buttons.length; i++) {
        final String src = PEPeerSource.PS_SOURCES[i];
        String msg_text = "ConfigView.section.connection.peersource." + src;
        Button button = new Button(sources_comp, SWT.CHECK);
        Messages.setLanguageText(button, msg_text);
        source_buttons[i] = button;
        button.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean selected = ((Button) e.widget).getSelection();
                if (current_dm != null) {
                    current_dm.getDownloadState().setPeerSourceEnabled(src, selected);
                }
            }
        });
        GridData gridData = new GridData();
        Utils.setLayoutData(button, gridData);
    }
    // IP Filter
    label = new Label(bottom_comp, SWT.NULL);
    label.setText(MessageText.getString("label.ip.filter") + ":");
    Composite ipfilter_comp = new Composite(bottom_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(ipfilter_comp, gd);
    ipfilter_comp.setLayout(removeMargins(new GridLayout(2, false)));
    ipfilter_enabled = new Button(ipfilter_comp, SWT.CHECK);
    ipfilter_enabled.setText(MessageText.getString("label.enabled"));
    ipfilter_enabled.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            current_dm.getDownloadState().setFlag(DownloadManagerState.FLAG_DISABLE_IP_FILTER, !ipfilter_enabled.getSelection());
        }
    });
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(ipfilter_enabled, gd);
    // VPN Info
    label = new Label(bottom_comp, SWT.NULL);
    label.setText(MessageText.getString("label.vpn.status") + ":");
    Composite vpn_comp = new Composite(bottom_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(vpn_comp, gd);
    vpn_comp.setLayout(removeMargins(new GridLayout(2, false)));
    vpn_info = new BufferedLabel(vpn_comp, SWT.DOUBLE_BUFFERED);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(vpn_info, gd);
    // SOCKS Info
    label = new Label(bottom_comp, SWT.NULL);
    label.setText(MessageText.getString("label.socks.status") + ":");
    Composite socks_comp = new Composite(bottom_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(socks_comp, gd);
    socks_comp.setLayout(removeMargins(new GridLayout(10, false)));
    label = new Label(socks_comp, SWT.NULL);
    label.setText(MessageText.getString("label.proxy") + ":");
    socks_state = new BufferedLabel(socks_comp, SWT.DOUBLE_BUFFERED);
    gd = new GridData();
    gd.widthHint = 120;
    Utils.setLayoutData(socks_state, gd);
    // current details
    label = new Label(socks_comp, SWT.NULL);
    label.setText(MessageText.getString("PeersView.state") + ":");
    socks_current = new BufferedLabel(socks_comp, SWT.DOUBLE_BUFFERED);
    gd = new GridData();
    gd.widthHint = 120;
    Utils.setLayoutData(socks_current, gd);
    // fail details
    label = new Label(socks_comp, SWT.NULL);
    label.setText(MessageText.getString("label.fails") + ":");
    socks_fails = new BufferedLabel(socks_comp, SWT.DOUBLE_BUFFERED);
    gd = new GridData();
    gd.widthHint = 120;
    Utils.setLayoutData(socks_fails, gd);
    // more info
    label = new Label(socks_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
    socks_more = new Label(socks_comp, SWT.NULL);
    socks_more.setText(MessageText.getString("label.more") + "...");
    Utils.setLayoutData(socks_more, gd);
    socks_more.setCursor(socks_more.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
    socks_more.setForeground(Colors.blue);
    socks_more.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent arg0) {
            showSOCKSInfo();
        }

        @Override
        public void mouseUp(MouseEvent arg0) {
            showSOCKSInfo();
        }
    });
    // the rest
    sc.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            Rectangle r = sc.getClientArea();
            Point size = cMainComposite.computeSize(r.width, SWT.DEFAULT);
            sc.setMinSize(size);
        }
    });
    swt_updateFields(null, current_dm);
    updatePeersEtc(current_dm);
    updateVPNSocks();
    Rectangle r = sc.getClientArea();
    Point size = cMainComposite.computeSize(r.width, SWT.DEFAULT);
    sc.setMinSize(size);
    Utils.relayout(cMainComposite);
}
Also used : TOTorrentAnnounceURLGroup(com.biglybt.core.torrent.TOTorrentAnnounceURLGroup) DownloadManagerStateAttributeListener(com.biglybt.core.download.DownloadManagerStateAttributeListener) UISWTViewCoreEventListener(com.biglybt.ui.swt.pifimpl.UISWTViewCoreEventListener) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) Rectangle(org.eclipse.swt.graphics.Rectangle) Font(org.eclipse.swt.graphics.Font) UIFunctions(com.biglybt.ui.UIFunctions) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IPCInterface(com.biglybt.pif.ipc.IPCInterface) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) PluginInterface(com.biglybt.pif.PluginInterface) FontData(org.eclipse.swt.graphics.FontData) IPCException(com.biglybt.pif.ipc.IPCException) MessageText(com.biglybt.core.internat.MessageText) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) SWTRunnable(com.biglybt.ui.swt.utils.SWTRunnable) AERunnable(com.biglybt.core.util.AERunnable) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent)

Example 14 with IPCInterface

use of com.biglybt.pif.ipc.IPCInterface in project BiglyBT by BiglySoftware.

the class AEPluginProxyHandler method testPluginHTTPProxy.

public static Boolean testPluginHTTPProxy(URL url, boolean can_wait, String reason) {
    if (isEnabled()) {
        checkPluginInstallation(null, reason);
        String url_protocol = url.getProtocol().toLowerCase();
        if (url_protocol.startsWith("http")) {
            if (can_wait) {
                waitForPlugins(0);
            }
            for (PluginInterface pi : plugins) {
                try {
                    IPCInterface ipc = pi.getIPC();
                    return ((Boolean) ipc.invoke("testHTTPPseudoProxy", new Object[] { url }));
                } catch (Throwable e) {
                }
            }
        } else {
            Debug.out("Unsupported protocol: " + url_protocol);
        }
    }
    return (null);
}
Also used : PluginInterface(com.biglybt.pif.PluginInterface) DHTPluginInterface(com.biglybt.plugin.dht.DHTPluginInterface) IPCInterface(com.biglybt.pif.ipc.IPCInterface)

Example 15 with IPCInterface

use of com.biglybt.pif.ipc.IPCInterface in project BiglyBT by BiglySoftware.

the class AEPluginProxyHandler method getPluginHTTPProxy.

public static PluginHTTPProxyImpl getPluginHTTPProxy(String reason, URL url, boolean can_wait) {
    if (isEnabled()) {
        checkPluginInstallation(null, reason);
        String url_protocol = url.getProtocol().toLowerCase();
        if (url_protocol.startsWith("http")) {
            if (can_wait) {
                waitForPlugins(0);
            }
            for (PluginInterface pi : plugins) {
                try {
                    IPCInterface ipc = pi.getIPC();
                    Proxy proxy = (Proxy) ipc.invoke("createHTTPPseudoProxy", new Object[] { reason, url });
                    if (proxy != null) {
                        return (new PluginHTTPProxyImpl(reason, ipc, proxy));
                    }
                } catch (Throwable e) {
                }
            }
        } else {
            Debug.out("Unsupported protocol: " + url_protocol);
        }
    }
    return (null);
}
Also used : Proxy(java.net.Proxy) PluginHTTPProxy(com.biglybt.core.proxy.AEProxyFactory.PluginHTTPProxy) PluginProxy(com.biglybt.core.proxy.AEProxyFactory.PluginProxy) PluginInterface(com.biglybt.pif.PluginInterface) DHTPluginInterface(com.biglybt.plugin.dht.DHTPluginInterface) IPCInterface(com.biglybt.pif.ipc.IPCInterface)

Aggregations

IPCInterface (com.biglybt.pif.ipc.IPCInterface)24 PluginInterface (com.biglybt.pif.PluginInterface)14 DHTPluginInterface (com.biglybt.plugin.dht.DHTPluginInterface)6 Map (java.util.Map)6 DiskManagerFileInfo (com.biglybt.pif.disk.DiskManagerFileInfo)5 URL (java.net.URL)5 HashMap (java.util.HashMap)5 ContentFile (com.biglybt.core.content.ContentFile)4 IPCException (com.biglybt.pif.ipc.IPCException)4 DiskManagerFileInfoURL (com.biglybt.core.download.DiskManagerFileInfoURL)3 File (java.io.File)3 AEThread2 (com.biglybt.core.util.AEThread2)2 UIFunctions (com.biglybt.ui.UIFunctions)2 IOException (java.io.IOException)2 ContentDownload (com.biglybt.core.content.ContentDownload)1 ContentFilter (com.biglybt.core.content.ContentFilter)1 DeviceMediaRenderer (com.biglybt.core.devices.DeviceMediaRenderer)1 DiskManagerPiece (com.biglybt.core.disk.DiskManagerPiece)1 DownloadManagerStateAttributeListener (com.biglybt.core.download.DownloadManagerStateAttributeListener)1 MessageText (com.biglybt.core.internat.MessageText)1