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();
}
}
}
});
}
}
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);
}
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);
}
}
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();
}
}
}
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();
}
}
Aggregations