Search in sources :

Example 1 with BuddyPlugin

use of com.biglybt.plugin.net.buddy.BuddyPlugin in project BiglyBT by BiglySoftware.

the class TagUIUtils method addShareWithFriendsMenuItems.

private static void addShareWithFriendsMenuItems(Menu menu, Tag tag, TagType tag_type) {
    PluginInterface bpi = PluginInitializer.getDefaultInterface().getPluginManager().getPluginInterfaceByClass(BuddyPlugin.class);
    if (tag_type.getTagType() == TagType.TT_DOWNLOAD_MANUAL && bpi != null) {
        TagFeatureProperties props = (TagFeatureProperties) tag;
        TagProperty tp = props.getProperty(TagFeatureProperties.PR_UNTAGGED);
        Boolean is_ut = tp == null ? null : tp.getBoolean();
        if (is_ut == null || !is_ut) {
            final BuddyPlugin buddy_plugin = (BuddyPlugin) bpi.getPlugin();
            if (buddy_plugin.isClassicEnabled()) {
                final Menu share_menu = new Menu(menu.getShell(), SWT.DROP_DOWN);
                final MenuItem share_item = new MenuItem(menu, SWT.CASCADE);
                Messages.setLanguageText(share_item, "azbuddy.ui.menu.cat.share");
                // nasty hack to fix nastyness on windows
                share_item.setText(share_item.getText() + "  ");
                share_item.setMenu(share_menu);
                List<BuddyPluginBuddy> buddies = buddy_plugin.getBuddies();
                if (buddies.size() == 0) {
                    final MenuItem item = new MenuItem(share_menu, SWT.CHECK);
                    item.setText(MessageText.getString("general.add.friends"));
                    item.setEnabled(false);
                } else {
                    final String tag_name = tag.getTagName(true);
                    final boolean is_public = buddy_plugin.isPublicTagOrCategory(tag_name);
                    final MenuItem itemPubCat = new MenuItem(share_menu, SWT.CHECK);
                    Messages.setLanguageText(itemPubCat, "general.all.friends");
                    itemPubCat.setSelection(is_public);
                    itemPubCat.addListener(SWT.Selection, new Listener() {

                        @Override
                        public void handleEvent(Event event) {
                            if (is_public) {
                                buddy_plugin.removePublicTagOrCategory(tag_name);
                            } else {
                                buddy_plugin.addPublicTagOrCategory(tag_name);
                            }
                        }
                    });
                    new MenuItem(share_menu, SWT.SEPARATOR);
                    for (final BuddyPluginBuddy buddy : buddies) {
                        if (buddy.getNickName() == null) {
                            continue;
                        }
                        final boolean auth = buddy.isLocalRSSTagOrCategoryAuthorised(tag_name);
                        final MenuItem itemShare = new MenuItem(share_menu, SWT.CHECK);
                        itemShare.setText(buddy.getName());
                        itemShare.setSelection(auth || is_public);
                        if (is_public) {
                            itemShare.setEnabled(false);
                        }
                        itemShare.addListener(SWT.Selection, new Listener() {

                            @Override
                            public void handleEvent(Event event) {
                                if (auth) {
                                    buddy.removeLocalAuthorisedRSSTagOrCategory(tag_name);
                                } else {
                                    buddy.addLocalAuthorisedRSSTagOrCategory(tag_name);
                                }
                            }
                        });
                    }
                }
            }
        }
    }
}
Also used : TagProperty(com.biglybt.core.tag.TagFeatureProperties.TagProperty) DisposeListener(org.eclipse.swt.events.DisposeListener) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener) CoreRunningListener(com.biglybt.core.CoreRunningListener) TrackerEditorListener(com.biglybt.ui.swt.maketorrent.TrackerEditorListener) PluginInterface(com.biglybt.pif.PluginInterface) BuddyPlugin(com.biglybt.plugin.net.buddy.BuddyPlugin) BuddyPluginBuddy(com.biglybt.plugin.net.buddy.BuddyPluginBuddy) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 2 with BuddyPlugin

