Search in sources :

Example 1 with DownloadImpl

use of com.biglybt.pifimpl.local.download.DownloadImpl in project BiglyBT by BiglySoftware.

the class PluginCoreUtils method convert.

public static Object convert(Object datasource, boolean toCore) {
    if (datasource instanceof Object[]) {
        Object[] array = (Object[]) datasource;
        Object[] newArray = new Object[array.length];
        for (int i = 0; i < array.length; i++) {
            Object o = array[i];
            newArray[i] = convert(o, toCore);
        }
        return newArray;
    }
    try {
        if (toCore) {
            if (datasource instanceof com.biglybt.core.download.DownloadManager) {
                return datasource;
            }
            if (datasource instanceof DownloadImpl) {
                return ((DownloadImpl) datasource).getDownload();
            }
            if (datasource instanceof com.biglybt.core.disk.DiskManager) {
                return datasource;
            }
            if (datasource instanceof DiskManagerImpl) {
                return ((DiskManagerImpl) datasource).getDiskmanager();
            }
            if (datasource instanceof PEPeerManager) {
                return datasource;
            }
            if (datasource instanceof PeerManagerImpl) {
                return ((PeerManagerImpl) datasource).getDelegate();
            }
            if (datasource instanceof PEPeer) {
                return datasource;
            }
            if (datasource instanceof PeerImpl) {
                return ((PeerImpl) datasource).getPEPeer();
            }
            if (datasource instanceof com.biglybt.core.disk.DiskManagerFileInfo) {
                return datasource;
            }
            if (datasource instanceof com.biglybt.pifimpl.local.disk.DiskManagerFileInfoImpl) {
                return ((com.biglybt.pifimpl.local.disk.DiskManagerFileInfoImpl) datasource).getCore();
            }
            if (datasource instanceof TRHostTorrent) {
                return datasource;
            }
            if (datasource instanceof TrackerTorrentImpl) {
                ((TrackerTorrentImpl) datasource).getHostTorrent();
            }
        } else {
            // to PI
            if (datasource instanceof com.biglybt.core.download.DownloadManager) {
                return wrap((com.biglybt.core.download.DownloadManager) datasource);
            }
            if (datasource instanceof DownloadImpl) {
                return datasource;
            }
            if (datasource instanceof com.biglybt.core.disk.DiskManager) {
                return wrap((com.biglybt.core.disk.DiskManager) datasource);
            }
            if (datasource instanceof DiskManagerImpl) {
                return datasource;
            }
            if (datasource instanceof PEPeerManager) {
                return wrap((PEPeerManager) datasource);
            }
            if (datasource instanceof PeerManagerImpl) {
                return datasource;
            }
            if (datasource instanceof PEPeer) {
                return PeerManagerImpl.getPeerForPEPeer((PEPeer) datasource);
            }
            if (datasource instanceof Peer) {
                return datasource;
            }
            if (datasource instanceof com.biglybt.core.disk.DiskManagerFileInfo) {
                DiskManagerFileInfo fileInfo = (com.biglybt.core.disk.DiskManagerFileInfo) datasource;
                if (fileInfo != null) {
                    try {
                        DownloadManager dm = fileInfo.getDownloadManager();
                        return new com.biglybt.pifimpl.local.disk.DiskManagerFileInfoImpl(dm == null ? null : DownloadManagerImpl.getDownloadStatic(dm), fileInfo);
                    } catch (DownloadException e) {
                    /* Ignore */
                    }
                }
            }
            if (datasource instanceof com.biglybt.pifimpl.local.disk.DiskManagerFileInfoImpl) {
                return datasource;
            }
            if (datasource instanceof TRHostTorrent) {
                TRHostTorrent item = (TRHostTorrent) datasource;
                return new TrackerTorrentImpl(item);
            }
            if (datasource instanceof TrackerTorrentImpl) {
                return datasource;
            }
        }
    } catch (Throwable t) {
        Debug.out(t);
    }
    return datasource;
}
Also used : PEPeer(com.biglybt.core.peer.PEPeer) DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) DiskManagerImpl(com.biglybt.pifimpl.local.disk.DiskManagerImpl) PEPeer(com.biglybt.core.peer.PEPeer) Peer(com.biglybt.pif.peers.Peer) DownloadImpl(com.biglybt.pifimpl.local.download.DownloadImpl) DiskManager(com.biglybt.pif.disk.DiskManager) TRHostTorrent(com.biglybt.core.tracker.host.TRHostTorrent) TrackerTorrentImpl(com.biglybt.pifimpl.local.tracker.TrackerTorrentImpl) DownloadManager(com.biglybt.core.download.DownloadManager) DiskManagerFileInfoImpl(com.biglybt.pifimpl.local.disk.DiskManagerFileInfoImpl) PeerManagerImpl(com.biglybt.pifimpl.local.peers.PeerManagerImpl) PeerImpl(com.biglybt.pifimpl.local.peers.PeerImpl) DownloadException(com.biglybt.pif.download.DownloadException) PEPeerManager(com.biglybt.core.peer.PEPeerManager)

Example 2 with DownloadImpl

use of com.biglybt.pifimpl.local.download.DownloadImpl in project BiglyBT by BiglySoftware.

the class UISWTInstanceImpl method showDownloadBar.

@Override
public void showDownloadBar(Download download, final boolean display) {
    if (!(download instanceof DownloadImpl)) {
        return;
    }
    final DownloadManager dm = ((DownloadImpl) download).getDownload();
    // Not expecting this, but just in case...
    if (dm == null) {
        return;
    }
    Utils.execSWTThread(new AERunnable() {

        @Override
        public void runSupport() {
            if (display) {
                DownloadBar.open(dm, getDisplay().getActiveShell());
            } else {
                DownloadBar.close(dm);
            }
        }
    }, false);
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) DownloadImpl(com.biglybt.pifimpl.local.download.DownloadImpl) DownloadManager(com.biglybt.core.download.DownloadManager)

Aggregations

DownloadManager (com.biglybt.core.download.DownloadManager)2 DownloadImpl (com.biglybt.pifimpl.local.download.DownloadImpl)2 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)1 PEPeer (com.biglybt.core.peer.PEPeer)1 PEPeerManager (com.biglybt.core.peer.PEPeerManager)1 TRHostTorrent (com.biglybt.core.tracker.host.TRHostTorrent)1 AERunnable (com.biglybt.core.util.AERunnable)1 DiskManager (com.biglybt.pif.disk.DiskManager)1 DownloadException (com.biglybt.pif.download.DownloadException)1 Peer (com.biglybt.pif.peers.Peer)1 DiskManagerFileInfoImpl (com.biglybt.pifimpl.local.disk.DiskManagerFileInfoImpl)1 DiskManagerImpl (com.biglybt.pifimpl.local.disk.DiskManagerImpl)1 PeerImpl (com.biglybt.pifimpl.local.peers.PeerImpl)1 PeerManagerImpl (com.biglybt.pifimpl.local.peers.PeerManagerImpl)1 TrackerTorrentImpl (com.biglybt.pifimpl.local.tracker.TrackerTorrentImpl)1