Search in sources :

Example 1 with PluginManager

use of com.biglybt.pif.PluginManager in project BiglyBT by BiglySoftware.

the class SideBar method addGeneralMenus.

/**
 * @since 3.1.0.1
 */
private void addGeneralMenus() {
    PluginManager pm = CoreFactory.getSingleton().getPluginManager();
    PluginInterface pi = pm.getDefaultPluginInterface();
    UIManager uim = pi.getUIManager();
    MenuManager menuManager = uim.getMenuManager();
    {
        MenuItem menuItem = menuManager.addMenuItem("sidebar._end_", "menu.add.to.dashboard");
        menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
        menuItem.addFillListener(new MenuItemFillListener() {

            @Override
            public void menuWillBeShown(MenuItem menu, Object data) {
                SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
                if (sbe != null && sbe.getId().equals(MultipleDocumentInterface.SIDEBAR_HEADER_DASHBOARD)) {
                    menu.setVisible(false);
                } else {
                    menu.setVisible(sbe != null && sbe.canBuildStandAlone());
                }
            }
        });
        menuItem.addListener(new MenuItemListener() {

            @Override
            public void selected(MenuItem menu, Object target) {
                SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
                if (sbe != null) {
                    MainMDISetup.getSb_dashboard().addItem(sbe);
                }
            }
        });
    }
    {
        MenuItem menuItem = menuManager.addMenuItem("sidebar._end_", "menu.pop.out");
        menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
        menuItem.addFillListener(new MenuItemFillListener() {

            @Override
            public void menuWillBeShown(MenuItem menu, Object data) {
                SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
                menu.setVisible(sbe != null && sbe.canBuildStandAlone());
            }
        });
        menuItem.addListener(new MenuItemListener() {

            @Override
            public void selected(MenuItem menu, Object target) {
                SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
                if (sbe != null) {
                    SkinnedDialog skinnedDialog = new SkinnedDialog("skin3_dlg_sidebar_popout", "shell", // standalone
                    null, SWT.RESIZE | SWT.MAX | SWT.DIALOG_TRIM);
                    SWTSkin skin = skinnedDialog.getSkin();
                    SWTSkinObjectContainer cont = sbe.buildStandAlone((SWTSkinObjectContainer) skin.getSkinObject("content-area"));
                    if (cont != null) {
                        skinnedDialog.setTitle(sbe.getTitle());
                        skinnedDialog.open();
                    } else {
                        skinnedDialog.close();
                    }
                }
            }
        });
    }
}
Also used : PluginManager(com.biglybt.pif.PluginManager) MenuItemFillListener(com.biglybt.pif.ui.menus.MenuItemFillListener) PluginInterface(com.biglybt.pif.PluginInterface) MenuManager(com.biglybt.pif.ui.menus.MenuManager) UIManager(com.biglybt.pif.ui.UIManager) MenuItem(com.biglybt.pif.ui.menus.MenuItem) PluginUISWTSkinObject(com.biglybt.ui.swt.pif.PluginUISWTSkinObject) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) SkinnedDialog(com.biglybt.ui.swt.views.skin.SkinnedDialog)

Example 2 with PluginManager

use of com.biglybt.pif.PluginManager in project BiglyBT by BiglySoftware.

the class ManagerUtils method getMediaServerContentURL.

