Search in sources :

Example 1 with TRHostTorrent

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);
}
Also used : TRHostTorrent(com.biglybt.core.tracker.host.TRHostTorrent) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 2 with TRHostTorrent

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);
}
Also used : TRHostTorrent(com.biglybt.core.tracker.host.TRHostTorrent)

Example 3 with TRHostTorrent

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);
    }
}
Also used : Category(com.biglybt.core.category.Category) TOTorrent(com.biglybt.core.torrent.TOTorrent) TRHostTorrent(com.biglybt.core.tracker.host.TRHostTorrent) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 4 with TRHostTorrent

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) {
            }
        }
    }
}
Also used : TableCellSWT(com.biglybt.ui.swt.views.table.TableCellSWT) TOTorrent(com.biglybt.core.torrent.TOTorrent) TRHostTorrent(com.biglybt.core.tracker.host.TRHostTorrent) Image(org.eclipse.swt.graphics.Image)

Example 5 with TRHostTorrent

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()));
    }
}
Also used : TOTorrentException(com.biglybt.core.torrent.TOTorrentException) TOTorrent(com.biglybt.core.torrent.TOTorrent) TRHostTorrent(com.biglybt.core.tracker.host.TRHostTorrent) URL(java.net.URL)

Aggregations

TRHostTorrent (com.biglybt.core.tracker.host.TRHostTorrent)19 TOTorrent (com.biglybt.core.torrent.TOTorrent)6 DownloadManager (com.biglybt.core.download.DownloadManager)5 TRHost (com.biglybt.core.tracker.host.TRHost)4 TOTorrentException (com.biglybt.core.torrent.TOTorrentException)3 CoreRunningListener (com.biglybt.core.CoreRunningListener)2 TRHostException (com.biglybt.core.tracker.host.TRHostException)2 TRHostListener (com.biglybt.core.tracker.host.TRHostListener)2 UIFunctions (com.biglybt.ui.UIFunctions)2 File (java.io.File)2 Core (com.biglybt.core.Core)1 Category (com.biglybt.core.category.Category)1 CategoryManagerListener (com.biglybt.core.category.CategoryManagerListener)1 ParameterListener (com.biglybt.core.config.ParameterListener)1 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)1 DownloadHistoryEvent (com.biglybt.core.history.DownloadHistoryEvent)1 DownloadHistoryListener (com.biglybt.core.history.DownloadHistoryListener)1 DownloadHistoryManager (com.biglybt.core.history.DownloadHistoryManager)1 PEPeer (com.biglybt.core.peer.PEPeer)1 PEPeerManager (com.biglybt.core.peer.PEPeerManager)1