use of com.biglybt.plugin.net.buddy.BuddyPlugin in project BiglyBT by BiglySoftware.

the class CategoryUIUtils method createMenuItems.

public static void createMenuItems(final Menu menu, final Category category) {
    if (category.getType() == Category.TYPE_USER) {
        final MenuItem itemDelete = new MenuItem(menu, SWT.PUSH);
        Messages.setLanguageText(itemDelete, "MyTorrentsView.menu.category.delete");
        itemDelete.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {
                GlobalManager gm = CoreFactory.getSingleton().getGlobalManager();
                List<DownloadManager> managers = category.getDownloadManagers(gm.getDownloadManagers());
                // move to array,since setCategory removed it from the category,
                // which would mess up our loop
                DownloadManager[] dms = managers.toArray(new DownloadManager[managers.size()]);
                for (DownloadManager dm : dms) {
                    DownloadManagerState state = dm.getDownloadState();
                    if (state != null) {
                        state.setCategory(null);
                    }
                }
                CategoryManager.removeCategory(category);
            }
        });
    }
    if (category.getType() != Category.TYPE_ALL) {
        long kInB = DisplayFormatters.getKinB();
        long maxDownload = COConfigurationManager.getIntParameter("Max Download Speed KBs", 0) * kInB;
        long maxUpload = COConfigurationManager.getIntParameter("Max Upload Speed KBs", 0) * kInB;
        int down_speed = category.getDownloadSpeed();
        int up_speed = category.getUploadSpeed();
        ViewUtils.addSpeedMenu(menu.getShell(), menu, true, true, true, true, false, down_speed == 0, down_speed, down_speed, maxDownload, false, up_speed == 0, up_speed, up_speed, maxUpload, 1, null, new SpeedAdapter() {

            @Override
            public void setDownSpeed(int val) {
                category.setDownloadSpeed(val);
            }

            @Override
            public void setUpSpeed(int val) {
                category.setUploadSpeed(val);
            }
        });
    }
    GlobalManager gm = CoreFactory.getSingleton().getGlobalManager();
    List<DownloadManager> managers = category.getDownloadManagers(gm.getDownloadManagers());
    final DownloadManager[] dms = managers.toArray(new DownloadManager[managers.size()]);
    boolean start = false;
    boolean stop = false;
    for (DownloadManager dm : dms) {
        stop = stop || ManagerUtils.isStopable(dm);
        start = start || ManagerUtils.isStartable(dm);
    }
    // Queue
    final MenuItem itemQueue = new MenuItem(menu, SWT.PUSH);
    Messages.setLanguageText(itemQueue, "MyTorrentsView.menu.queue");
    Utils.setMenuItemImage(itemQueue, "start");
    itemQueue.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            GlobalManager gm = CoreFactory.getSingleton().getGlobalManager();
            List<?> managers = category.getDownloadManagers(gm.getDownloadManagers());
            Object[] dms = managers.toArray();
            TorrentUtil.queueDataSources(dms, true);
        }
    });
    itemQueue.setEnabled(start);
    // Stop
    final MenuItem itemStop = new MenuItem(menu, SWT.PUSH);
    Messages.setLanguageText(itemStop, "MyTorrentsView.menu.stop");
    Utils.setMenuItemImage(itemStop, "stop");
    itemStop.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            GlobalManager gm = CoreFactory.getSingleton().getGlobalManager();
            List<?> managers = category.getDownloadManagers(gm.getDownloadManagers());
            Object[] dms = managers.toArray();
            TorrentUtil.stopDataSources(dms);
        }
    });
    itemStop.setEnabled(stop);
    if (category.canBePublic()) {
        new MenuItem(menu, SWT.SEPARATOR);
        final MenuItem itemPublic = new MenuItem(menu, SWT.CHECK);
        itemPublic.setSelection(category.isPublic());
        Messages.setLanguageText(itemPublic, "cat.share");
        itemPublic.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {
                category.setPublic(itemPublic.getSelection());
            }
        });
    }
    // share with friends
    PluginInterface bpi = PluginInitializer.getDefaultInterface().getPluginManager().getPluginInterfaceByClass(BuddyPlugin.class);
    int cat_type = category.getType();
    if (bpi != null && cat_type != Category.TYPE_UNCATEGORIZED) {
        final BuddyPlugin buddy_plugin = (BuddyPlugin) bpi.getPlugin();
        if (buddy_plugin.isClassicEnabled()) {
            final Menu share_menu = new Menu(menu.getShell(), SWT.DROP_DOWN);
            final MenuItem share_item = new MenuItem(menu, SWT.CASCADE);
            Messages.setLanguageText(share_item, "azbuddy.ui.menu.cat.share");
            share_item.setMenu(share_menu);
            List<BuddyPluginBuddy> buddies = buddy_plugin.getBuddies();
            if (buddies.size() == 0) {
                final MenuItem item = new MenuItem(share_menu, SWT.CHECK);
                item.setText(MessageText.getString("general.add.friends"));
                item.setEnabled(false);
            } else {
                final String cname;
                if (cat_type == Category.TYPE_ALL) {
                    cname = "All";
                } else {
                    cname = category.getName();
                }
                final boolean is_public = buddy_plugin.isPublicTagOrCategory(cname);
                final MenuItem itemPubCat = new MenuItem(share_menu, SWT.CHECK);
                Messages.setLanguageText(itemPubCat, "general.all.friends");
                itemPubCat.setSelection(is_public);
                itemPubCat.addListener(SWT.Selection, new Listener() {

                    @Override
                    public void handleEvent(Event event) {
                        if (is_public) {
                            buddy_plugin.removePublicTagOrCategory(cname);
                        } else {
                            buddy_plugin.addPublicTagOrCategory(cname);
                        }
                    }
                });
                new MenuItem(share_menu, SWT.SEPARATOR);
                for (final BuddyPluginBuddy buddy : buddies) {
                    if (buddy.getNickName() == null) {
                        continue;
                    }
                    final boolean auth = buddy.isLocalRSSTagOrCategoryAuthorised(cname);
                    final MenuItem itemShare = new MenuItem(share_menu, SWT.CHECK);
                    itemShare.setText(buddy.getName());
                    itemShare.setSelection(auth || is_public);
                    if (is_public) {
                        itemShare.setEnabled(false);
                    }
                    itemShare.addListener(SWT.Selection, new Listener() {

                        @Override
                        public void handleEvent(Event event) {
                            if (auth) {
                                buddy.removeLocalAuthorisedRSSTagOrCategory(cname);
                            } else {
                                buddy.addLocalAuthorisedRSSTagOrCategory(cname);
                            }
                        }
                    });
                }
            }
        }
    }
    if (category.getType() != Category.TYPE_ALL) {
        TrancodeUIUtils.TranscodeTarget[] tts = TrancodeUIUtils.getTranscodeTargets();
        if (tts.length > 0) {
            final Menu t_menu = new Menu(menu.getShell(), SWT.DROP_DOWN);
            final MenuItem t_item = new MenuItem(menu, SWT.CASCADE);
            Messages.setLanguageText(t_item, "cat.autoxcode");
            t_item.setMenu(t_menu);
            String existing = category.getStringAttribute(Category.AT_AUTO_TRANSCODE_TARGET);
            for (TrancodeUIUtils.TranscodeTarget tt : tts) {
                TrancodeUIUtils.TranscodeProfile[] profiles = tt.getProfiles();
                if (profiles.length > 0) {
                    final Menu tt_menu = new Menu(t_menu.getShell(), SWT.DROP_DOWN);
                    final MenuItem tt_item = new MenuItem(t_menu, SWT.CASCADE);
                    tt_item.setText(tt.getName());
                    tt_item.setMenu(tt_menu);
                    for (final TrancodeUIUtils.TranscodeProfile tp : profiles) {
                        final MenuItem p_item = new MenuItem(tt_menu, SWT.CHECK);
                        p_item.setText(tp.getName());
                        boolean selected = existing != null && existing.equals(tp.getUID());
                        if (selected) {
                            Utils.setMenuItemImage(tt_item, "blacktick");
                        }
                        p_item.setSelection(selected);
                        p_item.addListener(SWT.Selection, new Listener() {

                            @Override
                            public void handleEvent(Event event) {
                                category.setStringAttribute(Category.AT_AUTO_TRANSCODE_TARGET, p_item.getSelection() ? tp.getUID() : null);
                            }
                        });
                    }
                }
            }
        }
    }
    // rss feed
    final MenuItem rssOption = new MenuItem(menu, SWT.CHECK);
    rssOption.setSelection(category.getBooleanAttribute(Category.AT_RSS_GEN));
    Messages.setLanguageText(rssOption, "cat.rss.gen");
    rssOption.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            boolean set = rssOption.getSelection();
            category.setBooleanAttribute(Category.AT_RSS_GEN, set);
        }
    });
    if (cat_type != Category.TYPE_UNCATEGORIZED && cat_type != Category.TYPE_ALL) {
        final MenuItem upPriority = new MenuItem(menu, SWT.CHECK);
        upPriority.setSelection(category.getIntAttribute(Category.AT_UPLOAD_PRIORITY) > 0);
        Messages.setLanguageText(upPriority, "cat.upload.priority");
        upPriority.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {
                boolean set = upPriority.getSelection();
                category.setIntAttribute(Category.AT_UPLOAD_PRIORITY, set ? 1 : 0);
            }
        });
    }
    // options
    MenuItem itemOptions = new MenuItem(menu, SWT.PUSH);
    Messages.setLanguageText(itemOptions, "cat.options");
    itemOptions.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
            if (uiFunctions != null) {
                MultipleDocumentInterface mdi = uiFunctions.getMDI();
                if (mdi != null) {
                    mdi.showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_TORRENT_OPTIONS, dms);
                }
            }
        }
    });
    if (dms.length == 0) {
        itemOptions.setEnabled(false);
    }
}
Also used : Listener(org.eclipse.swt.widgets.Listener) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener) MenuListener(org.eclipse.swt.events.MenuListener) DownloadManager(com.biglybt.core.download.DownloadManager) DownloadManagerState(com.biglybt.core.download.DownloadManagerState) BuddyPlugin(com.biglybt.plugin.net.buddy.BuddyPlugin) SpeedAdapter(com.biglybt.ui.swt.views.ViewUtils.SpeedAdapter) GlobalManager(com.biglybt.core.global.GlobalManager) UIFunctions(com.biglybt.ui.UIFunctions) List(java.util.List) Menu(org.eclipse.swt.widgets.Menu) PluginInterface(com.biglybt.pif.PluginInterface) MenuItem(org.eclipse.swt.widgets.MenuItem) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) BuddyPluginBuddy(com.biglybt.plugin.net.buddy.BuddyPluginBuddy) Event(org.eclipse.swt.widgets.Event) MenuEvent(org.eclipse.swt.events.MenuEvent)

