Search in sources :

Example 66 with PEPeer

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

the class OptimisticUnchokeItem method refresh.

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

Example 67 with PEPeer

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

the class OutgoingRequestCountItem method refresh.

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

Example 68 with PEPeer

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

the class PeerIDItem method refresh.

@Override
public void refresh(TableCell cell) {
    PEPeer peer = (PEPeer) cell.getDataSource();
    if (peer == null) {
        cell.setText("");
        return;
    }
    byte[] peer_id = peer.getId();
    if (peer_id == null) {
        cell.setText("");
        return;
    }
    try {
        String text = new String(peer_id, 0, peer_id.length, Constants.BYTE_ENCODING);
        // Replace newlines.
        text = text.replace((char) 12, (char) 32);
        text = text.replace((char) 10, (char) 32);
        cell.setText(text);
    } catch (java.io.UnsupportedEncodingException uee) {
        cell.setText("");
    }
}
Also used : PEPeer(com.biglybt.core.peer.PEPeer)

Example 69 with PEPeer

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

the class PercentItem method refresh.

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

Example 70 with PEPeer

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

the class ASItem method refresh.

@Override
public void refresh(TableCell cell) {
    final PEPeer peer = (PEPeer) cell.getDataSource();
    String text = "";
    if (peer != null) {
        text = (String) peer.getUserData(ASItem.class);
        if (text == null) {
            text = "";
            peer.setUserData(ASItem.class, text);
            String peer_ip = peer.getIp();
            if (AENetworkClassifier.categoriseAddress(peer_ip) == AENetworkClassifier.AT_PUBLIC) {
                try {
                    NetworkAdmin.getSingleton().lookupASN(InetAddress.getByName(peer_ip), new NetworkAdminASNListener() {

                        @Override
                        public void success(NetworkAdminASN asn) {
                            peer.setUserData(ASItem.class, asn.getAS() + " - " + asn.getASName());
                        }

                        @Override
                        public void failed(NetworkAdminException error) {
                        }
                    });
                } catch (Throwable e) {
                }
            }
        }
    }
    if (!cell.setSortValue(text) && cell.isValid()) {
        return;
    }
    cell.setText(text);
}
Also used : PEPeer(com.biglybt.core.peer.PEPeer)

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