Search in sources :

Example 21 with PEPeer

use of com.biglybt.core.peer.PEPeer in project BiglyBT by BiglySoftware.

the class PieceItem method refresh.

@Override
public void refresh(TableCell cell) {
    PEPeer peer = (PEPeer) cell.getDataSource();
    int value = (peer == null) ? 0 : peer.getLastPiece();
    if (!cell.setSortValue(value) && cell.isValid())
        return;
    cell.setText("" + value);
}
Also used : PEPeer(com.biglybt.core.peer.PEPeer)

Example 22 with PEPeer

use of com.biglybt.core.peer.PEPeer in project BiglyBT by BiglySoftware.

the class UpDownRatioItem method refresh.

@Override
public void refresh(TableCell cell) {
    PEPeer peer = (PEPeer) cell.getDataSource();
    float value = 0;
    long lDivisor = 0;
    long lDivident = 0;
    if (peer != null) {
        lDivisor = peer.getStats().getTotalDataBytesReceived() - peer.getStats().getTotalBytesDiscarded();
        lDivident = peer.getStats().getTotalDataBytesSent();
        // skip if divisor is small (most likely handshake) or 0 (DivisionByZero)
        if (lDivisor > 1024) {
            value = lDivident / (float) lDivisor;
            if (value == 0)
                value = -1;
        } else if (lDivident > 0)
            value = Float.MAX_VALUE;
    }
    if (!cell.setSortValue((long) (value * 1000.0d)) && cell.isValid())
        return;
    String s;
    if (lDivisor <= 0)
        s = "";
    else if (value == Float.MAX_VALUE)
        s = Constants.INFINITY_STRING + ":1";
    else if (value == -1)
        s = "1:" + Constants.INFINITY_STRING;
    else
        s = DisplayFormatters.formatDecimal(value, 2) + ":1";
    cell.setText(s);
}
Also used : PEPeer(com.biglybt.core.peer.PEPeer)

Example 23 with PEPeer

use of com.biglybt.core.peer.PEPeer in project BiglyBT by BiglySoftware.

the class UpItem method refresh.

@Override
public void refresh(TableCell cell) {
    PEPeer peer = (PEPeer) cell.getDataSource();
    long data_value = 0;
    long prot_value = 0;
    if (peer != null) {
        data_value = peer.getStats().getTotalDataBytesSent();
        prot_value = peer.getStats().getTotalProtocolBytesSent();
    }
    long sort_value;
    if (separate_prot_data_stats) {
        sort_value = (data_value << 24) + prot_value;
    } else if (data_stats_only) {
        sort_value = data_value;
    } else {
        sort_value = data_value + prot_value;
    }
    if (!cell.setSortValue(sort_value) && cell.isValid())
        return;
    cell.setText(DisplayFormatters.formatDataProtByteCountToKiBEtc(data_value, prot_value));
}
Also used : PEPeer(com.biglybt.core.peer.PEPeer)

Example 24 with PEPeer

use of com.biglybt.core.peer.PEPeer in project BiglyBT by BiglySoftware.

the class UpSpeedLimitItem method refresh.

@Override
public void refresh(TableCell cell) {
    PEPeer peer = (PEPeer) cell.getDataSource();
    long value = (peer == null) ? 0 : peer.getUploadRateLimitBytesPerSecond();
    if (!cell.setSortValue(value) && cell.isValid())
        return;
    if (value == -1) {
        cell.setText(MessageText.getString("MyTorrents.items.UpSpeedLimit.disabled"));
    } else if (value == 0) {
        cell.setText(Constants.INFINITY_STRING);
    } else {
        cell.setText(DisplayFormatters.formatByteCountToKiBEtcPerSec(value));
    }
}
Also used : PEPeer(com.biglybt.core.peer.PEPeer)

Example 25 with PEPeer

use of com.biglybt.core.peer.PEPeer in project BiglyBT by BiglySoftware.

the class DownloadManagerImpl method addPeerListener.

@Override
public void addPeerListener(DownloadManagerPeerListener listener, boolean bDispatchForExisting) {
    try {
        peer_listeners_mon.enter();
        peer_listeners.addListener(listener);
        if (!bDispatchForExisting) {
            // finally will call
            return;
        }
        for (PEPeer peer : current_peers.keySet()) {
            peer_listeners.dispatch(listener, LDT_PE_PEER_ADDED, peer);
        }
        PEPeerManager temp = controller.getPeerManager();
        if (temp != null) {
            peer_listeners.dispatch(listener, LDT_PE_PM_ADDED, temp);
        }
    } finally {
        peer_listeners_mon.exit();
    }
}
Also used : PEPeer(com.biglybt.core.peer.PEPeer) PEPeerManager(com.biglybt.core.peer.PEPeerManager)

Aggregations

PEPeer (com.biglybt.core.peer.PEPeer)84 PEPeerManager (com.biglybt.core.peer.PEPeerManager)18 DownloadManager (com.biglybt.core.download.DownloadManager)11 ArrayList (java.util.ArrayList)11 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)5 AERunnable (com.biglybt.core.util.AERunnable)5 PEPiece (com.biglybt.core.peer.PEPiece)4 List (java.util.List)4 Image (org.eclipse.swt.graphics.Image)4 DiskManager (com.biglybt.core.disk.DiskManager)3 GlobalManager (com.biglybt.core.global.GlobalManager)3 PEPeerStats (com.biglybt.core.peer.PEPeerStats)3 PEPeerTransport (com.biglybt.core.peer.impl.PEPeerTransport)3 TOTorrent (com.biglybt.core.torrent.TOTorrent)3 Point (org.eclipse.swt.graphics.Point)3 DiskManagerPiece (com.biglybt.core.disk.DiskManagerPiece)2 DownloadManagerPeerListener (com.biglybt.core.download.DownloadManagerPeerListener)2 PiecePicker (com.biglybt.core.peermanager.piecepicker.PiecePicker)2 BitFlags (com.biglybt.core.peermanager.piecepicker.util.BitFlags)2 Tag (com.biglybt.core.tag.Tag)2