use of com.biglybt.core.tracker.host.TRHostTorrent in project BiglyBT by BiglySoftware.
the class HealthItem method refresh.
@Override
public void refresh(TableCell cell) {
if (tracker_host == null) {
try {
tracker_host = CoreFactory.getSingleton().getTrackerHost();
} catch (Throwable t) {
}
if (tracker_host == null) {
return;
}
}
DownloadManager dm = (DownloadManager) cell.getDataSource();
int health;
TRHostTorrent ht;
if (dm == null) {
health = 0;
ht = null;
} else {
health = dm.getHealthStatus();
ht = tracker_host.getHostTorrent(dm.getTorrent());
}
if (!cell.setSortValue(health + (ht == null ? 0 : 256)) && cell.isValid())
return;
String sHelpID = null;
if (health == DownloadManager.WEALTH_KO) {
sHelpID = "health.explain.red";
} else if (health == DownloadManager.WEALTH_OK) {
sHelpID = "health.explain.green";
} else if (health == DownloadManager.WEALTH_NO_TRACKER) {
sHelpID = "health.explain.blue";
} else if (health == DownloadManager.WEALTH_NO_REMOTE) {
sHelpID = "health.explain.yellow";
} else if (health == DownloadManager.WEALTH_ERROR) {
} else {
sHelpID = "health.explain.grey";
}
String sToolTip = (health == DownloadManager.WEALTH_ERROR && dm != null) ? dm.getErrorDetails() : MessageText.getString(sHelpID);
if (ht != null)
sToolTip += "\n" + MessageText.getString("health.explain.share");
cell.setToolTip(sToolTip);
}
use of com.biglybt.core.tracker.host.TRHostTorrent in project BiglyBT by BiglySoftware.
the class BadNATCountItem method refresh.
@Override
public void refresh(TableCell cell) {
TRHostTorrent item = (TRHostTorrent) cell.getDataSource();
long value = 0;
if (item != null) {
Long longObject = (Long) item.getData("GUI_BadNATCount");
if (longObject != null)
value = longObject.longValue();
}
if (!cell.setSortValue(value) && cell.isValid()) {
return;
}
cell.setText("" + value);
}
use of com.biglybt.core.tracker.host.TRHostTorrent in project BiglyBT by BiglySoftware.
the class CategoryItem method refresh.
@Override
public void refresh(TableCell cell) {
TRHostTorrent tr_torrent = (TRHostTorrent) cell.getDataSource();
if (tr_torrent == null) {
cell.setText("");
} else {
TOTorrent torrent = tr_torrent.getTorrent();
if (gm == null) {
if (CoreFactory.isCoreRunning()) {
return;
}
gm = CoreFactory.getSingleton().getGlobalManager();
}
DownloadManager dm = gm.getDownloadManager(torrent);
String cat_str = null;
if (dm != null) {
Category cat = dm.getDownloadState().getCategory();
if (cat != null) {
cat_str = cat.getName();
}
} else {
// pick up specific torrent category, bit 'o' a hack tis
cat_str = TorrentUtils.getPluginStringProperty(torrent, "azcoreplugins.category");
}
cell.setText(cat_str == null ? "" : cat_str);
}
}
use of com.biglybt.core.tracker.host.TRHostTorrent in project BiglyBT by BiglySoftware.
the class NameItem method refresh.
@Override
public void refresh(TableCell cell) {
TRHostTorrent item = (TRHostTorrent) cell.getDataSource();
String name = (item == null) ? "" : TorrentUtils.getLocalisedName(item.getTorrent());
if (cell.setText(name) || !cell.isValid()) {
if (item != null && item.getTorrent() != null && bShowIcon && (cell instanceof TableCellSWT)) {
try {
final TOTorrent torrent = item.getTorrent();
final String path = torrent.getFiles()[0].getRelativePath();
if (path != null) {
Image icon = null;
final TableCellSWT _cell = (TableCellSWT) cell;
if (Utils.isSWTThread()) {
icon = ImageRepository.getPathIcon(path, false, !torrent.isSimpleTorrent());
} else {
// happens rarely (seen of filtering of file-view rows
// when a new row is added )
Utils.execSWTThread(new Runnable() {
@Override
public void run() {
Image icon = ImageRepository.getPathIcon(path, false, !torrent.isSimpleTorrent());
_cell.setIcon(icon);
_cell.redraw();
}
});
}
if (icon != null) {
_cell.setIcon(icon);
}
}
} catch (Exception e) {
}
}
}
}
use of com.biglybt.core.tracker.host.TRHostTorrent in project BiglyBT by BiglySoftware.
the class TrackerWebPageResponseImpl method writeTorrent.
@Override
public void writeTorrent(TrackerTorrent tracker_torrent) throws IOException {
try {
TRHostTorrent host_torrent = ((TrackerTorrentImpl) tracker_torrent).getHostTorrent();
TOTorrent torrent = host_torrent.getTorrent();
// make a copy of the torrent
TOTorrent torrent_to_send = TOTorrentFactory.deserialiseFromMap(torrent.serialiseToMap());
// remove any non-standard stuff (e.g. resume data)
torrent_to_send.removeAdditionalProperties();
if (!TorrentUtils.isDecentralised(torrent_to_send)) {
URL[][] url_sets = TRTrackerUtils.getAnnounceURLs();
if (host_torrent.getStatus() != TRHostTorrent.TS_PUBLISHED && url_sets.length > 0) {
if (COConfigurationManager.getBooleanParameter("Tracker Host Add Our Announce URLs")) {
String protocol = torrent_to_send.getAnnounceURL().getProtocol();
for (int i = 0; i < url_sets.length; i++) {
URL[] urls = url_sets[i];
if (urls[0].getProtocol().equalsIgnoreCase(protocol)) {
torrent_to_send.setAnnounceURL(urls[0]);
torrent_to_send.getAnnounceURLGroup().setAnnounceURLSets(new TOTorrentAnnounceURLSet[0]);
for (int j = 1; j < urls.length; j++) {
TorrentUtils.announceGroupsInsertLast(torrent_to_send, new URL[] { urls[j] });
}
break;
}
}
}
}
}
baos.write(BEncoder.encode(torrent_to_send.serialiseToMap()));
setContentType("application/x-bittorrent");
} catch (TOTorrentException e) {
Debug.printStackTrace(e);
throw (new IOException(e.toString()));
}
}
Aggregations