Search in sources :

Example 36 with Core

use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.

the class ActivitiesManager method _initialize.

static void _initialize(Core core) {
    if (diag_logger != null) {
        diag_logger.log("Initialize Called");
    }
    core.addLifecycleListener(new CoreLifecycleAdapter() {

        @Override
        public void stopping(Core core) {
            if (saveEventsOnClose) {
                saveEventsNow();
            }
        }
    });
    loadEvents();
    replyListener = new PlatformVuzeActivitiesMessenger.GetEntriesReplyListener() {

        @Override
        public void gotVuzeNewsEntries(ActivitiesEntry[] entries, long refreshInMS) {
            if (diag_logger != null) {
                diag_logger.log("Received Reply from platform with " + entries.length + " entries.  Refresh in " + refreshInMS);
            }
            addEntries(entries);
            if (refreshInMS <= 0) {
                refreshInMS = DEFAULT_PLATFORM_REFRESH;
            }
            SimpleTimer.addEvent("GetVuzeNews", SystemTime.getOffsetTime(refreshInMS), new TimerEventPerformer() {

                @Override
                public void perform(TimerEvent event) {
                    pullActivitiesNow(5000, "timer", false);
                }
            });
        }
    };
    pullActivitiesNow(5000, "initial", false);
}
Also used : CoreLifecycleAdapter(com.biglybt.core.CoreLifecycleAdapter) PlatformVuzeActivitiesMessenger(com.biglybt.core.messenger.config.PlatformVuzeActivitiesMessenger) Core(com.biglybt.core.Core)

Example 37 with Core

use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.

the class DeviceManagerImpl method ensureInitialised.

private TranscodeManager ensureInitialised(boolean partial) {
    Core core = CoreFactory.getSingleton();
    if (core.isStarted()) {
        initWithCore(core);
    } else if (core.isInitThread()) {
        Debug.out("This is bad");
        initWithCore(core);
    }
    if (partial) {
        long start = SystemTime.getMonotonousTime();
        while (!init_sem.reserve(250)) {
            if (transcode_manager != null) {
                break;
            }
            if (SystemTime.getMonotonousTime() - start >= 30 * 1000) {
                Debug.out("Timeout waiting for init");
                AEDiagnostics.dumpThreads();
                break;
            }
        }
    } else {
        if (!init_sem.reserve(30 * 1000)) {
            Debug.out("Timeout waiting for init");
            AEDiagnostics.dumpThreads();
        }
    }
    return (transcode_manager);
}
Also used : Core(com.biglybt.core.Core)

Example 38 with Core

use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.

the class NetworkAdminImpl method generateDiagnostics.

