Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.util.launchutils
Class LaunchArgHandler

java.lang.Object
  extended by net.java.sip.communicator.util.launchutils.LaunchArgHandler

public class LaunchArgHandler
extends Object

The LauncherArgHandler class handles invocation arguments that have been passed to us when running SIP Communicator. The class supports a fixed set of options and also allows for registration of delegates.

Author:
Emil Ivov

Field Summary
static int ACTION_CONTINUE
          Returned by the handleArgs methods when all arguments have been parsed and the SIP Communicator launch can continue.
static int ACTION_CONTINUE_LOCK_DISABLED
          Returned by the handleArgs methods when all arguments have been successfully parsed and one of them indicates that the user has requested a multi instance launch.
static int ACTION_ERROR
          Returned by the handleArgs method when parsing the arguments has failed or if no arguments were passed and an instance of SC was already launched.
static int ACTION_EXIT
          Returned by the handleArgs methods when the arguments that have been parsed do not require for SIP Communicator to be started and the Launcher is supposed to exit.
static int ERROR_CODE_ALREADY_STARTED
          The error code returned when we try to launch SIP Communicator while there is already a running instance and there were no arguments that we forward to that instance.
static int ERROR_CODE_CREATE_DIR_FAILED
          The error code that we return when we fail to create a directory that has been specified with the -c|--config option.
static int ERROR_CODE_UNKNOWN_ARG
          The error code returned when we couldn't parse one of the options.
 
Method Summary
 int getErrorCode()
          Returns an error code that could help identify an error when handleArgs returns ACTION_ERROR or 0 if everything went fine.
static LaunchArgHandler getInstance()
          Creates a singleton instance of the LauncherArgHandler if necessary and returns a reference to it.
 int handleArgs(String[] args)
          Does the actual argument handling.
 void handleConcurrentInvocationRequestArgs(String[] args)
          Called when the user has tried to launch a second instance of SIP Communicator while a first one was already running.
 void handleHelpArg()
          Prints a help message containing usage instructions and descriptions of all options currently supported by Jitsi.
 void handleUnknownArg(String arg)
          Prints an error message and then prints the help message.
 void setDelegationPeer(ArgDelegationPeer delegationPeer)
          Sets the delegationPeer that would be handling all URIs passed as command line arguments to SIP Communicator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_EXIT

public static final int ACTION_EXIT
Returned by the handleArgs methods when the arguments that have been parsed do not require for SIP Communicator to be started and the Launcher is supposed to exit. That could happen when "SIP Communicator" is launched with a --version argument for example or when trying to run the application after an instance was already launched.

See Also:
Constant Field Values

ACTION_CONTINUE

public static final int ACTION_CONTINUE
Returned by the handleArgs methods when all arguments have been parsed and the SIP Communicator launch can continue.

See Also:
Constant Field Values

ACTION_ERROR

public static final int ACTION_ERROR
Returned by the handleArgs method when parsing the arguments has failed or if no arguments were passed and an instance of SC was already launched. If this is the code returned by handleArgs, then the getErrorCode method would return an error code indicating what the error was.

See Also:
Constant Field Values

ACTION_CONTINUE_LOCK_DISABLED

public static final int ACTION_CONTINUE_LOCK_DISABLED
Returned by the handleArgs methods when all arguments have been successfully parsed and one of them indicates that the user has requested a multi instance launch.

See Also:
Constant Field Values

ERROR_CODE_UNKNOWN_ARG

public static final int ERROR_CODE_UNKNOWN_ARG
The error code returned when we couldn't parse one of the options.

See Also:
Constant Field Values

ERROR_CODE_ALREADY_STARTED

public static final int ERROR_CODE_ALREADY_STARTED
The error code returned when we try to launch SIP Communicator while there is already a running instance and there were no arguments that we forward to that instance.

See Also:
Constant Field Values

ERROR_CODE_CREATE_DIR_FAILED

public static final int ERROR_CODE_CREATE_DIR_FAILED
The error code that we return when we fail to create a directory that has been specified with the -c|--config option.

See Also:
Constant Field Values
Method Detail

getInstance

public static LaunchArgHandler getInstance()
Creates a singleton instance of the LauncherArgHandler if necessary and returns a reference to it.

Returns:
the singleton instance of the LauncherArgHandler.

handleArgs

public int handleArgs(String[] args)
Does the actual argument handling.

Parameters:
args - the arguments the way we have received them from the main() method.
Returns:
one of the ACTION_XXX fields defined here, intended to indicate to the caller they action that they are supposed as a result of the arg handling.

handleUnknownArg

public void handleUnknownArg(String arg)
Prints an error message and then prints the help message.

Parameters:
arg - the unknown argument we need to print

handleHelpArg

public void handleHelpArg()
Prints a help message containing usage instructions and descriptions of all options currently supported by Jitsi.


getErrorCode

public int getErrorCode()
Returns an error code that could help identify an error when handleArgs returns ACTION_ERROR or 0 if everything went fine.

Returns:
an error code that could help identify an error when handleArgs returns ACTION_ERROR or 0 if everything went fine.

setDelegationPeer

public void setDelegationPeer(ArgDelegationPeer delegationPeer)
Sets the delegationPeer that would be handling all URIs passed as command line arguments to SIP Communicator.

Parameters:
delegationPeer - the delegationPeer that should handle URIs or null if we'd like to unset a previously set peer.

handleConcurrentInvocationRequestArgs

public void handleConcurrentInvocationRequestArgs(String[] args)
Called when the user has tried to launch a second instance of SIP Communicator while a first one was already running. This method only handles arguments that need to be handled by a running instance of SIP Communicator assuming that simple ones such as "--version" or "--help" have been handled by the calling instance.

Parameters:
args - the args that we need to handle.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.