📄 priority.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: Priority.java
package org.gudy.azureus2.ui.console.commands;
import java.io.PrintStream;
import java.util.LinkedList;
import java.util.List;
import org.apache.commons.cli.CommandLine;
import org.gudy.azureus2.core3.disk.DiskManagerFileInfo;
import org.gudy.azureus2.core3.download.DownloadManager;
import org.gudy.azureus2.ui.console.ConsoleInput;
// Referenced classes of package org.gudy.azureus2.ui.console.commands:
// OptionsConsoleCommand
public class Priority extends OptionsConsoleCommand
{
private static final int NORMAL = 1;
private static final int HIGH = 2;
private static final int DONOTDOWNLOAD = 3;
private static final int DELETE = 4;
private static final String priostr[] = {
"Normal", "High", "DoNotDownload", "Delete"
};
private int newprio;
public Priority()
{
super("prio");
}
public String getCommandDescriptions()
{
return "prio [#torrent] [#file|range(i.e. 1-2,5)|all] [normal|high|dnd|del]";
}
public void printHelpExtra(PrintStream out, List args)
{
out.println("> -----");
out.println("Usage: prio [torrent] [file(s)] [priority]");
out.println("Options:");
out.println("\t[torrent]\tThe torrent number from 'show torrents'");
out.println("\t[file(s)] is one of:");
out.println("\t\t\t#file:\tthe file number from 'show [#torrent]',");
out.println("\t\t\trange:\ta range of file numbers, i.e. 1-3 or 1-10,12-15 or 1,3,5-8 ,");
out.println("\t\t\tall:\t 'all' applies priority to all files of the torrent");
out.println("\t[priority] is one of:");
out.println("\t\t\tnormal\tNormal priority");
out.println("\t\t\thigh \tHigh priority");
out.println("\t\t\tdnd \tDo not download (skip)");
out.println("\t\t\tdel \tDo not download & delete file");
out.println("> -----");
}
public void execute(String commandName, ConsoleInput console, CommandLine commandLine)
{
String fnumstr;
int tnumber;
DiskManagerFileInfo files[];
List args;
DownloadManager dm;
args = commandLine.getArgList();
if (args.isEmpty())
{
console.out.println("Torrent # required!");
return;
}
String tnumstr = (String)args.remove(0);
if (args.isEmpty())
{
console.out.println("File # required!");
return;
}
fnumstr = (String)args.remove(0);
if (console.torrents == null || console.torrents.isEmpty())
{
console.out.println("> Command 'prio': No torrents in list (try 'show torrents' first).");
return;
}
try
{
tnumber = Integer.parseInt(tnumstr);
if (tnumber == 0 || tnumber > console.torrents.size())
{
console.out.println((new StringBuilder()).append("> Command 'prio': Torrent #").append(tnumber).append(" unknown.").toString());
return;
}
}
catch (Exception e)
{
e.printStackTrace();
console.out.println((new StringBuilder()).append("> Command 'prio': Torrent # '").append(tnumstr).append("' unknown.").toString());
return;
}
dm = (DownloadManager)console.torrents.get(tnumber - 1);
files = dm.getDiskManagerFileInfo();
String sections[];
LinkedList fs;
LinkedList fe;
int i;
if (args.isEmpty())
{
console.out.println("> Command 'prio': missing parameter for new priority");
return;
}
String newpriostr = (String)args.remove(0);
if (newpriostr.equalsIgnoreCase("normal"))
newprio = 1;
else
if (newpriostr.equalsIgnoreCase("high"))
newprio = 2;
else
if (newpriostr.equalsIgnoreCase("dnd"))
newprio = 3;
else
if (newpriostr.equalsIgnoreCase("del"))
{
newprio = 4;
} else
{
console.out.println((new StringBuilder()).append("> Command 'prio': unknown priority ").append(newpriostr).toString());
return;
}
if (fnumstr.equalsIgnoreCase("all"))
{
sections = new String[1];
sections[0] = (new StringBuilder()).append("1-").append(files.length).toString();
} else
{
sections = fnumstr.split(",");
}
fs = new LinkedList();
fe = new LinkedList();
i = 0;
_L2:
if (i >= sections.length)
break; /* Loop/switch isn't completed */
int start;
int end;
try
{
int dash;
if ((dash = sections[i].indexOf('-')) != -1)
{
start = Integer.parseInt(sections[i].substring(0, dash));
end = Integer.parseInt(sections[i].substring(dash + 1));
} else
{
start = end = Integer.parseInt(sections[i]);
}
if (start == 0 || end > files.length)
{
console.out.println((new StringBuilder()).append("> Command 'prio': Invalid file range ").append(sections[i]).toString());
return;
}
}
catch (Exception e)
{
console.out.println((new StringBuilder()).append("> Command 'prio': File # '").append(sections[i]).append("' unknown.").toString());
return;
}
if (start > end)
console.out.println((new StringBuilder()).append("> Command 'prio': Invalid file range '").append(sections[i]).append("'").toString());
fs.add(new Integer(start - 1));
fe.add(new Integer(end - 1));
i++;
if (true) goto _L2; else goto _L1
_L1:
if (newprio == 4 && dm.getState() != 70)
try
{
dm.stopIt(70, false, false);
}
catch (Exception e)
{
console.out.println((new StringBuilder()).append("Failed to stop torrent ").append(tnumber).toString());
return;
}
int nummod = 0;
while (fs.size() > 0)
{
int start = ((Integer)fs.removeFirst()).intValue();
int end = ((Integer)fe.removeFirst()).intValue();
int i = start;
while (i <= end)
{
nummod++;
if (newprio == 1)
{
files[i].setPriority(false);
files[i].setSkipped(false);
} else
if (newprio == 2)
{
files[i].setPriority(true);
files[i].setSkipped(false);
} else
if (newprio == 3)
{
files[i].setPriority(false);
files[i].setSkipped(true);
} else
if (newprio == 4)
if (files[i].setStorageType(2))
{
files[i].setPriority(false);
files[i].setSkipped(true);
} else
{
console.out.println((new StringBuilder()).append("> Command 'prio': Failed to delete file ").append(i + 1).toString());
nummod--;
}
i++;
}
}
if (newprio == 4 && dm.getState() == 70)
try
{
dm.stopIt(75, false, false);
}
catch (Exception e)
{
console.out.println((new StringBuilder()).append("Failed to restart torrent ").append(tnumber).toString());
return;
}
console.out.println((new StringBuilder()).append(nummod).append(" file(s) priority set to ").append(priostr[newprio - 1]).toString());
return;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -