Search in sources :

Example 1 with DownloadStub

use of com.biglybt.pif.download.DownloadStub in project BiglyBT by BiglySoftware.

the class SBC_ArchivedDownloadsView method toolBarItemActivated.

@Override
public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
    if (tv == null || !tv.isVisible()) {
        return (false);
    }
    List<Object> datasources = tv.getSelectedDataSources();
    if (datasources.size() > 0) {
        List<DownloadStub> dms = new ArrayList<>(datasources.size());
        for (Object o : datasources) {
            dms.add((DownloadStub) o);
        }
        String id = item.getID();
        if (id.equals("remove")) {
            TorrentUtil.removeDataSources(datasources.toArray());
        } else if (id.equals("startstop") || id.equals("start")) {
            ManagerUtils.restoreFromArchive(dms, true, null);
        }
        return true;
    }
    return false;
}
Also used : DownloadStub(com.biglybt.pif.download.DownloadStub) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject)

Example 2 with DownloadStub

use of com.biglybt.pif.download.DownloadStub in project BiglyBT by BiglySoftware.

the class ManagerUtils method moveToArchive.

public static void moveToArchive(final List<Download> downloads, ArchiveCallback _run_when_complete) {
    final ArchiveCallback run_when_complete = _run_when_complete == null ? new ArchiveCallback() : _run_when_complete;
    Utils.getOffOfSWTThread(new AERunnable() {

        @Override
        public void runSupport() {
            try {
                String title = MessageText.getString("archive.info.title");
                String text = MessageText.getString("archive.info.text");
                MessageBoxShell prompter = new MessageBoxShell(title, text, new String[] { MessageText.getString("Button.ok") }, 0);
                String remember_id = "managerutils.archive.info";
                prompter.setRemember(remember_id, true, MessageText.getString("MessageBoxWindow.nomoreprompting"));
                prompter.setAutoCloseInMS(0);
                prompter.open(null);
                prompter.waitUntilClosed();
                for (Download dm : downloads) {
                    try {
                        DownloadStub stub = dm.stubbify();
                        run_when_complete.success(dm, stub);
                    } catch (Throwable e) {
                        run_when_complete.failed(dm, e);
                        Debug.out(e);
                    }
                }
            } finally {
                run_when_complete.completed();
            }
        }
    });
}
Also used : DownloadStub(com.biglybt.pif.download.DownloadStub) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell) Download(com.biglybt.pif.download.Download)

Example 3 with DownloadStub

use of com.biglybt.pif.download.DownloadStub in project BiglyBT by BiglySoftware.

the class Archive method execute.

@Override
public void execute(String commandName, ConsoleInput ci, List<String> args) {
    if (args.size() > 0) {
        PluginInterface pi = ci.getCore().getPluginManager().getDefaultPluginInterface();
        DownloadStub[] stubs = pi.getDownloadManager().getDownloadStubs();
        String sub = args.get(0);
        int index = -1;
        if (args.size() > 1) {
            String index_str = args.get(1);
            try {
                index = Integer.parseInt(index_str);
                index--;
                if (index < 0 || index >= stubs.length) {
                    index = -1;
                }
            } catch (Throwable e) {
            }
            if (index == -1) {
                ci.out.println("Invalid archive index: " + index_str);
            }
        }
        if (sub.equals("list") || sub.equals("l")) {
            int pos = 1;
            ci.out.println("> -----");
            for (DownloadStub stub : stubs) {
                System.out.println(" " + (pos++) + "\t" + stub.getName() + " (" + DisplayFormatters.formatByteCountToKiBEtc(stub.getTorrentSize()) + ")");
            }
            ci.out.println("> -----");
        } else if (index != -1 && (sub.equals("show") || sub.equals("s"))) {
            try {
                DownloadStub stub = stubs[index];
                ci.out.println("> -----");
                ci.out.println("  " + stub.getName() + " - hash=" + ByteFormatter.encodeString(stub.getTorrentHash()));
                DownloadStubFile[] files = stub.getStubFiles();
                ci.out.println("  Files: " + files.length);
                for (DownloadStubFile file : files) {
                    long length = file.getLength();
                    ci.out.println("    " + file.getFile() + " - " + (length < 0 ? ("Not downloaded") : DisplayFormatters.formatByteCountToKiBEtc(length)));
                }
                ci.out.println("> -----");
            } catch (Throwable e) {
                ci.out.print(e);
            }
        } else if (index != -1 && (sub.equals("restore") || sub.equals("res"))) {
            try {
                Download d = stubs[index].destubbify();
                ci.out.println("> Restore of " + d.getName() + " succeeded.");
            } catch (Throwable e) {
                ci.out.print(e);
            }
        } else if (index != -1 && (sub.equals("delete") || sub.equals("del"))) {
            try {
                DownloadStub stub = stubs[index];
                String name = stub.getName();
                stub.remove();
                ci.out.println("> Delete of " + name + " succeeded.");
            } catch (Throwable e) {
                ci.out.print(e);
            }
        } else {
            ci.out.println("Unsupported sub-command: " + sub);
            return;
        }
    } else {
        printHelp(ci.out, args);
    }
}
Also used : DownloadStub(com.biglybt.pif.download.DownloadStub) DownloadStubFile(com.biglybt.pif.download.DownloadStub.DownloadStubFile) PluginInterface(com.biglybt.pif.PluginInterface) Download(com.biglybt.pif.download.Download)