@Override
public void generateDiagnostics(final IndentWriter iw) {
    Set public_addresses = new HashSet();
    NetworkAdminHTTPProxy proxy = getHTTPProxy();
    if (proxy == null) {
        iw.println("HTTP proxy: none");
    } else {
        iw.println("HTTP proxy: " + proxy.getName());
        try {
            NetworkAdminHTTPProxy.Details details = proxy.getDetails();
            iw.println("    name: " + details.getServerName());
            iw.println("    resp: " + details.getResponse());
            iw.println("    auth: " + details.getAuthenticationType());
        } catch (NetworkAdminException e) {
            iw.println("    failed: " + e.getLocalizedMessage());
        }
    }
    NetworkAdminSocksProxy[] socks = getSocksProxies();
    if (socks.length == 0) {
        iw.println("Socks proxy: none");
    } else {
        for (int i = 0; i < socks.length; i++) {
            NetworkAdminSocksProxy sock = socks[i];
            iw.println("Socks proxy: " + sock.getName());
            try {
                String[] versions = sock.getVersionsSupported();
                String str = "";
                for (int j = 0; j < versions.length; j++) {
                    str += (j == 0 ? "" : ",") + versions[j];
                }
                iw.println("   version: " + str);
            } catch (NetworkAdminException e) {
                iw.println("    failed: " + e.getLocalizedMessage());
            }
        }
    }
    try {
        NetworkAdminNATDevice[] nat_devices = getNATDevices(CoreFactory.getSingleton());
        iw.println("NAT Devices: " + nat_devices.length);
        for (int i = 0; i < nat_devices.length; i++) {
            NetworkAdminNATDevice device = nat_devices[i];
            iw.println("    " + device.getName() + ",address=" + device.getAddress().getHostAddress() + ":" + device.getPort() + ",ext=" + device.getExternalAddress());
            public_addresses.add(device.getExternalAddress());
        }
    } catch (Exception e) {
        iw.println("Nat Devices: Can't get -> " + e.toString());
    }
    iw.println("Interfaces");
    NetworkAdminNetworkInterface[] interfaces = getInterfaces();
    if (FULL_INTF_PROBE) {
        if (interfaces.length > 0) {
            if (interfaces.length > 1 || interfaces[0].getAddresses().length > 1) {
                for (int i = 0; i < interfaces.length; i++) {
                    networkInterface interf = (networkInterface) interfaces[i];
                    iw.indent();
                    try {
                        interf.generateDiagnostics(iw, public_addresses);
                    } finally {
                        iw.exdent();
                    }
                }
            } else {
                if (interfaces[0].getAddresses().length > 0) {
                    networkInterface.networkAddress address = (networkInterface.networkAddress) interfaces[0].getAddresses()[0];
                    try {
                        NetworkAdminNode[] nodes = address.getRoute(InetAddress.getByName("www.google.com"), 30000, trace_route_listener);
                        for (int i = 0; i < nodes.length; i++) {
                            networkNode node = (networkNode) nodes[i];
                            iw.println(node.getString());
                        }
                    } catch (Throwable e) {
                        iw.println("Can't resolve host for route trace - " + e.getMessage());
                    }
                }
            }
        }
    } else {
        try {
            pingTargets(InetAddress.getByName("www.google.com"), 30000, new NetworkAdminRoutesListener() {

                private int timeouts = 0;

                @Override
                public boolean foundNode(NetworkAdminNetworkInterfaceAddress intf, NetworkAdminNode[] route, int distance, int rtt) {
                    iw.println(intf.getAddress().getHostAddress() + ": " + route[route.length - 1].getAddress().getHostAddress() + " (" + distance + ")");
                    return (false);
                }

                @Override
                public boolean timeout(NetworkAdminNetworkInterfaceAddress intf, NetworkAdminNode[] route, int distance) {
                    iw.println(intf.getAddress().getHostAddress() + ": timeout (dist=" + distance + ")");
                    timeouts++;
                    return (timeouts < 3);
                }
            });
        } catch (Throwable e) {
            iw.println("getRoutes failed: " + Debug.getNestedExceptionMessage(e));
        }
    }
    iw.println("Inbound protocols: default routing");
    if (CoreFactory.isCoreRunning()) {
        Core core = CoreFactory.getSingleton();
        NetworkAdminProtocol[] protocols = getInboundProtocols(core);
        for (int i = 0; i < protocols.length; i++) {
            NetworkAdminProtocol protocol = protocols[i];
            try {
                InetAddress ext_addr = testProtocol(protocol);
                if (ext_addr != null) {
                    public_addresses.add(ext_addr);
                }
                iw.println("    " + protocol.getName() + " - " + ext_addr);
            } catch (NetworkAdminException e) {
                iw.println("    " + protocol.getName() + " - " + Debug.getNestedExceptionMessage(e));
            }
        }
        iw.println("Outbound protocols: default routing");
        protocols = getOutboundProtocols(core);
        for (int i = 0; i < protocols.length; i++) {
            NetworkAdminProtocol protocol = protocols[i];
            try {
                InetAddress ext_addr = testProtocol(protocol);
                if (ext_addr != null) {
                    public_addresses.add(ext_addr);
                }
                iw.println("    " + protocol.getName() + " - " + ext_addr);
            } catch (NetworkAdminException e) {
                iw.println("    " + protocol.getName() + " - " + Debug.getNestedExceptionMessage(e));
            }
        }
    }
    Iterator it = public_addresses.iterator();
    iw.println("Public Addresses");
    while (it.hasNext()) {
        InetAddress pub_address = (InetAddress) it.next();
        try {
            NetworkAdminASN res = lookupCurrentASN(pub_address);
            iw.println("    " + pub_address.getHostAddress() + " -> " + res.getAS() + "/" + res.getASName());
        } catch (Throwable e) {
            iw.println("    " + pub_address.getHostAddress() + " -> " + Debug.getNestedExceptionMessage(e));
        }
    }
}
Also used : Core(com.biglybt.core.Core) PlatformManagerException(com.biglybt.pif.platform.PlatformManagerException) UnsupportedAddressTypeException(java.nio.channels.UnsupportedAddressTypeException) IOException(java.io.IOException)

Example 39 with Core

use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.

the class TagPropertyConstraintHandler method checkTimer.

private void checkTimer() {
    if (constrained_tags.size() > 0) {
        if (timer == null) {
            timer = SimpleTimer.addPeriodicEvent("tag:constraint:timer", 30 * 1000, new TimerEventPerformer() {

                @Override
                public void perform(TimerEvent event) {
                    apply_history.clear();
                    apply();
                }
            });
            CoreFactory.addCoreRunningListener(new CoreRunningListener() {

                @Override
                public void coreRunning(Core core) {
                    synchronized (constrained_tags) {
                        if (timer != null) {
                            core.getPluginManager().getDefaultPluginInterface().getDownloadManager().getGlobalDownloadEventNotifier().addListener(TagPropertyConstraintHandler.this);
                            dm_listener_added = true;
                        }
                    }
                }
            });
        }
    } else if (timer != null) {
        timer.cancel();
        timer = null;
        if (dm_listener_added) {
            core.getPluginManager().getDefaultPluginInterface().getDownloadManager().getGlobalDownloadEventNotifier().removeListener(this);
        }
        apply_history.clear();
    }
}
Also used : CoreRunningListener(com.biglybt.core.CoreRunningListener) Core(com.biglybt.core.Core)

Example 40 with Core

use of com.biglybt.core.Core in project BiglyBT by BiglySoftware.

the class PlatformTorrentUtils method writeTorrentIfExists.

private static void writeTorrentIfExists(TOTorrent torrent) {
    if (!CoreFactory.isCoreRunning()) {
        return;
    }
    Core core = CoreFactory.getSingleton();
    if (core == null || !core.isStarted()) {
        return;
    }
    GlobalManager gm = core.getGlobalManager();
    if (gm == null || gm.getDownloadManager(torrent) == null) {
        return;
    }
    try {
        TorrentUtils.writeToFile(torrent);
    } catch (TOTorrentException e) {
        Debug.out(e);
    }
}
Also used : GlobalManager(com.biglybt.core.global.GlobalManager) 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