Example 3 with BuddyPlugin

use of com.biglybt.plugin.net.buddy.BuddyPlugin in project BiglyBT by BiglySoftware.

the class PeersViewBase method fillMenu.

private static void fillMenu(final Menu menu, final PEPeer[] peers, final Shell shell, DownloadManager download_specific) {
    boolean hasSelection = (peers.length > 0);
    boolean downSpeedDisabled = false;
    boolean downSpeedUnlimited = false;
    long totalDownSpeed = 0;
    long downSpeedSetMax = 0;
    long maxDown = 0;
    boolean upSpeedDisabled = false;
    boolean upSpeedUnlimited = false;
    long totalUpSpeed = 0;
    long upSpeedSetMax = 0;
    long maxUp = 0;
    GlobalManager gm = CoreFactory.getSingleton().getGlobalManager();
    final IdentityHashSet<DownloadManager> download_managers = new IdentityHashSet<>();
    Map<PEPeer, DownloadManager> peer_dm_map = new HashMap<>();
    if (hasSelection) {
        for (int i = 0; i < peers.length; i++) {
            PEPeer peer = peers[i];
            PEPeerManager m = peer.getManager();
            if (m != null) {
                if (gm != null) {
                    DownloadManager dm = gm.getDownloadManager(new HashWrapper(m.getHash()));
                    if (dm != null) {
                        peer_dm_map.put(peer, dm);
                        download_managers.add(dm);
                    }
                }
            }
            try {
                int maxul = peer.getStats().getUploadRateLimitBytesPerSecond();
                maxUp += maxul * 4;
                if (maxul == 0) {
                    upSpeedUnlimited = true;
                } else {
                    if (maxul > upSpeedSetMax) {
                        upSpeedSetMax = maxul;
                    }
                }
                if (maxul == -1) {
                    maxul = 0;
                    upSpeedDisabled = true;
                }
                totalUpSpeed += maxul;
                int maxdl = peer.getStats().getDownloadRateLimitBytesPerSecond();
                maxDown += maxdl * 4;
                if (maxdl == 0) {
                    downSpeedUnlimited = true;
                } else {
                    if (maxdl > downSpeedSetMax) {
                        downSpeedSetMax = maxdl;
                    }
                }
                if (maxdl == -1) {
                    maxdl = 0;
                    downSpeedDisabled = true;
                }
                totalDownSpeed += maxdl;
            } catch (Exception ex) {
                Debug.printStackTrace(ex);
            }
        }
    }
    if (download_specific != null) {
        final MenuItem block_item = new MenuItem(menu, SWT.CHECK);
        PEPeer peer = peers.length == 0 ? null : peers[0];
        if (peer == null || peer.getManager().getDiskManager().getRemainingExcludingDND() > 0) {
            // disallow peer upload blocking when downloading
            block_item.setSelection(false);
            block_item.setEnabled(false);
        } else {
            block_item.setEnabled(true);
            block_item.setSelection(peer.isSnubbed());
        }
        if (peer != null) {
            final boolean newSnubbedValue = !peer.isSnubbed();
            Messages.setLanguageText(block_item, "PeersView.menu.blockupload");
            block_item.addListener(SWT.Selection, new PeersRunner(peers) {

                @Override
                public void run(PEPeer peer) {
                    peer.setSnubbed(newSnubbedValue);
                }
            });
        }
    } else {
        if (download_managers.size() > 0) {
            MenuItem itemDetails = new MenuItem(menu, SWT.PUSH);
            Messages.setLanguageText(itemDetails, "PeersView.menu.showdownload");
            Utils.setMenuItemImage(itemDetails, "details");
            itemDetails.addListener(SWT.Selection, new Listener() {

                @Override
                public void handleEvent(Event event) {
                    UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
                    if (uiFunctions != null) {
                        for (DownloadManager dm : download_managers) {
                            uiFunctions.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_TORRENT_DETAILS, dm);
                        }
                    }
                }
            });
            new MenuItem(menu, SWT.SEPARATOR);
        }
    }
    BuddyPlugin bp = BuddyPluginUtils.getPlugin();
    if (bp != null) {
        boolean has_pb = false;
        boolean has_public = false;
        for (PEPeer peer : peers) {
            if (AENetworkClassifier.categoriseAddress(peer.getIp()) == AENetworkClassifier.AT_PUBLIC) {
                has_public = true;
                DownloadManager dm = peer_dm_map.get(peer);
                if (dm != null && bp.isPartialBuddy(PluginCoreUtils.wrap(dm), PluginCoreUtils.wrap(peer))) {
                    has_pb = true;
                }
            }
        }
        MenuItem boost_item = new MenuItem(menu, SWT.CHECK);
        Messages.setLanguageText(boost_item, "PeersView.menu.boost");
        boost_item.setSelection(has_pb);
        boost_item.setEnabled(has_public);
        boost_item.addListener(SWT.Selection, new PeersRunner(peers) {

            @Override
            public void run(PEPeer peer) {
                boolean sel = boost_item.getSelection();
                if (AENetworkClassifier.categoriseAddress(peer.getIp()) == AENetworkClassifier.AT_PUBLIC) {
                    DownloadManager dm = peer_dm_map.get(peer);
                    if (dm != null) {
                        bp.setPartialBuddy(PluginCoreUtils.wrap(dm), PluginCoreUtils.wrap(peer), sel);
                    }
                }
            }
        });
    }
    final MenuItem kick_item = new MenuItem(menu, SWT.PUSH);
    Messages.setLanguageText(kick_item, "PeersView.menu.kick");
    kick_item.addListener(SWT.Selection, new PeersRunner(peers) {

        @Override
        public void run(PEPeer peer) {
            peer.getManager().removePeer(peer, "Peer kicked");
        }
    });
    final MenuItem ban_item = new MenuItem(menu, SWT.PUSH);
    Messages.setLanguageText(ban_item, "PeersView.menu.kickandban");
    ban_item.addListener(SWT.Selection, new PeersRunner(peers) {

        @Override
        public void run(PEPeer peer) {
            String msg = MessageText.getString("PeersView.menu.kickandban.reason");
            IpFilterManagerFactory.getSingleton().getIPFilter().ban(peer.getIp(), msg, true);
            peer.getManager().removePeer(peer, "Peer kicked and banned");
        }
    });
    final MenuItem ban_for_item = new MenuItem(menu, SWT.PUSH);
    Messages.setLanguageText(ban_for_item, "PeersView.menu.kickandbanfor");
    ban_for_item.addListener(SWT.Selection, new PeersRunner(peers) {

        @Override
        public boolean run(final PEPeer[] peers) {
            String text = MessageText.getString("dialog.ban.for.period.text");
            SimpleTextEntryWindow entryWindow = new SimpleTextEntryWindow("dialog.ban.for.period.title", "!" + text + "!");
            int def = COConfigurationManager.getIntParameter("ban.for.period.default", 60);
            entryWindow.setPreenteredText(String.valueOf(def), false);
            entryWindow.prompt(new UIInputReceiverListener() {

                @Override
                public void UIInputReceiverClosed(UIInputReceiver entryWindow) {
                    if (!entryWindow.hasSubmittedInput()) {
                        return;
                    }
                    String sReturn = entryWindow.getSubmittedInput();
                    if (sReturn == null) {
                        return;
                    }
                    int mins = -1;
                    try {
                        mins = Integer.valueOf(sReturn).intValue();
                    } catch (NumberFormatException er) {
                    // Ignore
                    }
                    if (mins <= 0) {
                        MessageBox mb = new MessageBox(Utils.findAnyShell(), SWT.ICON_ERROR | SWT.OK);
                        mb.setText(MessageText.getString("MyTorrentsView.dialog.NumberError.title"));
                        mb.setMessage(MessageText.getString("MyTorrentsView.dialog.NumberError.text"));
                        mb.open();
                        return;
                    }
                    COConfigurationManager.setParameter("ban.for.period.default", mins);
                    IpFilter filter = IpFilterManagerFactory.getSingleton().getIPFilter();
                    for (PEPeer peer : peers) {
                        String msg = MessageText.getString("PeersView.menu.kickandbanfor.reason", new String[] { String.valueOf(mins) });
                        filter.ban(peer.getIp(), msg, true, mins);
                        peer.getManager().removePeer(peer, "Peer kicked and banned");
                    }
                }
            });
            return (true);
        }
    });
    // === advanced menu ===
    final MenuItem itemAdvanced = new MenuItem(menu, SWT.CASCADE);
    Messages.setLanguageText(itemAdvanced, "MyTorrentsView.menu.advancedmenu");
    itemAdvanced.setEnabled(hasSelection);
    final Menu menuAdvanced = new Menu(shell, SWT.DROP_DOWN);
    itemAdvanced.setMenu(menuAdvanced);
    // advanced > Download Speed Menu //
    Map<String, Object> menu_properties = new HashMap<>();
    menu_properties.put(ViewUtils.SM_PROP_PERMIT_UPLOAD_DISABLE, true);
    menu_properties.put(ViewUtils.SM_PROP_PERMIT_DOWNLOAD_DISABLE, true);
    ViewUtils.addSpeedMenu(shell, menuAdvanced, true, true, false, hasSelection, downSpeedDisabled, downSpeedUnlimited, totalDownSpeed, downSpeedSetMax, maxDown, upSpeedDisabled, upSpeedUnlimited, totalUpSpeed, upSpeedSetMax, maxUp, peers.length, menu_properties, new ViewUtils.SpeedAdapter() {

        @Override
        public void setDownSpeed(int speed) {
            if (peers.length > 0) {
                for (int i = 0; i < peers.length; i++) {
                    try {
                        PEPeer peer = (PEPeer) peers[i];
                        peer.getStats().setDownloadRateLimitBytesPerSecond(speed);
                    } catch (Exception e) {
                        Debug.printStackTrace(e);
                    }
                }
            }
        }

        @Override
        public void setUpSpeed(int speed) {
            if (peers.length > 0) {
                for (int i = 0; i < peers.length; i++) {
                    try {
                        PEPeer peer = (PEPeer) peers[i];
                        peer.getStats().setUploadRateLimitBytesPerSecond(speed);
                    } catch (Exception e) {
                        Debug.printStackTrace(e);
                    }
                }
            }
        }
    });
    addPeersMenu(download_specific, "", menu);
}
Also used : IdentityHashSet(com.biglybt.core.util.IdentityHashSet) PEPeer(com.biglybt.core.peer.PEPeer) IpFilter(com.biglybt.core.ipfilter.IpFilter) SelectionListener(org.eclipse.swt.events.SelectionListener) TableViewSWTMenuFillListener(com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener) Listener(org.eclipse.swt.widgets.Listener) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener) TableSelectionListener(com.biglybt.ui.common.table.TableSelectionListener) UIManagerListener(com.biglybt.pif.ui.UIManagerListener) TableLifeCycleListener(com.biglybt.ui.common.table.TableLifeCycleListener) HashMap(java.util.HashMap) DownloadManager(com.biglybt.core.download.DownloadManager) BuddyPlugin(com.biglybt.plugin.net.buddy.BuddyPlugin) GlobalManager(com.biglybt.core.global.GlobalManager) UIFunctions(com.biglybt.ui.UIFunctions) SimpleTextEntryWindow(com.biglybt.ui.swt.SimpleTextEntryWindow) Menu(org.eclipse.swt.widgets.Menu) MenuItem(org.eclipse.swt.widgets.MenuItem) MessageBox(org.eclipse.swt.widgets.MessageBox) HashWrapper(com.biglybt.core.util.HashWrapper) UIInputReceiver(com.biglybt.pif.ui.UIInputReceiver) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) PEPeerManager(com.biglybt.core.peer.PEPeerManager) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener)

