Search in sources :

Example 6 with IPCException

use of com.biglybt.pif.ipc.IPCException 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 7 with IPCException

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

the class TranscodeProviderVuze method update.

protected void update(PluginInterface pi) {
    plugin_interface = pi;
    try {
        plugin_interface.getIPC().invoke("addProfileListChangedListener", new Object[] { new AERunnable() {

            @Override
            public void runSupport() {
                resetProfiles();
            }
        } });
    } catch (IPCException e) {
    }
    resetProfiles();
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) IPCException(com.biglybt.pif.ipc.IPCException)

Example 8 with IPCException

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

the class IPCInterfaceImpl method invoke.

@Override
public Object invoke(String methodName, Object[] params) throws IPCException {
    Object target = getTarget();
    try {
        Method mtd = getMethod(target, methodName, params);
        mtd.setAccessible(true);
        return mtd.invoke(target, params);
    } catch (Throwable e) {
        if (e instanceof InvocationTargetException) {
            if (e.getCause() != null) {
                e = e.getCause();
            }
        }
        throw new IPCException(e);
    }
}
Also used : IPCException(com.biglybt.pif.ipc.IPCException) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 9 with IPCException

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

the class SpeedTestSelector method _runMLABTest.

private static void _runMLABTest(final Runnable runWhenClosed) {
    PluginInterface pi = CoreFactory.getSingleton().getPluginManager().getPluginInterfaceByID("mlab");
    if (pi == null) {
        Debug.out("mlab plugin not available");
        if (runWhenClosed != null) {
            runWhenClosed.run();
        }
    } else {
        try {
            HashMap<String, Object> map = new HashMap<>();
            pi.getIPC().invoke("runTest", new Object[] { map, new IPCInterface() {

                @Override
                public Object invoke(String methodName, Object[] params) throws IPCException {
                    // we could set SpeedTest Completed when methodName == "results"
                    // or ask user if they want to be prompted again if it isn't
                    // But, we'd have to pass a param into runMLABTest (so we don't
                    // get prompt on menu invocation).
                    // For now, show only once, with no reprompt (even if they cancel).
                    // They can use the menu
                    COConfigurationManager.setParameter("SpeedTest Completed", true);
                    if (runWhenClosed != null) {
                        runWhenClosed.run();
                    }
                    return null;
                }

                @Override
                public boolean canInvoke(String methodName, Object[] params) {
                    return true;
                }
            }, true });
        } catch (Throwable e) {
            Debug.out(e);
            if (runWhenClosed != null) {
                runWhenClosed.run();
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) PluginInterface(com.biglybt.pif.PluginInterface) IPCException(com.biglybt.pif.ipc.IPCException) IPCInterface(com.biglybt.pif.ipc.IPCInterface)

Aggregations

IPCException (com.biglybt.pif.ipc.IPCException)9 PluginInterface (com.biglybt.pif.PluginInterface)4 IPCInterface (com.biglybt.pif.ipc.IPCInterface)4 AERunnable (com.biglybt.core.util.AERunnable)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 DownloadManagerStateAttributeListener (com.biglybt.core.download.DownloadManagerStateAttributeListener)1 MessageText (com.biglybt.core.internat.MessageText)1 SubscriptionManager (com.biglybt.core.subs.SubscriptionManager)1 TOTorrentAnnounceURLGroup (com.biglybt.core.torrent.TOTorrentAnnounceURLGroup)1 MagnetPlugin (com.biglybt.plugin.magnet.MagnetPlugin)1 MagnetPluginProgressListener (com.biglybt.plugin.magnet.MagnetPluginProgressListener)1 UIFunctions (com.biglybt.ui.UIFunctions)1 BufferedLabel (com.biglybt.ui.swt.components.BufferedLabel)1 LinkLabel (com.biglybt.ui.swt.components.LinkLabel)1 UISWTViewEvent (com.biglybt.ui.swt.pif.UISWTViewEvent)1 UISWTViewCoreEventListener (com.biglybt.ui.swt.pifimpl.UISWTViewCoreEventListener)1 SWTRunnable (com.biglybt.ui.swt.utils.SWTRunnable)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1