use of com.biglybt.core.tracker.TrackerPeerSource in project BiglyBT by BiglySoftware.
the class TypeItem method refresh.
@Override
public void refresh(TableCell cell) {
TrackerPeerSource ps = (TrackerPeerSource) cell.getDataSource();
int value = (ps == null) ? TrackerPeerSource.TP_UNKNOWN : ps.getType();
if (!cell.setSortValue(value) && cell.isValid()) {
return;
}
cell.setText(js_resources[value]);
}
use of com.biglybt.core.tracker.TrackerPeerSource in project BiglyBT by BiglySoftware.
the class TRTrackerAnnouncerMuxer method getTrackerPeerSource.
@Override
public TrackerPeerSource getTrackerPeerSource(final TOTorrentAnnounceURLSet set) {
URL[] urls = set.getAnnounceURLs();
final String[] url_strs = new String[urls.length];
for (int i = 0; i < urls.length; i++) {
url_strs[i] = urls[i].toExternalForm();
}
return (new TrackerPeerSource() {
private StatusSummary _summary;
private boolean enabled;
private long fixup_time;
private StatusSummary fixup() {
long now = SystemTime.getMonotonousTime();
if (now - fixup_time > 1000) {
long most_recent = 0;
StatusSummary summary = null;
synchronized (TRTrackerAnnouncerMuxer.this) {
for (String str : url_strs) {
StatusSummary s = recent_responses.get(str);
if (s != null) {
if (summary == null || s.getTime() > most_recent) {
summary = s;
most_recent = s.getTime();
}
}
}
}
if (provider != null) {
enabled = provider.isPeerSourceEnabled(PEPeerSource.PS_BT_TRACKER);
}
if (summary != null) {
_summary = summary;
}
fixup_time = now;
}
return (_summary);
}
@Override
public int getType() {
return (TrackerPeerSource.TP_TRACKER);
}
@Override
public String getName() {
StatusSummary summary = fixup();
if (summary != null) {
String str = summary.getURL().toExternalForm();
int pos = str.indexOf('?');
if (pos != -1) {
str = str.substring(0, pos);
}
return (str);
}
return (url_strs[0]);
}
@Override
public String getDetails() {
return (null);
}
@Override
public URL getURL() {
StatusSummary summary = fixup();
if (summary != null) {
return (summary.getURL());
}
return (urls[0]);
}
@Override
public int getStatus() {
StatusSummary summary = fixup();
if (!enabled) {
return (ST_DISABLED);
}
if (summary != null) {
return (summary.getStatus());
}
return (ST_QUEUED);
}
@Override
public String getStatusString() {
StatusSummary summary = fixup();
if (summary != null && enabled) {
return (summary.getStatusString());
}
return (null);
}
@Override
public int getSeedCount() {
StatusSummary summary = fixup();
if (summary != null) {
return (summary.getSeedCount());
}
return (-1);
}
@Override
public int getLeecherCount() {
StatusSummary summary = fixup();
if (summary != null) {
return (summary.getLeecherCount());
}
return (-1);
}
@Override
public int getCompletedCount() {
StatusSummary summary = fixup();
if (summary != null) {
return (summary.getCompletedCount());
}
return (-1);
}
@Override
public int getPeers() {
StatusSummary summary = fixup();
if (summary != null) {
return (summary.getPeers());
}
return (-1);
}
@Override
public int getLastUpdate() {
StatusSummary summary = fixup();
if (summary != null) {
long time = summary.getTime();
if (time == 0) {
return (0);
}
long elapsed = SystemTime.getMonotonousTime() - time;
return ((int) ((SystemTime.getCurrentTime() - elapsed) / 1000));
}
return (0);
}
@Override
public int getSecondsToUpdate() {
StatusSummary summary = fixup();
if (summary != null) {
return (summary.getSecondsToUpdate());
}
return (Integer.MIN_VALUE);
}
@Override
public int getInterval() {
StatusSummary summary = fixup();
if (summary != null) {
return (summary.getInterval());
}
return (-1);
}
@Override
public int getMinInterval() {
StatusSummary summary = fixup();
if (summary != null && enabled) {
return (summary.getMinInterval());
}
return (-1);
}
@Override
public boolean isUpdating() {
StatusSummary summary = fixup();
if (summary != null && enabled) {
return (summary.isUpdating());
}
return (false);
}
@Override
public boolean canManuallyUpdate() {
StatusSummary summary = fixup();
if (summary == null) {
return (false);
}
return (summary.canManuallyUpdate());
}
@Override
public void manualUpdate() {
StatusSummary summary = fixup();
if (summary != null) {
summary.manualUpdate();
}
}
@Override
public long[] getReportedStats() {
StatusSummary summary = fixup();
if (summary != null && enabled) {
return (summary.getReportedStats());
}
return (null);
}
@Override
public boolean canDelete() {
return (false);
}
@Override
public void delete() {
Debug.out("derp");
}
});
}
Aggregations