Aggregations

UIInputReceiverListener (com.biglybt.pif.ui.UIInputReceiverListener)3 BuddyPlugin (com.biglybt.plugin.net.buddy.BuddyPlugin)3 DownloadManager (com.biglybt.core.download.DownloadManager)2 GlobalManager (com.biglybt.core.global.GlobalManager)2 PluginInterface (com.biglybt.pif.PluginInterface)2 BuddyPluginBuddy (com.biglybt.plugin.net.buddy.BuddyPluginBuddy)2 UIFunctions (com.biglybt.ui.UIFunctions)2 Event (org.eclipse.swt.widgets.Event)2 Listener (org.eclipse.swt.widgets.Listener)2 Menu (org.eclipse.swt.widgets.Menu)2 MenuItem (org.eclipse.swt.widgets.MenuItem)2 CoreRunningListener (com.biglybt.core.CoreRunningListener)1 DownloadManagerState (com.biglybt.core.download.DownloadManagerState)1 IpFilter (com.biglybt.core.ipfilter.IpFilter)1 PEPeer (com.biglybt.core.peer.PEPeer)1 PEPeerManager (com.biglybt.core.peer.PEPeerManager)1 TagProperty (com.biglybt.core.tag.TagFeatureProperties.TagProperty)1 HashWrapper (com.biglybt.core.util.HashWrapper)1 IdentityHashSet (com.biglybt.core.util.IdentityHashSet)1 UIInputReceiver (com.biglybt.pif.ui.UIInputReceiver)1