org.stanwood.media.store.mp4.itunes
Class ITunesRemoteClient

java.lang.Object
  extended by java.lang.Thread
      extended by org.stanwood.media.store.mp4.itunes.ITunesRemoteClient
All Implemented Interfaces:
java.lang.Runnable

public class ITunesRemoteClient
extends java.lang.Thread

This is a client to the iTunes control server. It is used to send and receive messages. Details of the server can be found at "http://code.google.com/p/itunes-remote-control-server/".


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static java.lang.String CMD_ADD_FILES
          The ADDFILES command text
static java.lang.String CMD_CLEAR_FILES
          The CLEARFILES command text
static java.lang.String CMD_FILE
          The FILE command text
static java.lang.String CMD_HELO
          The HELO command text
static java.lang.String CMD_LIST_DEAD_FILES
          The LISTDEADFILES command text
static java.lang.String CMD_LOGIN
          The LOGIN command text
static java.lang.String CMD_PASSWORD
          The PASSWORD command text
static java.lang.String CMD_QUIT
          The QUIT command text
static java.lang.String CMD_REFRESH_FILES
          The REFRESHFILES command text
static java.lang.String CMD_REMOVE_DEAD_FILES
          The REMOVEDEADFILES command text
static java.lang.String CMD_REMOVE_FILES
          The REMOVEFILES command text
static long DEFAULT_TIMEOUT
          The default timeout for commands that don't take a long time in seconds
static long NO_TIMEOUT
          This can be used if no timeout is requried
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ITunesRemoteClient()
          The constructor
 
Method Summary
 void connect(java.net.InetAddress hostname, int port)
          Used to connect to the server
 void disconnect()
          Used to disconnect from the server
 void login(java.lang.String username, java.lang.String password)
          Used to login to the server
 void run()
          
 void sendCommand(java.lang.String cmd, int expectedCode, long timeout)
          Used to send a command to the server
protected  void waitForCode(java.lang.String cmd, int expectedCode, long timeout)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_TIMEOUT

public static final long DEFAULT_TIMEOUT
The default timeout for commands that don't take a long time in seconds

See Also:
Constant Field Values

NO_TIMEOUT

public static final long NO_TIMEOUT
This can be used if no timeout is requried

See Also:
Constant Field Values

CMD_HELO

public static final java.lang.String CMD_HELO
The HELO command text

See Also:
Constant Field Values

CMD_QUIT

public static final java.lang.String CMD_QUIT
The QUIT command text

See Also:
Constant Field Values

CMD_LOGIN

public static final java.lang.String CMD_LOGIN
The LOGIN command text

See Also:
Constant Field Values

CMD_PASSWORD

public static final java.lang.String CMD_PASSWORD
The PASSWORD command text

See Also:
Constant Field Values

CMD_CLEAR_FILES

public static final java.lang.String CMD_CLEAR_FILES
The CLEARFILES command text

See Also:
Constant Field Values

CMD_ADD_FILES

public static final java.lang.String CMD_ADD_FILES
The ADDFILES command text

See Also:
Constant Field Values

CMD_REMOVE_FILES

public static final java.lang.String CMD_REMOVE_FILES
The REMOVEFILES command text

See Also:
Constant Field Values

CMD_REMOVE_DEAD_FILES

public static final java.lang.String CMD_REMOVE_DEAD_FILES
The REMOVEDEADFILES command text

See Also:
Constant Field Values

CMD_LIST_DEAD_FILES

public static final java.lang.String CMD_LIST_DEAD_FILES
The LISTDEADFILES command text

See Also:
Constant Field Values

CMD_REFRESH_FILES

public static final java.lang.String CMD_REFRESH_FILES
The REFRESHFILES command text

See Also:
Constant Field Values

CMD_FILE

public static final java.lang.String CMD_FILE
The FILE command text

See Also:
Constant Field Values
Constructor Detail

ITunesRemoteClient

public ITunesRemoteClient()
The constructor

Method Detail

connect

public void connect(java.net.InetAddress hostname,
                    int port)
             throws StoreException
Used to connect to the server

Parameters:
hostname - The hostname of the server
port - The port number of the host
Throws:
StoreException - Thrown if their is a problem

login

public void login(java.lang.String username,
                  java.lang.String password)
           throws StoreException
Used to login to the server

Parameters:
username - The username of the user connecting to the server
password - The password of the user connecting to the server
Throws:
StoreException - Thrown if their is a problem

run

public void run()

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

sendCommand

public void sendCommand(java.lang.String cmd,
                        int expectedCode,
                        long timeout)
                 throws StoreException
Used to send a command to the server

Parameters:
cmd - The command to set to the server
expectedCode - The expected return code if their are no errors
timeout - the timeout in seconds, or -1 for no timeout
Throws:
StoreException - Thrown if their is a problem

waitForCode

protected void waitForCode(java.lang.String cmd,
                           int expectedCode,
                           long timeout)
                    throws StoreException
Throws:
StoreException

disconnect

public void disconnect()
Used to disconnect from the server