use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.
the class MyTorrentsSuperView method initialize.
public void initialize(final Composite parent) {
if (form != null) {
return;
}
form = new Composite(parent, SWT.NONE);
FormLayout flayout = new FormLayout();
flayout.marginHeight = 0;
flayout.marginWidth = 0;
form.setLayout(flayout);
GridData gridData;
gridData = new GridData(GridData.FILL_BOTH);
form.setLayoutData(gridData);
GridLayout layout;
child1 = new Composite(form, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 1;
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
child1.setLayout(layout);
final Sash sash = Utils.createSash(form, SASH_WIDTH);
child2 = new Composite(form, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 1;
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
child2.setLayout(layout);
FormData formData;
// More precision, times by 100
int weight = (int) (COConfigurationManager.getFloatParameter("MyTorrents.SplitAt"));
if (weight > 10000) {
weight = 10000;
} else if (weight < 100) {
weight *= 100;
}
// Min/max of 5%/95%
if (weight < 500) {
weight = 500;
} else if (weight > 9000) {
weight = 9000;
}
double pct = (float) weight / 10000;
sash.setData("PCT", new Double(pct));
// FormData for table child1
formData = new FormData();
formData.left = new FormAttachment(0, 0);
formData.right = new FormAttachment(100, 0);
formData.top = new FormAttachment(0, 0);
formData.bottom = new FormAttachment((int) (pct * 100), 0);
child1.setLayoutData(formData);
final FormData child1Data = formData;
// sash
formData = new FormData();
formData.left = new FormAttachment(0, 0);
formData.right = new FormAttachment(100, 0);
formData.top = new FormAttachment(child1);
formData.height = SASH_WIDTH;
sash.setLayoutData(formData);
// child2
formData = new FormData();
formData.left = new FormAttachment(0, 0);
formData.right = new FormAttachment(100, 0);
formData.bottom = new FormAttachment(100, 0);
formData.top = new FormAttachment(sash);
child2.setLayoutData(formData);
// Listeners to size the folder
sash.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final boolean FASTDRAG = true;
if (FASTDRAG && e.detail == SWT.DRAG)
return;
child1Data.height = e.y + e.height - SASH_WIDTH;
form.layout();
Double l = new Double((double) child1.getBounds().height / form.getBounds().height);
sash.setData("PCT", l);
if (e.detail != SWT.DRAG) {
int i = (int) (l.doubleValue() * 10000);
COConfigurationManager.setParameter("MyTorrents.SplitAt", i);
}
}
});
form.addListener(SWT.Resize, new DelayedListenerMultiCombiner() {
@Override
public void handleDelayedEvent(Event e) {
if (sash.isDisposed()) {
return;
}
Double l = (Double) sash.getData("PCT");
if (l == null) {
return;
}
int newHeight = (int) (form.getBounds().height * l.doubleValue());
if (child1Data.height != newHeight || child1Data.bottom != null) {
child1Data.bottom = null;
child1Data.height = newHeight;
form.layout();
}
}
});
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(final Core core) {
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
initializeWithCore(core, parent);
}
});
}
});
}
use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.
the class MyTrackerView method defaultSelected.
// @see TableSelectionListener#defaultSelected(TableRowCore[])
@Override
public void defaultSelected(TableRowCore[] rows, int stateMask) {
final TRHostTorrent torrent = (TRHostTorrent) tv.getFirstSelectedDataSource();
if (torrent == null)
return;
CoreWaiterSWT.waitForCoreRunning(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
DownloadManager dm = core.getGlobalManager().getDownloadManager(torrent.getTorrent());
if (dm != null) {
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null) {
uiFunctions.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_TORRENT_DETAILS, dm);
}
}
}
});
}
use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.
the class TorrentUtils method getTLSTorrent.
public static TOTorrent getTLSTorrent() {
HashWrapper hash = (HashWrapper) (tls.get()).get("hash");
if (hash != null) {
try {
Core core = CoreFactory.getSingleton();
DownloadManager dm = core.getGlobalManager().getDownloadManager(hash);
if (dm != null) {
return (dm.getTorrent());
}
} catch (Throwable e) {
Debug.printStackTrace(e);
}
}
return (null);
}
use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.
the class AENameServiceDescriptor method checkI2PInstall.
private static void checkI2PInstall(final String host_name) {
synchronized (AENameServiceDescriptor.class) {
if (i2p_checked) {
return;
}
try {
Core core = CoreFactory.getSingleton();
if (core != null) {
i2p_checked = true;
PluginInterface pi = core.getPluginManager().getDefaultPluginInterface();
pi.addListener(new PluginAdapter() {
@Override
public void initializationComplete() {
if (I2PHelpers.isI2PInstalled()) {
return;
}
final boolean[] install_outcome = { false };
String enable_i2p_reason = MessageText.getString("azneti2phelper.install.reason.dns", new String[] { host_name });
I2PHelpers.installI2PHelper(enable_i2p_reason, "azneti2phelper.install.dns.resolve", install_outcome, new Runnable() {
@Override
public void run() {
if (!install_outcome[0]) {
}
}
});
}
});
}
} catch (Throwable e) {
}
}
}
use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.
the class VersionCheckClient method main.
public static void main(String[] args) {
try {
COConfigurationManager.initialise();
COConfigurationManager.setParameter("IPV6 Enable Support", true);
boolean v6 = true;
// Test connectivity.
if (true) {
// System.out.println( "UDP: " + getSingleton().getExternalIpAddressUDP(null,0,v6));
// System.out.println( "TCP: " + getSingleton().getExternalIpAddressTCP(null,0,v6));
System.out.println("HTTP: " + getSingleton().getExternalIpAddressHTTP(v6));
}
Map data = constructVersionCheckMessage(VersionCheckClient.REASON_UPDATE_CHECK_START);
System.out.println("Sending (pre-initialisation):");
printDataMap(data);
System.out.println("-----------");
System.out.println("Receiving (pre-initialisation):");
printDataMap(getSingleton().getVersionCheckInfo(VersionCheckClient.REASON_UPDATE_CHECK_START));
System.out.println("-----------");
System.out.println();
System.out.print("Initialising core... ");
/**
* Suppress all of these errors being displayed in the output.
*
* These things should be temporary...
*/
CoreImpl.SUPPRESS_CLASSLOADER_ERRORS = true;
DownloadManagerStateImpl.SUPPRESS_FIXUP_ERRORS = true;
Core core = CoreFactory.create();
core.start();
System.out.println("done.");
System.out.println();
System.out.println("-----------");
data = constructVersionCheckMessage(VersionCheckClient.REASON_UPDATE_CHECK_START);
System.out.println("Sending (post-initialisation):");
printDataMap(data);
System.out.println("-----------");
System.out.println("Receiving (post-initialisation):");
printDataMap(getSingleton().getVersionCheckInfo(VersionCheckClient.REASON_UPDATE_CHECK_START));
System.out.println("-----------");
System.out.println();
System.out.print("Shutting down core... ");
core.stop();
System.out.println("done.");
} catch (Throwable e) {
e.printStackTrace();
}
}
Aggregations