Example 4 with DownloadStub

use of com.biglybt.pif.download.DownloadStub in project BiglyBT by BiglySoftware.

the class ColumnArchiveDLFileCount method refresh.

@Override
public void refresh(TableCell cell) {
    DownloadStub dl = (DownloadStub) cell.getDataSource();
    long count = 0;
    if (dl != null) {
        count = dl.getStubFiles().length;
    }
    if (!cell.setSortValue(count) && cell.isValid()) {
    // return;
    }
    if (!cell.isShown()) {
        return;
    }
    cell.setText(String.valueOf(count));
}
Also used : DownloadStub(com.biglybt.pif.download.DownloadStub)

Example 5 with DownloadStub

use of com.biglybt.pif.download.DownloadStub in project BiglyBT by BiglySoftware.

the class ColumnArchiveDLName method refresh.

@Override
public void refresh(TableCell cell) {
    DownloadStub dl = (DownloadStub) cell.getDataSource();
    String name = null;
    if (dl != null) {
        name = dl.getName();
    }
    if (name == null) {
        name = "";
    }
    if (!cell.setSortValue(name) && cell.isValid()) {
        return;
    }
    if (!cell.isShown()) {
        return;
    }
    cell.setText(name);
}
Also used : DownloadStub(com.biglybt.pif.download.DownloadStub)

Aggregations

DownloadStub (com.biglybt.pif.download.DownloadStub)9 Download (com.biglybt.pif.download.Download)3 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)3 DownloadManager (com.biglybt.core.download.DownloadManager)2 DownloadHistoryManager (com.biglybt.core.history.DownloadHistoryManager)2 PluginInterface (com.biglybt.pif.PluginInterface)2 DownloadStubFile (com.biglybt.pif.download.DownloadStub.DownloadStubFile)2 DownloadStubEvent (com.biglybt.pif.download.DownloadStubEvent)2 DownloadStubListener (com.biglybt.pif.download.DownloadStubListener)2 File (java.io.File)2 Core (com.biglybt.core.Core)1 ParameterListener (com.biglybt.core.config.ParameterListener)1 GlobalManager (com.biglybt.core.global.GlobalManager)1 DownloadHistoryEvent (com.biglybt.core.history.DownloadHistoryEvent)1 DownloadHistoryListener (com.biglybt.core.history.DownloadHistoryListener)1 TOTorrent (com.biglybt.core.torrent.TOTorrent)1 TRHost (com.biglybt.core.tracker.host.TRHost)1 TRHostListener (com.biglybt.core.tracker.host.TRHostListener)1 TRHostTorrent (com.biglybt.core.tracker.host.TRHostTorrent)1 AsyncController (com.biglybt.core.util.AsyncController)1