Package com.biglybt.ui.console
Class ConsoleInput
- java.lang.Object
-
- java.lang.Thread
-
- com.biglybt.ui.console.ConsoleInput
-
- All Implemented Interfaces:
java.lang.Runnable
- Direct Known Subclasses:
MultiUserConsoleInput
public class ConsoleInput extends java.lang.Thread
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
ConsoleInput.CommandEcho
private class
ConsoleInput.CommandHelp
private class
ConsoleInput.CommandLogging
private static class
ConsoleInput.CommandLogout
private static class
ConsoleInput.CommandQuit
private static class
ConsoleInput.CommandUI
private class
ConsoleInput.RedirectOutputStream
-
Field Summary
Fields Modifier and Type Field Description java.io.File[]
adds
java.util.Properties
aliases
private static java.lang.String
ALIASES_CONFIG_FILE
private CommandReader
br
private java.util.Map
commands
private boolean
controlling
Core
core
private ConsoleInput.RedirectOutputStream
current_ros
private java.util.List<LogEvent>
errorLogEvents
private java.util.List
helpItems
private int
numNewErrorLogEvents
private java.util.Vector
oldcommand
java.io.PrintStream
out
private static java.util.List
pluginCommands
protected boolean
running
java.util.List
torrents
private UserProfile
userProfile
private boolean
waitingForInput
-
Constructor Summary
Constructors Constructor Description ConsoleInput(Core core, java.io.PrintStream _out)
Simple constructor to allow other components to use the console commands such as "set"ConsoleInput(java.lang.String con, Core _core, java.io.InputStream _in, java.io.PrintStream _out, java.lang.Boolean _controlling)
ConsoleInput(java.lang.String con, Core _core, java.io.Reader _in, java.io.PrintStream _out, java.lang.Boolean _controlling)
Creates a new instance of ConsoleInputConsoleInput(java.lang.String con, Core _core, java.io.Reader _in, java.io.PrintStream _out, java.lang.Boolean _controlling, UserProfile profile)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
downloadRemoteTorrent(java.lang.String url)
downloads the remote torrent file.void
downloadRemoteTorrent(java.lang.String url, java.lang.String outputDir)
downloads the remote torrent file.void
downloadTorrent(java.lang.String fileName)
downloads a torrent on the local file system to the default save directoryvoid
downloadTorrent(java.lang.String filename, java.lang.String outputDir)
begins the download of the torrent in the specified file, downloading it to the specified output directory.private java.io.File
getAliasesFile()
Core
getCore()
java.lang.String
getDefaultSaveDirectory()
returns the default directory that torrents should be saved to unless otherwise specifiedjava.util.List<LogEvent>
getErrorLogEvents()
GlobalManager
getGlobalManager()
UserProfile
getUserProfile()
protected void
initialise()
boolean
invokeCommand(java.lang.String command, java.util.List cargs)
private void
loadAliases()
read in the aliases from the alias properties filevoid
printconsolehelp()
private void
printconsolehelp(java.io.PrintStream os)
void
printwelcome()
private void
quit(boolean finish)
protected void
registerAlertHandler()
protected void
registerCommand(IConsoleCommand command)
protected void
registerCommands()
registers the commands available to be executed from this consolestatic void
registerPluginCommand(java.lang.Class clazz)
can be used by plugins to register console commands since they may not have access to each ConsoleInput object that is created.private void
registerPluginCommands()
instantiates each of the plugin commands and registers tprotected void
registerUpdateChecker()
void
run()
void
saveAliases()
writes the aliases back out to the alias fileprotected void
unregisterCommand(IConsoleCommand command)
protected void
unregisterCommand(java.lang.String commandName)
static void
unregisterPluginCommand(java.lang.Class clazz)
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
ALIASES_CONFIG_FILE
private static final java.lang.String ALIASES_CONFIG_FILE
- See Also:
- Constant Field Values
-
core
public final Core core
-
out
public volatile java.io.PrintStream out
-
current_ros
private ConsoleInput.RedirectOutputStream current_ros
-
torrents
public final java.util.List torrents
-
adds
public java.io.File[] adds
-
br
private final CommandReader br
-
controlling
private final boolean controlling
-
running
protected boolean running
-
oldcommand
private final java.util.Vector oldcommand
-
pluginCommands
private static final java.util.List pluginCommands
-
aliases
public final java.util.Properties aliases
-
commands
private final java.util.Map commands
-
helpItems
private final java.util.List helpItems
-
userProfile
private final UserProfile userProfile
-
errorLogEvents
private final java.util.List<LogEvent> errorLogEvents
-
numNewErrorLogEvents
private int numNewErrorLogEvents
-
waitingForInput
private boolean waitingForInput
-
-
Constructor Detail
-
ConsoleInput
public ConsoleInput(java.lang.String con, Core _core, java.io.Reader _in, java.io.PrintStream _out, java.lang.Boolean _controlling)
Creates a new instance of ConsoleInput
-
ConsoleInput
public ConsoleInput(java.lang.String con, Core _core, java.io.Reader _in, java.io.PrintStream _out, java.lang.Boolean _controlling, UserProfile profile)
-
ConsoleInput
public ConsoleInput(Core core, java.io.PrintStream _out)
Simple constructor to allow other components to use the console commands such as "set"- Parameters:
core
-_out
-
-
ConsoleInput
public ConsoleInput(java.lang.String con, Core _core, java.io.InputStream _in, java.io.PrintStream _out, java.lang.Boolean _controlling)
-
-
Method Detail
-
registerPluginCommand
public static void registerPluginCommand(java.lang.Class clazz)
can be used by plugins to register console commands since they may not have access to each ConsoleInput object that is created.
-
unregisterPluginCommand
public static void unregisterPluginCommand(java.lang.Class clazz)
-
initialise
protected void initialise()
-
downloadTorrent
public void downloadTorrent(java.lang.String filename, java.lang.String outputDir)
begins the download of the torrent in the specified file, downloading it to the specified output directory. We also annotate the download with the current username- Parameters:
filename
-outputDir
-
-
downloadRemoteTorrent
public void downloadRemoteTorrent(java.lang.String url, java.lang.String outputDir)
downloads the remote torrent file. once we have downloaded the .torrent file, we pass the data to the downloadTorrent() method for further processing- Parameters:
url
-outputDir
-
-
downloadTorrent
public void downloadTorrent(java.lang.String fileName)
downloads a torrent on the local file system to the default save directory- Parameters:
fileName
-
-
downloadRemoteTorrent
public void downloadRemoteTorrent(java.lang.String url)
downloads the remote torrent file. once we have downloaded the .torrent file, we pass the data to the downloadTorrent() method for further processing
-
registerPluginCommands
private void registerPluginCommands()
instantiates each of the plugin commands and registers t
-
registerAlertHandler
protected void registerAlertHandler()
-
registerCommands
protected void registerCommands()
registers the commands available to be executed from this console
-
registerCommand
protected void registerCommand(IConsoleCommand command)
- Parameters:
set
-
-
unregisterCommand
protected void unregisterCommand(IConsoleCommand command)
-
unregisterCommand
protected void unregisterCommand(java.lang.String commandName)
-
quit
private void quit(boolean finish)
-
printwelcome
public void printwelcome()
-
printconsolehelp
public void printconsolehelp()
-
printconsolehelp
private void printconsolehelp(java.io.PrintStream os)
-
invokeCommand
public boolean invokeCommand(java.lang.String command, java.util.List cargs)
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
-
getAliasesFile
private java.io.File getAliasesFile()
-
loadAliases
private void loadAliases() throws java.io.IOException
read in the aliases from the alias properties file- Throws:
java.io.IOException
-
saveAliases
public void saveAliases()
writes the aliases back out to the alias file
-
getUserProfile
public UserProfile getUserProfile()
- Returns:
- Returns the userProfile.
-
getDefaultSaveDirectory
public java.lang.String getDefaultSaveDirectory()
returns the default directory that torrents should be saved to unless otherwise specified- Returns:
-
registerUpdateChecker
protected void registerUpdateChecker()
-
getCore
public Core getCore()
-
getGlobalManager
public GlobalManager getGlobalManager()
-
getErrorLogEvents
public java.util.List<LogEvent> getErrorLogEvents()
-
-