Search in sources :

Example 11 with TRHostTorrent

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]);
            }
        }
    }
}
Also used : TableRowSWT(com.biglybt.ui.swt.views.table.TableRowSWT) UIFunctions(com.biglybt.ui.UIFunctions) Color(org.eclipse.swt.graphics.Color) TRHostTorrent(com.biglybt.core.tracker.host.TRHostTorrent)

Example 12 with TRHostTorrent

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

Example 13 with TRHostTorrent

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

Example 14 with TRHostTorrent

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

Example 15 with TRHostTorrent

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

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