use of com.biglybt.core.tracker.host.TRHostTorrent in project BiglyBT by BiglySoftware.
the class MyTrackerView method tableRefresh.
// @see TableRefreshListener#tableRefresh()
@Override
public void tableRefresh() {
if (getComposite() == null || getComposite().isDisposed()) {
return;
}
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null) {
uiFunctions.refreshIconBar();
}
// Store values for columns that are calculate from peer information, so
// that we only have to do one loop. (As opposed to each cell doing a loop)
// Calculate code copied from TrackerTableItem
TableRowCore[] rows = tv.getRows();
for (int x = 0; x < rows.length; x++) {
TableRowSWT row = (TableRowSWT) rows[x];
if (row == null) {
continue;
}
TRHostTorrent host_torrent = (TRHostTorrent) rows[x].getDataSource(true);
if (host_torrent == null) {
continue;
}
long uploaded = host_torrent.getTotalUploaded();
long downloaded = host_torrent.getTotalDownloaded();
long left = host_torrent.getTotalLeft();
int seed_count = host_torrent.getSeedCount();
host_torrent.setData("GUI_PeerCount", new Long(host_torrent.getLeecherCount()));
host_torrent.setData("GUI_SeedCount", new Long(seed_count));
host_torrent.setData("GUI_BadNATCount", new Long(host_torrent.getBadNATCount()));
host_torrent.setData("GUI_Uploaded", new Long(uploaded));
host_torrent.setData("GUI_Downloaded", new Long(downloaded));
host_torrent.setData("GUI_Left", new Long(left));
if (seed_count != 0) {
Color fg = row.getForeground();
if (fg != null && fg.equals(Colors.blues[Colors.BLUES_MIDDARK])) {
row.setForeground(Colors.blues[Colors.BLUES_MIDDARK]);
}
}
}
}
use of com.biglybt.core.tracker.host.TRHostTorrent in project BiglyBT by BiglySoftware.
the class MyTrackerView method refreshToolBarItems.
@Override
public void refreshToolBarItems(Map<String, Long> list) {
boolean start = false, stop = false, remove = false;
Object[] hostTorrents = tv.getSelectedDataSources().toArray();
if (hostTorrents.length > 0) {
remove = true;
for (int i = 0; i < hostTorrents.length; i++) {
TRHostTorrent host_torrent = (TRHostTorrent) hostTorrents[i];
int status = host_torrent.getStatus();
if (status == TRHostTorrent.TS_STOPPED) {
start = true;
}
if (status == TRHostTorrent.TS_STARTED) {
stop = true;
}
/*
try{
host_torrent.canBeRemoved();
}catch( TRHostTorrentRemovalVetoException f ){
remove = false;
}
*/
}
}
list.put("start", start ? UIToolBarItem.STATE_ENABLED : 0);
list.put("stop", stop ? UIToolBarItem.STATE_ENABLED : 0);
list.put("remove", remove ? UIToolBarItem.STATE_ENABLED : 0);
}
use of com.biglybt.core.tracker.host.TRHostTorrent in project BiglyBT by BiglySoftware.
the class GlobalManagerHostSupport method torrentRemoved.
protected void torrentRemoved(String torrent_file_str, TOTorrent torrent) {
TRHostTorrent host_torrent = host.getHostTorrent(torrent);
if (host_torrent != null) {
// it we remove a torrent while it is hosted then we flip it into passive mode to
// keep it around in a sensible state
// we've got to ensure that the torrent's file location is available in the torrent itself
// as we're moving from download-managed persistence to host managed :(
// check file already exists - might have already been deleted as in the
// case of shared resources
File torrent_file = new File(torrent_file_str);
if (torrent_file.exists()) {
try {
TorrentUtils.writeToFile(host_torrent.getTorrent(), torrent_file, false);
host_torrent.setPassive(true);
} catch (Throwable e) {
Debug.out("Failed to make torrent '" + torrent_file_str + "' passive: " + Debug.getNestedExceptionMessage(e));
}
}
}
}
use of com.biglybt.core.tracker.host.TRHostTorrent in project BiglyBT by BiglySoftware.
the class PersistentItem method refresh.
@Override
public void refresh(TableCell cell) {
TRHostTorrent item = (TRHostTorrent) cell.getDataSource();
String status_text = "";
if (item != null) {
if (!cell.setSortValue(item.isPassive() ? 1 : 0) && cell.isValid()) {
return;
}
if (item.isPersistent()) {
status_text = MessageText.getString("Button.yes").replaceAll("&", "");
} else {
status_text = MessageText.getString("Button.no").replaceAll("&", "");
}
}
cell.setText(status_text);
}
use of com.biglybt.core.tracker.host.TRHostTorrent in project BiglyBT by BiglySoftware.
the class NameItem method getObfuscatedText.
@Override
public String getObfuscatedText(TableCell cell) {
TRHostTorrent item = (TRHostTorrent) cell.getDataSource();
String name = null;
try {
name = ByteFormatter.nicePrint(item.getTorrent().getHash(), true);
} catch (Throwable e) {
}
if (name == null)
name = "";
return name;
}
Aggregations