Search in sources :

Example 51 with Core

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);
                }
            });
        }
    });
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DelayedListenerMultiCombiner(com.biglybt.ui.swt.DelayedListenerMultiCombiner) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CoreRunningListener(com.biglybt.core.CoreRunningListener) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Core(com.biglybt.core.Core) TableColumnCore(com.biglybt.ui.common.table.TableColumnCore)

Example 52 with Core

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);
                }
            }
        }
    });
}
Also used : UIFunctions(com.biglybt.ui.UIFunctions) CoreRunningListener(com.biglybt.core.CoreRunningListener) TRHostTorrent(com.biglybt.core.tracker.host.TRHostTorrent) DownloadManager(com.biglybt.core.download.DownloadManager) Core(com.biglybt.core.Core)

Example 53 with Core

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);
}
Also used : DownloadManager(com.biglybt.core.download.DownloadManager) Core(com.biglybt.core.Core)

Example 54 with Core

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) {
        }
    }
}
Also used : PluginAdapter(com.biglybt.pif.PluginAdapter) PluginInterface(com.biglybt.pif.PluginInterface) Core(com.biglybt.core.Core)

Example 55 with Core

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();
    }
}
Also used : Core(com.biglybt.core.Core)

Aggregations

Core (com.biglybt.core.Core)71 CoreRunningListener (com.biglybt.core.CoreRunningListener)37 DownloadManager (com.biglybt.core.download.DownloadManager)17 CoreLifecycleAdapter (com.biglybt.core.CoreLifecycleAdapter)12 GlobalManager (com.biglybt.core.global.GlobalManager)10 File (java.io.File)9 GridLayout (org.eclipse.swt.layout.GridLayout)8 UIFunctions (com.biglybt.ui.UIFunctions)6 Composite (org.eclipse.swt.widgets.Composite)6 ParameterListener (com.biglybt.core.config.ParameterListener)5 LogAlert (com.biglybt.core.logging.LogAlert)5 TOTorrent (com.biglybt.core.torrent.TOTorrent)5 AERunnable (com.biglybt.core.util.AERunnable)5 GridData (org.eclipse.swt.layout.GridData)5 DownloadManagerInitialisationAdapter (com.biglybt.core.download.DownloadManagerInitialisationAdapter)4 PluginInterface (com.biglybt.pif.PluginInterface)4 TableColumnCore (com.biglybt.ui.common.table.TableColumnCore)4 ArrayList (java.util.ArrayList)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 MessageText (com.biglybt.core.internat.MessageText)3