public static URL getMediaServerContentURL(DiskManagerFileInfo file) {
    PluginManager pm = CoreFactory.getSingleton().getPluginManager();
    PluginInterface pi = pm.getPluginInterfaceByID("azupnpav", false);
    if (pi == null) {
        return (null);
    }
    if (!pi.getPluginState().isOperational()) {
        return (null);
    }
    try {
        Object url = pi.getIPC().invoke("getContentURL", new Object[] { PluginCoreUtils.wrap(file) });
        if (url instanceof String) {
            String s_url = (String) url;
            if (s_url.length() > 0) {
                return (new URL(s_url));
            }
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
    return (null);
}
Also used : PluginManager(com.biglybt.pif.PluginManager) PluginInterface(com.biglybt.pif.PluginInterface) URL(java.net.URL)

Example 3 with PluginManager

use of com.biglybt.pif.PluginManager in project BiglyBT by BiglySoftware.

the class StreamManager method isStreamingUsable.

public boolean isStreamingUsable() {
    if (!(Constants.isWindows || Constants.isOSX)) {
        return (false);
    }
    try {
        PluginManager plug_man = CoreFactory.getSingleton().getPluginManager();
        PluginInterface xcode_pi = plug_man.getPluginInterfaceByID("vuzexcode", false);
        if (xcode_pi != null && !xcode_pi.getPluginState().isOperational()) {
            return (false);
        }
        // otherwise xcode will be installed on demand
        PluginInterface emp_pi = plug_man.getPluginInterfaceByID("azemp", false);
        if (emp_pi == null) {
            return (true);
        }
        if (!emp_pi.getPluginState().isOperational()) {
            return (false);
        }
        // emp installed but need version with prepareWindow, wait for update
        Class<?> epwClass = emp_pi.getPlugin().getClass().getClassLoader().loadClass("com.azureus.plugins.azemp.ui.swt.emp.EmbeddedPlayerWindowSWT");
        Method method = epwClass.getMethod("prepareWindow", new Class[] { String.class });
        return (method != null);
    } catch (Throwable e) {
        return (false);
    }
}
Also used : PluginManager(com.biglybt.pif.PluginManager) PluginInterface(com.biglybt.pif.PluginInterface) Method(java.lang.reflect.Method)

Example 4 with PluginManager

use of com.biglybt.pif.PluginManager in project BiglyBT by BiglySoftware.

the class LightWeightSeedManager method startUp.

protected void startUp() {
    synchronized (this) {
        if (started) {
            return;
        }
        started = true;
    }
    boolean release_now = true;
    try {
        final PluginManager plugin_manager = CoreFactory.getSingleton().getPluginManager();
        PluginInterface pi = plugin_manager.getPluginInterfaceByClass(DHTTrackerPlugin.class);
        if (pi != null) {
            final DHTTrackerPlugin plugin = (DHTTrackerPlugin) pi.getPlugin();
            new AEThread2("LWS:waitForPlug", true) {

                @Override
                public void run() {
                    try {
                        plugin.waitUntilInitialised();
                        if (plugin.isRunning()) {
                            tttorrent = DDBaseImpl.getSingleton(CoreFactory.getSingleton()).getTTTorrent();
                        }
                        Set<LWSDownload> to_add;
                        try {
                            PluginInterface anon_pi = plugin_manager.getPluginInterfaceByID("azneti2phelper");
                            if (anon_pi != null) {
                                anon_dht_tracker_plugin = anon_pi.getIPC();
                            }
                        } catch (Throwable e) {
                            Debug.out(e);
                        }
                        synchronized (this) {
                            public_dht_tracker_plugin = plugin;
                            to_add = new HashSet<>(dht_add_queue);
                            dht_add_queue.clear();
                        }
                        Iterator<LWSDownload> it = to_add.iterator();
                        while (it.hasNext()) {
                            addDownload(it.next());
                        }
                    } finally {
                        init_sem.releaseForever();
                    }
                }
            }.start();
            release_now = false;
        } else {
            synchronized (dht_add_queue) {
                borked = true;
                dht_add_queue.clear();
            }
        }
    } finally {
        if (release_now) {
            init_sem.releaseForever();
        }
    }
}
Also used : PluginManager(com.biglybt.pif.PluginManager) PluginInterface(com.biglybt.pif.PluginInterface) DHTTrackerPlugin(com.biglybt.plugin.tracker.dht.DHTTrackerPlugin)

Example 5 with PluginManager

use of com.biglybt.pif.PluginManager in project BiglyBT by BiglySoftware.

the class OverallStatsImpl method updateStats.

private void updateStats(boolean force) {
    try {
        this_mon.enter();
        long current_time = SystemTime.getCurrentTime() / 1000;
        if (current_time < lastUptime) {
            // time went backwards
            lastUptime = current_time;
            return;
        }
        long current_total_d_received = gm_stats.getTotalDataBytesReceived();
        long current_total_p_received = gm_stats.getTotalProtocolBytesReceived();
        long current_total_d_sent = gm_stats.getTotalDataBytesSent();
        long current_total_p_sent = gm_stats.getTotalProtocolBytesSent();
        long current_total_received = current_total_d_received + current_total_p_received;
        long current_total_sent = current_total_d_sent + current_total_p_sent;
        // overall totals
        totalDownloaded += current_total_received - lastDownloaded;
        lastDownloaded = current_total_received;
        if (totalDownloaded < 0)
            totalDownloaded = 0;
        totalUploaded += current_total_sent - lastUploaded;
        lastUploaded = current_total_sent;
        if (totalUploaded < 0)
            totalUploaded = 0;
        // split totals
        totalDataDownloaded += current_total_d_received - lastDataDownloaded;
        lastDataDownloaded = current_total_d_received;
        if (totalDataDownloaded < 0)
            totalDataDownloaded = 0;
        totalProtocolDownloaded += current_total_p_received - lastProtocolDownloaded;
        lastProtocolDownloaded = current_total_p_received;
        if (totalProtocolDownloaded < 0)
            totalProtocolDownloaded = 0;
        totalDataUploaded += current_total_d_sent - lastDataUploaded;
        lastDataUploaded = current_total_d_sent;
        if (totalDataUploaded < 0)
            totalDataUploaded = 0;
        totalProtocolUploaded += current_total_p_sent - lastProtocolUploaded;
        lastProtocolUploaded = current_total_p_sent;
        if (totalProtocolUploaded < 0)
            totalProtocolUploaded = 0;
        if (dhts == null) {
            try {
                PluginManager pm = core.getPluginManager();
                if (pm.isInitialized()) {
                    PluginInterface dht_pi = pm.getPluginInterfaceByClass(DHTPlugin.class);
                    if (dht_pi == null) {
                        dhts = new DHT[0];
                    } else {
                        DHTPlugin plugin = (DHTPlugin) dht_pi.getPlugin();
                        if (!plugin.isInitialising()) {
                            if (plugin.isEnabled()) {
                                dhts = ((DHTPlugin) dht_pi.getPlugin()).getDHTs();
                            } else {
                                dhts = new DHT[0];
                            }
                        }
                    }
                }
            } catch (Throwable e) {
                dhts = new DHT[0];
            }
        }
        long current_total_dht_up = 0;
        long current_total_dht_down = 0;
        if (dhts != null) {
            for (DHT dht : dhts) {
                DHTTransportStats stats = dht.getTransport().getStats();
                current_total_dht_up += stats.getBytesSent();
                current_total_dht_down += stats.getBytesReceived();
            }
        }
        totalDHTUploaded += current_total_dht_up - lastDHTUploaded;
        lastDHTUploaded = current_total_dht_up;
        if (totalDHTUploaded < 0)
            totalDHTUploaded = 0;
        totalDHTDownloaded += current_total_dht_down - lastDHTDownloaded;
        lastDHTDownloaded = current_total_dht_down;
        if (totalDHTDownloaded < 0)
            totalDHTDownloaded = 0;
        // TIME
        long delta = current_time - lastUptime;
        if (delta > 100 || delta < 0) {
            // make sure the time diff isn't borked
            lastUptime = current_time;
            return;
        }
        if (totalUptime < 0)
            totalUptime = 0;
        totalUptime += delta;
        lastUptime = current_time;
        lastSnapshot = new long[] { totalProtocolUploaded, totalDataUploaded, totalProtocolDownloaded, totalDataDownloaded, totalDHTUploaded, totalDHTDownloaded, current_total_p_sent, current_total_d_sent, current_total_p_received, current_total_d_received, current_total_dht_up, current_total_dht_down };
        HashMap overallMap = new HashMap();
        overallMap.put("downloaded", new Long(totalDownloaded));
        overallMap.put("uploaded", new Long(totalUploaded));
        overallMap.put("uptime", new Long(totalUptime));
        overallMap.put("mark_time", new Long(markTime));
        overallMap.put("mark_downloaded", new Long(markTotalDownloaded));
        overallMap.put("mark_uploaded", new Long(markTotalUploaded));
        overallMap.put("mark_uptime", new Long(markTotalUptime));
        overallMap.put("dht_down", new Long(totalDHTDownloaded));
        overallMap.put("dht_up", new Long(totalDHTUploaded));
        overallMap.put("p_uploaded", new Long(totalProtocolUploaded));
        overallMap.put("d_uploaded", new Long(totalDataUploaded));
        overallMap.put("p_downloaded", new Long(totalProtocolDownloaded));
        overallMap.put("d_downloaded", new Long(totalDataDownloaded));
        Map map = new HashMap();
        map.put("all", overallMap);
        tick_count++;
        if (force || tick_count % SAVE_TICKS == 0) {
            save(map);
        }
    } finally {
        this_mon.exit();
    }
}
Also used : PluginManager(com.biglybt.pif.PluginManager) DHT(com.biglybt.core.dht.DHT) HashMap(java.util.HashMap) PluginInterface(com.biglybt.pif.PluginInterface) DHTPlugin(com.biglybt.plugin.dht.DHTPlugin) HashMap(java.util.HashMap) Map(java.util.Map) DHTTransportStats(com.biglybt.core.dht.transport.DHTTransportStats)

Aggregations

PluginInterface (com.biglybt.pif.PluginInterface)12 PluginManager (com.biglybt.pif.PluginManager)12 MenuManager (com.biglybt.pif.ui.menus.MenuManager)3 URL (java.net.URL)3 DownloadManager (com.biglybt.core.download.DownloadManager)2 PluginException (com.biglybt.pif.PluginException)2 InstallablePlugin (com.biglybt.pif.installer.InstallablePlugin)2 UIManager (com.biglybt.pif.ui.UIManager)2 MenuItemFillListener (com.biglybt.pif.ui.menus.MenuItemFillListener)2 MenuItemListener (com.biglybt.pif.ui.menus.MenuItemListener)2 Update (com.biglybt.pif.update.Update)2 UpdateCheckInstance (com.biglybt.pif.update.UpdateCheckInstance)2 UpdateCheckInstanceListener (com.biglybt.pif.update.UpdateCheckInstanceListener)2 UpdateManager (com.biglybt.pif.update.UpdateManager)2 PluginUISWTSkinObject (com.biglybt.ui.swt.pif.PluginUISWTSkinObject)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 UnassociatedDevice (com.biglybt.core.devices.DeviceManager.UnassociatedDevice)1 DHT (com.biglybt.core.dht.DHT)1 DHTTransportStats (com.biglybt.core.dht.transport.DHTTransportStats)1